ltmain.sh revision 44dda7b2
17a3b38f7Smrg# Generated from ltmain.m4sh. 27a3b38f7Smrg 344dda7b2Smrg# libtool (GNU libtool) 2.2.10 47a3b38f7Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 57a3b38f7Smrg 644dda7b2Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 744dda7b2Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 87a3b38f7Smrg# This is free software; see the source for copying conditions. There is NO 97a3b38f7Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 107a3b38f7Smrg 117a3b38f7Smrg# GNU Libtool is free software; you can redistribute it and/or modify 12ff559fabSmrg# it under the terms of the GNU General Public License as published by 13ff559fabSmrg# the Free Software Foundation; either version 2 of the License, or 14ff559fabSmrg# (at your option) any later version. 15ff559fabSmrg# 167a3b38f7Smrg# As a special exception to the GNU General Public License, 177a3b38f7Smrg# if you distribute this file as part of a program or library that 187a3b38f7Smrg# is built using GNU Libtool, you may include this file under the 197a3b38f7Smrg# same distribution terms that you use for the rest of that program. 207a3b38f7Smrg# 217a3b38f7Smrg# GNU Libtool is distributed in the hope that it will be useful, but 22ff559fabSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 23ff559fabSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24ff559fabSmrg# General Public License for more details. 25ff559fabSmrg# 26ff559fabSmrg# You should have received a copy of the GNU General Public License 277a3b38f7Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 287a3b38f7Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 297a3b38f7Smrg# or obtained by writing to the Free Software Foundation, Inc., 307a3b38f7Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 317a3b38f7Smrg 327a3b38f7Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 337a3b38f7Smrg# 347a3b38f7Smrg# Provide generalized library-building support services. 35ff559fabSmrg# 3644dda7b2Smrg# --config show all configuration variables 3744dda7b2Smrg# --debug enable verbose shell tracing 3844dda7b2Smrg# -n, --dry-run display commands without modifying any files 3944dda7b2Smrg# --features display basic configuration information and exit 4044dda7b2Smrg# --mode=MODE use operation mode MODE 4144dda7b2Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 4244dda7b2Smrg# --quiet, --silent don't print informational messages 4344dda7b2Smrg# --no-quiet, --no-silent 4444dda7b2Smrg# print informational messages (default) 4544dda7b2Smrg# --tag=TAG use configuration variables from tag TAG 4644dda7b2Smrg# -v, --verbose print more informational messages than default 4744dda7b2Smrg# --no-verbose don't print the extra informational messages 4844dda7b2Smrg# --version print version information 4944dda7b2Smrg# -h, --help, --help-all print short, long, or detailed help message 507a3b38f7Smrg# 517a3b38f7Smrg# MODE must be one of the following: 527a3b38f7Smrg# 5344dda7b2Smrg# clean remove files from the build directory 5444dda7b2Smrg# compile compile a source file into a libtool object 5544dda7b2Smrg# execute automatically set library path, then run a program 5644dda7b2Smrg# finish complete the installation of libtool libraries 5744dda7b2Smrg# install install libraries or executables 5844dda7b2Smrg# link create a library or an executable 5944dda7b2Smrg# uninstall remove libraries from an installed directory 607a3b38f7Smrg# 6144dda7b2Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 6244dda7b2Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 637a3b38f7Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 647a3b38f7Smrg# 657a3b38f7Smrg# When reporting a bug, please describe a test case to reproduce it and 667a3b38f7Smrg# include the following information: 677a3b38f7Smrg# 6844dda7b2Smrg# host-triplet: $host 6944dda7b2Smrg# shell: $SHELL 7044dda7b2Smrg# compiler: $LTCC 7144dda7b2Smrg# compiler flags: $LTCFLAGS 7244dda7b2Smrg# linker: $LD (gnu? $with_gnu_ld) 7344dda7b2Smrg# $progname: (GNU libtool) 2.2.10 7444dda7b2Smrg# automake: $automake_version 7544dda7b2Smrg# autoconf: $autoconf_version 767a3b38f7Smrg# 777a3b38f7Smrg# Report bugs to <bug-libtool@gnu.org>. 787a3b38f7Smrg 7944dda7b2SmrgPROGRAM=libtool 807a3b38f7SmrgPACKAGE=libtool 8144dda7b2SmrgVERSION=2.2.10 827a3b38f7SmrgTIMESTAMP="" 8344dda7b2Smrgpackage_revision=1.3175 847a3b38f7Smrg 857a3b38f7Smrg# Be Bourne compatible 867a3b38f7Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 877a3b38f7Smrg emulate sh 887a3b38f7Smrg NULLCMD=: 897a3b38f7Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 907a3b38f7Smrg # is contrary to our usage. Disable this feature. 917a3b38f7Smrg alias -g '${1+"$@"}'='"$@"' 927a3b38f7Smrg setopt NO_GLOB_SUBST 937a3b38f7Smrgelse 947a3b38f7Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 957a3b38f7Smrgfi 967a3b38f7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 977a3b38f7SmrgDUALCASE=1; export DUALCASE # for MKS sh 987a3b38f7Smrg 9944dda7b2Smrg# A function that is used when there is no print builtin or printf. 10044dda7b2Smrgfunc_fallback_echo () 10144dda7b2Smrg{ 10244dda7b2Smrg eval 'cat <<_LTECHO_EOF 10344dda7b2Smrg$1 10444dda7b2Smrg_LTECHO_EOF' 10544dda7b2Smrg} 10644dda7b2Smrg 1077a3b38f7Smrg# NLS nuisances: We save the old values to restore during execute mode. 1087a3b38f7Smrglt_user_locale= 1097a3b38f7Smrglt_safe_locale= 1107a3b38f7Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1117a3b38f7Smrgdo 1127a3b38f7Smrg eval "if test \"\${$lt_var+set}\" = set; then 1137a3b38f7Smrg save_$lt_var=\$$lt_var 1147a3b38f7Smrg $lt_var=C 1157a3b38f7Smrg export $lt_var 1167a3b38f7Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 1177a3b38f7Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 1187a3b38f7Smrg fi" 1197a3b38f7Smrgdone 12044dda7b2SmrgLC_ALL=C 12144dda7b2SmrgLANGUAGE=C 12244dda7b2Smrgexport LANGUAGE LC_ALL 1237a3b38f7Smrg 1247a3b38f7Smrg$lt_unset CDPATH 1257a3b38f7Smrg 1267a3b38f7Smrg 12744dda7b2Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 12844dda7b2Smrg# is ksh but when the shell is invoked as "sh" and the current value of 12944dda7b2Smrg# the _XPG environment variable is not equal to 1 (one), the special 13044dda7b2Smrg# positional parameter $0, within a function call, is the name of the 13144dda7b2Smrg# function. 13244dda7b2Smrgprogpath="$0" 1337a3b38f7Smrg 1347a3b38f7Smrg 1357a3b38f7Smrg 1367a3b38f7Smrg: ${CP="cp -f"} 13744dda7b2Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 13844dda7b2Smrg: ${EGREP="grep -E"} 13944dda7b2Smrg: ${FGREP="grep -F"} 14044dda7b2Smrg: ${GREP="grep"} 1417a3b38f7Smrg: ${LN_S="ln -s"} 1427a3b38f7Smrg: ${MAKE="make"} 1437a3b38f7Smrg: ${MKDIR="mkdir"} 1447a3b38f7Smrg: ${MV="mv -f"} 1457a3b38f7Smrg: ${RM="rm -f"} 14644dda7b2Smrg: ${SED="sed"} 1477a3b38f7Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 1487a3b38f7Smrg: ${Xsed="$SED -e 1s/^X//"} 149ff559fabSmrg 1507a3b38f7Smrg# Global variables: 1517a3b38f7SmrgEXIT_SUCCESS=0 1527a3b38f7SmrgEXIT_FAILURE=1 1537a3b38f7SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 1547a3b38f7SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 1557a3b38f7Smrg 1567a3b38f7Smrgexit_status=$EXIT_SUCCESS 1577a3b38f7Smrg 1587a3b38f7Smrg# Make sure IFS has a sensible default 1597a3b38f7Smrglt_nl=' 1607a3b38f7Smrg' 1617a3b38f7SmrgIFS=" $lt_nl" 1627a3b38f7Smrg 1637a3b38f7Smrgdirname="s,/[^/]*$,," 1647a3b38f7Smrgbasename="s,^.*/,," 1657a3b38f7Smrg 1667a3b38f7Smrg# func_dirname_and_basename file append nondir_replacement 1677a3b38f7Smrg# perform func_basename and func_dirname in a single function 1687a3b38f7Smrg# call: 1697a3b38f7Smrg# dirname: Compute the dirname of FILE. If nonempty, 1707a3b38f7Smrg# add APPEND to the result, otherwise set result 1717a3b38f7Smrg# to NONDIR_REPLACEMENT. 1727a3b38f7Smrg# value returned in "$func_dirname_result" 1737a3b38f7Smrg# basename: Compute filename of FILE. 1747a3b38f7Smrg# value retuned in "$func_basename_result" 1757a3b38f7Smrg# Implementation must be kept synchronized with func_dirname 1767a3b38f7Smrg# and func_basename. For efficiency, we do not delegate to 1777a3b38f7Smrg# those functions but instead duplicate the functionality here. 1787a3b38f7Smrgfunc_dirname_and_basename () 1797a3b38f7Smrg{ 1807a3b38f7Smrg # Extract subdirectory from the argument. 18144dda7b2Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 1827a3b38f7Smrg if test "X$func_dirname_result" = "X${1}"; then 1837a3b38f7Smrg func_dirname_result="${3}" 1847a3b38f7Smrg else 1857a3b38f7Smrg func_dirname_result="$func_dirname_result${2}" 1867a3b38f7Smrg fi 18744dda7b2Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 1887a3b38f7Smrg} 1897a3b38f7Smrg 1907a3b38f7Smrg# Generated shell functions inserted here. 191ff559fabSmrg 19244dda7b2Smrg# These SED scripts presuppose an absolute path with a trailing slash. 19344dda7b2Smrgpathcar='s,^/\([^/]*\).*$,\1,' 19444dda7b2Smrgpathcdr='s,^/[^/]*,,' 19544dda7b2Smrgremovedotparts=':dotsl 19644dda7b2Smrg s@/\./@/@g 19744dda7b2Smrg t dotsl 19844dda7b2Smrg s,/\.$,/,' 19944dda7b2Smrgcollapseslashes='s@/\{1,\}@/@g' 20044dda7b2Smrgfinalslash='s,/*$,/,' 20144dda7b2Smrg 20244dda7b2Smrg# func_normal_abspath PATH 20344dda7b2Smrg# Remove doubled-up and trailing slashes, "." path components, 20444dda7b2Smrg# and cancel out any ".." path components in PATH after making 20544dda7b2Smrg# it an absolute path. 20644dda7b2Smrg# value returned in "$func_normal_abspath_result" 20744dda7b2Smrgfunc_normal_abspath () 20844dda7b2Smrg{ 20944dda7b2Smrg # Start from root dir and reassemble the path. 21044dda7b2Smrg func_normal_abspath_result= 21144dda7b2Smrg func_normal_abspath_tpath=$1 21244dda7b2Smrg func_normal_abspath_altnamespace= 21344dda7b2Smrg case $func_normal_abspath_tpath in 21444dda7b2Smrg "") 21544dda7b2Smrg # Empty path, that just means $cwd. 21644dda7b2Smrg func_stripname '' '/' "`pwd`" 21744dda7b2Smrg func_normal_abspath_result=$func_stripname_result 21844dda7b2Smrg return 21944dda7b2Smrg ;; 22044dda7b2Smrg # The next three entries are used to spot a run of precisely 22144dda7b2Smrg # two leading slashes without using negated character classes; 22244dda7b2Smrg # we take advantage of case's first-match behaviour. 22344dda7b2Smrg ///*) 22444dda7b2Smrg # Unusual form of absolute path, do nothing. 22544dda7b2Smrg ;; 22644dda7b2Smrg //*) 22744dda7b2Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 22844dda7b2Smrg # and for example Cygwin uses it to access remote file shares 22944dda7b2Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 23044dda7b2Smrg func_normal_abspath_altnamespace=/ 23144dda7b2Smrg ;; 23244dda7b2Smrg /*) 23344dda7b2Smrg # Absolute path, do nothing. 23444dda7b2Smrg ;; 23544dda7b2Smrg *) 23644dda7b2Smrg # Relative path, prepend $cwd. 23744dda7b2Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 23844dda7b2Smrg ;; 23944dda7b2Smrg esac 24044dda7b2Smrg # Cancel out all the simple stuff to save iterations. We also want 24144dda7b2Smrg # the path to end with a slash for ease of parsing, so make sure 24244dda7b2Smrg # there is one (and only one) here. 24344dda7b2Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 24444dda7b2Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 24544dda7b2Smrg while :; do 24644dda7b2Smrg # Processed it all yet? 24744dda7b2Smrg if test "$func_normal_abspath_tpath" = / ; then 24844dda7b2Smrg # If we ascended to the root using ".." the result may be empty now. 24944dda7b2Smrg if test -z "$func_normal_abspath_result" ; then 25044dda7b2Smrg func_normal_abspath_result=/ 25144dda7b2Smrg fi 25244dda7b2Smrg break 25344dda7b2Smrg fi 25444dda7b2Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 25544dda7b2Smrg -e "$pathcar"` 25644dda7b2Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 25744dda7b2Smrg -e "$pathcdr"` 25844dda7b2Smrg # Figure out what to do with it 25944dda7b2Smrg case $func_normal_abspath_tcomponent in 26044dda7b2Smrg "") 26144dda7b2Smrg # Trailing empty path component, ignore it. 26244dda7b2Smrg ;; 26344dda7b2Smrg ..) 26444dda7b2Smrg # Parent dir; strip last assembled component from result. 26544dda7b2Smrg func_dirname "$func_normal_abspath_result" 26644dda7b2Smrg func_normal_abspath_result=$func_dirname_result 26744dda7b2Smrg ;; 26844dda7b2Smrg *) 26944dda7b2Smrg # Actual path component, append it. 27044dda7b2Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 27144dda7b2Smrg ;; 27244dda7b2Smrg esac 27344dda7b2Smrg done 27444dda7b2Smrg # Restore leading double-slash if one was found on entry. 27544dda7b2Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 27644dda7b2Smrg} 27744dda7b2Smrg 27844dda7b2Smrg# func_relative_path SRCDIR DSTDIR 27944dda7b2Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 28044dda7b2Smrg# slash if non-empty, suitable for immediately appending a filename 28144dda7b2Smrg# without needing to append a separator. 28244dda7b2Smrg# value returned in "$func_relative_path_result" 28344dda7b2Smrgfunc_relative_path () 28444dda7b2Smrg{ 28544dda7b2Smrg func_relative_path_result= 28644dda7b2Smrg func_normal_abspath "$1" 28744dda7b2Smrg func_relative_path_tlibdir=$func_normal_abspath_result 28844dda7b2Smrg func_normal_abspath "$2" 28944dda7b2Smrg func_relative_path_tbindir=$func_normal_abspath_result 29044dda7b2Smrg 29144dda7b2Smrg # Ascend the tree starting from libdir 29244dda7b2Smrg while :; do 29344dda7b2Smrg # check if we have found a prefix of bindir 29444dda7b2Smrg case $func_relative_path_tbindir in 29544dda7b2Smrg $func_relative_path_tlibdir) 29644dda7b2Smrg # found an exact match 29744dda7b2Smrg func_relative_path_tcancelled= 29844dda7b2Smrg break 29944dda7b2Smrg ;; 30044dda7b2Smrg $func_relative_path_tlibdir*) 30144dda7b2Smrg # found a matching prefix 30244dda7b2Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 30344dda7b2Smrg func_relative_path_tcancelled=$func_stripname_result 30444dda7b2Smrg if test -z "$func_relative_path_result"; then 30544dda7b2Smrg func_relative_path_result=. 30644dda7b2Smrg fi 30744dda7b2Smrg break 30844dda7b2Smrg ;; 30944dda7b2Smrg *) 31044dda7b2Smrg func_dirname $func_relative_path_tlibdir 31144dda7b2Smrg func_relative_path_tlibdir=${func_dirname_result} 31244dda7b2Smrg if test "x$func_relative_path_tlibdir" = x ; then 31344dda7b2Smrg # Have to descend all the way to the root! 31444dda7b2Smrg func_relative_path_result=../$func_relative_path_result 31544dda7b2Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 31644dda7b2Smrg break 31744dda7b2Smrg fi 31844dda7b2Smrg func_relative_path_result=../$func_relative_path_result 31944dda7b2Smrg ;; 32044dda7b2Smrg esac 32144dda7b2Smrg done 32244dda7b2Smrg 32344dda7b2Smrg # Now calculate path; take care to avoid doubling-up slashes. 32444dda7b2Smrg func_stripname '' '/' "$func_relative_path_result" 32544dda7b2Smrg func_relative_path_result=$func_stripname_result 32644dda7b2Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 32744dda7b2Smrg if test "x$func_stripname_result" != x ; then 32844dda7b2Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 32944dda7b2Smrg fi 33044dda7b2Smrg 33144dda7b2Smrg # Normalisation. If bindir is libdir, return empty string, 33244dda7b2Smrg # else relative path ending with a slash; either way, target 33344dda7b2Smrg # file name can be directly appended. 33444dda7b2Smrg if test ! -z "$func_relative_path_result"; then 33544dda7b2Smrg func_stripname './' '' "$func_relative_path_result/" 33644dda7b2Smrg func_relative_path_result=$func_stripname_result 33744dda7b2Smrg fi 33844dda7b2Smrg} 339ff559fabSmrg 340ff559fabSmrg# The name of this program: 3417a3b38f7Smrgfunc_dirname_and_basename "$progpath" 3427a3b38f7Smrgprogname=$func_basename_result 343ff559fabSmrg 3447a3b38f7Smrg# Make sure we have an absolute path for reexecution: 3457a3b38f7Smrgcase $progpath in 3467a3b38f7Smrg [\\/]*|[A-Za-z]:\\*) ;; 3477a3b38f7Smrg *[\\/]*) 3487a3b38f7Smrg progdir=$func_dirname_result 3497a3b38f7Smrg progdir=`cd "$progdir" && pwd` 3507a3b38f7Smrg progpath="$progdir/$progname" 3517a3b38f7Smrg ;; 3527a3b38f7Smrg *) 3537a3b38f7Smrg save_IFS="$IFS" 3547a3b38f7Smrg IFS=: 3557a3b38f7Smrg for progdir in $PATH; do 3567a3b38f7Smrg IFS="$save_IFS" 3577a3b38f7Smrg test -x "$progdir/$progname" && break 3587a3b38f7Smrg done 3597a3b38f7Smrg IFS="$save_IFS" 3607a3b38f7Smrg test -n "$progdir" || progdir=`pwd` 3617a3b38f7Smrg progpath="$progdir/$progname" 3627a3b38f7Smrg ;; 3637a3b38f7Smrgesac 364ff559fabSmrg 3657a3b38f7Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3667a3b38f7Smrg# metacharacters that are still active within double-quoted strings. 3677a3b38f7SmrgXsed="${SED}"' -e 1s/^X//' 3687a3b38f7Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 3697a3b38f7Smrg 3707a3b38f7Smrg# Same as above, but do not quote variable references. 3717a3b38f7Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 3727a3b38f7Smrg 3737a3b38f7Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 3747a3b38f7Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 3757a3b38f7Smrg# in input to double_quote_subst, that '$' was protected from expansion. 3767a3b38f7Smrg# Since each input `\' is now two `\'s, look for any number of runs of 3777a3b38f7Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 3787a3b38f7Smrgbs='\\' 3797a3b38f7Smrgbs2='\\\\' 3807a3b38f7Smrgbs4='\\\\\\\\' 3817a3b38f7Smrgdollar='\$' 3827a3b38f7Smrgsed_double_backslash="\ 3837a3b38f7Smrg s/$bs4/&\\ 3847a3b38f7Smrg/g 3857a3b38f7Smrg s/^$bs2$dollar/$bs&/ 3867a3b38f7Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 3877a3b38f7Smrg s/\n//g" 3887a3b38f7Smrg 3897a3b38f7Smrg# Standard options: 3907a3b38f7Smrgopt_dry_run=false 3917a3b38f7Smrgopt_help=false 3927a3b38f7Smrgopt_quiet=false 3937a3b38f7Smrgopt_verbose=false 3947a3b38f7Smrgopt_warning=: 3957a3b38f7Smrg 3967a3b38f7Smrg# func_echo arg... 3977a3b38f7Smrg# Echo program name prefixed message, along with the current mode 3987a3b38f7Smrg# name if it has been set yet. 3997a3b38f7Smrgfunc_echo () 4007a3b38f7Smrg{ 4017a3b38f7Smrg $ECHO "$progname${mode+: }$mode: $*" 4027a3b38f7Smrg} 403ff559fabSmrg 4047a3b38f7Smrg# func_verbose arg... 4057a3b38f7Smrg# Echo program name prefixed message in verbose mode only. 4067a3b38f7Smrgfunc_verbose () 4077a3b38f7Smrg{ 4087a3b38f7Smrg $opt_verbose && func_echo ${1+"$@"} 409ff559fabSmrg 4107a3b38f7Smrg # A bug in bash halts the script if the last line of a function 4117a3b38f7Smrg # fails when set -e is in force, so we need another command to 4127a3b38f7Smrg # work around that: 4137a3b38f7Smrg : 4147a3b38f7Smrg} 415ff559fabSmrg 41644dda7b2Smrg# func_echo_all arg... 41744dda7b2Smrg# Invoke $ECHO with all args, space-separated. 41844dda7b2Smrgfunc_echo_all () 41944dda7b2Smrg{ 42044dda7b2Smrg $ECHO "$*" 42144dda7b2Smrg} 42244dda7b2Smrg 4237a3b38f7Smrg# func_error arg... 4247a3b38f7Smrg# Echo program name prefixed message to standard error. 4257a3b38f7Smrgfunc_error () 4267a3b38f7Smrg{ 4277a3b38f7Smrg $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 4287a3b38f7Smrg} 429ff559fabSmrg 4307a3b38f7Smrg# func_warning arg... 4317a3b38f7Smrg# Echo program name prefixed warning message to standard error. 4327a3b38f7Smrgfunc_warning () 4337a3b38f7Smrg{ 4347a3b38f7Smrg $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 435ff559fabSmrg 4367a3b38f7Smrg # bash bug again: 4377a3b38f7Smrg : 4387a3b38f7Smrg} 439ff559fabSmrg 4407a3b38f7Smrg# func_fatal_error arg... 4417a3b38f7Smrg# Echo program name prefixed message to standard error, and exit. 4427a3b38f7Smrgfunc_fatal_error () 4437a3b38f7Smrg{ 4447a3b38f7Smrg func_error ${1+"$@"} 4457a3b38f7Smrg exit $EXIT_FAILURE 4467a3b38f7Smrg} 447ff559fabSmrg 4487a3b38f7Smrg# func_fatal_help arg... 4497a3b38f7Smrg# Echo program name prefixed message to standard error, followed by 4507a3b38f7Smrg# a help hint, and exit. 4517a3b38f7Smrgfunc_fatal_help () 4527a3b38f7Smrg{ 4537a3b38f7Smrg func_error ${1+"$@"} 4547a3b38f7Smrg func_fatal_error "$help" 4557a3b38f7Smrg} 4567a3b38f7Smrghelp="Try \`$progname --help' for more information." ## default 457ff559fabSmrg 458ff559fabSmrg 4597a3b38f7Smrg# func_grep expression filename 4607a3b38f7Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 4617a3b38f7Smrgfunc_grep () 4627a3b38f7Smrg{ 4637a3b38f7Smrg $GREP "$1" "$2" >/dev/null 2>&1 4647a3b38f7Smrg} 4657a3b38f7Smrg 4667a3b38f7Smrg 4677a3b38f7Smrg# func_mkdir_p directory-path 4687a3b38f7Smrg# Make sure the entire path to DIRECTORY-PATH is available. 4697a3b38f7Smrgfunc_mkdir_p () 4707a3b38f7Smrg{ 4717a3b38f7Smrg my_directory_path="$1" 4727a3b38f7Smrg my_dir_list= 4737a3b38f7Smrg 4747a3b38f7Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 4757a3b38f7Smrg 4767a3b38f7Smrg # Protect directory names starting with `-' 4777a3b38f7Smrg case $my_directory_path in 4787a3b38f7Smrg -*) my_directory_path="./$my_directory_path" ;; 4797a3b38f7Smrg esac 4807a3b38f7Smrg 4817a3b38f7Smrg # While some portion of DIR does not yet exist... 4827a3b38f7Smrg while test ! -d "$my_directory_path"; do 4837a3b38f7Smrg # ...make a list in topmost first order. Use a colon delimited 4847a3b38f7Smrg # list incase some portion of path contains whitespace. 4857a3b38f7Smrg my_dir_list="$my_directory_path:$my_dir_list" 4867a3b38f7Smrg 4877a3b38f7Smrg # If the last portion added has no slash in it, the list is done 4887a3b38f7Smrg case $my_directory_path in */*) ;; *) break ;; esac 4897a3b38f7Smrg 4907a3b38f7Smrg # ...otherwise throw away the child directory and loop 49144dda7b2Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 4927a3b38f7Smrg done 49344dda7b2Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 4947a3b38f7Smrg 4957a3b38f7Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 4967a3b38f7Smrg for my_dir in $my_dir_list; do 4977a3b38f7Smrg IFS="$save_mkdir_p_IFS" 4987a3b38f7Smrg # mkdir can fail with a `File exist' error if two processes 4997a3b38f7Smrg # try to create one of the directories concurrently. Don't 5007a3b38f7Smrg # stop in that case! 5017a3b38f7Smrg $MKDIR "$my_dir" 2>/dev/null || : 5027a3b38f7Smrg done 5037a3b38f7Smrg IFS="$save_mkdir_p_IFS" 5047a3b38f7Smrg 5057a3b38f7Smrg # Bail out if we (or some other process) failed to create a directory. 5067a3b38f7Smrg test -d "$my_directory_path" || \ 5077a3b38f7Smrg func_fatal_error "Failed to create \`$1'" 5087a3b38f7Smrg fi 5097a3b38f7Smrg} 510ff559fabSmrg 511ff559fabSmrg 512ff559fabSmrg# func_mktempdir [string] 513ff559fabSmrg# Make a temporary directory that won't clash with other running 514ff559fabSmrg# libtool processes, and avoids race conditions if possible. If 515ff559fabSmrg# given, STRING is the basename for that directory. 516ff559fabSmrgfunc_mktempdir () 517ff559fabSmrg{ 518ff559fabSmrg my_template="${TMPDIR-/tmp}/${1-$progname}" 519ff559fabSmrg 5207a3b38f7Smrg if test "$opt_dry_run" = ":"; then 521ff559fabSmrg # Return a directory name, but don't create it in dry-run mode 522ff559fabSmrg my_tmpdir="${my_template}-$$" 523ff559fabSmrg else 524ff559fabSmrg 525ff559fabSmrg # If mktemp works, use that first and foremost 526ff559fabSmrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 527ff559fabSmrg 528ff559fabSmrg if test ! -d "$my_tmpdir"; then 5297a3b38f7Smrg # Failing that, at least try and use $RANDOM to avoid a race 5307a3b38f7Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 531ff559fabSmrg 5327a3b38f7Smrg save_mktempdir_umask=`umask` 5337a3b38f7Smrg umask 0077 5347a3b38f7Smrg $MKDIR "$my_tmpdir" 5357a3b38f7Smrg umask $save_mktempdir_umask 536ff559fabSmrg fi 537ff559fabSmrg 538ff559fabSmrg # If we're not in dry-run mode, bomb out on failure 5397a3b38f7Smrg test -d "$my_tmpdir" || \ 5407a3b38f7Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 541ff559fabSmrg fi 542ff559fabSmrg 54344dda7b2Smrg $ECHO "$my_tmpdir" 544ff559fabSmrg} 545ff559fabSmrg 546ff559fabSmrg 5477a3b38f7Smrg# func_quote_for_eval arg 5487a3b38f7Smrg# Aesthetically quote ARG to be evaled later. 5497a3b38f7Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 5507a3b38f7Smrg# is double-quoted, suitable for a subsequent eval, whereas 5517a3b38f7Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 5527a3b38f7Smrg# which are still active within double quotes backslashified. 5537a3b38f7Smrgfunc_quote_for_eval () 554ff559fabSmrg{ 5557a3b38f7Smrg case $1 in 5567a3b38f7Smrg *[\\\`\"\$]*) 55744dda7b2Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 5587a3b38f7Smrg *) 5597a3b38f7Smrg func_quote_for_eval_unquoted_result="$1" ;; 5607a3b38f7Smrg esac 5617a3b38f7Smrg 5627a3b38f7Smrg case $func_quote_for_eval_unquoted_result in 5637a3b38f7Smrg # Double-quote args containing shell metacharacters to delay 5647a3b38f7Smrg # word splitting, command substitution and and variable 5657a3b38f7Smrg # expansion for a subsequent eval. 5667a3b38f7Smrg # Many Bourne shells cannot handle close brackets correctly 5677a3b38f7Smrg # in scan sets, so we specify it separately. 5687a3b38f7Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 5697a3b38f7Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 5707a3b38f7Smrg ;; 5717a3b38f7Smrg *) 5727a3b38f7Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 573ff559fabSmrg esac 574ff559fabSmrg} 575ff559fabSmrg 576ff559fabSmrg 5777a3b38f7Smrg# func_quote_for_expand arg 5787a3b38f7Smrg# Aesthetically quote ARG to be evaled later; same as above, 5797a3b38f7Smrg# but do not quote variable references. 5807a3b38f7Smrgfunc_quote_for_expand () 581ff559fabSmrg{ 5827a3b38f7Smrg case $1 in 5837a3b38f7Smrg *[\\\`\"]*) 58444dda7b2Smrg my_arg=`$ECHO "$1" | $SED \ 5857a3b38f7Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 586ff559fabSmrg *) 5877a3b38f7Smrg my_arg="$1" ;; 5887a3b38f7Smrg esac 5897a3b38f7Smrg 5907a3b38f7Smrg case $my_arg in 5917a3b38f7Smrg # Double-quote args containing shell metacharacters to delay 5927a3b38f7Smrg # word splitting and command substitution for a subsequent eval. 5937a3b38f7Smrg # Many Bourne shells cannot handle close brackets correctly 5947a3b38f7Smrg # in scan sets, so we specify it separately. 5957a3b38f7Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 5967a3b38f7Smrg my_arg="\"$my_arg\"" 5977a3b38f7Smrg ;; 5987a3b38f7Smrg esac 5997a3b38f7Smrg 6007a3b38f7Smrg func_quote_for_expand_result="$my_arg" 601ff559fabSmrg} 602ff559fabSmrg 603ff559fabSmrg 6047a3b38f7Smrg# func_show_eval cmd [fail_exp] 6057a3b38f7Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6067a3b38f7Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6077a3b38f7Smrg# is given, then evaluate it. 6087a3b38f7Smrgfunc_show_eval () 609ff559fabSmrg{ 6107a3b38f7Smrg my_cmd="$1" 6117a3b38f7Smrg my_fail_exp="${2-:}" 612ff559fabSmrg 6137a3b38f7Smrg ${opt_silent-false} || { 6147a3b38f7Smrg func_quote_for_expand "$my_cmd" 6157a3b38f7Smrg eval "func_echo $func_quote_for_expand_result" 6167a3b38f7Smrg } 6177a3b38f7Smrg 6187a3b38f7Smrg if ${opt_dry_run-false}; then :; else 6197a3b38f7Smrg eval "$my_cmd" 6207a3b38f7Smrg my_status=$? 6217a3b38f7Smrg if test "$my_status" -eq 0; then :; else 6227a3b38f7Smrg eval "(exit $my_status); $my_fail_exp" 6237a3b38f7Smrg fi 624ff559fabSmrg fi 625ff559fabSmrg} 626ff559fabSmrg 6277a3b38f7Smrg 6287a3b38f7Smrg# func_show_eval_locale cmd [fail_exp] 6297a3b38f7Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6307a3b38f7Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6317a3b38f7Smrg# is given, then evaluate it. Use the saved locale for evaluation. 6327a3b38f7Smrgfunc_show_eval_locale () 633ff559fabSmrg{ 6347a3b38f7Smrg my_cmd="$1" 6357a3b38f7Smrg my_fail_exp="${2-:}" 636ff559fabSmrg 6377a3b38f7Smrg ${opt_silent-false} || { 6387a3b38f7Smrg func_quote_for_expand "$my_cmd" 6397a3b38f7Smrg eval "func_echo $func_quote_for_expand_result" 6407a3b38f7Smrg } 6417a3b38f7Smrg 6427a3b38f7Smrg if ${opt_dry_run-false}; then :; else 6437a3b38f7Smrg eval "$lt_user_locale 6447a3b38f7Smrg $my_cmd" 6457a3b38f7Smrg my_status=$? 6467a3b38f7Smrg eval "$lt_safe_locale" 6477a3b38f7Smrg if test "$my_status" -eq 0; then :; else 6487a3b38f7Smrg eval "(exit $my_status); $my_fail_exp" 649ff559fabSmrg fi 6507a3b38f7Smrg fi 651ff559fabSmrg} 652ff559fabSmrg 653ff559fabSmrg 6547a3b38f7Smrg# func_version 6557a3b38f7Smrg# Echo version message to standard output and exit. 6567a3b38f7Smrgfunc_version () 6577a3b38f7Smrg{ 65844dda7b2Smrg $SED -n '/(C)/!b go 65944dda7b2Smrg :more 66044dda7b2Smrg /\./!{ 66144dda7b2Smrg N 66244dda7b2Smrg s/\n# / / 66344dda7b2Smrg b more 66444dda7b2Smrg } 66544dda7b2Smrg :go 66644dda7b2Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 6677a3b38f7Smrg s/^# // 6687a3b38f7Smrg s/^# *$// 6697a3b38f7Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 6707a3b38f7Smrg p 6717a3b38f7Smrg }' < "$progpath" 6727a3b38f7Smrg exit $? 6737a3b38f7Smrg} 6747a3b38f7Smrg 6757a3b38f7Smrg# func_usage 6767a3b38f7Smrg# Echo short help message to standard output and exit. 6777a3b38f7Smrgfunc_usage () 6787a3b38f7Smrg{ 67944dda7b2Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 6807a3b38f7Smrg s/^# // 6817a3b38f7Smrg s/^# *$// 6827a3b38f7Smrg s/\$progname/'$progname'/ 6837a3b38f7Smrg p 6847a3b38f7Smrg }' < "$progpath" 68544dda7b2Smrg echo 6867a3b38f7Smrg $ECHO "run \`$progname --help | more' for full usage" 6877a3b38f7Smrg exit $? 6887a3b38f7Smrg} 6897a3b38f7Smrg 69044dda7b2Smrg# func_help [NOEXIT] 69144dda7b2Smrg# Echo long help message to standard output and exit, 69244dda7b2Smrg# unless 'noexit' is passed as argument. 6937a3b38f7Smrgfunc_help () 6947a3b38f7Smrg{ 6957a3b38f7Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 6967a3b38f7Smrg s/^# // 6977a3b38f7Smrg s/^# *$// 6987a3b38f7Smrg s*\$progname*'$progname'* 6997a3b38f7Smrg s*\$host*'"$host"'* 7007a3b38f7Smrg s*\$SHELL*'"$SHELL"'* 7017a3b38f7Smrg s*\$LTCC*'"$LTCC"'* 7027a3b38f7Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 7037a3b38f7Smrg s*\$LD*'"$LD"'* 7047a3b38f7Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 7057a3b38f7Smrg s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ 7067a3b38f7Smrg s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ 7077a3b38f7Smrg p 7087a3b38f7Smrg }' < "$progpath" 70944dda7b2Smrg ret=$? 71044dda7b2Smrg if test -z "$1"; then 71144dda7b2Smrg exit $ret 71244dda7b2Smrg fi 7137a3b38f7Smrg} 7147a3b38f7Smrg 7157a3b38f7Smrg# func_missing_arg argname 7167a3b38f7Smrg# Echo program name prefixed message to standard error and set global 7177a3b38f7Smrg# exit_cmd. 7187a3b38f7Smrgfunc_missing_arg () 7197a3b38f7Smrg{ 72044dda7b2Smrg func_error "missing argument for $1." 7217a3b38f7Smrg exit_cmd=exit 7227a3b38f7Smrg} 7237a3b38f7Smrg 7247a3b38f7Smrgexit_cmd=: 7257a3b38f7Smrg 7267a3b38f7Smrg 7277a3b38f7Smrg 7287a3b38f7Smrg 7297a3b38f7Smrg 730ff559fabSmrg 7317a3b38f7Smrgmagic="%%%MAGIC variable%%%" 7327a3b38f7Smrgmagic_exe="%%%MAGIC EXE variable%%%" 733ff559fabSmrg 7347a3b38f7Smrg# Global variables. 7357a3b38f7Smrg# $mode is unset 7367a3b38f7Smrgnonopt= 7377a3b38f7Smrgexecute_dlfiles= 7387a3b38f7Smrgpreserve_args= 7397a3b38f7Smrglo2o="s/\\.lo\$/.${objext}/" 7407a3b38f7Smrgo2lo="s/\\.${objext}\$/.lo/" 7417a3b38f7Smrgextracted_archives= 7427a3b38f7Smrgextracted_serial=0 743ff559fabSmrg 7447a3b38f7Smrgopt_dry_run=false 7457a3b38f7Smrgopt_duplicate_deps=false 7467a3b38f7Smrgopt_silent=false 7477a3b38f7Smrgopt_debug=: 748ff559fabSmrg 7497a3b38f7Smrg# If this variable is set in any of the actions, the command in it 7507a3b38f7Smrg# will be execed at the end. This prevents here-documents from being 7517a3b38f7Smrg# left over by shells. 7527a3b38f7Smrgexec_cmd= 753ff559fabSmrg 7547a3b38f7Smrg# func_fatal_configuration arg... 7557a3b38f7Smrg# Echo program name prefixed message to standard error, followed by 7567a3b38f7Smrg# a configuration failure hint, and exit. 7577a3b38f7Smrgfunc_fatal_configuration () 7587a3b38f7Smrg{ 7597a3b38f7Smrg func_error ${1+"$@"} 7607a3b38f7Smrg func_error "See the $PACKAGE documentation for more information." 7617a3b38f7Smrg func_fatal_error "Fatal configuration error." 7627a3b38f7Smrg} 7637a3b38f7Smrg 7647a3b38f7Smrg 7657a3b38f7Smrg# func_config 7667a3b38f7Smrg# Display the configuration for all the tags in this script. 7677a3b38f7Smrgfunc_config () 7687a3b38f7Smrg{ 7697a3b38f7Smrg re_begincf='^# ### BEGIN LIBTOOL' 7707a3b38f7Smrg re_endcf='^# ### END LIBTOOL' 7717a3b38f7Smrg 7727a3b38f7Smrg # Default configuration. 7737a3b38f7Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 774ff559fabSmrg 775ff559fabSmrg # Now print the configurations for the tags. 776ff559fabSmrg for tagname in $taglist; do 7777a3b38f7Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 778ff559fabSmrg done 779ff559fabSmrg 7807a3b38f7Smrg exit $? 7817a3b38f7Smrg} 782ff559fabSmrg 7837a3b38f7Smrg# func_features 7847a3b38f7Smrg# Display the features supported by this script. 7857a3b38f7Smrgfunc_features () 7867a3b38f7Smrg{ 78744dda7b2Smrg echo "host: $host" 788ff559fabSmrg if test "$build_libtool_libs" = yes; then 78944dda7b2Smrg echo "enable shared libraries" 790ff559fabSmrg else 79144dda7b2Smrg echo "disable shared libraries" 792ff559fabSmrg fi 793ff559fabSmrg if test "$build_old_libs" = yes; then 79444dda7b2Smrg echo "enable static libraries" 795ff559fabSmrg else 79644dda7b2Smrg echo "disable static libraries" 797ff559fabSmrg fi 7987a3b38f7Smrg 799ff559fabSmrg exit $? 8007a3b38f7Smrg} 8017a3b38f7Smrg 8027a3b38f7Smrg# func_enable_tag tagname 8037a3b38f7Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 8047a3b38f7Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 8057a3b38f7Smrg# variable here. 8067a3b38f7Smrgfunc_enable_tag () 8077a3b38f7Smrg{ 8087a3b38f7Smrg # Global variable: 8097a3b38f7Smrg tagname="$1" 810ff559fabSmrg 8117a3b38f7Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 8127a3b38f7Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 8137a3b38f7Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 814ff559fabSmrg 8157a3b38f7Smrg # Validate tagname. 8167a3b38f7Smrg case $tagname in 8177a3b38f7Smrg *[!-_A-Za-z0-9,/]*) 8187a3b38f7Smrg func_fatal_error "invalid tag name: $tagname" 8197a3b38f7Smrg ;; 8207a3b38f7Smrg esac 821ff559fabSmrg 8227a3b38f7Smrg # Don't test for the "default" C tag, as we know it's 8237a3b38f7Smrg # there but not specially marked. 8247a3b38f7Smrg case $tagname in 8257a3b38f7Smrg CC) ;; 8267a3b38f7Smrg *) 8277a3b38f7Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 8287a3b38f7Smrg taglist="$taglist $tagname" 8297a3b38f7Smrg 8307a3b38f7Smrg # Evaluate the configuration. Be careful to quote the path 8317a3b38f7Smrg # and the sed script, to avoid splitting on whitespace, but 8327a3b38f7Smrg # also don't use non-portable quotes within backquotes within 8337a3b38f7Smrg # quotes we have to do it in 2 steps: 8347a3b38f7Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 8357a3b38f7Smrg eval "$extractedcf" 8367a3b38f7Smrg else 8377a3b38f7Smrg func_error "ignoring unknown tag $tagname" 8387a3b38f7Smrg fi 8397a3b38f7Smrg ;; 8407a3b38f7Smrg esac 8417a3b38f7Smrg} 842ff559fabSmrg 8437a3b38f7Smrg# Parse options once, thoroughly. This comes as soon as possible in 8447a3b38f7Smrg# the script to make things like `libtool --version' happen quickly. 8457a3b38f7Smrg{ 846ff559fabSmrg 8477a3b38f7Smrg # Shorthand for --mode=foo, only valid as the first argument 8487a3b38f7Smrg case $1 in 8497a3b38f7Smrg clean|clea|cle|cl) 8507a3b38f7Smrg shift; set dummy --mode clean ${1+"$@"}; shift 851ff559fabSmrg ;; 8527a3b38f7Smrg compile|compil|compi|comp|com|co|c) 8537a3b38f7Smrg shift; set dummy --mode compile ${1+"$@"}; shift 854ff559fabSmrg ;; 8557a3b38f7Smrg execute|execut|execu|exec|exe|ex|e) 8567a3b38f7Smrg shift; set dummy --mode execute ${1+"$@"}; shift 857ff559fabSmrg ;; 8587a3b38f7Smrg finish|finis|fini|fin|fi|f) 8597a3b38f7Smrg shift; set dummy --mode finish ${1+"$@"}; shift 860ff559fabSmrg ;; 8617a3b38f7Smrg install|instal|insta|inst|ins|in|i) 8627a3b38f7Smrg shift; set dummy --mode install ${1+"$@"}; shift 8637a3b38f7Smrg ;; 8647a3b38f7Smrg link|lin|li|l) 8657a3b38f7Smrg shift; set dummy --mode link ${1+"$@"}; shift 8667a3b38f7Smrg ;; 8677a3b38f7Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 8687a3b38f7Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 869ff559fabSmrg ;; 870ff559fabSmrg esac 871ff559fabSmrg 8727a3b38f7Smrg # Parse non-mode specific arguments: 8737a3b38f7Smrg while test "$#" -gt 0; do 8747a3b38f7Smrg opt="$1" 8757a3b38f7Smrg shift 876ff559fabSmrg 8777a3b38f7Smrg case $opt in 8787a3b38f7Smrg --config) func_config ;; 879ff559fabSmrg 8807a3b38f7Smrg --debug) preserve_args="$preserve_args $opt" 8817a3b38f7Smrg func_echo "enabling shell trace mode" 8827a3b38f7Smrg opt_debug='set -x' 8837a3b38f7Smrg $opt_debug 8847a3b38f7Smrg ;; 885ff559fabSmrg 8867a3b38f7Smrg -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break 8877a3b38f7Smrg execute_dlfiles="$execute_dlfiles $1" 8887a3b38f7Smrg shift 8897a3b38f7Smrg ;; 890ff559fabSmrg 8917a3b38f7Smrg --dry-run | -n) opt_dry_run=: ;; 8927a3b38f7Smrg --features) func_features ;; 8937a3b38f7Smrg --finish) mode="finish" ;; 8947a3b38f7Smrg 8957a3b38f7Smrg --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break 8967a3b38f7Smrg case $1 in 8977a3b38f7Smrg # Valid mode arguments: 8987a3b38f7Smrg clean) ;; 8997a3b38f7Smrg compile) ;; 9007a3b38f7Smrg execute) ;; 9017a3b38f7Smrg finish) ;; 9027a3b38f7Smrg install) ;; 9037a3b38f7Smrg link) ;; 9047a3b38f7Smrg relink) ;; 9057a3b38f7Smrg uninstall) ;; 9067a3b38f7Smrg 9077a3b38f7Smrg # Catch anything else as an error 9087a3b38f7Smrg *) func_error "invalid argument for $opt" 9097a3b38f7Smrg exit_cmd=exit 9107a3b38f7Smrg break 9117a3b38f7Smrg ;; 9127a3b38f7Smrg esac 9137a3b38f7Smrg 9147a3b38f7Smrg mode="$1" 9157a3b38f7Smrg shift 9167a3b38f7Smrg ;; 9177a3b38f7Smrg 9187a3b38f7Smrg --preserve-dup-deps) 9197a3b38f7Smrg opt_duplicate_deps=: ;; 9207a3b38f7Smrg 9217a3b38f7Smrg --quiet|--silent) preserve_args="$preserve_args $opt" 9227a3b38f7Smrg opt_silent=: 92344dda7b2Smrg opt_verbose=false 92444dda7b2Smrg ;; 92544dda7b2Smrg 92644dda7b2Smrg --no-quiet|--no-silent) 92744dda7b2Smrg preserve_args="$preserve_args $opt" 92844dda7b2Smrg opt_silent=false 9297a3b38f7Smrg ;; 9307a3b38f7Smrg 9317a3b38f7Smrg --verbose| -v) preserve_args="$preserve_args $opt" 9327a3b38f7Smrg opt_silent=false 93344dda7b2Smrg opt_verbose=: 93444dda7b2Smrg ;; 93544dda7b2Smrg 93644dda7b2Smrg --no-verbose) preserve_args="$preserve_args $opt" 93744dda7b2Smrg opt_verbose=false 9387a3b38f7Smrg ;; 9397a3b38f7Smrg 9407a3b38f7Smrg --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break 9417a3b38f7Smrg preserve_args="$preserve_args $opt $1" 9427a3b38f7Smrg func_enable_tag "$1" # tagname is set here 9437a3b38f7Smrg shift 9447a3b38f7Smrg ;; 9457a3b38f7Smrg 9467a3b38f7Smrg # Separate optargs to long options: 9477a3b38f7Smrg -dlopen=*|--mode=*|--tag=*) 9487a3b38f7Smrg func_opt_split "$opt" 9497a3b38f7Smrg set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} 9507a3b38f7Smrg shift 9517a3b38f7Smrg ;; 9527a3b38f7Smrg 9537a3b38f7Smrg -\?|-h) func_usage ;; 9547a3b38f7Smrg --help) opt_help=: ;; 95544dda7b2Smrg --help-all) opt_help=': help-all' ;; 9567a3b38f7Smrg --version) func_version ;; 9577a3b38f7Smrg 9587a3b38f7Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 9597a3b38f7Smrg 9607a3b38f7Smrg *) nonopt="$opt" 9617a3b38f7Smrg break 9627a3b38f7Smrg ;; 9637a3b38f7Smrg esac 9647a3b38f7Smrg done 9657a3b38f7Smrg 9667a3b38f7Smrg 9677a3b38f7Smrg case $host in 9687a3b38f7Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 9697a3b38f7Smrg # don't eliminate duplications in $postdeps and $predeps 9707a3b38f7Smrg opt_duplicate_compiler_generated_deps=: 971ff559fabSmrg ;; 972ff559fabSmrg *) 9737a3b38f7Smrg opt_duplicate_compiler_generated_deps=$opt_duplicate_deps 9747a3b38f7Smrg ;; 9757a3b38f7Smrg esac 976ff559fabSmrg 9777a3b38f7Smrg # Having warned about all mis-specified options, bail out if 9787a3b38f7Smrg # anything was wrong. 9797a3b38f7Smrg $exit_cmd $EXIT_FAILURE 9807a3b38f7Smrg} 9817a3b38f7Smrg 9827a3b38f7Smrg# func_check_version_match 9837a3b38f7Smrg# Ensure that we are using m4 macros, and libtool script from the same 9847a3b38f7Smrg# release of libtool. 9857a3b38f7Smrgfunc_check_version_match () 9867a3b38f7Smrg{ 9877a3b38f7Smrg if test "$package_revision" != "$macro_revision"; then 9887a3b38f7Smrg if test "$VERSION" != "$macro_version"; then 9897a3b38f7Smrg if test -z "$macro_version"; then 9907a3b38f7Smrg cat >&2 <<_LT_EOF 9917a3b38f7Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 9927a3b38f7Smrg$progname: definition of this LT_INIT comes from an older release. 9937a3b38f7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 9947a3b38f7Smrg$progname: and run autoconf again. 9957a3b38f7Smrg_LT_EOF 9967a3b38f7Smrg else 9977a3b38f7Smrg cat >&2 <<_LT_EOF 9987a3b38f7Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 9997a3b38f7Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 10007a3b38f7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 10017a3b38f7Smrg$progname: and run autoconf again. 10027a3b38f7Smrg_LT_EOF 1003ff559fabSmrg fi 10047a3b38f7Smrg else 10057a3b38f7Smrg cat >&2 <<_LT_EOF 10067a3b38f7Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 10077a3b38f7Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 10087a3b38f7Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 10097a3b38f7Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 10107a3b38f7Smrg_LT_EOF 10117a3b38f7Smrg fi 10127a3b38f7Smrg 10137a3b38f7Smrg exit $EXIT_MISMATCH 10147a3b38f7Smrg fi 10157a3b38f7Smrg} 10167a3b38f7Smrg 10177a3b38f7Smrg 10187a3b38f7Smrg## ----------- ## 10197a3b38f7Smrg## Main. ## 10207a3b38f7Smrg## ----------- ## 10217a3b38f7Smrg 10227a3b38f7Smrg$opt_help || { 10237a3b38f7Smrg # Sanity checks first: 10247a3b38f7Smrg func_check_version_match 10257a3b38f7Smrg 10267a3b38f7Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 10277a3b38f7Smrg func_fatal_configuration "not configured to build any kind of library" 1028ff559fabSmrg fi 1029ff559fabSmrg 10307a3b38f7Smrg test -z "$mode" && func_fatal_error "error: you must specify a MODE." 10317a3b38f7Smrg 10327a3b38f7Smrg 10337a3b38f7Smrg # Darwin sucks 10347a3b38f7Smrg eval std_shrext=\"$shrext_cmds\" 10357a3b38f7Smrg 10367a3b38f7Smrg 1037ff559fabSmrg # Only execute mode is allowed to have -dlopen flags. 1038ff559fabSmrg if test -n "$execute_dlfiles" && test "$mode" != execute; then 10397a3b38f7Smrg func_error "unrecognized option \`-dlopen'" 10407a3b38f7Smrg $ECHO "$help" 1>&2 1041ff559fabSmrg exit $EXIT_FAILURE 1042ff559fabSmrg fi 1043ff559fabSmrg 1044ff559fabSmrg # Change the help message to a mode-specific one. 1045ff559fabSmrg generic_help="$help" 10467a3b38f7Smrg help="Try \`$progname --help --mode=$mode' for more information." 10477a3b38f7Smrg} 1048ff559fabSmrg 1049ff559fabSmrg 10507a3b38f7Smrg# func_lalib_p file 10517a3b38f7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 10527a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out 10537a3b38f7Smrg# determined imposters. 10547a3b38f7Smrgfunc_lalib_p () 10557a3b38f7Smrg{ 10567a3b38f7Smrg test -f "$1" && 10577a3b38f7Smrg $SED -e 4q "$1" 2>/dev/null \ 10587a3b38f7Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 10597a3b38f7Smrg} 1060ff559fabSmrg 10617a3b38f7Smrg# func_lalib_unsafe_p file 10627a3b38f7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 10637a3b38f7Smrg# This function implements the same check as func_lalib_p without 10647a3b38f7Smrg# resorting to external programs. To this end, it redirects stdin and 10657a3b38f7Smrg# closes it afterwards, without saving the original file descriptor. 10667a3b38f7Smrg# As a safety measure, use it only where a negative result would be 10677a3b38f7Smrg# fatal anyway. Works if `file' does not exist. 10687a3b38f7Smrgfunc_lalib_unsafe_p () 10697a3b38f7Smrg{ 10707a3b38f7Smrg lalib_p=no 10717a3b38f7Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 10727a3b38f7Smrg for lalib_p_l in 1 2 3 4 10737a3b38f7Smrg do 10747a3b38f7Smrg read lalib_p_line 10757a3b38f7Smrg case "$lalib_p_line" in 10767a3b38f7Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 10777a3b38f7Smrg esac 10787a3b38f7Smrg done 10797a3b38f7Smrg exec 0<&5 5<&- 10807a3b38f7Smrg fi 10817a3b38f7Smrg test "$lalib_p" = yes 10827a3b38f7Smrg} 1083ff559fabSmrg 10847a3b38f7Smrg# func_ltwrapper_script_p file 10857a3b38f7Smrg# True iff FILE is a libtool wrapper script 10867a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out 10877a3b38f7Smrg# determined imposters. 10887a3b38f7Smrgfunc_ltwrapper_script_p () 10897a3b38f7Smrg{ 10907a3b38f7Smrg func_lalib_p "$1" 10917a3b38f7Smrg} 1092ff559fabSmrg 10937a3b38f7Smrg# func_ltwrapper_executable_p file 10947a3b38f7Smrg# True iff FILE is a libtool wrapper executable 10957a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out 10967a3b38f7Smrg# determined imposters. 10977a3b38f7Smrgfunc_ltwrapper_executable_p () 10987a3b38f7Smrg{ 10997a3b38f7Smrg func_ltwrapper_exec_suffix= 11007a3b38f7Smrg case $1 in 11017a3b38f7Smrg *.exe) ;; 11027a3b38f7Smrg *) func_ltwrapper_exec_suffix=.exe ;; 11037a3b38f7Smrg esac 11047a3b38f7Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 11057a3b38f7Smrg} 1106ff559fabSmrg 11077a3b38f7Smrg# func_ltwrapper_scriptname file 11087a3b38f7Smrg# Assumes file is an ltwrapper_executable 11097a3b38f7Smrg# uses $file to determine the appropriate filename for a 11107a3b38f7Smrg# temporary ltwrapper_script. 11117a3b38f7Smrgfunc_ltwrapper_scriptname () 11127a3b38f7Smrg{ 11137a3b38f7Smrg func_ltwrapper_scriptname_result="" 11147a3b38f7Smrg if func_ltwrapper_executable_p "$1"; then 11157a3b38f7Smrg func_dirname_and_basename "$1" "" "." 11167a3b38f7Smrg func_stripname '' '.exe' "$func_basename_result" 11177a3b38f7Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 11187a3b38f7Smrg fi 11197a3b38f7Smrg} 1120ff559fabSmrg 11217a3b38f7Smrg# func_ltwrapper_p file 11227a3b38f7Smrg# True iff FILE is a libtool wrapper script or wrapper executable 11237a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out 11247a3b38f7Smrg# determined imposters. 11257a3b38f7Smrgfunc_ltwrapper_p () 11267a3b38f7Smrg{ 11277a3b38f7Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 11287a3b38f7Smrg} 1129ff559fabSmrg 1130ff559fabSmrg 11317a3b38f7Smrg# func_execute_cmds commands fail_cmd 11327a3b38f7Smrg# Execute tilde-delimited COMMANDS. 11337a3b38f7Smrg# If FAIL_CMD is given, eval that upon failure. 11347a3b38f7Smrg# FAIL_CMD may read-access the current command in variable CMD! 11357a3b38f7Smrgfunc_execute_cmds () 11367a3b38f7Smrg{ 11377a3b38f7Smrg $opt_debug 11387a3b38f7Smrg save_ifs=$IFS; IFS='~' 11397a3b38f7Smrg for cmd in $1; do 11407a3b38f7Smrg IFS=$save_ifs 11417a3b38f7Smrg eval cmd=\"$cmd\" 11427a3b38f7Smrg func_show_eval "$cmd" "${2-:}" 11437a3b38f7Smrg done 11447a3b38f7Smrg IFS=$save_ifs 11457a3b38f7Smrg} 11467a3b38f7Smrg 11477a3b38f7Smrg 11487a3b38f7Smrg# func_source file 11497a3b38f7Smrg# Source FILE, adding directory component if necessary. 11507a3b38f7Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 11517a3b38f7Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 11527a3b38f7Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 11537a3b38f7Smrg# `FILE.' does not work on cygwin managed mounts. 11547a3b38f7Smrgfunc_source () 11557a3b38f7Smrg{ 11567a3b38f7Smrg $opt_debug 11577a3b38f7Smrg case $1 in 11587a3b38f7Smrg */* | *\\*) . "$1" ;; 11597a3b38f7Smrg *) . "./$1" ;; 11607a3b38f7Smrg esac 11617a3b38f7Smrg} 11627a3b38f7Smrg 11637a3b38f7Smrg 11647a3b38f7Smrg# func_infer_tag arg 11657a3b38f7Smrg# Infer tagged configuration to use if any are available and 11667a3b38f7Smrg# if one wasn't chosen via the "--tag" command line option. 11677a3b38f7Smrg# Only attempt this if the compiler in the base compile 11687a3b38f7Smrg# command doesn't match the default compiler. 11697a3b38f7Smrg# arg is usually of the form 'gcc ...' 11707a3b38f7Smrgfunc_infer_tag () 11717a3b38f7Smrg{ 11727a3b38f7Smrg $opt_debug 11737a3b38f7Smrg if test -n "$available_tags" && test -z "$tagname"; then 11747a3b38f7Smrg CC_quoted= 11757a3b38f7Smrg for arg in $CC; do 11767a3b38f7Smrg func_quote_for_eval "$arg" 11777a3b38f7Smrg CC_quoted="$CC_quoted $func_quote_for_eval_result" 11787a3b38f7Smrg done 117944dda7b2Smrg CC_expanded=`func_echo_all $CC` 118044dda7b2Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 11817a3b38f7Smrg case $@ in 11827a3b38f7Smrg # Blanks in the command may have been stripped by the calling shell, 11837a3b38f7Smrg # but not from the CC environment variable when configure was run. 118444dda7b2Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 118544dda7b2Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 11867a3b38f7Smrg # Blanks at the start of $base_compile will cause this to fail 11877a3b38f7Smrg # if we don't check for them as well. 11887a3b38f7Smrg *) 11897a3b38f7Smrg for z in $available_tags; do 11907a3b38f7Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 11917a3b38f7Smrg # Evaluate the configuration. 11927a3b38f7Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 11937a3b38f7Smrg CC_quoted= 11947a3b38f7Smrg for arg in $CC; do 11957a3b38f7Smrg # Double-quote args containing other shell metacharacters. 11967a3b38f7Smrg func_quote_for_eval "$arg" 11977a3b38f7Smrg CC_quoted="$CC_quoted $func_quote_for_eval_result" 11987a3b38f7Smrg done 119944dda7b2Smrg CC_expanded=`func_echo_all $CC` 120044dda7b2Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 12017a3b38f7Smrg case "$@ " in 120244dda7b2Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 120344dda7b2Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 12047a3b38f7Smrg # The compiler in the base compile command matches 12057a3b38f7Smrg # the one in the tagged configuration. 12067a3b38f7Smrg # Assume this is the tagged configuration we want. 12077a3b38f7Smrg tagname=$z 12087a3b38f7Smrg break 12097a3b38f7Smrg ;; 1210ff559fabSmrg esac 12117a3b38f7Smrg fi 12127a3b38f7Smrg done 12137a3b38f7Smrg # If $tagname still isn't set, then no tagged configuration 12147a3b38f7Smrg # was found and let the user know that the "--tag" command 12157a3b38f7Smrg # line option must be used. 12167a3b38f7Smrg if test -z "$tagname"; then 12177a3b38f7Smrg func_echo "unable to infer tagged configuration" 12187a3b38f7Smrg func_fatal_error "specify a tag with \`--tag'" 12197a3b38f7Smrg# else 12207a3b38f7Smrg# func_verbose "using $tagname tagged configuration" 12217a3b38f7Smrg fi 12227a3b38f7Smrg ;; 12237a3b38f7Smrg esac 12247a3b38f7Smrg fi 12257a3b38f7Smrg} 12267a3b38f7Smrg 12277a3b38f7Smrg 12287a3b38f7Smrg 12297a3b38f7Smrg# func_write_libtool_object output_name pic_name nonpic_name 12307a3b38f7Smrg# Create a libtool object file (analogous to a ".la" file), 12317a3b38f7Smrg# but don't create it if we're doing a dry run. 12327a3b38f7Smrgfunc_write_libtool_object () 12337a3b38f7Smrg{ 12347a3b38f7Smrg write_libobj=${1} 12357a3b38f7Smrg if test "$build_libtool_libs" = yes; then 12367a3b38f7Smrg write_lobj=\'${2}\' 12377a3b38f7Smrg else 12387a3b38f7Smrg write_lobj=none 12397a3b38f7Smrg fi 12407a3b38f7Smrg 12417a3b38f7Smrg if test "$build_old_libs" = yes; then 12427a3b38f7Smrg write_oldobj=\'${3}\' 12437a3b38f7Smrg else 12447a3b38f7Smrg write_oldobj=none 12457a3b38f7Smrg fi 12467a3b38f7Smrg 12477a3b38f7Smrg $opt_dry_run || { 12487a3b38f7Smrg cat >${write_libobj}T <<EOF 12497a3b38f7Smrg# $write_libobj - a libtool object file 12507a3b38f7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 12517a3b38f7Smrg# 12527a3b38f7Smrg# Please DO NOT delete this file! 12537a3b38f7Smrg# It is necessary for linking the library. 12547a3b38f7Smrg 12557a3b38f7Smrg# Name of the PIC object. 12567a3b38f7Smrgpic_object=$write_lobj 12577a3b38f7Smrg 12587a3b38f7Smrg# Name of the non-PIC object 12597a3b38f7Smrgnon_pic_object=$write_oldobj 12607a3b38f7Smrg 12617a3b38f7SmrgEOF 12627a3b38f7Smrg $MV "${write_libobj}T" "${write_libobj}" 12637a3b38f7Smrg } 12647a3b38f7Smrg} 12657a3b38f7Smrg 12667a3b38f7Smrg# func_mode_compile arg... 12677a3b38f7Smrgfunc_mode_compile () 12687a3b38f7Smrg{ 12697a3b38f7Smrg $opt_debug 12707a3b38f7Smrg # Get the compilation command and the source file. 12717a3b38f7Smrg base_compile= 12727a3b38f7Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 12737a3b38f7Smrg suppress_opt=yes 12747a3b38f7Smrg suppress_output= 12757a3b38f7Smrg arg_mode=normal 12767a3b38f7Smrg libobj= 12777a3b38f7Smrg later= 12787a3b38f7Smrg pie_flag= 12797a3b38f7Smrg 12807a3b38f7Smrg for arg 12817a3b38f7Smrg do 12827a3b38f7Smrg case $arg_mode in 12837a3b38f7Smrg arg ) 12847a3b38f7Smrg # do not "continue". Instead, add this to base_compile 12857a3b38f7Smrg lastarg="$arg" 12867a3b38f7Smrg arg_mode=normal 12877a3b38f7Smrg ;; 12887a3b38f7Smrg 12897a3b38f7Smrg target ) 12907a3b38f7Smrg libobj="$arg" 12917a3b38f7Smrg arg_mode=normal 12927a3b38f7Smrg continue 12937a3b38f7Smrg ;; 12947a3b38f7Smrg 12957a3b38f7Smrg normal ) 12967a3b38f7Smrg # Accept any command-line options. 12977a3b38f7Smrg case $arg in 12987a3b38f7Smrg -o) 12997a3b38f7Smrg test -n "$libobj" && \ 13007a3b38f7Smrg func_fatal_error "you cannot specify \`-o' more than once" 13017a3b38f7Smrg arg_mode=target 13027a3b38f7Smrg continue 13037a3b38f7Smrg ;; 13047a3b38f7Smrg 13057a3b38f7Smrg -pie | -fpie | -fPIE) 13067a3b38f7Smrg pie_flag="$pie_flag $arg" 13077a3b38f7Smrg continue 13087a3b38f7Smrg ;; 13097a3b38f7Smrg 13107a3b38f7Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 13117a3b38f7Smrg later="$later $arg" 13127a3b38f7Smrg continue 13137a3b38f7Smrg ;; 13147a3b38f7Smrg 13157a3b38f7Smrg -no-suppress) 13167a3b38f7Smrg suppress_opt=no 13177a3b38f7Smrg continue 13187a3b38f7Smrg ;; 13197a3b38f7Smrg 13207a3b38f7Smrg -Xcompiler) 13217a3b38f7Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 13227a3b38f7Smrg continue # The current "srcfile" will either be retained or 13237a3b38f7Smrg ;; # replaced later. I would guess that would be a bug. 13247a3b38f7Smrg 13257a3b38f7Smrg -Wc,*) 13267a3b38f7Smrg func_stripname '-Wc,' '' "$arg" 13277a3b38f7Smrg args=$func_stripname_result 13287a3b38f7Smrg lastarg= 13297a3b38f7Smrg save_ifs="$IFS"; IFS=',' 13307a3b38f7Smrg for arg in $args; do 13317a3b38f7Smrg IFS="$save_ifs" 13327a3b38f7Smrg func_quote_for_eval "$arg" 13337a3b38f7Smrg lastarg="$lastarg $func_quote_for_eval_result" 1334ff559fabSmrg done 1335ff559fabSmrg IFS="$save_ifs" 13367a3b38f7Smrg func_stripname ' ' '' "$lastarg" 13377a3b38f7Smrg lastarg=$func_stripname_result 1338ff559fabSmrg 1339ff559fabSmrg # Add the arguments to base_compile. 1340ff559fabSmrg base_compile="$base_compile $lastarg" 1341ff559fabSmrg continue 1342ff559fabSmrg ;; 1343ff559fabSmrg 13447a3b38f7Smrg *) 1345ff559fabSmrg # Accept the current argument as the source file. 1346ff559fabSmrg # The previous "srcfile" becomes the current argument. 1347ff559fabSmrg # 1348ff559fabSmrg lastarg="$srcfile" 1349ff559fabSmrg srcfile="$arg" 1350ff559fabSmrg ;; 1351ff559fabSmrg esac # case $arg 1352ff559fabSmrg ;; 1353ff559fabSmrg esac # case $arg_mode 1354ff559fabSmrg 1355ff559fabSmrg # Aesthetically quote the previous argument. 13567a3b38f7Smrg func_quote_for_eval "$lastarg" 13577a3b38f7Smrg base_compile="$base_compile $func_quote_for_eval_result" 1358ff559fabSmrg done # for arg 1359ff559fabSmrg 1360ff559fabSmrg case $arg_mode in 1361ff559fabSmrg arg) 13627a3b38f7Smrg func_fatal_error "you must specify an argument for -Xcompile" 1363ff559fabSmrg ;; 1364ff559fabSmrg target) 13657a3b38f7Smrg func_fatal_error "you must specify a target with \`-o'" 1366ff559fabSmrg ;; 1367ff559fabSmrg *) 1368ff559fabSmrg # Get the name of the library object. 13697a3b38f7Smrg test -z "$libobj" && { 13707a3b38f7Smrg func_basename "$srcfile" 13717a3b38f7Smrg libobj="$func_basename_result" 13727a3b38f7Smrg } 1373ff559fabSmrg ;; 1374ff559fabSmrg esac 1375ff559fabSmrg 1376ff559fabSmrg # Recognize several different file suffixes. 1377ff559fabSmrg # If the user specifies -o file.o, it is replaced with file.lo 1378ff559fabSmrg case $libobj in 13797a3b38f7Smrg *.[cCFSifmso] | \ 13807a3b38f7Smrg *.ada | *.adb | *.ads | *.asm | \ 13817a3b38f7Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 138244dda7b2Smrg *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) 13837a3b38f7Smrg func_xform "$libobj" 13847a3b38f7Smrg libobj=$func_xform_result 13857a3b38f7Smrg ;; 1386ff559fabSmrg esac 1387ff559fabSmrg 1388ff559fabSmrg case $libobj in 13897a3b38f7Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 1390ff559fabSmrg *) 13917a3b38f7Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 1392ff559fabSmrg ;; 1393ff559fabSmrg esac 1394ff559fabSmrg 1395ff559fabSmrg func_infer_tag $base_compile 1396ff559fabSmrg 1397ff559fabSmrg for arg in $later; do 1398ff559fabSmrg case $arg in 13997a3b38f7Smrg -shared) 14007a3b38f7Smrg test "$build_libtool_libs" != yes && \ 14017a3b38f7Smrg func_fatal_configuration "can not build a shared library" 14027a3b38f7Smrg build_old_libs=no 14037a3b38f7Smrg continue 14047a3b38f7Smrg ;; 14057a3b38f7Smrg 1406ff559fabSmrg -static) 14077a3b38f7Smrg build_libtool_libs=no 1408ff559fabSmrg build_old_libs=yes 1409ff559fabSmrg continue 1410ff559fabSmrg ;; 1411ff559fabSmrg 1412ff559fabSmrg -prefer-pic) 1413ff559fabSmrg pic_mode=yes 1414ff559fabSmrg continue 1415ff559fabSmrg ;; 1416ff559fabSmrg 1417ff559fabSmrg -prefer-non-pic) 1418ff559fabSmrg pic_mode=no 1419ff559fabSmrg continue 1420ff559fabSmrg ;; 1421ff559fabSmrg esac 1422ff559fabSmrg done 1423ff559fabSmrg 14247a3b38f7Smrg func_quote_for_eval "$libobj" 14257a3b38f7Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 14267a3b38f7Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 14277a3b38f7Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 14287a3b38f7Smrg func_dirname_and_basename "$obj" "/" "" 14297a3b38f7Smrg objname="$func_basename_result" 14307a3b38f7Smrg xdir="$func_dirname_result" 1431ff559fabSmrg lobj=${xdir}$objdir/$objname 1432ff559fabSmrg 14337a3b38f7Smrg test -z "$base_compile" && \ 14347a3b38f7Smrg func_fatal_help "you must specify a compilation command" 1435ff559fabSmrg 1436ff559fabSmrg # Delete any leftover library objects. 1437ff559fabSmrg if test "$build_old_libs" = yes; then 1438ff559fabSmrg removelist="$obj $lobj $libobj ${libobj}T" 1439ff559fabSmrg else 1440ff559fabSmrg removelist="$lobj $libobj ${libobj}T" 1441ff559fabSmrg fi 1442ff559fabSmrg 1443ff559fabSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 1444ff559fabSmrg case $host_os in 14457a3b38f7Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 1446ff559fabSmrg pic_mode=default 1447ff559fabSmrg ;; 1448ff559fabSmrg esac 1449ff559fabSmrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 1450ff559fabSmrg # non-PIC code in shared libraries is not supported 1451ff559fabSmrg pic_mode=default 1452ff559fabSmrg fi 1453ff559fabSmrg 1454ff559fabSmrg # Calculate the filename of the output object if compiler does 1455ff559fabSmrg # not support -o with -c 1456ff559fabSmrg if test "$compiler_c_o" = no; then 145744dda7b2Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 1458ff559fabSmrg lockfile="$output_obj.lock" 1459ff559fabSmrg else 1460ff559fabSmrg output_obj= 1461ff559fabSmrg need_locks=no 1462ff559fabSmrg lockfile= 1463ff559fabSmrg fi 1464ff559fabSmrg 1465ff559fabSmrg # Lock this critical section if it is needed 1466ff559fabSmrg # We use this script file to make the link, it avoids creating a new file 1467ff559fabSmrg if test "$need_locks" = yes; then 14687a3b38f7Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 14697a3b38f7Smrg func_echo "Waiting for $lockfile to be removed" 1470ff559fabSmrg sleep 2 1471ff559fabSmrg done 1472ff559fabSmrg elif test "$need_locks" = warn; then 1473ff559fabSmrg if test -f "$lockfile"; then 14747a3b38f7Smrg $ECHO "\ 1475ff559fabSmrg*** ERROR, $lockfile exists and contains: 1476ff559fabSmrg`cat $lockfile 2>/dev/null` 1477ff559fabSmrg 1478ff559fabSmrgThis indicates that another process is trying to use the same 1479ff559fabSmrgtemporary object file, and libtool could not work around it because 1480ff559fabSmrgyour compiler does not support \`-c' and \`-o' together. If you 1481ff559fabSmrgrepeat this compilation, it may succeed, by chance, but you had better 1482ff559fabSmrgavoid parallel builds (make -j) in this platform, or get a better 1483ff559fabSmrgcompiler." 1484ff559fabSmrg 14857a3b38f7Smrg $opt_dry_run || $RM $removelist 1486ff559fabSmrg exit $EXIT_FAILURE 1487ff559fabSmrg fi 14887a3b38f7Smrg removelist="$removelist $output_obj" 14897a3b38f7Smrg $ECHO "$srcfile" > "$lockfile" 1490ff559fabSmrg fi 1491ff559fabSmrg 14927a3b38f7Smrg $opt_dry_run || $RM $removelist 14937a3b38f7Smrg removelist="$removelist $lockfile" 14947a3b38f7Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 14957a3b38f7Smrg 1496ff559fabSmrg if test -n "$fix_srcfile_path"; then 1497ff559fabSmrg eval srcfile=\"$fix_srcfile_path\" 1498ff559fabSmrg fi 14997a3b38f7Smrg func_quote_for_eval "$srcfile" 15007a3b38f7Smrg qsrcfile=$func_quote_for_eval_result 1501ff559fabSmrg 1502ff559fabSmrg # Only build a PIC object if we are building libtool libraries. 1503ff559fabSmrg if test "$build_libtool_libs" = yes; then 1504ff559fabSmrg # Without this assignment, base_compile gets emptied. 1505ff559fabSmrg fbsd_hideous_sh_bug=$base_compile 1506ff559fabSmrg 1507ff559fabSmrg if test "$pic_mode" != no; then 1508ff559fabSmrg command="$base_compile $qsrcfile $pic_flag" 1509ff559fabSmrg else 1510ff559fabSmrg # Don't build PIC code 1511ff559fabSmrg command="$base_compile $qsrcfile" 1512ff559fabSmrg fi 1513ff559fabSmrg 15147a3b38f7Smrg func_mkdir_p "$xdir$objdir" 1515ff559fabSmrg 1516ff559fabSmrg if test -z "$output_obj"; then 1517ff559fabSmrg # Place PIC objects in $objdir 1518ff559fabSmrg command="$command -o $lobj" 1519ff559fabSmrg fi 1520ff559fabSmrg 15217a3b38f7Smrg func_show_eval_locale "$command" \ 15227a3b38f7Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 1523ff559fabSmrg 1524ff559fabSmrg if test "$need_locks" = warn && 1525ff559fabSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 15267a3b38f7Smrg $ECHO "\ 1527ff559fabSmrg*** ERROR, $lockfile contains: 1528ff559fabSmrg`cat $lockfile 2>/dev/null` 1529ff559fabSmrg 1530ff559fabSmrgbut it should contain: 1531ff559fabSmrg$srcfile 1532ff559fabSmrg 1533ff559fabSmrgThis indicates that another process is trying to use the same 1534ff559fabSmrgtemporary object file, and libtool could not work around it because 1535ff559fabSmrgyour compiler does not support \`-c' and \`-o' together. If you 1536ff559fabSmrgrepeat this compilation, it may succeed, by chance, but you had better 1537ff559fabSmrgavoid parallel builds (make -j) in this platform, or get a better 1538ff559fabSmrgcompiler." 1539ff559fabSmrg 15407a3b38f7Smrg $opt_dry_run || $RM $removelist 1541ff559fabSmrg exit $EXIT_FAILURE 1542ff559fabSmrg fi 1543ff559fabSmrg 1544ff559fabSmrg # Just move the object if needed, then go on to compile the next one 1545ff559fabSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 15467a3b38f7Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 15477a3b38f7Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 1548ff559fabSmrg fi 1549ff559fabSmrg 1550ff559fabSmrg # Allow error messages only from the first compilation. 1551ff559fabSmrg if test "$suppress_opt" = yes; then 15527a3b38f7Smrg suppress_output=' >/dev/null 2>&1' 1553ff559fabSmrg fi 1554ff559fabSmrg fi 1555ff559fabSmrg 1556ff559fabSmrg # Only build a position-dependent object if we build old libraries. 1557ff559fabSmrg if test "$build_old_libs" = yes; then 1558ff559fabSmrg if test "$pic_mode" != yes; then 1559ff559fabSmrg # Don't build PIC code 15607a3b38f7Smrg command="$base_compile $qsrcfile$pie_flag" 1561ff559fabSmrg else 1562ff559fabSmrg command="$base_compile $qsrcfile $pic_flag" 1563ff559fabSmrg fi 1564ff559fabSmrg if test "$compiler_c_o" = yes; then 1565ff559fabSmrg command="$command -o $obj" 1566ff559fabSmrg fi 1567ff559fabSmrg 1568ff559fabSmrg # Suppress compiler output if we already did a PIC compilation. 1569ff559fabSmrg command="$command$suppress_output" 15707a3b38f7Smrg func_show_eval_locale "$command" \ 15717a3b38f7Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1572ff559fabSmrg 1573ff559fabSmrg if test "$need_locks" = warn && 1574ff559fabSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 15757a3b38f7Smrg $ECHO "\ 1576ff559fabSmrg*** ERROR, $lockfile contains: 1577ff559fabSmrg`cat $lockfile 2>/dev/null` 1578ff559fabSmrg 1579ff559fabSmrgbut it should contain: 1580ff559fabSmrg$srcfile 1581ff559fabSmrg 1582ff559fabSmrgThis indicates that another process is trying to use the same 1583ff559fabSmrgtemporary object file, and libtool could not work around it because 1584ff559fabSmrgyour compiler does not support \`-c' and \`-o' together. If you 1585ff559fabSmrgrepeat this compilation, it may succeed, by chance, but you had better 1586ff559fabSmrgavoid parallel builds (make -j) in this platform, or get a better 1587ff559fabSmrgcompiler." 1588ff559fabSmrg 15897a3b38f7Smrg $opt_dry_run || $RM $removelist 1590ff559fabSmrg exit $EXIT_FAILURE 1591ff559fabSmrg fi 1592ff559fabSmrg 1593ff559fabSmrg # Just move the object if needed 1594ff559fabSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 15957a3b38f7Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 15967a3b38f7Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 1597ff559fabSmrg fi 1598ff559fabSmrg fi 1599ff559fabSmrg 16007a3b38f7Smrg $opt_dry_run || { 16017a3b38f7Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 1602ff559fabSmrg 16037a3b38f7Smrg # Unlock the critical section if it was locked 16047a3b38f7Smrg if test "$need_locks" != no; then 16057a3b38f7Smrg removelist=$lockfile 16067a3b38f7Smrg $RM "$lockfile" 16077a3b38f7Smrg fi 16087a3b38f7Smrg } 1609ff559fabSmrg 1610ff559fabSmrg exit $EXIT_SUCCESS 16117a3b38f7Smrg} 1612ff559fabSmrg 16137a3b38f7Smrg$opt_help || { 161444dda7b2Smrg test "$mode" = compile && func_mode_compile ${1+"$@"} 16157a3b38f7Smrg} 1616ff559fabSmrg 16177a3b38f7Smrgfunc_mode_help () 16187a3b38f7Smrg{ 16197a3b38f7Smrg # We need to display help for each of the modes. 16207a3b38f7Smrg case $mode in 16217a3b38f7Smrg "") 16227a3b38f7Smrg # Generic help is extracted from the usage comments 16237a3b38f7Smrg # at the start of this file. 16247a3b38f7Smrg func_help 16257a3b38f7Smrg ;; 1626ff559fabSmrg 16277a3b38f7Smrg clean) 16287a3b38f7Smrg $ECHO \ 16297a3b38f7Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 1630ff559fabSmrg 16317a3b38f7SmrgRemove files from the build directory. 1632ff559fabSmrg 16337a3b38f7SmrgRM is the name of the program to use to delete files associated with each FILE 16347a3b38f7Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 16357a3b38f7Smrgto RM. 1636ff559fabSmrg 16377a3b38f7SmrgIf FILE is a libtool library, object or program, all the files associated 16387a3b38f7Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 16397a3b38f7Smrg ;; 1640ff559fabSmrg 16417a3b38f7Smrg compile) 16427a3b38f7Smrg $ECHO \ 16437a3b38f7Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 1644ff559fabSmrg 16457a3b38f7SmrgCompile a source file into a libtool library object. 1646ff559fabSmrg 16477a3b38f7SmrgThis mode accepts the following additional options: 1648ff559fabSmrg 16497a3b38f7Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 16507a3b38f7Smrg -no-suppress do not suppress compiler output for multiple passes 165144dda7b2Smrg -prefer-pic try to build PIC objects only 165244dda7b2Smrg -prefer-non-pic try to build non-PIC objects only 16537a3b38f7Smrg -shared do not build a \`.o' file suitable for static linking 16547a3b38f7Smrg -static only build a \`.o' file suitable for static linking 165544dda7b2Smrg -Wc,FLAG pass FLAG directly to the compiler 1656ff559fabSmrg 16577a3b38f7SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 16587a3b38f7Smrgfrom the given SOURCEFILE. 1659ff559fabSmrg 16607a3b38f7SmrgThe output file name is determined by removing the directory component from 16617a3b38f7SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 16627a3b38f7Smrglibrary object suffix, \`.lo'." 16637a3b38f7Smrg ;; 1664ff559fabSmrg 16657a3b38f7Smrg execute) 16667a3b38f7Smrg $ECHO \ 16677a3b38f7Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 1668ff559fabSmrg 16697a3b38f7SmrgAutomatically set library path, then run a program. 1670ff559fabSmrg 16717a3b38f7SmrgThis mode accepts the following additional options: 1672ff559fabSmrg 16737a3b38f7Smrg -dlopen FILE add the directory containing FILE to the library path 1674ff559fabSmrg 16757a3b38f7SmrgThis mode sets the library path environment variable according to \`-dlopen' 16767a3b38f7Smrgflags. 1677ff559fabSmrg 16787a3b38f7SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 16797a3b38f7Smrginto their corresponding uninstalled binary, and any of their required library 16807a3b38f7Smrgdirectories are added to the library path. 1681ff559fabSmrg 16827a3b38f7SmrgThen, COMMAND is executed, with ARGS as arguments." 16837a3b38f7Smrg ;; 1684ff559fabSmrg 16857a3b38f7Smrg finish) 16867a3b38f7Smrg $ECHO \ 16877a3b38f7Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 1688ff559fabSmrg 16897a3b38f7SmrgComplete the installation of libtool libraries. 1690ff559fabSmrg 16917a3b38f7SmrgEach LIBDIR is a directory that contains libtool libraries. 1692ff559fabSmrg 16937a3b38f7SmrgThe commands that this mode executes may require superuser privileges. Use 16947a3b38f7Smrgthe \`--dry-run' option if you just want to see what would be executed." 16957a3b38f7Smrg ;; 1696ff559fabSmrg 16977a3b38f7Smrg install) 16987a3b38f7Smrg $ECHO \ 16997a3b38f7Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 1700ff559fabSmrg 17017a3b38f7SmrgInstall executables or libraries. 1702ff559fabSmrg 17037a3b38f7SmrgINSTALL-COMMAND is the installation command. The first component should be 17047a3b38f7Smrgeither the \`install' or \`cp' program. 1705ff559fabSmrg 17067a3b38f7SmrgThe following components of INSTALL-COMMAND are treated specially: 1707ff559fabSmrg 170844dda7b2Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 1709ff559fabSmrg 17107a3b38f7SmrgThe rest of the components are interpreted as arguments to that command (only 17117a3b38f7SmrgBSD-compatible install options are recognized)." 17127a3b38f7Smrg ;; 1713ff559fabSmrg 17147a3b38f7Smrg link) 17157a3b38f7Smrg $ECHO \ 17167a3b38f7Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 1717ff559fabSmrg 17187a3b38f7SmrgLink object files or libraries together to form another library, or to 17197a3b38f7Smrgcreate an executable program. 1720ff559fabSmrg 17217a3b38f7SmrgLINK-COMMAND is a command using the C compiler that you would use to create 17227a3b38f7Smrga program from several object files. 1723ff559fabSmrg 17247a3b38f7SmrgThe following components of LINK-COMMAND are treated specially: 1725ff559fabSmrg 17267a3b38f7Smrg -all-static do not do any dynamic linking at all 17277a3b38f7Smrg -avoid-version do not add a version suffix if possible 172844dda7b2Smrg -bindir BINDIR specify path to binaries directory (for systems where 172944dda7b2Smrg libraries must be found in the PATH setting at runtime) 17307a3b38f7Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 17317a3b38f7Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 17327a3b38f7Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 17337a3b38f7Smrg -export-symbols SYMFILE 17347a3b38f7Smrg try to export only the symbols listed in SYMFILE 17357a3b38f7Smrg -export-symbols-regex REGEX 17367a3b38f7Smrg try to export only the symbols matching REGEX 17377a3b38f7Smrg -LLIBDIR search LIBDIR for required installed libraries 17387a3b38f7Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 17397a3b38f7Smrg -module build a library that can dlopened 17407a3b38f7Smrg -no-fast-install disable the fast-install mode 17417a3b38f7Smrg -no-install link a not-installable executable 17427a3b38f7Smrg -no-undefined declare that a library does not refer to external symbols 17437a3b38f7Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 17447a3b38f7Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 17457a3b38f7Smrg -precious-files-regex REGEX 17467a3b38f7Smrg don't remove output files matching REGEX 17477a3b38f7Smrg -release RELEASE specify package release information 17487a3b38f7Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 17497a3b38f7Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 17507a3b38f7Smrg -shared only do dynamic linking of libtool libraries 17517a3b38f7Smrg -shrext SUFFIX override the standard shared library file extension 17527a3b38f7Smrg -static do not do any dynamic linking of uninstalled libtool libraries 17537a3b38f7Smrg -static-libtool-libs 17547a3b38f7Smrg do not do any dynamic linking of libtool libraries 17557a3b38f7Smrg -version-info CURRENT[:REVISION[:AGE]] 17567a3b38f7Smrg specify library version info [each variable defaults to 0] 17577a3b38f7Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 175844dda7b2Smrg -Wc,FLAG 175944dda7b2Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 176044dda7b2Smrg -Wl,FLAG 176144dda7b2Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 176244dda7b2Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 1763ff559fabSmrg 17647a3b38f7SmrgAll other options (arguments beginning with \`-') are ignored. 1765ff559fabSmrg 17667a3b38f7SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 17677a3b38f7Smrgtreated as uninstalled libtool libraries, other files are standard or library 17687a3b38f7Smrgobject files. 1769ff559fabSmrg 17707a3b38f7SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 17717a3b38f7Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 17727a3b38f7Smrgrequired, except when creating a convenience library. 1773ff559fabSmrg 17747a3b38f7SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 17757a3b38f7Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 1776ff559fabSmrg 17777a3b38f7SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 17787a3b38f7Smrgis created, otherwise an executable program is created." 1779ff559fabSmrg ;; 1780ff559fabSmrg 17817a3b38f7Smrg uninstall) 17827a3b38f7Smrg $ECHO \ 17837a3b38f7Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 1784ff559fabSmrg 17857a3b38f7SmrgRemove libraries from an installation directory. 1786ff559fabSmrg 17877a3b38f7SmrgRM is the name of the program to use to delete files associated with each FILE 17887a3b38f7Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 17897a3b38f7Smrgto RM. 1790ff559fabSmrg 17917a3b38f7SmrgIf FILE is a libtool library, all the files associated with it are deleted. 17927a3b38f7SmrgOtherwise, only FILE itself is deleted using RM." 17937a3b38f7Smrg ;; 1794ff559fabSmrg 17957a3b38f7Smrg *) 17967a3b38f7Smrg func_fatal_help "invalid operation mode \`$mode'" 17977a3b38f7Smrg ;; 17987a3b38f7Smrg esac 1799ff559fabSmrg 180044dda7b2Smrg echo 18017a3b38f7Smrg $ECHO "Try \`$progname --help' for more information about other modes." 18027a3b38f7Smrg} 1803ff559fabSmrg 180444dda7b2Smrg# Now that we've collected a possible --mode arg, show help if necessary 180544dda7b2Smrgif $opt_help; then 180644dda7b2Smrg if test "$opt_help" = :; then 180744dda7b2Smrg func_mode_help 180844dda7b2Smrg else 180944dda7b2Smrg { 181044dda7b2Smrg func_help noexit 181144dda7b2Smrg for mode in compile link execute install finish uninstall clean; do 181244dda7b2Smrg func_mode_help 181344dda7b2Smrg done 181444dda7b2Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 181544dda7b2Smrg { 181644dda7b2Smrg func_help noexit 181744dda7b2Smrg for mode in compile link execute install finish uninstall clean; do 181844dda7b2Smrg echo 181944dda7b2Smrg func_mode_help 182044dda7b2Smrg done 182144dda7b2Smrg } | 182244dda7b2Smrg sed '1d 182344dda7b2Smrg /^When reporting/,/^Report/{ 182444dda7b2Smrg H 182544dda7b2Smrg d 182644dda7b2Smrg } 182744dda7b2Smrg $x 182844dda7b2Smrg /information about other modes/d 182944dda7b2Smrg /more detailed .*MODE/d 183044dda7b2Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 183144dda7b2Smrg fi 183244dda7b2Smrg exit $? 183344dda7b2Smrgfi 1834ff559fabSmrg 1835ff559fabSmrg 18367a3b38f7Smrg# func_mode_execute arg... 18377a3b38f7Smrgfunc_mode_execute () 18387a3b38f7Smrg{ 18397a3b38f7Smrg $opt_debug 18407a3b38f7Smrg # The first argument is the command name. 18417a3b38f7Smrg cmd="$nonopt" 18427a3b38f7Smrg test -z "$cmd" && \ 18437a3b38f7Smrg func_fatal_help "you must specify a COMMAND" 1844ff559fabSmrg 18457a3b38f7Smrg # Handle -dlopen flags immediately. 18467a3b38f7Smrg for file in $execute_dlfiles; do 18477a3b38f7Smrg test -f "$file" \ 18487a3b38f7Smrg || func_fatal_help "\`$file' is not a file" 1849ff559fabSmrg 18507a3b38f7Smrg dir= 18517a3b38f7Smrg case $file in 18527a3b38f7Smrg *.la) 18537a3b38f7Smrg # Check to see that this really is a libtool archive. 18547a3b38f7Smrg func_lalib_unsafe_p "$file" \ 18557a3b38f7Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 1856ff559fabSmrg 18577a3b38f7Smrg # Read the libtool library. 18587a3b38f7Smrg dlname= 18597a3b38f7Smrg library_names= 18607a3b38f7Smrg func_source "$file" 1861ff559fabSmrg 18627a3b38f7Smrg # Skip this library if it cannot be dlopened. 18637a3b38f7Smrg if test -z "$dlname"; then 18647a3b38f7Smrg # Warn if it was a shared library. 18657a3b38f7Smrg test -n "$library_names" && \ 18667a3b38f7Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 18677a3b38f7Smrg continue 18687a3b38f7Smrg fi 1869ff559fabSmrg 18707a3b38f7Smrg func_dirname "$file" "" "." 18717a3b38f7Smrg dir="$func_dirname_result" 1872ff559fabSmrg 18737a3b38f7Smrg if test -f "$dir/$objdir/$dlname"; then 18747a3b38f7Smrg dir="$dir/$objdir" 18757a3b38f7Smrg else 18767a3b38f7Smrg if test ! -f "$dir/$dlname"; then 18777a3b38f7Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 18787a3b38f7Smrg fi 18797a3b38f7Smrg fi 1880ff559fabSmrg ;; 1881ff559fabSmrg 18827a3b38f7Smrg *.lo) 18837a3b38f7Smrg # Just add the directory containing the .lo file. 18847a3b38f7Smrg func_dirname "$file" "" "." 18857a3b38f7Smrg dir="$func_dirname_result" 1886ff559fabSmrg ;; 1887ff559fabSmrg 18887a3b38f7Smrg *) 18897a3b38f7Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 1890ff559fabSmrg continue 1891ff559fabSmrg ;; 18927a3b38f7Smrg esac 1893ff559fabSmrg 18947a3b38f7Smrg # Get the absolute pathname. 18957a3b38f7Smrg absdir=`cd "$dir" && pwd` 18967a3b38f7Smrg test -n "$absdir" && dir="$absdir" 1897ff559fabSmrg 18987a3b38f7Smrg # Now add the directory to shlibpath_var. 18997a3b38f7Smrg if eval "test -z \"\$$shlibpath_var\""; then 19007a3b38f7Smrg eval "$shlibpath_var=\"\$dir\"" 19017a3b38f7Smrg else 19027a3b38f7Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 19037a3b38f7Smrg fi 19047a3b38f7Smrg done 1905ff559fabSmrg 19067a3b38f7Smrg # This variable tells wrapper scripts just to set shlibpath_var 19077a3b38f7Smrg # rather than running their programs. 19087a3b38f7Smrg libtool_execute_magic="$magic" 1909ff559fabSmrg 19107a3b38f7Smrg # Check if any of the arguments is a wrapper script. 19117a3b38f7Smrg args= 19127a3b38f7Smrg for file 19137a3b38f7Smrg do 19147a3b38f7Smrg case $file in 191544dda7b2Smrg -* | *.la | *.lo ) ;; 19167a3b38f7Smrg *) 19177a3b38f7Smrg # Do a test to see if this is really a libtool program. 19187a3b38f7Smrg if func_ltwrapper_script_p "$file"; then 19197a3b38f7Smrg func_source "$file" 19207a3b38f7Smrg # Transform arg to wrapped name. 19217a3b38f7Smrg file="$progdir/$program" 19227a3b38f7Smrg elif func_ltwrapper_executable_p "$file"; then 19237a3b38f7Smrg func_ltwrapper_scriptname "$file" 19247a3b38f7Smrg func_source "$func_ltwrapper_scriptname_result" 19257a3b38f7Smrg # Transform arg to wrapped name. 19267a3b38f7Smrg file="$progdir/$program" 19277a3b38f7Smrg fi 19287a3b38f7Smrg ;; 19297a3b38f7Smrg esac 19307a3b38f7Smrg # Quote arguments (to preserve shell metacharacters). 19317a3b38f7Smrg func_quote_for_eval "$file" 19327a3b38f7Smrg args="$args $func_quote_for_eval_result" 19337a3b38f7Smrg done 1934ff559fabSmrg 19357a3b38f7Smrg if test "X$opt_dry_run" = Xfalse; then 19367a3b38f7Smrg if test -n "$shlibpath_var"; then 19377a3b38f7Smrg # Export the shlibpath_var. 19387a3b38f7Smrg eval "export $shlibpath_var" 19397a3b38f7Smrg fi 1940ff559fabSmrg 19417a3b38f7Smrg # Restore saved environment variables 19427a3b38f7Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 19437a3b38f7Smrg do 19447a3b38f7Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 19457a3b38f7Smrg $lt_var=\$save_$lt_var; export $lt_var 19467a3b38f7Smrg else 19477a3b38f7Smrg $lt_unset $lt_var 19487a3b38f7Smrg fi" 19497a3b38f7Smrg done 1950ff559fabSmrg 19517a3b38f7Smrg # Now prepare to actually exec the command. 19527a3b38f7Smrg exec_cmd="\$cmd$args" 19537a3b38f7Smrg else 19547a3b38f7Smrg # Display what would be done. 19557a3b38f7Smrg if test -n "$shlibpath_var"; then 19567a3b38f7Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 195744dda7b2Smrg echo "export $shlibpath_var" 19587a3b38f7Smrg fi 19597a3b38f7Smrg $ECHO "$cmd$args" 19607a3b38f7Smrg exit $EXIT_SUCCESS 19617a3b38f7Smrg fi 19627a3b38f7Smrg} 1963ff559fabSmrg 19647a3b38f7Smrgtest "$mode" = execute && func_mode_execute ${1+"$@"} 1965ff559fabSmrg 1966ff559fabSmrg 19677a3b38f7Smrg# func_mode_finish arg... 19687a3b38f7Smrgfunc_mode_finish () 19697a3b38f7Smrg{ 19707a3b38f7Smrg $opt_debug 19717a3b38f7Smrg libdirs="$nonopt" 19727a3b38f7Smrg admincmds= 1973ff559fabSmrg 19747a3b38f7Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 19757a3b38f7Smrg for dir 19767a3b38f7Smrg do 19777a3b38f7Smrg libdirs="$libdirs $dir" 19787a3b38f7Smrg done 1979ff559fabSmrg 19807a3b38f7Smrg for libdir in $libdirs; do 19817a3b38f7Smrg if test -n "$finish_cmds"; then 19827a3b38f7Smrg # Do each command in the finish commands. 19837a3b38f7Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 19847a3b38f7Smrg'"$cmd"'"' 19857a3b38f7Smrg fi 19867a3b38f7Smrg if test -n "$finish_eval"; then 19877a3b38f7Smrg # Do the single finish_eval. 19887a3b38f7Smrg eval cmds=\"$finish_eval\" 19897a3b38f7Smrg $opt_dry_run || eval "$cmds" || admincmds="$admincmds 19907a3b38f7Smrg $cmds" 19917a3b38f7Smrg fi 19927a3b38f7Smrg done 19937a3b38f7Smrg fi 1994ff559fabSmrg 19957a3b38f7Smrg # Exit here if they wanted silent mode. 19967a3b38f7Smrg $opt_silent && exit $EXIT_SUCCESS 1997ff559fabSmrg 199844dda7b2Smrg echo "----------------------------------------------------------------------" 199944dda7b2Smrg echo "Libraries have been installed in:" 20007a3b38f7Smrg for libdir in $libdirs; do 20017a3b38f7Smrg $ECHO " $libdir" 20027a3b38f7Smrg done 200344dda7b2Smrg echo 200444dda7b2Smrg echo "If you ever happen to want to link against installed libraries" 200544dda7b2Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 200644dda7b2Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 200744dda7b2Smrg echo "flag during linking and do at least one of the following:" 20087a3b38f7Smrg if test -n "$shlibpath_var"; then 200944dda7b2Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 201044dda7b2Smrg echo " during execution" 20117a3b38f7Smrg fi 20127a3b38f7Smrg if test -n "$runpath_var"; then 201344dda7b2Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 201444dda7b2Smrg echo " during linking" 20157a3b38f7Smrg fi 20167a3b38f7Smrg if test -n "$hardcode_libdir_flag_spec"; then 20177a3b38f7Smrg libdir=LIBDIR 20187a3b38f7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 2019ff559fabSmrg 20207a3b38f7Smrg $ECHO " - use the \`$flag' linker flag" 20217a3b38f7Smrg fi 20227a3b38f7Smrg if test -n "$admincmds"; then 20237a3b38f7Smrg $ECHO " - have your system administrator run these commands:$admincmds" 20247a3b38f7Smrg fi 20257a3b38f7Smrg if test -f /etc/ld.so.conf; then 202644dda7b2Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 20277a3b38f7Smrg fi 202844dda7b2Smrg echo 2029ff559fabSmrg 203044dda7b2Smrg echo "See any operating system documentation about shared libraries for" 20317a3b38f7Smrg case $host in 20327a3b38f7Smrg solaris2.[6789]|solaris2.1[0-9]) 203344dda7b2Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 203444dda7b2Smrg echo "pages." 2035ff559fabSmrg ;; 20367a3b38f7Smrg *) 203744dda7b2Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 20387a3b38f7Smrg ;; 20397a3b38f7Smrg esac 204044dda7b2Smrg echo "----------------------------------------------------------------------" 20417a3b38f7Smrg exit $EXIT_SUCCESS 20427a3b38f7Smrg} 2043ff559fabSmrg 20447a3b38f7Smrgtest "$mode" = finish && func_mode_finish ${1+"$@"} 2045ff559fabSmrg 2046ff559fabSmrg 20477a3b38f7Smrg# func_mode_install arg... 20487a3b38f7Smrgfunc_mode_install () 20497a3b38f7Smrg{ 20507a3b38f7Smrg $opt_debug 20517a3b38f7Smrg # There may be an optional sh(1) argument at the beginning of 20527a3b38f7Smrg # install_prog (especially on Windows NT). 20537a3b38f7Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 20547a3b38f7Smrg # Allow the use of GNU shtool's install command. 205544dda7b2Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 20567a3b38f7Smrg # Aesthetically quote it. 20577a3b38f7Smrg func_quote_for_eval "$nonopt" 20587a3b38f7Smrg install_prog="$func_quote_for_eval_result " 20597a3b38f7Smrg arg=$1 20607a3b38f7Smrg shift 20617a3b38f7Smrg else 20627a3b38f7Smrg install_prog= 20637a3b38f7Smrg arg=$nonopt 20647a3b38f7Smrg fi 2065ff559fabSmrg 20667a3b38f7Smrg # The real first argument should be the name of the installation program. 20677a3b38f7Smrg # Aesthetically quote it. 20687a3b38f7Smrg func_quote_for_eval "$arg" 20697a3b38f7Smrg install_prog="$install_prog$func_quote_for_eval_result" 207044dda7b2Smrg install_shared_prog=$install_prog 207144dda7b2Smrg case " $install_prog " in 207244dda7b2Smrg *[\\\ /]cp\ *) install_cp=: ;; 207344dda7b2Smrg *) install_cp=false ;; 207444dda7b2Smrg esac 20757a3b38f7Smrg 20767a3b38f7Smrg # We need to accept at least all the BSD install flags. 20777a3b38f7Smrg dest= 20787a3b38f7Smrg files= 20797a3b38f7Smrg opts= 20807a3b38f7Smrg prev= 20817a3b38f7Smrg install_type= 20827a3b38f7Smrg isdir=no 20837a3b38f7Smrg stripme= 208444dda7b2Smrg no_mode=: 20857a3b38f7Smrg for arg 20867a3b38f7Smrg do 208744dda7b2Smrg arg2= 20887a3b38f7Smrg if test -n "$dest"; then 20897a3b38f7Smrg files="$files $dest" 20907a3b38f7Smrg dest=$arg 20917a3b38f7Smrg continue 2092ff559fabSmrg fi 2093ff559fabSmrg 20947a3b38f7Smrg case $arg in 20957a3b38f7Smrg -d) isdir=yes ;; 20967a3b38f7Smrg -f) 209744dda7b2Smrg if $install_cp; then :; else 209844dda7b2Smrg prev=$arg 209944dda7b2Smrg fi 21007a3b38f7Smrg ;; 21017a3b38f7Smrg -g | -m | -o) 21027a3b38f7Smrg prev=$arg 21037a3b38f7Smrg ;; 21047a3b38f7Smrg -s) 21057a3b38f7Smrg stripme=" -s" 21067a3b38f7Smrg continue 21077a3b38f7Smrg ;; 21087a3b38f7Smrg -*) 21097a3b38f7Smrg ;; 21107a3b38f7Smrg *) 21117a3b38f7Smrg # If the previous option needed an argument, then skip it. 21127a3b38f7Smrg if test -n "$prev"; then 211344dda7b2Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 211444dda7b2Smrg arg2=$install_override_mode 211544dda7b2Smrg no_mode=false 211644dda7b2Smrg fi 21177a3b38f7Smrg prev= 21187a3b38f7Smrg else 21197a3b38f7Smrg dest=$arg 21207a3b38f7Smrg continue 21217a3b38f7Smrg fi 21227a3b38f7Smrg ;; 21237a3b38f7Smrg esac 2124ff559fabSmrg 21257a3b38f7Smrg # Aesthetically quote the argument. 21267a3b38f7Smrg func_quote_for_eval "$arg" 21277a3b38f7Smrg install_prog="$install_prog $func_quote_for_eval_result" 212844dda7b2Smrg if test -n "$arg2"; then 212944dda7b2Smrg func_quote_for_eval "$arg2" 213044dda7b2Smrg fi 213144dda7b2Smrg install_shared_prog="$install_shared_prog $func_quote_for_eval_result" 21327a3b38f7Smrg done 2133ff559fabSmrg 21347a3b38f7Smrg test -z "$install_prog" && \ 21357a3b38f7Smrg func_fatal_help "you must specify an install program" 2136ff559fabSmrg 21377a3b38f7Smrg test -n "$prev" && \ 21387a3b38f7Smrg func_fatal_help "the \`$prev' option requires an argument" 2139ff559fabSmrg 214044dda7b2Smrg if test -n "$install_override_mode" && $no_mode; then 214144dda7b2Smrg if $install_cp; then :; else 214244dda7b2Smrg func_quote_for_eval "$install_override_mode" 214344dda7b2Smrg install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result" 214444dda7b2Smrg fi 214544dda7b2Smrg fi 214644dda7b2Smrg 21477a3b38f7Smrg if test -z "$files"; then 21487a3b38f7Smrg if test -z "$dest"; then 21497a3b38f7Smrg func_fatal_help "no file or destination specified" 21507a3b38f7Smrg else 21517a3b38f7Smrg func_fatal_help "you must specify a destination" 2152ff559fabSmrg fi 2153ff559fabSmrg fi 2154ff559fabSmrg 21557a3b38f7Smrg # Strip any trailing slash from the destination. 21567a3b38f7Smrg func_stripname '' '/' "$dest" 21577a3b38f7Smrg dest=$func_stripname_result 2158ff559fabSmrg 21597a3b38f7Smrg # Check to see that the destination is a directory. 21607a3b38f7Smrg test -d "$dest" && isdir=yes 21617a3b38f7Smrg if test "$isdir" = yes; then 21627a3b38f7Smrg destdir="$dest" 21637a3b38f7Smrg destname= 21647a3b38f7Smrg else 21657a3b38f7Smrg func_dirname_and_basename "$dest" "" "." 21667a3b38f7Smrg destdir="$func_dirname_result" 21677a3b38f7Smrg destname="$func_basename_result" 21687a3b38f7Smrg 21697a3b38f7Smrg # Not a directory, so check to see that there is only one file specified. 21707a3b38f7Smrg set dummy $files; shift 21717a3b38f7Smrg test "$#" -gt 1 && \ 21727a3b38f7Smrg func_fatal_help "\`$dest' is not a directory" 21737a3b38f7Smrg fi 21747a3b38f7Smrg case $destdir in 21757a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 2176ff559fabSmrg *) 21777a3b38f7Smrg for file in $files; do 21787a3b38f7Smrg case $file in 21797a3b38f7Smrg *.lo) ;; 21807a3b38f7Smrg *) 21817a3b38f7Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 21827a3b38f7Smrg ;; 21837a3b38f7Smrg esac 21847a3b38f7Smrg done 2185ff559fabSmrg ;; 2186ff559fabSmrg esac 2187ff559fabSmrg 21887a3b38f7Smrg # This variable tells wrapper scripts just to set variables rather 21897a3b38f7Smrg # than running their programs. 21907a3b38f7Smrg libtool_install_magic="$magic" 2191ff559fabSmrg 21927a3b38f7Smrg staticlibs= 21937a3b38f7Smrg future_libdirs= 21947a3b38f7Smrg current_libdirs= 21957a3b38f7Smrg for file in $files; do 2196ff559fabSmrg 21977a3b38f7Smrg # Do each installation. 21987a3b38f7Smrg case $file in 21997a3b38f7Smrg *.$libext) 22007a3b38f7Smrg # Do the static libraries later. 22017a3b38f7Smrg staticlibs="$staticlibs $file" 22027a3b38f7Smrg ;; 22037a3b38f7Smrg 22047a3b38f7Smrg *.la) 22057a3b38f7Smrg # Check to see that this really is a libtool archive. 22067a3b38f7Smrg func_lalib_unsafe_p "$file" \ 22077a3b38f7Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 22087a3b38f7Smrg 22097a3b38f7Smrg library_names= 22107a3b38f7Smrg old_library= 22117a3b38f7Smrg relink_command= 22127a3b38f7Smrg func_source "$file" 22137a3b38f7Smrg 22147a3b38f7Smrg # Add the libdir to current_libdirs if it is the destination. 22157a3b38f7Smrg if test "X$destdir" = "X$libdir"; then 22167a3b38f7Smrg case "$current_libdirs " in 22177a3b38f7Smrg *" $libdir "*) ;; 22187a3b38f7Smrg *) current_libdirs="$current_libdirs $libdir" ;; 2219ff559fabSmrg esac 22207a3b38f7Smrg else 22217a3b38f7Smrg # Note the libdir as a future libdir. 22227a3b38f7Smrg case "$future_libdirs " in 22237a3b38f7Smrg *" $libdir "*) ;; 22247a3b38f7Smrg *) future_libdirs="$future_libdirs $libdir" ;; 22257a3b38f7Smrg esac 22267a3b38f7Smrg fi 2227ff559fabSmrg 22287a3b38f7Smrg func_dirname "$file" "/" "" 22297a3b38f7Smrg dir="$func_dirname_result" 22307a3b38f7Smrg dir="$dir$objdir" 22317a3b38f7Smrg 22327a3b38f7Smrg if test -n "$relink_command"; then 22337a3b38f7Smrg # Determine the prefix the user has applied to our future dir. 223444dda7b2Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 22357a3b38f7Smrg 22367a3b38f7Smrg # Don't allow the user to place us outside of our expected 22377a3b38f7Smrg # location b/c this prevents finding dependent libraries that 22387a3b38f7Smrg # are installed to the same prefix. 22397a3b38f7Smrg # At present, this check doesn't affect windows .dll's that 22407a3b38f7Smrg # are installed into $libdir/../bin (currently, that works fine) 22417a3b38f7Smrg # but it's something to keep an eye on. 22427a3b38f7Smrg test "$inst_prefix_dir" = "$destdir" && \ 22437a3b38f7Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 22447a3b38f7Smrg 22457a3b38f7Smrg if test -n "$inst_prefix_dir"; then 22467a3b38f7Smrg # Stick the inst_prefix_dir data into the link command. 224744dda7b2Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 22487a3b38f7Smrg else 224944dda7b2Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 22507a3b38f7Smrg fi 22517a3b38f7Smrg 22527a3b38f7Smrg func_warning "relinking \`$file'" 22537a3b38f7Smrg func_show_eval "$relink_command" \ 22547a3b38f7Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 22557a3b38f7Smrg fi 22567a3b38f7Smrg 22577a3b38f7Smrg # See the names of the shared library. 22587a3b38f7Smrg set dummy $library_names; shift 22597a3b38f7Smrg if test -n "$1"; then 22607a3b38f7Smrg realname="$1" 22617a3b38f7Smrg shift 22627a3b38f7Smrg 22637a3b38f7Smrg srcname="$realname" 22647a3b38f7Smrg test -n "$relink_command" && srcname="$realname"T 22657a3b38f7Smrg 22667a3b38f7Smrg # Install the shared library and build the symlinks. 226744dda7b2Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 22687a3b38f7Smrg 'exit $?' 22697a3b38f7Smrg tstripme="$stripme" 22707a3b38f7Smrg case $host_os in 22717a3b38f7Smrg cygwin* | mingw* | pw32* | cegcc*) 22727a3b38f7Smrg case $realname in 22737a3b38f7Smrg *.dll.a) 22747a3b38f7Smrg tstripme="" 22757a3b38f7Smrg ;; 22767a3b38f7Smrg esac 2277ff559fabSmrg ;; 2278ff559fabSmrg esac 22797a3b38f7Smrg if test -n "$tstripme" && test -n "$striplib"; then 22807a3b38f7Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 2281ff559fabSmrg fi 22827a3b38f7Smrg 22837a3b38f7Smrg if test "$#" -gt 0; then 22847a3b38f7Smrg # Delete the old symlinks, and create new ones. 22857a3b38f7Smrg # Try `ln -sf' first, because the `ln' binary might depend on 22867a3b38f7Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 22877a3b38f7Smrg # so we also need to try rm && ln -s. 22887a3b38f7Smrg for linkname 22897a3b38f7Smrg do 22907a3b38f7Smrg test "$linkname" != "$realname" \ 22917a3b38f7Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 2292ff559fabSmrg done 2293ff559fabSmrg fi 2294ff559fabSmrg 22957a3b38f7Smrg # Do each command in the postinstall commands. 22967a3b38f7Smrg lib="$destdir/$realname" 22977a3b38f7Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 2298ff559fabSmrg fi 2299ff559fabSmrg 23007a3b38f7Smrg # Install the pseudo-library for information purposes. 23017a3b38f7Smrg func_basename "$file" 23027a3b38f7Smrg name="$func_basename_result" 23037a3b38f7Smrg instname="$dir/$name"i 23047a3b38f7Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 2305ff559fabSmrg 23067a3b38f7Smrg # Maybe install the static library, too. 23077a3b38f7Smrg test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" 23087a3b38f7Smrg ;; 2309ff559fabSmrg 23107a3b38f7Smrg *.lo) 23117a3b38f7Smrg # Install (i.e. copy) a libtool object. 2312ff559fabSmrg 23137a3b38f7Smrg # Figure out destination file name, if it wasn't already specified. 23147a3b38f7Smrg if test -n "$destname"; then 23157a3b38f7Smrg destfile="$destdir/$destname" 23167a3b38f7Smrg else 23177a3b38f7Smrg func_basename "$file" 23187a3b38f7Smrg destfile="$func_basename_result" 23197a3b38f7Smrg destfile="$destdir/$destfile" 23207a3b38f7Smrg fi 23217a3b38f7Smrg 23227a3b38f7Smrg # Deduce the name of the destination old-style object file. 23237a3b38f7Smrg case $destfile in 23247a3b38f7Smrg *.lo) 23257a3b38f7Smrg func_lo2o "$destfile" 23267a3b38f7Smrg staticdest=$func_lo2o_result 23277a3b38f7Smrg ;; 23287a3b38f7Smrg *.$objext) 23297a3b38f7Smrg staticdest="$destfile" 23307a3b38f7Smrg destfile= 23317a3b38f7Smrg ;; 23327a3b38f7Smrg *) 23337a3b38f7Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 23347a3b38f7Smrg ;; 2335ff559fabSmrg esac 2336ff559fabSmrg 23377a3b38f7Smrg # Install the libtool object if requested. 23387a3b38f7Smrg test -n "$destfile" && \ 23397a3b38f7Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 23407a3b38f7Smrg 23417a3b38f7Smrg # Install the old object if enabled. 23427a3b38f7Smrg if test "$build_old_libs" = yes; then 23437a3b38f7Smrg # Deduce the name of the old-style object file. 23447a3b38f7Smrg func_lo2o "$file" 23457a3b38f7Smrg staticobj=$func_lo2o_result 23467a3b38f7Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 2347ff559fabSmrg fi 23487a3b38f7Smrg exit $EXIT_SUCCESS 23497a3b38f7Smrg ;; 2350ff559fabSmrg 23517a3b38f7Smrg *) 23527a3b38f7Smrg # Figure out destination file name, if it wasn't already specified. 23537a3b38f7Smrg if test -n "$destname"; then 23547a3b38f7Smrg destfile="$destdir/$destname" 23557a3b38f7Smrg else 23567a3b38f7Smrg func_basename "$file" 23577a3b38f7Smrg destfile="$func_basename_result" 23587a3b38f7Smrg destfile="$destdir/$destfile" 23597a3b38f7Smrg fi 23607a3b38f7Smrg 23617a3b38f7Smrg # If the file is missing, and there is a .exe on the end, strip it 23627a3b38f7Smrg # because it is most likely a libtool script we actually want to 23637a3b38f7Smrg # install 23647a3b38f7Smrg stripped_ext="" 23657a3b38f7Smrg case $file in 23667a3b38f7Smrg *.exe) 23677a3b38f7Smrg if test ! -f "$file"; then 23687a3b38f7Smrg func_stripname '' '.exe' "$file" 23697a3b38f7Smrg file=$func_stripname_result 23707a3b38f7Smrg stripped_ext=".exe" 2371ff559fabSmrg fi 23727a3b38f7Smrg ;; 23737a3b38f7Smrg esac 2374ff559fabSmrg 23757a3b38f7Smrg # Do a test to see if this is really a libtool program. 23767a3b38f7Smrg case $host in 23777a3b38f7Smrg *cygwin* | *mingw*) 23787a3b38f7Smrg if func_ltwrapper_executable_p "$file"; then 23797a3b38f7Smrg func_ltwrapper_scriptname "$file" 23807a3b38f7Smrg wrapper=$func_ltwrapper_scriptname_result 23817a3b38f7Smrg else 23827a3b38f7Smrg func_stripname '' '.exe' "$file" 23837a3b38f7Smrg wrapper=$func_stripname_result 23847a3b38f7Smrg fi 23857a3b38f7Smrg ;; 23867a3b38f7Smrg *) 23877a3b38f7Smrg wrapper=$file 23887a3b38f7Smrg ;; 23897a3b38f7Smrg esac 23907a3b38f7Smrg if func_ltwrapper_script_p "$wrapper"; then 23917a3b38f7Smrg notinst_deplibs= 23927a3b38f7Smrg relink_command= 2393ff559fabSmrg 23947a3b38f7Smrg func_source "$wrapper" 2395ff559fabSmrg 23967a3b38f7Smrg # Check the variables that should have been set. 23977a3b38f7Smrg test -z "$generated_by_libtool_version" && \ 23987a3b38f7Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 23997a3b38f7Smrg 24007a3b38f7Smrg finalize=yes 24017a3b38f7Smrg for lib in $notinst_deplibs; do 24027a3b38f7Smrg # Check to see that each library is installed. 24037a3b38f7Smrg libdir= 24047a3b38f7Smrg if test -f "$lib"; then 24057a3b38f7Smrg func_source "$lib" 24067a3b38f7Smrg fi 240744dda7b2Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 24087a3b38f7Smrg if test -n "$libdir" && test ! -f "$libfile"; then 24097a3b38f7Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 24107a3b38f7Smrg finalize=no 24117a3b38f7Smrg fi 24127a3b38f7Smrg done 24137a3b38f7Smrg 24147a3b38f7Smrg relink_command= 24157a3b38f7Smrg func_source "$wrapper" 24167a3b38f7Smrg 24177a3b38f7Smrg outputname= 24187a3b38f7Smrg if test "$fast_install" = no && test -n "$relink_command"; then 24197a3b38f7Smrg $opt_dry_run || { 24207a3b38f7Smrg if test "$finalize" = yes; then 24217a3b38f7Smrg tmpdir=`func_mktempdir` 24227a3b38f7Smrg func_basename "$file$stripped_ext" 24237a3b38f7Smrg file="$func_basename_result" 24247a3b38f7Smrg outputname="$tmpdir/$file" 24257a3b38f7Smrg # Replace the output file specification. 242644dda7b2Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 24277a3b38f7Smrg 24287a3b38f7Smrg $opt_silent || { 24297a3b38f7Smrg func_quote_for_expand "$relink_command" 24307a3b38f7Smrg eval "func_echo $func_quote_for_expand_result" 24317a3b38f7Smrg } 24327a3b38f7Smrg if eval "$relink_command"; then : 24337a3b38f7Smrg else 24347a3b38f7Smrg func_error "error: relink \`$file' with the above command before installing it" 24357a3b38f7Smrg $opt_dry_run || ${RM}r "$tmpdir" 24367a3b38f7Smrg continue 24377a3b38f7Smrg fi 24387a3b38f7Smrg file="$outputname" 24397a3b38f7Smrg else 24407a3b38f7Smrg func_warning "cannot relink \`$file'" 24417a3b38f7Smrg fi 24427a3b38f7Smrg } 2443ff559fabSmrg else 24447a3b38f7Smrg # Install the binary that we compiled earlier. 244544dda7b2Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 2446ff559fabSmrg fi 24477a3b38f7Smrg fi 2448ff559fabSmrg 24497a3b38f7Smrg # remove .exe since cygwin /usr/bin/install will append another 24507a3b38f7Smrg # one anyway 24517a3b38f7Smrg case $install_prog,$host in 24527a3b38f7Smrg */usr/bin/install*,*cygwin*) 24537a3b38f7Smrg case $file:$destfile in 24547a3b38f7Smrg *.exe:*.exe) 24557a3b38f7Smrg # this is ok 24567a3b38f7Smrg ;; 24577a3b38f7Smrg *.exe:*) 24587a3b38f7Smrg destfile=$destfile.exe 24597a3b38f7Smrg ;; 24607a3b38f7Smrg *:*.exe) 24617a3b38f7Smrg func_stripname '' '.exe' "$destfile" 24627a3b38f7Smrg destfile=$func_stripname_result 24637a3b38f7Smrg ;; 24647a3b38f7Smrg esac 2465ff559fabSmrg ;; 2466ff559fabSmrg esac 24677a3b38f7Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 24687a3b38f7Smrg $opt_dry_run || if test -n "$outputname"; then 24697a3b38f7Smrg ${RM}r "$tmpdir" 24707a3b38f7Smrg fi 24717a3b38f7Smrg ;; 24727a3b38f7Smrg esac 24737a3b38f7Smrg done 2474ff559fabSmrg 24757a3b38f7Smrg for file in $staticlibs; do 24767a3b38f7Smrg func_basename "$file" 24777a3b38f7Smrg name="$func_basename_result" 2478ff559fabSmrg 24797a3b38f7Smrg # Set up the ranlib parameters. 24807a3b38f7Smrg oldlib="$destdir/$name" 2481ff559fabSmrg 24827a3b38f7Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 2483ff559fabSmrg 24847a3b38f7Smrg if test -n "$stripme" && test -n "$old_striplib"; then 24857a3b38f7Smrg func_show_eval "$old_striplib $oldlib" 'exit $?' 24867a3b38f7Smrg fi 2487ff559fabSmrg 24887a3b38f7Smrg # Do each command in the postinstall commands. 24897a3b38f7Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 24907a3b38f7Smrg done 2491ff559fabSmrg 24927a3b38f7Smrg test -n "$future_libdirs" && \ 24937a3b38f7Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 2494ff559fabSmrg 24957a3b38f7Smrg if test -n "$current_libdirs"; then 24967a3b38f7Smrg # Maybe just do a dry run. 24977a3b38f7Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 24987a3b38f7Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 24997a3b38f7Smrg else 25007a3b38f7Smrg exit $EXIT_SUCCESS 25017a3b38f7Smrg fi 25027a3b38f7Smrg} 2503ff559fabSmrg 25047a3b38f7Smrgtest "$mode" = install && func_mode_install ${1+"$@"} 2505ff559fabSmrg 2506ff559fabSmrg 25077a3b38f7Smrg# func_generate_dlsyms outputname originator pic_p 25087a3b38f7Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 25097a3b38f7Smrg# a dlpreopen symbol table. 25107a3b38f7Smrgfunc_generate_dlsyms () 25117a3b38f7Smrg{ 25127a3b38f7Smrg $opt_debug 25137a3b38f7Smrg my_outputname="$1" 25147a3b38f7Smrg my_originator="$2" 25157a3b38f7Smrg my_pic_p="${3-no}" 25167a3b38f7Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 25177a3b38f7Smrg my_dlsyms= 25187a3b38f7Smrg 25197a3b38f7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 25207a3b38f7Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 25217a3b38f7Smrg my_dlsyms="${my_outputname}S.c" 25227a3b38f7Smrg else 25237a3b38f7Smrg func_error "not configured to extract global symbols from dlpreopened files" 25247a3b38f7Smrg fi 25257a3b38f7Smrg fi 2526ff559fabSmrg 25277a3b38f7Smrg if test -n "$my_dlsyms"; then 25287a3b38f7Smrg case $my_dlsyms in 25297a3b38f7Smrg "") ;; 25307a3b38f7Smrg *.c) 25317a3b38f7Smrg # Discover the nlist of each of the dlfiles. 25327a3b38f7Smrg nlist="$output_objdir/${my_outputname}.nm" 25337a3b38f7Smrg 25347a3b38f7Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 25357a3b38f7Smrg 25367a3b38f7Smrg # Parse the name list into a source file. 25377a3b38f7Smrg func_verbose "creating $output_objdir/$my_dlsyms" 25387a3b38f7Smrg 25397a3b38f7Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 25407a3b38f7Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 25417a3b38f7Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 25427a3b38f7Smrg 25437a3b38f7Smrg#ifdef __cplusplus 25447a3b38f7Smrgextern \"C\" { 25457a3b38f7Smrg#endif 25467a3b38f7Smrg 254744dda7b2Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 254844dda7b2Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 254944dda7b2Smrg#endif 255044dda7b2Smrg 25517a3b38f7Smrg/* External symbol declarations for the compiler. */\ 25527a3b38f7Smrg" 25537a3b38f7Smrg 25547a3b38f7Smrg if test "$dlself" = yes; then 25557a3b38f7Smrg func_verbose "generating symbol list for \`$output'" 25567a3b38f7Smrg 25577a3b38f7Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 25587a3b38f7Smrg 25597a3b38f7Smrg # Add our own program objects to the symbol list. 256044dda7b2Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 25617a3b38f7Smrg for progfile in $progfiles; do 25627a3b38f7Smrg func_verbose "extracting global C symbols from \`$progfile'" 25637a3b38f7Smrg $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" 25647a3b38f7Smrg done 25657a3b38f7Smrg 25667a3b38f7Smrg if test -n "$exclude_expsyms"; then 25677a3b38f7Smrg $opt_dry_run || { 25687a3b38f7Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 25697a3b38f7Smrg eval '$MV "$nlist"T "$nlist"' 25707a3b38f7Smrg } 2571ff559fabSmrg fi 2572ff559fabSmrg 25737a3b38f7Smrg if test -n "$export_symbols_regex"; then 25747a3b38f7Smrg $opt_dry_run || { 25757a3b38f7Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 25767a3b38f7Smrg eval '$MV "$nlist"T "$nlist"' 25777a3b38f7Smrg } 2578ff559fabSmrg fi 25797a3b38f7Smrg 25807a3b38f7Smrg # Prepare the list of exported symbols 25817a3b38f7Smrg if test -z "$export_symbols"; then 25827a3b38f7Smrg export_symbols="$output_objdir/$outputname.exp" 25837a3b38f7Smrg $opt_dry_run || { 25847a3b38f7Smrg $RM $export_symbols 25857a3b38f7Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 25867a3b38f7Smrg case $host in 25877a3b38f7Smrg *cygwin* | *mingw* | *cegcc* ) 25887a3b38f7Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 25897a3b38f7Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 25907a3b38f7Smrg ;; 2591ff559fabSmrg esac 25927a3b38f7Smrg } 25937a3b38f7Smrg else 25947a3b38f7Smrg $opt_dry_run || { 25957a3b38f7Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 25967a3b38f7Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 25977a3b38f7Smrg eval '$MV "$nlist"T "$nlist"' 25987a3b38f7Smrg case $host in 259944dda7b2Smrg *cygwin* | *mingw* | *cegcc* ) 26007a3b38f7Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 26017a3b38f7Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 26027a3b38f7Smrg ;; 2603ff559fabSmrg esac 26047a3b38f7Smrg } 2605ff559fabSmrg fi 26067a3b38f7Smrg fi 2607ff559fabSmrg 26087a3b38f7Smrg for dlprefile in $dlprefiles; do 26097a3b38f7Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 26107a3b38f7Smrg func_basename "$dlprefile" 26117a3b38f7Smrg name="$func_basename_result" 26127a3b38f7Smrg $opt_dry_run || { 26137a3b38f7Smrg eval '$ECHO ": $name " >> "$nlist"' 26147a3b38f7Smrg eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" 26157a3b38f7Smrg } 26167a3b38f7Smrg done 2617ff559fabSmrg 26187a3b38f7Smrg $opt_dry_run || { 26197a3b38f7Smrg # Make sure we have at least an empty file. 26207a3b38f7Smrg test -f "$nlist" || : > "$nlist" 2621ff559fabSmrg 26227a3b38f7Smrg if test -n "$exclude_expsyms"; then 26237a3b38f7Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 26247a3b38f7Smrg $MV "$nlist"T "$nlist" 2625ff559fabSmrg fi 2626ff559fabSmrg 26277a3b38f7Smrg # Try sorting and uniquifying the output. 26287a3b38f7Smrg if $GREP -v "^: " < "$nlist" | 26297a3b38f7Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 26307a3b38f7Smrg sort -k 3 2631ff559fabSmrg else 26327a3b38f7Smrg sort +2 26337a3b38f7Smrg fi | 26347a3b38f7Smrg uniq > "$nlist"S; then 26357a3b38f7Smrg : 2636ff559fabSmrg else 26377a3b38f7Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 2638ff559fabSmrg fi 2639ff559fabSmrg 26407a3b38f7Smrg if test -f "$nlist"S; then 26417a3b38f7Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 2642ff559fabSmrg else 264344dda7b2Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 2644ff559fabSmrg fi 2645ff559fabSmrg 264644dda7b2Smrg echo >> "$output_objdir/$my_dlsyms" "\ 2647ff559fabSmrg 26487a3b38f7Smrg/* The mapping between symbol names and symbols. */ 26497a3b38f7Smrgtypedef struct { 26507a3b38f7Smrg const char *name; 26517a3b38f7Smrg void *address; 26527a3b38f7Smrg} lt_dlsymlist; 26537a3b38f7Smrg" 26547a3b38f7Smrg case $host in 26557a3b38f7Smrg *cygwin* | *mingw* | *cegcc* ) 265644dda7b2Smrg echo >> "$output_objdir/$my_dlsyms" "\ 26577a3b38f7Smrg/* DATA imports from DLLs on WIN32 con't be const, because 26587a3b38f7Smrg runtime relocations are performed -- see ld's documentation 26597a3b38f7Smrg on pseudo-relocs. */" 26607a3b38f7Smrg lt_dlsym_const= ;; 26617a3b38f7Smrg *osf5*) 26627a3b38f7Smrg echo >> "$output_objdir/$my_dlsyms" "\ 26637a3b38f7Smrg/* This system does not cope well with relocations in const data */" 26647a3b38f7Smrg lt_dlsym_const= ;; 26657a3b38f7Smrg *) 26667a3b38f7Smrg lt_dlsym_const=const ;; 26677a3b38f7Smrg esac 26687a3b38f7Smrg 266944dda7b2Smrg echo >> "$output_objdir/$my_dlsyms" "\ 26707a3b38f7Smrgextern $lt_dlsym_const lt_dlsymlist 26717a3b38f7Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 26727a3b38f7Smrg$lt_dlsym_const lt_dlsymlist 26737a3b38f7Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 26747a3b38f7Smrg{\ 26757a3b38f7Smrg { \"$my_originator\", (void *) 0 }," 26767a3b38f7Smrg 26777a3b38f7Smrg case $need_lib_prefix in 26787a3b38f7Smrg no) 26797a3b38f7Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 26807a3b38f7Smrg ;; 26817a3b38f7Smrg *) 26827a3b38f7Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 26837a3b38f7Smrg ;; 26847a3b38f7Smrg esac 268544dda7b2Smrg echo >> "$output_objdir/$my_dlsyms" "\ 26867a3b38f7Smrg {0, (void *) 0} 26877a3b38f7Smrg}; 26887a3b38f7Smrg 26897a3b38f7Smrg/* This works around a problem in FreeBSD linker */ 26907a3b38f7Smrg#ifdef FREEBSD_WORKAROUND 26917a3b38f7Smrgstatic const void *lt_preloaded_setup() { 26927a3b38f7Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 26937a3b38f7Smrg} 26947a3b38f7Smrg#endif 26957a3b38f7Smrg 26967a3b38f7Smrg#ifdef __cplusplus 26977a3b38f7Smrg} 26987a3b38f7Smrg#endif\ 26997a3b38f7Smrg" 27007a3b38f7Smrg } # !$opt_dry_run 27017a3b38f7Smrg 27027a3b38f7Smrg pic_flag_for_symtable= 27037a3b38f7Smrg case "$compile_command " in 27047a3b38f7Smrg *" -static "*) ;; 27057a3b38f7Smrg *) 27067a3b38f7Smrg case $host in 27077a3b38f7Smrg # compiling the symbol table file with pic_flag works around 27087a3b38f7Smrg # a FreeBSD bug that causes programs to crash when -lm is 27097a3b38f7Smrg # linked before any other PIC object. But we must not use 27107a3b38f7Smrg # pic_flag when linking with -static. The problem exists in 27117a3b38f7Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 27127a3b38f7Smrg *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 27137a3b38f7Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 27147a3b38f7Smrg *-*-hpux*) 27157a3b38f7Smrg pic_flag_for_symtable=" $pic_flag" ;; 27167a3b38f7Smrg *) 27177a3b38f7Smrg if test "X$my_pic_p" != Xno; then 27187a3b38f7Smrg pic_flag_for_symtable=" $pic_flag" 2719ff559fabSmrg fi 27207a3b38f7Smrg ;; 27217a3b38f7Smrg esac 27227a3b38f7Smrg ;; 27237a3b38f7Smrg esac 27247a3b38f7Smrg symtab_cflags= 27257a3b38f7Smrg for arg in $LTCFLAGS; do 27267a3b38f7Smrg case $arg in 27277a3b38f7Smrg -pie | -fpie | -fPIE) ;; 27287a3b38f7Smrg *) symtab_cflags="$symtab_cflags $arg" ;; 27297a3b38f7Smrg esac 27307a3b38f7Smrg done 2731ff559fabSmrg 27327a3b38f7Smrg # Now compile the dynamic symbol file. 27337a3b38f7Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 2734ff559fabSmrg 27357a3b38f7Smrg # Clean up the generated files. 27367a3b38f7Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 27377a3b38f7Smrg 27387a3b38f7Smrg # Transform the symbol file into the correct name. 27397a3b38f7Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 27407a3b38f7Smrg case $host in 27417a3b38f7Smrg *cygwin* | *mingw* | *cegcc* ) 27427a3b38f7Smrg if test -f "$output_objdir/$my_outputname.def"; then 274344dda7b2Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 274444dda7b2Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 27457a3b38f7Smrg else 274644dda7b2Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 274744dda7b2Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 27487a3b38f7Smrg fi 27497a3b38f7Smrg ;; 27507a3b38f7Smrg *) 275144dda7b2Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 275244dda7b2Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 2753ff559fabSmrg ;; 2754ff559fabSmrg esac 27557a3b38f7Smrg ;; 27567a3b38f7Smrg *) 27577a3b38f7Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 27587a3b38f7Smrg ;; 27597a3b38f7Smrg esac 27607a3b38f7Smrg else 27617a3b38f7Smrg # We keep going just in case the user didn't refer to 27627a3b38f7Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 27637a3b38f7Smrg # really was required. 27647a3b38f7Smrg 27657a3b38f7Smrg # Nullify the symbol file. 276644dda7b2Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 276744dda7b2Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 2768ff559fabSmrg fi 27697a3b38f7Smrg} 2770ff559fabSmrg 27717a3b38f7Smrg# func_win32_libid arg 27727a3b38f7Smrg# return the library type of file 'arg' 27737a3b38f7Smrg# 27747a3b38f7Smrg# Need a lot of goo to handle *both* DLLs and import libs 27757a3b38f7Smrg# Has to be a shell function in order to 'eat' the argument 27767a3b38f7Smrg# that is supplied when $file_magic_command is called. 277744dda7b2Smrg# Despite the name, also deal with 64 bit binaries. 27787a3b38f7Smrgfunc_win32_libid () 27797a3b38f7Smrg{ 27807a3b38f7Smrg $opt_debug 27817a3b38f7Smrg win32_libid_type="unknown" 27827a3b38f7Smrg win32_fileres=`file -L $1 2>/dev/null` 27837a3b38f7Smrg case $win32_fileres in 27847a3b38f7Smrg *ar\ archive\ import\ library*) # definitely import 27857a3b38f7Smrg win32_libid_type="x86 archive import" 27867a3b38f7Smrg ;; 27877a3b38f7Smrg *ar\ archive*) # could be an import, or static 278844dda7b2Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 27897a3b38f7Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 279044dda7b2Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 27917a3b38f7Smrg win32_nmres=`eval $NM -f posix -A $1 | 27927a3b38f7Smrg $SED -n -e ' 27937a3b38f7Smrg 1,100{ 27947a3b38f7Smrg / I /{ 27957a3b38f7Smrg s,.*,import, 27967a3b38f7Smrg p 27977a3b38f7Smrg q 27987a3b38f7Smrg } 27997a3b38f7Smrg }'` 28007a3b38f7Smrg case $win32_nmres in 28017a3b38f7Smrg import*) win32_libid_type="x86 archive import";; 28027a3b38f7Smrg *) win32_libid_type="x86 archive static";; 28037a3b38f7Smrg esac 28047a3b38f7Smrg fi 28057a3b38f7Smrg ;; 28067a3b38f7Smrg *DLL*) 28077a3b38f7Smrg win32_libid_type="x86 DLL" 28087a3b38f7Smrg ;; 28097a3b38f7Smrg *executable*) # but shell scripts are "executable" too... 28107a3b38f7Smrg case $win32_fileres in 28117a3b38f7Smrg *MS\ Windows\ PE\ Intel*) 28127a3b38f7Smrg win32_libid_type="x86 DLL" 28137a3b38f7Smrg ;; 28147a3b38f7Smrg esac 28157a3b38f7Smrg ;; 28167a3b38f7Smrg esac 28177a3b38f7Smrg $ECHO "$win32_libid_type" 28187a3b38f7Smrg} 2819ff559fabSmrg 2820ff559fabSmrg 2821ff559fabSmrg 28227a3b38f7Smrg# func_extract_an_archive dir oldlib 28237a3b38f7Smrgfunc_extract_an_archive () 28247a3b38f7Smrg{ 28257a3b38f7Smrg $opt_debug 28267a3b38f7Smrg f_ex_an_ar_dir="$1"; shift 28277a3b38f7Smrg f_ex_an_ar_oldlib="$1" 282844dda7b2Smrg if test "$lock_old_archive_extraction" = yes; then 282944dda7b2Smrg lockfile=$f_ex_an_ar_oldlib.lock 283044dda7b2Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 283144dda7b2Smrg func_echo "Waiting for $lockfile to be removed" 283244dda7b2Smrg sleep 2 283344dda7b2Smrg done 283444dda7b2Smrg fi 283544dda7b2Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 283644dda7b2Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 283744dda7b2Smrg if test "$lock_old_archive_extraction" = yes; then 283844dda7b2Smrg $opt_dry_run || rm -f "$lockfile" 283944dda7b2Smrg fi 28407a3b38f7Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 28417a3b38f7Smrg : 28427a3b38f7Smrg else 28437a3b38f7Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 28447a3b38f7Smrg fi 28457a3b38f7Smrg} 2846ff559fabSmrg 2847ff559fabSmrg 28487a3b38f7Smrg# func_extract_archives gentop oldlib ... 28497a3b38f7Smrgfunc_extract_archives () 28507a3b38f7Smrg{ 28517a3b38f7Smrg $opt_debug 28527a3b38f7Smrg my_gentop="$1"; shift 28537a3b38f7Smrg my_oldlibs=${1+"$@"} 28547a3b38f7Smrg my_oldobjs="" 28557a3b38f7Smrg my_xlib="" 28567a3b38f7Smrg my_xabs="" 28577a3b38f7Smrg my_xdir="" 2858ff559fabSmrg 28597a3b38f7Smrg for my_xlib in $my_oldlibs; do 28607a3b38f7Smrg # Extract the objects. 28617a3b38f7Smrg case $my_xlib in 28627a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 28637a3b38f7Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 28647a3b38f7Smrg esac 28657a3b38f7Smrg func_basename "$my_xlib" 28667a3b38f7Smrg my_xlib="$func_basename_result" 28677a3b38f7Smrg my_xlib_u=$my_xlib 28687a3b38f7Smrg while :; do 28697a3b38f7Smrg case " $extracted_archives " in 28707a3b38f7Smrg *" $my_xlib_u "*) 28717a3b38f7Smrg func_arith $extracted_serial + 1 28727a3b38f7Smrg extracted_serial=$func_arith_result 28737a3b38f7Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 28747a3b38f7Smrg *) break ;; 28757a3b38f7Smrg esac 28767a3b38f7Smrg done 28777a3b38f7Smrg extracted_archives="$extracted_archives $my_xlib_u" 28787a3b38f7Smrg my_xdir="$my_gentop/$my_xlib_u" 2879ff559fabSmrg 28807a3b38f7Smrg func_mkdir_p "$my_xdir" 2881ff559fabSmrg 28827a3b38f7Smrg case $host in 28837a3b38f7Smrg *-darwin*) 28847a3b38f7Smrg func_verbose "Extracting $my_xabs" 28857a3b38f7Smrg # Do not bother doing anything if just a dry run 28867a3b38f7Smrg $opt_dry_run || { 28877a3b38f7Smrg darwin_orig_dir=`pwd` 28887a3b38f7Smrg cd $my_xdir || exit $? 28897a3b38f7Smrg darwin_archive=$my_xabs 28907a3b38f7Smrg darwin_curdir=`pwd` 28917a3b38f7Smrg darwin_base_archive=`basename "$darwin_archive"` 28927a3b38f7Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 28937a3b38f7Smrg if test -n "$darwin_arches"; then 28947a3b38f7Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 28957a3b38f7Smrg darwin_arch= 28967a3b38f7Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 28977a3b38f7Smrg for darwin_arch in $darwin_arches ; do 28987a3b38f7Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 28997a3b38f7Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 29007a3b38f7Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 29017a3b38f7Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 29027a3b38f7Smrg cd "$darwin_curdir" 29037a3b38f7Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 29047a3b38f7Smrg done # $darwin_arches 29057a3b38f7Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 29067a3b38f7Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 29077a3b38f7Smrg darwin_file= 29087a3b38f7Smrg darwin_files= 29097a3b38f7Smrg for darwin_file in $darwin_filelist; do 291044dda7b2Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 29117a3b38f7Smrg $LIPO -create -output "$darwin_file" $darwin_files 29127a3b38f7Smrg done # $darwin_filelist 29137a3b38f7Smrg $RM -rf unfat-$$ 29147a3b38f7Smrg cd "$darwin_orig_dir" 29157a3b38f7Smrg else 29167a3b38f7Smrg cd $darwin_orig_dir 29177a3b38f7Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 29187a3b38f7Smrg fi # $darwin_arches 29197a3b38f7Smrg } # !$opt_dry_run 29207a3b38f7Smrg ;; 29217a3b38f7Smrg *) 29227a3b38f7Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 29237a3b38f7Smrg ;; 2924ff559fabSmrg esac 292544dda7b2Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 29267a3b38f7Smrg done 2927ff559fabSmrg 29287a3b38f7Smrg func_extract_archives_result="$my_oldobjs" 29297a3b38f7Smrg} 2930ff559fabSmrg 2931ff559fabSmrg 293244dda7b2Smrg# func_emit_wrapper [arg=no] 293344dda7b2Smrg# 293444dda7b2Smrg# Emit a libtool wrapper script on stdout. 293544dda7b2Smrg# Don't directly open a file because we may want to 293644dda7b2Smrg# incorporate the script contents within a cygwin/mingw 293744dda7b2Smrg# wrapper executable. Must ONLY be called from within 293844dda7b2Smrg# func_mode_link because it depends on a number of variables 293944dda7b2Smrg# set therein. 29407a3b38f7Smrg# 294144dda7b2Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 294244dda7b2Smrg# variable will take. If 'yes', then the emitted script 294344dda7b2Smrg# will assume that the directory in which it is stored is 294444dda7b2Smrg# the $objdir directory. This is a cygwin/mingw-specific 294544dda7b2Smrg# behavior. 294644dda7b2Smrgfunc_emit_wrapper () 29477a3b38f7Smrg{ 294844dda7b2Smrg func_emit_wrapper_arg1=${1-no} 2949ff559fabSmrg 29507a3b38f7Smrg $ECHO "\ 29517a3b38f7Smrg#! $SHELL 2952ff559fabSmrg 29537a3b38f7Smrg# $output - temporary wrapper script for $objdir/$outputname 29547a3b38f7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 29557a3b38f7Smrg# 29567a3b38f7Smrg# The $output program cannot be directly executed until all the libtool 29577a3b38f7Smrg# libraries that it depends on are installed. 29587a3b38f7Smrg# 29597a3b38f7Smrg# This wrapper script should never be moved out of the build directory. 29607a3b38f7Smrg# If it is, it will not operate correctly. 2961ff559fabSmrg 29627a3b38f7Smrg# Sed substitution that helps us do robust quoting. It backslashifies 29637a3b38f7Smrg# metacharacters that are still active within double-quoted strings. 29647a3b38f7Smrgsed_quote_subst='$sed_quote_subst' 2965ff559fabSmrg 29667a3b38f7Smrg# Be Bourne compatible 29677a3b38f7Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 29687a3b38f7Smrg emulate sh 29697a3b38f7Smrg NULLCMD=: 29707a3b38f7Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 29717a3b38f7Smrg # is contrary to our usage. Disable this feature. 29727a3b38f7Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 29737a3b38f7Smrg setopt NO_GLOB_SUBST 29747a3b38f7Smrgelse 29757a3b38f7Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 29767a3b38f7Smrgfi 29777a3b38f7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 29787a3b38f7SmrgDUALCASE=1; export DUALCASE # for MKS sh 2979ff559fabSmrg 29807a3b38f7Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 29817a3b38f7Smrg# if CDPATH is set. 29827a3b38f7Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 2983ff559fabSmrg 29847a3b38f7Smrgrelink_command=\"$relink_command\" 2985ff559fabSmrg 29867a3b38f7Smrg# This environment variable determines our operation mode. 29877a3b38f7Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 29887a3b38f7Smrg # install mode needs the following variables: 29897a3b38f7Smrg generated_by_libtool_version='$macro_version' 29907a3b38f7Smrg notinst_deplibs='$notinst_deplibs' 29917a3b38f7Smrgelse 29927a3b38f7Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 29937a3b38f7Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 299444dda7b2Smrg file=\"\$0\"" 299544dda7b2Smrg 299644dda7b2Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 299744dda7b2Smrg $ECHO "\ 299844dda7b2Smrg 299944dda7b2Smrg# A function that is used when there is no print builtin or printf. 300044dda7b2Smrgfunc_fallback_echo () 300144dda7b2Smrg{ 300244dda7b2Smrg eval 'cat <<_LTECHO_EOF 300344dda7b2Smrg\$1 300444dda7b2Smrg_LTECHO_EOF' 300544dda7b2Smrg} 300644dda7b2Smrg ECHO=\"$qECHO\" 300744dda7b2Smrg fi 300844dda7b2Smrg 300944dda7b2Smrg# Very basic option parsing. These options are (a) specific to 301044dda7b2Smrg# the libtool wrapper, (b) are identical between the wrapper 301144dda7b2Smrg# /script/ and the wrapper /executable/ which is used only on 301244dda7b2Smrg# windows platforms, and (c) all begin with the string "--lt-" 301344dda7b2Smrg# (application programs are unlikely to have options which match 301444dda7b2Smrg# this pattern). 301544dda7b2Smrg# 301644dda7b2Smrg# There are only two supported options: --lt-debug and 301744dda7b2Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 301844dda7b2Smrg# 301944dda7b2Smrg# The first argument to this parsing function should be the 302044dda7b2Smrg# script's $0 value, followed by "$@". 302144dda7b2Smrglt_option_debug= 302244dda7b2Smrgfunc_parse_lt_options () 302344dda7b2Smrg{ 302444dda7b2Smrg lt_script_arg0=\$0 302544dda7b2Smrg shift 302644dda7b2Smrg for lt_opt 302744dda7b2Smrg do 302844dda7b2Smrg case \"\$lt_opt\" in 302944dda7b2Smrg --lt-debug) lt_option_debug=1 ;; 303044dda7b2Smrg --lt-dump-script) 303144dda7b2Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 303244dda7b2Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 303344dda7b2Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 303444dda7b2Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 303544dda7b2Smrg exit 0 303644dda7b2Smrg ;; 303744dda7b2Smrg --lt-*) 303844dda7b2Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 303944dda7b2Smrg exit 1 304044dda7b2Smrg ;; 304144dda7b2Smrg esac 304244dda7b2Smrg done 304344dda7b2Smrg 304444dda7b2Smrg # Print the debug banner immediately: 304544dda7b2Smrg if test -n \"\$lt_option_debug\"; then 304644dda7b2Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 304744dda7b2Smrg fi 304844dda7b2Smrg} 304944dda7b2Smrg 305044dda7b2Smrg# Used when --lt-debug. Prints its arguments to stdout 305144dda7b2Smrg# (redirection is the responsibility of the caller) 305244dda7b2Smrgfunc_lt_dump_args () 305344dda7b2Smrg{ 305444dda7b2Smrg lt_dump_args_N=1; 305544dda7b2Smrg for lt_arg 305644dda7b2Smrg do 305744dda7b2Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 305844dda7b2Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 305944dda7b2Smrg done 306044dda7b2Smrg} 306144dda7b2Smrg 306244dda7b2Smrg# Core function for launching the target application 306344dda7b2Smrgfunc_exec_program_core () 306444dda7b2Smrg{ 30657a3b38f7Smrg" 306644dda7b2Smrg case $host in 306744dda7b2Smrg # Backslashes separate directories on plain windows 306844dda7b2Smrg *-*-mingw | *-*-os2* | *-cegcc*) 306944dda7b2Smrg $ECHO "\ 307044dda7b2Smrg if test -n \"\$lt_option_debug\"; then 307144dda7b2Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 307244dda7b2Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 307344dda7b2Smrg fi 307444dda7b2Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 307544dda7b2Smrg" 307644dda7b2Smrg ;; 307744dda7b2Smrg 307844dda7b2Smrg *) 307944dda7b2Smrg $ECHO "\ 308044dda7b2Smrg if test -n \"\$lt_option_debug\"; then 308144dda7b2Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 308244dda7b2Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 308344dda7b2Smrg fi 308444dda7b2Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 308544dda7b2Smrg" 308644dda7b2Smrg ;; 308744dda7b2Smrg esac 308844dda7b2Smrg $ECHO "\ 308944dda7b2Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 309044dda7b2Smrg exit 1 309144dda7b2Smrg} 309244dda7b2Smrg 309344dda7b2Smrg# A function to encapsulate launching the target application 309444dda7b2Smrg# Strips options in the --lt-* namespace from \$@ and 309544dda7b2Smrg# launches target application with the remaining arguments. 309644dda7b2Smrgfunc_exec_program () 309744dda7b2Smrg{ 309844dda7b2Smrg for lt_wr_arg 309944dda7b2Smrg do 310044dda7b2Smrg case \$lt_wr_arg in 310144dda7b2Smrg --lt-*) ;; 310244dda7b2Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 310344dda7b2Smrg esac 310444dda7b2Smrg shift 310544dda7b2Smrg done 310644dda7b2Smrg func_exec_program_core \${1+\"\$@\"} 310744dda7b2Smrg} 310844dda7b2Smrg 310944dda7b2Smrg # Parse options 311044dda7b2Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 3111ff559fabSmrg 31127a3b38f7Smrg # Find the directory that this script lives in. 311344dda7b2Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 31147a3b38f7Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 3115ff559fabSmrg 31167a3b38f7Smrg # Follow symbolic links until we get to the real thisdir. 311744dda7b2Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 31187a3b38f7Smrg while test -n \"\$file\"; do 311944dda7b2Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 3120ff559fabSmrg 31217a3b38f7Smrg # If there was a directory component, then change thisdir. 31227a3b38f7Smrg if test \"x\$destdir\" != \"x\$file\"; then 31237a3b38f7Smrg case \"\$destdir\" in 31247a3b38f7Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 31257a3b38f7Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 31267a3b38f7Smrg esac 31277a3b38f7Smrg fi 3128ff559fabSmrg 312944dda7b2Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 313044dda7b2Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 31317a3b38f7Smrg done 3132ff559fabSmrg 31337a3b38f7Smrg # Usually 'no', except on cygwin/mingw when embedded into 31347a3b38f7Smrg # the cwrapper. 313544dda7b2Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 31367a3b38f7Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 31377a3b38f7Smrg # special case for '.' 31387a3b38f7Smrg if test \"\$thisdir\" = \".\"; then 31397a3b38f7Smrg thisdir=\`pwd\` 31407a3b38f7Smrg fi 31417a3b38f7Smrg # remove .libs from thisdir 31427a3b38f7Smrg case \"\$thisdir\" in 314344dda7b2Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 31447a3b38f7Smrg $objdir ) thisdir=. ;; 31457a3b38f7Smrg esac 31467a3b38f7Smrg fi 3147ff559fabSmrg 31487a3b38f7Smrg # Try to get the absolute directory name. 31497a3b38f7Smrg absdir=\`cd \"\$thisdir\" && pwd\` 31507a3b38f7Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 31517a3b38f7Smrg" 3152ff559fabSmrg 31537a3b38f7Smrg if test "$fast_install" = yes; then 31547a3b38f7Smrg $ECHO "\ 31557a3b38f7Smrg program=lt-'$outputname'$exeext 31567a3b38f7Smrg progdir=\"\$thisdir/$objdir\" 3157ff559fabSmrg 31587a3b38f7Smrg if test ! -f \"\$progdir/\$program\" || 31597a3b38f7Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 31607a3b38f7Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 3161ff559fabSmrg 31627a3b38f7Smrg file=\"\$\$-\$program\" 3163ff559fabSmrg 31647a3b38f7Smrg if test ! -d \"\$progdir\"; then 31657a3b38f7Smrg $MKDIR \"\$progdir\" 31667a3b38f7Smrg else 31677a3b38f7Smrg $RM \"\$progdir/\$file\" 31687a3b38f7Smrg fi" 3169ff559fabSmrg 31707a3b38f7Smrg $ECHO "\ 3171ff559fabSmrg 31727a3b38f7Smrg # relink executable if necessary 31737a3b38f7Smrg if test -n \"\$relink_command\"; then 31747a3b38f7Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 31757a3b38f7Smrg else 31767a3b38f7Smrg $ECHO \"\$relink_command_output\" >&2 31777a3b38f7Smrg $RM \"\$progdir/\$file\" 31787a3b38f7Smrg exit 1 31797a3b38f7Smrg fi 31807a3b38f7Smrg fi 3181ff559fabSmrg 31827a3b38f7Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 31837a3b38f7Smrg { $RM \"\$progdir/\$program\"; 31847a3b38f7Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 31857a3b38f7Smrg $RM \"\$progdir/\$file\" 31867a3b38f7Smrg fi" 31877a3b38f7Smrg else 31887a3b38f7Smrg $ECHO "\ 31897a3b38f7Smrg program='$outputname' 31907a3b38f7Smrg progdir=\"\$thisdir/$objdir\" 31917a3b38f7Smrg" 31927a3b38f7Smrg fi 3193ff559fabSmrg 31947a3b38f7Smrg $ECHO "\ 3195ff559fabSmrg 31967a3b38f7Smrg if test -f \"\$progdir/\$program\"; then" 3197ff559fabSmrg 31987a3b38f7Smrg # Export our shlibpath_var if we have one. 31997a3b38f7Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 32007a3b38f7Smrg $ECHO "\ 32017a3b38f7Smrg # Add our own library path to $shlibpath_var 32027a3b38f7Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 3203ff559fabSmrg 32047a3b38f7Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 32057a3b38f7Smrg # The second colon is a workaround for a bug in BeOS R4 sed 320644dda7b2Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 3207ff559fabSmrg 32087a3b38f7Smrg export $shlibpath_var 32097a3b38f7Smrg" 3210ff559fabSmrg fi 3211ff559fabSmrg 32127a3b38f7Smrg # fixup the dll searchpath if we need to. 32137a3b38f7Smrg if test -n "$dllsearchpath"; then 32147a3b38f7Smrg $ECHO "\ 32157a3b38f7Smrg # Add the dll search path components to the executable PATH 32167a3b38f7Smrg PATH=$dllsearchpath:\$PATH 32177a3b38f7Smrg" 3218ff559fabSmrg fi 3219ff559fabSmrg 32207a3b38f7Smrg $ECHO "\ 32217a3b38f7Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 32227a3b38f7Smrg # Run the actual program with our arguments. 322344dda7b2Smrg func_exec_program \${1+\"\$@\"} 32247a3b38f7Smrg fi 32257a3b38f7Smrg else 32267a3b38f7Smrg # The program doesn't exist. 32277a3b38f7Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 32287a3b38f7Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 322944dda7b2Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 32307a3b38f7Smrg exit 1 32317a3b38f7Smrg fi 32327a3b38f7Smrgfi\ 32337a3b38f7Smrg" 32347a3b38f7Smrg} 3235ff559fabSmrg 3236ff559fabSmrg 32377a3b38f7Smrg# func_to_host_path arg 32387a3b38f7Smrg# 32397a3b38f7Smrg# Convert paths to host format when used with build tools. 32407a3b38f7Smrg# Intended for use with "native" mingw (where libtool itself 32417a3b38f7Smrg# is running under the msys shell), or in the following cross- 32427a3b38f7Smrg# build environments: 32437a3b38f7Smrg# $build $host 32447a3b38f7Smrg# mingw (msys) mingw [e.g. native] 32457a3b38f7Smrg# cygwin mingw 32467a3b38f7Smrg# *nix + wine mingw 32477a3b38f7Smrg# where wine is equipped with the `winepath' executable. 32487a3b38f7Smrg# In the native mingw case, the (msys) shell automatically 32497a3b38f7Smrg# converts paths for any non-msys applications it launches, 32507a3b38f7Smrg# but that facility isn't available from inside the cwrapper. 32517a3b38f7Smrg# Similar accommodations are necessary for $host mingw and 32527a3b38f7Smrg# $build cygwin. Calling this function does no harm for other 32537a3b38f7Smrg# $host/$build combinations not listed above. 32547a3b38f7Smrg# 32557a3b38f7Smrg# ARG is the path (on $build) that should be converted to 32567a3b38f7Smrg# the proper representation for $host. The result is stored 32577a3b38f7Smrg# in $func_to_host_path_result. 32587a3b38f7Smrgfunc_to_host_path () 32597a3b38f7Smrg{ 32607a3b38f7Smrg func_to_host_path_result="$1" 326144dda7b2Smrg if test -n "$1"; then 32627a3b38f7Smrg case $host in 32637a3b38f7Smrg *mingw* ) 32647a3b38f7Smrg lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 32657a3b38f7Smrg case $build in 32667a3b38f7Smrg *mingw* ) # actually, msys 32677a3b38f7Smrg # awkward: cmd appends spaces to result 326844dda7b2Smrg func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null | 326944dda7b2Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 32707a3b38f7Smrg ;; 32717a3b38f7Smrg *cygwin* ) 327244dda7b2Smrg func_to_host_path_result=`cygpath -w "$1" | 327344dda7b2Smrg $SED -e "$lt_sed_naive_backslashify"` 32747a3b38f7Smrg ;; 32757a3b38f7Smrg * ) 32767a3b38f7Smrg # Unfortunately, winepath does not exit with a non-zero 32777a3b38f7Smrg # error code, so we are forced to check the contents of 32787a3b38f7Smrg # stdout. On the other hand, if the command is not 32797a3b38f7Smrg # found, the shell will set an exit code of 127 and print 32807a3b38f7Smrg # *an error message* to stdout. So we must check for both 32817a3b38f7Smrg # error code of zero AND non-empty stdout, which explains 32827a3b38f7Smrg # the odd construction: 32837a3b38f7Smrg func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` 32847a3b38f7Smrg if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then 328544dda7b2Smrg func_to_host_path_result=`$ECHO "$func_to_host_path_tmp1" | 32867a3b38f7Smrg $SED -e "$lt_sed_naive_backslashify"` 32877a3b38f7Smrg else 32887a3b38f7Smrg # Allow warning below. 328944dda7b2Smrg func_to_host_path_result= 32907a3b38f7Smrg fi 32917a3b38f7Smrg ;; 32927a3b38f7Smrg esac 32937a3b38f7Smrg if test -z "$func_to_host_path_result" ; then 32947a3b38f7Smrg func_error "Could not determine host path corresponding to" 329544dda7b2Smrg func_error " \`$1'" 32967a3b38f7Smrg func_error "Continuing, but uninstalled executables may not work." 32977a3b38f7Smrg # Fallback: 32987a3b38f7Smrg func_to_host_path_result="$1" 32997a3b38f7Smrg fi 33007a3b38f7Smrg ;; 33017a3b38f7Smrg esac 33027a3b38f7Smrg fi 33037a3b38f7Smrg} 33047a3b38f7Smrg# end: func_to_host_path 3305ff559fabSmrg 33067a3b38f7Smrg# func_to_host_pathlist arg 33077a3b38f7Smrg# 33087a3b38f7Smrg# Convert pathlists to host format when used with build tools. 33097a3b38f7Smrg# See func_to_host_path(), above. This function supports the 33107a3b38f7Smrg# following $build/$host combinations (but does no harm for 33117a3b38f7Smrg# combinations not listed here): 33127a3b38f7Smrg# $build $host 33137a3b38f7Smrg# mingw (msys) mingw [e.g. native] 33147a3b38f7Smrg# cygwin mingw 33157a3b38f7Smrg# *nix + wine mingw 33167a3b38f7Smrg# 33177a3b38f7Smrg# Path separators are also converted from $build format to 33187a3b38f7Smrg# $host format. If ARG begins or ends with a path separator 33197a3b38f7Smrg# character, it is preserved (but converted to $host format) 33207a3b38f7Smrg# on output. 33217a3b38f7Smrg# 33227a3b38f7Smrg# ARG is a pathlist (on $build) that should be converted to 33237a3b38f7Smrg# the proper representation on $host. The result is stored 33247a3b38f7Smrg# in $func_to_host_pathlist_result. 33257a3b38f7Smrgfunc_to_host_pathlist () 33267a3b38f7Smrg{ 33277a3b38f7Smrg func_to_host_pathlist_result="$1" 332844dda7b2Smrg if test -n "$1"; then 33297a3b38f7Smrg case $host in 33307a3b38f7Smrg *mingw* ) 33317a3b38f7Smrg lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 33327a3b38f7Smrg # Remove leading and trailing path separator characters from 33337a3b38f7Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 33347a3b38f7Smrg # into '.;' and ';.', and winepath ignores them completely. 333544dda7b2Smrg func_stripname : : "$1" 333644dda7b2Smrg func_to_host_pathlist_tmp1=$func_stripname_result 33377a3b38f7Smrg case $build in 33387a3b38f7Smrg *mingw* ) # Actually, msys. 33397a3b38f7Smrg # Awkward: cmd appends spaces to result. 334044dda7b2Smrg func_to_host_pathlist_result=` 334144dda7b2Smrg ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null | 334244dda7b2Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 33437a3b38f7Smrg ;; 33447a3b38f7Smrg *cygwin* ) 334544dda7b2Smrg func_to_host_pathlist_result=`cygpath -w -p "$func_to_host_pathlist_tmp1" | 33467a3b38f7Smrg $SED -e "$lt_sed_naive_backslashify"` 33477a3b38f7Smrg ;; 33487a3b38f7Smrg * ) 33497a3b38f7Smrg # unfortunately, winepath doesn't convert pathlists 33507a3b38f7Smrg func_to_host_pathlist_result="" 33517a3b38f7Smrg func_to_host_pathlist_oldIFS=$IFS 33527a3b38f7Smrg IFS=: 33537a3b38f7Smrg for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do 33547a3b38f7Smrg IFS=$func_to_host_pathlist_oldIFS 33557a3b38f7Smrg if test -n "$func_to_host_pathlist_f" ; then 33567a3b38f7Smrg func_to_host_path "$func_to_host_pathlist_f" 33577a3b38f7Smrg if test -n "$func_to_host_path_result" ; then 33587a3b38f7Smrg if test -z "$func_to_host_pathlist_result" ; then 33597a3b38f7Smrg func_to_host_pathlist_result="$func_to_host_path_result" 33607a3b38f7Smrg else 336144dda7b2Smrg func_append func_to_host_pathlist_result ";$func_to_host_path_result" 33627a3b38f7Smrg fi 33637a3b38f7Smrg fi 33647a3b38f7Smrg fi 33657a3b38f7Smrg done 33667a3b38f7Smrg IFS=$func_to_host_pathlist_oldIFS 33677a3b38f7Smrg ;; 33687a3b38f7Smrg esac 336944dda7b2Smrg if test -z "$func_to_host_pathlist_result"; then 33707a3b38f7Smrg func_error "Could not determine the host path(s) corresponding to" 337144dda7b2Smrg func_error " \`$1'" 33727a3b38f7Smrg func_error "Continuing, but uninstalled executables may not work." 33737a3b38f7Smrg # Fallback. This may break if $1 contains DOS-style drive 33747a3b38f7Smrg # specifications. The fix is not to complicate the expression 33757a3b38f7Smrg # below, but for the user to provide a working wine installation 33767a3b38f7Smrg # with winepath so that path translation in the cross-to-mingw 33777a3b38f7Smrg # case works properly. 33787a3b38f7Smrg lt_replace_pathsep_nix_to_dos="s|:|;|g" 33797a3b38f7Smrg func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ 33807a3b38f7Smrg $SED -e "$lt_replace_pathsep_nix_to_dos"` 33817a3b38f7Smrg fi 33827a3b38f7Smrg # Now, add the leading and trailing path separators back 33837a3b38f7Smrg case "$1" in 33847a3b38f7Smrg :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" 33857a3b38f7Smrg ;; 33867a3b38f7Smrg esac 33877a3b38f7Smrg case "$1" in 338844dda7b2Smrg *: ) func_append func_to_host_pathlist_result ";" 33897a3b38f7Smrg ;; 33907a3b38f7Smrg esac 33917a3b38f7Smrg ;; 33927a3b38f7Smrg esac 33937a3b38f7Smrg fi 33947a3b38f7Smrg} 33957a3b38f7Smrg# end: func_to_host_pathlist 3396ff559fabSmrg 33977a3b38f7Smrg# func_emit_cwrapperexe_src 33987a3b38f7Smrg# emit the source code for a wrapper executable on stdout 33997a3b38f7Smrg# Must ONLY be called from within func_mode_link because 34007a3b38f7Smrg# it depends on a number of variable set therein. 34017a3b38f7Smrgfunc_emit_cwrapperexe_src () 34027a3b38f7Smrg{ 34037a3b38f7Smrg cat <<EOF 3404ff559fabSmrg 34057a3b38f7Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 34067a3b38f7Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3407ff559fabSmrg 34087a3b38f7Smrg The $output program cannot be directly executed until all the libtool 34097a3b38f7Smrg libraries that it depends on are installed. 3410ff559fabSmrg 34117a3b38f7Smrg This wrapper executable should never be moved out of the build directory. 34127a3b38f7Smrg If it is, it will not operate correctly. 34137a3b38f7Smrg*/ 34147a3b38f7SmrgEOF 34157a3b38f7Smrg cat <<"EOF" 341644dda7b2Smrg#ifdef _MSC_VER 341744dda7b2Smrg# define _CRT_SECURE_NO_DEPRECATE 1 341844dda7b2Smrg#endif 34197a3b38f7Smrg#include <stdio.h> 34207a3b38f7Smrg#include <stdlib.h> 34217a3b38f7Smrg#ifdef _MSC_VER 34227a3b38f7Smrg# include <direct.h> 34237a3b38f7Smrg# include <process.h> 34247a3b38f7Smrg# include <io.h> 34257a3b38f7Smrg#else 34267a3b38f7Smrg# include <unistd.h> 34277a3b38f7Smrg# include <stdint.h> 34287a3b38f7Smrg# ifdef __CYGWIN__ 34297a3b38f7Smrg# include <io.h> 34307a3b38f7Smrg# endif 34317a3b38f7Smrg#endif 34327a3b38f7Smrg#include <malloc.h> 34337a3b38f7Smrg#include <stdarg.h> 34347a3b38f7Smrg#include <assert.h> 34357a3b38f7Smrg#include <string.h> 34367a3b38f7Smrg#include <ctype.h> 34377a3b38f7Smrg#include <errno.h> 34387a3b38f7Smrg#include <fcntl.h> 34397a3b38f7Smrg#include <sys/stat.h> 34407a3b38f7Smrg 344144dda7b2Smrg/* declarations of non-ANSI functions */ 344244dda7b2Smrg#if defined(__MINGW32__) 344344dda7b2Smrg# ifdef __STRICT_ANSI__ 344444dda7b2Smrgint _putenv (const char *); 344544dda7b2Smrg# endif 344644dda7b2Smrg#elif defined(__CYGWIN__) 344744dda7b2Smrg# ifdef __STRICT_ANSI__ 344844dda7b2Smrgchar *realpath (const char *, char *); 344944dda7b2Smrgint putenv (char *); 345044dda7b2Smrgint setenv (const char *, const char *, int); 345144dda7b2Smrg# endif 345244dda7b2Smrg/* #elif defined (other platforms) ... */ 345344dda7b2Smrg#endif 345444dda7b2Smrg 345544dda7b2Smrg/* portability defines, excluding path handling macros */ 345644dda7b2Smrg#if defined(_MSC_VER) 345744dda7b2Smrg# define setmode _setmode 345844dda7b2Smrg# define stat _stat 345944dda7b2Smrg# define chmod _chmod 346044dda7b2Smrg# define getcwd _getcwd 346144dda7b2Smrg# define putenv _putenv 346244dda7b2Smrg# define S_IXUSR _S_IEXEC 346344dda7b2Smrg# ifndef _INTPTR_T_DEFINED 346444dda7b2Smrg# define _INTPTR_T_DEFINED 346544dda7b2Smrg# define intptr_t int 346644dda7b2Smrg# endif 346744dda7b2Smrg#elif defined(__MINGW32__) 346844dda7b2Smrg# define setmode _setmode 346944dda7b2Smrg# define stat _stat 347044dda7b2Smrg# define chmod _chmod 347144dda7b2Smrg# define getcwd _getcwd 347244dda7b2Smrg# define putenv _putenv 347344dda7b2Smrg#elif defined(__CYGWIN__) 347444dda7b2Smrg# define HAVE_SETENV 347544dda7b2Smrg# define FOPEN_WB "wb" 347644dda7b2Smrg/* #elif defined (other platforms) ... */ 347744dda7b2Smrg#endif 347844dda7b2Smrg 34797a3b38f7Smrg#if defined(PATH_MAX) 34807a3b38f7Smrg# define LT_PATHMAX PATH_MAX 34817a3b38f7Smrg#elif defined(MAXPATHLEN) 34827a3b38f7Smrg# define LT_PATHMAX MAXPATHLEN 34837a3b38f7Smrg#else 34847a3b38f7Smrg# define LT_PATHMAX 1024 34857a3b38f7Smrg#endif 34867a3b38f7Smrg 34877a3b38f7Smrg#ifndef S_IXOTH 34887a3b38f7Smrg# define S_IXOTH 0 34897a3b38f7Smrg#endif 34907a3b38f7Smrg#ifndef S_IXGRP 34917a3b38f7Smrg# define S_IXGRP 0 34927a3b38f7Smrg#endif 34937a3b38f7Smrg 349444dda7b2Smrg/* path handling portability macros */ 34957a3b38f7Smrg#ifndef DIR_SEPARATOR 34967a3b38f7Smrg# define DIR_SEPARATOR '/' 34977a3b38f7Smrg# define PATH_SEPARATOR ':' 34987a3b38f7Smrg#endif 34997a3b38f7Smrg 35007a3b38f7Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 35017a3b38f7Smrg defined (__OS2__) 35027a3b38f7Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 35037a3b38f7Smrg# define FOPEN_WB "wb" 35047a3b38f7Smrg# ifndef DIR_SEPARATOR_2 35057a3b38f7Smrg# define DIR_SEPARATOR_2 '\\' 35067a3b38f7Smrg# endif 35077a3b38f7Smrg# ifndef PATH_SEPARATOR_2 35087a3b38f7Smrg# define PATH_SEPARATOR_2 ';' 35097a3b38f7Smrg# endif 35107a3b38f7Smrg#endif 35117a3b38f7Smrg 35127a3b38f7Smrg#ifndef DIR_SEPARATOR_2 35137a3b38f7Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 35147a3b38f7Smrg#else /* DIR_SEPARATOR_2 */ 35157a3b38f7Smrg# define IS_DIR_SEPARATOR(ch) \ 35167a3b38f7Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 35177a3b38f7Smrg#endif /* DIR_SEPARATOR_2 */ 35187a3b38f7Smrg 35197a3b38f7Smrg#ifndef PATH_SEPARATOR_2 35207a3b38f7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 35217a3b38f7Smrg#else /* PATH_SEPARATOR_2 */ 35227a3b38f7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 35237a3b38f7Smrg#endif /* PATH_SEPARATOR_2 */ 35247a3b38f7Smrg 35257a3b38f7Smrg#ifndef FOPEN_WB 35267a3b38f7Smrg# define FOPEN_WB "w" 35277a3b38f7Smrg#endif 35287a3b38f7Smrg#ifndef _O_BINARY 35297a3b38f7Smrg# define _O_BINARY 0 35307a3b38f7Smrg#endif 35317a3b38f7Smrg 35327a3b38f7Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 35337a3b38f7Smrg#define XFREE(stale) do { \ 35347a3b38f7Smrg if (stale) { free ((void *) stale); stale = 0; } \ 35357a3b38f7Smrg} while (0) 35367a3b38f7Smrg 353744dda7b2Smrg#if defined(LT_DEBUGWRAPPER) 353844dda7b2Smrgstatic int lt_debug = 1; 35397a3b38f7Smrg#else 354044dda7b2Smrgstatic int lt_debug = 0; 35417a3b38f7Smrg#endif 35427a3b38f7Smrg 354344dda7b2Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 35447a3b38f7Smrg 35457a3b38f7Smrgvoid *xmalloc (size_t num); 35467a3b38f7Smrgchar *xstrdup (const char *string); 35477a3b38f7Smrgconst char *base_name (const char *name); 35487a3b38f7Smrgchar *find_executable (const char *wrapper); 35497a3b38f7Smrgchar *chase_symlinks (const char *pathspec); 35507a3b38f7Smrgint make_executable (const char *path); 35517a3b38f7Smrgint check_executable (const char *path); 35527a3b38f7Smrgchar *strendzap (char *str, const char *pat); 355344dda7b2Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 355444dda7b2Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 355544dda7b2Smrgstatic const char *nonnull (const char *s); 355644dda7b2Smrgstatic const char *nonempty (const char *s); 35577a3b38f7Smrgvoid lt_setenv (const char *name, const char *value); 35587a3b38f7Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 35597a3b38f7Smrgvoid lt_update_exe_path (const char *name, const char *value); 35607a3b38f7Smrgvoid lt_update_lib_path (const char *name, const char *value); 356144dda7b2Smrgchar **prepare_spawn (char **argv); 356244dda7b2Smrgvoid lt_dump_script (FILE *f); 35637a3b38f7SmrgEOF 35647a3b38f7Smrg 35657a3b38f7Smrg cat <<EOF 35667a3b38f7Smrgconst char * MAGIC_EXE = "$magic_exe"; 35677a3b38f7Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 35687a3b38f7SmrgEOF 35697a3b38f7Smrg 35707a3b38f7Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 35717a3b38f7Smrg func_to_host_pathlist "$temp_rpath" 35727a3b38f7Smrg cat <<EOF 35737a3b38f7Smrgconst char * LIB_PATH_VALUE = "$func_to_host_pathlist_result"; 3574ff559fabSmrgEOF 3575ff559fabSmrg else 35767a3b38f7Smrg cat <<"EOF" 35777a3b38f7Smrgconst char * LIB_PATH_VALUE = ""; 35787a3b38f7SmrgEOF 3579ff559fabSmrg fi 35807a3b38f7Smrg 35817a3b38f7Smrg if test -n "$dllsearchpath"; then 35827a3b38f7Smrg func_to_host_pathlist "$dllsearchpath:" 35837a3b38f7Smrg cat <<EOF 35847a3b38f7Smrgconst char * EXE_PATH_VARNAME = "PATH"; 35857a3b38f7Smrgconst char * EXE_PATH_VALUE = "$func_to_host_pathlist_result"; 35867a3b38f7SmrgEOF 3587ff559fabSmrg else 35887a3b38f7Smrg cat <<"EOF" 35897a3b38f7Smrgconst char * EXE_PATH_VARNAME = ""; 35907a3b38f7Smrgconst char * EXE_PATH_VALUE = ""; 35917a3b38f7SmrgEOF 3592ff559fabSmrg fi 35937a3b38f7Smrg 35947a3b38f7Smrg if test "$fast_install" = yes; then 35957a3b38f7Smrg cat <<EOF 35967a3b38f7Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 35977a3b38f7SmrgEOF 3598ff559fabSmrg else 35997a3b38f7Smrg cat <<EOF 36007a3b38f7Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 36017a3b38f7SmrgEOF 3602ff559fabSmrg fi 3603ff559fabSmrg 3604ff559fabSmrg 36057a3b38f7Smrg cat <<"EOF" 3606ff559fabSmrg 36077a3b38f7Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 3608ff559fabSmrg 36097a3b38f7Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 36107a3b38f7Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 361144dda7b2Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 3612ff559fabSmrg 36137a3b38f7Smrgint 36147a3b38f7Smrgmain (int argc, char *argv[]) 36157a3b38f7Smrg{ 36167a3b38f7Smrg char **newargz; 36177a3b38f7Smrg int newargc; 36187a3b38f7Smrg char *tmp_pathspec; 36197a3b38f7Smrg char *actual_cwrapper_path; 36207a3b38f7Smrg char *actual_cwrapper_name; 36217a3b38f7Smrg char *target_name; 36227a3b38f7Smrg char *lt_argv_zero; 36237a3b38f7Smrg intptr_t rval = 127; 3624ff559fabSmrg 36257a3b38f7Smrg int i; 3626ff559fabSmrg 36277a3b38f7Smrg program_name = (char *) xstrdup (base_name (argv[0])); 362844dda7b2Smrg newargz = XMALLOC (char *, argc + 1); 3629ff559fabSmrg 363044dda7b2Smrg /* very simple arg parsing; don't want to rely on getopt 363144dda7b2Smrg * also, copy all non cwrapper options to newargz, except 363244dda7b2Smrg * argz[0], which is handled differently 363344dda7b2Smrg */ 363444dda7b2Smrg newargc=0; 36357a3b38f7Smrg for (i = 1; i < argc; i++) 36367a3b38f7Smrg { 36377a3b38f7Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 36387a3b38f7Smrg { 36397a3b38f7SmrgEOF 36407a3b38f7Smrg case "$host" in 36417a3b38f7Smrg *mingw* | *cygwin* ) 36427a3b38f7Smrg # make stdout use "unix" line endings 36437a3b38f7Smrg echo " setmode(1,_O_BINARY);" 36447a3b38f7Smrg ;; 36457a3b38f7Smrg esac 3646ff559fabSmrg 36477a3b38f7Smrg cat <<"EOF" 364844dda7b2Smrg lt_dump_script (stdout); 36497a3b38f7Smrg return 0; 36507a3b38f7Smrg } 365144dda7b2Smrg if (strcmp (argv[i], debug_opt) == 0) 365244dda7b2Smrg { 365344dda7b2Smrg lt_debug = 1; 365444dda7b2Smrg continue; 365544dda7b2Smrg } 365644dda7b2Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 365744dda7b2Smrg { 365844dda7b2Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 365944dda7b2Smrg namespace, but it is not one of the ones we know about and 366044dda7b2Smrg have already dealt with, above (inluding dump-script), then 366144dda7b2Smrg report an error. Otherwise, targets might begin to believe 366244dda7b2Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 366344dda7b2Smrg namespace. The first time any user complains about this, we'll 366444dda7b2Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 366544dda7b2Smrg or a configure.ac-settable value. 366644dda7b2Smrg */ 366744dda7b2Smrg lt_fatal (__FILE__, __LINE__, 366844dda7b2Smrg "unrecognized %s option: '%s'", 366944dda7b2Smrg ltwrapper_option_prefix, argv[i]); 367044dda7b2Smrg } 367144dda7b2Smrg /* otherwise ... */ 367244dda7b2Smrg newargz[++newargc] = xstrdup (argv[i]); 36737a3b38f7Smrg } 367444dda7b2Smrg newargz[++newargc] = NULL; 367544dda7b2Smrg 367644dda7b2SmrgEOF 367744dda7b2Smrg cat <<EOF 367844dda7b2Smrg /* The GNU banner must be the first non-error debug message */ 367944dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 368044dda7b2SmrgEOF 368144dda7b2Smrg cat <<"EOF" 368244dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 368344dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 3684ff559fabSmrg 36857a3b38f7Smrg tmp_pathspec = find_executable (argv[0]); 36867a3b38f7Smrg if (tmp_pathspec == NULL) 368744dda7b2Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 368844dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 368944dda7b2Smrg "(main) found exe (before symlink chase) at: %s\n", 369044dda7b2Smrg tmp_pathspec); 36917a3b38f7Smrg 36927a3b38f7Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 369344dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 369444dda7b2Smrg "(main) found exe (after symlink chase) at: %s\n", 369544dda7b2Smrg actual_cwrapper_path); 36967a3b38f7Smrg XFREE (tmp_pathspec); 36977a3b38f7Smrg 369844dda7b2Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 36997a3b38f7Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 37007a3b38f7Smrg 37017a3b38f7Smrg /* wrapper name transforms */ 37027a3b38f7Smrg strendzap (actual_cwrapper_name, ".exe"); 37037a3b38f7Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 37047a3b38f7Smrg XFREE (actual_cwrapper_name); 37057a3b38f7Smrg actual_cwrapper_name = tmp_pathspec; 37067a3b38f7Smrg tmp_pathspec = 0; 37077a3b38f7Smrg 37087a3b38f7Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 37097a3b38f7Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 37107a3b38f7Smrg strendzap (target_name, ".exe"); 37117a3b38f7Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 37127a3b38f7Smrg XFREE (target_name); 37137a3b38f7Smrg target_name = tmp_pathspec; 37147a3b38f7Smrg tmp_pathspec = 0; 37157a3b38f7Smrg 371644dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 371744dda7b2Smrg "(main) libtool target name: %s\n", 371844dda7b2Smrg target_name); 37197a3b38f7SmrgEOF 3720ff559fabSmrg 37217a3b38f7Smrg cat <<EOF 37227a3b38f7Smrg newargz[0] = 37237a3b38f7Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 37247a3b38f7Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 37257a3b38f7Smrg strcpy (newargz[0], actual_cwrapper_path); 37267a3b38f7Smrg strcat (newargz[0], "$objdir"); 37277a3b38f7Smrg strcat (newargz[0], "/"); 37287a3b38f7SmrgEOF 3729ff559fabSmrg 37307a3b38f7Smrg cat <<"EOF" 37317a3b38f7Smrg /* stop here, and copy so we don't have to do this twice */ 37327a3b38f7Smrg tmp_pathspec = xstrdup (newargz[0]); 3733ff559fabSmrg 37347a3b38f7Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 37357a3b38f7Smrg strcat (newargz[0], actual_cwrapper_name); 3736ff559fabSmrg 37377a3b38f7Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 37387a3b38f7Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 37397a3b38f7Smrg XFREE (tmp_pathspec); 37407a3b38f7Smrg tmp_pathspec = NULL; 37417a3b38f7SmrgEOF 3742ff559fabSmrg 37437a3b38f7Smrg case $host_os in 37447a3b38f7Smrg mingw*) 37457a3b38f7Smrg cat <<"EOF" 37467a3b38f7Smrg { 37477a3b38f7Smrg char* p; 37487a3b38f7Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 37497a3b38f7Smrg { 37507a3b38f7Smrg *p = '/'; 37517a3b38f7Smrg } 37527a3b38f7Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 37537a3b38f7Smrg { 37547a3b38f7Smrg *p = '/'; 37557a3b38f7Smrg } 37567a3b38f7Smrg } 37577a3b38f7SmrgEOF 37587a3b38f7Smrg ;; 37597a3b38f7Smrg esac 3760ff559fabSmrg 37617a3b38f7Smrg cat <<"EOF" 37627a3b38f7Smrg XFREE (target_name); 37637a3b38f7Smrg XFREE (actual_cwrapper_path); 37647a3b38f7Smrg XFREE (actual_cwrapper_name); 3765ff559fabSmrg 37667a3b38f7Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 37677a3b38f7Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 37687a3b38f7Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 37697a3b38f7Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 3770ff559fabSmrg 377144dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 377244dda7b2Smrg nonnull (lt_argv_zero)); 37737a3b38f7Smrg for (i = 0; i < newargc; i++) 37747a3b38f7Smrg { 377544dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 377644dda7b2Smrg i, nonnull (newargz[i])); 37777a3b38f7Smrg } 3778ff559fabSmrg 37797a3b38f7SmrgEOF 3780ff559fabSmrg 37817a3b38f7Smrg case $host_os in 37827a3b38f7Smrg mingw*) 37837a3b38f7Smrg cat <<"EOF" 37847a3b38f7Smrg /* execv doesn't actually work on mingw as expected on unix */ 378544dda7b2Smrg newargz = prepare_spawn (newargz); 37867a3b38f7Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 37877a3b38f7Smrg if (rval == -1) 37887a3b38f7Smrg { 37897a3b38f7Smrg /* failed to start process */ 379044dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 379144dda7b2Smrg "(main) failed to launch target \"%s\": %s\n", 379244dda7b2Smrg lt_argv_zero, nonnull (strerror (errno))); 37937a3b38f7Smrg return 127; 37947a3b38f7Smrg } 37957a3b38f7Smrg return rval; 37967a3b38f7SmrgEOF 37977a3b38f7Smrg ;; 37987a3b38f7Smrg *) 37997a3b38f7Smrg cat <<"EOF" 38007a3b38f7Smrg execv (lt_argv_zero, newargz); 38017a3b38f7Smrg return rval; /* =127, but avoids unused variable warning */ 38027a3b38f7SmrgEOF 38037a3b38f7Smrg ;; 38047a3b38f7Smrg esac 3805ff559fabSmrg 38067a3b38f7Smrg cat <<"EOF" 38077a3b38f7Smrg} 3808ff559fabSmrg 38097a3b38f7Smrgvoid * 38107a3b38f7Smrgxmalloc (size_t num) 38117a3b38f7Smrg{ 38127a3b38f7Smrg void *p = (void *) malloc (num); 38137a3b38f7Smrg if (!p) 381444dda7b2Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 3815ff559fabSmrg 38167a3b38f7Smrg return p; 38177a3b38f7Smrg} 3818ff559fabSmrg 38197a3b38f7Smrgchar * 38207a3b38f7Smrgxstrdup (const char *string) 38217a3b38f7Smrg{ 38227a3b38f7Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 38237a3b38f7Smrg string) : NULL; 38247a3b38f7Smrg} 3825ff559fabSmrg 38267a3b38f7Smrgconst char * 38277a3b38f7Smrgbase_name (const char *name) 38287a3b38f7Smrg{ 38297a3b38f7Smrg const char *base; 3830ff559fabSmrg 38317a3b38f7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 38327a3b38f7Smrg /* Skip over the disk name in MSDOS pathnames. */ 38337a3b38f7Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 38347a3b38f7Smrg name += 2; 38357a3b38f7Smrg#endif 3836ff559fabSmrg 38377a3b38f7Smrg for (base = name; *name; name++) 38387a3b38f7Smrg if (IS_DIR_SEPARATOR (*name)) 38397a3b38f7Smrg base = name + 1; 38407a3b38f7Smrg return base; 38417a3b38f7Smrg} 3842ff559fabSmrg 38437a3b38f7Smrgint 38447a3b38f7Smrgcheck_executable (const char *path) 38457a3b38f7Smrg{ 38467a3b38f7Smrg struct stat st; 3847ff559fabSmrg 384844dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 384944dda7b2Smrg nonempty (path)); 38507a3b38f7Smrg if ((!path) || (!*path)) 38517a3b38f7Smrg return 0; 3852ff559fabSmrg 38537a3b38f7Smrg if ((stat (path, &st) >= 0) 38547a3b38f7Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 38557a3b38f7Smrg return 1; 38567a3b38f7Smrg else 38577a3b38f7Smrg return 0; 38587a3b38f7Smrg} 3859ff559fabSmrg 38607a3b38f7Smrgint 38617a3b38f7Smrgmake_executable (const char *path) 38627a3b38f7Smrg{ 38637a3b38f7Smrg int rval = 0; 38647a3b38f7Smrg struct stat st; 3865ff559fabSmrg 386644dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 386744dda7b2Smrg nonempty (path)); 38687a3b38f7Smrg if ((!path) || (!*path)) 38697a3b38f7Smrg return 0; 3870ff559fabSmrg 38717a3b38f7Smrg if (stat (path, &st) >= 0) 38727a3b38f7Smrg { 38737a3b38f7Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 38747a3b38f7Smrg } 38757a3b38f7Smrg return rval; 38767a3b38f7Smrg} 3877ff559fabSmrg 38787a3b38f7Smrg/* Searches for the full path of the wrapper. Returns 38797a3b38f7Smrg newly allocated full path name if found, NULL otherwise 38807a3b38f7Smrg Does not chase symlinks, even on platforms that support them. 38817a3b38f7Smrg*/ 38827a3b38f7Smrgchar * 38837a3b38f7Smrgfind_executable (const char *wrapper) 38847a3b38f7Smrg{ 38857a3b38f7Smrg int has_slash = 0; 38867a3b38f7Smrg const char *p; 38877a3b38f7Smrg const char *p_next; 38887a3b38f7Smrg /* static buffer for getcwd */ 38897a3b38f7Smrg char tmp[LT_PATHMAX + 1]; 38907a3b38f7Smrg int tmp_len; 38917a3b38f7Smrg char *concat_name; 3892ff559fabSmrg 389344dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 389444dda7b2Smrg nonempty (wrapper)); 3895ff559fabSmrg 38967a3b38f7Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 38977a3b38f7Smrg return NULL; 3898ff559fabSmrg 38997a3b38f7Smrg /* Absolute path? */ 39007a3b38f7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 39017a3b38f7Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 39027a3b38f7Smrg { 39037a3b38f7Smrg concat_name = xstrdup (wrapper); 39047a3b38f7Smrg if (check_executable (concat_name)) 39057a3b38f7Smrg return concat_name; 39067a3b38f7Smrg XFREE (concat_name); 39077a3b38f7Smrg } 39087a3b38f7Smrg else 39097a3b38f7Smrg { 39107a3b38f7Smrg#endif 39117a3b38f7Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 39127a3b38f7Smrg { 39137a3b38f7Smrg concat_name = xstrdup (wrapper); 39147a3b38f7Smrg if (check_executable (concat_name)) 39157a3b38f7Smrg return concat_name; 39167a3b38f7Smrg XFREE (concat_name); 39177a3b38f7Smrg } 39187a3b38f7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 39197a3b38f7Smrg } 39207a3b38f7Smrg#endif 3921ff559fabSmrg 39227a3b38f7Smrg for (p = wrapper; *p; p++) 39237a3b38f7Smrg if (*p == '/') 39247a3b38f7Smrg { 39257a3b38f7Smrg has_slash = 1; 39267a3b38f7Smrg break; 39277a3b38f7Smrg } 39287a3b38f7Smrg if (!has_slash) 39297a3b38f7Smrg { 39307a3b38f7Smrg /* no slashes; search PATH */ 39317a3b38f7Smrg const char *path = getenv ("PATH"); 39327a3b38f7Smrg if (path != NULL) 39337a3b38f7Smrg { 39347a3b38f7Smrg for (p = path; *p; p = p_next) 39357a3b38f7Smrg { 39367a3b38f7Smrg const char *q; 39377a3b38f7Smrg size_t p_len; 39387a3b38f7Smrg for (q = p; *q; q++) 39397a3b38f7Smrg if (IS_PATH_SEPARATOR (*q)) 39407a3b38f7Smrg break; 39417a3b38f7Smrg p_len = q - p; 39427a3b38f7Smrg p_next = (*q == '\0' ? q : q + 1); 39437a3b38f7Smrg if (p_len == 0) 39447a3b38f7Smrg { 39457a3b38f7Smrg /* empty path: current directory */ 39467a3b38f7Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 394744dda7b2Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 394844dda7b2Smrg nonnull (strerror (errno))); 39497a3b38f7Smrg tmp_len = strlen (tmp); 39507a3b38f7Smrg concat_name = 39517a3b38f7Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 39527a3b38f7Smrg memcpy (concat_name, tmp, tmp_len); 39537a3b38f7Smrg concat_name[tmp_len] = '/'; 39547a3b38f7Smrg strcpy (concat_name + tmp_len + 1, wrapper); 39557a3b38f7Smrg } 39567a3b38f7Smrg else 39577a3b38f7Smrg { 39587a3b38f7Smrg concat_name = 39597a3b38f7Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 39607a3b38f7Smrg memcpy (concat_name, p, p_len); 39617a3b38f7Smrg concat_name[p_len] = '/'; 39627a3b38f7Smrg strcpy (concat_name + p_len + 1, wrapper); 39637a3b38f7Smrg } 39647a3b38f7Smrg if (check_executable (concat_name)) 39657a3b38f7Smrg return concat_name; 39667a3b38f7Smrg XFREE (concat_name); 39677a3b38f7Smrg } 39687a3b38f7Smrg } 39697a3b38f7Smrg /* not found in PATH; assume curdir */ 39707a3b38f7Smrg } 39717a3b38f7Smrg /* Relative path | not found in path: prepend cwd */ 39727a3b38f7Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 397344dda7b2Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 397444dda7b2Smrg nonnull (strerror (errno))); 39757a3b38f7Smrg tmp_len = strlen (tmp); 39767a3b38f7Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 39777a3b38f7Smrg memcpy (concat_name, tmp, tmp_len); 39787a3b38f7Smrg concat_name[tmp_len] = '/'; 39797a3b38f7Smrg strcpy (concat_name + tmp_len + 1, wrapper); 3980ff559fabSmrg 39817a3b38f7Smrg if (check_executable (concat_name)) 39827a3b38f7Smrg return concat_name; 39837a3b38f7Smrg XFREE (concat_name); 39847a3b38f7Smrg return NULL; 39857a3b38f7Smrg} 3986ff559fabSmrg 39877a3b38f7Smrgchar * 39887a3b38f7Smrgchase_symlinks (const char *pathspec) 39897a3b38f7Smrg{ 39907a3b38f7Smrg#ifndef S_ISLNK 39917a3b38f7Smrg return xstrdup (pathspec); 39927a3b38f7Smrg#else 39937a3b38f7Smrg char buf[LT_PATHMAX]; 39947a3b38f7Smrg struct stat s; 39957a3b38f7Smrg char *tmp_pathspec = xstrdup (pathspec); 39967a3b38f7Smrg char *p; 39977a3b38f7Smrg int has_symlinks = 0; 39987a3b38f7Smrg while (strlen (tmp_pathspec) && !has_symlinks) 39997a3b38f7Smrg { 400044dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 400144dda7b2Smrg "checking path component for symlinks: %s\n", 400244dda7b2Smrg tmp_pathspec); 40037a3b38f7Smrg if (lstat (tmp_pathspec, &s) == 0) 40047a3b38f7Smrg { 40057a3b38f7Smrg if (S_ISLNK (s.st_mode) != 0) 40067a3b38f7Smrg { 40077a3b38f7Smrg has_symlinks = 1; 40087a3b38f7Smrg break; 40097a3b38f7Smrg } 4010ff559fabSmrg 40117a3b38f7Smrg /* search backwards for last DIR_SEPARATOR */ 40127a3b38f7Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 40137a3b38f7Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 40147a3b38f7Smrg p--; 40157a3b38f7Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 40167a3b38f7Smrg { 40177a3b38f7Smrg /* no more DIR_SEPARATORS left */ 40187a3b38f7Smrg break; 40197a3b38f7Smrg } 40207a3b38f7Smrg *p = '\0'; 40217a3b38f7Smrg } 40227a3b38f7Smrg else 40237a3b38f7Smrg { 402444dda7b2Smrg lt_fatal (__FILE__, __LINE__, 402544dda7b2Smrg "error accessing file \"%s\": %s", 402644dda7b2Smrg tmp_pathspec, nonnull (strerror (errno))); 40277a3b38f7Smrg } 40287a3b38f7Smrg } 40297a3b38f7Smrg XFREE (tmp_pathspec); 4030ff559fabSmrg 40317a3b38f7Smrg if (!has_symlinks) 40327a3b38f7Smrg { 40337a3b38f7Smrg return xstrdup (pathspec); 40347a3b38f7Smrg } 4035ff559fabSmrg 40367a3b38f7Smrg tmp_pathspec = realpath (pathspec, buf); 40377a3b38f7Smrg if (tmp_pathspec == 0) 40387a3b38f7Smrg { 403944dda7b2Smrg lt_fatal (__FILE__, __LINE__, 404044dda7b2Smrg "could not follow symlinks for %s", pathspec); 40417a3b38f7Smrg } 40427a3b38f7Smrg return xstrdup (tmp_pathspec); 40437a3b38f7Smrg#endif 40447a3b38f7Smrg} 4045ff559fabSmrg 40467a3b38f7Smrgchar * 40477a3b38f7Smrgstrendzap (char *str, const char *pat) 40487a3b38f7Smrg{ 40497a3b38f7Smrg size_t len, patlen; 4050ff559fabSmrg 40517a3b38f7Smrg assert (str != NULL); 40527a3b38f7Smrg assert (pat != NULL); 4053ff559fabSmrg 40547a3b38f7Smrg len = strlen (str); 40557a3b38f7Smrg patlen = strlen (pat); 4056ff559fabSmrg 40577a3b38f7Smrg if (patlen <= len) 40587a3b38f7Smrg { 40597a3b38f7Smrg str += len - patlen; 40607a3b38f7Smrg if (strcmp (str, pat) == 0) 40617a3b38f7Smrg *str = '\0'; 40627a3b38f7Smrg } 40637a3b38f7Smrg return str; 40647a3b38f7Smrg} 4065ff559fabSmrg 406644dda7b2Smrgvoid 406744dda7b2Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 406844dda7b2Smrg{ 406944dda7b2Smrg va_list args; 407044dda7b2Smrg if (lt_debug) 407144dda7b2Smrg { 407244dda7b2Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 407344dda7b2Smrg va_start (args, fmt); 407444dda7b2Smrg (void) vfprintf (stderr, fmt, args); 407544dda7b2Smrg va_end (args); 407644dda7b2Smrg } 407744dda7b2Smrg} 407844dda7b2Smrg 40797a3b38f7Smrgstatic void 408044dda7b2Smrglt_error_core (int exit_status, const char *file, 408144dda7b2Smrg int line, const char *mode, 40827a3b38f7Smrg const char *message, va_list ap) 40837a3b38f7Smrg{ 408444dda7b2Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 40857a3b38f7Smrg vfprintf (stderr, message, ap); 40867a3b38f7Smrg fprintf (stderr, ".\n"); 4087ff559fabSmrg 40887a3b38f7Smrg if (exit_status >= 0) 40897a3b38f7Smrg exit (exit_status); 40907a3b38f7Smrg} 4091ff559fabSmrg 40927a3b38f7Smrgvoid 409344dda7b2Smrglt_fatal (const char *file, int line, const char *message, ...) 40947a3b38f7Smrg{ 40957a3b38f7Smrg va_list ap; 40967a3b38f7Smrg va_start (ap, message); 409744dda7b2Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 40987a3b38f7Smrg va_end (ap); 40997a3b38f7Smrg} 4100ff559fabSmrg 410144dda7b2Smrgstatic const char * 410244dda7b2Smrgnonnull (const char *s) 410344dda7b2Smrg{ 410444dda7b2Smrg return s ? s : "(null)"; 410544dda7b2Smrg} 410644dda7b2Smrg 410744dda7b2Smrgstatic const char * 410844dda7b2Smrgnonempty (const char *s) 410944dda7b2Smrg{ 411044dda7b2Smrg return (s && !*s) ? "(empty)" : nonnull (s); 411144dda7b2Smrg} 411244dda7b2Smrg 41137a3b38f7Smrgvoid 41147a3b38f7Smrglt_setenv (const char *name, const char *value) 41157a3b38f7Smrg{ 411644dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 411744dda7b2Smrg "(lt_setenv) setting '%s' to '%s'\n", 411844dda7b2Smrg nonnull (name), nonnull (value)); 41197a3b38f7Smrg { 41207a3b38f7Smrg#ifdef HAVE_SETENV 41217a3b38f7Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 41227a3b38f7Smrg char *str = xstrdup (value); 41237a3b38f7Smrg setenv (name, str, 1); 41247a3b38f7Smrg#else 41257a3b38f7Smrg int len = strlen (name) + 1 + strlen (value) + 1; 41267a3b38f7Smrg char *str = XMALLOC (char, len); 41277a3b38f7Smrg sprintf (str, "%s=%s", name, value); 41287a3b38f7Smrg if (putenv (str) != EXIT_SUCCESS) 41297a3b38f7Smrg { 41307a3b38f7Smrg XFREE (str); 41317a3b38f7Smrg } 41327a3b38f7Smrg#endif 41337a3b38f7Smrg } 41347a3b38f7Smrg} 4135ff559fabSmrg 41367a3b38f7Smrgchar * 41377a3b38f7Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 41387a3b38f7Smrg{ 41397a3b38f7Smrg char *new_value; 41407a3b38f7Smrg if (orig_value && *orig_value) 41417a3b38f7Smrg { 41427a3b38f7Smrg int orig_value_len = strlen (orig_value); 41437a3b38f7Smrg int add_len = strlen (add); 41447a3b38f7Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 41457a3b38f7Smrg if (to_end) 41467a3b38f7Smrg { 41477a3b38f7Smrg strcpy (new_value, orig_value); 41487a3b38f7Smrg strcpy (new_value + orig_value_len, add); 41497a3b38f7Smrg } 41507a3b38f7Smrg else 41517a3b38f7Smrg { 41527a3b38f7Smrg strcpy (new_value, add); 41537a3b38f7Smrg strcpy (new_value + add_len, orig_value); 41547a3b38f7Smrg } 41557a3b38f7Smrg } 41567a3b38f7Smrg else 41577a3b38f7Smrg { 41587a3b38f7Smrg new_value = xstrdup (add); 41597a3b38f7Smrg } 41607a3b38f7Smrg return new_value; 41617a3b38f7Smrg} 4162ff559fabSmrg 41637a3b38f7Smrgvoid 41647a3b38f7Smrglt_update_exe_path (const char *name, const char *value) 41657a3b38f7Smrg{ 416644dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 416744dda7b2Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 416844dda7b2Smrg nonnull (name), nonnull (value)); 4169ff559fabSmrg 41707a3b38f7Smrg if (name && *name && value && *value) 41717a3b38f7Smrg { 41727a3b38f7Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 41737a3b38f7Smrg /* some systems can't cope with a ':'-terminated path #' */ 41747a3b38f7Smrg int len = strlen (new_value); 41757a3b38f7Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 41767a3b38f7Smrg { 41777a3b38f7Smrg new_value[len-1] = '\0'; 41787a3b38f7Smrg } 41797a3b38f7Smrg lt_setenv (name, new_value); 41807a3b38f7Smrg XFREE (new_value); 41817a3b38f7Smrg } 41827a3b38f7Smrg} 4183ff559fabSmrg 41847a3b38f7Smrgvoid 41857a3b38f7Smrglt_update_lib_path (const char *name, const char *value) 41867a3b38f7Smrg{ 418744dda7b2Smrg lt_debugprintf (__FILE__, __LINE__, 418844dda7b2Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 418944dda7b2Smrg nonnull (name), nonnull (value)); 4190ff559fabSmrg 41917a3b38f7Smrg if (name && *name && value && *value) 41927a3b38f7Smrg { 41937a3b38f7Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 41947a3b38f7Smrg lt_setenv (name, new_value); 41957a3b38f7Smrg XFREE (new_value); 41967a3b38f7Smrg } 41977a3b38f7Smrg} 4198ff559fabSmrg 419944dda7b2SmrgEOF 420044dda7b2Smrg case $host_os in 420144dda7b2Smrg mingw*) 420244dda7b2Smrg cat <<"EOF" 420344dda7b2Smrg 420444dda7b2Smrg/* Prepares an argument vector before calling spawn(). 420544dda7b2Smrg Note that spawn() does not by itself call the command interpreter 420644dda7b2Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 420744dda7b2Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 420844dda7b2Smrg GetVersionEx(&v); 420944dda7b2Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 421044dda7b2Smrg }) ? "cmd.exe" : "command.com"). 421144dda7b2Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 421244dda7b2Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 421344dda7b2Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 421444dda7b2Smrg special way: 421544dda7b2Smrg - Space and tab are interpreted as delimiters. They are not treated as 421644dda7b2Smrg delimiters if they are surrounded by double quotes: "...". 421744dda7b2Smrg - Unescaped double quotes are removed from the input. Their only effect is 421844dda7b2Smrg that within double quotes, space and tab are treated like normal 421944dda7b2Smrg characters. 422044dda7b2Smrg - Backslashes not followed by double quotes are not special. 422144dda7b2Smrg - But 2*n+1 backslashes followed by a double quote become 422244dda7b2Smrg n backslashes followed by a double quote (n >= 0): 422344dda7b2Smrg \" -> " 422444dda7b2Smrg \\\" -> \" 422544dda7b2Smrg \\\\\" -> \\" 422644dda7b2Smrg */ 422744dda7b2Smrg#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" 422844dda7b2Smrg#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" 422944dda7b2Smrgchar ** 423044dda7b2Smrgprepare_spawn (char **argv) 423144dda7b2Smrg{ 423244dda7b2Smrg size_t argc; 423344dda7b2Smrg char **new_argv; 423444dda7b2Smrg size_t i; 423544dda7b2Smrg 423644dda7b2Smrg /* Count number of arguments. */ 423744dda7b2Smrg for (argc = 0; argv[argc] != NULL; argc++) 423844dda7b2Smrg ; 423944dda7b2Smrg 424044dda7b2Smrg /* Allocate new argument vector. */ 424144dda7b2Smrg new_argv = XMALLOC (char *, argc + 1); 424244dda7b2Smrg 424344dda7b2Smrg /* Put quoted arguments into the new argument vector. */ 424444dda7b2Smrg for (i = 0; i < argc; i++) 424544dda7b2Smrg { 424644dda7b2Smrg const char *string = argv[i]; 424744dda7b2Smrg 424844dda7b2Smrg if (string[0] == '\0') 424944dda7b2Smrg new_argv[i] = xstrdup ("\"\""); 425044dda7b2Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 425144dda7b2Smrg { 425244dda7b2Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 425344dda7b2Smrg size_t length; 425444dda7b2Smrg unsigned int backslashes; 425544dda7b2Smrg const char *s; 425644dda7b2Smrg char *quoted_string; 425744dda7b2Smrg char *p; 425844dda7b2Smrg 425944dda7b2Smrg length = 0; 426044dda7b2Smrg backslashes = 0; 426144dda7b2Smrg if (quote_around) 426244dda7b2Smrg length++; 426344dda7b2Smrg for (s = string; *s != '\0'; s++) 426444dda7b2Smrg { 426544dda7b2Smrg char c = *s; 426644dda7b2Smrg if (c == '"') 426744dda7b2Smrg length += backslashes + 1; 426844dda7b2Smrg length++; 426944dda7b2Smrg if (c == '\\') 427044dda7b2Smrg backslashes++; 427144dda7b2Smrg else 427244dda7b2Smrg backslashes = 0; 427344dda7b2Smrg } 427444dda7b2Smrg if (quote_around) 427544dda7b2Smrg length += backslashes + 1; 427644dda7b2Smrg 427744dda7b2Smrg quoted_string = XMALLOC (char, length + 1); 427844dda7b2Smrg 427944dda7b2Smrg p = quoted_string; 428044dda7b2Smrg backslashes = 0; 428144dda7b2Smrg if (quote_around) 428244dda7b2Smrg *p++ = '"'; 428344dda7b2Smrg for (s = string; *s != '\0'; s++) 428444dda7b2Smrg { 428544dda7b2Smrg char c = *s; 428644dda7b2Smrg if (c == '"') 428744dda7b2Smrg { 428844dda7b2Smrg unsigned int j; 428944dda7b2Smrg for (j = backslashes + 1; j > 0; j--) 429044dda7b2Smrg *p++ = '\\'; 429144dda7b2Smrg } 429244dda7b2Smrg *p++ = c; 429344dda7b2Smrg if (c == '\\') 429444dda7b2Smrg backslashes++; 429544dda7b2Smrg else 429644dda7b2Smrg backslashes = 0; 429744dda7b2Smrg } 429844dda7b2Smrg if (quote_around) 429944dda7b2Smrg { 430044dda7b2Smrg unsigned int j; 430144dda7b2Smrg for (j = backslashes; j > 0; j--) 430244dda7b2Smrg *p++ = '\\'; 430344dda7b2Smrg *p++ = '"'; 430444dda7b2Smrg } 430544dda7b2Smrg *p = '\0'; 430644dda7b2Smrg 430744dda7b2Smrg new_argv[i] = quoted_string; 430844dda7b2Smrg } 430944dda7b2Smrg else 431044dda7b2Smrg new_argv[i] = (char *) string; 431144dda7b2Smrg } 431244dda7b2Smrg new_argv[argc] = NULL; 431344dda7b2Smrg 431444dda7b2Smrg return new_argv; 431544dda7b2Smrg} 431644dda7b2SmrgEOF 431744dda7b2Smrg ;; 431844dda7b2Smrg esac 431944dda7b2Smrg 432044dda7b2Smrg cat <<"EOF" 432144dda7b2Smrgvoid lt_dump_script (FILE* f) 432244dda7b2Smrg{ 432344dda7b2SmrgEOF 432444dda7b2Smrg func_emit_wrapper yes | 432544dda7b2Smrg $SED -e 's/\([\\"]\)/\\\1/g' \ 432644dda7b2Smrg -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' 4327ff559fabSmrg 432844dda7b2Smrg cat <<"EOF" 432944dda7b2Smrg} 43307a3b38f7SmrgEOF 43317a3b38f7Smrg} 43327a3b38f7Smrg# end: func_emit_cwrapperexe_src 4333ff559fabSmrg 433444dda7b2Smrg# func_win32_import_lib_p ARG 433544dda7b2Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 433644dda7b2Smrgfunc_win32_import_lib_p () 433744dda7b2Smrg{ 433844dda7b2Smrg $opt_debug 433944dda7b2Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 434044dda7b2Smrg *import*) : ;; 434144dda7b2Smrg *) false ;; 434244dda7b2Smrg esac 434344dda7b2Smrg} 434444dda7b2Smrg 43457a3b38f7Smrg# func_mode_link arg... 43467a3b38f7Smrgfunc_mode_link () 43477a3b38f7Smrg{ 43487a3b38f7Smrg $opt_debug 43497a3b38f7Smrg case $host in 43507a3b38f7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 43517a3b38f7Smrg # It is impossible to link a dll without this setting, and 43527a3b38f7Smrg # we shouldn't force the makefile maintainer to figure out 43537a3b38f7Smrg # which system we are compiling for in order to pass an extra 43547a3b38f7Smrg # flag for every libtool invocation. 43557a3b38f7Smrg # allow_undefined=no 4356ff559fabSmrg 43577a3b38f7Smrg # FIXME: Unfortunately, there are problems with the above when trying 43587a3b38f7Smrg # to make a dll which has undefined symbols, in which case not 43597a3b38f7Smrg # even a static library is built. For now, we need to specify 43607a3b38f7Smrg # -no-undefined on the libtool link line when we can be certain 43617a3b38f7Smrg # that all symbols are satisfied, otherwise we get a static library. 43627a3b38f7Smrg allow_undefined=yes 43637a3b38f7Smrg ;; 43647a3b38f7Smrg *) 43657a3b38f7Smrg allow_undefined=yes 43667a3b38f7Smrg ;; 43677a3b38f7Smrg esac 43687a3b38f7Smrg libtool_args=$nonopt 43697a3b38f7Smrg base_compile="$nonopt $@" 43707a3b38f7Smrg compile_command=$nonopt 43717a3b38f7Smrg finalize_command=$nonopt 4372ff559fabSmrg 43737a3b38f7Smrg compile_rpath= 43747a3b38f7Smrg finalize_rpath= 43757a3b38f7Smrg compile_shlibpath= 43767a3b38f7Smrg finalize_shlibpath= 43777a3b38f7Smrg convenience= 43787a3b38f7Smrg old_convenience= 43797a3b38f7Smrg deplibs= 43807a3b38f7Smrg old_deplibs= 43817a3b38f7Smrg compiler_flags= 43827a3b38f7Smrg linker_flags= 43837a3b38f7Smrg dllsearchpath= 43847a3b38f7Smrg lib_search_path=`pwd` 43857a3b38f7Smrg inst_prefix_dir= 43867a3b38f7Smrg new_inherited_linker_flags= 4387ff559fabSmrg 43887a3b38f7Smrg avoid_version=no 438944dda7b2Smrg bindir= 43907a3b38f7Smrg dlfiles= 43917a3b38f7Smrg dlprefiles= 43927a3b38f7Smrg dlself=no 43937a3b38f7Smrg export_dynamic=no 43947a3b38f7Smrg export_symbols= 43957a3b38f7Smrg export_symbols_regex= 43967a3b38f7Smrg generated= 43977a3b38f7Smrg libobjs= 43987a3b38f7Smrg ltlibs= 43997a3b38f7Smrg module=no 44007a3b38f7Smrg no_install=no 44017a3b38f7Smrg objs= 44027a3b38f7Smrg non_pic_objects= 44037a3b38f7Smrg precious_files_regex= 44047a3b38f7Smrg prefer_static_libs=no 44057a3b38f7Smrg preload=no 44067a3b38f7Smrg prev= 44077a3b38f7Smrg prevarg= 44087a3b38f7Smrg release= 44097a3b38f7Smrg rpath= 44107a3b38f7Smrg xrpath= 44117a3b38f7Smrg perm_rpath= 44127a3b38f7Smrg temp_rpath= 44137a3b38f7Smrg thread_safe=no 44147a3b38f7Smrg vinfo= 44157a3b38f7Smrg vinfo_number=no 44167a3b38f7Smrg weak_libs= 44177a3b38f7Smrg single_module="${wl}-single_module" 44187a3b38f7Smrg func_infer_tag $base_compile 4419ff559fabSmrg 44207a3b38f7Smrg # We need to know -static, to get the right output filenames. 44217a3b38f7Smrg for arg 44227a3b38f7Smrg do 44237a3b38f7Smrg case $arg in 44247a3b38f7Smrg -shared) 44257a3b38f7Smrg test "$build_libtool_libs" != yes && \ 44267a3b38f7Smrg func_fatal_configuration "can not build a shared library" 44277a3b38f7Smrg build_old_libs=no 44287a3b38f7Smrg break 44297a3b38f7Smrg ;; 44307a3b38f7Smrg -all-static | -static | -static-libtool-libs) 44317a3b38f7Smrg case $arg in 44327a3b38f7Smrg -all-static) 44337a3b38f7Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 44347a3b38f7Smrg func_warning "complete static linking is impossible in this configuration" 4435ff559fabSmrg fi 44367a3b38f7Smrg if test -n "$link_static_flag"; then 44377a3b38f7Smrg dlopen_self=$dlopen_self_static 4438ff559fabSmrg fi 44397a3b38f7Smrg prefer_static_libs=yes 4440ff559fabSmrg ;; 44417a3b38f7Smrg -static) 44427a3b38f7Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 44437a3b38f7Smrg dlopen_self=$dlopen_self_static 44447a3b38f7Smrg fi 44457a3b38f7Smrg prefer_static_libs=built 44467a3b38f7Smrg ;; 44477a3b38f7Smrg -static-libtool-libs) 44487a3b38f7Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 44497a3b38f7Smrg dlopen_self=$dlopen_self_static 44507a3b38f7Smrg fi 44517a3b38f7Smrg prefer_static_libs=yes 4452ff559fabSmrg ;; 4453ff559fabSmrg esac 44547a3b38f7Smrg build_libtool_libs=no 44557a3b38f7Smrg build_old_libs=yes 44567a3b38f7Smrg break 44577a3b38f7Smrg ;; 44587a3b38f7Smrg esac 44597a3b38f7Smrg done 4460ff559fabSmrg 44617a3b38f7Smrg # See if our shared archives depend on static archives. 44627a3b38f7Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 4463ff559fabSmrg 44647a3b38f7Smrg # Go through the arguments, transforming them on the way. 44657a3b38f7Smrg while test "$#" -gt 0; do 44667a3b38f7Smrg arg="$1" 44677a3b38f7Smrg shift 44687a3b38f7Smrg func_quote_for_eval "$arg" 44697a3b38f7Smrg qarg=$func_quote_for_eval_unquoted_result 44707a3b38f7Smrg func_append libtool_args " $func_quote_for_eval_result" 4471ff559fabSmrg 44727a3b38f7Smrg # If the previous option needs an argument, assign it. 44737a3b38f7Smrg if test -n "$prev"; then 44747a3b38f7Smrg case $prev in 44757a3b38f7Smrg output) 44767a3b38f7Smrg func_append compile_command " @OUTPUT@" 44777a3b38f7Smrg func_append finalize_command " @OUTPUT@" 44787a3b38f7Smrg ;; 44797a3b38f7Smrg esac 4480ff559fabSmrg 44817a3b38f7Smrg case $prev in 448244dda7b2Smrg bindir) 448344dda7b2Smrg bindir="$arg" 448444dda7b2Smrg prev= 448544dda7b2Smrg continue 448644dda7b2Smrg ;; 44877a3b38f7Smrg dlfiles|dlprefiles) 44887a3b38f7Smrg if test "$preload" = no; then 44897a3b38f7Smrg # Add the symbol object into the linking commands. 44907a3b38f7Smrg func_append compile_command " @SYMFILE@" 44917a3b38f7Smrg func_append finalize_command " @SYMFILE@" 44927a3b38f7Smrg preload=yes 44937a3b38f7Smrg fi 44947a3b38f7Smrg case $arg in 44957a3b38f7Smrg *.la | *.lo) ;; # We handle these cases below. 44967a3b38f7Smrg force) 44977a3b38f7Smrg if test "$dlself" = no; then 44987a3b38f7Smrg dlself=needless 44997a3b38f7Smrg export_dynamic=yes 45007a3b38f7Smrg fi 45017a3b38f7Smrg prev= 45027a3b38f7Smrg continue 45037a3b38f7Smrg ;; 45047a3b38f7Smrg self) 45057a3b38f7Smrg if test "$prev" = dlprefiles; then 45067a3b38f7Smrg dlself=yes 45077a3b38f7Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 45087a3b38f7Smrg dlself=yes 45097a3b38f7Smrg else 45107a3b38f7Smrg dlself=needless 45117a3b38f7Smrg export_dynamic=yes 45127a3b38f7Smrg fi 45137a3b38f7Smrg prev= 45147a3b38f7Smrg continue 4515ff559fabSmrg ;; 4516ff559fabSmrg *) 45177a3b38f7Smrg if test "$prev" = dlfiles; then 45187a3b38f7Smrg dlfiles="$dlfiles $arg" 45197a3b38f7Smrg else 45207a3b38f7Smrg dlprefiles="$dlprefiles $arg" 45217a3b38f7Smrg fi 45227a3b38f7Smrg prev= 45237a3b38f7Smrg continue 4524ff559fabSmrg ;; 4525ff559fabSmrg esac 45267a3b38f7Smrg ;; 45277a3b38f7Smrg expsyms) 45287a3b38f7Smrg export_symbols="$arg" 45297a3b38f7Smrg test -f "$arg" \ 45307a3b38f7Smrg || func_fatal_error "symbol file \`$arg' does not exist" 45317a3b38f7Smrg prev= 45327a3b38f7Smrg continue 45337a3b38f7Smrg ;; 45347a3b38f7Smrg expsyms_regex) 45357a3b38f7Smrg export_symbols_regex="$arg" 45367a3b38f7Smrg prev= 45377a3b38f7Smrg continue 45387a3b38f7Smrg ;; 45397a3b38f7Smrg framework) 45407a3b38f7Smrg case $host in 45417a3b38f7Smrg *-*-darwin*) 45427a3b38f7Smrg case "$deplibs " in 45437a3b38f7Smrg *" $qarg.ltframework "*) ;; 45447a3b38f7Smrg *) deplibs="$deplibs $qarg.ltframework" # this is fixed later 45457a3b38f7Smrg ;; 45467a3b38f7Smrg esac 45477a3b38f7Smrg ;; 45487a3b38f7Smrg esac 45497a3b38f7Smrg prev= 45507a3b38f7Smrg continue 45517a3b38f7Smrg ;; 45527a3b38f7Smrg inst_prefix) 45537a3b38f7Smrg inst_prefix_dir="$arg" 45547a3b38f7Smrg prev= 45557a3b38f7Smrg continue 45567a3b38f7Smrg ;; 45577a3b38f7Smrg objectlist) 45587a3b38f7Smrg if test -f "$arg"; then 45597a3b38f7Smrg save_arg=$arg 45607a3b38f7Smrg moreargs= 45617a3b38f7Smrg for fil in `cat "$save_arg"` 45627a3b38f7Smrg do 45637a3b38f7Smrg# moreargs="$moreargs $fil" 45647a3b38f7Smrg arg=$fil 45657a3b38f7Smrg # A libtool-controlled object. 4566ff559fabSmrg 45677a3b38f7Smrg # Check to see that this really is a libtool object. 45687a3b38f7Smrg if func_lalib_unsafe_p "$arg"; then 45697a3b38f7Smrg pic_object= 45707a3b38f7Smrg non_pic_object= 4571ff559fabSmrg 45727a3b38f7Smrg # Read the .lo file 45737a3b38f7Smrg func_source "$arg" 4574ff559fabSmrg 45757a3b38f7Smrg if test -z "$pic_object" || 45767a3b38f7Smrg test -z "$non_pic_object" || 45777a3b38f7Smrg test "$pic_object" = none && 45787a3b38f7Smrg test "$non_pic_object" = none; then 45797a3b38f7Smrg func_fatal_error "cannot find name of object for \`$arg'" 45807a3b38f7Smrg fi 4581ff559fabSmrg 45827a3b38f7Smrg # Extract subdirectory from the argument. 45837a3b38f7Smrg func_dirname "$arg" "/" "" 45847a3b38f7Smrg xdir="$func_dirname_result" 4585ff559fabSmrg 45867a3b38f7Smrg if test "$pic_object" != none; then 45877a3b38f7Smrg # Prepend the subdirectory the object is found in. 45887a3b38f7Smrg pic_object="$xdir$pic_object" 4589ff559fabSmrg 45907a3b38f7Smrg if test "$prev" = dlfiles; then 45917a3b38f7Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 45927a3b38f7Smrg dlfiles="$dlfiles $pic_object" 45937a3b38f7Smrg prev= 45947a3b38f7Smrg continue 45957a3b38f7Smrg else 45967a3b38f7Smrg # If libtool objects are unsupported, then we need to preload. 45977a3b38f7Smrg prev=dlprefiles 45987a3b38f7Smrg fi 45997a3b38f7Smrg fi 4600ff559fabSmrg 46017a3b38f7Smrg # CHECK ME: I think I busted this. -Ossama 46027a3b38f7Smrg if test "$prev" = dlprefiles; then 46037a3b38f7Smrg # Preload the old-style object. 46047a3b38f7Smrg dlprefiles="$dlprefiles $pic_object" 46057a3b38f7Smrg prev= 46067a3b38f7Smrg fi 4607ff559fabSmrg 46087a3b38f7Smrg # A PIC object. 46097a3b38f7Smrg func_append libobjs " $pic_object" 46107a3b38f7Smrg arg="$pic_object" 46117a3b38f7Smrg fi 4612ff559fabSmrg 46137a3b38f7Smrg # Non-PIC object. 46147a3b38f7Smrg if test "$non_pic_object" != none; then 46157a3b38f7Smrg # Prepend the subdirectory the object is found in. 46167a3b38f7Smrg non_pic_object="$xdir$non_pic_object" 4617ff559fabSmrg 46187a3b38f7Smrg # A standard non-PIC object 46197a3b38f7Smrg func_append non_pic_objects " $non_pic_object" 46207a3b38f7Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 46217a3b38f7Smrg arg="$non_pic_object" 46227a3b38f7Smrg fi 46237a3b38f7Smrg else 46247a3b38f7Smrg # If the PIC object exists, use it instead. 46257a3b38f7Smrg # $xdir was prepended to $pic_object above. 46267a3b38f7Smrg non_pic_object="$pic_object" 46277a3b38f7Smrg func_append non_pic_objects " $non_pic_object" 46287a3b38f7Smrg fi 46297a3b38f7Smrg else 46307a3b38f7Smrg # Only an error if not doing a dry-run. 46317a3b38f7Smrg if $opt_dry_run; then 46327a3b38f7Smrg # Extract subdirectory from the argument. 46337a3b38f7Smrg func_dirname "$arg" "/" "" 46347a3b38f7Smrg xdir="$func_dirname_result" 46357a3b38f7Smrg 46367a3b38f7Smrg func_lo2o "$arg" 46377a3b38f7Smrg pic_object=$xdir$objdir/$func_lo2o_result 46387a3b38f7Smrg non_pic_object=$xdir$func_lo2o_result 46397a3b38f7Smrg func_append libobjs " $pic_object" 46407a3b38f7Smrg func_append non_pic_objects " $non_pic_object" 46417a3b38f7Smrg else 46427a3b38f7Smrg func_fatal_error "\`$arg' is not a valid libtool object" 46437a3b38f7Smrg fi 46447a3b38f7Smrg fi 46457a3b38f7Smrg done 46467a3b38f7Smrg else 46477a3b38f7Smrg func_fatal_error "link input file \`$arg' does not exist" 46487a3b38f7Smrg fi 46497a3b38f7Smrg arg=$save_arg 46507a3b38f7Smrg prev= 46517a3b38f7Smrg continue 46527a3b38f7Smrg ;; 46537a3b38f7Smrg precious_regex) 46547a3b38f7Smrg precious_files_regex="$arg" 46557a3b38f7Smrg prev= 46567a3b38f7Smrg continue 46577a3b38f7Smrg ;; 46587a3b38f7Smrg release) 46597a3b38f7Smrg release="-$arg" 46607a3b38f7Smrg prev= 46617a3b38f7Smrg continue 46627a3b38f7Smrg ;; 46637a3b38f7Smrg rpath | xrpath) 46647a3b38f7Smrg # We need an absolute path. 46657a3b38f7Smrg case $arg in 46667a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 46677a3b38f7Smrg *) 46687a3b38f7Smrg func_fatal_error "only absolute run-paths are allowed" 46697a3b38f7Smrg ;; 46707a3b38f7Smrg esac 46717a3b38f7Smrg if test "$prev" = rpath; then 46727a3b38f7Smrg case "$rpath " in 46737a3b38f7Smrg *" $arg "*) ;; 46747a3b38f7Smrg *) rpath="$rpath $arg" ;; 46757a3b38f7Smrg esac 46767a3b38f7Smrg else 46777a3b38f7Smrg case "$xrpath " in 46787a3b38f7Smrg *" $arg "*) ;; 46797a3b38f7Smrg *) xrpath="$xrpath $arg" ;; 46807a3b38f7Smrg esac 46817a3b38f7Smrg fi 46827a3b38f7Smrg prev= 46837a3b38f7Smrg continue 46847a3b38f7Smrg ;; 46857a3b38f7Smrg shrext) 46867a3b38f7Smrg shrext_cmds="$arg" 46877a3b38f7Smrg prev= 46887a3b38f7Smrg continue 46897a3b38f7Smrg ;; 46907a3b38f7Smrg weak) 46917a3b38f7Smrg weak_libs="$weak_libs $arg" 46927a3b38f7Smrg prev= 46937a3b38f7Smrg continue 46947a3b38f7Smrg ;; 46957a3b38f7Smrg xcclinker) 46967a3b38f7Smrg linker_flags="$linker_flags $qarg" 46977a3b38f7Smrg compiler_flags="$compiler_flags $qarg" 46987a3b38f7Smrg prev= 46997a3b38f7Smrg func_append compile_command " $qarg" 47007a3b38f7Smrg func_append finalize_command " $qarg" 47017a3b38f7Smrg continue 47027a3b38f7Smrg ;; 47037a3b38f7Smrg xcompiler) 47047a3b38f7Smrg compiler_flags="$compiler_flags $qarg" 47057a3b38f7Smrg prev= 47067a3b38f7Smrg func_append compile_command " $qarg" 47077a3b38f7Smrg func_append finalize_command " $qarg" 47087a3b38f7Smrg continue 47097a3b38f7Smrg ;; 47107a3b38f7Smrg xlinker) 47117a3b38f7Smrg linker_flags="$linker_flags $qarg" 47127a3b38f7Smrg compiler_flags="$compiler_flags $wl$qarg" 47137a3b38f7Smrg prev= 47147a3b38f7Smrg func_append compile_command " $wl$qarg" 47157a3b38f7Smrg func_append finalize_command " $wl$qarg" 47167a3b38f7Smrg continue 47177a3b38f7Smrg ;; 47187a3b38f7Smrg *) 47197a3b38f7Smrg eval "$prev=\"\$arg\"" 47207a3b38f7Smrg prev= 47217a3b38f7Smrg continue 47227a3b38f7Smrg ;; 4723ff559fabSmrg esac 47247a3b38f7Smrg fi # test -n "$prev" 4725ff559fabSmrg 47267a3b38f7Smrg prevarg="$arg" 4727ff559fabSmrg 47287a3b38f7Smrg case $arg in 47297a3b38f7Smrg -all-static) 47307a3b38f7Smrg if test -n "$link_static_flag"; then 47317a3b38f7Smrg # See comment for -static flag below, for more details. 47327a3b38f7Smrg func_append compile_command " $link_static_flag" 47337a3b38f7Smrg func_append finalize_command " $link_static_flag" 47347a3b38f7Smrg fi 47357a3b38f7Smrg continue 47367a3b38f7Smrg ;; 4737ff559fabSmrg 47387a3b38f7Smrg -allow-undefined) 47397a3b38f7Smrg # FIXME: remove this flag sometime in the future. 47407a3b38f7Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 47417a3b38f7Smrg ;; 4742ff559fabSmrg 47437a3b38f7Smrg -avoid-version) 47447a3b38f7Smrg avoid_version=yes 47457a3b38f7Smrg continue 47467a3b38f7Smrg ;; 4747ff559fabSmrg 474844dda7b2Smrg -bindir) 474944dda7b2Smrg prev=bindir 475044dda7b2Smrg continue 475144dda7b2Smrg ;; 475244dda7b2Smrg 47537a3b38f7Smrg -dlopen) 47547a3b38f7Smrg prev=dlfiles 47557a3b38f7Smrg continue 47567a3b38f7Smrg ;; 4757ff559fabSmrg 47587a3b38f7Smrg -dlpreopen) 47597a3b38f7Smrg prev=dlprefiles 47607a3b38f7Smrg continue 47617a3b38f7Smrg ;; 4762ff559fabSmrg 47637a3b38f7Smrg -export-dynamic) 47647a3b38f7Smrg export_dynamic=yes 47657a3b38f7Smrg continue 47667a3b38f7Smrg ;; 4767ff559fabSmrg 47687a3b38f7Smrg -export-symbols | -export-symbols-regex) 47697a3b38f7Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 47707a3b38f7Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 47717a3b38f7Smrg fi 47727a3b38f7Smrg if test "X$arg" = "X-export-symbols"; then 47737a3b38f7Smrg prev=expsyms 47747a3b38f7Smrg else 47757a3b38f7Smrg prev=expsyms_regex 47767a3b38f7Smrg fi 47777a3b38f7Smrg continue 47787a3b38f7Smrg ;; 4779ff559fabSmrg 47807a3b38f7Smrg -framework) 47817a3b38f7Smrg prev=framework 47827a3b38f7Smrg continue 47837a3b38f7Smrg ;; 4784ff559fabSmrg 47857a3b38f7Smrg -inst-prefix-dir) 47867a3b38f7Smrg prev=inst_prefix 47877a3b38f7Smrg continue 47887a3b38f7Smrg ;; 4789ff559fabSmrg 47907a3b38f7Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 47917a3b38f7Smrg # so, if we see these flags be careful not to treat them like -L 47927a3b38f7Smrg -L[A-Z][A-Z]*:*) 47937a3b38f7Smrg case $with_gcc/$host in 47947a3b38f7Smrg no/*-*-irix* | /*-*-irix*) 47957a3b38f7Smrg func_append compile_command " $arg" 47967a3b38f7Smrg func_append finalize_command " $arg" 47977a3b38f7Smrg ;; 47987a3b38f7Smrg esac 47997a3b38f7Smrg continue 48007a3b38f7Smrg ;; 4801ff559fabSmrg 48027a3b38f7Smrg -L*) 48037a3b38f7Smrg func_stripname '-L' '' "$arg" 48047a3b38f7Smrg dir=$func_stripname_result 48057a3b38f7Smrg if test -z "$dir"; then 48067a3b38f7Smrg if test "$#" -gt 0; then 48077a3b38f7Smrg func_fatal_error "require no space between \`-L' and \`$1'" 48087a3b38f7Smrg else 48097a3b38f7Smrg func_fatal_error "need path for \`-L' option" 48107a3b38f7Smrg fi 48117a3b38f7Smrg fi 48127a3b38f7Smrg # We need an absolute path. 48137a3b38f7Smrg case $dir in 48147a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 48157a3b38f7Smrg *) 48167a3b38f7Smrg absdir=`cd "$dir" && pwd` 48177a3b38f7Smrg test -z "$absdir" && \ 48187a3b38f7Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 48197a3b38f7Smrg dir="$absdir" 48207a3b38f7Smrg ;; 48217a3b38f7Smrg esac 48227a3b38f7Smrg case "$deplibs " in 48237a3b38f7Smrg *" -L$dir "*) ;; 48247a3b38f7Smrg *) 48257a3b38f7Smrg deplibs="$deplibs -L$dir" 48267a3b38f7Smrg lib_search_path="$lib_search_path $dir" 48277a3b38f7Smrg ;; 48287a3b38f7Smrg esac 48297a3b38f7Smrg case $host in 48307a3b38f7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 483144dda7b2Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 48327a3b38f7Smrg case :$dllsearchpath: in 48337a3b38f7Smrg *":$dir:"*) ;; 48347a3b38f7Smrg ::) dllsearchpath=$dir;; 48357a3b38f7Smrg *) dllsearchpath="$dllsearchpath:$dir";; 48367a3b38f7Smrg esac 48377a3b38f7Smrg case :$dllsearchpath: in 48387a3b38f7Smrg *":$testbindir:"*) ;; 48397a3b38f7Smrg ::) dllsearchpath=$testbindir;; 48407a3b38f7Smrg *) dllsearchpath="$dllsearchpath:$testbindir";; 48417a3b38f7Smrg esac 48427a3b38f7Smrg ;; 48437a3b38f7Smrg esac 48447a3b38f7Smrg continue 48457a3b38f7Smrg ;; 4846ff559fabSmrg 48477a3b38f7Smrg -l*) 48487a3b38f7Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 48497a3b38f7Smrg case $host in 485044dda7b2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 48517a3b38f7Smrg # These systems don't actually have a C or math library (as such) 48527a3b38f7Smrg continue 48537a3b38f7Smrg ;; 48547a3b38f7Smrg *-*-os2*) 48557a3b38f7Smrg # These systems don't actually have a C library (as such) 48567a3b38f7Smrg test "X$arg" = "X-lc" && continue 48577a3b38f7Smrg ;; 48587a3b38f7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 48597a3b38f7Smrg # Do not include libc due to us having libc/libc_r. 48607a3b38f7Smrg test "X$arg" = "X-lc" && continue 48617a3b38f7Smrg ;; 48627a3b38f7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 48637a3b38f7Smrg # Rhapsody C and math libraries are in the System framework 48647a3b38f7Smrg deplibs="$deplibs System.ltframework" 48657a3b38f7Smrg continue 48667a3b38f7Smrg ;; 48677a3b38f7Smrg *-*-sco3.2v5* | *-*-sco5v6*) 48687a3b38f7Smrg # Causes problems with __ctype 48697a3b38f7Smrg test "X$arg" = "X-lc" && continue 48707a3b38f7Smrg ;; 48717a3b38f7Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 48727a3b38f7Smrg # Compiler inserts libc in the correct place for threads to work 48737a3b38f7Smrg test "X$arg" = "X-lc" && continue 48747a3b38f7Smrg ;; 48757a3b38f7Smrg esac 48767a3b38f7Smrg elif test "X$arg" = "X-lc_r"; then 48777a3b38f7Smrg case $host in 48787a3b38f7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 48797a3b38f7Smrg # Do not include libc_r directly, use -pthread flag. 48807a3b38f7Smrg continue 48817a3b38f7Smrg ;; 48827a3b38f7Smrg esac 48837a3b38f7Smrg fi 48847a3b38f7Smrg deplibs="$deplibs $arg" 48857a3b38f7Smrg continue 48867a3b38f7Smrg ;; 4887ff559fabSmrg 48887a3b38f7Smrg -module) 48897a3b38f7Smrg module=yes 48907a3b38f7Smrg continue 48917a3b38f7Smrg ;; 4892ff559fabSmrg 48937a3b38f7Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 48947a3b38f7Smrg # classes, name mangling, and exception handling. 48957a3b38f7Smrg # Darwin uses the -arch flag to determine output architecture. 48967a3b38f7Smrg -model|-arch|-isysroot) 48977a3b38f7Smrg compiler_flags="$compiler_flags $arg" 48987a3b38f7Smrg func_append compile_command " $arg" 48997a3b38f7Smrg func_append finalize_command " $arg" 49007a3b38f7Smrg prev=xcompiler 49017a3b38f7Smrg continue 49027a3b38f7Smrg ;; 4903ff559fabSmrg 49047a3b38f7Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 49057a3b38f7Smrg compiler_flags="$compiler_flags $arg" 49067a3b38f7Smrg func_append compile_command " $arg" 49077a3b38f7Smrg func_append finalize_command " $arg" 49087a3b38f7Smrg case "$new_inherited_linker_flags " in 49097a3b38f7Smrg *" $arg "*) ;; 49107a3b38f7Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; 49117a3b38f7Smrg esac 49127a3b38f7Smrg continue 49137a3b38f7Smrg ;; 4914ff559fabSmrg 49157a3b38f7Smrg -multi_module) 49167a3b38f7Smrg single_module="${wl}-multi_module" 49177a3b38f7Smrg continue 49187a3b38f7Smrg ;; 4919ff559fabSmrg 49207a3b38f7Smrg -no-fast-install) 49217a3b38f7Smrg fast_install=no 49227a3b38f7Smrg continue 49237a3b38f7Smrg ;; 4924ff559fabSmrg 49257a3b38f7Smrg -no-install) 49267a3b38f7Smrg case $host in 49277a3b38f7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 49287a3b38f7Smrg # The PATH hackery in wrapper scripts is required on Windows 49297a3b38f7Smrg # and Darwin in order for the loader to find any dlls it needs. 49307a3b38f7Smrg func_warning "\`-no-install' is ignored for $host" 49317a3b38f7Smrg func_warning "assuming \`-no-fast-install' instead" 49327a3b38f7Smrg fast_install=no 49337a3b38f7Smrg ;; 49347a3b38f7Smrg *) no_install=yes ;; 49357a3b38f7Smrg esac 49367a3b38f7Smrg continue 49377a3b38f7Smrg ;; 4938ff559fabSmrg 49397a3b38f7Smrg -no-undefined) 49407a3b38f7Smrg allow_undefined=no 49417a3b38f7Smrg continue 49427a3b38f7Smrg ;; 4943ff559fabSmrg 49447a3b38f7Smrg -objectlist) 49457a3b38f7Smrg prev=objectlist 49467a3b38f7Smrg continue 49477a3b38f7Smrg ;; 4948ff559fabSmrg 49497a3b38f7Smrg -o) prev=output ;; 4950ff559fabSmrg 49517a3b38f7Smrg -precious-files-regex) 49527a3b38f7Smrg prev=precious_regex 49537a3b38f7Smrg continue 49547a3b38f7Smrg ;; 4955ff559fabSmrg 49567a3b38f7Smrg -release) 49577a3b38f7Smrg prev=release 49587a3b38f7Smrg continue 49597a3b38f7Smrg ;; 4960ff559fabSmrg 49617a3b38f7Smrg -rpath) 49627a3b38f7Smrg prev=rpath 49637a3b38f7Smrg continue 49647a3b38f7Smrg ;; 4965ff559fabSmrg 49667a3b38f7Smrg -R) 49677a3b38f7Smrg prev=xrpath 49687a3b38f7Smrg continue 49697a3b38f7Smrg ;; 4970ff559fabSmrg 49717a3b38f7Smrg -R*) 49727a3b38f7Smrg func_stripname '-R' '' "$arg" 49737a3b38f7Smrg dir=$func_stripname_result 49747a3b38f7Smrg # We need an absolute path. 49757a3b38f7Smrg case $dir in 49767a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 49777a3b38f7Smrg *) 49787a3b38f7Smrg func_fatal_error "only absolute run-paths are allowed" 49797a3b38f7Smrg ;; 49807a3b38f7Smrg esac 49817a3b38f7Smrg case "$xrpath " in 49827a3b38f7Smrg *" $dir "*) ;; 49837a3b38f7Smrg *) xrpath="$xrpath $dir" ;; 49847a3b38f7Smrg esac 49857a3b38f7Smrg continue 49867a3b38f7Smrg ;; 4987ff559fabSmrg 49887a3b38f7Smrg -shared) 49897a3b38f7Smrg # The effects of -shared are defined in a previous loop. 49907a3b38f7Smrg continue 49917a3b38f7Smrg ;; 4992ff559fabSmrg 49937a3b38f7Smrg -shrext) 49947a3b38f7Smrg prev=shrext 49957a3b38f7Smrg continue 49967a3b38f7Smrg ;; 4997ff559fabSmrg 49987a3b38f7Smrg -static | -static-libtool-libs) 49997a3b38f7Smrg # The effects of -static are defined in a previous loop. 50007a3b38f7Smrg # We used to do the same as -all-static on platforms that 50017a3b38f7Smrg # didn't have a PIC flag, but the assumption that the effects 50027a3b38f7Smrg # would be equivalent was wrong. It would break on at least 50037a3b38f7Smrg # Digital Unix and AIX. 50047a3b38f7Smrg continue 50057a3b38f7Smrg ;; 5006ff559fabSmrg 50077a3b38f7Smrg -thread-safe) 50087a3b38f7Smrg thread_safe=yes 50097a3b38f7Smrg continue 50107a3b38f7Smrg ;; 5011ff559fabSmrg 50127a3b38f7Smrg -version-info) 50137a3b38f7Smrg prev=vinfo 50147a3b38f7Smrg continue 50157a3b38f7Smrg ;; 5016ff559fabSmrg 50177a3b38f7Smrg -version-number) 50187a3b38f7Smrg prev=vinfo 50197a3b38f7Smrg vinfo_number=yes 50207a3b38f7Smrg continue 50217a3b38f7Smrg ;; 5022ff559fabSmrg 50237a3b38f7Smrg -weak) 50247a3b38f7Smrg prev=weak 50257a3b38f7Smrg continue 50267a3b38f7Smrg ;; 5027ff559fabSmrg 50287a3b38f7Smrg -Wc,*) 50297a3b38f7Smrg func_stripname '-Wc,' '' "$arg" 50307a3b38f7Smrg args=$func_stripname_result 50317a3b38f7Smrg arg= 50327a3b38f7Smrg save_ifs="$IFS"; IFS=',' 50337a3b38f7Smrg for flag in $args; do 50347a3b38f7Smrg IFS="$save_ifs" 50357a3b38f7Smrg func_quote_for_eval "$flag" 503644dda7b2Smrg arg="$arg $func_quote_for_eval_result" 50377a3b38f7Smrg compiler_flags="$compiler_flags $func_quote_for_eval_result" 50387a3b38f7Smrg done 50397a3b38f7Smrg IFS="$save_ifs" 50407a3b38f7Smrg func_stripname ' ' '' "$arg" 50417a3b38f7Smrg arg=$func_stripname_result 50427a3b38f7Smrg ;; 5043ff559fabSmrg 50447a3b38f7Smrg -Wl,*) 50457a3b38f7Smrg func_stripname '-Wl,' '' "$arg" 50467a3b38f7Smrg args=$func_stripname_result 50477a3b38f7Smrg arg= 50487a3b38f7Smrg save_ifs="$IFS"; IFS=',' 50497a3b38f7Smrg for flag in $args; do 50507a3b38f7Smrg IFS="$save_ifs" 50517a3b38f7Smrg func_quote_for_eval "$flag" 50527a3b38f7Smrg arg="$arg $wl$func_quote_for_eval_result" 50537a3b38f7Smrg compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" 50547a3b38f7Smrg linker_flags="$linker_flags $func_quote_for_eval_result" 50557a3b38f7Smrg done 50567a3b38f7Smrg IFS="$save_ifs" 50577a3b38f7Smrg func_stripname ' ' '' "$arg" 50587a3b38f7Smrg arg=$func_stripname_result 50597a3b38f7Smrg ;; 5060ff559fabSmrg 50617a3b38f7Smrg -Xcompiler) 50627a3b38f7Smrg prev=xcompiler 50637a3b38f7Smrg continue 50647a3b38f7Smrg ;; 5065ff559fabSmrg 50667a3b38f7Smrg -Xlinker) 50677a3b38f7Smrg prev=xlinker 50687a3b38f7Smrg continue 50697a3b38f7Smrg ;; 5070ff559fabSmrg 50717a3b38f7Smrg -XCClinker) 50727a3b38f7Smrg prev=xcclinker 50737a3b38f7Smrg continue 50747a3b38f7Smrg ;; 5075ff559fabSmrg 50767a3b38f7Smrg # -msg_* for osf cc 50777a3b38f7Smrg -msg_*) 50787a3b38f7Smrg func_quote_for_eval "$arg" 50797a3b38f7Smrg arg="$func_quote_for_eval_result" 50807a3b38f7Smrg ;; 5081ff559fabSmrg 508244dda7b2Smrg # Flags to be passed through unchanged, with rationale: 508344dda7b2Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 508444dda7b2Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 508544dda7b2Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 508644dda7b2Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 508744dda7b2Smrg # -q* compiler args for the IBM compiler 508844dda7b2Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 508944dda7b2Smrg # -F/path path to uninstalled frameworks, gcc on darwin 509044dda7b2Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 509144dda7b2Smrg # @file GCC response files 509244dda7b2Smrg # -tp=* Portland pgcc target processor selection 50937a3b38f7Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 509444dda7b2Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*) 50957a3b38f7Smrg func_quote_for_eval "$arg" 50967a3b38f7Smrg arg="$func_quote_for_eval_result" 50977a3b38f7Smrg func_append compile_command " $arg" 50987a3b38f7Smrg func_append finalize_command " $arg" 50997a3b38f7Smrg compiler_flags="$compiler_flags $arg" 51007a3b38f7Smrg continue 51017a3b38f7Smrg ;; 5102ff559fabSmrg 51037a3b38f7Smrg # Some other compiler flag. 51047a3b38f7Smrg -* | +*) 51057a3b38f7Smrg func_quote_for_eval "$arg" 51067a3b38f7Smrg arg="$func_quote_for_eval_result" 51077a3b38f7Smrg ;; 5108ff559fabSmrg 51097a3b38f7Smrg *.$objext) 51107a3b38f7Smrg # A standard object. 51117a3b38f7Smrg objs="$objs $arg" 51127a3b38f7Smrg ;; 51137a3b38f7Smrg 51147a3b38f7Smrg *.lo) 51157a3b38f7Smrg # A libtool-controlled object. 51167a3b38f7Smrg 51177a3b38f7Smrg # Check to see that this really is a libtool object. 51187a3b38f7Smrg if func_lalib_unsafe_p "$arg"; then 51197a3b38f7Smrg pic_object= 51207a3b38f7Smrg non_pic_object= 51217a3b38f7Smrg 51227a3b38f7Smrg # Read the .lo file 51237a3b38f7Smrg func_source "$arg" 51247a3b38f7Smrg 51257a3b38f7Smrg if test -z "$pic_object" || 51267a3b38f7Smrg test -z "$non_pic_object" || 51277a3b38f7Smrg test "$pic_object" = none && 51287a3b38f7Smrg test "$non_pic_object" = none; then 51297a3b38f7Smrg func_fatal_error "cannot find name of object for \`$arg'" 51307a3b38f7Smrg fi 51317a3b38f7Smrg 51327a3b38f7Smrg # Extract subdirectory from the argument. 51337a3b38f7Smrg func_dirname "$arg" "/" "" 51347a3b38f7Smrg xdir="$func_dirname_result" 51357a3b38f7Smrg 51367a3b38f7Smrg if test "$pic_object" != none; then 51377a3b38f7Smrg # Prepend the subdirectory the object is found in. 51387a3b38f7Smrg pic_object="$xdir$pic_object" 51397a3b38f7Smrg 51407a3b38f7Smrg if test "$prev" = dlfiles; then 51417a3b38f7Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 51427a3b38f7Smrg dlfiles="$dlfiles $pic_object" 51437a3b38f7Smrg prev= 51447a3b38f7Smrg continue 51457a3b38f7Smrg else 51467a3b38f7Smrg # If libtool objects are unsupported, then we need to preload. 51477a3b38f7Smrg prev=dlprefiles 51487a3b38f7Smrg fi 51497a3b38f7Smrg fi 51507a3b38f7Smrg 51517a3b38f7Smrg # CHECK ME: I think I busted this. -Ossama 51527a3b38f7Smrg if test "$prev" = dlprefiles; then 51537a3b38f7Smrg # Preload the old-style object. 51547a3b38f7Smrg dlprefiles="$dlprefiles $pic_object" 51557a3b38f7Smrg prev= 51567a3b38f7Smrg fi 51577a3b38f7Smrg 51587a3b38f7Smrg # A PIC object. 51597a3b38f7Smrg func_append libobjs " $pic_object" 51607a3b38f7Smrg arg="$pic_object" 51617a3b38f7Smrg fi 51627a3b38f7Smrg 51637a3b38f7Smrg # Non-PIC object. 51647a3b38f7Smrg if test "$non_pic_object" != none; then 51657a3b38f7Smrg # Prepend the subdirectory the object is found in. 51667a3b38f7Smrg non_pic_object="$xdir$non_pic_object" 51677a3b38f7Smrg 51687a3b38f7Smrg # A standard non-PIC object 51697a3b38f7Smrg func_append non_pic_objects " $non_pic_object" 51707a3b38f7Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 51717a3b38f7Smrg arg="$non_pic_object" 51727a3b38f7Smrg fi 51737a3b38f7Smrg else 51747a3b38f7Smrg # If the PIC object exists, use it instead. 51757a3b38f7Smrg # $xdir was prepended to $pic_object above. 51767a3b38f7Smrg non_pic_object="$pic_object" 51777a3b38f7Smrg func_append non_pic_objects " $non_pic_object" 51787a3b38f7Smrg fi 51797a3b38f7Smrg else 51807a3b38f7Smrg # Only an error if not doing a dry-run. 51817a3b38f7Smrg if $opt_dry_run; then 51827a3b38f7Smrg # Extract subdirectory from the argument. 51837a3b38f7Smrg func_dirname "$arg" "/" "" 51847a3b38f7Smrg xdir="$func_dirname_result" 51857a3b38f7Smrg 51867a3b38f7Smrg func_lo2o "$arg" 51877a3b38f7Smrg pic_object=$xdir$objdir/$func_lo2o_result 51887a3b38f7Smrg non_pic_object=$xdir$func_lo2o_result 51897a3b38f7Smrg func_append libobjs " $pic_object" 51907a3b38f7Smrg func_append non_pic_objects " $non_pic_object" 51917a3b38f7Smrg else 51927a3b38f7Smrg func_fatal_error "\`$arg' is not a valid libtool object" 51937a3b38f7Smrg fi 51947a3b38f7Smrg fi 51957a3b38f7Smrg ;; 51967a3b38f7Smrg 51977a3b38f7Smrg *.$libext) 51987a3b38f7Smrg # An archive. 51997a3b38f7Smrg deplibs="$deplibs $arg" 52007a3b38f7Smrg old_deplibs="$old_deplibs $arg" 52017a3b38f7Smrg continue 52027a3b38f7Smrg ;; 52037a3b38f7Smrg 52047a3b38f7Smrg *.la) 52057a3b38f7Smrg # A libtool-controlled library. 52067a3b38f7Smrg 52077a3b38f7Smrg if test "$prev" = dlfiles; then 52087a3b38f7Smrg # This library was specified with -dlopen. 52097a3b38f7Smrg dlfiles="$dlfiles $arg" 52107a3b38f7Smrg prev= 52117a3b38f7Smrg elif test "$prev" = dlprefiles; then 52127a3b38f7Smrg # The library was specified with -dlpreopen. 52137a3b38f7Smrg dlprefiles="$dlprefiles $arg" 52147a3b38f7Smrg prev= 52157a3b38f7Smrg else 52167a3b38f7Smrg deplibs="$deplibs $arg" 52177a3b38f7Smrg fi 52187a3b38f7Smrg continue 52197a3b38f7Smrg ;; 52207a3b38f7Smrg 52217a3b38f7Smrg # Some other compiler argument. 52227a3b38f7Smrg *) 52237a3b38f7Smrg # Unknown arguments in both finalize_command and compile_command need 52247a3b38f7Smrg # to be aesthetically quoted because they are evaled later. 52257a3b38f7Smrg func_quote_for_eval "$arg" 52267a3b38f7Smrg arg="$func_quote_for_eval_result" 52277a3b38f7Smrg ;; 52287a3b38f7Smrg esac # arg 52297a3b38f7Smrg 52307a3b38f7Smrg # Now actually substitute the argument into the commands. 52317a3b38f7Smrg if test -n "$arg"; then 52327a3b38f7Smrg func_append compile_command " $arg" 52337a3b38f7Smrg func_append finalize_command " $arg" 52347a3b38f7Smrg fi 52357a3b38f7Smrg done # argument parsing loop 52367a3b38f7Smrg 52377a3b38f7Smrg test -n "$prev" && \ 52387a3b38f7Smrg func_fatal_help "the \`$prevarg' option requires an argument" 52397a3b38f7Smrg 52407a3b38f7Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 52417a3b38f7Smrg eval arg=\"$export_dynamic_flag_spec\" 52427a3b38f7Smrg func_append compile_command " $arg" 52437a3b38f7Smrg func_append finalize_command " $arg" 52447a3b38f7Smrg fi 52457a3b38f7Smrg 52467a3b38f7Smrg oldlibs= 52477a3b38f7Smrg # calculate the name of the file, without its directory 52487a3b38f7Smrg func_basename "$output" 52497a3b38f7Smrg outputname="$func_basename_result" 52507a3b38f7Smrg libobjs_save="$libobjs" 52517a3b38f7Smrg 52527a3b38f7Smrg if test -n "$shlibpath_var"; then 52537a3b38f7Smrg # get the directories listed in $shlibpath_var 525444dda7b2Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 5255ff559fabSmrg else 52567a3b38f7Smrg shlib_search_path= 5257ff559fabSmrg fi 52587a3b38f7Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 52597a3b38f7Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 5260ff559fabSmrg 52617a3b38f7Smrg func_dirname "$output" "/" "" 52627a3b38f7Smrg output_objdir="$func_dirname_result$objdir" 52637a3b38f7Smrg # Create the object directory. 52647a3b38f7Smrg func_mkdir_p "$output_objdir" 5265ff559fabSmrg 52667a3b38f7Smrg # Determine the type of output 52677a3b38f7Smrg case $output in 52687a3b38f7Smrg "") 52697a3b38f7Smrg func_fatal_help "you must specify an output file" 52707a3b38f7Smrg ;; 52717a3b38f7Smrg *.$libext) linkmode=oldlib ;; 52727a3b38f7Smrg *.lo | *.$objext) linkmode=obj ;; 52737a3b38f7Smrg *.la) linkmode=lib ;; 52747a3b38f7Smrg *) linkmode=prog ;; # Anything else should be a program. 52757a3b38f7Smrg esac 52767a3b38f7Smrg 52777a3b38f7Smrg specialdeplibs= 52787a3b38f7Smrg 52797a3b38f7Smrg libs= 52807a3b38f7Smrg # Find all interdependent deplibs by searching for libraries 52817a3b38f7Smrg # that are linked more than once (e.g. -la -lb -la) 52827a3b38f7Smrg for deplib in $deplibs; do 52837a3b38f7Smrg if $opt_duplicate_deps ; then 52847a3b38f7Smrg case "$libs " in 52857a3b38f7Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 52867a3b38f7Smrg esac 52877a3b38f7Smrg fi 52887a3b38f7Smrg libs="$libs $deplib" 52897a3b38f7Smrg done 52907a3b38f7Smrg 52917a3b38f7Smrg if test "$linkmode" = lib; then 52927a3b38f7Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 52937a3b38f7Smrg 52947a3b38f7Smrg # Compute libraries that are listed more than once in $predeps 52957a3b38f7Smrg # $postdeps and mark them as special (i.e., whose duplicates are 52967a3b38f7Smrg # not to be eliminated). 52977a3b38f7Smrg pre_post_deps= 52987a3b38f7Smrg if $opt_duplicate_compiler_generated_deps; then 52997a3b38f7Smrg for pre_post_dep in $predeps $postdeps; do 53007a3b38f7Smrg case "$pre_post_deps " in 53017a3b38f7Smrg *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; 53027a3b38f7Smrg esac 53037a3b38f7Smrg pre_post_deps="$pre_post_deps $pre_post_dep" 53047a3b38f7Smrg done 53057a3b38f7Smrg fi 53067a3b38f7Smrg pre_post_deps= 53077a3b38f7Smrg fi 53087a3b38f7Smrg 53097a3b38f7Smrg deplibs= 53107a3b38f7Smrg newdependency_libs= 53117a3b38f7Smrg newlib_search_path= 53127a3b38f7Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 53137a3b38f7Smrg notinst_deplibs= # not-installed libtool libraries 53147a3b38f7Smrg notinst_path= # paths that contain not-installed libtool libraries 53157a3b38f7Smrg 53167a3b38f7Smrg case $linkmode in 53177a3b38f7Smrg lib) 53187a3b38f7Smrg passes="conv dlpreopen link" 53197a3b38f7Smrg for file in $dlfiles $dlprefiles; do 53207a3b38f7Smrg case $file in 53217a3b38f7Smrg *.la) ;; 53227a3b38f7Smrg *) 53237a3b38f7Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 53247a3b38f7Smrg ;; 53257a3b38f7Smrg esac 53267a3b38f7Smrg done 53277a3b38f7Smrg ;; 53287a3b38f7Smrg prog) 53297a3b38f7Smrg compile_deplibs= 53307a3b38f7Smrg finalize_deplibs= 53317a3b38f7Smrg alldeplibs=no 53327a3b38f7Smrg newdlfiles= 53337a3b38f7Smrg newdlprefiles= 53347a3b38f7Smrg passes="conv scan dlopen dlpreopen link" 53357a3b38f7Smrg ;; 53367a3b38f7Smrg *) passes="conv" 53377a3b38f7Smrg ;; 53387a3b38f7Smrg esac 53397a3b38f7Smrg 53407a3b38f7Smrg for pass in $passes; do 53417a3b38f7Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 53427a3b38f7Smrg # so that -L comes before libs that need it for instance... 53437a3b38f7Smrg if test "$linkmode,$pass" = "lib,link"; then 53447a3b38f7Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 53457a3b38f7Smrg ## order, and fix it there properly 53467a3b38f7Smrg tmp_deplibs= 53477a3b38f7Smrg for deplib in $deplibs; do 53487a3b38f7Smrg tmp_deplibs="$deplib $tmp_deplibs" 53497a3b38f7Smrg done 53507a3b38f7Smrg deplibs="$tmp_deplibs" 53517a3b38f7Smrg fi 53527a3b38f7Smrg 53537a3b38f7Smrg if test "$linkmode,$pass" = "lib,link" || 53547a3b38f7Smrg test "$linkmode,$pass" = "prog,scan"; then 53557a3b38f7Smrg libs="$deplibs" 53567a3b38f7Smrg deplibs= 53577a3b38f7Smrg fi 53587a3b38f7Smrg if test "$linkmode" = prog; then 53597a3b38f7Smrg case $pass in 53607a3b38f7Smrg dlopen) libs="$dlfiles" ;; 53617a3b38f7Smrg dlpreopen) libs="$dlprefiles" ;; 53627a3b38f7Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 53637a3b38f7Smrg esac 53647a3b38f7Smrg fi 53657a3b38f7Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 53667a3b38f7Smrg # Collect and forward deplibs of preopened libtool libs 53677a3b38f7Smrg for lib in $dlprefiles; do 53687a3b38f7Smrg # Ignore non-libtool-libs 53697a3b38f7Smrg dependency_libs= 53707a3b38f7Smrg case $lib in 53717a3b38f7Smrg *.la) func_source "$lib" ;; 53727a3b38f7Smrg esac 53737a3b38f7Smrg 53747a3b38f7Smrg # Collect preopened libtool deplibs, except any this library 53757a3b38f7Smrg # has declared as weak libs 53767a3b38f7Smrg for deplib in $dependency_libs; do 537744dda7b2Smrg func_basename "$deplib" 537844dda7b2Smrg deplib_base=$func_basename_result 53797a3b38f7Smrg case " $weak_libs " in 53807a3b38f7Smrg *" $deplib_base "*) ;; 53817a3b38f7Smrg *) deplibs="$deplibs $deplib" ;; 53827a3b38f7Smrg esac 53837a3b38f7Smrg done 53847a3b38f7Smrg done 53857a3b38f7Smrg libs="$dlprefiles" 53867a3b38f7Smrg fi 53877a3b38f7Smrg if test "$pass" = dlopen; then 53887a3b38f7Smrg # Collect dlpreopened libraries 53897a3b38f7Smrg save_deplibs="$deplibs" 53907a3b38f7Smrg deplibs= 53917a3b38f7Smrg fi 53927a3b38f7Smrg 53937a3b38f7Smrg for deplib in $libs; do 53947a3b38f7Smrg lib= 53957a3b38f7Smrg found=no 53967a3b38f7Smrg case $deplib in 53977a3b38f7Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 53987a3b38f7Smrg if test "$linkmode,$pass" = "prog,link"; then 53997a3b38f7Smrg compile_deplibs="$deplib $compile_deplibs" 54007a3b38f7Smrg finalize_deplibs="$deplib $finalize_deplibs" 54017a3b38f7Smrg else 54027a3b38f7Smrg compiler_flags="$compiler_flags $deplib" 54037a3b38f7Smrg if test "$linkmode" = lib ; then 54047a3b38f7Smrg case "$new_inherited_linker_flags " in 54057a3b38f7Smrg *" $deplib "*) ;; 54067a3b38f7Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; 54077a3b38f7Smrg esac 54087a3b38f7Smrg fi 54097a3b38f7Smrg fi 54107a3b38f7Smrg continue 54117a3b38f7Smrg ;; 54127a3b38f7Smrg -l*) 54137a3b38f7Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 54147a3b38f7Smrg func_warning "\`-l' is ignored for archives/objects" 54157a3b38f7Smrg continue 54167a3b38f7Smrg fi 54177a3b38f7Smrg func_stripname '-l' '' "$deplib" 54187a3b38f7Smrg name=$func_stripname_result 54197a3b38f7Smrg if test "$linkmode" = lib; then 54207a3b38f7Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 54217a3b38f7Smrg else 54227a3b38f7Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 54237a3b38f7Smrg fi 54247a3b38f7Smrg for searchdir in $searchdirs; do 54257a3b38f7Smrg for search_ext in .la $std_shrext .so .a; do 54267a3b38f7Smrg # Search the libtool library 54277a3b38f7Smrg lib="$searchdir/lib${name}${search_ext}" 54287a3b38f7Smrg if test -f "$lib"; then 54297a3b38f7Smrg if test "$search_ext" = ".la"; then 54307a3b38f7Smrg found=yes 54317a3b38f7Smrg else 54327a3b38f7Smrg found=no 54337a3b38f7Smrg fi 54347a3b38f7Smrg break 2 54357a3b38f7Smrg fi 54367a3b38f7Smrg done 54377a3b38f7Smrg done 54387a3b38f7Smrg if test "$found" != yes; then 54397a3b38f7Smrg # deplib doesn't seem to be a libtool library 54407a3b38f7Smrg if test "$linkmode,$pass" = "prog,link"; then 54417a3b38f7Smrg compile_deplibs="$deplib $compile_deplibs" 54427a3b38f7Smrg finalize_deplibs="$deplib $finalize_deplibs" 54437a3b38f7Smrg else 54447a3b38f7Smrg deplibs="$deplib $deplibs" 54457a3b38f7Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 54467a3b38f7Smrg fi 54477a3b38f7Smrg continue 54487a3b38f7Smrg else # deplib is a libtool library 54497a3b38f7Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 54507a3b38f7Smrg # We need to do some special things here, and not later. 54517a3b38f7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 54527a3b38f7Smrg case " $predeps $postdeps " in 54537a3b38f7Smrg *" $deplib "*) 54547a3b38f7Smrg if func_lalib_p "$lib"; then 54557a3b38f7Smrg library_names= 54567a3b38f7Smrg old_library= 54577a3b38f7Smrg func_source "$lib" 54587a3b38f7Smrg for l in $old_library $library_names; do 54597a3b38f7Smrg ll="$l" 54607a3b38f7Smrg done 54617a3b38f7Smrg if test "X$ll" = "X$old_library" ; then # only static version available 54627a3b38f7Smrg found=no 54637a3b38f7Smrg func_dirname "$lib" "" "." 54647a3b38f7Smrg ladir="$func_dirname_result" 54657a3b38f7Smrg lib=$ladir/$old_library 54667a3b38f7Smrg if test "$linkmode,$pass" = "prog,link"; then 54677a3b38f7Smrg compile_deplibs="$deplib $compile_deplibs" 54687a3b38f7Smrg finalize_deplibs="$deplib $finalize_deplibs" 54697a3b38f7Smrg else 54707a3b38f7Smrg deplibs="$deplib $deplibs" 54717a3b38f7Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 54727a3b38f7Smrg fi 54737a3b38f7Smrg continue 54747a3b38f7Smrg fi 54757a3b38f7Smrg fi 54767a3b38f7Smrg ;; 54777a3b38f7Smrg *) ;; 54787a3b38f7Smrg esac 54797a3b38f7Smrg fi 54807a3b38f7Smrg fi 54817a3b38f7Smrg ;; # -l 54827a3b38f7Smrg *.ltframework) 54837a3b38f7Smrg if test "$linkmode,$pass" = "prog,link"; then 54847a3b38f7Smrg compile_deplibs="$deplib $compile_deplibs" 54857a3b38f7Smrg finalize_deplibs="$deplib $finalize_deplibs" 54867a3b38f7Smrg else 54877a3b38f7Smrg deplibs="$deplib $deplibs" 54887a3b38f7Smrg if test "$linkmode" = lib ; then 54897a3b38f7Smrg case "$new_inherited_linker_flags " in 54907a3b38f7Smrg *" $deplib "*) ;; 54917a3b38f7Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; 54927a3b38f7Smrg esac 54937a3b38f7Smrg fi 54947a3b38f7Smrg fi 54957a3b38f7Smrg continue 54967a3b38f7Smrg ;; 54977a3b38f7Smrg -L*) 54987a3b38f7Smrg case $linkmode in 54997a3b38f7Smrg lib) 55007a3b38f7Smrg deplibs="$deplib $deplibs" 55017a3b38f7Smrg test "$pass" = conv && continue 55027a3b38f7Smrg newdependency_libs="$deplib $newdependency_libs" 55037a3b38f7Smrg func_stripname '-L' '' "$deplib" 55047a3b38f7Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 55057a3b38f7Smrg ;; 55067a3b38f7Smrg prog) 55077a3b38f7Smrg if test "$pass" = conv; then 55087a3b38f7Smrg deplibs="$deplib $deplibs" 55097a3b38f7Smrg continue 55107a3b38f7Smrg fi 55117a3b38f7Smrg if test "$pass" = scan; then 55127a3b38f7Smrg deplibs="$deplib $deplibs" 55137a3b38f7Smrg else 55147a3b38f7Smrg compile_deplibs="$deplib $compile_deplibs" 55157a3b38f7Smrg finalize_deplibs="$deplib $finalize_deplibs" 55167a3b38f7Smrg fi 55177a3b38f7Smrg func_stripname '-L' '' "$deplib" 55187a3b38f7Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 55197a3b38f7Smrg ;; 55207a3b38f7Smrg *) 55217a3b38f7Smrg func_warning "\`-L' is ignored for archives/objects" 55227a3b38f7Smrg ;; 55237a3b38f7Smrg esac # linkmode 55247a3b38f7Smrg continue 55257a3b38f7Smrg ;; # -L 55267a3b38f7Smrg -R*) 55277a3b38f7Smrg if test "$pass" = link; then 55287a3b38f7Smrg func_stripname '-R' '' "$deplib" 55297a3b38f7Smrg dir=$func_stripname_result 55307a3b38f7Smrg # Make sure the xrpath contains only unique directories. 55317a3b38f7Smrg case "$xrpath " in 55327a3b38f7Smrg *" $dir "*) ;; 55337a3b38f7Smrg *) xrpath="$xrpath $dir" ;; 55347a3b38f7Smrg esac 55357a3b38f7Smrg fi 55367a3b38f7Smrg deplibs="$deplib $deplibs" 55377a3b38f7Smrg continue 55387a3b38f7Smrg ;; 55397a3b38f7Smrg *.la) lib="$deplib" ;; 55407a3b38f7Smrg *.$libext) 55417a3b38f7Smrg if test "$pass" = conv; then 55427a3b38f7Smrg deplibs="$deplib $deplibs" 55437a3b38f7Smrg continue 55447a3b38f7Smrg fi 55457a3b38f7Smrg case $linkmode in 55467a3b38f7Smrg lib) 55477a3b38f7Smrg # Linking convenience modules into shared libraries is allowed, 55487a3b38f7Smrg # but linking other static libraries is non-portable. 55497a3b38f7Smrg case " $dlpreconveniencelibs " in 55507a3b38f7Smrg *" $deplib "*) ;; 55517a3b38f7Smrg *) 55527a3b38f7Smrg valid_a_lib=no 55537a3b38f7Smrg case $deplibs_check_method in 55547a3b38f7Smrg match_pattern*) 55557a3b38f7Smrg set dummy $deplibs_check_method; shift 55567a3b38f7Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 555744dda7b2Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 55587a3b38f7Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 55597a3b38f7Smrg valid_a_lib=yes 55607a3b38f7Smrg fi 55617a3b38f7Smrg ;; 55627a3b38f7Smrg pass_all) 55637a3b38f7Smrg valid_a_lib=yes 55647a3b38f7Smrg ;; 55657a3b38f7Smrg esac 55667a3b38f7Smrg if test "$valid_a_lib" != yes; then 556744dda7b2Smrg echo 55687a3b38f7Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 556944dda7b2Smrg echo "*** I have the capability to make that library automatically link in when" 557044dda7b2Smrg echo "*** you link to this library. But I can only do this if you have a" 557144dda7b2Smrg echo "*** shared version of the library, which you do not appear to have" 557244dda7b2Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 557344dda7b2Smrg echo "*** that it is just a static archive that I should not use here." 55747a3b38f7Smrg else 557544dda7b2Smrg echo 55767a3b38f7Smrg $ECHO "*** Warning: Linking the shared library $output against the" 55777a3b38f7Smrg $ECHO "*** static library $deplib is not portable!" 55787a3b38f7Smrg deplibs="$deplib $deplibs" 55797a3b38f7Smrg fi 55807a3b38f7Smrg ;; 55817a3b38f7Smrg esac 55827a3b38f7Smrg continue 55837a3b38f7Smrg ;; 55847a3b38f7Smrg prog) 55857a3b38f7Smrg if test "$pass" != link; then 55867a3b38f7Smrg deplibs="$deplib $deplibs" 55877a3b38f7Smrg else 55887a3b38f7Smrg compile_deplibs="$deplib $compile_deplibs" 55897a3b38f7Smrg finalize_deplibs="$deplib $finalize_deplibs" 55907a3b38f7Smrg fi 55917a3b38f7Smrg continue 55927a3b38f7Smrg ;; 55937a3b38f7Smrg esac # linkmode 55947a3b38f7Smrg ;; # *.$libext 55957a3b38f7Smrg *.lo | *.$objext) 55967a3b38f7Smrg if test "$pass" = conv; then 55977a3b38f7Smrg deplibs="$deplib $deplibs" 55987a3b38f7Smrg elif test "$linkmode" = prog; then 55997a3b38f7Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 56007a3b38f7Smrg # If there is no dlopen support or we're linking statically, 56017a3b38f7Smrg # we need to preload. 56027a3b38f7Smrg newdlprefiles="$newdlprefiles $deplib" 56037a3b38f7Smrg compile_deplibs="$deplib $compile_deplibs" 56047a3b38f7Smrg finalize_deplibs="$deplib $finalize_deplibs" 56057a3b38f7Smrg else 56067a3b38f7Smrg newdlfiles="$newdlfiles $deplib" 56077a3b38f7Smrg fi 56087a3b38f7Smrg fi 56097a3b38f7Smrg continue 56107a3b38f7Smrg ;; 56117a3b38f7Smrg %DEPLIBS%) 56127a3b38f7Smrg alldeplibs=yes 56137a3b38f7Smrg continue 56147a3b38f7Smrg ;; 56157a3b38f7Smrg esac # case $deplib 56167a3b38f7Smrg 56177a3b38f7Smrg if test "$found" = yes || test -f "$lib"; then : 56187a3b38f7Smrg else 56197a3b38f7Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 56207a3b38f7Smrg fi 56217a3b38f7Smrg 56227a3b38f7Smrg # Check to see that this really is a libtool archive. 56237a3b38f7Smrg func_lalib_unsafe_p "$lib" \ 56247a3b38f7Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 56257a3b38f7Smrg 56267a3b38f7Smrg func_dirname "$lib" "" "." 56277a3b38f7Smrg ladir="$func_dirname_result" 56287a3b38f7Smrg 56297a3b38f7Smrg dlname= 56307a3b38f7Smrg dlopen= 56317a3b38f7Smrg dlpreopen= 56327a3b38f7Smrg libdir= 56337a3b38f7Smrg library_names= 56347a3b38f7Smrg old_library= 56357a3b38f7Smrg inherited_linker_flags= 56367a3b38f7Smrg # If the library was installed with an old release of libtool, 56377a3b38f7Smrg # it will not redefine variables installed, or shouldnotlink 56387a3b38f7Smrg installed=yes 56397a3b38f7Smrg shouldnotlink=no 56407a3b38f7Smrg avoidtemprpath= 56417a3b38f7Smrg 56427a3b38f7Smrg 56437a3b38f7Smrg # Read the .la file 56447a3b38f7Smrg func_source "$lib" 56457a3b38f7Smrg 56467a3b38f7Smrg # Convert "-framework foo" to "foo.ltframework" 56477a3b38f7Smrg if test -n "$inherited_linker_flags"; then 564844dda7b2Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 56497a3b38f7Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 56507a3b38f7Smrg case " $new_inherited_linker_flags " in 56517a3b38f7Smrg *" $tmp_inherited_linker_flag "*) ;; 56527a3b38f7Smrg *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; 56537a3b38f7Smrg esac 56547a3b38f7Smrg done 56557a3b38f7Smrg fi 565644dda7b2Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 56577a3b38f7Smrg if test "$linkmode,$pass" = "lib,link" || 56587a3b38f7Smrg test "$linkmode,$pass" = "prog,scan" || 56597a3b38f7Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 56607a3b38f7Smrg test -n "$dlopen" && dlfiles="$dlfiles $dlopen" 56617a3b38f7Smrg test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" 56627a3b38f7Smrg fi 56637a3b38f7Smrg 56647a3b38f7Smrg if test "$pass" = conv; then 56657a3b38f7Smrg # Only check for convenience libraries 56667a3b38f7Smrg deplibs="$lib $deplibs" 56677a3b38f7Smrg if test -z "$libdir"; then 56687a3b38f7Smrg if test -z "$old_library"; then 56697a3b38f7Smrg func_fatal_error "cannot find name of link library for \`$lib'" 56707a3b38f7Smrg fi 56717a3b38f7Smrg # It is a libtool convenience library, so add in its objects. 56727a3b38f7Smrg convenience="$convenience $ladir/$objdir/$old_library" 56737a3b38f7Smrg old_convenience="$old_convenience $ladir/$objdir/$old_library" 56747a3b38f7Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 56757a3b38f7Smrg func_fatal_error "\`$lib' is not a convenience library" 56767a3b38f7Smrg fi 56777a3b38f7Smrg tmp_libs= 56787a3b38f7Smrg for deplib in $dependency_libs; do 56797a3b38f7Smrg deplibs="$deplib $deplibs" 56807a3b38f7Smrg if $opt_duplicate_deps ; then 56817a3b38f7Smrg case "$tmp_libs " in 56827a3b38f7Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 56837a3b38f7Smrg esac 56847a3b38f7Smrg fi 56857a3b38f7Smrg tmp_libs="$tmp_libs $deplib" 56867a3b38f7Smrg done 56877a3b38f7Smrg continue 56887a3b38f7Smrg fi # $pass = conv 56897a3b38f7Smrg 56907a3b38f7Smrg 56917a3b38f7Smrg # Get the name of the library we link against. 56927a3b38f7Smrg linklib= 56937a3b38f7Smrg for l in $old_library $library_names; do 56947a3b38f7Smrg linklib="$l" 56957a3b38f7Smrg done 56967a3b38f7Smrg if test -z "$linklib"; then 56977a3b38f7Smrg func_fatal_error "cannot find name of link library for \`$lib'" 56987a3b38f7Smrg fi 56997a3b38f7Smrg 57007a3b38f7Smrg # This library was specified with -dlopen. 57017a3b38f7Smrg if test "$pass" = dlopen; then 57027a3b38f7Smrg if test -z "$libdir"; then 57037a3b38f7Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 57047a3b38f7Smrg fi 57057a3b38f7Smrg if test -z "$dlname" || 57067a3b38f7Smrg test "$dlopen_support" != yes || 57077a3b38f7Smrg test "$build_libtool_libs" = no; then 57087a3b38f7Smrg # If there is no dlname, no dlopen support or we're linking 57097a3b38f7Smrg # statically, we need to preload. We also need to preload any 57107a3b38f7Smrg # dependent libraries so libltdl's deplib preloader doesn't 57117a3b38f7Smrg # bomb out in the load deplibs phase. 57127a3b38f7Smrg dlprefiles="$dlprefiles $lib $dependency_libs" 57137a3b38f7Smrg else 57147a3b38f7Smrg newdlfiles="$newdlfiles $lib" 57157a3b38f7Smrg fi 57167a3b38f7Smrg continue 57177a3b38f7Smrg fi # $pass = dlopen 57187a3b38f7Smrg 57197a3b38f7Smrg # We need an absolute path. 57207a3b38f7Smrg case $ladir in 57217a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 57227a3b38f7Smrg *) 57237a3b38f7Smrg abs_ladir=`cd "$ladir" && pwd` 57247a3b38f7Smrg if test -z "$abs_ladir"; then 57257a3b38f7Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 57267a3b38f7Smrg func_warning "passing it literally to the linker, although it might fail" 57277a3b38f7Smrg abs_ladir="$ladir" 57287a3b38f7Smrg fi 57297a3b38f7Smrg ;; 57307a3b38f7Smrg esac 57317a3b38f7Smrg func_basename "$lib" 57327a3b38f7Smrg laname="$func_basename_result" 57337a3b38f7Smrg 57347a3b38f7Smrg # Find the relevant object directory and library name. 57357a3b38f7Smrg if test "X$installed" = Xyes; then 57367a3b38f7Smrg if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 57377a3b38f7Smrg func_warning "library \`$lib' was moved." 57387a3b38f7Smrg dir="$ladir" 57397a3b38f7Smrg absdir="$abs_ladir" 57407a3b38f7Smrg libdir="$abs_ladir" 57417a3b38f7Smrg else 57427a3b38f7Smrg dir="$libdir" 57437a3b38f7Smrg absdir="$libdir" 57447a3b38f7Smrg fi 57457a3b38f7Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 57467a3b38f7Smrg else 57477a3b38f7Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 57487a3b38f7Smrg dir="$ladir" 57497a3b38f7Smrg absdir="$abs_ladir" 57507a3b38f7Smrg # Remove this search path later 57517a3b38f7Smrg notinst_path="$notinst_path $abs_ladir" 57527a3b38f7Smrg else 57537a3b38f7Smrg dir="$ladir/$objdir" 57547a3b38f7Smrg absdir="$abs_ladir/$objdir" 57557a3b38f7Smrg # Remove this search path later 57567a3b38f7Smrg notinst_path="$notinst_path $abs_ladir" 57577a3b38f7Smrg fi 57587a3b38f7Smrg fi # $installed = yes 57597a3b38f7Smrg func_stripname 'lib' '.la' "$laname" 57607a3b38f7Smrg name=$func_stripname_result 57617a3b38f7Smrg 57627a3b38f7Smrg # This library was specified with -dlpreopen. 57637a3b38f7Smrg if test "$pass" = dlpreopen; then 57647a3b38f7Smrg if test -z "$libdir" && test "$linkmode" = prog; then 57657a3b38f7Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 57667a3b38f7Smrg fi 57677a3b38f7Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 57687a3b38f7Smrg # are required to link). 57697a3b38f7Smrg if test -n "$old_library"; then 57707a3b38f7Smrg newdlprefiles="$newdlprefiles $dir/$old_library" 57717a3b38f7Smrg # Keep a list of preopened convenience libraries to check 57727a3b38f7Smrg # that they are being used correctly in the link pass. 57737a3b38f7Smrg test -z "$libdir" && \ 57747a3b38f7Smrg dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" 57757a3b38f7Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 57767a3b38f7Smrg elif test -n "$dlname"; then 57777a3b38f7Smrg newdlprefiles="$newdlprefiles $dir/$dlname" 57787a3b38f7Smrg else 57797a3b38f7Smrg newdlprefiles="$newdlprefiles $dir/$linklib" 57807a3b38f7Smrg fi 57817a3b38f7Smrg fi # $pass = dlpreopen 57827a3b38f7Smrg 57837a3b38f7Smrg if test -z "$libdir"; then 57847a3b38f7Smrg # Link the convenience library 57857a3b38f7Smrg if test "$linkmode" = lib; then 57867a3b38f7Smrg deplibs="$dir/$old_library $deplibs" 57877a3b38f7Smrg elif test "$linkmode,$pass" = "prog,link"; then 57887a3b38f7Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 57897a3b38f7Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 57907a3b38f7Smrg else 57917a3b38f7Smrg deplibs="$lib $deplibs" # used for prog,scan pass 57927a3b38f7Smrg fi 57937a3b38f7Smrg continue 57947a3b38f7Smrg fi 57957a3b38f7Smrg 57967a3b38f7Smrg 57977a3b38f7Smrg if test "$linkmode" = prog && test "$pass" != link; then 57987a3b38f7Smrg newlib_search_path="$newlib_search_path $ladir" 57997a3b38f7Smrg deplibs="$lib $deplibs" 58007a3b38f7Smrg 58017a3b38f7Smrg linkalldeplibs=no 58027a3b38f7Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 58037a3b38f7Smrg test "$build_libtool_libs" = no; then 58047a3b38f7Smrg linkalldeplibs=yes 58057a3b38f7Smrg fi 58067a3b38f7Smrg 58077a3b38f7Smrg tmp_libs= 58087a3b38f7Smrg for deplib in $dependency_libs; do 58097a3b38f7Smrg case $deplib in 58107a3b38f7Smrg -L*) func_stripname '-L' '' "$deplib" 58117a3b38f7Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 58127a3b38f7Smrg ;; 58137a3b38f7Smrg esac 58147a3b38f7Smrg # Need to link against all dependency_libs? 58157a3b38f7Smrg if test "$linkalldeplibs" = yes; then 58167a3b38f7Smrg deplibs="$deplib $deplibs" 58177a3b38f7Smrg else 58187a3b38f7Smrg # Need to hardcode shared library paths 58197a3b38f7Smrg # or/and link against static libraries 58207a3b38f7Smrg newdependency_libs="$deplib $newdependency_libs" 58217a3b38f7Smrg fi 58227a3b38f7Smrg if $opt_duplicate_deps ; then 58237a3b38f7Smrg case "$tmp_libs " in 58247a3b38f7Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 58257a3b38f7Smrg esac 58267a3b38f7Smrg fi 58277a3b38f7Smrg tmp_libs="$tmp_libs $deplib" 58287a3b38f7Smrg done # for deplib 58297a3b38f7Smrg continue 58307a3b38f7Smrg fi # $linkmode = prog... 58317a3b38f7Smrg 58327a3b38f7Smrg if test "$linkmode,$pass" = "prog,link"; then 58337a3b38f7Smrg if test -n "$library_names" && 58347a3b38f7Smrg { { test "$prefer_static_libs" = no || 58357a3b38f7Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 58367a3b38f7Smrg test -z "$old_library"; }; then 58377a3b38f7Smrg # We need to hardcode the library path 58387a3b38f7Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 58397a3b38f7Smrg # Make sure the rpath contains only unique directories. 58407a3b38f7Smrg case "$temp_rpath:" in 58417a3b38f7Smrg *"$absdir:"*) ;; 58427a3b38f7Smrg *) temp_rpath="$temp_rpath$absdir:" ;; 58437a3b38f7Smrg esac 58447a3b38f7Smrg fi 58457a3b38f7Smrg 58467a3b38f7Smrg # Hardcode the library path. 58477a3b38f7Smrg # Skip directories that are in the system default run-time 58487a3b38f7Smrg # search path. 58497a3b38f7Smrg case " $sys_lib_dlsearch_path " in 58507a3b38f7Smrg *" $absdir "*) ;; 58517a3b38f7Smrg *) 58527a3b38f7Smrg case "$compile_rpath " in 58537a3b38f7Smrg *" $absdir "*) ;; 58547a3b38f7Smrg *) compile_rpath="$compile_rpath $absdir" 58557a3b38f7Smrg esac 58567a3b38f7Smrg ;; 58577a3b38f7Smrg esac 58587a3b38f7Smrg case " $sys_lib_dlsearch_path " in 58597a3b38f7Smrg *" $libdir "*) ;; 58607a3b38f7Smrg *) 58617a3b38f7Smrg case "$finalize_rpath " in 58627a3b38f7Smrg *" $libdir "*) ;; 58637a3b38f7Smrg *) finalize_rpath="$finalize_rpath $libdir" 58647a3b38f7Smrg esac 58657a3b38f7Smrg ;; 58667a3b38f7Smrg esac 58677a3b38f7Smrg fi # $linkmode,$pass = prog,link... 58687a3b38f7Smrg 58697a3b38f7Smrg if test "$alldeplibs" = yes && 58707a3b38f7Smrg { test "$deplibs_check_method" = pass_all || 58717a3b38f7Smrg { test "$build_libtool_libs" = yes && 58727a3b38f7Smrg test -n "$library_names"; }; }; then 58737a3b38f7Smrg # We only need to search for static libraries 58747a3b38f7Smrg continue 58757a3b38f7Smrg fi 58767a3b38f7Smrg fi 58777a3b38f7Smrg 58787a3b38f7Smrg link_static=no # Whether the deplib will be linked statically 58797a3b38f7Smrg use_static_libs=$prefer_static_libs 58807a3b38f7Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 58817a3b38f7Smrg use_static_libs=no 58827a3b38f7Smrg fi 58837a3b38f7Smrg if test -n "$library_names" && 58847a3b38f7Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 58857a3b38f7Smrg case $host in 58867a3b38f7Smrg *cygwin* | *mingw* | *cegcc*) 58877a3b38f7Smrg # No point in relinking DLLs because paths are not encoded 58887a3b38f7Smrg notinst_deplibs="$notinst_deplibs $lib" 58897a3b38f7Smrg need_relink=no 58907a3b38f7Smrg ;; 58917a3b38f7Smrg *) 58927a3b38f7Smrg if test "$installed" = no; then 58937a3b38f7Smrg notinst_deplibs="$notinst_deplibs $lib" 58947a3b38f7Smrg need_relink=yes 58957a3b38f7Smrg fi 58967a3b38f7Smrg ;; 58977a3b38f7Smrg esac 58987a3b38f7Smrg # This is a shared library 58997a3b38f7Smrg 59007a3b38f7Smrg # Warn about portability, can't link against -module's on some 59017a3b38f7Smrg # systems (darwin). Don't bleat about dlopened modules though! 59027a3b38f7Smrg dlopenmodule="" 59037a3b38f7Smrg for dlpremoduletest in $dlprefiles; do 59047a3b38f7Smrg if test "X$dlpremoduletest" = "X$lib"; then 59057a3b38f7Smrg dlopenmodule="$dlpremoduletest" 59067a3b38f7Smrg break 59077a3b38f7Smrg fi 59087a3b38f7Smrg done 59097a3b38f7Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 591044dda7b2Smrg echo 59117a3b38f7Smrg if test "$linkmode" = prog; then 59127a3b38f7Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 59137a3b38f7Smrg else 59147a3b38f7Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 59157a3b38f7Smrg fi 59167a3b38f7Smrg $ECHO "*** $linklib is not portable!" 59177a3b38f7Smrg fi 59187a3b38f7Smrg if test "$linkmode" = lib && 59197a3b38f7Smrg test "$hardcode_into_libs" = yes; then 59207a3b38f7Smrg # Hardcode the library path. 59217a3b38f7Smrg # Skip directories that are in the system default run-time 59227a3b38f7Smrg # search path. 59237a3b38f7Smrg case " $sys_lib_dlsearch_path " in 59247a3b38f7Smrg *" $absdir "*) ;; 59257a3b38f7Smrg *) 59267a3b38f7Smrg case "$compile_rpath " in 59277a3b38f7Smrg *" $absdir "*) ;; 59287a3b38f7Smrg *) compile_rpath="$compile_rpath $absdir" 59297a3b38f7Smrg esac 59307a3b38f7Smrg ;; 59317a3b38f7Smrg esac 59327a3b38f7Smrg case " $sys_lib_dlsearch_path " in 59337a3b38f7Smrg *" $libdir "*) ;; 59347a3b38f7Smrg *) 59357a3b38f7Smrg case "$finalize_rpath " in 59367a3b38f7Smrg *" $libdir "*) ;; 59377a3b38f7Smrg *) finalize_rpath="$finalize_rpath $libdir" 59387a3b38f7Smrg esac 59397a3b38f7Smrg ;; 59407a3b38f7Smrg esac 59417a3b38f7Smrg fi 59427a3b38f7Smrg 59437a3b38f7Smrg if test -n "$old_archive_from_expsyms_cmds"; then 59447a3b38f7Smrg # figure out the soname 59457a3b38f7Smrg set dummy $library_names 59467a3b38f7Smrg shift 59477a3b38f7Smrg realname="$1" 59487a3b38f7Smrg shift 59497a3b38f7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 59507a3b38f7Smrg # use dlname if we got it. it's perfectly good, no? 59517a3b38f7Smrg if test -n "$dlname"; then 59527a3b38f7Smrg soname="$dlname" 59537a3b38f7Smrg elif test -n "$soname_spec"; then 59547a3b38f7Smrg # bleh windows 59557a3b38f7Smrg case $host in 59567a3b38f7Smrg *cygwin* | mingw* | *cegcc*) 59577a3b38f7Smrg func_arith $current - $age 59587a3b38f7Smrg major=$func_arith_result 59597a3b38f7Smrg versuffix="-$major" 59607a3b38f7Smrg ;; 59617a3b38f7Smrg esac 59627a3b38f7Smrg eval soname=\"$soname_spec\" 59637a3b38f7Smrg else 59647a3b38f7Smrg soname="$realname" 59657a3b38f7Smrg fi 59667a3b38f7Smrg 59677a3b38f7Smrg # Make a new name for the extract_expsyms_cmds to use 59687a3b38f7Smrg soroot="$soname" 59697a3b38f7Smrg func_basename "$soroot" 59707a3b38f7Smrg soname="$func_basename_result" 59717a3b38f7Smrg func_stripname 'lib' '.dll' "$soname" 59727a3b38f7Smrg newlib=libimp-$func_stripname_result.a 59737a3b38f7Smrg 59747a3b38f7Smrg # If the library has no export list, then create one now 59757a3b38f7Smrg if test -f "$output_objdir/$soname-def"; then : 59767a3b38f7Smrg else 59777a3b38f7Smrg func_verbose "extracting exported symbol list from \`$soname'" 59787a3b38f7Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 59797a3b38f7Smrg fi 59807a3b38f7Smrg 59817a3b38f7Smrg # Create $newlib 59827a3b38f7Smrg if test -f "$output_objdir/$newlib"; then :; else 59837a3b38f7Smrg func_verbose "generating import library for \`$soname'" 59847a3b38f7Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 59857a3b38f7Smrg fi 59867a3b38f7Smrg # make sure the library variables are pointing to the new library 59877a3b38f7Smrg dir=$output_objdir 59887a3b38f7Smrg linklib=$newlib 59897a3b38f7Smrg fi # test -n "$old_archive_from_expsyms_cmds" 59907a3b38f7Smrg 59917a3b38f7Smrg if test "$linkmode" = prog || test "$mode" != relink; then 59927a3b38f7Smrg add_shlibpath= 59937a3b38f7Smrg add_dir= 59947a3b38f7Smrg add= 59957a3b38f7Smrg lib_linked=yes 59967a3b38f7Smrg case $hardcode_action in 59977a3b38f7Smrg immediate | unsupported) 59987a3b38f7Smrg if test "$hardcode_direct" = no; then 59997a3b38f7Smrg add="$dir/$linklib" 60007a3b38f7Smrg case $host in 60017a3b38f7Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 60027a3b38f7Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 60037a3b38f7Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 60047a3b38f7Smrg *-*-unixware7*) add_dir="-L$dir" ;; 60057a3b38f7Smrg *-*-darwin* ) 60067a3b38f7Smrg # if the lib is a (non-dlopened) module then we can not 60077a3b38f7Smrg # link against it, someone is ignoring the earlier warnings 60087a3b38f7Smrg if /usr/bin/file -L $add 2> /dev/null | 60097a3b38f7Smrg $GREP ": [^:]* bundle" >/dev/null ; then 60107a3b38f7Smrg if test "X$dlopenmodule" != "X$lib"; then 60117a3b38f7Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 60127a3b38f7Smrg if test -z "$old_library" ; then 601344dda7b2Smrg echo 601444dda7b2Smrg echo "*** And there doesn't seem to be a static archive available" 601544dda7b2Smrg echo "*** The link will probably fail, sorry" 60167a3b38f7Smrg else 60177a3b38f7Smrg add="$dir/$old_library" 60187a3b38f7Smrg fi 60197a3b38f7Smrg elif test -n "$old_library"; then 60207a3b38f7Smrg add="$dir/$old_library" 60217a3b38f7Smrg fi 60227a3b38f7Smrg fi 60237a3b38f7Smrg esac 60247a3b38f7Smrg elif test "$hardcode_minus_L" = no; then 60257a3b38f7Smrg case $host in 60267a3b38f7Smrg *-*-sunos*) add_shlibpath="$dir" ;; 60277a3b38f7Smrg esac 60287a3b38f7Smrg add_dir="-L$dir" 60297a3b38f7Smrg add="-l$name" 60307a3b38f7Smrg elif test "$hardcode_shlibpath_var" = no; then 60317a3b38f7Smrg add_shlibpath="$dir" 60327a3b38f7Smrg add="-l$name" 60337a3b38f7Smrg else 60347a3b38f7Smrg lib_linked=no 60357a3b38f7Smrg fi 60367a3b38f7Smrg ;; 60377a3b38f7Smrg relink) 60387a3b38f7Smrg if test "$hardcode_direct" = yes && 60397a3b38f7Smrg test "$hardcode_direct_absolute" = no; then 60407a3b38f7Smrg add="$dir/$linklib" 60417a3b38f7Smrg elif test "$hardcode_minus_L" = yes; then 60427a3b38f7Smrg add_dir="-L$dir" 60437a3b38f7Smrg # Try looking first in the location we're being installed to. 60447a3b38f7Smrg if test -n "$inst_prefix_dir"; then 60457a3b38f7Smrg case $libdir in 60467a3b38f7Smrg [\\/]*) 60477a3b38f7Smrg add_dir="$add_dir -L$inst_prefix_dir$libdir" 60487a3b38f7Smrg ;; 60497a3b38f7Smrg esac 60507a3b38f7Smrg fi 60517a3b38f7Smrg add="-l$name" 60527a3b38f7Smrg elif test "$hardcode_shlibpath_var" = yes; then 60537a3b38f7Smrg add_shlibpath="$dir" 60547a3b38f7Smrg add="-l$name" 60557a3b38f7Smrg else 60567a3b38f7Smrg lib_linked=no 60577a3b38f7Smrg fi 60587a3b38f7Smrg ;; 60597a3b38f7Smrg *) lib_linked=no ;; 60607a3b38f7Smrg esac 60617a3b38f7Smrg 60627a3b38f7Smrg if test "$lib_linked" != yes; then 60637a3b38f7Smrg func_fatal_configuration "unsupported hardcode properties" 60647a3b38f7Smrg fi 60657a3b38f7Smrg 60667a3b38f7Smrg if test -n "$add_shlibpath"; then 60677a3b38f7Smrg case :$compile_shlibpath: in 60687a3b38f7Smrg *":$add_shlibpath:"*) ;; 60697a3b38f7Smrg *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; 60707a3b38f7Smrg esac 60717a3b38f7Smrg fi 60727a3b38f7Smrg if test "$linkmode" = prog; then 60737a3b38f7Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 60747a3b38f7Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 60757a3b38f7Smrg else 60767a3b38f7Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 60777a3b38f7Smrg test -n "$add" && deplibs="$add $deplibs" 60787a3b38f7Smrg if test "$hardcode_direct" != yes && 60797a3b38f7Smrg test "$hardcode_minus_L" != yes && 60807a3b38f7Smrg test "$hardcode_shlibpath_var" = yes; then 60817a3b38f7Smrg case :$finalize_shlibpath: in 60827a3b38f7Smrg *":$libdir:"*) ;; 60837a3b38f7Smrg *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; 60847a3b38f7Smrg esac 60857a3b38f7Smrg fi 60867a3b38f7Smrg fi 60877a3b38f7Smrg fi 60887a3b38f7Smrg 60897a3b38f7Smrg if test "$linkmode" = prog || test "$mode" = relink; then 60907a3b38f7Smrg add_shlibpath= 60917a3b38f7Smrg add_dir= 60927a3b38f7Smrg add= 60937a3b38f7Smrg # Finalize command for both is simple: just hardcode it. 60947a3b38f7Smrg if test "$hardcode_direct" = yes && 60957a3b38f7Smrg test "$hardcode_direct_absolute" = no; then 60967a3b38f7Smrg add="$libdir/$linklib" 60977a3b38f7Smrg elif test "$hardcode_minus_L" = yes; then 60987a3b38f7Smrg add_dir="-L$libdir" 60997a3b38f7Smrg add="-l$name" 61007a3b38f7Smrg elif test "$hardcode_shlibpath_var" = yes; then 61017a3b38f7Smrg case :$finalize_shlibpath: in 61027a3b38f7Smrg *":$libdir:"*) ;; 61037a3b38f7Smrg *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; 61047a3b38f7Smrg esac 61057a3b38f7Smrg add="-l$name" 61067a3b38f7Smrg elif test "$hardcode_automatic" = yes; then 61077a3b38f7Smrg if test -n "$inst_prefix_dir" && 61087a3b38f7Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 61097a3b38f7Smrg add="$inst_prefix_dir$libdir/$linklib" 61107a3b38f7Smrg else 61117a3b38f7Smrg add="$libdir/$linklib" 61127a3b38f7Smrg fi 61137a3b38f7Smrg else 61147a3b38f7Smrg # We cannot seem to hardcode it, guess we'll fake it. 61157a3b38f7Smrg add_dir="-L$libdir" 61167a3b38f7Smrg # Try looking first in the location we're being installed to. 61177a3b38f7Smrg if test -n "$inst_prefix_dir"; then 61187a3b38f7Smrg case $libdir in 61197a3b38f7Smrg [\\/]*) 61207a3b38f7Smrg add_dir="$add_dir -L$inst_prefix_dir$libdir" 61217a3b38f7Smrg ;; 61227a3b38f7Smrg esac 61237a3b38f7Smrg fi 61247a3b38f7Smrg add="-l$name" 61257a3b38f7Smrg fi 61267a3b38f7Smrg 61277a3b38f7Smrg if test "$linkmode" = prog; then 61287a3b38f7Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 61297a3b38f7Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 61307a3b38f7Smrg else 61317a3b38f7Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 61327a3b38f7Smrg test -n "$add" && deplibs="$add $deplibs" 61337a3b38f7Smrg fi 61347a3b38f7Smrg fi 61357a3b38f7Smrg elif test "$linkmode" = prog; then 61367a3b38f7Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 61377a3b38f7Smrg # is not unsupported. This is valid on all known static and 61387a3b38f7Smrg # shared platforms. 61397a3b38f7Smrg if test "$hardcode_direct" != unsupported; then 61407a3b38f7Smrg test -n "$old_library" && linklib="$old_library" 61417a3b38f7Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 61427a3b38f7Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 61437a3b38f7Smrg else 61447a3b38f7Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 61457a3b38f7Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 61467a3b38f7Smrg fi 61477a3b38f7Smrg elif test "$build_libtool_libs" = yes; then 61487a3b38f7Smrg # Not a shared library 61497a3b38f7Smrg if test "$deplibs_check_method" != pass_all; then 61507a3b38f7Smrg # We're trying link a shared library against a static one 61517a3b38f7Smrg # but the system doesn't support it. 61527a3b38f7Smrg 61537a3b38f7Smrg # Just print a warning and add the library to dependency_libs so 61547a3b38f7Smrg # that the program can be linked against the static library. 615544dda7b2Smrg echo 61567a3b38f7Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 615744dda7b2Smrg echo "*** I have the capability to make that library automatically link in when" 615844dda7b2Smrg echo "*** you link to this library. But I can only do this if you have a" 615944dda7b2Smrg echo "*** shared version of the library, which you do not appear to have." 61607a3b38f7Smrg if test "$module" = yes; then 616144dda7b2Smrg echo "*** But as you try to build a module library, libtool will still create " 616244dda7b2Smrg echo "*** a static module, that should work as long as the dlopening application" 616344dda7b2Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 61647a3b38f7Smrg if test -z "$global_symbol_pipe"; then 616544dda7b2Smrg echo 616644dda7b2Smrg echo "*** However, this would only work if libtool was able to extract symbol" 616744dda7b2Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 616844dda7b2Smrg echo "*** not find such a program. So, this module is probably useless." 616944dda7b2Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 61707a3b38f7Smrg fi 61717a3b38f7Smrg if test "$build_old_libs" = no; then 61727a3b38f7Smrg build_libtool_libs=module 61737a3b38f7Smrg build_old_libs=yes 61747a3b38f7Smrg else 61757a3b38f7Smrg build_libtool_libs=no 61767a3b38f7Smrg fi 61777a3b38f7Smrg fi 61787a3b38f7Smrg else 61797a3b38f7Smrg deplibs="$dir/$old_library $deplibs" 61807a3b38f7Smrg link_static=yes 61817a3b38f7Smrg fi 61827a3b38f7Smrg fi # link shared/static library? 61837a3b38f7Smrg 61847a3b38f7Smrg if test "$linkmode" = lib; then 61857a3b38f7Smrg if test -n "$dependency_libs" && 61867a3b38f7Smrg { test "$hardcode_into_libs" != yes || 61877a3b38f7Smrg test "$build_old_libs" = yes || 61887a3b38f7Smrg test "$link_static" = yes; }; then 61897a3b38f7Smrg # Extract -R from dependency_libs 61907a3b38f7Smrg temp_deplibs= 61917a3b38f7Smrg for libdir in $dependency_libs; do 61927a3b38f7Smrg case $libdir in 61937a3b38f7Smrg -R*) func_stripname '-R' '' "$libdir" 61947a3b38f7Smrg temp_xrpath=$func_stripname_result 61957a3b38f7Smrg case " $xrpath " in 61967a3b38f7Smrg *" $temp_xrpath "*) ;; 61977a3b38f7Smrg *) xrpath="$xrpath $temp_xrpath";; 61987a3b38f7Smrg esac;; 61997a3b38f7Smrg *) temp_deplibs="$temp_deplibs $libdir";; 62007a3b38f7Smrg esac 62017a3b38f7Smrg done 62027a3b38f7Smrg dependency_libs="$temp_deplibs" 62037a3b38f7Smrg fi 62047a3b38f7Smrg 62057a3b38f7Smrg newlib_search_path="$newlib_search_path $absdir" 62067a3b38f7Smrg # Link against this library 62077a3b38f7Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 62087a3b38f7Smrg # ... and its dependency_libs 62097a3b38f7Smrg tmp_libs= 62107a3b38f7Smrg for deplib in $dependency_libs; do 62117a3b38f7Smrg newdependency_libs="$deplib $newdependency_libs" 62127a3b38f7Smrg if $opt_duplicate_deps ; then 62137a3b38f7Smrg case "$tmp_libs " in 62147a3b38f7Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 62157a3b38f7Smrg esac 62167a3b38f7Smrg fi 62177a3b38f7Smrg tmp_libs="$tmp_libs $deplib" 62187a3b38f7Smrg done 62197a3b38f7Smrg 62207a3b38f7Smrg if test "$link_all_deplibs" != no; then 62217a3b38f7Smrg # Add the search paths of all dependency libraries 62227a3b38f7Smrg for deplib in $dependency_libs; do 622344dda7b2Smrg path= 62247a3b38f7Smrg case $deplib in 62257a3b38f7Smrg -L*) path="$deplib" ;; 62267a3b38f7Smrg *.la) 62277a3b38f7Smrg func_dirname "$deplib" "" "." 62287a3b38f7Smrg dir="$func_dirname_result" 62297a3b38f7Smrg # We need an absolute path. 62307a3b38f7Smrg case $dir in 62317a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 62327a3b38f7Smrg *) 62337a3b38f7Smrg absdir=`cd "$dir" && pwd` 62347a3b38f7Smrg if test -z "$absdir"; then 62357a3b38f7Smrg func_warning "cannot determine absolute directory name of \`$dir'" 62367a3b38f7Smrg absdir="$dir" 62377a3b38f7Smrg fi 62387a3b38f7Smrg ;; 62397a3b38f7Smrg esac 62407a3b38f7Smrg if $GREP "^installed=no" $deplib > /dev/null; then 62417a3b38f7Smrg case $host in 62427a3b38f7Smrg *-*-darwin*) 62437a3b38f7Smrg depdepl= 62447a3b38f7Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 62457a3b38f7Smrg if test -n "$deplibrary_names" ; then 62467a3b38f7Smrg for tmp in $deplibrary_names ; do 62477a3b38f7Smrg depdepl=$tmp 62487a3b38f7Smrg done 62497a3b38f7Smrg if test -f "$absdir/$objdir/$depdepl" ; then 62507a3b38f7Smrg depdepl="$absdir/$objdir/$depdepl" 62517a3b38f7Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 62527a3b38f7Smrg if test -z "$darwin_install_name"; then 62537a3b38f7Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 62547a3b38f7Smrg fi 62557a3b38f7Smrg compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 62567a3b38f7Smrg linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" 62577a3b38f7Smrg path= 62587a3b38f7Smrg fi 62597a3b38f7Smrg fi 62607a3b38f7Smrg ;; 62617a3b38f7Smrg *) 62627a3b38f7Smrg path="-L$absdir/$objdir" 62637a3b38f7Smrg ;; 62647a3b38f7Smrg esac 62657a3b38f7Smrg else 62667a3b38f7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 62677a3b38f7Smrg test -z "$libdir" && \ 62687a3b38f7Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 62697a3b38f7Smrg test "$absdir" != "$libdir" && \ 62707a3b38f7Smrg func_warning "\`$deplib' seems to be moved" 62717a3b38f7Smrg 62727a3b38f7Smrg path="-L$absdir" 62737a3b38f7Smrg fi 62747a3b38f7Smrg ;; 62757a3b38f7Smrg esac 62767a3b38f7Smrg case " $deplibs " in 62777a3b38f7Smrg *" $path "*) ;; 62787a3b38f7Smrg *) deplibs="$path $deplibs" ;; 62797a3b38f7Smrg esac 62807a3b38f7Smrg done 62817a3b38f7Smrg fi # link_all_deplibs != no 62827a3b38f7Smrg fi # linkmode = lib 62837a3b38f7Smrg done # for deplib in $libs 62847a3b38f7Smrg if test "$pass" = link; then 62857a3b38f7Smrg if test "$linkmode" = "prog"; then 62867a3b38f7Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 62877a3b38f7Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 62887a3b38f7Smrg else 628944dda7b2Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 62907a3b38f7Smrg fi 62917a3b38f7Smrg fi 62927a3b38f7Smrg dependency_libs="$newdependency_libs" 62937a3b38f7Smrg if test "$pass" = dlpreopen; then 62947a3b38f7Smrg # Link the dlpreopened libraries before other libraries 62957a3b38f7Smrg for deplib in $save_deplibs; do 62967a3b38f7Smrg deplibs="$deplib $deplibs" 62977a3b38f7Smrg done 62987a3b38f7Smrg fi 62997a3b38f7Smrg if test "$pass" != dlopen; then 63007a3b38f7Smrg if test "$pass" != conv; then 63017a3b38f7Smrg # Make sure lib_search_path contains only unique directories. 63027a3b38f7Smrg lib_search_path= 63037a3b38f7Smrg for dir in $newlib_search_path; do 63047a3b38f7Smrg case "$lib_search_path " in 63057a3b38f7Smrg *" $dir "*) ;; 63067a3b38f7Smrg *) lib_search_path="$lib_search_path $dir" ;; 63077a3b38f7Smrg esac 63087a3b38f7Smrg done 63097a3b38f7Smrg newlib_search_path= 63107a3b38f7Smrg fi 63117a3b38f7Smrg 63127a3b38f7Smrg if test "$linkmode,$pass" != "prog,link"; then 63137a3b38f7Smrg vars="deplibs" 63147a3b38f7Smrg else 63157a3b38f7Smrg vars="compile_deplibs finalize_deplibs" 63167a3b38f7Smrg fi 63177a3b38f7Smrg for var in $vars dependency_libs; do 63187a3b38f7Smrg # Add libraries to $var in reverse order 63197a3b38f7Smrg eval tmp_libs=\"\$$var\" 63207a3b38f7Smrg new_libs= 63217a3b38f7Smrg for deplib in $tmp_libs; do 63227a3b38f7Smrg # FIXME: Pedantically, this is the right thing to do, so 63237a3b38f7Smrg # that some nasty dependency loop isn't accidentally 63247a3b38f7Smrg # broken: 63257a3b38f7Smrg #new_libs="$deplib $new_libs" 63267a3b38f7Smrg # Pragmatically, this seems to cause very few problems in 63277a3b38f7Smrg # practice: 63287a3b38f7Smrg case $deplib in 63297a3b38f7Smrg -L*) new_libs="$deplib $new_libs" ;; 63307a3b38f7Smrg -R*) ;; 63317a3b38f7Smrg *) 63327a3b38f7Smrg # And here is the reason: when a library appears more 63337a3b38f7Smrg # than once as an explicit dependence of a library, or 63347a3b38f7Smrg # is implicitly linked in more than once by the 63357a3b38f7Smrg # compiler, it is considered special, and multiple 63367a3b38f7Smrg # occurrences thereof are not removed. Compare this 63377a3b38f7Smrg # with having the same library being listed as a 63387a3b38f7Smrg # dependency of multiple other libraries: in this case, 63397a3b38f7Smrg # we know (pedantically, we assume) the library does not 63407a3b38f7Smrg # need to be listed more than once, so we keep only the 63417a3b38f7Smrg # last copy. This is not always right, but it is rare 63427a3b38f7Smrg # enough that we require users that really mean to play 63437a3b38f7Smrg # such unportable linking tricks to link the library 63447a3b38f7Smrg # using -Wl,-lname, so that libtool does not consider it 63457a3b38f7Smrg # for duplicate removal. 63467a3b38f7Smrg case " $specialdeplibs " in 63477a3b38f7Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 63487a3b38f7Smrg *) 63497a3b38f7Smrg case " $new_libs " in 63507a3b38f7Smrg *" $deplib "*) ;; 63517a3b38f7Smrg *) new_libs="$deplib $new_libs" ;; 63527a3b38f7Smrg esac 63537a3b38f7Smrg ;; 63547a3b38f7Smrg esac 63557a3b38f7Smrg ;; 63567a3b38f7Smrg esac 63577a3b38f7Smrg done 63587a3b38f7Smrg tmp_libs= 63597a3b38f7Smrg for deplib in $new_libs; do 63607a3b38f7Smrg case $deplib in 63617a3b38f7Smrg -L*) 63627a3b38f7Smrg case " $tmp_libs " in 63637a3b38f7Smrg *" $deplib "*) ;; 63647a3b38f7Smrg *) tmp_libs="$tmp_libs $deplib" ;; 63657a3b38f7Smrg esac 63667a3b38f7Smrg ;; 63677a3b38f7Smrg *) tmp_libs="$tmp_libs $deplib" ;; 63687a3b38f7Smrg esac 63697a3b38f7Smrg done 63707a3b38f7Smrg eval $var=\"$tmp_libs\" 63717a3b38f7Smrg done # for var 63727a3b38f7Smrg fi 63737a3b38f7Smrg # Last step: remove runtime libs from dependency_libs 63747a3b38f7Smrg # (they stay in deplibs) 63757a3b38f7Smrg tmp_libs= 63767a3b38f7Smrg for i in $dependency_libs ; do 63777a3b38f7Smrg case " $predeps $postdeps $compiler_lib_search_path " in 63787a3b38f7Smrg *" $i "*) 63797a3b38f7Smrg i="" 63807a3b38f7Smrg ;; 63817a3b38f7Smrg esac 63827a3b38f7Smrg if test -n "$i" ; then 63837a3b38f7Smrg tmp_libs="$tmp_libs $i" 63847a3b38f7Smrg fi 63857a3b38f7Smrg done 63867a3b38f7Smrg dependency_libs=$tmp_libs 63877a3b38f7Smrg done # for pass 63887a3b38f7Smrg if test "$linkmode" = prog; then 63897a3b38f7Smrg dlfiles="$newdlfiles" 63907a3b38f7Smrg fi 63917a3b38f7Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 63927a3b38f7Smrg dlprefiles="$newdlprefiles" 63937a3b38f7Smrg fi 63947a3b38f7Smrg 63957a3b38f7Smrg case $linkmode in 63967a3b38f7Smrg oldlib) 63977a3b38f7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 63987a3b38f7Smrg func_warning "\`-dlopen' is ignored for archives" 63997a3b38f7Smrg fi 64007a3b38f7Smrg 64017a3b38f7Smrg case " $deplibs" in 64027a3b38f7Smrg *\ -l* | *\ -L*) 64037a3b38f7Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 64047a3b38f7Smrg esac 64057a3b38f7Smrg 64067a3b38f7Smrg test -n "$rpath" && \ 64077a3b38f7Smrg func_warning "\`-rpath' is ignored for archives" 64087a3b38f7Smrg 64097a3b38f7Smrg test -n "$xrpath" && \ 64107a3b38f7Smrg func_warning "\`-R' is ignored for archives" 64117a3b38f7Smrg 64127a3b38f7Smrg test -n "$vinfo" && \ 64137a3b38f7Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 64147a3b38f7Smrg 64157a3b38f7Smrg test -n "$release" && \ 64167a3b38f7Smrg func_warning "\`-release' is ignored for archives" 64177a3b38f7Smrg 64187a3b38f7Smrg test -n "$export_symbols$export_symbols_regex" && \ 64197a3b38f7Smrg func_warning "\`-export-symbols' is ignored for archives" 64207a3b38f7Smrg 64217a3b38f7Smrg # Now set the variables for building old libraries. 64227a3b38f7Smrg build_libtool_libs=no 64237a3b38f7Smrg oldlibs="$output" 64247a3b38f7Smrg objs="$objs$old_deplibs" 64257a3b38f7Smrg ;; 64267a3b38f7Smrg 64277a3b38f7Smrg lib) 64287a3b38f7Smrg # Make sure we only generate libraries of the form `libNAME.la'. 64297a3b38f7Smrg case $outputname in 64307a3b38f7Smrg lib*) 64317a3b38f7Smrg func_stripname 'lib' '.la' "$outputname" 64327a3b38f7Smrg name=$func_stripname_result 64337a3b38f7Smrg eval shared_ext=\"$shrext_cmds\" 64347a3b38f7Smrg eval libname=\"$libname_spec\" 64357a3b38f7Smrg ;; 64367a3b38f7Smrg *) 64377a3b38f7Smrg test "$module" = no && \ 64387a3b38f7Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 64397a3b38f7Smrg 64407a3b38f7Smrg if test "$need_lib_prefix" != no; then 64417a3b38f7Smrg # Add the "lib" prefix for modules if required 64427a3b38f7Smrg func_stripname '' '.la' "$outputname" 64437a3b38f7Smrg name=$func_stripname_result 64447a3b38f7Smrg eval shared_ext=\"$shrext_cmds\" 64457a3b38f7Smrg eval libname=\"$libname_spec\" 64467a3b38f7Smrg else 64477a3b38f7Smrg func_stripname '' '.la' "$outputname" 64487a3b38f7Smrg libname=$func_stripname_result 64497a3b38f7Smrg fi 64507a3b38f7Smrg ;; 64517a3b38f7Smrg esac 64527a3b38f7Smrg 64537a3b38f7Smrg if test -n "$objs"; then 64547a3b38f7Smrg if test "$deplibs_check_method" != pass_all; then 64557a3b38f7Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 64567a3b38f7Smrg else 645744dda7b2Smrg echo 64587a3b38f7Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 64597a3b38f7Smrg $ECHO "*** objects $objs is not portable!" 64607a3b38f7Smrg libobjs="$libobjs $objs" 64617a3b38f7Smrg fi 64627a3b38f7Smrg fi 64637a3b38f7Smrg 64647a3b38f7Smrg test "$dlself" != no && \ 64657a3b38f7Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 64667a3b38f7Smrg 64677a3b38f7Smrg set dummy $rpath 64687a3b38f7Smrg shift 64697a3b38f7Smrg test "$#" -gt 1 && \ 64707a3b38f7Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 64717a3b38f7Smrg 64727a3b38f7Smrg install_libdir="$1" 64737a3b38f7Smrg 64747a3b38f7Smrg oldlibs= 64757a3b38f7Smrg if test -z "$rpath"; then 64767a3b38f7Smrg if test "$build_libtool_libs" = yes; then 64777a3b38f7Smrg # Building a libtool convenience library. 64787a3b38f7Smrg # Some compilers have problems with a `.al' extension so 64797a3b38f7Smrg # convenience libraries should have the same extension an 64807a3b38f7Smrg # archive normally would. 64817a3b38f7Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 64827a3b38f7Smrg build_libtool_libs=convenience 64837a3b38f7Smrg build_old_libs=yes 64847a3b38f7Smrg fi 64857a3b38f7Smrg 64867a3b38f7Smrg test -n "$vinfo" && \ 64877a3b38f7Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 64887a3b38f7Smrg 64897a3b38f7Smrg test -n "$release" && \ 64907a3b38f7Smrg func_warning "\`-release' is ignored for convenience libraries" 64917a3b38f7Smrg else 64927a3b38f7Smrg 64937a3b38f7Smrg # Parse the version information argument. 64947a3b38f7Smrg save_ifs="$IFS"; IFS=':' 64957a3b38f7Smrg set dummy $vinfo 0 0 0 64967a3b38f7Smrg shift 64977a3b38f7Smrg IFS="$save_ifs" 64987a3b38f7Smrg 64997a3b38f7Smrg test -n "$7" && \ 65007a3b38f7Smrg func_fatal_help "too many parameters to \`-version-info'" 65017a3b38f7Smrg 65027a3b38f7Smrg # convert absolute version numbers to libtool ages 65037a3b38f7Smrg # this retains compatibility with .la files and attempts 65047a3b38f7Smrg # to make the code below a bit more comprehensible 65057a3b38f7Smrg 65067a3b38f7Smrg case $vinfo_number in 65077a3b38f7Smrg yes) 65087a3b38f7Smrg number_major="$1" 65097a3b38f7Smrg number_minor="$2" 65107a3b38f7Smrg number_revision="$3" 65117a3b38f7Smrg # 65127a3b38f7Smrg # There are really only two kinds -- those that 65137a3b38f7Smrg # use the current revision as the major version 65147a3b38f7Smrg # and those that subtract age and use age as 65157a3b38f7Smrg # a minor version. But, then there is irix 65167a3b38f7Smrg # which has an extra 1 added just for fun 65177a3b38f7Smrg # 65187a3b38f7Smrg case $version_type in 65197a3b38f7Smrg darwin|linux|osf|windows|none) 65207a3b38f7Smrg func_arith $number_major + $number_minor 65217a3b38f7Smrg current=$func_arith_result 65227a3b38f7Smrg age="$number_minor" 65237a3b38f7Smrg revision="$number_revision" 65247a3b38f7Smrg ;; 652544dda7b2Smrg freebsd-aout|freebsd-elf|qnx|sunos) 65267a3b38f7Smrg current="$number_major" 65277a3b38f7Smrg revision="$number_minor" 65287a3b38f7Smrg age="0" 65297a3b38f7Smrg ;; 65307a3b38f7Smrg irix|nonstopux) 65317a3b38f7Smrg func_arith $number_major + $number_minor 65327a3b38f7Smrg current=$func_arith_result 65337a3b38f7Smrg age="$number_minor" 65347a3b38f7Smrg revision="$number_minor" 65357a3b38f7Smrg lt_irix_increment=no 65367a3b38f7Smrg ;; 65377a3b38f7Smrg esac 65387a3b38f7Smrg ;; 65397a3b38f7Smrg no) 65407a3b38f7Smrg current="$1" 65417a3b38f7Smrg revision="$2" 65427a3b38f7Smrg age="$3" 65437a3b38f7Smrg ;; 65447a3b38f7Smrg esac 65457a3b38f7Smrg 65467a3b38f7Smrg # Check that each of the things are valid numbers. 65477a3b38f7Smrg case $current in 65487a3b38f7Smrg 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]) ;; 65497a3b38f7Smrg *) 65507a3b38f7Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 65517a3b38f7Smrg func_fatal_error "\`$vinfo' is not valid version information" 65527a3b38f7Smrg ;; 65537a3b38f7Smrg esac 65547a3b38f7Smrg 65557a3b38f7Smrg case $revision in 65567a3b38f7Smrg 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]) ;; 65577a3b38f7Smrg *) 65587a3b38f7Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 65597a3b38f7Smrg func_fatal_error "\`$vinfo' is not valid version information" 65607a3b38f7Smrg ;; 65617a3b38f7Smrg esac 65627a3b38f7Smrg 65637a3b38f7Smrg case $age in 65647a3b38f7Smrg 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]) ;; 65657a3b38f7Smrg *) 65667a3b38f7Smrg func_error "AGE \`$age' must be a nonnegative integer" 65677a3b38f7Smrg func_fatal_error "\`$vinfo' is not valid version information" 65687a3b38f7Smrg ;; 65697a3b38f7Smrg esac 65707a3b38f7Smrg 65717a3b38f7Smrg if test "$age" -gt "$current"; then 65727a3b38f7Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 65737a3b38f7Smrg func_fatal_error "\`$vinfo' is not valid version information" 65747a3b38f7Smrg fi 65757a3b38f7Smrg 65767a3b38f7Smrg # Calculate the version variables. 65777a3b38f7Smrg major= 65787a3b38f7Smrg versuffix= 65797a3b38f7Smrg verstring= 65807a3b38f7Smrg case $version_type in 65817a3b38f7Smrg none) ;; 65827a3b38f7Smrg 65837a3b38f7Smrg darwin) 65847a3b38f7Smrg # Like Linux, but with the current version available in 65857a3b38f7Smrg # verstring for coding it into the library header 65867a3b38f7Smrg func_arith $current - $age 65877a3b38f7Smrg major=.$func_arith_result 65887a3b38f7Smrg versuffix="$major.$age.$revision" 65897a3b38f7Smrg # Darwin ld doesn't like 0 for these options... 65907a3b38f7Smrg func_arith $current + 1 65917a3b38f7Smrg minor_current=$func_arith_result 65927a3b38f7Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 65937a3b38f7Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 65947a3b38f7Smrg ;; 65957a3b38f7Smrg 65967a3b38f7Smrg freebsd-aout) 65977a3b38f7Smrg major=".$current" 65987a3b38f7Smrg versuffix=".$current.$revision"; 65997a3b38f7Smrg ;; 66007a3b38f7Smrg 66017a3b38f7Smrg freebsd-elf) 66027a3b38f7Smrg major=".$current" 66037a3b38f7Smrg versuffix=".$current" 66047a3b38f7Smrg ;; 66057a3b38f7Smrg 66067a3b38f7Smrg irix | nonstopux) 66077a3b38f7Smrg if test "X$lt_irix_increment" = "Xno"; then 66087a3b38f7Smrg func_arith $current - $age 66097a3b38f7Smrg else 66107a3b38f7Smrg func_arith $current - $age + 1 66117a3b38f7Smrg fi 66127a3b38f7Smrg major=$func_arith_result 66137a3b38f7Smrg 66147a3b38f7Smrg case $version_type in 66157a3b38f7Smrg nonstopux) verstring_prefix=nonstopux ;; 66167a3b38f7Smrg *) verstring_prefix=sgi ;; 66177a3b38f7Smrg esac 66187a3b38f7Smrg verstring="$verstring_prefix$major.$revision" 66197a3b38f7Smrg 66207a3b38f7Smrg # Add in all the interfaces that we are compatible with. 66217a3b38f7Smrg loop=$revision 66227a3b38f7Smrg while test "$loop" -ne 0; do 66237a3b38f7Smrg func_arith $revision - $loop 66247a3b38f7Smrg iface=$func_arith_result 66257a3b38f7Smrg func_arith $loop - 1 66267a3b38f7Smrg loop=$func_arith_result 66277a3b38f7Smrg verstring="$verstring_prefix$major.$iface:$verstring" 66287a3b38f7Smrg done 66297a3b38f7Smrg 66307a3b38f7Smrg # Before this point, $major must not contain `.'. 66317a3b38f7Smrg major=.$major 66327a3b38f7Smrg versuffix="$major.$revision" 66337a3b38f7Smrg ;; 66347a3b38f7Smrg 66357a3b38f7Smrg linux) 66367a3b38f7Smrg func_arith $current - $age 66377a3b38f7Smrg major=.$func_arith_result 66387a3b38f7Smrg versuffix="$major.$age.$revision" 66397a3b38f7Smrg ;; 66407a3b38f7Smrg 66417a3b38f7Smrg osf) 66427a3b38f7Smrg func_arith $current - $age 66437a3b38f7Smrg major=.$func_arith_result 66447a3b38f7Smrg versuffix=".$current.$age.$revision" 66457a3b38f7Smrg verstring="$current.$age.$revision" 66467a3b38f7Smrg 66477a3b38f7Smrg # Add in all the interfaces that we are compatible with. 66487a3b38f7Smrg loop=$age 66497a3b38f7Smrg while test "$loop" -ne 0; do 66507a3b38f7Smrg func_arith $current - $loop 66517a3b38f7Smrg iface=$func_arith_result 66527a3b38f7Smrg func_arith $loop - 1 66537a3b38f7Smrg loop=$func_arith_result 66547a3b38f7Smrg verstring="$verstring:${iface}.0" 66557a3b38f7Smrg done 66567a3b38f7Smrg 66577a3b38f7Smrg # Make executables depend on our current version. 66587a3b38f7Smrg verstring="$verstring:${current}.0" 66597a3b38f7Smrg ;; 66607a3b38f7Smrg 66617a3b38f7Smrg qnx) 66627a3b38f7Smrg major=".$current" 66637a3b38f7Smrg versuffix=".$current" 66647a3b38f7Smrg ;; 66657a3b38f7Smrg 66667a3b38f7Smrg sunos) 66677a3b38f7Smrg major=".$current" 66687a3b38f7Smrg versuffix=".$current.$revision" 66697a3b38f7Smrg ;; 66707a3b38f7Smrg 66717a3b38f7Smrg windows) 66727a3b38f7Smrg # Use '-' rather than '.', since we only want one 66737a3b38f7Smrg # extension on DOS 8.3 filesystems. 66747a3b38f7Smrg func_arith $current - $age 66757a3b38f7Smrg major=$func_arith_result 66767a3b38f7Smrg versuffix="-$major" 66777a3b38f7Smrg ;; 66787a3b38f7Smrg 66797a3b38f7Smrg *) 66807a3b38f7Smrg func_fatal_configuration "unknown library version type \`$version_type'" 66817a3b38f7Smrg ;; 66827a3b38f7Smrg esac 66837a3b38f7Smrg 66847a3b38f7Smrg # Clear the version info if we defaulted, and they specified a release. 66857a3b38f7Smrg if test -z "$vinfo" && test -n "$release"; then 66867a3b38f7Smrg major= 66877a3b38f7Smrg case $version_type in 66887a3b38f7Smrg darwin) 66897a3b38f7Smrg # we can't check for "0.0" in archive_cmds due to quoting 66907a3b38f7Smrg # problems, so we reset it completely 66917a3b38f7Smrg verstring= 66927a3b38f7Smrg ;; 66937a3b38f7Smrg *) 66947a3b38f7Smrg verstring="0.0" 66957a3b38f7Smrg ;; 66967a3b38f7Smrg esac 66977a3b38f7Smrg if test "$need_version" = no; then 66987a3b38f7Smrg versuffix= 66997a3b38f7Smrg else 67007a3b38f7Smrg versuffix=".0.0" 67017a3b38f7Smrg fi 67027a3b38f7Smrg fi 67037a3b38f7Smrg 67047a3b38f7Smrg # Remove version info from name if versioning should be avoided 67057a3b38f7Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 67067a3b38f7Smrg major= 67077a3b38f7Smrg versuffix= 67087a3b38f7Smrg verstring="" 67097a3b38f7Smrg fi 67107a3b38f7Smrg 67117a3b38f7Smrg # Check to see if the archive will have undefined symbols. 67127a3b38f7Smrg if test "$allow_undefined" = yes; then 67137a3b38f7Smrg if test "$allow_undefined_flag" = unsupported; then 67147a3b38f7Smrg func_warning "undefined symbols not allowed in $host shared libraries" 67157a3b38f7Smrg build_libtool_libs=no 67167a3b38f7Smrg build_old_libs=yes 67177a3b38f7Smrg fi 67187a3b38f7Smrg else 67197a3b38f7Smrg # Don't allow undefined symbols. 67207a3b38f7Smrg allow_undefined_flag="$no_undefined_flag" 67217a3b38f7Smrg fi 67227a3b38f7Smrg 67237a3b38f7Smrg fi 67247a3b38f7Smrg 67257a3b38f7Smrg func_generate_dlsyms "$libname" "$libname" "yes" 67267a3b38f7Smrg libobjs="$libobjs $symfileobj" 67277a3b38f7Smrg test "X$libobjs" = "X " && libobjs= 67287a3b38f7Smrg 67297a3b38f7Smrg if test "$mode" != relink; then 67307a3b38f7Smrg # Remove our outputs, but don't remove object files since they 67317a3b38f7Smrg # may have been created when compiling PIC objects. 67327a3b38f7Smrg removelist= 67337a3b38f7Smrg tempremovelist=`$ECHO "$output_objdir/*"` 67347a3b38f7Smrg for p in $tempremovelist; do 67357a3b38f7Smrg case $p in 67367a3b38f7Smrg *.$objext | *.gcno) 67377a3b38f7Smrg ;; 67387a3b38f7Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 67397a3b38f7Smrg if test "X$precious_files_regex" != "X"; then 67407a3b38f7Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 67417a3b38f7Smrg then 67427a3b38f7Smrg continue 67437a3b38f7Smrg fi 67447a3b38f7Smrg fi 67457a3b38f7Smrg removelist="$removelist $p" 67467a3b38f7Smrg ;; 67477a3b38f7Smrg *) ;; 67487a3b38f7Smrg esac 67497a3b38f7Smrg done 67507a3b38f7Smrg test -n "$removelist" && \ 67517a3b38f7Smrg func_show_eval "${RM}r \$removelist" 67527a3b38f7Smrg fi 67537a3b38f7Smrg 67547a3b38f7Smrg # Now set the variables for building old libraries. 67557a3b38f7Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 67567a3b38f7Smrg oldlibs="$oldlibs $output_objdir/$libname.$libext" 67577a3b38f7Smrg 67587a3b38f7Smrg # Transform .lo files to .o files. 675944dda7b2Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 67607a3b38f7Smrg fi 67617a3b38f7Smrg 67627a3b38f7Smrg # Eliminate all temporary directories. 67637a3b38f7Smrg #for path in $notinst_path; do 676444dda7b2Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 676544dda7b2Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 676644dda7b2Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 67677a3b38f7Smrg #done 67687a3b38f7Smrg 67697a3b38f7Smrg if test -n "$xrpath"; then 67707a3b38f7Smrg # If the user specified any rpath flags, then add them. 67717a3b38f7Smrg temp_xrpath= 67727a3b38f7Smrg for libdir in $xrpath; do 67737a3b38f7Smrg temp_xrpath="$temp_xrpath -R$libdir" 67747a3b38f7Smrg case "$finalize_rpath " in 67757a3b38f7Smrg *" $libdir "*) ;; 67767a3b38f7Smrg *) finalize_rpath="$finalize_rpath $libdir" ;; 67777a3b38f7Smrg esac 67787a3b38f7Smrg done 67797a3b38f7Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 67807a3b38f7Smrg dependency_libs="$temp_xrpath $dependency_libs" 67817a3b38f7Smrg fi 67827a3b38f7Smrg fi 67837a3b38f7Smrg 67847a3b38f7Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 67857a3b38f7Smrg old_dlfiles="$dlfiles" 67867a3b38f7Smrg dlfiles= 67877a3b38f7Smrg for lib in $old_dlfiles; do 67887a3b38f7Smrg case " $dlprefiles $dlfiles " in 67897a3b38f7Smrg *" $lib "*) ;; 67907a3b38f7Smrg *) dlfiles="$dlfiles $lib" ;; 67917a3b38f7Smrg esac 67927a3b38f7Smrg done 67937a3b38f7Smrg 67947a3b38f7Smrg # Make sure dlprefiles contains only unique files 67957a3b38f7Smrg old_dlprefiles="$dlprefiles" 67967a3b38f7Smrg dlprefiles= 67977a3b38f7Smrg for lib in $old_dlprefiles; do 67987a3b38f7Smrg case "$dlprefiles " in 67997a3b38f7Smrg *" $lib "*) ;; 68007a3b38f7Smrg *) dlprefiles="$dlprefiles $lib" ;; 68017a3b38f7Smrg esac 68027a3b38f7Smrg done 68037a3b38f7Smrg 68047a3b38f7Smrg if test "$build_libtool_libs" = yes; then 68057a3b38f7Smrg if test -n "$rpath"; then 68067a3b38f7Smrg case $host in 680744dda7b2Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 68087a3b38f7Smrg # these systems don't actually have a c library (as such)! 68097a3b38f7Smrg ;; 68107a3b38f7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 68117a3b38f7Smrg # Rhapsody C library is in the System framework 68127a3b38f7Smrg deplibs="$deplibs System.ltframework" 68137a3b38f7Smrg ;; 68147a3b38f7Smrg *-*-netbsd*) 68157a3b38f7Smrg # Don't link with libc until the a.out ld.so is fixed. 68167a3b38f7Smrg ;; 68177a3b38f7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 68187a3b38f7Smrg # Do not include libc due to us having libc/libc_r. 68197a3b38f7Smrg ;; 68207a3b38f7Smrg *-*-sco3.2v5* | *-*-sco5v6*) 68217a3b38f7Smrg # Causes problems with __ctype 68227a3b38f7Smrg ;; 68237a3b38f7Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 68247a3b38f7Smrg # Compiler inserts libc in the correct place for threads to work 68257a3b38f7Smrg ;; 68267a3b38f7Smrg *) 68277a3b38f7Smrg # Add libc to deplibs on all other systems if necessary. 68287a3b38f7Smrg if test "$build_libtool_need_lc" = "yes"; then 68297a3b38f7Smrg deplibs="$deplibs -lc" 68307a3b38f7Smrg fi 68317a3b38f7Smrg ;; 68327a3b38f7Smrg esac 68337a3b38f7Smrg fi 68347a3b38f7Smrg 68357a3b38f7Smrg # Transform deplibs into only deplibs that can be linked in shared. 68367a3b38f7Smrg name_save=$name 68377a3b38f7Smrg libname_save=$libname 68387a3b38f7Smrg release_save=$release 68397a3b38f7Smrg versuffix_save=$versuffix 68407a3b38f7Smrg major_save=$major 68417a3b38f7Smrg # I'm not sure if I'm treating the release correctly. I think 68427a3b38f7Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 68437a3b38f7Smrg # add it in twice. Is that correct? 68447a3b38f7Smrg release="" 68457a3b38f7Smrg versuffix="" 68467a3b38f7Smrg major="" 68477a3b38f7Smrg newdeplibs= 68487a3b38f7Smrg droppeddeps=no 68497a3b38f7Smrg case $deplibs_check_method in 68507a3b38f7Smrg pass_all) 68517a3b38f7Smrg # Don't check for shared/static. Everything works. 68527a3b38f7Smrg # This might be a little naive. We might want to check 68537a3b38f7Smrg # whether the library exists or not. But this is on 68547a3b38f7Smrg # osf3 & osf4 and I'm not really sure... Just 68557a3b38f7Smrg # implementing what was already the behavior. 68567a3b38f7Smrg newdeplibs=$deplibs 68577a3b38f7Smrg ;; 68587a3b38f7Smrg test_compile) 68597a3b38f7Smrg # This code stresses the "libraries are programs" paradigm to its 68607a3b38f7Smrg # limits. Maybe even breaks it. We compile a program, linking it 68617a3b38f7Smrg # against the deplibs as a proxy for the library. Then we can check 68627a3b38f7Smrg # whether they linked in statically or dynamically with ldd. 68637a3b38f7Smrg $opt_dry_run || $RM conftest.c 68647a3b38f7Smrg cat > conftest.c <<EOF 68657a3b38f7Smrg int main() { return 0; } 68667a3b38f7SmrgEOF 68677a3b38f7Smrg $opt_dry_run || $RM conftest 68687a3b38f7Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 68697a3b38f7Smrg ldd_output=`ldd conftest` 68707a3b38f7Smrg for i in $deplibs; do 68717a3b38f7Smrg case $i in 68727a3b38f7Smrg -l*) 68737a3b38f7Smrg func_stripname -l '' "$i" 68747a3b38f7Smrg name=$func_stripname_result 68757a3b38f7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 68767a3b38f7Smrg case " $predeps $postdeps " in 68777a3b38f7Smrg *" $i "*) 68787a3b38f7Smrg newdeplibs="$newdeplibs $i" 68797a3b38f7Smrg i="" 68807a3b38f7Smrg ;; 68817a3b38f7Smrg esac 68827a3b38f7Smrg fi 68837a3b38f7Smrg if test -n "$i" ; then 68847a3b38f7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 68857a3b38f7Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 68867a3b38f7Smrg set dummy $deplib_matches; shift 68877a3b38f7Smrg deplib_match=$1 68887a3b38f7Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 68897a3b38f7Smrg newdeplibs="$newdeplibs $i" 68907a3b38f7Smrg else 68917a3b38f7Smrg droppeddeps=yes 689244dda7b2Smrg echo 68937a3b38f7Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 689444dda7b2Smrg echo "*** I have the capability to make that library automatically link in when" 689544dda7b2Smrg echo "*** you link to this library. But I can only do this if you have a" 689644dda7b2Smrg echo "*** shared version of the library, which I believe you do not have" 689744dda7b2Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 689844dda7b2Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 68997a3b38f7Smrg fi 69007a3b38f7Smrg fi 69017a3b38f7Smrg ;; 69027a3b38f7Smrg *) 69037a3b38f7Smrg newdeplibs="$newdeplibs $i" 69047a3b38f7Smrg ;; 69057a3b38f7Smrg esac 69067a3b38f7Smrg done 69077a3b38f7Smrg else 69087a3b38f7Smrg # Error occurred in the first compile. Let's try to salvage 69097a3b38f7Smrg # the situation: Compile a separate program for each library. 69107a3b38f7Smrg for i in $deplibs; do 69117a3b38f7Smrg case $i in 69127a3b38f7Smrg -l*) 69137a3b38f7Smrg func_stripname -l '' "$i" 69147a3b38f7Smrg name=$func_stripname_result 69157a3b38f7Smrg $opt_dry_run || $RM conftest 69167a3b38f7Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 69177a3b38f7Smrg ldd_output=`ldd conftest` 69187a3b38f7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 69197a3b38f7Smrg case " $predeps $postdeps " in 69207a3b38f7Smrg *" $i "*) 69217a3b38f7Smrg newdeplibs="$newdeplibs $i" 69227a3b38f7Smrg i="" 69237a3b38f7Smrg ;; 69247a3b38f7Smrg esac 69257a3b38f7Smrg fi 69267a3b38f7Smrg if test -n "$i" ; then 69277a3b38f7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 69287a3b38f7Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 69297a3b38f7Smrg set dummy $deplib_matches; shift 69307a3b38f7Smrg deplib_match=$1 69317a3b38f7Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 69327a3b38f7Smrg newdeplibs="$newdeplibs $i" 69337a3b38f7Smrg else 69347a3b38f7Smrg droppeddeps=yes 693544dda7b2Smrg echo 69367a3b38f7Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 693744dda7b2Smrg echo "*** I have the capability to make that library automatically link in when" 693844dda7b2Smrg echo "*** you link to this library. But I can only do this if you have a" 693944dda7b2Smrg echo "*** shared version of the library, which you do not appear to have" 694044dda7b2Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 694144dda7b2Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 69427a3b38f7Smrg fi 69437a3b38f7Smrg fi 69447a3b38f7Smrg else 69457a3b38f7Smrg droppeddeps=yes 694644dda7b2Smrg echo 69477a3b38f7Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 694844dda7b2Smrg echo "*** make it link in! You will probably need to install it or some" 694944dda7b2Smrg echo "*** library that it depends on before this library will be fully" 695044dda7b2Smrg echo "*** functional. Installing it before continuing would be even better." 69517a3b38f7Smrg fi 69527a3b38f7Smrg ;; 69537a3b38f7Smrg *) 69547a3b38f7Smrg newdeplibs="$newdeplibs $i" 69557a3b38f7Smrg ;; 69567a3b38f7Smrg esac 69577a3b38f7Smrg done 69587a3b38f7Smrg fi 69597a3b38f7Smrg ;; 69607a3b38f7Smrg file_magic*) 69617a3b38f7Smrg set dummy $deplibs_check_method; shift 69627a3b38f7Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 69637a3b38f7Smrg for a_deplib in $deplibs; do 69647a3b38f7Smrg case $a_deplib in 69657a3b38f7Smrg -l*) 69667a3b38f7Smrg func_stripname -l '' "$a_deplib" 69677a3b38f7Smrg name=$func_stripname_result 69687a3b38f7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 69697a3b38f7Smrg case " $predeps $postdeps " in 69707a3b38f7Smrg *" $a_deplib "*) 69717a3b38f7Smrg newdeplibs="$newdeplibs $a_deplib" 69727a3b38f7Smrg a_deplib="" 69737a3b38f7Smrg ;; 69747a3b38f7Smrg esac 69757a3b38f7Smrg fi 69767a3b38f7Smrg if test -n "$a_deplib" ; then 69777a3b38f7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 69787a3b38f7Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 69797a3b38f7Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 69807a3b38f7Smrg for potent_lib in $potential_libs; do 69817a3b38f7Smrg # Follow soft links. 69827a3b38f7Smrg if ls -lLd "$potent_lib" 2>/dev/null | 69837a3b38f7Smrg $GREP " -> " >/dev/null; then 69847a3b38f7Smrg continue 69857a3b38f7Smrg fi 69867a3b38f7Smrg # The statement above tries to avoid entering an 69877a3b38f7Smrg # endless loop below, in case of cyclic links. 69887a3b38f7Smrg # We might still enter an endless loop, since a link 69897a3b38f7Smrg # loop can be closed while we follow links, 69907a3b38f7Smrg # but so what? 69917a3b38f7Smrg potlib="$potent_lib" 69927a3b38f7Smrg while test -h "$potlib" 2>/dev/null; do 69937a3b38f7Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 69947a3b38f7Smrg case $potliblink in 69957a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 699644dda7b2Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 69977a3b38f7Smrg esac 69987a3b38f7Smrg done 69997a3b38f7Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 70007a3b38f7Smrg $SED -e 10q | 70017a3b38f7Smrg $EGREP "$file_magic_regex" > /dev/null; then 70027a3b38f7Smrg newdeplibs="$newdeplibs $a_deplib" 70037a3b38f7Smrg a_deplib="" 70047a3b38f7Smrg break 2 70057a3b38f7Smrg fi 70067a3b38f7Smrg done 70077a3b38f7Smrg done 70087a3b38f7Smrg fi 70097a3b38f7Smrg if test -n "$a_deplib" ; then 70107a3b38f7Smrg droppeddeps=yes 701144dda7b2Smrg echo 70127a3b38f7Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 701344dda7b2Smrg echo "*** I have the capability to make that library automatically link in when" 701444dda7b2Smrg echo "*** you link to this library. But I can only do this if you have a" 701544dda7b2Smrg echo "*** shared version of the library, which you do not appear to have" 701644dda7b2Smrg echo "*** because I did check the linker path looking for a file starting" 70177a3b38f7Smrg if test -z "$potlib" ; then 70187a3b38f7Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 70197a3b38f7Smrg else 70207a3b38f7Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 70217a3b38f7Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 70227a3b38f7Smrg fi 70237a3b38f7Smrg fi 70247a3b38f7Smrg ;; 70257a3b38f7Smrg *) 70267a3b38f7Smrg # Add a -L argument. 70277a3b38f7Smrg newdeplibs="$newdeplibs $a_deplib" 70287a3b38f7Smrg ;; 70297a3b38f7Smrg esac 70307a3b38f7Smrg done # Gone through all deplibs. 70317a3b38f7Smrg ;; 70327a3b38f7Smrg match_pattern*) 70337a3b38f7Smrg set dummy $deplibs_check_method; shift 70347a3b38f7Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 70357a3b38f7Smrg for a_deplib in $deplibs; do 70367a3b38f7Smrg case $a_deplib in 70377a3b38f7Smrg -l*) 70387a3b38f7Smrg func_stripname -l '' "$a_deplib" 70397a3b38f7Smrg name=$func_stripname_result 70407a3b38f7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 70417a3b38f7Smrg case " $predeps $postdeps " in 70427a3b38f7Smrg *" $a_deplib "*) 70437a3b38f7Smrg newdeplibs="$newdeplibs $a_deplib" 70447a3b38f7Smrg a_deplib="" 70457a3b38f7Smrg ;; 70467a3b38f7Smrg esac 70477a3b38f7Smrg fi 70487a3b38f7Smrg if test -n "$a_deplib" ; then 70497a3b38f7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 70507a3b38f7Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 70517a3b38f7Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 70527a3b38f7Smrg for potent_lib in $potential_libs; do 70537a3b38f7Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 705444dda7b2Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 70557a3b38f7Smrg $EGREP "$match_pattern_regex" > /dev/null; then 70567a3b38f7Smrg newdeplibs="$newdeplibs $a_deplib" 70577a3b38f7Smrg a_deplib="" 70587a3b38f7Smrg break 2 70597a3b38f7Smrg fi 70607a3b38f7Smrg done 70617a3b38f7Smrg done 70627a3b38f7Smrg fi 70637a3b38f7Smrg if test -n "$a_deplib" ; then 70647a3b38f7Smrg droppeddeps=yes 706544dda7b2Smrg echo 70667a3b38f7Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 706744dda7b2Smrg echo "*** I have the capability to make that library automatically link in when" 706844dda7b2Smrg echo "*** you link to this library. But I can only do this if you have a" 706944dda7b2Smrg echo "*** shared version of the library, which you do not appear to have" 707044dda7b2Smrg echo "*** because I did check the linker path looking for a file starting" 70717a3b38f7Smrg if test -z "$potlib" ; then 70727a3b38f7Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 70737a3b38f7Smrg else 70747a3b38f7Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 70757a3b38f7Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 70767a3b38f7Smrg fi 70777a3b38f7Smrg fi 70787a3b38f7Smrg ;; 70797a3b38f7Smrg *) 70807a3b38f7Smrg # Add a -L argument. 70817a3b38f7Smrg newdeplibs="$newdeplibs $a_deplib" 70827a3b38f7Smrg ;; 70837a3b38f7Smrg esac 70847a3b38f7Smrg done # Gone through all deplibs. 70857a3b38f7Smrg ;; 70867a3b38f7Smrg none | unknown | *) 70877a3b38f7Smrg newdeplibs="" 708844dda7b2Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 70897a3b38f7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 70907a3b38f7Smrg for i in $predeps $postdeps ; do 70917a3b38f7Smrg # can't use Xsed below, because $i might contain '/' 709244dda7b2Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 70937a3b38f7Smrg done 70947a3b38f7Smrg fi 709544dda7b2Smrg case $tmp_deplibs in 709644dda7b2Smrg *[!\ \ ]*) 709744dda7b2Smrg echo 70987a3b38f7Smrg if test "X$deplibs_check_method" = "Xnone"; then 709944dda7b2Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 71007a3b38f7Smrg else 710144dda7b2Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 71027a3b38f7Smrg fi 710344dda7b2Smrg echo "*** All declared inter-library dependencies are being dropped." 71047a3b38f7Smrg droppeddeps=yes 710544dda7b2Smrg ;; 710644dda7b2Smrg esac 71077a3b38f7Smrg ;; 71087a3b38f7Smrg esac 71097a3b38f7Smrg versuffix=$versuffix_save 71107a3b38f7Smrg major=$major_save 71117a3b38f7Smrg release=$release_save 71127a3b38f7Smrg libname=$libname_save 71137a3b38f7Smrg name=$name_save 71147a3b38f7Smrg 71157a3b38f7Smrg case $host in 71167a3b38f7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 71177a3b38f7Smrg # On Rhapsody replace the C library with the System framework 711844dda7b2Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 71197a3b38f7Smrg ;; 71207a3b38f7Smrg esac 71217a3b38f7Smrg 71227a3b38f7Smrg if test "$droppeddeps" = yes; then 71237a3b38f7Smrg if test "$module" = yes; then 712444dda7b2Smrg echo 712544dda7b2Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 71267a3b38f7Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 712744dda7b2Smrg echo "*** a static module, that should work as long as the dlopening" 712844dda7b2Smrg echo "*** application is linked with the -dlopen flag." 71297a3b38f7Smrg if test -z "$global_symbol_pipe"; then 713044dda7b2Smrg echo 713144dda7b2Smrg echo "*** However, this would only work if libtool was able to extract symbol" 713244dda7b2Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 713344dda7b2Smrg echo "*** not find such a program. So, this module is probably useless." 713444dda7b2Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 71357a3b38f7Smrg fi 71367a3b38f7Smrg if test "$build_old_libs" = no; then 71377a3b38f7Smrg oldlibs="$output_objdir/$libname.$libext" 71387a3b38f7Smrg build_libtool_libs=module 71397a3b38f7Smrg build_old_libs=yes 71407a3b38f7Smrg else 71417a3b38f7Smrg build_libtool_libs=no 71427a3b38f7Smrg fi 71437a3b38f7Smrg else 714444dda7b2Smrg echo "*** The inter-library dependencies that have been dropped here will be" 714544dda7b2Smrg echo "*** automatically added whenever a program is linked with this library" 714644dda7b2Smrg echo "*** or is declared to -dlopen it." 71477a3b38f7Smrg 71487a3b38f7Smrg if test "$allow_undefined" = no; then 714944dda7b2Smrg echo 715044dda7b2Smrg echo "*** Since this library must not contain undefined symbols," 715144dda7b2Smrg echo "*** because either the platform does not support them or" 715244dda7b2Smrg echo "*** it was explicitly requested with -no-undefined," 715344dda7b2Smrg echo "*** libtool will only create a static version of it." 71547a3b38f7Smrg if test "$build_old_libs" = no; then 71557a3b38f7Smrg oldlibs="$output_objdir/$libname.$libext" 71567a3b38f7Smrg build_libtool_libs=module 71577a3b38f7Smrg build_old_libs=yes 71587a3b38f7Smrg else 71597a3b38f7Smrg build_libtool_libs=no 71607a3b38f7Smrg fi 71617a3b38f7Smrg fi 71627a3b38f7Smrg fi 71637a3b38f7Smrg fi 71647a3b38f7Smrg # Done checking deplibs! 71657a3b38f7Smrg deplibs=$newdeplibs 71667a3b38f7Smrg fi 71677a3b38f7Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 71687a3b38f7Smrg case $host in 71697a3b38f7Smrg *-*-darwin*) 717044dda7b2Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 717144dda7b2Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 717244dda7b2Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 71737a3b38f7Smrg ;; 71747a3b38f7Smrg esac 71757a3b38f7Smrg 71767a3b38f7Smrg # move library search paths that coincide with paths to not yet 71777a3b38f7Smrg # installed libraries to the beginning of the library search list 71787a3b38f7Smrg new_libs= 71797a3b38f7Smrg for path in $notinst_path; do 71807a3b38f7Smrg case " $new_libs " in 71817a3b38f7Smrg *" -L$path/$objdir "*) ;; 71827a3b38f7Smrg *) 71837a3b38f7Smrg case " $deplibs " in 71847a3b38f7Smrg *" -L$path/$objdir "*) 71857a3b38f7Smrg new_libs="$new_libs -L$path/$objdir" ;; 71867a3b38f7Smrg esac 71877a3b38f7Smrg ;; 71887a3b38f7Smrg esac 71897a3b38f7Smrg done 71907a3b38f7Smrg for deplib in $deplibs; do 71917a3b38f7Smrg case $deplib in 71927a3b38f7Smrg -L*) 71937a3b38f7Smrg case " $new_libs " in 71947a3b38f7Smrg *" $deplib "*) ;; 71957a3b38f7Smrg *) new_libs="$new_libs $deplib" ;; 71967a3b38f7Smrg esac 71977a3b38f7Smrg ;; 71987a3b38f7Smrg *) new_libs="$new_libs $deplib" ;; 71997a3b38f7Smrg esac 72007a3b38f7Smrg done 72017a3b38f7Smrg deplibs="$new_libs" 72027a3b38f7Smrg 72037a3b38f7Smrg # All the library-specific variables (install_libdir is set above). 72047a3b38f7Smrg library_names= 72057a3b38f7Smrg old_library= 72067a3b38f7Smrg dlname= 72077a3b38f7Smrg 72087a3b38f7Smrg # Test again, we may have decided not to build it any more 72097a3b38f7Smrg if test "$build_libtool_libs" = yes; then 72107a3b38f7Smrg if test "$hardcode_into_libs" = yes; then 72117a3b38f7Smrg # Hardcode the library paths 72127a3b38f7Smrg hardcode_libdirs= 72137a3b38f7Smrg dep_rpath= 72147a3b38f7Smrg rpath="$finalize_rpath" 72157a3b38f7Smrg test "$mode" != relink && rpath="$compile_rpath$rpath" 72167a3b38f7Smrg for libdir in $rpath; do 72177a3b38f7Smrg if test -n "$hardcode_libdir_flag_spec"; then 72187a3b38f7Smrg if test -n "$hardcode_libdir_separator"; then 72197a3b38f7Smrg if test -z "$hardcode_libdirs"; then 72207a3b38f7Smrg hardcode_libdirs="$libdir" 72217a3b38f7Smrg else 72227a3b38f7Smrg # Just accumulate the unique libdirs. 72237a3b38f7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 72247a3b38f7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 72257a3b38f7Smrg ;; 72267a3b38f7Smrg *) 72277a3b38f7Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 72287a3b38f7Smrg ;; 72297a3b38f7Smrg esac 72307a3b38f7Smrg fi 72317a3b38f7Smrg else 72327a3b38f7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 72337a3b38f7Smrg dep_rpath="$dep_rpath $flag" 72347a3b38f7Smrg fi 72357a3b38f7Smrg elif test -n "$runpath_var"; then 72367a3b38f7Smrg case "$perm_rpath " in 72377a3b38f7Smrg *" $libdir "*) ;; 72387a3b38f7Smrg *) perm_rpath="$perm_rpath $libdir" ;; 72397a3b38f7Smrg esac 72407a3b38f7Smrg fi 72417a3b38f7Smrg done 72427a3b38f7Smrg # Substitute the hardcoded libdirs into the rpath. 72437a3b38f7Smrg if test -n "$hardcode_libdir_separator" && 72447a3b38f7Smrg test -n "$hardcode_libdirs"; then 72457a3b38f7Smrg libdir="$hardcode_libdirs" 72467a3b38f7Smrg if test -n "$hardcode_libdir_flag_spec_ld"; then 72477a3b38f7Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 72487a3b38f7Smrg else 72497a3b38f7Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec\" 72507a3b38f7Smrg fi 72517a3b38f7Smrg fi 72527a3b38f7Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 72537a3b38f7Smrg # We should set the runpath_var. 72547a3b38f7Smrg rpath= 72557a3b38f7Smrg for dir in $perm_rpath; do 72567a3b38f7Smrg rpath="$rpath$dir:" 72577a3b38f7Smrg done 72587a3b38f7Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 72597a3b38f7Smrg fi 72607a3b38f7Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 72617a3b38f7Smrg fi 7262ff559fabSmrg 72637a3b38f7Smrg shlibpath="$finalize_shlibpath" 72647a3b38f7Smrg test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 72657a3b38f7Smrg if test -n "$shlibpath"; then 72667a3b38f7Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 72677a3b38f7Smrg fi 7268ff559fabSmrg 72697a3b38f7Smrg # Get the real and link names of the library. 72707a3b38f7Smrg eval shared_ext=\"$shrext_cmds\" 72717a3b38f7Smrg eval library_names=\"$library_names_spec\" 72727a3b38f7Smrg set dummy $library_names 72737a3b38f7Smrg shift 72747a3b38f7Smrg realname="$1" 72757a3b38f7Smrg shift 7276ff559fabSmrg 72777a3b38f7Smrg if test -n "$soname_spec"; then 72787a3b38f7Smrg eval soname=\"$soname_spec\" 72797a3b38f7Smrg else 72807a3b38f7Smrg soname="$realname" 72817a3b38f7Smrg fi 72827a3b38f7Smrg if test -z "$dlname"; then 72837a3b38f7Smrg dlname=$soname 72847a3b38f7Smrg fi 7285ff559fabSmrg 72867a3b38f7Smrg lib="$output_objdir/$realname" 72877a3b38f7Smrg linknames= 72887a3b38f7Smrg for link 72897a3b38f7Smrg do 72907a3b38f7Smrg linknames="$linknames $link" 72917a3b38f7Smrg done 7292ff559fabSmrg 72937a3b38f7Smrg # Use standard objects if they are pic 729444dda7b2Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 72957a3b38f7Smrg test "X$libobjs" = "X " && libobjs= 7296ff559fabSmrg 72977a3b38f7Smrg delfiles= 72987a3b38f7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 72997a3b38f7Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 73007a3b38f7Smrg export_symbols="$output_objdir/$libname.uexp" 73017a3b38f7Smrg delfiles="$delfiles $export_symbols" 73027a3b38f7Smrg fi 7303ff559fabSmrg 73047a3b38f7Smrg orig_export_symbols= 73057a3b38f7Smrg case $host_os in 73067a3b38f7Smrg cygwin* | mingw* | cegcc*) 73077a3b38f7Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 73087a3b38f7Smrg # exporting using user supplied symfile 73097a3b38f7Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 73107a3b38f7Smrg # and it's NOT already a .def file. Must figure out 73117a3b38f7Smrg # which of the given symbols are data symbols and tag 73127a3b38f7Smrg # them as such. So, trigger use of export_symbols_cmds. 73137a3b38f7Smrg # export_symbols gets reassigned inside the "prepare 73147a3b38f7Smrg # the list of exported symbols" if statement, so the 73157a3b38f7Smrg # include_expsyms logic still works. 73167a3b38f7Smrg orig_export_symbols="$export_symbols" 73177a3b38f7Smrg export_symbols= 73187a3b38f7Smrg always_export_symbols=yes 73197a3b38f7Smrg fi 73207a3b38f7Smrg fi 73217a3b38f7Smrg ;; 73227a3b38f7Smrg esac 7323ff559fabSmrg 73247a3b38f7Smrg # Prepare the list of exported symbols 73257a3b38f7Smrg if test -z "$export_symbols"; then 73267a3b38f7Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 73277a3b38f7Smrg func_verbose "generating symbol list for \`$libname.la'" 73287a3b38f7Smrg export_symbols="$output_objdir/$libname.exp" 73297a3b38f7Smrg $opt_dry_run || $RM $export_symbols 73307a3b38f7Smrg cmds=$export_symbols_cmds 73317a3b38f7Smrg save_ifs="$IFS"; IFS='~' 73327a3b38f7Smrg for cmd in $cmds; do 73337a3b38f7Smrg IFS="$save_ifs" 73347a3b38f7Smrg eval cmd=\"$cmd\" 73357a3b38f7Smrg func_len " $cmd" 73367a3b38f7Smrg len=$func_len_result 73377a3b38f7Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 73387a3b38f7Smrg func_show_eval "$cmd" 'exit $?' 73397a3b38f7Smrg skipped_export=false 73407a3b38f7Smrg else 73417a3b38f7Smrg # The command line is too long to execute in one step. 73427a3b38f7Smrg func_verbose "using reloadable object file for export list..." 73437a3b38f7Smrg skipped_export=: 73447a3b38f7Smrg # Break out early, otherwise skipped_export may be 73457a3b38f7Smrg # set to false by a later but shorter cmd. 73467a3b38f7Smrg break 73477a3b38f7Smrg fi 73487a3b38f7Smrg done 73497a3b38f7Smrg IFS="$save_ifs" 73507a3b38f7Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 73517a3b38f7Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 73527a3b38f7Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 73537a3b38f7Smrg fi 73547a3b38f7Smrg fi 73557a3b38f7Smrg fi 7356ff559fabSmrg 73577a3b38f7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 73587a3b38f7Smrg tmp_export_symbols="$export_symbols" 73597a3b38f7Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 736044dda7b2Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 73617a3b38f7Smrg fi 7362ff559fabSmrg 73637a3b38f7Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 73647a3b38f7Smrg # The given exports_symbols file has to be filtered, so filter it. 73657a3b38f7Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 73667a3b38f7Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 73677a3b38f7Smrg # 's' commands which not all seds can handle. GNU sed should be fine 73687a3b38f7Smrg # though. Also, the filter scales superlinearly with the number of 73697a3b38f7Smrg # global variables. join(1) would be nice here, but unfortunately 73707a3b38f7Smrg # isn't a blessed tool. 73717a3b38f7Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 73727a3b38f7Smrg delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" 73737a3b38f7Smrg export_symbols=$output_objdir/$libname.def 73747a3b38f7Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 7375ff559fabSmrg fi 7376ff559fabSmrg 73777a3b38f7Smrg tmp_deplibs= 73787a3b38f7Smrg for test_deplib in $deplibs; do 73797a3b38f7Smrg case " $convenience " in 73807a3b38f7Smrg *" $test_deplib "*) ;; 73817a3b38f7Smrg *) 73827a3b38f7Smrg tmp_deplibs="$tmp_deplibs $test_deplib" 73837a3b38f7Smrg ;; 73847a3b38f7Smrg esac 73857a3b38f7Smrg done 73867a3b38f7Smrg deplibs="$tmp_deplibs" 7387ff559fabSmrg 73887a3b38f7Smrg if test -n "$convenience"; then 73897a3b38f7Smrg if test -n "$whole_archive_flag_spec" && 73907a3b38f7Smrg test "$compiler_needs_object" = yes && 73917a3b38f7Smrg test -z "$libobjs"; then 73927a3b38f7Smrg # extract the archives, so we have objects to list. 73937a3b38f7Smrg # TODO: could optimize this to just extract one archive. 73947a3b38f7Smrg whole_archive_flag_spec= 73957a3b38f7Smrg fi 73967a3b38f7Smrg if test -n "$whole_archive_flag_spec"; then 73977a3b38f7Smrg save_libobjs=$libobjs 73987a3b38f7Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 73997a3b38f7Smrg test "X$libobjs" = "X " && libobjs= 74007a3b38f7Smrg else 74017a3b38f7Smrg gentop="$output_objdir/${outputname}x" 74027a3b38f7Smrg generated="$generated $gentop" 7403ff559fabSmrg 74047a3b38f7Smrg func_extract_archives $gentop $convenience 74057a3b38f7Smrg libobjs="$libobjs $func_extract_archives_result" 74067a3b38f7Smrg test "X$libobjs" = "X " && libobjs= 74077a3b38f7Smrg fi 74087a3b38f7Smrg fi 7409ff559fabSmrg 74107a3b38f7Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 74117a3b38f7Smrg eval flag=\"$thread_safe_flag_spec\" 74127a3b38f7Smrg linker_flags="$linker_flags $flag" 74137a3b38f7Smrg fi 7414ff559fabSmrg 74157a3b38f7Smrg # Make a backup of the uninstalled library when relinking 74167a3b38f7Smrg if test "$mode" = relink; then 74177a3b38f7Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 7418ff559fabSmrg fi 7419ff559fabSmrg 74207a3b38f7Smrg # Do each of the archive commands. 74217a3b38f7Smrg if test "$module" = yes && test -n "$module_cmds" ; then 74227a3b38f7Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 74237a3b38f7Smrg eval test_cmds=\"$module_expsym_cmds\" 74247a3b38f7Smrg cmds=$module_expsym_cmds 74257a3b38f7Smrg else 74267a3b38f7Smrg eval test_cmds=\"$module_cmds\" 74277a3b38f7Smrg cmds=$module_cmds 74287a3b38f7Smrg fi 74297a3b38f7Smrg else 74307a3b38f7Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 74317a3b38f7Smrg eval test_cmds=\"$archive_expsym_cmds\" 74327a3b38f7Smrg cmds=$archive_expsym_cmds 74337a3b38f7Smrg else 74347a3b38f7Smrg eval test_cmds=\"$archive_cmds\" 74357a3b38f7Smrg cmds=$archive_cmds 74367a3b38f7Smrg fi 7437ff559fabSmrg fi 7438ff559fabSmrg 74397a3b38f7Smrg if test "X$skipped_export" != "X:" && 74407a3b38f7Smrg func_len " $test_cmds" && 74417a3b38f7Smrg len=$func_len_result && 74427a3b38f7Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 74437a3b38f7Smrg : 74447a3b38f7Smrg else 74457a3b38f7Smrg # The command line is too long to link in one step, link piecewise 74467a3b38f7Smrg # or, if using GNU ld and skipped_export is not :, use a linker 74477a3b38f7Smrg # script. 7448ff559fabSmrg 74497a3b38f7Smrg # Save the value of $output and $libobjs because we want to 74507a3b38f7Smrg # use them later. If we have whole_archive_flag_spec, we 74517a3b38f7Smrg # want to use save_libobjs as it was before 74527a3b38f7Smrg # whole_archive_flag_spec was expanded, because we can't 74537a3b38f7Smrg # assume the linker understands whole_archive_flag_spec. 74547a3b38f7Smrg # This may have to be revisited, in case too many 74557a3b38f7Smrg # convenience libraries get linked in and end up exceeding 74567a3b38f7Smrg # the spec. 74577a3b38f7Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 74587a3b38f7Smrg save_libobjs=$libobjs 74597a3b38f7Smrg fi 74607a3b38f7Smrg save_output=$output 746144dda7b2Smrg func_basename "$output" 746244dda7b2Smrg output_la=$func_basename_result 7463ff559fabSmrg 74647a3b38f7Smrg # Clear the reloadable object creation command queue and 74657a3b38f7Smrg # initialize k to one. 74667a3b38f7Smrg test_cmds= 74677a3b38f7Smrg concat_cmds= 74687a3b38f7Smrg objlist= 74697a3b38f7Smrg last_robj= 74707a3b38f7Smrg k=1 7471ff559fabSmrg 74727a3b38f7Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 74737a3b38f7Smrg output=${output_objdir}/${output_la}.lnkscript 74747a3b38f7Smrg func_verbose "creating GNU ld script: $output" 747544dda7b2Smrg echo 'INPUT (' > $output 74767a3b38f7Smrg for obj in $save_libobjs 74777a3b38f7Smrg do 74787a3b38f7Smrg $ECHO "$obj" >> $output 74797a3b38f7Smrg done 748044dda7b2Smrg echo ')' >> $output 74817a3b38f7Smrg delfiles="$delfiles $output" 74827a3b38f7Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 74837a3b38f7Smrg output=${output_objdir}/${output_la}.lnk 74847a3b38f7Smrg func_verbose "creating linker input file list: $output" 74857a3b38f7Smrg : > $output 74867a3b38f7Smrg set x $save_libobjs 74877a3b38f7Smrg shift 74887a3b38f7Smrg firstobj= 74897a3b38f7Smrg if test "$compiler_needs_object" = yes; then 74907a3b38f7Smrg firstobj="$1 " 74917a3b38f7Smrg shift 74927a3b38f7Smrg fi 74937a3b38f7Smrg for obj 74947a3b38f7Smrg do 74957a3b38f7Smrg $ECHO "$obj" >> $output 74967a3b38f7Smrg done 74977a3b38f7Smrg delfiles="$delfiles $output" 74987a3b38f7Smrg output=$firstobj\"$file_list_spec$output\" 74997a3b38f7Smrg else 75007a3b38f7Smrg if test -n "$save_libobjs"; then 75017a3b38f7Smrg func_verbose "creating reloadable object files..." 75027a3b38f7Smrg output=$output_objdir/$output_la-${k}.$objext 75037a3b38f7Smrg eval test_cmds=\"$reload_cmds\" 75047a3b38f7Smrg func_len " $test_cmds" 75057a3b38f7Smrg len0=$func_len_result 75067a3b38f7Smrg len=$len0 75077a3b38f7Smrg 75087a3b38f7Smrg # Loop over the list of objects to be linked. 75097a3b38f7Smrg for obj in $save_libobjs 75107a3b38f7Smrg do 75117a3b38f7Smrg func_len " $obj" 75127a3b38f7Smrg func_arith $len + $func_len_result 75137a3b38f7Smrg len=$func_arith_result 75147a3b38f7Smrg if test "X$objlist" = X || 75157a3b38f7Smrg test "$len" -lt "$max_cmd_len"; then 75167a3b38f7Smrg func_append objlist " $obj" 75177a3b38f7Smrg else 75187a3b38f7Smrg # The command $test_cmds is almost too long, add a 75197a3b38f7Smrg # command to the queue. 75207a3b38f7Smrg if test "$k" -eq 1 ; then 75217a3b38f7Smrg # The first file doesn't have a previous command to add. 752244dda7b2Smrg reload_objs=$objlist 752344dda7b2Smrg eval concat_cmds=\"$reload_cmds\" 75247a3b38f7Smrg else 75257a3b38f7Smrg # All subsequent reloadable object files will link in 75267a3b38f7Smrg # the last one created. 752744dda7b2Smrg reload_objs="$objlist $last_robj" 752844dda7b2Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 75297a3b38f7Smrg fi 75307a3b38f7Smrg last_robj=$output_objdir/$output_la-${k}.$objext 75317a3b38f7Smrg func_arith $k + 1 75327a3b38f7Smrg k=$func_arith_result 75337a3b38f7Smrg output=$output_objdir/$output_la-${k}.$objext 753444dda7b2Smrg objlist=" $obj" 75357a3b38f7Smrg func_len " $last_robj" 75367a3b38f7Smrg func_arith $len0 + $func_len_result 75377a3b38f7Smrg len=$func_arith_result 75387a3b38f7Smrg fi 75397a3b38f7Smrg done 75407a3b38f7Smrg # Handle the remaining objects by creating one last 75417a3b38f7Smrg # reloadable object file. All subsequent reloadable object 75427a3b38f7Smrg # files will link in the last one created. 75437a3b38f7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 754444dda7b2Smrg reload_objs="$objlist $last_robj" 754544dda7b2Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 75467a3b38f7Smrg if test -n "$last_robj"; then 75477a3b38f7Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 75487a3b38f7Smrg fi 75497a3b38f7Smrg delfiles="$delfiles $output" 7550ff559fabSmrg 75517a3b38f7Smrg else 75527a3b38f7Smrg output= 75537a3b38f7Smrg fi 7554ff559fabSmrg 75557a3b38f7Smrg if ${skipped_export-false}; then 75567a3b38f7Smrg func_verbose "generating symbol list for \`$libname.la'" 75577a3b38f7Smrg export_symbols="$output_objdir/$libname.exp" 75587a3b38f7Smrg $opt_dry_run || $RM $export_symbols 75597a3b38f7Smrg libobjs=$output 75607a3b38f7Smrg # Append the command to create the export file. 75617a3b38f7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 75627a3b38f7Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 75637a3b38f7Smrg if test -n "$last_robj"; then 75647a3b38f7Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 75657a3b38f7Smrg fi 75667a3b38f7Smrg fi 7567ff559fabSmrg 75687a3b38f7Smrg test -n "$save_libobjs" && 75697a3b38f7Smrg func_verbose "creating a temporary reloadable object file: $output" 7570ff559fabSmrg 75717a3b38f7Smrg # Loop through the commands generated above and execute them. 75727a3b38f7Smrg save_ifs="$IFS"; IFS='~' 75737a3b38f7Smrg for cmd in $concat_cmds; do 75747a3b38f7Smrg IFS="$save_ifs" 75757a3b38f7Smrg $opt_silent || { 75767a3b38f7Smrg func_quote_for_expand "$cmd" 75777a3b38f7Smrg eval "func_echo $func_quote_for_expand_result" 75787a3b38f7Smrg } 75797a3b38f7Smrg $opt_dry_run || eval "$cmd" || { 75807a3b38f7Smrg lt_exit=$? 75817a3b38f7Smrg 75827a3b38f7Smrg # Restore the uninstalled library and exit 75837a3b38f7Smrg if test "$mode" = relink; then 75847a3b38f7Smrg ( cd "$output_objdir" && \ 75857a3b38f7Smrg $RM "${realname}T" && \ 75867a3b38f7Smrg $MV "${realname}U" "$realname" ) 75877a3b38f7Smrg fi 7588ff559fabSmrg 75897a3b38f7Smrg exit $lt_exit 75907a3b38f7Smrg } 75917a3b38f7Smrg done 75927a3b38f7Smrg IFS="$save_ifs" 75937a3b38f7Smrg 75947a3b38f7Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 75957a3b38f7Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 75967a3b38f7Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 7597ff559fabSmrg fi 7598ff559fabSmrg fi 7599ff559fabSmrg 76007a3b38f7Smrg if ${skipped_export-false}; then 76017a3b38f7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 76027a3b38f7Smrg tmp_export_symbols="$export_symbols" 76037a3b38f7Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 760444dda7b2Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 76057a3b38f7Smrg fi 7606ff559fabSmrg 76077a3b38f7Smrg if test -n "$orig_export_symbols"; then 76087a3b38f7Smrg # The given exports_symbols file has to be filtered, so filter it. 76097a3b38f7Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 76107a3b38f7Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 76117a3b38f7Smrg # 's' commands which not all seds can handle. GNU sed should be fine 76127a3b38f7Smrg # though. Also, the filter scales superlinearly with the number of 76137a3b38f7Smrg # global variables. join(1) would be nice here, but unfortunately 76147a3b38f7Smrg # isn't a blessed tool. 76157a3b38f7Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 76167a3b38f7Smrg delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" 76177a3b38f7Smrg export_symbols=$output_objdir/$libname.def 76187a3b38f7Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 76197a3b38f7Smrg fi 76207a3b38f7Smrg fi 7621ff559fabSmrg 76227a3b38f7Smrg libobjs=$output 76237a3b38f7Smrg # Restore the value of output. 76247a3b38f7Smrg output=$save_output 7625ff559fabSmrg 76267a3b38f7Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 76277a3b38f7Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 76287a3b38f7Smrg test "X$libobjs" = "X " && libobjs= 76297a3b38f7Smrg fi 76307a3b38f7Smrg # Expand the library linking commands again to reset the 76317a3b38f7Smrg # value of $libobjs for piecewise linking. 76327a3b38f7Smrg 76337a3b38f7Smrg # Do each of the archive commands. 76347a3b38f7Smrg if test "$module" = yes && test -n "$module_cmds" ; then 76357a3b38f7Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 76367a3b38f7Smrg cmds=$module_expsym_cmds 7637ff559fabSmrg else 76387a3b38f7Smrg cmds=$module_cmds 7639ff559fabSmrg fi 7640ff559fabSmrg else 76417a3b38f7Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 76427a3b38f7Smrg cmds=$archive_expsym_cmds 76437a3b38f7Smrg else 76447a3b38f7Smrg cmds=$archive_cmds 76457a3b38f7Smrg fi 7646ff559fabSmrg fi 7647ff559fabSmrg fi 7648ff559fabSmrg 76497a3b38f7Smrg if test -n "$delfiles"; then 76507a3b38f7Smrg # Append the command to remove temporary files to $cmds. 76517a3b38f7Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 76527a3b38f7Smrg fi 7653ff559fabSmrg 76547a3b38f7Smrg # Add any objects from preloaded convenience libraries 76557a3b38f7Smrg if test -n "$dlprefiles"; then 76567a3b38f7Smrg gentop="$output_objdir/${outputname}x" 76577a3b38f7Smrg generated="$generated $gentop" 7658ff559fabSmrg 76597a3b38f7Smrg func_extract_archives $gentop $dlprefiles 76607a3b38f7Smrg libobjs="$libobjs $func_extract_archives_result" 76617a3b38f7Smrg test "X$libobjs" = "X " && libobjs= 7662ff559fabSmrg fi 7663ff559fabSmrg 76647a3b38f7Smrg save_ifs="$IFS"; IFS='~' 76657a3b38f7Smrg for cmd in $cmds; do 76667a3b38f7Smrg IFS="$save_ifs" 76677a3b38f7Smrg eval cmd=\"$cmd\" 76687a3b38f7Smrg $opt_silent || { 76697a3b38f7Smrg func_quote_for_expand "$cmd" 76707a3b38f7Smrg eval "func_echo $func_quote_for_expand_result" 76717a3b38f7Smrg } 76727a3b38f7Smrg $opt_dry_run || eval "$cmd" || { 76737a3b38f7Smrg lt_exit=$? 7674ff559fabSmrg 76757a3b38f7Smrg # Restore the uninstalled library and exit 76767a3b38f7Smrg if test "$mode" = relink; then 76777a3b38f7Smrg ( cd "$output_objdir" && \ 76787a3b38f7Smrg $RM "${realname}T" && \ 76797a3b38f7Smrg $MV "${realname}U" "$realname" ) 76807a3b38f7Smrg fi 76817a3b38f7Smrg 76827a3b38f7Smrg exit $lt_exit 76837a3b38f7Smrg } 76847a3b38f7Smrg done 76857a3b38f7Smrg IFS="$save_ifs" 76867a3b38f7Smrg 76877a3b38f7Smrg # Restore the uninstalled library and exit 76887a3b38f7Smrg if test "$mode" = relink; then 76897a3b38f7Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 76907a3b38f7Smrg 76917a3b38f7Smrg if test -n "$convenience"; then 76927a3b38f7Smrg if test -z "$whole_archive_flag_spec"; then 76937a3b38f7Smrg func_show_eval '${RM}r "$gentop"' 7694ff559fabSmrg fi 7695ff559fabSmrg fi 7696ff559fabSmrg 76977a3b38f7Smrg exit $EXIT_SUCCESS 76987a3b38f7Smrg fi 7699ff559fabSmrg 77007a3b38f7Smrg # Create links to the real library. 77017a3b38f7Smrg for linkname in $linknames; do 77027a3b38f7Smrg if test "$realname" != "$linkname"; then 77037a3b38f7Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 77047a3b38f7Smrg fi 77057a3b38f7Smrg done 77067a3b38f7Smrg 77077a3b38f7Smrg # If -module or -export-dynamic was specified, set the dlname. 77087a3b38f7Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 77097a3b38f7Smrg # On all known operating systems, these are identical. 77107a3b38f7Smrg dlname="$soname" 77117a3b38f7Smrg fi 77127a3b38f7Smrg fi 77137a3b38f7Smrg ;; 77147a3b38f7Smrg 77157a3b38f7Smrg obj) 77167a3b38f7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 77177a3b38f7Smrg func_warning "\`-dlopen' is ignored for objects" 77187a3b38f7Smrg fi 77197a3b38f7Smrg 77207a3b38f7Smrg case " $deplibs" in 77217a3b38f7Smrg *\ -l* | *\ -L*) 77227a3b38f7Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 77237a3b38f7Smrg esac 77247a3b38f7Smrg 77257a3b38f7Smrg test -n "$rpath" && \ 77267a3b38f7Smrg func_warning "\`-rpath' is ignored for objects" 77277a3b38f7Smrg 77287a3b38f7Smrg test -n "$xrpath" && \ 77297a3b38f7Smrg func_warning "\`-R' is ignored for objects" 77307a3b38f7Smrg 77317a3b38f7Smrg test -n "$vinfo" && \ 77327a3b38f7Smrg func_warning "\`-version-info' is ignored for objects" 77337a3b38f7Smrg 77347a3b38f7Smrg test -n "$release" && \ 77357a3b38f7Smrg func_warning "\`-release' is ignored for objects" 77367a3b38f7Smrg 77377a3b38f7Smrg case $output in 77387a3b38f7Smrg *.lo) 77397a3b38f7Smrg test -n "$objs$old_deplibs" && \ 77407a3b38f7Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 77417a3b38f7Smrg 77427a3b38f7Smrg libobj=$output 77437a3b38f7Smrg func_lo2o "$libobj" 77447a3b38f7Smrg obj=$func_lo2o_result 77457a3b38f7Smrg ;; 77467a3b38f7Smrg *) 77477a3b38f7Smrg libobj= 77487a3b38f7Smrg obj="$output" 77497a3b38f7Smrg ;; 77507a3b38f7Smrg esac 77517a3b38f7Smrg 77527a3b38f7Smrg # Delete the old objects. 77537a3b38f7Smrg $opt_dry_run || $RM $obj $libobj 77547a3b38f7Smrg 77557a3b38f7Smrg # Objects from convenience libraries. This assumes 77567a3b38f7Smrg # single-version convenience libraries. Whenever we create 77577a3b38f7Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 77587a3b38f7Smrg # the extraction. 77597a3b38f7Smrg reload_conv_objs= 77607a3b38f7Smrg gentop= 77617a3b38f7Smrg # reload_cmds runs $LD directly, so let us get rid of 77627a3b38f7Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 77637a3b38f7Smrg # turning comma into space.. 77647a3b38f7Smrg wl= 77657a3b38f7Smrg 77667a3b38f7Smrg if test -n "$convenience"; then 77677a3b38f7Smrg if test -n "$whole_archive_flag_spec"; then 77687a3b38f7Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 776944dda7b2Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 77707a3b38f7Smrg else 77717a3b38f7Smrg gentop="$output_objdir/${obj}x" 77727a3b38f7Smrg generated="$generated $gentop" 77737a3b38f7Smrg 77747a3b38f7Smrg func_extract_archives $gentop $convenience 77757a3b38f7Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 77767a3b38f7Smrg fi 77777a3b38f7Smrg fi 7778ff559fabSmrg 77797a3b38f7Smrg # Create the old-style object. 778044dda7b2Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 7781ff559fabSmrg 77827a3b38f7Smrg output="$obj" 77837a3b38f7Smrg func_execute_cmds "$reload_cmds" 'exit $?' 7784ff559fabSmrg 77857a3b38f7Smrg # Exit if we aren't doing a library object file. 77867a3b38f7Smrg if test -z "$libobj"; then 77877a3b38f7Smrg if test -n "$gentop"; then 77887a3b38f7Smrg func_show_eval '${RM}r "$gentop"' 77897a3b38f7Smrg fi 7790ff559fabSmrg 77917a3b38f7Smrg exit $EXIT_SUCCESS 77927a3b38f7Smrg fi 7793ff559fabSmrg 77947a3b38f7Smrg if test "$build_libtool_libs" != yes; then 77957a3b38f7Smrg if test -n "$gentop"; then 77967a3b38f7Smrg func_show_eval '${RM}r "$gentop"' 77977a3b38f7Smrg fi 7798ff559fabSmrg 77997a3b38f7Smrg # Create an invalid libtool object if no PIC, so that we don't 78007a3b38f7Smrg # accidentally link it into a program. 78017a3b38f7Smrg # $show "echo timestamp > $libobj" 78027a3b38f7Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 78037a3b38f7Smrg exit $EXIT_SUCCESS 78047a3b38f7Smrg fi 7805ff559fabSmrg 78067a3b38f7Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 78077a3b38f7Smrg # Only do commands if we really have different PIC objects. 78087a3b38f7Smrg reload_objs="$libobjs $reload_conv_objs" 78097a3b38f7Smrg output="$libobj" 78107a3b38f7Smrg func_execute_cmds "$reload_cmds" 'exit $?' 7811ff559fabSmrg fi 7812ff559fabSmrg 78137a3b38f7Smrg if test -n "$gentop"; then 78147a3b38f7Smrg func_show_eval '${RM}r "$gentop"' 78157a3b38f7Smrg fi 7816ff559fabSmrg 78177a3b38f7Smrg exit $EXIT_SUCCESS 78187a3b38f7Smrg ;; 7819ff559fabSmrg 78207a3b38f7Smrg prog) 78217a3b38f7Smrg case $host in 78227a3b38f7Smrg *cygwin*) func_stripname '' '.exe' "$output" 78237a3b38f7Smrg output=$func_stripname_result.exe;; 7824ff559fabSmrg esac 78257a3b38f7Smrg test -n "$vinfo" && \ 78267a3b38f7Smrg func_warning "\`-version-info' is ignored for programs" 7827ff559fabSmrg 78287a3b38f7Smrg test -n "$release" && \ 78297a3b38f7Smrg func_warning "\`-release' is ignored for programs" 7830ff559fabSmrg 78317a3b38f7Smrg test "$preload" = yes \ 78327a3b38f7Smrg && test "$dlopen_support" = unknown \ 78337a3b38f7Smrg && test "$dlopen_self" = unknown \ 78347a3b38f7Smrg && test "$dlopen_self_static" = unknown && \ 78357a3b38f7Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 7836ff559fabSmrg 78377a3b38f7Smrg case $host in 78387a3b38f7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 78397a3b38f7Smrg # On Rhapsody replace the C library is the System framework 784044dda7b2Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 784144dda7b2Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 7842ff559fabSmrg ;; 7843ff559fabSmrg esac 7844ff559fabSmrg 78457a3b38f7Smrg case $host in 78467a3b38f7Smrg *-*-darwin*) 78477a3b38f7Smrg # Don't allow lazy linking, it breaks C++ global constructors 78487a3b38f7Smrg # But is supposedly fixed on 10.4 or later (yay!). 78497a3b38f7Smrg if test "$tagname" = CXX ; then 78507a3b38f7Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 78517a3b38f7Smrg 10.[0123]) 78527a3b38f7Smrg compile_command="$compile_command ${wl}-bind_at_load" 78537a3b38f7Smrg finalize_command="$finalize_command ${wl}-bind_at_load" 78547a3b38f7Smrg ;; 78557a3b38f7Smrg esac 78567a3b38f7Smrg fi 78577a3b38f7Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 785844dda7b2Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 785944dda7b2Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7860ff559fabSmrg ;; 7861ff559fabSmrg esac 7862ff559fabSmrg 7863ff559fabSmrg 78647a3b38f7Smrg # move library search paths that coincide with paths to not yet 78657a3b38f7Smrg # installed libraries to the beginning of the library search list 78667a3b38f7Smrg new_libs= 78677a3b38f7Smrg for path in $notinst_path; do 78687a3b38f7Smrg case " $new_libs " in 78697a3b38f7Smrg *" -L$path/$objdir "*) ;; 7870ff559fabSmrg *) 78717a3b38f7Smrg case " $compile_deplibs " in 78727a3b38f7Smrg *" -L$path/$objdir "*) 78737a3b38f7Smrg new_libs="$new_libs -L$path/$objdir" ;; 78747a3b38f7Smrg esac 7875ff559fabSmrg ;; 7876ff559fabSmrg esac 7877ff559fabSmrg done 78787a3b38f7Smrg for deplib in $compile_deplibs; do 78797a3b38f7Smrg case $deplib in 78807a3b38f7Smrg -L*) 78817a3b38f7Smrg case " $new_libs " in 78827a3b38f7Smrg *" $deplib "*) ;; 78837a3b38f7Smrg *) new_libs="$new_libs $deplib" ;; 78847a3b38f7Smrg esac 78857a3b38f7Smrg ;; 78867a3b38f7Smrg *) new_libs="$new_libs $deplib" ;; 78877a3b38f7Smrg esac 78887a3b38f7Smrg done 78897a3b38f7Smrg compile_deplibs="$new_libs" 7890ff559fabSmrg 7891ff559fabSmrg 78927a3b38f7Smrg compile_command="$compile_command $compile_deplibs" 78937a3b38f7Smrg finalize_command="$finalize_command $finalize_deplibs" 7894ff559fabSmrg 78957a3b38f7Smrg if test -n "$rpath$xrpath"; then 78967a3b38f7Smrg # If the user specified any rpath flags, then add them. 78977a3b38f7Smrg for libdir in $rpath $xrpath; do 78987a3b38f7Smrg # This is the magic to use -rpath. 78997a3b38f7Smrg case "$finalize_rpath " in 79007a3b38f7Smrg *" $libdir "*) ;; 79017a3b38f7Smrg *) finalize_rpath="$finalize_rpath $libdir" ;; 79027a3b38f7Smrg esac 79037a3b38f7Smrg done 79047a3b38f7Smrg fi 7905ff559fabSmrg 79067a3b38f7Smrg # Now hardcode the library paths 79077a3b38f7Smrg rpath= 79087a3b38f7Smrg hardcode_libdirs= 79097a3b38f7Smrg for libdir in $compile_rpath $finalize_rpath; do 79107a3b38f7Smrg if test -n "$hardcode_libdir_flag_spec"; then 79117a3b38f7Smrg if test -n "$hardcode_libdir_separator"; then 79127a3b38f7Smrg if test -z "$hardcode_libdirs"; then 79137a3b38f7Smrg hardcode_libdirs="$libdir" 79147a3b38f7Smrg else 79157a3b38f7Smrg # Just accumulate the unique libdirs. 79167a3b38f7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 79177a3b38f7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 79187a3b38f7Smrg ;; 79197a3b38f7Smrg *) 79207a3b38f7Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 79217a3b38f7Smrg ;; 79227a3b38f7Smrg esac 79237a3b38f7Smrg fi 79247a3b38f7Smrg else 79257a3b38f7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 79267a3b38f7Smrg rpath="$rpath $flag" 79277a3b38f7Smrg fi 79287a3b38f7Smrg elif test -n "$runpath_var"; then 79297a3b38f7Smrg case "$perm_rpath " in 7930ff559fabSmrg *" $libdir "*) ;; 79317a3b38f7Smrg *) perm_rpath="$perm_rpath $libdir" ;; 7932ff559fabSmrg esac 79337a3b38f7Smrg fi 79347a3b38f7Smrg case $host in 79357a3b38f7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 79367a3b38f7Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 79377a3b38f7Smrg case :$dllsearchpath: in 79387a3b38f7Smrg *":$libdir:"*) ;; 79397a3b38f7Smrg ::) dllsearchpath=$libdir;; 79407a3b38f7Smrg *) dllsearchpath="$dllsearchpath:$libdir";; 79417a3b38f7Smrg esac 79427a3b38f7Smrg case :$dllsearchpath: in 79437a3b38f7Smrg *":$testbindir:"*) ;; 79447a3b38f7Smrg ::) dllsearchpath=$testbindir;; 79457a3b38f7Smrg *) dllsearchpath="$dllsearchpath:$testbindir";; 79467a3b38f7Smrg esac 79477a3b38f7Smrg ;; 79487a3b38f7Smrg esac 79497a3b38f7Smrg done 79507a3b38f7Smrg # Substitute the hardcoded libdirs into the rpath. 79517a3b38f7Smrg if test -n "$hardcode_libdir_separator" && 79527a3b38f7Smrg test -n "$hardcode_libdirs"; then 79537a3b38f7Smrg libdir="$hardcode_libdirs" 79547a3b38f7Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 79557a3b38f7Smrg fi 79567a3b38f7Smrg compile_rpath="$rpath" 79577a3b38f7Smrg 79587a3b38f7Smrg rpath= 79597a3b38f7Smrg hardcode_libdirs= 79607a3b38f7Smrg for libdir in $finalize_rpath; do 79617a3b38f7Smrg if test -n "$hardcode_libdir_flag_spec"; then 79627a3b38f7Smrg if test -n "$hardcode_libdir_separator"; then 79637a3b38f7Smrg if test -z "$hardcode_libdirs"; then 79647a3b38f7Smrg hardcode_libdirs="$libdir" 79657a3b38f7Smrg else 79667a3b38f7Smrg # Just accumulate the unique libdirs. 79677a3b38f7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 79687a3b38f7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 79697a3b38f7Smrg ;; 79707a3b38f7Smrg *) 79717a3b38f7Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 79727a3b38f7Smrg ;; 79737a3b38f7Smrg esac 79747a3b38f7Smrg fi 79757a3b38f7Smrg else 79767a3b38f7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 79777a3b38f7Smrg rpath="$rpath $flag" 79787a3b38f7Smrg fi 79797a3b38f7Smrg elif test -n "$runpath_var"; then 79807a3b38f7Smrg case "$finalize_perm_rpath " in 7981ff559fabSmrg *" $libdir "*) ;; 79827a3b38f7Smrg *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; 7983ff559fabSmrg esac 7984ff559fabSmrg fi 79857a3b38f7Smrg done 79867a3b38f7Smrg # Substitute the hardcoded libdirs into the rpath. 79877a3b38f7Smrg if test -n "$hardcode_libdir_separator" && 79887a3b38f7Smrg test -n "$hardcode_libdirs"; then 79897a3b38f7Smrg libdir="$hardcode_libdirs" 79907a3b38f7Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 79917a3b38f7Smrg fi 79927a3b38f7Smrg finalize_rpath="$rpath" 7993ff559fabSmrg 79947a3b38f7Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 79957a3b38f7Smrg # Transform all the library objects into standard objects. 799644dda7b2Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 799744dda7b2Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 79987a3b38f7Smrg fi 7999ff559fabSmrg 80007a3b38f7Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8001ff559fabSmrg 80027a3b38f7Smrg # template prelinking step 80037a3b38f7Smrg if test -n "$prelink_cmds"; then 80047a3b38f7Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 80057a3b38f7Smrg fi 8006ff559fabSmrg 80077a3b38f7Smrg wrappers_required=yes 80087a3b38f7Smrg case $host in 800944dda7b2Smrg *cegcc* | *mingw32ce*) 801044dda7b2Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 801144dda7b2Smrg wrappers_required=no 801244dda7b2Smrg ;; 80137a3b38f7Smrg *cygwin* | *mingw* ) 80147a3b38f7Smrg if test "$build_libtool_libs" != yes; then 80157a3b38f7Smrg wrappers_required=no 80167a3b38f7Smrg fi 80177a3b38f7Smrg ;; 80187a3b38f7Smrg *) 80197a3b38f7Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 80207a3b38f7Smrg wrappers_required=no 80217a3b38f7Smrg fi 80227a3b38f7Smrg ;; 80237a3b38f7Smrg esac 80247a3b38f7Smrg if test "$wrappers_required" = no; then 80257a3b38f7Smrg # Replace the output file specification. 802644dda7b2Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 80277a3b38f7Smrg link_command="$compile_command$compile_rpath" 8028ff559fabSmrg 80297a3b38f7Smrg # We have no uninstalled library dependencies, so finalize right now. 80307a3b38f7Smrg exit_status=0 80317a3b38f7Smrg func_show_eval "$link_command" 'exit_status=$?' 8032ff559fabSmrg 80337a3b38f7Smrg # Delete the generated files. 80347a3b38f7Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 80357a3b38f7Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 80367a3b38f7Smrg fi 8037ff559fabSmrg 80387a3b38f7Smrg exit $exit_status 80397a3b38f7Smrg fi 8040ff559fabSmrg 80417a3b38f7Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 80427a3b38f7Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 80437a3b38f7Smrg fi 80447a3b38f7Smrg if test -n "$finalize_shlibpath"; then 80457a3b38f7Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 80467a3b38f7Smrg fi 8047ff559fabSmrg 80487a3b38f7Smrg compile_var= 80497a3b38f7Smrg finalize_var= 80507a3b38f7Smrg if test -n "$runpath_var"; then 80517a3b38f7Smrg if test -n "$perm_rpath"; then 80527a3b38f7Smrg # We should set the runpath_var. 80537a3b38f7Smrg rpath= 80547a3b38f7Smrg for dir in $perm_rpath; do 80557a3b38f7Smrg rpath="$rpath$dir:" 8056ff559fabSmrg done 80577a3b38f7Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8058ff559fabSmrg fi 80597a3b38f7Smrg if test -n "$finalize_perm_rpath"; then 80607a3b38f7Smrg # We should set the runpath_var. 80617a3b38f7Smrg rpath= 80627a3b38f7Smrg for dir in $finalize_perm_rpath; do 80637a3b38f7Smrg rpath="$rpath$dir:" 80647a3b38f7Smrg done 80657a3b38f7Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 80667a3b38f7Smrg fi 80677a3b38f7Smrg fi 8068ff559fabSmrg 80697a3b38f7Smrg if test "$no_install" = yes; then 80707a3b38f7Smrg # We don't need to create a wrapper script. 80717a3b38f7Smrg link_command="$compile_var$compile_command$compile_rpath" 80727a3b38f7Smrg # Replace the output file specification. 807344dda7b2Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 80747a3b38f7Smrg # Delete the old output file. 80757a3b38f7Smrg $opt_dry_run || $RM $output 80767a3b38f7Smrg # Link the executable and exit 80777a3b38f7Smrg func_show_eval "$link_command" 'exit $?' 80787a3b38f7Smrg exit $EXIT_SUCCESS 80797a3b38f7Smrg fi 8080ff559fabSmrg 80817a3b38f7Smrg if test "$hardcode_action" = relink; then 80827a3b38f7Smrg # Fast installation is not supported 80837a3b38f7Smrg link_command="$compile_var$compile_command$compile_rpath" 80847a3b38f7Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8085ff559fabSmrg 80867a3b38f7Smrg func_warning "this platform does not like uninstalled shared libraries" 80877a3b38f7Smrg func_warning "\`$output' will be relinked during installation" 80887a3b38f7Smrg else 80897a3b38f7Smrg if test "$fast_install" != no; then 80907a3b38f7Smrg link_command="$finalize_var$compile_command$finalize_rpath" 80917a3b38f7Smrg if test "$fast_install" = yes; then 809244dda7b2Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 80937a3b38f7Smrg else 80947a3b38f7Smrg # fast_install is set to needless 80957a3b38f7Smrg relink_command= 80967a3b38f7Smrg fi 8097ff559fabSmrg else 80987a3b38f7Smrg link_command="$compile_var$compile_command$compile_rpath" 80997a3b38f7Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8100ff559fabSmrg fi 81017a3b38f7Smrg fi 8102ff559fabSmrg 81037a3b38f7Smrg # Replace the output file specification. 810444dda7b2Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8105ff559fabSmrg 81067a3b38f7Smrg # Delete the old output files. 81077a3b38f7Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8108ff559fabSmrg 81097a3b38f7Smrg func_show_eval "$link_command" 'exit $?' 8110ff559fabSmrg 81117a3b38f7Smrg # Now create the wrapper script. 81127a3b38f7Smrg func_verbose "creating $output" 8113ff559fabSmrg 81147a3b38f7Smrg # Quote the relink command for shipping. 81157a3b38f7Smrg if test -n "$relink_command"; then 81167a3b38f7Smrg # Preserve any variables that may affect compiler behavior 81177a3b38f7Smrg for var in $variables_saved_for_relink; do 81187a3b38f7Smrg if eval test -z \"\${$var+set}\"; then 81197a3b38f7Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 81207a3b38f7Smrg elif eval var_value=\$$var; test -z "$var_value"; then 81217a3b38f7Smrg relink_command="$var=; export $var; $relink_command" 81227a3b38f7Smrg else 81237a3b38f7Smrg func_quote_for_eval "$var_value" 81247a3b38f7Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 81257a3b38f7Smrg fi 81267a3b38f7Smrg done 81277a3b38f7Smrg relink_command="(cd `pwd`; $relink_command)" 812844dda7b2Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 81297a3b38f7Smrg fi 8130ff559fabSmrg 81317a3b38f7Smrg # Only actually do things if not in dry run mode. 81327a3b38f7Smrg $opt_dry_run || { 81337a3b38f7Smrg # win32 will think the script is a binary if it has 81347a3b38f7Smrg # a .exe suffix, so we strip it off here. 81357a3b38f7Smrg case $output in 81367a3b38f7Smrg *.exe) func_stripname '' '.exe' "$output" 81377a3b38f7Smrg output=$func_stripname_result ;; 81387a3b38f7Smrg esac 81397a3b38f7Smrg # test for cygwin because mv fails w/o .exe extensions 8140ff559fabSmrg case $host in 81417a3b38f7Smrg *cygwin*) 81427a3b38f7Smrg exeext=.exe 81437a3b38f7Smrg func_stripname '' '.exe' "$outputname" 81447a3b38f7Smrg outputname=$func_stripname_result ;; 81457a3b38f7Smrg *) exeext= ;; 8146ff559fabSmrg esac 81477a3b38f7Smrg case $host in 81487a3b38f7Smrg *cygwin* | *mingw* ) 81497a3b38f7Smrg func_dirname_and_basename "$output" "" "." 81507a3b38f7Smrg output_name=$func_basename_result 81517a3b38f7Smrg output_path=$func_dirname_result 81527a3b38f7Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 81537a3b38f7Smrg cwrapper="$output_path/$output_name.exe" 81547a3b38f7Smrg $RM $cwrappersource $cwrapper 81557a3b38f7Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 81567a3b38f7Smrg 81577a3b38f7Smrg func_emit_cwrapperexe_src > $cwrappersource 81587a3b38f7Smrg 81597a3b38f7Smrg # The wrapper executable is built using the $host compiler, 81607a3b38f7Smrg # because it contains $host paths and files. If cross- 81617a3b38f7Smrg # compiling, it, like the target executable, must be 81627a3b38f7Smrg # executed on the $host or under an emulation environment. 81637a3b38f7Smrg $opt_dry_run || { 81647a3b38f7Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 81657a3b38f7Smrg $STRIP $cwrapper 81667a3b38f7Smrg } 8167ff559fabSmrg 81687a3b38f7Smrg # Now, create the wrapper script for func_source use: 81697a3b38f7Smrg func_ltwrapper_scriptname $cwrapper 81707a3b38f7Smrg $RM $func_ltwrapper_scriptname_result 81717a3b38f7Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 81727a3b38f7Smrg $opt_dry_run || { 81737a3b38f7Smrg # note: this script will not be executed, so do not chmod. 81747a3b38f7Smrg if test "x$build" = "x$host" ; then 81757a3b38f7Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 8176ff559fabSmrg else 81777a3b38f7Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 8178ff559fabSmrg fi 81797a3b38f7Smrg } 81807a3b38f7Smrg ;; 81817a3b38f7Smrg * ) 81827a3b38f7Smrg $RM $output 81837a3b38f7Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 8184ff559fabSmrg 81857a3b38f7Smrg func_emit_wrapper no > $output 81867a3b38f7Smrg chmod +x $output 8187ff559fabSmrg ;; 8188ff559fabSmrg esac 81897a3b38f7Smrg } 81907a3b38f7Smrg exit $EXIT_SUCCESS 81917a3b38f7Smrg ;; 81927a3b38f7Smrg esac 8193ff559fabSmrg 81947a3b38f7Smrg # See if we need to build an old-fashioned archive. 81957a3b38f7Smrg for oldlib in $oldlibs; do 8196ff559fabSmrg 81977a3b38f7Smrg if test "$build_libtool_libs" = convenience; then 81987a3b38f7Smrg oldobjs="$libobjs_save $symfileobj" 81997a3b38f7Smrg addlibs="$convenience" 82007a3b38f7Smrg build_libtool_libs=no 82017a3b38f7Smrg else 82027a3b38f7Smrg if test "$build_libtool_libs" = module; then 82037a3b38f7Smrg oldobjs="$libobjs_save" 82047a3b38f7Smrg build_libtool_libs=no 82057a3b38f7Smrg else 82067a3b38f7Smrg oldobjs="$old_deplibs $non_pic_objects" 82077a3b38f7Smrg if test "$preload" = yes && test -f "$symfileobj"; then 82087a3b38f7Smrg oldobjs="$oldobjs $symfileobj" 82097a3b38f7Smrg fi 82107a3b38f7Smrg fi 82117a3b38f7Smrg addlibs="$old_convenience" 8212ff559fabSmrg fi 8213ff559fabSmrg 82147a3b38f7Smrg if test -n "$addlibs"; then 82157a3b38f7Smrg gentop="$output_objdir/${outputname}x" 82167a3b38f7Smrg generated="$generated $gentop" 8217ff559fabSmrg 82187a3b38f7Smrg func_extract_archives $gentop $addlibs 82197a3b38f7Smrg oldobjs="$oldobjs $func_extract_archives_result" 82207a3b38f7Smrg fi 8221ff559fabSmrg 82227a3b38f7Smrg # Do each command in the archive commands. 82237a3b38f7Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 82247a3b38f7Smrg cmds=$old_archive_from_new_cmds 82257a3b38f7Smrg else 8226ff559fabSmrg 82277a3b38f7Smrg # Add any objects from preloaded convenience libraries 82287a3b38f7Smrg if test -n "$dlprefiles"; then 82297a3b38f7Smrg gentop="$output_objdir/${outputname}x" 82307a3b38f7Smrg generated="$generated $gentop" 8231ff559fabSmrg 82327a3b38f7Smrg func_extract_archives $gentop $dlprefiles 82337a3b38f7Smrg oldobjs="$oldobjs $func_extract_archives_result" 82347a3b38f7Smrg fi 8235ff559fabSmrg 82367a3b38f7Smrg # POSIX demands no paths to be encoded in archives. We have 82377a3b38f7Smrg # to avoid creating archives with duplicate basenames if we 82387a3b38f7Smrg # might have to extract them afterwards, e.g., when creating a 82397a3b38f7Smrg # static archive out of a convenience library, or when linking 82407a3b38f7Smrg # the entirety of a libtool archive into another (currently 82417a3b38f7Smrg # not supported by libtool). 82427a3b38f7Smrg if (for obj in $oldobjs 82437a3b38f7Smrg do 82447a3b38f7Smrg func_basename "$obj" 82457a3b38f7Smrg $ECHO "$func_basename_result" 82467a3b38f7Smrg done | sort | sort -uc >/dev/null 2>&1); then 82477a3b38f7Smrg : 82487a3b38f7Smrg else 824944dda7b2Smrg echo "copying selected object files to avoid basename conflicts..." 82507a3b38f7Smrg gentop="$output_objdir/${outputname}x" 82517a3b38f7Smrg generated="$generated $gentop" 82527a3b38f7Smrg func_mkdir_p "$gentop" 82537a3b38f7Smrg save_oldobjs=$oldobjs 82547a3b38f7Smrg oldobjs= 82557a3b38f7Smrg counter=1 82567a3b38f7Smrg for obj in $save_oldobjs 82577a3b38f7Smrg do 82587a3b38f7Smrg func_basename "$obj" 82597a3b38f7Smrg objbase="$func_basename_result" 82607a3b38f7Smrg case " $oldobjs " in 82617a3b38f7Smrg " ") oldobjs=$obj ;; 82627a3b38f7Smrg *[\ /]"$objbase "*) 82637a3b38f7Smrg while :; do 82647a3b38f7Smrg # Make sure we don't pick an alternate name that also 82657a3b38f7Smrg # overlaps. 82667a3b38f7Smrg newobj=lt$counter-$objbase 82677a3b38f7Smrg func_arith $counter + 1 82687a3b38f7Smrg counter=$func_arith_result 82697a3b38f7Smrg case " $oldobjs " in 82707a3b38f7Smrg *[\ /]"$newobj "*) ;; 82717a3b38f7Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 82727a3b38f7Smrg esac 82737a3b38f7Smrg done 82747a3b38f7Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 82757a3b38f7Smrg oldobjs="$oldobjs $gentop/$newobj" 82767a3b38f7Smrg ;; 82777a3b38f7Smrg *) oldobjs="$oldobjs $obj" ;; 82787a3b38f7Smrg esac 8279ff559fabSmrg done 8280ff559fabSmrg fi 82817a3b38f7Smrg eval cmds=\"$old_archive_cmds\" 8282ff559fabSmrg 82837a3b38f7Smrg func_len " $cmds" 82847a3b38f7Smrg len=$func_len_result 82857a3b38f7Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 82867a3b38f7Smrg cmds=$old_archive_cmds 82877a3b38f7Smrg else 82887a3b38f7Smrg # the command line is too long to link in one step, link in parts 82897a3b38f7Smrg func_verbose "using piecewise archive linking..." 82907a3b38f7Smrg save_RANLIB=$RANLIB 82917a3b38f7Smrg RANLIB=: 82927a3b38f7Smrg objlist= 82937a3b38f7Smrg concat_cmds= 82947a3b38f7Smrg save_oldobjs=$oldobjs 82957a3b38f7Smrg oldobjs= 82967a3b38f7Smrg # Is there a better way of finding the last object in the list? 82977a3b38f7Smrg for obj in $save_oldobjs 82987a3b38f7Smrg do 82997a3b38f7Smrg last_oldobj=$obj 83007a3b38f7Smrg done 83017a3b38f7Smrg eval test_cmds=\"$old_archive_cmds\" 83027a3b38f7Smrg func_len " $test_cmds" 83037a3b38f7Smrg len0=$func_len_result 83047a3b38f7Smrg len=$len0 83057a3b38f7Smrg for obj in $save_oldobjs 83067a3b38f7Smrg do 83077a3b38f7Smrg func_len " $obj" 83087a3b38f7Smrg func_arith $len + $func_len_result 83097a3b38f7Smrg len=$func_arith_result 83107a3b38f7Smrg func_append objlist " $obj" 83117a3b38f7Smrg if test "$len" -lt "$max_cmd_len"; then 83127a3b38f7Smrg : 83137a3b38f7Smrg else 83147a3b38f7Smrg # the above command should be used before it gets too long 83157a3b38f7Smrg oldobjs=$objlist 83167a3b38f7Smrg if test "$obj" = "$last_oldobj" ; then 83177a3b38f7Smrg RANLIB=$save_RANLIB 83187a3b38f7Smrg fi 83197a3b38f7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 83207a3b38f7Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 83217a3b38f7Smrg objlist= 83227a3b38f7Smrg len=$len0 83237a3b38f7Smrg fi 83247a3b38f7Smrg done 83257a3b38f7Smrg RANLIB=$save_RANLIB 83267a3b38f7Smrg oldobjs=$objlist 83277a3b38f7Smrg if test "X$oldobjs" = "X" ; then 83287a3b38f7Smrg eval cmds=\"\$concat_cmds\" 83297a3b38f7Smrg else 83307a3b38f7Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 83317a3b38f7Smrg fi 83327a3b38f7Smrg fi 83337a3b38f7Smrg fi 83347a3b38f7Smrg func_execute_cmds "$cmds" 'exit $?' 8335ff559fabSmrg done 8336ff559fabSmrg 83377a3b38f7Smrg test -n "$generated" && \ 83387a3b38f7Smrg func_show_eval "${RM}r$generated" 8339ff559fabSmrg 83407a3b38f7Smrg # Now create the libtool archive. 83417a3b38f7Smrg case $output in 83427a3b38f7Smrg *.la) 83437a3b38f7Smrg old_library= 83447a3b38f7Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 83457a3b38f7Smrg func_verbose "creating $output" 8346ff559fabSmrg 83477a3b38f7Smrg # Preserve any variables that may affect compiler behavior 83487a3b38f7Smrg for var in $variables_saved_for_relink; do 83497a3b38f7Smrg if eval test -z \"\${$var+set}\"; then 83507a3b38f7Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 83517a3b38f7Smrg elif eval var_value=\$$var; test -z "$var_value"; then 83527a3b38f7Smrg relink_command="$var=; export $var; $relink_command" 8353ff559fabSmrg else 83547a3b38f7Smrg func_quote_for_eval "$var_value" 83557a3b38f7Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 8356ff559fabSmrg fi 83577a3b38f7Smrg done 83587a3b38f7Smrg # Quote the link command for shipping. 83597a3b38f7Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 836044dda7b2Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 83617a3b38f7Smrg if test "$hardcode_automatic" = yes ; then 83627a3b38f7Smrg relink_command= 83637a3b38f7Smrg fi 8364ff559fabSmrg 83657a3b38f7Smrg # Only create the output if not a dry run. 83667a3b38f7Smrg $opt_dry_run || { 83677a3b38f7Smrg for installed in no yes; do 83687a3b38f7Smrg if test "$installed" = yes; then 83697a3b38f7Smrg if test -z "$install_libdir"; then 83707a3b38f7Smrg break 83717a3b38f7Smrg fi 83727a3b38f7Smrg output="$output_objdir/$outputname"i 83737a3b38f7Smrg # Replace all uninstalled libtool libraries with the installed ones 83747a3b38f7Smrg newdependency_libs= 83757a3b38f7Smrg for deplib in $dependency_libs; do 83767a3b38f7Smrg case $deplib in 83777a3b38f7Smrg *.la) 83787a3b38f7Smrg func_basename "$deplib" 83797a3b38f7Smrg name="$func_basename_result" 83807a3b38f7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 83817a3b38f7Smrg test -z "$libdir" && \ 83827a3b38f7Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 83837a3b38f7Smrg newdependency_libs="$newdependency_libs $libdir/$name" 83847a3b38f7Smrg ;; 83857a3b38f7Smrg *) newdependency_libs="$newdependency_libs $deplib" ;; 83867a3b38f7Smrg esac 83877a3b38f7Smrg done 83887a3b38f7Smrg dependency_libs="$newdependency_libs" 83897a3b38f7Smrg newdlfiles= 83907a3b38f7Smrg 83917a3b38f7Smrg for lib in $dlfiles; do 83927a3b38f7Smrg case $lib in 83937a3b38f7Smrg *.la) 83947a3b38f7Smrg func_basename "$lib" 83957a3b38f7Smrg name="$func_basename_result" 83967a3b38f7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 83977a3b38f7Smrg test -z "$libdir" && \ 83987a3b38f7Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 83997a3b38f7Smrg newdlfiles="$newdlfiles $libdir/$name" 84007a3b38f7Smrg ;; 84017a3b38f7Smrg *) newdlfiles="$newdlfiles $lib" ;; 84027a3b38f7Smrg esac 84037a3b38f7Smrg done 84047a3b38f7Smrg dlfiles="$newdlfiles" 84057a3b38f7Smrg newdlprefiles= 84067a3b38f7Smrg for lib in $dlprefiles; do 84077a3b38f7Smrg case $lib in 84087a3b38f7Smrg *.la) 84097a3b38f7Smrg # Only pass preopened files to the pseudo-archive (for 84107a3b38f7Smrg # eventual linking with the app. that links it) if we 84117a3b38f7Smrg # didn't already link the preopened objects directly into 84127a3b38f7Smrg # the library: 84137a3b38f7Smrg func_basename "$lib" 84147a3b38f7Smrg name="$func_basename_result" 84157a3b38f7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 84167a3b38f7Smrg test -z "$libdir" && \ 84177a3b38f7Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 84187a3b38f7Smrg newdlprefiles="$newdlprefiles $libdir/$name" 84197a3b38f7Smrg ;; 84207a3b38f7Smrg esac 84217a3b38f7Smrg done 84227a3b38f7Smrg dlprefiles="$newdlprefiles" 84237a3b38f7Smrg else 84247a3b38f7Smrg newdlfiles= 84257a3b38f7Smrg for lib in $dlfiles; do 84267a3b38f7Smrg case $lib in 84277a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 84287a3b38f7Smrg *) abs=`pwd`"/$lib" ;; 84297a3b38f7Smrg esac 84307a3b38f7Smrg newdlfiles="$newdlfiles $abs" 84317a3b38f7Smrg done 84327a3b38f7Smrg dlfiles="$newdlfiles" 84337a3b38f7Smrg newdlprefiles= 84347a3b38f7Smrg for lib in $dlprefiles; do 84357a3b38f7Smrg case $lib in 84367a3b38f7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 84377a3b38f7Smrg *) abs=`pwd`"/$lib" ;; 84387a3b38f7Smrg esac 84397a3b38f7Smrg newdlprefiles="$newdlprefiles $abs" 84407a3b38f7Smrg done 84417a3b38f7Smrg dlprefiles="$newdlprefiles" 84427a3b38f7Smrg fi 84437a3b38f7Smrg $RM $output 84447a3b38f7Smrg # place dlname in correct position for cygwin 844544dda7b2Smrg # In fact, it would be nice if we could use this code for all target 844644dda7b2Smrg # systems that can't hard-code library paths into their executables 844744dda7b2Smrg # and that have no shared library path variable independent of PATH, 844844dda7b2Smrg # but it turns out we can't easily determine that from inspecting 844944dda7b2Smrg # libtool variables, so we have to hard-code the OSs to which it 845044dda7b2Smrg # applies here; at the moment, that means platforms that use the PE 845144dda7b2Smrg # object format with DLL files. See the long comment at the top of 845244dda7b2Smrg # tests/bindir.at for full details. 84537a3b38f7Smrg tdlname=$dlname 84547a3b38f7Smrg case $host,$output,$installed,$module,$dlname in 845544dda7b2Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 845644dda7b2Smrg # If a -bindir argument was supplied, place the dll there. 845744dda7b2Smrg if test "x$bindir" != x ; 845844dda7b2Smrg then 845944dda7b2Smrg func_relative_path "$install_libdir" "$bindir" 846044dda7b2Smrg tdlname=$func_relative_path_result$dlname 846144dda7b2Smrg else 846244dda7b2Smrg # Otherwise fall back on heuristic. 846344dda7b2Smrg tdlname=../bin/$dlname 846444dda7b2Smrg fi 846544dda7b2Smrg ;; 84667a3b38f7Smrg esac 84677a3b38f7Smrg $ECHO > $output "\ 84687a3b38f7Smrg# $outputname - a libtool library file 84697a3b38f7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 84707a3b38f7Smrg# 84717a3b38f7Smrg# Please DO NOT delete this file! 84727a3b38f7Smrg# It is necessary for linking the library. 8473ff559fabSmrg 84747a3b38f7Smrg# The name that we can dlopen(3). 84757a3b38f7Smrgdlname='$tdlname' 8476ff559fabSmrg 84777a3b38f7Smrg# Names of this library. 84787a3b38f7Smrglibrary_names='$library_names' 8479ff559fabSmrg 84807a3b38f7Smrg# The name of the static archive. 84817a3b38f7Smrgold_library='$old_library' 8482ff559fabSmrg 84837a3b38f7Smrg# Linker flags that can not go in dependency_libs. 84847a3b38f7Smrginherited_linker_flags='$new_inherited_linker_flags' 8485ff559fabSmrg 84867a3b38f7Smrg# Libraries that this one depends upon. 84877a3b38f7Smrgdependency_libs='$dependency_libs' 8488ff559fabSmrg 84897a3b38f7Smrg# Names of additional weak libraries provided by this library 84907a3b38f7Smrgweak_library_names='$weak_libs' 8491ff559fabSmrg 84927a3b38f7Smrg# Version information for $libname. 84937a3b38f7Smrgcurrent=$current 84947a3b38f7Smrgage=$age 84957a3b38f7Smrgrevision=$revision 8496ff559fabSmrg 84977a3b38f7Smrg# Is this an already installed library? 84987a3b38f7Smrginstalled=$installed 8499ff559fabSmrg 85007a3b38f7Smrg# Should we warn about portability when linking against -modules? 85017a3b38f7Smrgshouldnotlink=$module 8502ff559fabSmrg 85037a3b38f7Smrg# Files to dlopen/dlpreopen 85047a3b38f7Smrgdlopen='$dlfiles' 85057a3b38f7Smrgdlpreopen='$dlprefiles' 8506ff559fabSmrg 85077a3b38f7Smrg# Directory that this library needs to be installed in: 85087a3b38f7Smrglibdir='$install_libdir'" 85097a3b38f7Smrg if test "$installed" = no && test "$need_relink" = yes; then 85107a3b38f7Smrg $ECHO >> $output "\ 85117a3b38f7Smrgrelink_command=\"$relink_command\"" 85127a3b38f7Smrg fi 85137a3b38f7Smrg done 85147a3b38f7Smrg } 8515ff559fabSmrg 85167a3b38f7Smrg # Do a symbolic link so that the libtool archive can be found in 85177a3b38f7Smrg # LD_LIBRARY_PATH before the program is installed. 85187a3b38f7Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 85197a3b38f7Smrg ;; 85207a3b38f7Smrg esac 85217a3b38f7Smrg exit $EXIT_SUCCESS 85227a3b38f7Smrg} 8523ff559fabSmrg 85247a3b38f7Smrg{ test "$mode" = link || test "$mode" = relink; } && 85257a3b38f7Smrg func_mode_link ${1+"$@"} 8526ff559fabSmrg 8527ff559fabSmrg 85287a3b38f7Smrg# func_mode_uninstall arg... 85297a3b38f7Smrgfunc_mode_uninstall () 85307a3b38f7Smrg{ 85317a3b38f7Smrg $opt_debug 85327a3b38f7Smrg RM="$nonopt" 8533ff559fabSmrg files= 8534ff559fabSmrg rmforce= 8535ff559fabSmrg exit_status=0 8536ff559fabSmrg 8537ff559fabSmrg # This variable tells wrapper scripts just to set variables rather 8538ff559fabSmrg # than running their programs. 8539ff559fabSmrg libtool_install_magic="$magic" 8540ff559fabSmrg 8541ff559fabSmrg for arg 8542ff559fabSmrg do 8543ff559fabSmrg case $arg in 85447a3b38f7Smrg -f) RM="$RM $arg"; rmforce=yes ;; 85457a3b38f7Smrg -*) RM="$RM $arg" ;; 8546ff559fabSmrg *) files="$files $arg" ;; 8547ff559fabSmrg esac 8548ff559fabSmrg done 8549ff559fabSmrg 85507a3b38f7Smrg test -z "$RM" && \ 85517a3b38f7Smrg func_fatal_help "you must specify an RM program" 8552ff559fabSmrg 8553ff559fabSmrg rmdirs= 8554ff559fabSmrg 8555ff559fabSmrg origobjdir="$objdir" 8556ff559fabSmrg for file in $files; do 85577a3b38f7Smrg func_dirname "$file" "" "." 85587a3b38f7Smrg dir="$func_dirname_result" 85597a3b38f7Smrg if test "X$dir" = X.; then 8560ff559fabSmrg objdir="$origobjdir" 8561ff559fabSmrg else 8562ff559fabSmrg objdir="$dir/$origobjdir" 8563ff559fabSmrg fi 85647a3b38f7Smrg func_basename "$file" 85657a3b38f7Smrg name="$func_basename_result" 8566ff559fabSmrg test "$mode" = uninstall && objdir="$dir" 8567ff559fabSmrg 8568ff559fabSmrg # Remember objdir for removal later, being careful to avoid duplicates 8569ff559fabSmrg if test "$mode" = clean; then 8570ff559fabSmrg case " $rmdirs " in 8571ff559fabSmrg *" $objdir "*) ;; 8572ff559fabSmrg *) rmdirs="$rmdirs $objdir" ;; 8573ff559fabSmrg esac 8574ff559fabSmrg fi 8575ff559fabSmrg 8576ff559fabSmrg # Don't error if the file doesn't exist and rm -f was used. 85777a3b38f7Smrg if { test -L "$file"; } >/dev/null 2>&1 || 85787a3b38f7Smrg { test -h "$file"; } >/dev/null 2>&1 || 85797a3b38f7Smrg test -f "$file"; then 8580ff559fabSmrg : 8581ff559fabSmrg elif test -d "$file"; then 8582ff559fabSmrg exit_status=1 8583ff559fabSmrg continue 8584ff559fabSmrg elif test "$rmforce" = yes; then 8585ff559fabSmrg continue 8586ff559fabSmrg fi 8587ff559fabSmrg 8588ff559fabSmrg rmfiles="$file" 8589ff559fabSmrg 8590ff559fabSmrg case $name in 8591ff559fabSmrg *.la) 8592ff559fabSmrg # Possibly a libtool archive, so verify it. 85937a3b38f7Smrg if func_lalib_p "$file"; then 85947a3b38f7Smrg func_source $dir/$name 8595ff559fabSmrg 8596ff559fabSmrg # Delete the libtool libraries and symlinks. 8597ff559fabSmrg for n in $library_names; do 8598ff559fabSmrg rmfiles="$rmfiles $objdir/$n" 8599ff559fabSmrg done 8600ff559fabSmrg test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" 8601ff559fabSmrg 8602ff559fabSmrg case "$mode" in 8603ff559fabSmrg clean) 8604ff559fabSmrg case " $library_names " in 8605ff559fabSmrg # " " in the beginning catches empty $dlname 8606ff559fabSmrg *" $dlname "*) ;; 8607ff559fabSmrg *) rmfiles="$rmfiles $objdir/$dlname" ;; 8608ff559fabSmrg esac 86097a3b38f7Smrg test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" 8610ff559fabSmrg ;; 8611ff559fabSmrg uninstall) 8612ff559fabSmrg if test -n "$library_names"; then 8613ff559fabSmrg # Do each command in the postuninstall commands. 86147a3b38f7Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 8615ff559fabSmrg fi 8616ff559fabSmrg 8617ff559fabSmrg if test -n "$old_library"; then 8618ff559fabSmrg # Do each command in the old_postuninstall commands. 86197a3b38f7Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 8620ff559fabSmrg fi 8621ff559fabSmrg # FIXME: should reinstall the best remaining shared library. 8622ff559fabSmrg ;; 8623ff559fabSmrg esac 8624ff559fabSmrg fi 8625ff559fabSmrg ;; 8626ff559fabSmrg 8627ff559fabSmrg *.lo) 8628ff559fabSmrg # Possibly a libtool object, so verify it. 86297a3b38f7Smrg if func_lalib_p "$file"; then 8630ff559fabSmrg 8631ff559fabSmrg # Read the .lo file 86327a3b38f7Smrg func_source $dir/$name 8633ff559fabSmrg 8634ff559fabSmrg # Add PIC object to the list of files to remove. 86357a3b38f7Smrg if test -n "$pic_object" && 86367a3b38f7Smrg test "$pic_object" != none; then 8637ff559fabSmrg rmfiles="$rmfiles $dir/$pic_object" 8638ff559fabSmrg fi 8639ff559fabSmrg 8640ff559fabSmrg # Add non-PIC object to the list of files to remove. 86417a3b38f7Smrg if test -n "$non_pic_object" && 86427a3b38f7Smrg test "$non_pic_object" != none; then 8643ff559fabSmrg rmfiles="$rmfiles $dir/$non_pic_object" 8644ff559fabSmrg fi 8645ff559fabSmrg fi 8646ff559fabSmrg ;; 8647ff559fabSmrg 8648ff559fabSmrg *) 8649ff559fabSmrg if test "$mode" = clean ; then 8650ff559fabSmrg noexename=$name 8651ff559fabSmrg case $file in 8652ff559fabSmrg *.exe) 86537a3b38f7Smrg func_stripname '' '.exe' "$file" 86547a3b38f7Smrg file=$func_stripname_result 86557a3b38f7Smrg func_stripname '' '.exe' "$name" 86567a3b38f7Smrg noexename=$func_stripname_result 8657ff559fabSmrg # $file with .exe has already been added to rmfiles, 8658ff559fabSmrg # add $file without .exe 8659ff559fabSmrg rmfiles="$rmfiles $file" 8660ff559fabSmrg ;; 8661ff559fabSmrg esac 8662ff559fabSmrg # Do a test to see if this is a libtool program. 86637a3b38f7Smrg if func_ltwrapper_p "$file"; then 86647a3b38f7Smrg if func_ltwrapper_executable_p "$file"; then 86657a3b38f7Smrg func_ltwrapper_scriptname "$file" 86667a3b38f7Smrg relink_command= 86677a3b38f7Smrg func_source $func_ltwrapper_scriptname_result 86687a3b38f7Smrg rmfiles="$rmfiles $func_ltwrapper_scriptname_result" 86697a3b38f7Smrg else 86707a3b38f7Smrg relink_command= 86717a3b38f7Smrg func_source $dir/$noexename 86727a3b38f7Smrg fi 8673ff559fabSmrg 8674ff559fabSmrg # note $name still contains .exe if it was in $file originally 8675ff559fabSmrg # as does the version of $file that was added into $rmfiles 8676ff559fabSmrg rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" 8677ff559fabSmrg if test "$fast_install" = yes && test -n "$relink_command"; then 8678ff559fabSmrg rmfiles="$rmfiles $objdir/lt-$name" 8679ff559fabSmrg fi 8680ff559fabSmrg if test "X$noexename" != "X$name" ; then 8681ff559fabSmrg rmfiles="$rmfiles $objdir/lt-${noexename}.c" 8682ff559fabSmrg fi 8683ff559fabSmrg fi 8684ff559fabSmrg fi 8685ff559fabSmrg ;; 8686ff559fabSmrg esac 86877a3b38f7Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 8688ff559fabSmrg done 8689ff559fabSmrg objdir="$origobjdir" 8690ff559fabSmrg 8691ff559fabSmrg # Try to remove the ${objdir}s in the directories where we deleted files 8692ff559fabSmrg for dir in $rmdirs; do 8693ff559fabSmrg if test -d "$dir"; then 86947a3b38f7Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 8695ff559fabSmrg fi 8696ff559fabSmrg done 8697ff559fabSmrg 8698ff559fabSmrg exit $exit_status 86997a3b38f7Smrg} 8700ff559fabSmrg 87017a3b38f7Smrg{ test "$mode" = uninstall || test "$mode" = clean; } && 87027a3b38f7Smrg func_mode_uninstall ${1+"$@"} 8703ff559fabSmrg 87047a3b38f7Smrgtest -z "$mode" && { 87057a3b38f7Smrg help="$generic_help" 87067a3b38f7Smrg func_fatal_help "you must specify a MODE" 87077a3b38f7Smrg} 87087a3b38f7Smrg 87097a3b38f7Smrgtest -z "$exec_cmd" && \ 87107a3b38f7Smrg func_fatal_help "invalid operation mode \`$mode'" 8711ff559fabSmrg 8712ff559fabSmrgif test -n "$exec_cmd"; then 87137a3b38f7Smrg eval exec "$exec_cmd" 8714ff559fabSmrg exit $EXIT_FAILURE 8715ff559fabSmrgfi 8716ff559fabSmrg 87177a3b38f7Smrgexit $exit_status 8718ff559fabSmrg 8719ff559fabSmrg 8720ff559fabSmrg# The TAGs below are defined such that we never get into a situation 8721ff559fabSmrg# in which we disable both kinds of libraries. Given conflicting 8722ff559fabSmrg# choices, we go for a static library, that is the most portable, 8723ff559fabSmrg# since we can't tell whether shared libraries were disabled because 8724ff559fabSmrg# the user asked for that or because the platform doesn't support 8725ff559fabSmrg# them. This is particularly important on AIX, because we don't 8726ff559fabSmrg# support having both static and shared libraries enabled at the same 8727ff559fabSmrg# time on that platform, so we default to a shared-only configuration. 8728ff559fabSmrg# If a disable-shared tag is given, we'll fallback to a static-only 8729ff559fabSmrg# configuration. But we'll never go from static-only to shared-only. 8730ff559fabSmrg 8731ff559fabSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 87327a3b38f7Smrgbuild_libtool_libs=no 87337a3b38f7Smrgbuild_old_libs=yes 8734ff559fabSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 8735ff559fabSmrg 8736ff559fabSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 87377a3b38f7Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 8738ff559fabSmrg# ### END LIBTOOL TAG CONFIG: disable-static 8739ff559fabSmrg 8740ff559fabSmrg# Local Variables: 8741ff559fabSmrg# mode:shell-script 8742ff559fabSmrg# sh-indentation:2 8743ff559fabSmrg# End: 87447a3b38f7Smrg# vi:sw=2 87457a3b38f7Smrg 8746