ltmain.sh revision 06f32fbe
1ea133fd7Smrg 206f32fbeSmrg# libtool (GNU libtool) 2.4 3ea133fd7Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 4ea133fd7Smrg 525b89263Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 625b89263Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 7ea133fd7Smrg# This is free software; see the source for copying conditions. There is NO 8ea133fd7Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9ea133fd7Smrg 10ea133fd7Smrg# GNU Libtool is free software; you can redistribute it and/or modify 11a253d6aeSmrg# it under the terms of the GNU General Public License as published by 12a253d6aeSmrg# the Free Software Foundation; either version 2 of the License, or 13a253d6aeSmrg# (at your option) any later version. 14a253d6aeSmrg# 15ea133fd7Smrg# As a special exception to the GNU General Public License, 16ea133fd7Smrg# if you distribute this file as part of a program or library that 17ea133fd7Smrg# is built using GNU Libtool, you may include this file under the 18ea133fd7Smrg# same distribution terms that you use for the rest of that program. 19ea133fd7Smrg# 20ea133fd7Smrg# GNU Libtool is distributed in the hope that it will be useful, but 21a253d6aeSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 22a253d6aeSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23a253d6aeSmrg# General Public License for more details. 24a253d6aeSmrg# 25a253d6aeSmrg# You should have received a copy of the GNU General Public License 26ea133fd7Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 27ea133fd7Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 28ea133fd7Smrg# or obtained by writing to the Free Software Foundation, Inc., 29ea133fd7Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30ea133fd7Smrg 31ea133fd7Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 32ea133fd7Smrg# 33ea133fd7Smrg# Provide generalized library-building support services. 34a253d6aeSmrg# 3525b89263Smrg# --config show all configuration variables 3625b89263Smrg# --debug enable verbose shell tracing 3725b89263Smrg# -n, --dry-run display commands without modifying any files 3825b89263Smrg# --features display basic configuration information and exit 3925b89263Smrg# --mode=MODE use operation mode MODE 4025b89263Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 4125b89263Smrg# --quiet, --silent don't print informational messages 4225b89263Smrg# --no-quiet, --no-silent 4325b89263Smrg# print informational messages (default) 4425b89263Smrg# --tag=TAG use configuration variables from tag TAG 4525b89263Smrg# -v, --verbose print more informational messages than default 4625b89263Smrg# --no-verbose don't print the extra informational messages 4725b89263Smrg# --version print version information 4825b89263Smrg# -h, --help, --help-all print short, long, or detailed help message 49ea133fd7Smrg# 50ea133fd7Smrg# MODE must be one of the following: 51ea133fd7Smrg# 5225b89263Smrg# clean remove files from the build directory 5325b89263Smrg# compile compile a source file into a libtool object 5425b89263Smrg# execute automatically set library path, then run a program 5525b89263Smrg# finish complete the installation of libtool libraries 5625b89263Smrg# install install libraries or executables 5725b89263Smrg# link create a library or an executable 5825b89263Smrg# uninstall remove libraries from an installed directory 59ea133fd7Smrg# 6025b89263Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 6125b89263Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 62ea133fd7Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 63ea133fd7Smrg# 64ea133fd7Smrg# When reporting a bug, please describe a test case to reproduce it and 65ea133fd7Smrg# include the following information: 66ea133fd7Smrg# 6725b89263Smrg# host-triplet: $host 6825b89263Smrg# shell: $SHELL 6925b89263Smrg# compiler: $LTCC 7025b89263Smrg# compiler flags: $LTCFLAGS 7125b89263Smrg# linker: $LD (gnu? $with_gnu_ld) 7206f32fbeSmrg# $progname: (GNU libtool) 2.4 7325b89263Smrg# automake: $automake_version 7425b89263Smrg# autoconf: $autoconf_version 75ea133fd7Smrg# 76ea133fd7Smrg# Report bugs to <bug-libtool@gnu.org>. 7706f32fbeSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 7806f32fbeSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 79ea133fd7Smrg 8025b89263SmrgPROGRAM=libtool 81ea133fd7SmrgPACKAGE=libtool 8206f32fbeSmrgVERSION=2.4 83ea133fd7SmrgTIMESTAMP="" 8406f32fbeSmrgpackage_revision=1.3293 85ea133fd7Smrg 86ea133fd7Smrg# Be Bourne compatible 87ea133fd7Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 88ea133fd7Smrg emulate sh 89ea133fd7Smrg NULLCMD=: 90ea133fd7Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 91ea133fd7Smrg # is contrary to our usage. Disable this feature. 92ea133fd7Smrg alias -g '${1+"$@"}'='"$@"' 93ea133fd7Smrg setopt NO_GLOB_SUBST 94ea133fd7Smrgelse 95ea133fd7Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 96ea133fd7Smrgfi 97ea133fd7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 98ea133fd7SmrgDUALCASE=1; export DUALCASE # for MKS sh 99ea133fd7Smrg 10025b89263Smrg# A function that is used when there is no print builtin or printf. 10125b89263Smrgfunc_fallback_echo () 10225b89263Smrg{ 10325b89263Smrg eval 'cat <<_LTECHO_EOF 10425b89263Smrg$1 10525b89263Smrg_LTECHO_EOF' 10625b89263Smrg} 10725b89263Smrg 108ea133fd7Smrg# NLS nuisances: We save the old values to restore during execute mode. 109ea133fd7Smrglt_user_locale= 110ea133fd7Smrglt_safe_locale= 111ea133fd7Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 112ea133fd7Smrgdo 113ea133fd7Smrg eval "if test \"\${$lt_var+set}\" = set; then 114ea133fd7Smrg save_$lt_var=\$$lt_var 115ea133fd7Smrg $lt_var=C 116ea133fd7Smrg export $lt_var 117ea133fd7Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 118ea133fd7Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 119ea133fd7Smrg fi" 120ea133fd7Smrgdone 12125b89263SmrgLC_ALL=C 12225b89263SmrgLANGUAGE=C 12325b89263Smrgexport LANGUAGE LC_ALL 124ea133fd7Smrg 125ea133fd7Smrg$lt_unset CDPATH 126ea133fd7Smrg 127ea133fd7Smrg 12825b89263Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 12925b89263Smrg# is ksh but when the shell is invoked as "sh" and the current value of 13025b89263Smrg# the _XPG environment variable is not equal to 1 (one), the special 13125b89263Smrg# positional parameter $0, within a function call, is the name of the 13225b89263Smrg# function. 13325b89263Smrgprogpath="$0" 134ea133fd7Smrg 135ea133fd7Smrg 136ea133fd7Smrg 137ea133fd7Smrg: ${CP="cp -f"} 13825b89263Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 13925b89263Smrg: ${EGREP="grep -E"} 14025b89263Smrg: ${FGREP="grep -F"} 14125b89263Smrg: ${GREP="grep"} 142ea133fd7Smrg: ${LN_S="ln -s"} 143ea133fd7Smrg: ${MAKE="make"} 144ea133fd7Smrg: ${MKDIR="mkdir"} 145ea133fd7Smrg: ${MV="mv -f"} 146ea133fd7Smrg: ${RM="rm -f"} 14725b89263Smrg: ${SED="sed"} 148ea133fd7Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 149ea133fd7Smrg: ${Xsed="$SED -e 1s/^X//"} 150a253d6aeSmrg 151ea133fd7Smrg# Global variables: 152ea133fd7SmrgEXIT_SUCCESS=0 153ea133fd7SmrgEXIT_FAILURE=1 154ea133fd7SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 155ea133fd7SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 156ea133fd7Smrg 157ea133fd7Smrgexit_status=$EXIT_SUCCESS 158ea133fd7Smrg 159ea133fd7Smrg# Make sure IFS has a sensible default 160ea133fd7Smrglt_nl=' 161ea133fd7Smrg' 162ea133fd7SmrgIFS=" $lt_nl" 163ea133fd7Smrg 164ea133fd7Smrgdirname="s,/[^/]*$,," 165ea133fd7Smrgbasename="s,^.*/,," 166ea133fd7Smrg 16706f32fbeSmrg# func_dirname file append nondir_replacement 16806f32fbeSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 16906f32fbeSmrg# otherwise set result to NONDIR_REPLACEMENT. 17006f32fbeSmrgfunc_dirname () 17106f32fbeSmrg{ 17206f32fbeSmrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 17306f32fbeSmrg if test "X$func_dirname_result" = "X${1}"; then 17406f32fbeSmrg func_dirname_result="${3}" 17506f32fbeSmrg else 17606f32fbeSmrg func_dirname_result="$func_dirname_result${2}" 17706f32fbeSmrg fi 17806f32fbeSmrg} # func_dirname may be replaced by extended shell implementation 17906f32fbeSmrg 18006f32fbeSmrg 18106f32fbeSmrg# func_basename file 18206f32fbeSmrgfunc_basename () 18306f32fbeSmrg{ 18406f32fbeSmrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 18506f32fbeSmrg} # func_basename may be replaced by extended shell implementation 18606f32fbeSmrg 18706f32fbeSmrg 188ea133fd7Smrg# func_dirname_and_basename file append nondir_replacement 189ea133fd7Smrg# perform func_basename and func_dirname in a single function 190ea133fd7Smrg# call: 191ea133fd7Smrg# dirname: Compute the dirname of FILE. If nonempty, 192ea133fd7Smrg# add APPEND to the result, otherwise set result 193ea133fd7Smrg# to NONDIR_REPLACEMENT. 194ea133fd7Smrg# value returned in "$func_dirname_result" 195ea133fd7Smrg# basename: Compute filename of FILE. 196ea133fd7Smrg# value retuned in "$func_basename_result" 197ea133fd7Smrg# Implementation must be kept synchronized with func_dirname 198ea133fd7Smrg# and func_basename. For efficiency, we do not delegate to 199ea133fd7Smrg# those functions but instead duplicate the functionality here. 200ea133fd7Smrgfunc_dirname_and_basename () 201ea133fd7Smrg{ 20206f32fbeSmrg # Extract subdirectory from the argument. 20306f32fbeSmrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 20406f32fbeSmrg if test "X$func_dirname_result" = "X${1}"; then 20506f32fbeSmrg func_dirname_result="${3}" 20606f32fbeSmrg else 20706f32fbeSmrg func_dirname_result="$func_dirname_result${2}" 20806f32fbeSmrg fi 20906f32fbeSmrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 21006f32fbeSmrg} # func_dirname_and_basename may be replaced by extended shell implementation 21106f32fbeSmrg 21206f32fbeSmrg 21306f32fbeSmrg# func_stripname prefix suffix name 21406f32fbeSmrg# strip PREFIX and SUFFIX off of NAME. 21506f32fbeSmrg# PREFIX and SUFFIX must not contain globbing or regex special 21606f32fbeSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 21706f32fbeSmrg# dot (in which case that matches only a dot). 21806f32fbeSmrg# func_strip_suffix prefix name 21906f32fbeSmrgfunc_stripname () 22006f32fbeSmrg{ 22106f32fbeSmrg case ${2} in 22206f32fbeSmrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 22306f32fbeSmrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 22406f32fbeSmrg esac 22506f32fbeSmrg} # func_stripname may be replaced by extended shell implementation 226ea133fd7Smrg 227a253d6aeSmrg 22825b89263Smrg# These SED scripts presuppose an absolute path with a trailing slash. 22925b89263Smrgpathcar='s,^/\([^/]*\).*$,\1,' 23025b89263Smrgpathcdr='s,^/[^/]*,,' 23125b89263Smrgremovedotparts=':dotsl 23225b89263Smrg s@/\./@/@g 23325b89263Smrg t dotsl 23425b89263Smrg s,/\.$,/,' 23525b89263Smrgcollapseslashes='s@/\{1,\}@/@g' 23625b89263Smrgfinalslash='s,/*$,/,' 23725b89263Smrg 23825b89263Smrg# func_normal_abspath PATH 23925b89263Smrg# Remove doubled-up and trailing slashes, "." path components, 24025b89263Smrg# and cancel out any ".." path components in PATH after making 24125b89263Smrg# it an absolute path. 24225b89263Smrg# value returned in "$func_normal_abspath_result" 24325b89263Smrgfunc_normal_abspath () 24425b89263Smrg{ 24525b89263Smrg # Start from root dir and reassemble the path. 24625b89263Smrg func_normal_abspath_result= 24725b89263Smrg func_normal_abspath_tpath=$1 24825b89263Smrg func_normal_abspath_altnamespace= 24925b89263Smrg case $func_normal_abspath_tpath in 25025b89263Smrg "") 25125b89263Smrg # Empty path, that just means $cwd. 25225b89263Smrg func_stripname '' '/' "`pwd`" 25325b89263Smrg func_normal_abspath_result=$func_stripname_result 25425b89263Smrg return 25525b89263Smrg ;; 25625b89263Smrg # The next three entries are used to spot a run of precisely 25725b89263Smrg # two leading slashes without using negated character classes; 25825b89263Smrg # we take advantage of case's first-match behaviour. 25925b89263Smrg ///*) 26025b89263Smrg # Unusual form of absolute path, do nothing. 26125b89263Smrg ;; 26225b89263Smrg //*) 26325b89263Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 26425b89263Smrg # and for example Cygwin uses it to access remote file shares 26525b89263Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 26625b89263Smrg func_normal_abspath_altnamespace=/ 26725b89263Smrg ;; 26825b89263Smrg /*) 26925b89263Smrg # Absolute path, do nothing. 27025b89263Smrg ;; 27125b89263Smrg *) 27225b89263Smrg # Relative path, prepend $cwd. 27325b89263Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 27425b89263Smrg ;; 27525b89263Smrg esac 27625b89263Smrg # Cancel out all the simple stuff to save iterations. We also want 27725b89263Smrg # the path to end with a slash for ease of parsing, so make sure 27825b89263Smrg # there is one (and only one) here. 27925b89263Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 28025b89263Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 28125b89263Smrg while :; do 28225b89263Smrg # Processed it all yet? 28325b89263Smrg if test "$func_normal_abspath_tpath" = / ; then 28425b89263Smrg # If we ascended to the root using ".." the result may be empty now. 28525b89263Smrg if test -z "$func_normal_abspath_result" ; then 28625b89263Smrg func_normal_abspath_result=/ 28725b89263Smrg fi 28825b89263Smrg break 28925b89263Smrg fi 29025b89263Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 29125b89263Smrg -e "$pathcar"` 29225b89263Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 29325b89263Smrg -e "$pathcdr"` 29425b89263Smrg # Figure out what to do with it 29525b89263Smrg case $func_normal_abspath_tcomponent in 29625b89263Smrg "") 29725b89263Smrg # Trailing empty path component, ignore it. 29825b89263Smrg ;; 29925b89263Smrg ..) 30025b89263Smrg # Parent dir; strip last assembled component from result. 30125b89263Smrg func_dirname "$func_normal_abspath_result" 30225b89263Smrg func_normal_abspath_result=$func_dirname_result 30325b89263Smrg ;; 30425b89263Smrg *) 30525b89263Smrg # Actual path component, append it. 30625b89263Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 30725b89263Smrg ;; 30825b89263Smrg esac 30925b89263Smrg done 31025b89263Smrg # Restore leading double-slash if one was found on entry. 31125b89263Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 31225b89263Smrg} 31325b89263Smrg 31425b89263Smrg# func_relative_path SRCDIR DSTDIR 31525b89263Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 31625b89263Smrg# slash if non-empty, suitable for immediately appending a filename 31725b89263Smrg# without needing to append a separator. 31825b89263Smrg# value returned in "$func_relative_path_result" 31925b89263Smrgfunc_relative_path () 32025b89263Smrg{ 32125b89263Smrg func_relative_path_result= 32225b89263Smrg func_normal_abspath "$1" 32325b89263Smrg func_relative_path_tlibdir=$func_normal_abspath_result 32425b89263Smrg func_normal_abspath "$2" 32525b89263Smrg func_relative_path_tbindir=$func_normal_abspath_result 32625b89263Smrg 32725b89263Smrg # Ascend the tree starting from libdir 32825b89263Smrg while :; do 32925b89263Smrg # check if we have found a prefix of bindir 33025b89263Smrg case $func_relative_path_tbindir in 33125b89263Smrg $func_relative_path_tlibdir) 33225b89263Smrg # found an exact match 33325b89263Smrg func_relative_path_tcancelled= 33425b89263Smrg break 33525b89263Smrg ;; 33625b89263Smrg $func_relative_path_tlibdir*) 33725b89263Smrg # found a matching prefix 33825b89263Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 33925b89263Smrg func_relative_path_tcancelled=$func_stripname_result 34025b89263Smrg if test -z "$func_relative_path_result"; then 34125b89263Smrg func_relative_path_result=. 34225b89263Smrg fi 34325b89263Smrg break 34425b89263Smrg ;; 34525b89263Smrg *) 34625b89263Smrg func_dirname $func_relative_path_tlibdir 34725b89263Smrg func_relative_path_tlibdir=${func_dirname_result} 34825b89263Smrg if test "x$func_relative_path_tlibdir" = x ; then 34925b89263Smrg # Have to descend all the way to the root! 35025b89263Smrg func_relative_path_result=../$func_relative_path_result 35125b89263Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 35225b89263Smrg break 35325b89263Smrg fi 35425b89263Smrg func_relative_path_result=../$func_relative_path_result 35525b89263Smrg ;; 35625b89263Smrg esac 35725b89263Smrg done 35825b89263Smrg 35925b89263Smrg # Now calculate path; take care to avoid doubling-up slashes. 36025b89263Smrg func_stripname '' '/' "$func_relative_path_result" 36125b89263Smrg func_relative_path_result=$func_stripname_result 36225b89263Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 36325b89263Smrg if test "x$func_stripname_result" != x ; then 36425b89263Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 36525b89263Smrg fi 36625b89263Smrg 36725b89263Smrg # Normalisation. If bindir is libdir, return empty string, 36825b89263Smrg # else relative path ending with a slash; either way, target 36925b89263Smrg # file name can be directly appended. 37025b89263Smrg if test ! -z "$func_relative_path_result"; then 37125b89263Smrg func_stripname './' '' "$func_relative_path_result/" 37225b89263Smrg func_relative_path_result=$func_stripname_result 37325b89263Smrg fi 37425b89263Smrg} 375a253d6aeSmrg 376a253d6aeSmrg# The name of this program: 377ea133fd7Smrgfunc_dirname_and_basename "$progpath" 378ea133fd7Smrgprogname=$func_basename_result 379a253d6aeSmrg 380ea133fd7Smrg# Make sure we have an absolute path for reexecution: 381ea133fd7Smrgcase $progpath in 382ea133fd7Smrg [\\/]*|[A-Za-z]:\\*) ;; 383ea133fd7Smrg *[\\/]*) 384ea133fd7Smrg progdir=$func_dirname_result 385ea133fd7Smrg progdir=`cd "$progdir" && pwd` 386ea133fd7Smrg progpath="$progdir/$progname" 387ea133fd7Smrg ;; 388ea133fd7Smrg *) 389ea133fd7Smrg save_IFS="$IFS" 390ea133fd7Smrg IFS=: 391ea133fd7Smrg for progdir in $PATH; do 392ea133fd7Smrg IFS="$save_IFS" 393ea133fd7Smrg test -x "$progdir/$progname" && break 394ea133fd7Smrg done 395ea133fd7Smrg IFS="$save_IFS" 396ea133fd7Smrg test -n "$progdir" || progdir=`pwd` 397ea133fd7Smrg progpath="$progdir/$progname" 398ea133fd7Smrg ;; 399ea133fd7Smrgesac 400a253d6aeSmrg 401ea133fd7Smrg# Sed substitution that helps us do robust quoting. It backslashifies 402ea133fd7Smrg# metacharacters that are still active within double-quoted strings. 403ea133fd7SmrgXsed="${SED}"' -e 1s/^X//' 404ea133fd7Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 405ea133fd7Smrg 406ea133fd7Smrg# Same as above, but do not quote variable references. 407ea133fd7Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 408ea133fd7Smrg 40906f32fbeSmrg# Sed substitution that turns a string into a regex matching for the 41006f32fbeSmrg# string literally. 41106f32fbeSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 41206f32fbeSmrg 41306f32fbeSmrg# Sed substitution that converts a w32 file name or path 41406f32fbeSmrg# which contains forward slashes, into one that contains 41506f32fbeSmrg# (escaped) backslashes. A very naive implementation. 41606f32fbeSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 41706f32fbeSmrg 418ea133fd7Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 419ea133fd7Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 420ea133fd7Smrg# in input to double_quote_subst, that '$' was protected from expansion. 421ea133fd7Smrg# Since each input `\' is now two `\'s, look for any number of runs of 422ea133fd7Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 423ea133fd7Smrgbs='\\' 424ea133fd7Smrgbs2='\\\\' 425ea133fd7Smrgbs4='\\\\\\\\' 426ea133fd7Smrgdollar='\$' 427ea133fd7Smrgsed_double_backslash="\ 428ea133fd7Smrg s/$bs4/&\\ 429ea133fd7Smrg/g 430ea133fd7Smrg s/^$bs2$dollar/$bs&/ 431ea133fd7Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 432ea133fd7Smrg s/\n//g" 433ea133fd7Smrg 434ea133fd7Smrg# Standard options: 435ea133fd7Smrgopt_dry_run=false 436ea133fd7Smrgopt_help=false 437ea133fd7Smrgopt_quiet=false 438ea133fd7Smrgopt_verbose=false 439ea133fd7Smrgopt_warning=: 440ea133fd7Smrg 441ea133fd7Smrg# func_echo arg... 442ea133fd7Smrg# Echo program name prefixed message, along with the current mode 443ea133fd7Smrg# name if it has been set yet. 444ea133fd7Smrgfunc_echo () 445ea133fd7Smrg{ 44606f32fbeSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 447ea133fd7Smrg} 448a253d6aeSmrg 449ea133fd7Smrg# func_verbose arg... 450ea133fd7Smrg# Echo program name prefixed message in verbose mode only. 451ea133fd7Smrgfunc_verbose () 452ea133fd7Smrg{ 453ea133fd7Smrg $opt_verbose && func_echo ${1+"$@"} 454a253d6aeSmrg 455ea133fd7Smrg # A bug in bash halts the script if the last line of a function 456ea133fd7Smrg # fails when set -e is in force, so we need another command to 457ea133fd7Smrg # work around that: 458ea133fd7Smrg : 459ea133fd7Smrg} 460a253d6aeSmrg 46125b89263Smrg# func_echo_all arg... 46225b89263Smrg# Invoke $ECHO with all args, space-separated. 46325b89263Smrgfunc_echo_all () 46425b89263Smrg{ 46525b89263Smrg $ECHO "$*" 46625b89263Smrg} 46725b89263Smrg 468ea133fd7Smrg# func_error arg... 469ea133fd7Smrg# Echo program name prefixed message to standard error. 470ea133fd7Smrgfunc_error () 471ea133fd7Smrg{ 47206f32fbeSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 473ea133fd7Smrg} 474a253d6aeSmrg 475ea133fd7Smrg# func_warning arg... 476ea133fd7Smrg# Echo program name prefixed warning message to standard error. 477ea133fd7Smrgfunc_warning () 478ea133fd7Smrg{ 47906f32fbeSmrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 480a253d6aeSmrg 481ea133fd7Smrg # bash bug again: 482ea133fd7Smrg : 483ea133fd7Smrg} 484a253d6aeSmrg 485ea133fd7Smrg# func_fatal_error arg... 486ea133fd7Smrg# Echo program name prefixed message to standard error, and exit. 487ea133fd7Smrgfunc_fatal_error () 488ea133fd7Smrg{ 489ea133fd7Smrg func_error ${1+"$@"} 490ea133fd7Smrg exit $EXIT_FAILURE 491ea133fd7Smrg} 492a253d6aeSmrg 493ea133fd7Smrg# func_fatal_help arg... 494ea133fd7Smrg# Echo program name prefixed message to standard error, followed by 495ea133fd7Smrg# a help hint, and exit. 496ea133fd7Smrgfunc_fatal_help () 497ea133fd7Smrg{ 498ea133fd7Smrg func_error ${1+"$@"} 499ea133fd7Smrg func_fatal_error "$help" 500ea133fd7Smrg} 501ea133fd7Smrghelp="Try \`$progname --help' for more information." ## default 502a253d6aeSmrg 503a253d6aeSmrg 504ea133fd7Smrg# func_grep expression filename 505ea133fd7Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 506ea133fd7Smrgfunc_grep () 507ea133fd7Smrg{ 508ea133fd7Smrg $GREP "$1" "$2" >/dev/null 2>&1 509ea133fd7Smrg} 510ea133fd7Smrg 511ea133fd7Smrg 512ea133fd7Smrg# func_mkdir_p directory-path 513ea133fd7Smrg# Make sure the entire path to DIRECTORY-PATH is available. 514ea133fd7Smrgfunc_mkdir_p () 515ea133fd7Smrg{ 516ea133fd7Smrg my_directory_path="$1" 517ea133fd7Smrg my_dir_list= 518ea133fd7Smrg 519ea133fd7Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 520ea133fd7Smrg 521ea133fd7Smrg # Protect directory names starting with `-' 522ea133fd7Smrg case $my_directory_path in 523ea133fd7Smrg -*) my_directory_path="./$my_directory_path" ;; 524ea133fd7Smrg esac 525ea133fd7Smrg 526ea133fd7Smrg # While some portion of DIR does not yet exist... 527ea133fd7Smrg while test ! -d "$my_directory_path"; do 528ea133fd7Smrg # ...make a list in topmost first order. Use a colon delimited 529ea133fd7Smrg # list incase some portion of path contains whitespace. 530ea133fd7Smrg my_dir_list="$my_directory_path:$my_dir_list" 531ea133fd7Smrg 532ea133fd7Smrg # If the last portion added has no slash in it, the list is done 533ea133fd7Smrg case $my_directory_path in */*) ;; *) break ;; esac 534ea133fd7Smrg 535ea133fd7Smrg # ...otherwise throw away the child directory and loop 53625b89263Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 537ea133fd7Smrg done 53825b89263Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 539ea133fd7Smrg 540ea133fd7Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 541ea133fd7Smrg for my_dir in $my_dir_list; do 542ea133fd7Smrg IFS="$save_mkdir_p_IFS" 543ea133fd7Smrg # mkdir can fail with a `File exist' error if two processes 544ea133fd7Smrg # try to create one of the directories concurrently. Don't 545ea133fd7Smrg # stop in that case! 546ea133fd7Smrg $MKDIR "$my_dir" 2>/dev/null || : 547ea133fd7Smrg done 548ea133fd7Smrg IFS="$save_mkdir_p_IFS" 549ea133fd7Smrg 550ea133fd7Smrg # Bail out if we (or some other process) failed to create a directory. 551ea133fd7Smrg test -d "$my_directory_path" || \ 552ea133fd7Smrg func_fatal_error "Failed to create \`$1'" 553ea133fd7Smrg fi 554ea133fd7Smrg} 555a253d6aeSmrg 556a253d6aeSmrg 557a253d6aeSmrg# func_mktempdir [string] 558a253d6aeSmrg# Make a temporary directory that won't clash with other running 559a253d6aeSmrg# libtool processes, and avoids race conditions if possible. If 560a253d6aeSmrg# given, STRING is the basename for that directory. 561a253d6aeSmrgfunc_mktempdir () 562a253d6aeSmrg{ 563a253d6aeSmrg my_template="${TMPDIR-/tmp}/${1-$progname}" 564a253d6aeSmrg 565ea133fd7Smrg if test "$opt_dry_run" = ":"; then 566a253d6aeSmrg # Return a directory name, but don't create it in dry-run mode 567a253d6aeSmrg my_tmpdir="${my_template}-$$" 568a253d6aeSmrg else 569a253d6aeSmrg 570a253d6aeSmrg # If mktemp works, use that first and foremost 571a253d6aeSmrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 572a253d6aeSmrg 573a253d6aeSmrg if test ! -d "$my_tmpdir"; then 574ea133fd7Smrg # Failing that, at least try and use $RANDOM to avoid a race 575ea133fd7Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 576a253d6aeSmrg 577ea133fd7Smrg save_mktempdir_umask=`umask` 578ea133fd7Smrg umask 0077 579ea133fd7Smrg $MKDIR "$my_tmpdir" 580ea133fd7Smrg umask $save_mktempdir_umask 581a253d6aeSmrg fi 582a253d6aeSmrg 583a253d6aeSmrg # If we're not in dry-run mode, bomb out on failure 584ea133fd7Smrg test -d "$my_tmpdir" || \ 585ea133fd7Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 586a253d6aeSmrg fi 587a253d6aeSmrg 58825b89263Smrg $ECHO "$my_tmpdir" 589a253d6aeSmrg} 590a253d6aeSmrg 591a253d6aeSmrg 592ea133fd7Smrg# func_quote_for_eval arg 593ea133fd7Smrg# Aesthetically quote ARG to be evaled later. 594ea133fd7Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 595ea133fd7Smrg# is double-quoted, suitable for a subsequent eval, whereas 596ea133fd7Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 597ea133fd7Smrg# which are still active within double quotes backslashified. 598ea133fd7Smrgfunc_quote_for_eval () 599a253d6aeSmrg{ 600ea133fd7Smrg case $1 in 601ea133fd7Smrg *[\\\`\"\$]*) 60225b89263Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 603ea133fd7Smrg *) 604ea133fd7Smrg func_quote_for_eval_unquoted_result="$1" ;; 605ea133fd7Smrg esac 606ea133fd7Smrg 607ea133fd7Smrg case $func_quote_for_eval_unquoted_result in 608ea133fd7Smrg # Double-quote args containing shell metacharacters to delay 609ea133fd7Smrg # word splitting, command substitution and and variable 610ea133fd7Smrg # expansion for a subsequent eval. 611ea133fd7Smrg # Many Bourne shells cannot handle close brackets correctly 612ea133fd7Smrg # in scan sets, so we specify it separately. 613ea133fd7Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 614ea133fd7Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 615ea133fd7Smrg ;; 616ea133fd7Smrg *) 617ea133fd7Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 618a253d6aeSmrg esac 619a253d6aeSmrg} 620a253d6aeSmrg 621a253d6aeSmrg 622ea133fd7Smrg# func_quote_for_expand arg 623ea133fd7Smrg# Aesthetically quote ARG to be evaled later; same as above, 624ea133fd7Smrg# but do not quote variable references. 625ea133fd7Smrgfunc_quote_for_expand () 626a253d6aeSmrg{ 627ea133fd7Smrg case $1 in 628ea133fd7Smrg *[\\\`\"]*) 62925b89263Smrg my_arg=`$ECHO "$1" | $SED \ 630ea133fd7Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 631a253d6aeSmrg *) 632ea133fd7Smrg my_arg="$1" ;; 633ea133fd7Smrg esac 634ea133fd7Smrg 635ea133fd7Smrg case $my_arg in 636ea133fd7Smrg # Double-quote args containing shell metacharacters to delay 637ea133fd7Smrg # word splitting and command substitution for a subsequent eval. 638ea133fd7Smrg # Many Bourne shells cannot handle close brackets correctly 639ea133fd7Smrg # in scan sets, so we specify it separately. 640ea133fd7Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 641ea133fd7Smrg my_arg="\"$my_arg\"" 642ea133fd7Smrg ;; 643ea133fd7Smrg esac 644ea133fd7Smrg 645ea133fd7Smrg func_quote_for_expand_result="$my_arg" 646a253d6aeSmrg} 647a253d6aeSmrg 648a253d6aeSmrg 649ea133fd7Smrg# func_show_eval cmd [fail_exp] 650ea133fd7Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 651ea133fd7Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 652ea133fd7Smrg# is given, then evaluate it. 653ea133fd7Smrgfunc_show_eval () 654a253d6aeSmrg{ 655ea133fd7Smrg my_cmd="$1" 656ea133fd7Smrg my_fail_exp="${2-:}" 657a253d6aeSmrg 658ea133fd7Smrg ${opt_silent-false} || { 659ea133fd7Smrg func_quote_for_expand "$my_cmd" 660ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 661ea133fd7Smrg } 662ea133fd7Smrg 663ea133fd7Smrg if ${opt_dry_run-false}; then :; else 664ea133fd7Smrg eval "$my_cmd" 665ea133fd7Smrg my_status=$? 666ea133fd7Smrg if test "$my_status" -eq 0; then :; else 667ea133fd7Smrg eval "(exit $my_status); $my_fail_exp" 668ea133fd7Smrg fi 669a253d6aeSmrg fi 670a253d6aeSmrg} 671a253d6aeSmrg 672ea133fd7Smrg 673ea133fd7Smrg# func_show_eval_locale cmd [fail_exp] 674ea133fd7Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 675ea133fd7Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 676ea133fd7Smrg# is given, then evaluate it. Use the saved locale for evaluation. 677ea133fd7Smrgfunc_show_eval_locale () 678a253d6aeSmrg{ 679ea133fd7Smrg my_cmd="$1" 680ea133fd7Smrg my_fail_exp="${2-:}" 681a253d6aeSmrg 682ea133fd7Smrg ${opt_silent-false} || { 683ea133fd7Smrg func_quote_for_expand "$my_cmd" 684ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 685ea133fd7Smrg } 686ea133fd7Smrg 687ea133fd7Smrg if ${opt_dry_run-false}; then :; else 688ea133fd7Smrg eval "$lt_user_locale 689ea133fd7Smrg $my_cmd" 690ea133fd7Smrg my_status=$? 691ea133fd7Smrg eval "$lt_safe_locale" 692ea133fd7Smrg if test "$my_status" -eq 0; then :; else 693ea133fd7Smrg eval "(exit $my_status); $my_fail_exp" 694a253d6aeSmrg fi 695ea133fd7Smrg fi 696a253d6aeSmrg} 697a253d6aeSmrg 69806f32fbeSmrg# func_tr_sh 69906f32fbeSmrg# Turn $1 into a string suitable for a shell variable name. 70006f32fbeSmrg# Result is stored in $func_tr_sh_result. All characters 70106f32fbeSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 70206f32fbeSmrg# if $1 begins with a digit, a '_' is prepended as well. 70306f32fbeSmrgfunc_tr_sh () 70406f32fbeSmrg{ 70506f32fbeSmrg case $1 in 70606f32fbeSmrg [0-9]* | *[!a-zA-Z0-9_]*) 70706f32fbeSmrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 70806f32fbeSmrg ;; 70906f32fbeSmrg * ) 71006f32fbeSmrg func_tr_sh_result=$1 71106f32fbeSmrg ;; 71206f32fbeSmrg esac 71306f32fbeSmrg} 71406f32fbeSmrg 715a253d6aeSmrg 716ea133fd7Smrg# func_version 717ea133fd7Smrg# Echo version message to standard output and exit. 718ea133fd7Smrgfunc_version () 719ea133fd7Smrg{ 72006f32fbeSmrg $opt_debug 72106f32fbeSmrg 72225b89263Smrg $SED -n '/(C)/!b go 72325b89263Smrg :more 72425b89263Smrg /\./!{ 72525b89263Smrg N 72625b89263Smrg s/\n# / / 72725b89263Smrg b more 72825b89263Smrg } 72925b89263Smrg :go 73025b89263Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 731ea133fd7Smrg s/^# // 732ea133fd7Smrg s/^# *$// 733ea133fd7Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 734ea133fd7Smrg p 735ea133fd7Smrg }' < "$progpath" 736ea133fd7Smrg exit $? 737ea133fd7Smrg} 738ea133fd7Smrg 739ea133fd7Smrg# func_usage 740ea133fd7Smrg# Echo short help message to standard output and exit. 741ea133fd7Smrgfunc_usage () 742ea133fd7Smrg{ 74306f32fbeSmrg $opt_debug 74406f32fbeSmrg 74525b89263Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 746ea133fd7Smrg s/^# // 747ea133fd7Smrg s/^# *$// 748ea133fd7Smrg s/\$progname/'$progname'/ 749ea133fd7Smrg p 750ea133fd7Smrg }' < "$progpath" 75125b89263Smrg echo 752ea133fd7Smrg $ECHO "run \`$progname --help | more' for full usage" 753ea133fd7Smrg exit $? 754ea133fd7Smrg} 755ea133fd7Smrg 75625b89263Smrg# func_help [NOEXIT] 75725b89263Smrg# Echo long help message to standard output and exit, 75825b89263Smrg# unless 'noexit' is passed as argument. 759ea133fd7Smrgfunc_help () 760ea133fd7Smrg{ 76106f32fbeSmrg $opt_debug 76206f32fbeSmrg 763ea133fd7Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 76406f32fbeSmrg :print 765ea133fd7Smrg s/^# // 766ea133fd7Smrg s/^# *$// 767ea133fd7Smrg s*\$progname*'$progname'* 768ea133fd7Smrg s*\$host*'"$host"'* 769ea133fd7Smrg s*\$SHELL*'"$SHELL"'* 770ea133fd7Smrg s*\$LTCC*'"$LTCC"'* 771ea133fd7Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 772ea133fd7Smrg s*\$LD*'"$LD"'* 773ea133fd7Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 774ea133fd7Smrg s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ 775ea133fd7Smrg s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ 776ea133fd7Smrg p 77706f32fbeSmrg d 77806f32fbeSmrg } 77906f32fbeSmrg /^# .* home page:/b print 78006f32fbeSmrg /^# General help using/b print 78106f32fbeSmrg ' < "$progpath" 78225b89263Smrg ret=$? 78325b89263Smrg if test -z "$1"; then 78425b89263Smrg exit $ret 78525b89263Smrg fi 786ea133fd7Smrg} 787ea133fd7Smrg 788ea133fd7Smrg# func_missing_arg argname 789ea133fd7Smrg# Echo program name prefixed message to standard error and set global 790ea133fd7Smrg# exit_cmd. 791ea133fd7Smrgfunc_missing_arg () 792ea133fd7Smrg{ 79306f32fbeSmrg $opt_debug 79406f32fbeSmrg 79525b89263Smrg func_error "missing argument for $1." 796ea133fd7Smrg exit_cmd=exit 797ea133fd7Smrg} 798ea133fd7Smrg 799ea133fd7Smrg 80006f32fbeSmrg# func_split_short_opt shortopt 80106f32fbeSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 80206f32fbeSmrg# variables after splitting SHORTOPT after the 2nd character. 80306f32fbeSmrgfunc_split_short_opt () 80406f32fbeSmrg{ 80506f32fbeSmrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 80606f32fbeSmrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 80706f32fbeSmrg 80806f32fbeSmrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 80906f32fbeSmrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 81006f32fbeSmrg} # func_split_short_opt may be replaced by extended shell implementation 81106f32fbeSmrg 81206f32fbeSmrg 81306f32fbeSmrg# func_split_long_opt longopt 81406f32fbeSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 81506f32fbeSmrg# variables after splitting LONGOPT at the `=' sign. 81606f32fbeSmrgfunc_split_long_opt () 81706f32fbeSmrg{ 81806f32fbeSmrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 81906f32fbeSmrg my_sed_long_arg='1s/^--[^=]*=//' 82006f32fbeSmrg 82106f32fbeSmrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 82206f32fbeSmrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 82306f32fbeSmrg} # func_split_long_opt may be replaced by extended shell implementation 82406f32fbeSmrg 82506f32fbeSmrgexit_cmd=: 826ea133fd7Smrg 827ea133fd7Smrg 828ea133fd7Smrg 829ea133fd7Smrg 830a253d6aeSmrg 831ea133fd7Smrgmagic="%%%MAGIC variable%%%" 832ea133fd7Smrgmagic_exe="%%%MAGIC EXE variable%%%" 833a253d6aeSmrg 834ea133fd7Smrg# Global variables. 835ea133fd7Smrgnonopt= 836ea133fd7Smrgpreserve_args= 837ea133fd7Smrglo2o="s/\\.lo\$/.${objext}/" 838ea133fd7Smrgo2lo="s/\\.${objext}\$/.lo/" 839ea133fd7Smrgextracted_archives= 840ea133fd7Smrgextracted_serial=0 841a253d6aeSmrg 842ea133fd7Smrg# If this variable is set in any of the actions, the command in it 843ea133fd7Smrg# will be execed at the end. This prevents here-documents from being 844ea133fd7Smrg# left over by shells. 845ea133fd7Smrgexec_cmd= 846a253d6aeSmrg 84706f32fbeSmrg# func_append var value 84806f32fbeSmrg# Append VALUE to the end of shell variable VAR. 84906f32fbeSmrgfunc_append () 85006f32fbeSmrg{ 85106f32fbeSmrg eval "${1}=\$${1}\${2}" 85206f32fbeSmrg} # func_append may be replaced by extended shell implementation 85306f32fbeSmrg 85406f32fbeSmrg# func_append_quoted var value 85506f32fbeSmrg# Quote VALUE and append to the end of shell variable VAR, separated 85606f32fbeSmrg# by a space. 85706f32fbeSmrgfunc_append_quoted () 85806f32fbeSmrg{ 85906f32fbeSmrg func_quote_for_eval "${2}" 86006f32fbeSmrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 86106f32fbeSmrg} # func_append_quoted may be replaced by extended shell implementation 86206f32fbeSmrg 86306f32fbeSmrg 86406f32fbeSmrg# func_arith arithmetic-term... 86506f32fbeSmrgfunc_arith () 86606f32fbeSmrg{ 86706f32fbeSmrg func_arith_result=`expr "${@}"` 86806f32fbeSmrg} # func_arith may be replaced by extended shell implementation 86906f32fbeSmrg 87006f32fbeSmrg 87106f32fbeSmrg# func_len string 87206f32fbeSmrg# STRING may not start with a hyphen. 87306f32fbeSmrgfunc_len () 87406f32fbeSmrg{ 87506f32fbeSmrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 87606f32fbeSmrg} # func_len may be replaced by extended shell implementation 87706f32fbeSmrg 87806f32fbeSmrg 87906f32fbeSmrg# func_lo2o object 88006f32fbeSmrgfunc_lo2o () 88106f32fbeSmrg{ 88206f32fbeSmrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 88306f32fbeSmrg} # func_lo2o may be replaced by extended shell implementation 88406f32fbeSmrg 88506f32fbeSmrg 88606f32fbeSmrg# func_xform libobj-or-source 88706f32fbeSmrgfunc_xform () 88806f32fbeSmrg{ 88906f32fbeSmrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 89006f32fbeSmrg} # func_xform may be replaced by extended shell implementation 89106f32fbeSmrg 89206f32fbeSmrg 893ea133fd7Smrg# func_fatal_configuration arg... 894ea133fd7Smrg# Echo program name prefixed message to standard error, followed by 895ea133fd7Smrg# a configuration failure hint, and exit. 896ea133fd7Smrgfunc_fatal_configuration () 897ea133fd7Smrg{ 898ea133fd7Smrg func_error ${1+"$@"} 899ea133fd7Smrg func_error "See the $PACKAGE documentation for more information." 900ea133fd7Smrg func_fatal_error "Fatal configuration error." 901ea133fd7Smrg} 902ea133fd7Smrg 903ea133fd7Smrg 904ea133fd7Smrg# func_config 905ea133fd7Smrg# Display the configuration for all the tags in this script. 906ea133fd7Smrgfunc_config () 907ea133fd7Smrg{ 908ea133fd7Smrg re_begincf='^# ### BEGIN LIBTOOL' 909ea133fd7Smrg re_endcf='^# ### END LIBTOOL' 910ea133fd7Smrg 911ea133fd7Smrg # Default configuration. 912ea133fd7Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 913a253d6aeSmrg 914a253d6aeSmrg # Now print the configurations for the tags. 915a253d6aeSmrg for tagname in $taglist; do 916ea133fd7Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 917a253d6aeSmrg done 918a253d6aeSmrg 919ea133fd7Smrg exit $? 920ea133fd7Smrg} 921a253d6aeSmrg 922ea133fd7Smrg# func_features 923ea133fd7Smrg# Display the features supported by this script. 924ea133fd7Smrgfunc_features () 925ea133fd7Smrg{ 92625b89263Smrg echo "host: $host" 927a253d6aeSmrg if test "$build_libtool_libs" = yes; then 92825b89263Smrg echo "enable shared libraries" 929a253d6aeSmrg else 93025b89263Smrg echo "disable shared libraries" 931a253d6aeSmrg fi 932a253d6aeSmrg if test "$build_old_libs" = yes; then 93325b89263Smrg echo "enable static libraries" 934a253d6aeSmrg else 93525b89263Smrg echo "disable static libraries" 936a253d6aeSmrg fi 937ea133fd7Smrg 938a253d6aeSmrg exit $? 939ea133fd7Smrg} 940ea133fd7Smrg 941ea133fd7Smrg# func_enable_tag tagname 942ea133fd7Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 943ea133fd7Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 944ea133fd7Smrg# variable here. 945ea133fd7Smrgfunc_enable_tag () 946ea133fd7Smrg{ 947ea133fd7Smrg # Global variable: 948ea133fd7Smrg tagname="$1" 949a253d6aeSmrg 950ea133fd7Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 951ea133fd7Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 952ea133fd7Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 953a253d6aeSmrg 954ea133fd7Smrg # Validate tagname. 955ea133fd7Smrg case $tagname in 956ea133fd7Smrg *[!-_A-Za-z0-9,/]*) 957ea133fd7Smrg func_fatal_error "invalid tag name: $tagname" 958ea133fd7Smrg ;; 959ea133fd7Smrg esac 960a253d6aeSmrg 961ea133fd7Smrg # Don't test for the "default" C tag, as we know it's 962ea133fd7Smrg # there but not specially marked. 963ea133fd7Smrg case $tagname in 964ea133fd7Smrg CC) ;; 965ea133fd7Smrg *) 966ea133fd7Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 967ea133fd7Smrg taglist="$taglist $tagname" 968ea133fd7Smrg 969ea133fd7Smrg # Evaluate the configuration. Be careful to quote the path 970ea133fd7Smrg # and the sed script, to avoid splitting on whitespace, but 971ea133fd7Smrg # also don't use non-portable quotes within backquotes within 972ea133fd7Smrg # quotes we have to do it in 2 steps: 973ea133fd7Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 974ea133fd7Smrg eval "$extractedcf" 975ea133fd7Smrg else 976ea133fd7Smrg func_error "ignoring unknown tag $tagname" 977ea133fd7Smrg fi 978ea133fd7Smrg ;; 979ea133fd7Smrg esac 980ea133fd7Smrg} 981a253d6aeSmrg 98206f32fbeSmrg# func_check_version_match 98306f32fbeSmrg# Ensure that we are using m4 macros, and libtool script from the same 98406f32fbeSmrg# release of libtool. 98506f32fbeSmrgfunc_check_version_match () 986ea133fd7Smrg{ 98706f32fbeSmrg if test "$package_revision" != "$macro_revision"; then 98806f32fbeSmrg if test "$VERSION" != "$macro_version"; then 98906f32fbeSmrg if test -z "$macro_version"; then 99006f32fbeSmrg cat >&2 <<_LT_EOF 99106f32fbeSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99206f32fbeSmrg$progname: definition of this LT_INIT comes from an older release. 99306f32fbeSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99406f32fbeSmrg$progname: and run autoconf again. 99506f32fbeSmrg_LT_EOF 99606f32fbeSmrg else 99706f32fbeSmrg cat >&2 <<_LT_EOF 99806f32fbeSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99906f32fbeSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 100006f32fbeSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 100106f32fbeSmrg$progname: and run autoconf again. 100206f32fbeSmrg_LT_EOF 100306f32fbeSmrg fi 100406f32fbeSmrg else 100506f32fbeSmrg cat >&2 <<_LT_EOF 100606f32fbeSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 100706f32fbeSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 100806f32fbeSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 100906f32fbeSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 101006f32fbeSmrg_LT_EOF 101106f32fbeSmrg fi 1012a253d6aeSmrg 101306f32fbeSmrg exit $EXIT_MISMATCH 101406f32fbeSmrg fi 101506f32fbeSmrg} 101606f32fbeSmrg 101706f32fbeSmrg 101806f32fbeSmrg# Shorthand for --mode=foo, only valid as the first argument 101906f32fbeSmrgcase $1 in 102006f32fbeSmrgclean|clea|cle|cl) 102106f32fbeSmrg shift; set dummy --mode clean ${1+"$@"}; shift 102206f32fbeSmrg ;; 102306f32fbeSmrgcompile|compil|compi|comp|com|co|c) 102406f32fbeSmrg shift; set dummy --mode compile ${1+"$@"}; shift 102506f32fbeSmrg ;; 102606f32fbeSmrgexecute|execut|execu|exec|exe|ex|e) 102706f32fbeSmrg shift; set dummy --mode execute ${1+"$@"}; shift 102806f32fbeSmrg ;; 102906f32fbeSmrgfinish|finis|fini|fin|fi|f) 103006f32fbeSmrg shift; set dummy --mode finish ${1+"$@"}; shift 103106f32fbeSmrg ;; 103206f32fbeSmrginstall|instal|insta|inst|ins|in|i) 103306f32fbeSmrg shift; set dummy --mode install ${1+"$@"}; shift 103406f32fbeSmrg ;; 103506f32fbeSmrglink|lin|li|l) 103606f32fbeSmrg shift; set dummy --mode link ${1+"$@"}; shift 103706f32fbeSmrg ;; 103806f32fbeSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 103906f32fbeSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 104006f32fbeSmrg ;; 104106f32fbeSmrgesac 1042a253d6aeSmrg 104306f32fbeSmrg 104406f32fbeSmrg 104506f32fbeSmrg# Option defaults: 104606f32fbeSmrgopt_debug=: 104706f32fbeSmrgopt_dry_run=false 104806f32fbeSmrgopt_config=false 104906f32fbeSmrgopt_preserve_dup_deps=false 105006f32fbeSmrgopt_features=false 105106f32fbeSmrgopt_finish=false 105206f32fbeSmrgopt_help=false 105306f32fbeSmrgopt_help_all=false 105406f32fbeSmrgopt_silent=: 105506f32fbeSmrgopt_verbose=: 105606f32fbeSmrgopt_silent=false 105706f32fbeSmrgopt_verbose=false 105806f32fbeSmrg 105906f32fbeSmrg 106006f32fbeSmrg# Parse options once, thoroughly. This comes as soon as possible in the 106106f32fbeSmrg# script to make things like `--version' happen as quickly as we can. 106206f32fbeSmrg{ 106306f32fbeSmrg # this just eases exit handling 106406f32fbeSmrg while test $# -gt 0; do 1065ea133fd7Smrg opt="$1" 1066ea133fd7Smrg shift 1067ea133fd7Smrg case $opt in 106806f32fbeSmrg --debug|-x) opt_debug='set -x' 1069ea133fd7Smrg func_echo "enabling shell trace mode" 1070ea133fd7Smrg $opt_debug 1071ea133fd7Smrg ;; 107206f32fbeSmrg --dry-run|--dryrun|-n) 107306f32fbeSmrg opt_dry_run=: 1074ea133fd7Smrg ;; 107506f32fbeSmrg --config) 107606f32fbeSmrg opt_config=: 107706f32fbeSmrgfunc_config 107806f32fbeSmrg ;; 107906f32fbeSmrg --dlopen|-dlopen) 108006f32fbeSmrg optarg="$1" 108106f32fbeSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 108206f32fbeSmrg}$optarg" 1083ea133fd7Smrg shift 1084ea133fd7Smrg ;; 1085ea133fd7Smrg --preserve-dup-deps) 108606f32fbeSmrg opt_preserve_dup_deps=: 108725b89263Smrg ;; 108806f32fbeSmrg --features) 108906f32fbeSmrg opt_features=: 109006f32fbeSmrgfunc_features 1091ea133fd7Smrg ;; 109206f32fbeSmrg --finish) 109306f32fbeSmrg opt_finish=: 109406f32fbeSmrgset dummy --mode finish ${1+"$@"}; shift 109506f32fbeSmrg ;; 109606f32fbeSmrg --help) 109706f32fbeSmrg opt_help=: 109806f32fbeSmrg ;; 109906f32fbeSmrg --help-all) 110006f32fbeSmrg opt_help_all=: 110106f32fbeSmrgopt_help=': help-all' 110206f32fbeSmrg ;; 110306f32fbeSmrg --mode) 110406f32fbeSmrg test $# = 0 && func_missing_arg $opt && break 110506f32fbeSmrg optarg="$1" 110606f32fbeSmrg opt_mode="$optarg" 110706f32fbeSmrgcase $optarg in 110806f32fbeSmrg # Valid mode arguments: 110906f32fbeSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 111006f32fbeSmrg 111106f32fbeSmrg # Catch anything else as an error 111206f32fbeSmrg *) func_error "invalid argument for $opt" 111306f32fbeSmrg exit_cmd=exit 111406f32fbeSmrg break 111506f32fbeSmrg ;; 111606f32fbeSmrgesac 111706f32fbeSmrg shift 111806f32fbeSmrg ;; 111906f32fbeSmrg --no-silent|--no-quiet) 1120ea133fd7Smrg opt_silent=false 112106f32fbeSmrgfunc_append preserve_args " $opt" 112225b89263Smrg ;; 112306f32fbeSmrg --no-verbose) 112425b89263Smrg opt_verbose=false 112506f32fbeSmrgfunc_append preserve_args " $opt" 1126ea133fd7Smrg ;; 112706f32fbeSmrg --silent|--quiet) 112806f32fbeSmrg opt_silent=: 112906f32fbeSmrgfunc_append preserve_args " $opt" 113006f32fbeSmrg opt_verbose=false 113106f32fbeSmrg ;; 113206f32fbeSmrg --verbose|-v) 113306f32fbeSmrg opt_verbose=: 113406f32fbeSmrgfunc_append preserve_args " $opt" 113506f32fbeSmrgopt_silent=false 113606f32fbeSmrg ;; 113706f32fbeSmrg --tag) 113806f32fbeSmrg test $# = 0 && func_missing_arg $opt && break 113906f32fbeSmrg optarg="$1" 114006f32fbeSmrg opt_tag="$optarg" 114106f32fbeSmrgfunc_append preserve_args " $opt $optarg" 114206f32fbeSmrgfunc_enable_tag "$optarg" 1143ea133fd7Smrg shift 1144ea133fd7Smrg ;; 1145ea133fd7Smrg 114606f32fbeSmrg -\?|-h) func_usage ;; 114706f32fbeSmrg --help) func_help ;; 114806f32fbeSmrg --version) func_version ;; 114906f32fbeSmrg 1150ea133fd7Smrg # Separate optargs to long options: 115106f32fbeSmrg --*=*) 115206f32fbeSmrg func_split_long_opt "$opt" 115306f32fbeSmrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 1154ea133fd7Smrg shift 1155ea133fd7Smrg ;; 1156ea133fd7Smrg 115706f32fbeSmrg # Separate non-argument short options: 115806f32fbeSmrg -\?*|-h*|-n*|-v*) 115906f32fbeSmrg func_split_short_opt "$opt" 116006f32fbeSmrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 116106f32fbeSmrg shift 1162ea133fd7Smrg ;; 116306f32fbeSmrg 116406f32fbeSmrg --) break ;; 116506f32fbeSmrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 116606f32fbeSmrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1167ea133fd7Smrg esac 1168ea133fd7Smrg done 1169ea133fd7Smrg 117006f32fbeSmrg # Validate options: 117106f32fbeSmrg 117206f32fbeSmrg # save first non-option argument 117306f32fbeSmrg if test "$#" -gt 0; then 117406f32fbeSmrg nonopt="$opt" 117506f32fbeSmrg shift 117606f32fbeSmrg fi 117706f32fbeSmrg 117806f32fbeSmrg # preserve --debug 117906f32fbeSmrg test "$opt_debug" = : || func_append preserve_args " --debug" 1180ea133fd7Smrg 1181ea133fd7Smrg case $host in 1182ea133fd7Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 1183ea133fd7Smrg # don't eliminate duplications in $postdeps and $predeps 1184ea133fd7Smrg opt_duplicate_compiler_generated_deps=: 1185a253d6aeSmrg ;; 1186a253d6aeSmrg *) 118706f32fbeSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 1188ea133fd7Smrg ;; 1189ea133fd7Smrg esac 1190a253d6aeSmrg 119106f32fbeSmrg $opt_help || { 119206f32fbeSmrg # Sanity checks first: 119306f32fbeSmrg func_check_version_match 1194ea133fd7Smrg 119506f32fbeSmrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 119606f32fbeSmrg func_fatal_configuration "not configured to build any kind of library" 1197ea133fd7Smrg fi 1198ea133fd7Smrg 119906f32fbeSmrg # Darwin sucks 120006f32fbeSmrg eval std_shrext=\"$shrext_cmds\" 1201ea133fd7Smrg 120206f32fbeSmrg # Only execute mode is allowed to have -dlopen flags. 120306f32fbeSmrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 120406f32fbeSmrg func_error "unrecognized option \`-dlopen'" 120506f32fbeSmrg $ECHO "$help" 1>&2 120606f32fbeSmrg exit $EXIT_FAILURE 120706f32fbeSmrg fi 1208ea133fd7Smrg 120906f32fbeSmrg # Change the help message to a mode-specific one. 121006f32fbeSmrg generic_help="$help" 121106f32fbeSmrg help="Try \`$progname --help --mode=$opt_mode' for more information." 121206f32fbeSmrg } 1213ea133fd7Smrg 1214ea133fd7Smrg 121506f32fbeSmrg # Bail if the options were screwed 121606f32fbeSmrg $exit_cmd $EXIT_FAILURE 121706f32fbeSmrg} 1218ea133fd7Smrg 1219ea133fd7Smrg 1220a253d6aeSmrg 1221a253d6aeSmrg 122206f32fbeSmrg## ----------- ## 122306f32fbeSmrg## Main. ## 122406f32fbeSmrg## ----------- ## 1225a253d6aeSmrg 1226ea133fd7Smrg# func_lalib_p file 1227ea133fd7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1228ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out 1229ea133fd7Smrg# determined imposters. 1230ea133fd7Smrgfunc_lalib_p () 1231ea133fd7Smrg{ 1232ea133fd7Smrg test -f "$1" && 1233ea133fd7Smrg $SED -e 4q "$1" 2>/dev/null \ 1234ea133fd7Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 1235ea133fd7Smrg} 1236a253d6aeSmrg 1237ea133fd7Smrg# func_lalib_unsafe_p file 1238ea133fd7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1239ea133fd7Smrg# This function implements the same check as func_lalib_p without 1240ea133fd7Smrg# resorting to external programs. To this end, it redirects stdin and 1241ea133fd7Smrg# closes it afterwards, without saving the original file descriptor. 1242ea133fd7Smrg# As a safety measure, use it only where a negative result would be 1243ea133fd7Smrg# fatal anyway. Works if `file' does not exist. 1244ea133fd7Smrgfunc_lalib_unsafe_p () 1245ea133fd7Smrg{ 1246ea133fd7Smrg lalib_p=no 1247ea133fd7Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 1248ea133fd7Smrg for lalib_p_l in 1 2 3 4 1249ea133fd7Smrg do 1250ea133fd7Smrg read lalib_p_line 1251ea133fd7Smrg case "$lalib_p_line" in 1252ea133fd7Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 1253ea133fd7Smrg esac 1254ea133fd7Smrg done 1255ea133fd7Smrg exec 0<&5 5<&- 1256ea133fd7Smrg fi 1257ea133fd7Smrg test "$lalib_p" = yes 1258ea133fd7Smrg} 1259a253d6aeSmrg 1260ea133fd7Smrg# func_ltwrapper_script_p file 1261ea133fd7Smrg# True iff FILE is a libtool wrapper script 1262ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out 1263ea133fd7Smrg# determined imposters. 1264ea133fd7Smrgfunc_ltwrapper_script_p () 1265ea133fd7Smrg{ 1266ea133fd7Smrg func_lalib_p "$1" 1267ea133fd7Smrg} 1268a253d6aeSmrg 1269ea133fd7Smrg# func_ltwrapper_executable_p file 1270ea133fd7Smrg# True iff FILE is a libtool wrapper executable 1271ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out 1272ea133fd7Smrg# determined imposters. 1273ea133fd7Smrgfunc_ltwrapper_executable_p () 1274ea133fd7Smrg{ 1275ea133fd7Smrg func_ltwrapper_exec_suffix= 1276ea133fd7Smrg case $1 in 1277ea133fd7Smrg *.exe) ;; 1278ea133fd7Smrg *) func_ltwrapper_exec_suffix=.exe ;; 1279ea133fd7Smrg esac 1280ea133fd7Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 1281ea133fd7Smrg} 1282a253d6aeSmrg 1283ea133fd7Smrg# func_ltwrapper_scriptname file 1284ea133fd7Smrg# Assumes file is an ltwrapper_executable 1285ea133fd7Smrg# uses $file to determine the appropriate filename for a 1286ea133fd7Smrg# temporary ltwrapper_script. 1287ea133fd7Smrgfunc_ltwrapper_scriptname () 1288ea133fd7Smrg{ 128906f32fbeSmrg func_dirname_and_basename "$1" "" "." 129006f32fbeSmrg func_stripname '' '.exe' "$func_basename_result" 129106f32fbeSmrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 1292ea133fd7Smrg} 1293a253d6aeSmrg 1294ea133fd7Smrg# func_ltwrapper_p file 1295ea133fd7Smrg# True iff FILE is a libtool wrapper script or wrapper executable 1296ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out 1297ea133fd7Smrg# determined imposters. 1298ea133fd7Smrgfunc_ltwrapper_p () 1299ea133fd7Smrg{ 1300ea133fd7Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 1301ea133fd7Smrg} 1302a253d6aeSmrg 1303a253d6aeSmrg 1304ea133fd7Smrg# func_execute_cmds commands fail_cmd 1305ea133fd7Smrg# Execute tilde-delimited COMMANDS. 1306ea133fd7Smrg# If FAIL_CMD is given, eval that upon failure. 1307ea133fd7Smrg# FAIL_CMD may read-access the current command in variable CMD! 1308ea133fd7Smrgfunc_execute_cmds () 1309ea133fd7Smrg{ 1310ea133fd7Smrg $opt_debug 1311ea133fd7Smrg save_ifs=$IFS; IFS='~' 1312ea133fd7Smrg for cmd in $1; do 1313ea133fd7Smrg IFS=$save_ifs 1314ea133fd7Smrg eval cmd=\"$cmd\" 1315ea133fd7Smrg func_show_eval "$cmd" "${2-:}" 1316ea133fd7Smrg done 1317ea133fd7Smrg IFS=$save_ifs 1318ea133fd7Smrg} 1319ea133fd7Smrg 1320ea133fd7Smrg 1321ea133fd7Smrg# func_source file 1322ea133fd7Smrg# Source FILE, adding directory component if necessary. 1323ea133fd7Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 1324ea133fd7Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 1325ea133fd7Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 1326ea133fd7Smrg# `FILE.' does not work on cygwin managed mounts. 1327ea133fd7Smrgfunc_source () 1328ea133fd7Smrg{ 1329ea133fd7Smrg $opt_debug 1330ea133fd7Smrg case $1 in 1331ea133fd7Smrg */* | *\\*) . "$1" ;; 1332ea133fd7Smrg *) . "./$1" ;; 1333ea133fd7Smrg esac 1334ea133fd7Smrg} 1335ea133fd7Smrg 1336ea133fd7Smrg 133706f32fbeSmrg# func_resolve_sysroot PATH 133806f32fbeSmrg# Replace a leading = in PATH with a sysroot. Store the result into 133906f32fbeSmrg# func_resolve_sysroot_result 134006f32fbeSmrgfunc_resolve_sysroot () 134106f32fbeSmrg{ 134206f32fbeSmrg func_resolve_sysroot_result=$1 134306f32fbeSmrg case $func_resolve_sysroot_result in 134406f32fbeSmrg =*) 134506f32fbeSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 134606f32fbeSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 134706f32fbeSmrg ;; 134806f32fbeSmrg esac 134906f32fbeSmrg} 135006f32fbeSmrg 135106f32fbeSmrg# func_replace_sysroot PATH 135206f32fbeSmrg# If PATH begins with the sysroot, replace it with = and 135306f32fbeSmrg# store the result into func_replace_sysroot_result. 135406f32fbeSmrgfunc_replace_sysroot () 135506f32fbeSmrg{ 135606f32fbeSmrg case "$lt_sysroot:$1" in 135706f32fbeSmrg ?*:"$lt_sysroot"*) 135806f32fbeSmrg func_stripname "$lt_sysroot" '' "$1" 135906f32fbeSmrg func_replace_sysroot_result="=$func_stripname_result" 136006f32fbeSmrg ;; 136106f32fbeSmrg *) 136206f32fbeSmrg # Including no sysroot. 136306f32fbeSmrg func_replace_sysroot_result=$1 136406f32fbeSmrg ;; 136506f32fbeSmrg esac 136606f32fbeSmrg} 136706f32fbeSmrg 1368ea133fd7Smrg# func_infer_tag arg 1369ea133fd7Smrg# Infer tagged configuration to use if any are available and 1370ea133fd7Smrg# if one wasn't chosen via the "--tag" command line option. 1371ea133fd7Smrg# Only attempt this if the compiler in the base compile 1372ea133fd7Smrg# command doesn't match the default compiler. 1373ea133fd7Smrg# arg is usually of the form 'gcc ...' 1374ea133fd7Smrgfunc_infer_tag () 1375ea133fd7Smrg{ 1376ea133fd7Smrg $opt_debug 1377ea133fd7Smrg if test -n "$available_tags" && test -z "$tagname"; then 1378ea133fd7Smrg CC_quoted= 1379ea133fd7Smrg for arg in $CC; do 138006f32fbeSmrg func_append_quoted CC_quoted "$arg" 1381ea133fd7Smrg done 138225b89263Smrg CC_expanded=`func_echo_all $CC` 138325b89263Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1384ea133fd7Smrg case $@ in 1385ea133fd7Smrg # Blanks in the command may have been stripped by the calling shell, 1386ea133fd7Smrg # but not from the CC environment variable when configure was run. 138725b89263Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 138825b89263Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 1389ea133fd7Smrg # Blanks at the start of $base_compile will cause this to fail 1390ea133fd7Smrg # if we don't check for them as well. 1391ea133fd7Smrg *) 1392ea133fd7Smrg for z in $available_tags; do 1393ea133fd7Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 1394ea133fd7Smrg # Evaluate the configuration. 1395ea133fd7Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 1396ea133fd7Smrg CC_quoted= 1397ea133fd7Smrg for arg in $CC; do 1398ea133fd7Smrg # Double-quote args containing other shell metacharacters. 139906f32fbeSmrg func_append_quoted CC_quoted "$arg" 1400ea133fd7Smrg done 140125b89263Smrg CC_expanded=`func_echo_all $CC` 140225b89263Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1403ea133fd7Smrg case "$@ " in 140425b89263Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 140525b89263Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 1406ea133fd7Smrg # The compiler in the base compile command matches 1407ea133fd7Smrg # the one in the tagged configuration. 1408ea133fd7Smrg # Assume this is the tagged configuration we want. 1409ea133fd7Smrg tagname=$z 1410ea133fd7Smrg break 1411ea133fd7Smrg ;; 1412a253d6aeSmrg esac 1413ea133fd7Smrg fi 1414ea133fd7Smrg done 1415ea133fd7Smrg # If $tagname still isn't set, then no tagged configuration 1416ea133fd7Smrg # was found and let the user know that the "--tag" command 1417ea133fd7Smrg # line option must be used. 1418ea133fd7Smrg if test -z "$tagname"; then 1419ea133fd7Smrg func_echo "unable to infer tagged configuration" 1420ea133fd7Smrg func_fatal_error "specify a tag with \`--tag'" 1421ea133fd7Smrg# else 1422ea133fd7Smrg# func_verbose "using $tagname tagged configuration" 1423ea133fd7Smrg fi 1424ea133fd7Smrg ;; 1425ea133fd7Smrg esac 1426ea133fd7Smrg fi 1427ea133fd7Smrg} 1428ea133fd7Smrg 1429ea133fd7Smrg 1430ea133fd7Smrg 143106f32fbeSmrg# func_write_libtool_object output_name pic_name nonpic_name 143206f32fbeSmrg# Create a libtool object file (analogous to a ".la" file), 143306f32fbeSmrg# but don't create it if we're doing a dry run. 143406f32fbeSmrgfunc_write_libtool_object () 143506f32fbeSmrg{ 143606f32fbeSmrg write_libobj=${1} 143706f32fbeSmrg if test "$build_libtool_libs" = yes; then 143806f32fbeSmrg write_lobj=\'${2}\' 143906f32fbeSmrg else 144006f32fbeSmrg write_lobj=none 144106f32fbeSmrg fi 144206f32fbeSmrg 144306f32fbeSmrg if test "$build_old_libs" = yes; then 144406f32fbeSmrg write_oldobj=\'${3}\' 144506f32fbeSmrg else 144606f32fbeSmrg write_oldobj=none 144706f32fbeSmrg fi 144806f32fbeSmrg 144906f32fbeSmrg $opt_dry_run || { 145006f32fbeSmrg cat >${write_libobj}T <<EOF 145106f32fbeSmrg# $write_libobj - a libtool object file 145206f32fbeSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 145306f32fbeSmrg# 145406f32fbeSmrg# Please DO NOT delete this file! 145506f32fbeSmrg# It is necessary for linking the library. 145606f32fbeSmrg 145706f32fbeSmrg# Name of the PIC object. 145806f32fbeSmrgpic_object=$write_lobj 145906f32fbeSmrg 146006f32fbeSmrg# Name of the non-PIC object 146106f32fbeSmrgnon_pic_object=$write_oldobj 146206f32fbeSmrg 146306f32fbeSmrgEOF 146406f32fbeSmrg $MV "${write_libobj}T" "${write_libobj}" 146506f32fbeSmrg } 146606f32fbeSmrg} 146706f32fbeSmrg 146806f32fbeSmrg 146906f32fbeSmrg################################################## 147006f32fbeSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 147106f32fbeSmrg################################################## 147206f32fbeSmrg 147306f32fbeSmrg# func_convert_core_file_wine_to_w32 ARG 147406f32fbeSmrg# Helper function used by file name conversion functions when $build is *nix, 147506f32fbeSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 147606f32fbeSmrg# correctly configured wine environment available, with the winepath program 147706f32fbeSmrg# in $build's $PATH. 147806f32fbeSmrg# 147906f32fbeSmrg# ARG is the $build file name to be converted to w32 format. 148006f32fbeSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 148106f32fbeSmrg# be empty on error (or when ARG is empty) 148206f32fbeSmrgfunc_convert_core_file_wine_to_w32 () 148306f32fbeSmrg{ 148406f32fbeSmrg $opt_debug 148506f32fbeSmrg func_convert_core_file_wine_to_w32_result="$1" 148606f32fbeSmrg if test -n "$1"; then 148706f32fbeSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 148806f32fbeSmrg # are forced to check the contents of stdout. On the other hand, if the 148906f32fbeSmrg # command is not found, the shell will set an exit code of 127 and print 149006f32fbeSmrg # *an error message* to stdout. So we must check for both error code of 149106f32fbeSmrg # zero AND non-empty stdout, which explains the odd construction: 149206f32fbeSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 149306f32fbeSmrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 149406f32fbeSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 149506f32fbeSmrg $SED -e "$lt_sed_naive_backslashify"` 149606f32fbeSmrg else 149706f32fbeSmrg func_convert_core_file_wine_to_w32_result= 149806f32fbeSmrg fi 149906f32fbeSmrg fi 150006f32fbeSmrg} 150106f32fbeSmrg# end: func_convert_core_file_wine_to_w32 150206f32fbeSmrg 150306f32fbeSmrg 150406f32fbeSmrg# func_convert_core_path_wine_to_w32 ARG 150506f32fbeSmrg# Helper function used by path conversion functions when $build is *nix, and 150606f32fbeSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 150706f32fbeSmrg# configured wine environment available, with the winepath program in $build's 150806f32fbeSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 150906f32fbeSmrg# 151006f32fbeSmrg# ARG is path to be converted from $build format to win32. 151106f32fbeSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 151206f32fbeSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 151306f32fbeSmrg# are convertible, then the result may be empty. 151406f32fbeSmrgfunc_convert_core_path_wine_to_w32 () 151506f32fbeSmrg{ 151606f32fbeSmrg $opt_debug 151706f32fbeSmrg # unfortunately, winepath doesn't convert paths, only file names 151806f32fbeSmrg func_convert_core_path_wine_to_w32_result="" 151906f32fbeSmrg if test -n "$1"; then 152006f32fbeSmrg oldIFS=$IFS 152106f32fbeSmrg IFS=: 152206f32fbeSmrg for func_convert_core_path_wine_to_w32_f in $1; do 152306f32fbeSmrg IFS=$oldIFS 152406f32fbeSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 152506f32fbeSmrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 152606f32fbeSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 152706f32fbeSmrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 152806f32fbeSmrg else 152906f32fbeSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 153006f32fbeSmrg fi 153106f32fbeSmrg fi 153206f32fbeSmrg done 153306f32fbeSmrg IFS=$oldIFS 153406f32fbeSmrg fi 153506f32fbeSmrg} 153606f32fbeSmrg# end: func_convert_core_path_wine_to_w32 153706f32fbeSmrg 153806f32fbeSmrg 153906f32fbeSmrg# func_cygpath ARGS... 154006f32fbeSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 154106f32fbeSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 154206f32fbeSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 154306f32fbeSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 154406f32fbeSmrg# file name or path is assumed to be in w32 format, as previously converted 154506f32fbeSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 154606f32fbeSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 154706f32fbeSmrg# Cygwin format). Returns an empty string on error. 154806f32fbeSmrg# 154906f32fbeSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 155006f32fbeSmrg# be converted. 155106f32fbeSmrg# 155206f32fbeSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 155306f32fbeSmrg# environment variable; do not put it in $PATH. 155406f32fbeSmrgfunc_cygpath () 155506f32fbeSmrg{ 155606f32fbeSmrg $opt_debug 155706f32fbeSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 155806f32fbeSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 155906f32fbeSmrg if test "$?" -ne 0; then 156006f32fbeSmrg # on failure, ensure result is empty 156106f32fbeSmrg func_cygpath_result= 156206f32fbeSmrg fi 156306f32fbeSmrg else 156406f32fbeSmrg func_cygpath_result= 156506f32fbeSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 156606f32fbeSmrg fi 156706f32fbeSmrg} 156806f32fbeSmrg#end: func_cygpath 156906f32fbeSmrg 157006f32fbeSmrg 157106f32fbeSmrg# func_convert_core_msys_to_w32 ARG 157206f32fbeSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 157306f32fbeSmrg# result in func_convert_core_msys_to_w32_result. 157406f32fbeSmrgfunc_convert_core_msys_to_w32 () 157506f32fbeSmrg{ 157606f32fbeSmrg $opt_debug 157706f32fbeSmrg # awkward: cmd appends spaces to result 157806f32fbeSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 157906f32fbeSmrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 158006f32fbeSmrg} 158106f32fbeSmrg#end: func_convert_core_msys_to_w32 158206f32fbeSmrg 158306f32fbeSmrg 158406f32fbeSmrg# func_convert_file_check ARG1 ARG2 158506f32fbeSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 158606f32fbeSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 158706f32fbeSmrg# func_to_host_file_result to ARG1). 158806f32fbeSmrgfunc_convert_file_check () 158906f32fbeSmrg{ 159006f32fbeSmrg $opt_debug 159106f32fbeSmrg if test -z "$2" && test -n "$1" ; then 159206f32fbeSmrg func_error "Could not determine host file name corresponding to" 159306f32fbeSmrg func_error " \`$1'" 159406f32fbeSmrg func_error "Continuing, but uninstalled executables may not work." 159506f32fbeSmrg # Fallback: 159606f32fbeSmrg func_to_host_file_result="$1" 159706f32fbeSmrg fi 159806f32fbeSmrg} 159906f32fbeSmrg# end func_convert_file_check 160006f32fbeSmrg 160106f32fbeSmrg 160206f32fbeSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 160306f32fbeSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 160406f32fbeSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 160506f32fbeSmrg# func_to_host_file_result to a simplistic fallback value (see below). 160606f32fbeSmrgfunc_convert_path_check () 160706f32fbeSmrg{ 160806f32fbeSmrg $opt_debug 160906f32fbeSmrg if test -z "$4" && test -n "$3"; then 161006f32fbeSmrg func_error "Could not determine the host path corresponding to" 161106f32fbeSmrg func_error " \`$3'" 161206f32fbeSmrg func_error "Continuing, but uninstalled executables may not work." 161306f32fbeSmrg # Fallback. This is a deliberately simplistic "conversion" and 161406f32fbeSmrg # should not be "improved". See libtool.info. 161506f32fbeSmrg if test "x$1" != "x$2"; then 161606f32fbeSmrg lt_replace_pathsep_chars="s|$1|$2|g" 161706f32fbeSmrg func_to_host_path_result=`echo "$3" | 161806f32fbeSmrg $SED -e "$lt_replace_pathsep_chars"` 161906f32fbeSmrg else 162006f32fbeSmrg func_to_host_path_result="$3" 162106f32fbeSmrg fi 162206f32fbeSmrg fi 162306f32fbeSmrg} 162406f32fbeSmrg# end func_convert_path_check 162506f32fbeSmrg 162606f32fbeSmrg 162706f32fbeSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 162806f32fbeSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 162906f32fbeSmrg# and appending REPL if ORIG matches BACKPAT. 163006f32fbeSmrgfunc_convert_path_front_back_pathsep () 163106f32fbeSmrg{ 163206f32fbeSmrg $opt_debug 163306f32fbeSmrg case $4 in 163406f32fbeSmrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 163506f32fbeSmrg ;; 163606f32fbeSmrg esac 163706f32fbeSmrg case $4 in 163806f32fbeSmrg $2 ) func_append func_to_host_path_result "$3" 163906f32fbeSmrg ;; 164006f32fbeSmrg esac 164106f32fbeSmrg} 164206f32fbeSmrg# end func_convert_path_front_back_pathsep 164306f32fbeSmrg 164406f32fbeSmrg 164506f32fbeSmrg################################################## 164606f32fbeSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 164706f32fbeSmrg################################################## 164806f32fbeSmrg# invoked via `$to_host_file_cmd ARG' 164906f32fbeSmrg# 165006f32fbeSmrg# In each case, ARG is the path to be converted from $build to $host format. 165106f32fbeSmrg# Result will be available in $func_to_host_file_result. 165206f32fbeSmrg 165306f32fbeSmrg 165406f32fbeSmrg# func_to_host_file ARG 165506f32fbeSmrg# Converts the file name ARG from $build format to $host format. Return result 165606f32fbeSmrg# in func_to_host_file_result. 165706f32fbeSmrgfunc_to_host_file () 165806f32fbeSmrg{ 165906f32fbeSmrg $opt_debug 166006f32fbeSmrg $to_host_file_cmd "$1" 166106f32fbeSmrg} 166206f32fbeSmrg# end func_to_host_file 166306f32fbeSmrg 166406f32fbeSmrg 166506f32fbeSmrg# func_to_tool_file ARG LAZY 166606f32fbeSmrg# converts the file name ARG from $build format to toolchain format. Return 166706f32fbeSmrg# result in func_to_tool_file_result. If the conversion in use is listed 166806f32fbeSmrg# in (the comma separated) LAZY, no conversion takes place. 166906f32fbeSmrgfunc_to_tool_file () 167006f32fbeSmrg{ 167106f32fbeSmrg $opt_debug 167206f32fbeSmrg case ,$2, in 167306f32fbeSmrg *,"$to_tool_file_cmd",*) 167406f32fbeSmrg func_to_tool_file_result=$1 167506f32fbeSmrg ;; 167606f32fbeSmrg *) 167706f32fbeSmrg $to_tool_file_cmd "$1" 167806f32fbeSmrg func_to_tool_file_result=$func_to_host_file_result 167906f32fbeSmrg ;; 168006f32fbeSmrg esac 168106f32fbeSmrg} 168206f32fbeSmrg# end func_to_tool_file 168306f32fbeSmrg 168406f32fbeSmrg 168506f32fbeSmrg# func_convert_file_noop ARG 168606f32fbeSmrg# Copy ARG to func_to_host_file_result. 168706f32fbeSmrgfunc_convert_file_noop () 168806f32fbeSmrg{ 168906f32fbeSmrg func_to_host_file_result="$1" 169006f32fbeSmrg} 169106f32fbeSmrg# end func_convert_file_noop 169206f32fbeSmrg 169306f32fbeSmrg 169406f32fbeSmrg# func_convert_file_msys_to_w32 ARG 169506f32fbeSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 169606f32fbeSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 169706f32fbeSmrg# func_to_host_file_result. 169806f32fbeSmrgfunc_convert_file_msys_to_w32 () 169906f32fbeSmrg{ 170006f32fbeSmrg $opt_debug 170106f32fbeSmrg func_to_host_file_result="$1" 170206f32fbeSmrg if test -n "$1"; then 170306f32fbeSmrg func_convert_core_msys_to_w32 "$1" 170406f32fbeSmrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 170506f32fbeSmrg fi 170606f32fbeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 170706f32fbeSmrg} 170806f32fbeSmrg# end func_convert_file_msys_to_w32 170906f32fbeSmrg 171006f32fbeSmrg 171106f32fbeSmrg# func_convert_file_cygwin_to_w32 ARG 171206f32fbeSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 171306f32fbeSmrg# func_to_host_file_result. 171406f32fbeSmrgfunc_convert_file_cygwin_to_w32 () 171506f32fbeSmrg{ 171606f32fbeSmrg $opt_debug 171706f32fbeSmrg func_to_host_file_result="$1" 171806f32fbeSmrg if test -n "$1"; then 171906f32fbeSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 172006f32fbeSmrg # LT_CYGPATH in this case. 172106f32fbeSmrg func_to_host_file_result=`cygpath -m "$1"` 172206f32fbeSmrg fi 172306f32fbeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 172406f32fbeSmrg} 172506f32fbeSmrg# end func_convert_file_cygwin_to_w32 172606f32fbeSmrg 172706f32fbeSmrg 172806f32fbeSmrg# func_convert_file_nix_to_w32 ARG 172906f32fbeSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 173006f32fbeSmrg# and a working winepath. Returns result in func_to_host_file_result. 173106f32fbeSmrgfunc_convert_file_nix_to_w32 () 173206f32fbeSmrg{ 173306f32fbeSmrg $opt_debug 173406f32fbeSmrg func_to_host_file_result="$1" 173506f32fbeSmrg if test -n "$1"; then 173606f32fbeSmrg func_convert_core_file_wine_to_w32 "$1" 173706f32fbeSmrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 173806f32fbeSmrg fi 173906f32fbeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 174006f32fbeSmrg} 174106f32fbeSmrg# end func_convert_file_nix_to_w32 174206f32fbeSmrg 174306f32fbeSmrg 174406f32fbeSmrg# func_convert_file_msys_to_cygwin ARG 174506f32fbeSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 174606f32fbeSmrg# Returns result in func_to_host_file_result. 174706f32fbeSmrgfunc_convert_file_msys_to_cygwin () 174806f32fbeSmrg{ 174906f32fbeSmrg $opt_debug 175006f32fbeSmrg func_to_host_file_result="$1" 175106f32fbeSmrg if test -n "$1"; then 175206f32fbeSmrg func_convert_core_msys_to_w32 "$1" 175306f32fbeSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 175406f32fbeSmrg func_to_host_file_result="$func_cygpath_result" 175506f32fbeSmrg fi 175606f32fbeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 175706f32fbeSmrg} 175806f32fbeSmrg# end func_convert_file_msys_to_cygwin 175906f32fbeSmrg 176006f32fbeSmrg 176106f32fbeSmrg# func_convert_file_nix_to_cygwin ARG 176206f32fbeSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 176306f32fbeSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 176406f32fbeSmrg# in func_to_host_file_result. 176506f32fbeSmrgfunc_convert_file_nix_to_cygwin () 176606f32fbeSmrg{ 176706f32fbeSmrg $opt_debug 176806f32fbeSmrg func_to_host_file_result="$1" 176906f32fbeSmrg if test -n "$1"; then 177006f32fbeSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 177106f32fbeSmrg func_convert_core_file_wine_to_w32 "$1" 177206f32fbeSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 177306f32fbeSmrg func_to_host_file_result="$func_cygpath_result" 177406f32fbeSmrg fi 177506f32fbeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 177606f32fbeSmrg} 177706f32fbeSmrg# end func_convert_file_nix_to_cygwin 177806f32fbeSmrg 177906f32fbeSmrg 178006f32fbeSmrg############################################# 178106f32fbeSmrg# $build to $host PATH CONVERSION FUNCTIONS # 178206f32fbeSmrg############################################# 178306f32fbeSmrg# invoked via `$to_host_path_cmd ARG' 178406f32fbeSmrg# 178506f32fbeSmrg# In each case, ARG is the path to be converted from $build to $host format. 178606f32fbeSmrg# The result will be available in $func_to_host_path_result. 178706f32fbeSmrg# 178806f32fbeSmrg# Path separators are also converted from $build format to $host format. If 178906f32fbeSmrg# ARG begins or ends with a path separator character, it is preserved (but 179006f32fbeSmrg# converted to $host format) on output. 179106f32fbeSmrg# 179206f32fbeSmrg# All path conversion functions are named using the following convention: 179306f32fbeSmrg# file name conversion function : func_convert_file_X_to_Y () 179406f32fbeSmrg# path conversion function : func_convert_path_X_to_Y () 179506f32fbeSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 179606f32fbeSmrg# same. If conversion functions are added for new $build/$host combinations, 179706f32fbeSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 179806f32fbeSmrg# will break. 179906f32fbeSmrg 180006f32fbeSmrg 180106f32fbeSmrg# func_init_to_host_path_cmd 180206f32fbeSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 180306f32fbeSmrg# appropriate value, based on the value of $to_host_file_cmd. 180406f32fbeSmrgto_host_path_cmd= 180506f32fbeSmrgfunc_init_to_host_path_cmd () 180606f32fbeSmrg{ 180706f32fbeSmrg $opt_debug 180806f32fbeSmrg if test -z "$to_host_path_cmd"; then 180906f32fbeSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 181006f32fbeSmrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 181106f32fbeSmrg fi 181206f32fbeSmrg} 181306f32fbeSmrg 181406f32fbeSmrg 181506f32fbeSmrg# func_to_host_path ARG 181606f32fbeSmrg# Converts the path ARG from $build format to $host format. Return result 181706f32fbeSmrg# in func_to_host_path_result. 181806f32fbeSmrgfunc_to_host_path () 181906f32fbeSmrg{ 182006f32fbeSmrg $opt_debug 182106f32fbeSmrg func_init_to_host_path_cmd 182206f32fbeSmrg $to_host_path_cmd "$1" 182306f32fbeSmrg} 182406f32fbeSmrg# end func_to_host_path 182506f32fbeSmrg 182606f32fbeSmrg 182706f32fbeSmrg# func_convert_path_noop ARG 182806f32fbeSmrg# Copy ARG to func_to_host_path_result. 182906f32fbeSmrgfunc_convert_path_noop () 183006f32fbeSmrg{ 183106f32fbeSmrg func_to_host_path_result="$1" 183206f32fbeSmrg} 183306f32fbeSmrg# end func_convert_path_noop 183406f32fbeSmrg 183506f32fbeSmrg 183606f32fbeSmrg# func_convert_path_msys_to_w32 ARG 183706f32fbeSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 183806f32fbeSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 183906f32fbeSmrg# func_to_host_path_result. 184006f32fbeSmrgfunc_convert_path_msys_to_w32 () 1841ea133fd7Smrg{ 184206f32fbeSmrg $opt_debug 184306f32fbeSmrg func_to_host_path_result="$1" 184406f32fbeSmrg if test -n "$1"; then 184506f32fbeSmrg # Remove leading and trailing path separator characters from ARG. MSYS 184606f32fbeSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 184706f32fbeSmrg # and winepath ignores them completely. 184806f32fbeSmrg func_stripname : : "$1" 184906f32fbeSmrg func_to_host_path_tmp1=$func_stripname_result 185006f32fbeSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 185106f32fbeSmrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 185206f32fbeSmrg func_convert_path_check : ";" \ 185306f32fbeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 185406f32fbeSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 185506f32fbeSmrg fi 185606f32fbeSmrg} 185706f32fbeSmrg# end func_convert_path_msys_to_w32 1858ea133fd7Smrg 1859ea133fd7Smrg 186006f32fbeSmrg# func_convert_path_cygwin_to_w32 ARG 186106f32fbeSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 186206f32fbeSmrg# func_to_host_file_result. 186306f32fbeSmrgfunc_convert_path_cygwin_to_w32 () 186406f32fbeSmrg{ 186506f32fbeSmrg $opt_debug 186606f32fbeSmrg func_to_host_path_result="$1" 186706f32fbeSmrg if test -n "$1"; then 186806f32fbeSmrg # See func_convert_path_msys_to_w32: 186906f32fbeSmrg func_stripname : : "$1" 187006f32fbeSmrg func_to_host_path_tmp1=$func_stripname_result 187106f32fbeSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 187206f32fbeSmrg func_convert_path_check : ";" \ 187306f32fbeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 187406f32fbeSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 187506f32fbeSmrg fi 187606f32fbeSmrg} 187706f32fbeSmrg# end func_convert_path_cygwin_to_w32 1878ea133fd7Smrg 1879ea133fd7Smrg 188006f32fbeSmrg# func_convert_path_nix_to_w32 ARG 188106f32fbeSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 188206f32fbeSmrg# a working winepath. Returns result in func_to_host_file_result. 188306f32fbeSmrgfunc_convert_path_nix_to_w32 () 188406f32fbeSmrg{ 188506f32fbeSmrg $opt_debug 188606f32fbeSmrg func_to_host_path_result="$1" 188706f32fbeSmrg if test -n "$1"; then 188806f32fbeSmrg # See func_convert_path_msys_to_w32: 188906f32fbeSmrg func_stripname : : "$1" 189006f32fbeSmrg func_to_host_path_tmp1=$func_stripname_result 189106f32fbeSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 189206f32fbeSmrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 189306f32fbeSmrg func_convert_path_check : ";" \ 189406f32fbeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 189506f32fbeSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 189606f32fbeSmrg fi 189706f32fbeSmrg} 189806f32fbeSmrg# end func_convert_path_nix_to_w32 1899ea133fd7Smrg 190006f32fbeSmrg 190106f32fbeSmrg# func_convert_path_msys_to_cygwin ARG 190206f32fbeSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 190306f32fbeSmrg# Returns result in func_to_host_file_result. 190406f32fbeSmrgfunc_convert_path_msys_to_cygwin () 190506f32fbeSmrg{ 190606f32fbeSmrg $opt_debug 190706f32fbeSmrg func_to_host_path_result="$1" 190806f32fbeSmrg if test -n "$1"; then 190906f32fbeSmrg # See func_convert_path_msys_to_w32: 191006f32fbeSmrg func_stripname : : "$1" 191106f32fbeSmrg func_to_host_path_tmp1=$func_stripname_result 191206f32fbeSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 191306f32fbeSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 191406f32fbeSmrg func_to_host_path_result="$func_cygpath_result" 191506f32fbeSmrg func_convert_path_check : : \ 191606f32fbeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 191706f32fbeSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 191806f32fbeSmrg fi 191906f32fbeSmrg} 192006f32fbeSmrg# end func_convert_path_msys_to_cygwin 192106f32fbeSmrg 192206f32fbeSmrg 192306f32fbeSmrg# func_convert_path_nix_to_cygwin ARG 192406f32fbeSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 192506f32fbeSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 192606f32fbeSmrg# func_to_host_file_result. 192706f32fbeSmrgfunc_convert_path_nix_to_cygwin () 192806f32fbeSmrg{ 192906f32fbeSmrg $opt_debug 193006f32fbeSmrg func_to_host_path_result="$1" 193106f32fbeSmrg if test -n "$1"; then 193206f32fbeSmrg # Remove leading and trailing path separator characters from 193306f32fbeSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 193406f32fbeSmrg # into '.;' and ';.', and winepath ignores them completely. 193506f32fbeSmrg func_stripname : : "$1" 193606f32fbeSmrg func_to_host_path_tmp1=$func_stripname_result 193706f32fbeSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 193806f32fbeSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 193906f32fbeSmrg func_to_host_path_result="$func_cygpath_result" 194006f32fbeSmrg func_convert_path_check : : \ 194106f32fbeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 194206f32fbeSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 194306f32fbeSmrg fi 1944ea133fd7Smrg} 194506f32fbeSmrg# end func_convert_path_nix_to_cygwin 194606f32fbeSmrg 1947ea133fd7Smrg 1948ea133fd7Smrg# func_mode_compile arg... 1949ea133fd7Smrgfunc_mode_compile () 1950ea133fd7Smrg{ 1951ea133fd7Smrg $opt_debug 1952ea133fd7Smrg # Get the compilation command and the source file. 1953ea133fd7Smrg base_compile= 1954ea133fd7Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 1955ea133fd7Smrg suppress_opt=yes 1956ea133fd7Smrg suppress_output= 1957ea133fd7Smrg arg_mode=normal 1958ea133fd7Smrg libobj= 1959ea133fd7Smrg later= 1960ea133fd7Smrg pie_flag= 1961ea133fd7Smrg 1962ea133fd7Smrg for arg 1963ea133fd7Smrg do 1964ea133fd7Smrg case $arg_mode in 1965ea133fd7Smrg arg ) 1966ea133fd7Smrg # do not "continue". Instead, add this to base_compile 1967ea133fd7Smrg lastarg="$arg" 1968ea133fd7Smrg arg_mode=normal 1969ea133fd7Smrg ;; 1970ea133fd7Smrg 1971ea133fd7Smrg target ) 1972ea133fd7Smrg libobj="$arg" 1973ea133fd7Smrg arg_mode=normal 1974ea133fd7Smrg continue 1975ea133fd7Smrg ;; 1976ea133fd7Smrg 1977ea133fd7Smrg normal ) 1978ea133fd7Smrg # Accept any command-line options. 1979ea133fd7Smrg case $arg in 1980ea133fd7Smrg -o) 1981ea133fd7Smrg test -n "$libobj" && \ 1982ea133fd7Smrg func_fatal_error "you cannot specify \`-o' more than once" 1983ea133fd7Smrg arg_mode=target 1984ea133fd7Smrg continue 1985ea133fd7Smrg ;; 1986ea133fd7Smrg 1987ea133fd7Smrg -pie | -fpie | -fPIE) 198806f32fbeSmrg func_append pie_flag " $arg" 1989ea133fd7Smrg continue 1990ea133fd7Smrg ;; 1991ea133fd7Smrg 1992ea133fd7Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 199306f32fbeSmrg func_append later " $arg" 1994ea133fd7Smrg continue 1995ea133fd7Smrg ;; 1996ea133fd7Smrg 1997ea133fd7Smrg -no-suppress) 1998ea133fd7Smrg suppress_opt=no 1999ea133fd7Smrg continue 2000ea133fd7Smrg ;; 2001ea133fd7Smrg 2002ea133fd7Smrg -Xcompiler) 2003ea133fd7Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 2004ea133fd7Smrg continue # The current "srcfile" will either be retained or 2005ea133fd7Smrg ;; # replaced later. I would guess that would be a bug. 2006ea133fd7Smrg 2007ea133fd7Smrg -Wc,*) 2008ea133fd7Smrg func_stripname '-Wc,' '' "$arg" 2009ea133fd7Smrg args=$func_stripname_result 2010ea133fd7Smrg lastarg= 2011ea133fd7Smrg save_ifs="$IFS"; IFS=',' 2012ea133fd7Smrg for arg in $args; do 2013ea133fd7Smrg IFS="$save_ifs" 201406f32fbeSmrg func_append_quoted lastarg "$arg" 2015a253d6aeSmrg done 2016a253d6aeSmrg IFS="$save_ifs" 2017ea133fd7Smrg func_stripname ' ' '' "$lastarg" 2018ea133fd7Smrg lastarg=$func_stripname_result 2019a253d6aeSmrg 2020a253d6aeSmrg # Add the arguments to base_compile. 202106f32fbeSmrg func_append base_compile " $lastarg" 2022a253d6aeSmrg continue 2023a253d6aeSmrg ;; 2024a253d6aeSmrg 2025ea133fd7Smrg *) 2026a253d6aeSmrg # Accept the current argument as the source file. 2027a253d6aeSmrg # The previous "srcfile" becomes the current argument. 2028a253d6aeSmrg # 2029a253d6aeSmrg lastarg="$srcfile" 2030a253d6aeSmrg srcfile="$arg" 2031a253d6aeSmrg ;; 2032a253d6aeSmrg esac # case $arg 2033a253d6aeSmrg ;; 2034a253d6aeSmrg esac # case $arg_mode 2035a253d6aeSmrg 2036a253d6aeSmrg # Aesthetically quote the previous argument. 203706f32fbeSmrg func_append_quoted base_compile "$lastarg" 2038a253d6aeSmrg done # for arg 2039a253d6aeSmrg 2040a253d6aeSmrg case $arg_mode in 2041a253d6aeSmrg arg) 2042ea133fd7Smrg func_fatal_error "you must specify an argument for -Xcompile" 2043a253d6aeSmrg ;; 2044a253d6aeSmrg target) 2045ea133fd7Smrg func_fatal_error "you must specify a target with \`-o'" 2046a253d6aeSmrg ;; 2047a253d6aeSmrg *) 2048a253d6aeSmrg # Get the name of the library object. 2049ea133fd7Smrg test -z "$libobj" && { 2050ea133fd7Smrg func_basename "$srcfile" 2051ea133fd7Smrg libobj="$func_basename_result" 2052ea133fd7Smrg } 2053a253d6aeSmrg ;; 2054a253d6aeSmrg esac 2055a253d6aeSmrg 2056a253d6aeSmrg # Recognize several different file suffixes. 2057a253d6aeSmrg # If the user specifies -o file.o, it is replaced with file.lo 2058a253d6aeSmrg case $libobj in 2059ea133fd7Smrg *.[cCFSifmso] | \ 2060ea133fd7Smrg *.ada | *.adb | *.ads | *.asm | \ 2061ea133fd7Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 206225b89263Smrg *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) 2063ea133fd7Smrg func_xform "$libobj" 2064ea133fd7Smrg libobj=$func_xform_result 2065ea133fd7Smrg ;; 2066a253d6aeSmrg esac 2067a253d6aeSmrg 2068a253d6aeSmrg case $libobj in 2069ea133fd7Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2070a253d6aeSmrg *) 2071ea133fd7Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 2072a253d6aeSmrg ;; 2073a253d6aeSmrg esac 2074a253d6aeSmrg 2075a253d6aeSmrg func_infer_tag $base_compile 2076a253d6aeSmrg 2077a253d6aeSmrg for arg in $later; do 2078a253d6aeSmrg case $arg in 2079ea133fd7Smrg -shared) 2080ea133fd7Smrg test "$build_libtool_libs" != yes && \ 2081ea133fd7Smrg func_fatal_configuration "can not build a shared library" 2082ea133fd7Smrg build_old_libs=no 2083ea133fd7Smrg continue 2084ea133fd7Smrg ;; 2085ea133fd7Smrg 2086a253d6aeSmrg -static) 2087ea133fd7Smrg build_libtool_libs=no 2088a253d6aeSmrg build_old_libs=yes 2089a253d6aeSmrg continue 2090a253d6aeSmrg ;; 2091a253d6aeSmrg 2092a253d6aeSmrg -prefer-pic) 2093a253d6aeSmrg pic_mode=yes 2094a253d6aeSmrg continue 2095a253d6aeSmrg ;; 2096a253d6aeSmrg 2097a253d6aeSmrg -prefer-non-pic) 2098a253d6aeSmrg pic_mode=no 2099a253d6aeSmrg continue 2100a253d6aeSmrg ;; 2101a253d6aeSmrg esac 2102a253d6aeSmrg done 2103a253d6aeSmrg 2104ea133fd7Smrg func_quote_for_eval "$libobj" 2105ea133fd7Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 2106ea133fd7Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 2107ea133fd7Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 2108ea133fd7Smrg func_dirname_and_basename "$obj" "/" "" 2109ea133fd7Smrg objname="$func_basename_result" 2110ea133fd7Smrg xdir="$func_dirname_result" 2111a253d6aeSmrg lobj=${xdir}$objdir/$objname 2112a253d6aeSmrg 2113ea133fd7Smrg test -z "$base_compile" && \ 2114ea133fd7Smrg func_fatal_help "you must specify a compilation command" 2115a253d6aeSmrg 2116a253d6aeSmrg # Delete any leftover library objects. 2117a253d6aeSmrg if test "$build_old_libs" = yes; then 2118a253d6aeSmrg removelist="$obj $lobj $libobj ${libobj}T" 2119a253d6aeSmrg else 2120a253d6aeSmrg removelist="$lobj $libobj ${libobj}T" 2121a253d6aeSmrg fi 2122a253d6aeSmrg 2123a253d6aeSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 2124a253d6aeSmrg case $host_os in 2125ea133fd7Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 2126a253d6aeSmrg pic_mode=default 2127a253d6aeSmrg ;; 2128a253d6aeSmrg esac 2129a253d6aeSmrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2130a253d6aeSmrg # non-PIC code in shared libraries is not supported 2131a253d6aeSmrg pic_mode=default 2132a253d6aeSmrg fi 2133a253d6aeSmrg 2134a253d6aeSmrg # Calculate the filename of the output object if compiler does 2135a253d6aeSmrg # not support -o with -c 2136a253d6aeSmrg if test "$compiler_c_o" = no; then 213725b89263Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2138a253d6aeSmrg lockfile="$output_obj.lock" 2139a253d6aeSmrg else 2140a253d6aeSmrg output_obj= 2141a253d6aeSmrg need_locks=no 2142a253d6aeSmrg lockfile= 2143a253d6aeSmrg fi 2144a253d6aeSmrg 2145a253d6aeSmrg # Lock this critical section if it is needed 2146a253d6aeSmrg # We use this script file to make the link, it avoids creating a new file 2147a253d6aeSmrg if test "$need_locks" = yes; then 2148ea133fd7Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 2149ea133fd7Smrg func_echo "Waiting for $lockfile to be removed" 2150a253d6aeSmrg sleep 2 2151a253d6aeSmrg done 2152a253d6aeSmrg elif test "$need_locks" = warn; then 2153a253d6aeSmrg if test -f "$lockfile"; then 2154ea133fd7Smrg $ECHO "\ 2155a253d6aeSmrg*** ERROR, $lockfile exists and contains: 2156a253d6aeSmrg`cat $lockfile 2>/dev/null` 2157a253d6aeSmrg 2158a253d6aeSmrgThis indicates that another process is trying to use the same 2159a253d6aeSmrgtemporary object file, and libtool could not work around it because 2160a253d6aeSmrgyour compiler does not support \`-c' and \`-o' together. If you 2161a253d6aeSmrgrepeat this compilation, it may succeed, by chance, but you had better 2162a253d6aeSmrgavoid parallel builds (make -j) in this platform, or get a better 2163a253d6aeSmrgcompiler." 2164a253d6aeSmrg 2165ea133fd7Smrg $opt_dry_run || $RM $removelist 2166a253d6aeSmrg exit $EXIT_FAILURE 2167a253d6aeSmrg fi 216806f32fbeSmrg func_append removelist " $output_obj" 2169ea133fd7Smrg $ECHO "$srcfile" > "$lockfile" 2170a253d6aeSmrg fi 2171a253d6aeSmrg 2172ea133fd7Smrg $opt_dry_run || $RM $removelist 217306f32fbeSmrg func_append removelist " $lockfile" 2174ea133fd7Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 2175ea133fd7Smrg 217606f32fbeSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 217706f32fbeSmrg srcfile=$func_to_tool_file_result 2178ea133fd7Smrg func_quote_for_eval "$srcfile" 2179ea133fd7Smrg qsrcfile=$func_quote_for_eval_result 2180a253d6aeSmrg 2181a253d6aeSmrg # Only build a PIC object if we are building libtool libraries. 2182a253d6aeSmrg if test "$build_libtool_libs" = yes; then 2183a253d6aeSmrg # Without this assignment, base_compile gets emptied. 2184a253d6aeSmrg fbsd_hideous_sh_bug=$base_compile 2185a253d6aeSmrg 2186a253d6aeSmrg if test "$pic_mode" != no; then 2187a253d6aeSmrg command="$base_compile $qsrcfile $pic_flag" 2188a253d6aeSmrg else 2189a253d6aeSmrg # Don't build PIC code 2190a253d6aeSmrg command="$base_compile $qsrcfile" 2191a253d6aeSmrg fi 2192a253d6aeSmrg 2193ea133fd7Smrg func_mkdir_p "$xdir$objdir" 2194a253d6aeSmrg 2195a253d6aeSmrg if test -z "$output_obj"; then 2196a253d6aeSmrg # Place PIC objects in $objdir 219706f32fbeSmrg func_append command " -o $lobj" 2198a253d6aeSmrg fi 2199a253d6aeSmrg 2200ea133fd7Smrg func_show_eval_locale "$command" \ 2201ea133fd7Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2202a253d6aeSmrg 2203a253d6aeSmrg if test "$need_locks" = warn && 2204a253d6aeSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2205ea133fd7Smrg $ECHO "\ 2206a253d6aeSmrg*** ERROR, $lockfile contains: 2207a253d6aeSmrg`cat $lockfile 2>/dev/null` 2208a253d6aeSmrg 2209a253d6aeSmrgbut it should contain: 2210a253d6aeSmrg$srcfile 2211a253d6aeSmrg 2212a253d6aeSmrgThis indicates that another process is trying to use the same 2213a253d6aeSmrgtemporary object file, and libtool could not work around it because 2214a253d6aeSmrgyour compiler does not support \`-c' and \`-o' together. If you 2215a253d6aeSmrgrepeat this compilation, it may succeed, by chance, but you had better 2216a253d6aeSmrgavoid parallel builds (make -j) in this platform, or get a better 2217a253d6aeSmrgcompiler." 2218a253d6aeSmrg 2219ea133fd7Smrg $opt_dry_run || $RM $removelist 2220a253d6aeSmrg exit $EXIT_FAILURE 2221a253d6aeSmrg fi 2222a253d6aeSmrg 2223a253d6aeSmrg # Just move the object if needed, then go on to compile the next one 2224a253d6aeSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 2225ea133fd7Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 2226ea133fd7Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2227a253d6aeSmrg fi 2228a253d6aeSmrg 2229a253d6aeSmrg # Allow error messages only from the first compilation. 2230a253d6aeSmrg if test "$suppress_opt" = yes; then 2231ea133fd7Smrg suppress_output=' >/dev/null 2>&1' 2232a253d6aeSmrg fi 2233a253d6aeSmrg fi 2234a253d6aeSmrg 2235a253d6aeSmrg # Only build a position-dependent object if we build old libraries. 2236a253d6aeSmrg if test "$build_old_libs" = yes; then 2237a253d6aeSmrg if test "$pic_mode" != yes; then 2238a253d6aeSmrg # Don't build PIC code 2239ea133fd7Smrg command="$base_compile $qsrcfile$pie_flag" 2240a253d6aeSmrg else 2241a253d6aeSmrg command="$base_compile $qsrcfile $pic_flag" 2242a253d6aeSmrg fi 2243a253d6aeSmrg if test "$compiler_c_o" = yes; then 224406f32fbeSmrg func_append command " -o $obj" 2245a253d6aeSmrg fi 2246a253d6aeSmrg 2247a253d6aeSmrg # Suppress compiler output if we already did a PIC compilation. 224806f32fbeSmrg func_append command "$suppress_output" 2249ea133fd7Smrg func_show_eval_locale "$command" \ 2250ea133fd7Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2251a253d6aeSmrg 2252a253d6aeSmrg if test "$need_locks" = warn && 2253a253d6aeSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2254ea133fd7Smrg $ECHO "\ 2255a253d6aeSmrg*** ERROR, $lockfile contains: 2256a253d6aeSmrg`cat $lockfile 2>/dev/null` 2257a253d6aeSmrg 2258a253d6aeSmrgbut it should contain: 2259a253d6aeSmrg$srcfile 2260a253d6aeSmrg 2261a253d6aeSmrgThis indicates that another process is trying to use the same 2262a253d6aeSmrgtemporary object file, and libtool could not work around it because 2263a253d6aeSmrgyour compiler does not support \`-c' and \`-o' together. If you 2264a253d6aeSmrgrepeat this compilation, it may succeed, by chance, but you had better 2265a253d6aeSmrgavoid parallel builds (make -j) in this platform, or get a better 2266a253d6aeSmrgcompiler." 2267a253d6aeSmrg 2268ea133fd7Smrg $opt_dry_run || $RM $removelist 2269a253d6aeSmrg exit $EXIT_FAILURE 2270a253d6aeSmrg fi 2271a253d6aeSmrg 2272a253d6aeSmrg # Just move the object if needed 2273a253d6aeSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 2274ea133fd7Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 2275ea133fd7Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2276a253d6aeSmrg fi 2277a253d6aeSmrg fi 2278a253d6aeSmrg 2279ea133fd7Smrg $opt_dry_run || { 2280ea133fd7Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2281a253d6aeSmrg 2282ea133fd7Smrg # Unlock the critical section if it was locked 2283ea133fd7Smrg if test "$need_locks" != no; then 2284ea133fd7Smrg removelist=$lockfile 2285ea133fd7Smrg $RM "$lockfile" 2286ea133fd7Smrg fi 2287ea133fd7Smrg } 2288a253d6aeSmrg 2289a253d6aeSmrg exit $EXIT_SUCCESS 2290ea133fd7Smrg} 2291a253d6aeSmrg 2292ea133fd7Smrg$opt_help || { 229306f32fbeSmrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 2294ea133fd7Smrg} 2295a253d6aeSmrg 2296ea133fd7Smrgfunc_mode_help () 2297ea133fd7Smrg{ 2298ea133fd7Smrg # We need to display help for each of the modes. 229906f32fbeSmrg case $opt_mode in 2300ea133fd7Smrg "") 2301ea133fd7Smrg # Generic help is extracted from the usage comments 2302ea133fd7Smrg # at the start of this file. 2303ea133fd7Smrg func_help 2304ea133fd7Smrg ;; 2305a253d6aeSmrg 2306ea133fd7Smrg clean) 2307ea133fd7Smrg $ECHO \ 2308ea133fd7Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2309a253d6aeSmrg 2310ea133fd7SmrgRemove files from the build directory. 2311a253d6aeSmrg 2312ea133fd7SmrgRM is the name of the program to use to delete files associated with each FILE 2313ea133fd7Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2314ea133fd7Smrgto RM. 2315a253d6aeSmrg 2316ea133fd7SmrgIf FILE is a libtool library, object or program, all the files associated 2317ea133fd7Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 2318ea133fd7Smrg ;; 2319a253d6aeSmrg 2320ea133fd7Smrg compile) 2321ea133fd7Smrg $ECHO \ 2322ea133fd7Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2323a253d6aeSmrg 2324ea133fd7SmrgCompile a source file into a libtool library object. 2325a253d6aeSmrg 2326ea133fd7SmrgThis mode accepts the following additional options: 2327a253d6aeSmrg 2328ea133fd7Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 2329ea133fd7Smrg -no-suppress do not suppress compiler output for multiple passes 233025b89263Smrg -prefer-pic try to build PIC objects only 233125b89263Smrg -prefer-non-pic try to build non-PIC objects only 2332ea133fd7Smrg -shared do not build a \`.o' file suitable for static linking 2333ea133fd7Smrg -static only build a \`.o' file suitable for static linking 233425b89263Smrg -Wc,FLAG pass FLAG directly to the compiler 2335a253d6aeSmrg 2336ea133fd7SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 2337ea133fd7Smrgfrom the given SOURCEFILE. 2338a253d6aeSmrg 2339ea133fd7SmrgThe output file name is determined by removing the directory component from 2340ea133fd7SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 2341ea133fd7Smrglibrary object suffix, \`.lo'." 2342ea133fd7Smrg ;; 2343a253d6aeSmrg 2344ea133fd7Smrg execute) 2345ea133fd7Smrg $ECHO \ 2346ea133fd7Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2347a253d6aeSmrg 2348ea133fd7SmrgAutomatically set library path, then run a program. 2349a253d6aeSmrg 2350ea133fd7SmrgThis mode accepts the following additional options: 2351a253d6aeSmrg 2352ea133fd7Smrg -dlopen FILE add the directory containing FILE to the library path 2353a253d6aeSmrg 2354ea133fd7SmrgThis mode sets the library path environment variable according to \`-dlopen' 2355ea133fd7Smrgflags. 2356a253d6aeSmrg 2357ea133fd7SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 2358ea133fd7Smrginto their corresponding uninstalled binary, and any of their required library 2359ea133fd7Smrgdirectories are added to the library path. 2360a253d6aeSmrg 2361ea133fd7SmrgThen, COMMAND is executed, with ARGS as arguments." 2362ea133fd7Smrg ;; 2363a253d6aeSmrg 2364ea133fd7Smrg finish) 2365ea133fd7Smrg $ECHO \ 2366ea133fd7Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2367a253d6aeSmrg 2368ea133fd7SmrgComplete the installation of libtool libraries. 2369a253d6aeSmrg 2370ea133fd7SmrgEach LIBDIR is a directory that contains libtool libraries. 2371a253d6aeSmrg 2372ea133fd7SmrgThe commands that this mode executes may require superuser privileges. Use 2373ea133fd7Smrgthe \`--dry-run' option if you just want to see what would be executed." 2374ea133fd7Smrg ;; 2375a253d6aeSmrg 2376ea133fd7Smrg install) 2377ea133fd7Smrg $ECHO \ 2378ea133fd7Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2379a253d6aeSmrg 2380ea133fd7SmrgInstall executables or libraries. 2381a253d6aeSmrg 2382ea133fd7SmrgINSTALL-COMMAND is the installation command. The first component should be 2383ea133fd7Smrgeither the \`install' or \`cp' program. 2384a253d6aeSmrg 2385ea133fd7SmrgThe following components of INSTALL-COMMAND are treated specially: 2386a253d6aeSmrg 238725b89263Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2388a253d6aeSmrg 2389ea133fd7SmrgThe rest of the components are interpreted as arguments to that command (only 2390ea133fd7SmrgBSD-compatible install options are recognized)." 2391ea133fd7Smrg ;; 2392a253d6aeSmrg 2393ea133fd7Smrg link) 2394ea133fd7Smrg $ECHO \ 2395ea133fd7Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2396a253d6aeSmrg 2397ea133fd7SmrgLink object files or libraries together to form another library, or to 2398ea133fd7Smrgcreate an executable program. 2399a253d6aeSmrg 2400ea133fd7SmrgLINK-COMMAND is a command using the C compiler that you would use to create 2401ea133fd7Smrga program from several object files. 2402a253d6aeSmrg 2403ea133fd7SmrgThe following components of LINK-COMMAND are treated specially: 2404a253d6aeSmrg 2405ea133fd7Smrg -all-static do not do any dynamic linking at all 2406ea133fd7Smrg -avoid-version do not add a version suffix if possible 240725b89263Smrg -bindir BINDIR specify path to binaries directory (for systems where 240825b89263Smrg libraries must be found in the PATH setting at runtime) 2409ea133fd7Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 2410ea133fd7Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 2411ea133fd7Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 2412ea133fd7Smrg -export-symbols SYMFILE 2413ea133fd7Smrg try to export only the symbols listed in SYMFILE 2414ea133fd7Smrg -export-symbols-regex REGEX 2415ea133fd7Smrg try to export only the symbols matching REGEX 2416ea133fd7Smrg -LLIBDIR search LIBDIR for required installed libraries 2417ea133fd7Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 2418ea133fd7Smrg -module build a library that can dlopened 2419ea133fd7Smrg -no-fast-install disable the fast-install mode 2420ea133fd7Smrg -no-install link a not-installable executable 2421ea133fd7Smrg -no-undefined declare that a library does not refer to external symbols 2422ea133fd7Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 2423ea133fd7Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 2424ea133fd7Smrg -precious-files-regex REGEX 2425ea133fd7Smrg don't remove output files matching REGEX 2426ea133fd7Smrg -release RELEASE specify package release information 2427ea133fd7Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 2428ea133fd7Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 2429ea133fd7Smrg -shared only do dynamic linking of libtool libraries 2430ea133fd7Smrg -shrext SUFFIX override the standard shared library file extension 2431ea133fd7Smrg -static do not do any dynamic linking of uninstalled libtool libraries 2432ea133fd7Smrg -static-libtool-libs 2433ea133fd7Smrg do not do any dynamic linking of libtool libraries 2434ea133fd7Smrg -version-info CURRENT[:REVISION[:AGE]] 2435ea133fd7Smrg specify library version info [each variable defaults to 0] 2436ea133fd7Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 243725b89263Smrg -Wc,FLAG 243825b89263Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 243925b89263Smrg -Wl,FLAG 244025b89263Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 244125b89263Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2442a253d6aeSmrg 2443ea133fd7SmrgAll other options (arguments beginning with \`-') are ignored. 2444a253d6aeSmrg 2445ea133fd7SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 2446ea133fd7Smrgtreated as uninstalled libtool libraries, other files are standard or library 2447ea133fd7Smrgobject files. 2448a253d6aeSmrg 2449ea133fd7SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 2450ea133fd7Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 2451ea133fd7Smrgrequired, except when creating a convenience library. 2452a253d6aeSmrg 2453ea133fd7SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 2454ea133fd7Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 2455a253d6aeSmrg 2456ea133fd7SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 2457ea133fd7Smrgis created, otherwise an executable program is created." 2458a253d6aeSmrg ;; 2459a253d6aeSmrg 2460ea133fd7Smrg uninstall) 2461ea133fd7Smrg $ECHO \ 2462ea133fd7Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2463a253d6aeSmrg 2464ea133fd7SmrgRemove libraries from an installation directory. 2465a253d6aeSmrg 2466ea133fd7SmrgRM is the name of the program to use to delete files associated with each FILE 2467ea133fd7Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2468ea133fd7Smrgto RM. 2469a253d6aeSmrg 2470ea133fd7SmrgIf FILE is a libtool library, all the files associated with it are deleted. 2471ea133fd7SmrgOtherwise, only FILE itself is deleted using RM." 2472ea133fd7Smrg ;; 2473a253d6aeSmrg 2474ea133fd7Smrg *) 247506f32fbeSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 2476ea133fd7Smrg ;; 2477ea133fd7Smrg esac 2478a253d6aeSmrg 247925b89263Smrg echo 2480ea133fd7Smrg $ECHO "Try \`$progname --help' for more information about other modes." 2481ea133fd7Smrg} 2482a253d6aeSmrg 248325b89263Smrg# Now that we've collected a possible --mode arg, show help if necessary 248425b89263Smrgif $opt_help; then 248525b89263Smrg if test "$opt_help" = :; then 248625b89263Smrg func_mode_help 248725b89263Smrg else 248825b89263Smrg { 248925b89263Smrg func_help noexit 249006f32fbeSmrg for opt_mode in compile link execute install finish uninstall clean; do 249125b89263Smrg func_mode_help 249225b89263Smrg done 249325b89263Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 249425b89263Smrg { 249525b89263Smrg func_help noexit 249606f32fbeSmrg for opt_mode in compile link execute install finish uninstall clean; do 249725b89263Smrg echo 249825b89263Smrg func_mode_help 249925b89263Smrg done 250025b89263Smrg } | 250125b89263Smrg sed '1d 250225b89263Smrg /^When reporting/,/^Report/{ 250325b89263Smrg H 250425b89263Smrg d 250525b89263Smrg } 250625b89263Smrg $x 250725b89263Smrg /information about other modes/d 250825b89263Smrg /more detailed .*MODE/d 250925b89263Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 251025b89263Smrg fi 251125b89263Smrg exit $? 251225b89263Smrgfi 2513a253d6aeSmrg 2514a253d6aeSmrg 2515ea133fd7Smrg# func_mode_execute arg... 2516ea133fd7Smrgfunc_mode_execute () 2517ea133fd7Smrg{ 2518ea133fd7Smrg $opt_debug 2519ea133fd7Smrg # The first argument is the command name. 2520ea133fd7Smrg cmd="$nonopt" 2521ea133fd7Smrg test -z "$cmd" && \ 2522ea133fd7Smrg func_fatal_help "you must specify a COMMAND" 2523a253d6aeSmrg 2524ea133fd7Smrg # Handle -dlopen flags immediately. 252506f32fbeSmrg for file in $opt_dlopen; do 2526ea133fd7Smrg test -f "$file" \ 2527ea133fd7Smrg || func_fatal_help "\`$file' is not a file" 2528a253d6aeSmrg 2529ea133fd7Smrg dir= 2530ea133fd7Smrg case $file in 2531ea133fd7Smrg *.la) 253206f32fbeSmrg func_resolve_sysroot "$file" 253306f32fbeSmrg file=$func_resolve_sysroot_result 253406f32fbeSmrg 2535ea133fd7Smrg # Check to see that this really is a libtool archive. 2536ea133fd7Smrg func_lalib_unsafe_p "$file" \ 2537ea133fd7Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 2538a253d6aeSmrg 2539ea133fd7Smrg # Read the libtool library. 2540ea133fd7Smrg dlname= 2541ea133fd7Smrg library_names= 2542ea133fd7Smrg func_source "$file" 2543a253d6aeSmrg 2544ea133fd7Smrg # Skip this library if it cannot be dlopened. 2545ea133fd7Smrg if test -z "$dlname"; then 2546ea133fd7Smrg # Warn if it was a shared library. 2547ea133fd7Smrg test -n "$library_names" && \ 2548ea133fd7Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 2549ea133fd7Smrg continue 2550ea133fd7Smrg fi 2551a253d6aeSmrg 2552ea133fd7Smrg func_dirname "$file" "" "." 2553ea133fd7Smrg dir="$func_dirname_result" 2554a253d6aeSmrg 2555ea133fd7Smrg if test -f "$dir/$objdir/$dlname"; then 255606f32fbeSmrg func_append dir "/$objdir" 2557ea133fd7Smrg else 2558ea133fd7Smrg if test ! -f "$dir/$dlname"; then 2559ea133fd7Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 2560ea133fd7Smrg fi 2561ea133fd7Smrg fi 2562a253d6aeSmrg ;; 2563a253d6aeSmrg 2564ea133fd7Smrg *.lo) 2565ea133fd7Smrg # Just add the directory containing the .lo file. 2566ea133fd7Smrg func_dirname "$file" "" "." 2567ea133fd7Smrg dir="$func_dirname_result" 2568a253d6aeSmrg ;; 2569a253d6aeSmrg 2570ea133fd7Smrg *) 2571ea133fd7Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 2572a253d6aeSmrg continue 2573a253d6aeSmrg ;; 2574ea133fd7Smrg esac 2575a253d6aeSmrg 2576ea133fd7Smrg # Get the absolute pathname. 2577ea133fd7Smrg absdir=`cd "$dir" && pwd` 2578ea133fd7Smrg test -n "$absdir" && dir="$absdir" 2579a253d6aeSmrg 2580ea133fd7Smrg # Now add the directory to shlibpath_var. 2581ea133fd7Smrg if eval "test -z \"\$$shlibpath_var\""; then 2582ea133fd7Smrg eval "$shlibpath_var=\"\$dir\"" 2583ea133fd7Smrg else 2584ea133fd7Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2585ea133fd7Smrg fi 2586ea133fd7Smrg done 2587a253d6aeSmrg 2588ea133fd7Smrg # This variable tells wrapper scripts just to set shlibpath_var 2589ea133fd7Smrg # rather than running their programs. 2590ea133fd7Smrg libtool_execute_magic="$magic" 2591a253d6aeSmrg 2592ea133fd7Smrg # Check if any of the arguments is a wrapper script. 2593ea133fd7Smrg args= 2594ea133fd7Smrg for file 2595ea133fd7Smrg do 2596ea133fd7Smrg case $file in 259725b89263Smrg -* | *.la | *.lo ) ;; 2598ea133fd7Smrg *) 2599ea133fd7Smrg # Do a test to see if this is really a libtool program. 2600ea133fd7Smrg if func_ltwrapper_script_p "$file"; then 2601ea133fd7Smrg func_source "$file" 2602ea133fd7Smrg # Transform arg to wrapped name. 2603ea133fd7Smrg file="$progdir/$program" 2604ea133fd7Smrg elif func_ltwrapper_executable_p "$file"; then 2605ea133fd7Smrg func_ltwrapper_scriptname "$file" 2606ea133fd7Smrg func_source "$func_ltwrapper_scriptname_result" 2607ea133fd7Smrg # Transform arg to wrapped name. 2608ea133fd7Smrg file="$progdir/$program" 2609ea133fd7Smrg fi 2610ea133fd7Smrg ;; 2611ea133fd7Smrg esac 2612ea133fd7Smrg # Quote arguments (to preserve shell metacharacters). 261306f32fbeSmrg func_append_quoted args "$file" 2614ea133fd7Smrg done 2615a253d6aeSmrg 2616ea133fd7Smrg if test "X$opt_dry_run" = Xfalse; then 2617ea133fd7Smrg if test -n "$shlibpath_var"; then 2618ea133fd7Smrg # Export the shlibpath_var. 2619ea133fd7Smrg eval "export $shlibpath_var" 2620ea133fd7Smrg fi 2621a253d6aeSmrg 2622ea133fd7Smrg # Restore saved environment variables 2623ea133fd7Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 2624ea133fd7Smrg do 2625ea133fd7Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 2626ea133fd7Smrg $lt_var=\$save_$lt_var; export $lt_var 2627ea133fd7Smrg else 2628ea133fd7Smrg $lt_unset $lt_var 2629ea133fd7Smrg fi" 2630ea133fd7Smrg done 2631a253d6aeSmrg 2632ea133fd7Smrg # Now prepare to actually exec the command. 2633ea133fd7Smrg exec_cmd="\$cmd$args" 2634ea133fd7Smrg else 2635ea133fd7Smrg # Display what would be done. 2636ea133fd7Smrg if test -n "$shlibpath_var"; then 2637ea133fd7Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 263825b89263Smrg echo "export $shlibpath_var" 2639ea133fd7Smrg fi 2640ea133fd7Smrg $ECHO "$cmd$args" 2641ea133fd7Smrg exit $EXIT_SUCCESS 2642ea133fd7Smrg fi 2643ea133fd7Smrg} 2644a253d6aeSmrg 264506f32fbeSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2646a253d6aeSmrg 2647a253d6aeSmrg 2648ea133fd7Smrg# func_mode_finish arg... 2649ea133fd7Smrgfunc_mode_finish () 2650ea133fd7Smrg{ 2651ea133fd7Smrg $opt_debug 265206f32fbeSmrg libs= 265306f32fbeSmrg libdirs= 2654ea133fd7Smrg admincmds= 2655a253d6aeSmrg 265606f32fbeSmrg for opt in "$nonopt" ${1+"$@"} 265706f32fbeSmrg do 265806f32fbeSmrg if test -d "$opt"; then 265906f32fbeSmrg func_append libdirs " $opt" 266006f32fbeSmrg 266106f32fbeSmrg elif test -f "$opt"; then 266206f32fbeSmrg if func_lalib_unsafe_p "$opt"; then 266306f32fbeSmrg func_append libs " $opt" 266406f32fbeSmrg else 266506f32fbeSmrg func_warning "\`$opt' is not a valid libtool archive" 266606f32fbeSmrg fi 266706f32fbeSmrg 266806f32fbeSmrg else 266906f32fbeSmrg func_fatal_error "invalid argument \`$opt'" 267006f32fbeSmrg fi 267106f32fbeSmrg done 267206f32fbeSmrg 267306f32fbeSmrg if test -n "$libs"; then 267406f32fbeSmrg if test -n "$lt_sysroot"; then 267506f32fbeSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 267606f32fbeSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 267706f32fbeSmrg else 267806f32fbeSmrg sysroot_cmd= 267906f32fbeSmrg fi 268006f32fbeSmrg 268106f32fbeSmrg # Remove sysroot references 268206f32fbeSmrg if $opt_dry_run; then 268306f32fbeSmrg for lib in $libs; do 268406f32fbeSmrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 268506f32fbeSmrg done 268606f32fbeSmrg else 268706f32fbeSmrg tmpdir=`func_mktempdir` 268806f32fbeSmrg for lib in $libs; do 268906f32fbeSmrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 269006f32fbeSmrg > $tmpdir/tmp-la 269106f32fbeSmrg mv -f $tmpdir/tmp-la $lib 269206f32fbeSmrg done 269306f32fbeSmrg ${RM}r "$tmpdir" 269406f32fbeSmrg fi 269506f32fbeSmrg fi 2696a253d6aeSmrg 269706f32fbeSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2698ea133fd7Smrg for libdir in $libdirs; do 2699ea133fd7Smrg if test -n "$finish_cmds"; then 2700ea133fd7Smrg # Do each command in the finish commands. 2701ea133fd7Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 2702ea133fd7Smrg'"$cmd"'"' 2703ea133fd7Smrg fi 2704ea133fd7Smrg if test -n "$finish_eval"; then 2705ea133fd7Smrg # Do the single finish_eval. 2706ea133fd7Smrg eval cmds=\"$finish_eval\" 270706f32fbeSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 2708ea133fd7Smrg $cmds" 2709ea133fd7Smrg fi 2710ea133fd7Smrg done 2711ea133fd7Smrg fi 2712a253d6aeSmrg 2713ea133fd7Smrg # Exit here if they wanted silent mode. 2714ea133fd7Smrg $opt_silent && exit $EXIT_SUCCESS 2715a253d6aeSmrg 271606f32fbeSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 271706f32fbeSmrg echo "----------------------------------------------------------------------" 271806f32fbeSmrg echo "Libraries have been installed in:" 271906f32fbeSmrg for libdir in $libdirs; do 272006f32fbeSmrg $ECHO " $libdir" 272106f32fbeSmrg done 272206f32fbeSmrg echo 272306f32fbeSmrg echo "If you ever happen to want to link against installed libraries" 272406f32fbeSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 272506f32fbeSmrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 272606f32fbeSmrg echo "flag during linking and do at least one of the following:" 272706f32fbeSmrg if test -n "$shlibpath_var"; then 272806f32fbeSmrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 272906f32fbeSmrg echo " during execution" 273006f32fbeSmrg fi 273106f32fbeSmrg if test -n "$runpath_var"; then 273206f32fbeSmrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 273306f32fbeSmrg echo " during linking" 273406f32fbeSmrg fi 273506f32fbeSmrg if test -n "$hardcode_libdir_flag_spec"; then 273606f32fbeSmrg libdir=LIBDIR 273706f32fbeSmrg eval flag=\"$hardcode_libdir_flag_spec\" 2738a253d6aeSmrg 273906f32fbeSmrg $ECHO " - use the \`$flag' linker flag" 274006f32fbeSmrg fi 274106f32fbeSmrg if test -n "$admincmds"; then 274206f32fbeSmrg $ECHO " - have your system administrator run these commands:$admincmds" 274306f32fbeSmrg fi 274406f32fbeSmrg if test -f /etc/ld.so.conf; then 274506f32fbeSmrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 274606f32fbeSmrg fi 274706f32fbeSmrg echo 2748a253d6aeSmrg 274906f32fbeSmrg echo "See any operating system documentation about shared libraries for" 275006f32fbeSmrg case $host in 275106f32fbeSmrg solaris2.[6789]|solaris2.1[0-9]) 275206f32fbeSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 275306f32fbeSmrg echo "pages." 275406f32fbeSmrg ;; 275506f32fbeSmrg *) 275606f32fbeSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 275706f32fbeSmrg ;; 275806f32fbeSmrg esac 275906f32fbeSmrg echo "----------------------------------------------------------------------" 276006f32fbeSmrg fi 2761ea133fd7Smrg exit $EXIT_SUCCESS 2762ea133fd7Smrg} 2763a253d6aeSmrg 276406f32fbeSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2765a253d6aeSmrg 2766a253d6aeSmrg 2767ea133fd7Smrg# func_mode_install arg... 2768ea133fd7Smrgfunc_mode_install () 2769ea133fd7Smrg{ 2770ea133fd7Smrg $opt_debug 2771ea133fd7Smrg # There may be an optional sh(1) argument at the beginning of 2772ea133fd7Smrg # install_prog (especially on Windows NT). 2773ea133fd7Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 2774ea133fd7Smrg # Allow the use of GNU shtool's install command. 277525b89263Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 2776ea133fd7Smrg # Aesthetically quote it. 2777ea133fd7Smrg func_quote_for_eval "$nonopt" 2778ea133fd7Smrg install_prog="$func_quote_for_eval_result " 2779ea133fd7Smrg arg=$1 2780ea133fd7Smrg shift 2781ea133fd7Smrg else 2782ea133fd7Smrg install_prog= 2783ea133fd7Smrg arg=$nonopt 2784ea133fd7Smrg fi 2785a253d6aeSmrg 2786ea133fd7Smrg # The real first argument should be the name of the installation program. 2787ea133fd7Smrg # Aesthetically quote it. 2788ea133fd7Smrg func_quote_for_eval "$arg" 278906f32fbeSmrg func_append install_prog "$func_quote_for_eval_result" 279025b89263Smrg install_shared_prog=$install_prog 279125b89263Smrg case " $install_prog " in 279225b89263Smrg *[\\\ /]cp\ *) install_cp=: ;; 279325b89263Smrg *) install_cp=false ;; 279425b89263Smrg esac 2795ea133fd7Smrg 2796ea133fd7Smrg # We need to accept at least all the BSD install flags. 2797ea133fd7Smrg dest= 2798ea133fd7Smrg files= 2799ea133fd7Smrg opts= 2800ea133fd7Smrg prev= 2801ea133fd7Smrg install_type= 2802ea133fd7Smrg isdir=no 2803ea133fd7Smrg stripme= 280425b89263Smrg no_mode=: 2805ea133fd7Smrg for arg 2806ea133fd7Smrg do 280725b89263Smrg arg2= 2808ea133fd7Smrg if test -n "$dest"; then 280906f32fbeSmrg func_append files " $dest" 2810ea133fd7Smrg dest=$arg 2811ea133fd7Smrg continue 2812a253d6aeSmrg fi 2813a253d6aeSmrg 2814ea133fd7Smrg case $arg in 2815ea133fd7Smrg -d) isdir=yes ;; 2816ea133fd7Smrg -f) 281725b89263Smrg if $install_cp; then :; else 281825b89263Smrg prev=$arg 281925b89263Smrg fi 2820ea133fd7Smrg ;; 2821ea133fd7Smrg -g | -m | -o) 2822ea133fd7Smrg prev=$arg 2823ea133fd7Smrg ;; 2824ea133fd7Smrg -s) 2825ea133fd7Smrg stripme=" -s" 2826ea133fd7Smrg continue 2827ea133fd7Smrg ;; 2828ea133fd7Smrg -*) 2829ea133fd7Smrg ;; 2830ea133fd7Smrg *) 2831ea133fd7Smrg # If the previous option needed an argument, then skip it. 2832ea133fd7Smrg if test -n "$prev"; then 283325b89263Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 283425b89263Smrg arg2=$install_override_mode 283525b89263Smrg no_mode=false 283625b89263Smrg fi 2837ea133fd7Smrg prev= 2838ea133fd7Smrg else 2839ea133fd7Smrg dest=$arg 2840ea133fd7Smrg continue 2841ea133fd7Smrg fi 2842ea133fd7Smrg ;; 2843ea133fd7Smrg esac 2844a253d6aeSmrg 2845ea133fd7Smrg # Aesthetically quote the argument. 2846ea133fd7Smrg func_quote_for_eval "$arg" 284706f32fbeSmrg func_append install_prog " $func_quote_for_eval_result" 284825b89263Smrg if test -n "$arg2"; then 284925b89263Smrg func_quote_for_eval "$arg2" 285025b89263Smrg fi 285106f32fbeSmrg func_append install_shared_prog " $func_quote_for_eval_result" 2852ea133fd7Smrg done 2853a253d6aeSmrg 2854ea133fd7Smrg test -z "$install_prog" && \ 2855ea133fd7Smrg func_fatal_help "you must specify an install program" 2856a253d6aeSmrg 2857ea133fd7Smrg test -n "$prev" && \ 2858ea133fd7Smrg func_fatal_help "the \`$prev' option requires an argument" 2859a253d6aeSmrg 286025b89263Smrg if test -n "$install_override_mode" && $no_mode; then 286125b89263Smrg if $install_cp; then :; else 286225b89263Smrg func_quote_for_eval "$install_override_mode" 286306f32fbeSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 286425b89263Smrg fi 286525b89263Smrg fi 286625b89263Smrg 2867ea133fd7Smrg if test -z "$files"; then 2868ea133fd7Smrg if test -z "$dest"; then 2869ea133fd7Smrg func_fatal_help "no file or destination specified" 2870ea133fd7Smrg else 2871ea133fd7Smrg func_fatal_help "you must specify a destination" 2872a253d6aeSmrg fi 2873a253d6aeSmrg fi 2874a253d6aeSmrg 2875ea133fd7Smrg # Strip any trailing slash from the destination. 2876ea133fd7Smrg func_stripname '' '/' "$dest" 2877ea133fd7Smrg dest=$func_stripname_result 2878a253d6aeSmrg 2879ea133fd7Smrg # Check to see that the destination is a directory. 2880ea133fd7Smrg test -d "$dest" && isdir=yes 2881ea133fd7Smrg if test "$isdir" = yes; then 2882ea133fd7Smrg destdir="$dest" 2883ea133fd7Smrg destname= 2884ea133fd7Smrg else 2885ea133fd7Smrg func_dirname_and_basename "$dest" "" "." 2886ea133fd7Smrg destdir="$func_dirname_result" 2887ea133fd7Smrg destname="$func_basename_result" 2888ea133fd7Smrg 2889ea133fd7Smrg # Not a directory, so check to see that there is only one file specified. 2890ea133fd7Smrg set dummy $files; shift 2891ea133fd7Smrg test "$#" -gt 1 && \ 2892ea133fd7Smrg func_fatal_help "\`$dest' is not a directory" 2893ea133fd7Smrg fi 2894ea133fd7Smrg case $destdir in 2895ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 2896a253d6aeSmrg *) 2897ea133fd7Smrg for file in $files; do 2898ea133fd7Smrg case $file in 2899ea133fd7Smrg *.lo) ;; 2900ea133fd7Smrg *) 2901ea133fd7Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 2902ea133fd7Smrg ;; 2903ea133fd7Smrg esac 2904ea133fd7Smrg done 2905a253d6aeSmrg ;; 2906a253d6aeSmrg esac 2907a253d6aeSmrg 2908ea133fd7Smrg # This variable tells wrapper scripts just to set variables rather 2909ea133fd7Smrg # than running their programs. 2910ea133fd7Smrg libtool_install_magic="$magic" 2911a253d6aeSmrg 2912ea133fd7Smrg staticlibs= 2913ea133fd7Smrg future_libdirs= 2914ea133fd7Smrg current_libdirs= 2915ea133fd7Smrg for file in $files; do 2916a253d6aeSmrg 2917ea133fd7Smrg # Do each installation. 2918ea133fd7Smrg case $file in 2919ea133fd7Smrg *.$libext) 2920ea133fd7Smrg # Do the static libraries later. 292106f32fbeSmrg func_append staticlibs " $file" 2922ea133fd7Smrg ;; 2923ea133fd7Smrg 2924ea133fd7Smrg *.la) 292506f32fbeSmrg func_resolve_sysroot "$file" 292606f32fbeSmrg file=$func_resolve_sysroot_result 292706f32fbeSmrg 2928ea133fd7Smrg # Check to see that this really is a libtool archive. 2929ea133fd7Smrg func_lalib_unsafe_p "$file" \ 2930ea133fd7Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 2931ea133fd7Smrg 2932ea133fd7Smrg library_names= 2933ea133fd7Smrg old_library= 2934ea133fd7Smrg relink_command= 2935ea133fd7Smrg func_source "$file" 2936ea133fd7Smrg 2937ea133fd7Smrg # Add the libdir to current_libdirs if it is the destination. 2938ea133fd7Smrg if test "X$destdir" = "X$libdir"; then 2939ea133fd7Smrg case "$current_libdirs " in 2940ea133fd7Smrg *" $libdir "*) ;; 294106f32fbeSmrg *) func_append current_libdirs " $libdir" ;; 2942a253d6aeSmrg esac 2943ea133fd7Smrg else 2944ea133fd7Smrg # Note the libdir as a future libdir. 2945ea133fd7Smrg case "$future_libdirs " in 2946ea133fd7Smrg *" $libdir "*) ;; 294706f32fbeSmrg *) func_append future_libdirs " $libdir" ;; 2948ea133fd7Smrg esac 2949ea133fd7Smrg fi 2950a253d6aeSmrg 2951ea133fd7Smrg func_dirname "$file" "/" "" 2952ea133fd7Smrg dir="$func_dirname_result" 295306f32fbeSmrg func_append dir "$objdir" 2954ea133fd7Smrg 2955ea133fd7Smrg if test -n "$relink_command"; then 2956ea133fd7Smrg # Determine the prefix the user has applied to our future dir. 295725b89263Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2958ea133fd7Smrg 2959ea133fd7Smrg # Don't allow the user to place us outside of our expected 2960ea133fd7Smrg # location b/c this prevents finding dependent libraries that 2961ea133fd7Smrg # are installed to the same prefix. 2962ea133fd7Smrg # At present, this check doesn't affect windows .dll's that 2963ea133fd7Smrg # are installed into $libdir/../bin (currently, that works fine) 2964ea133fd7Smrg # but it's something to keep an eye on. 2965ea133fd7Smrg test "$inst_prefix_dir" = "$destdir" && \ 2966ea133fd7Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 2967ea133fd7Smrg 2968ea133fd7Smrg if test -n "$inst_prefix_dir"; then 2969ea133fd7Smrg # Stick the inst_prefix_dir data into the link command. 297025b89263Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2971ea133fd7Smrg else 297225b89263Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2973ea133fd7Smrg fi 2974ea133fd7Smrg 2975ea133fd7Smrg func_warning "relinking \`$file'" 2976ea133fd7Smrg func_show_eval "$relink_command" \ 2977ea133fd7Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 2978ea133fd7Smrg fi 2979ea133fd7Smrg 2980ea133fd7Smrg # See the names of the shared library. 2981ea133fd7Smrg set dummy $library_names; shift 2982ea133fd7Smrg if test -n "$1"; then 2983ea133fd7Smrg realname="$1" 2984ea133fd7Smrg shift 2985ea133fd7Smrg 2986ea133fd7Smrg srcname="$realname" 2987ea133fd7Smrg test -n "$relink_command" && srcname="$realname"T 2988ea133fd7Smrg 2989ea133fd7Smrg # Install the shared library and build the symlinks. 299025b89263Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 2991ea133fd7Smrg 'exit $?' 2992ea133fd7Smrg tstripme="$stripme" 2993ea133fd7Smrg case $host_os in 2994ea133fd7Smrg cygwin* | mingw* | pw32* | cegcc*) 2995ea133fd7Smrg case $realname in 2996ea133fd7Smrg *.dll.a) 2997ea133fd7Smrg tstripme="" 2998ea133fd7Smrg ;; 2999ea133fd7Smrg esac 3000a253d6aeSmrg ;; 3001a253d6aeSmrg esac 3002ea133fd7Smrg if test -n "$tstripme" && test -n "$striplib"; then 3003ea133fd7Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 3004a253d6aeSmrg fi 3005ea133fd7Smrg 3006ea133fd7Smrg if test "$#" -gt 0; then 3007ea133fd7Smrg # Delete the old symlinks, and create new ones. 3008ea133fd7Smrg # Try `ln -sf' first, because the `ln' binary might depend on 3009ea133fd7Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 3010ea133fd7Smrg # so we also need to try rm && ln -s. 3011ea133fd7Smrg for linkname 3012ea133fd7Smrg do 3013ea133fd7Smrg test "$linkname" != "$realname" \ 3014ea133fd7Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3015a253d6aeSmrg done 3016a253d6aeSmrg fi 3017a253d6aeSmrg 3018ea133fd7Smrg # Do each command in the postinstall commands. 3019ea133fd7Smrg lib="$destdir/$realname" 3020ea133fd7Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 3021a253d6aeSmrg fi 3022a253d6aeSmrg 3023ea133fd7Smrg # Install the pseudo-library for information purposes. 3024ea133fd7Smrg func_basename "$file" 3025ea133fd7Smrg name="$func_basename_result" 3026ea133fd7Smrg instname="$dir/$name"i 3027ea133fd7Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3028a253d6aeSmrg 3029ea133fd7Smrg # Maybe install the static library, too. 303006f32fbeSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 3031ea133fd7Smrg ;; 3032a253d6aeSmrg 3033ea133fd7Smrg *.lo) 3034ea133fd7Smrg # Install (i.e. copy) a libtool object. 3035a253d6aeSmrg 3036ea133fd7Smrg # Figure out destination file name, if it wasn't already specified. 3037ea133fd7Smrg if test -n "$destname"; then 3038ea133fd7Smrg destfile="$destdir/$destname" 3039ea133fd7Smrg else 3040ea133fd7Smrg func_basename "$file" 3041ea133fd7Smrg destfile="$func_basename_result" 3042ea133fd7Smrg destfile="$destdir/$destfile" 3043ea133fd7Smrg fi 3044ea133fd7Smrg 3045ea133fd7Smrg # Deduce the name of the destination old-style object file. 3046ea133fd7Smrg case $destfile in 3047ea133fd7Smrg *.lo) 3048ea133fd7Smrg func_lo2o "$destfile" 3049ea133fd7Smrg staticdest=$func_lo2o_result 3050ea133fd7Smrg ;; 3051ea133fd7Smrg *.$objext) 3052ea133fd7Smrg staticdest="$destfile" 3053ea133fd7Smrg destfile= 3054ea133fd7Smrg ;; 3055ea133fd7Smrg *) 3056ea133fd7Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 3057ea133fd7Smrg ;; 3058a253d6aeSmrg esac 3059a253d6aeSmrg 3060ea133fd7Smrg # Install the libtool object if requested. 3061ea133fd7Smrg test -n "$destfile" && \ 3062ea133fd7Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 3063ea133fd7Smrg 3064ea133fd7Smrg # Install the old object if enabled. 3065ea133fd7Smrg if test "$build_old_libs" = yes; then 3066ea133fd7Smrg # Deduce the name of the old-style object file. 3067ea133fd7Smrg func_lo2o "$file" 3068ea133fd7Smrg staticobj=$func_lo2o_result 3069ea133fd7Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3070a253d6aeSmrg fi 3071ea133fd7Smrg exit $EXIT_SUCCESS 3072ea133fd7Smrg ;; 3073a253d6aeSmrg 3074ea133fd7Smrg *) 3075ea133fd7Smrg # Figure out destination file name, if it wasn't already specified. 3076ea133fd7Smrg if test -n "$destname"; then 3077ea133fd7Smrg destfile="$destdir/$destname" 3078ea133fd7Smrg else 3079ea133fd7Smrg func_basename "$file" 3080ea133fd7Smrg destfile="$func_basename_result" 3081ea133fd7Smrg destfile="$destdir/$destfile" 3082ea133fd7Smrg fi 3083ea133fd7Smrg 3084ea133fd7Smrg # If the file is missing, and there is a .exe on the end, strip it 3085ea133fd7Smrg # because it is most likely a libtool script we actually want to 3086ea133fd7Smrg # install 3087ea133fd7Smrg stripped_ext="" 3088ea133fd7Smrg case $file in 3089ea133fd7Smrg *.exe) 3090ea133fd7Smrg if test ! -f "$file"; then 3091ea133fd7Smrg func_stripname '' '.exe' "$file" 3092ea133fd7Smrg file=$func_stripname_result 3093ea133fd7Smrg stripped_ext=".exe" 3094a253d6aeSmrg fi 3095ea133fd7Smrg ;; 3096ea133fd7Smrg esac 3097a253d6aeSmrg 3098ea133fd7Smrg # Do a test to see if this is really a libtool program. 3099ea133fd7Smrg case $host in 3100ea133fd7Smrg *cygwin* | *mingw*) 3101ea133fd7Smrg if func_ltwrapper_executable_p "$file"; then 3102ea133fd7Smrg func_ltwrapper_scriptname "$file" 3103ea133fd7Smrg wrapper=$func_ltwrapper_scriptname_result 3104ea133fd7Smrg else 3105ea133fd7Smrg func_stripname '' '.exe' "$file" 3106ea133fd7Smrg wrapper=$func_stripname_result 3107ea133fd7Smrg fi 3108ea133fd7Smrg ;; 3109ea133fd7Smrg *) 3110ea133fd7Smrg wrapper=$file 3111ea133fd7Smrg ;; 3112ea133fd7Smrg esac 3113ea133fd7Smrg if func_ltwrapper_script_p "$wrapper"; then 3114ea133fd7Smrg notinst_deplibs= 3115ea133fd7Smrg relink_command= 3116a253d6aeSmrg 3117ea133fd7Smrg func_source "$wrapper" 3118a253d6aeSmrg 3119ea133fd7Smrg # Check the variables that should have been set. 3120ea133fd7Smrg test -z "$generated_by_libtool_version" && \ 3121ea133fd7Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3122ea133fd7Smrg 3123ea133fd7Smrg finalize=yes 3124ea133fd7Smrg for lib in $notinst_deplibs; do 3125ea133fd7Smrg # Check to see that each library is installed. 3126ea133fd7Smrg libdir= 3127ea133fd7Smrg if test -f "$lib"; then 3128ea133fd7Smrg func_source "$lib" 3129ea133fd7Smrg fi 313025b89263Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 3131ea133fd7Smrg if test -n "$libdir" && test ! -f "$libfile"; then 3132ea133fd7Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 3133ea133fd7Smrg finalize=no 3134ea133fd7Smrg fi 3135ea133fd7Smrg done 3136ea133fd7Smrg 3137ea133fd7Smrg relink_command= 3138ea133fd7Smrg func_source "$wrapper" 3139ea133fd7Smrg 3140ea133fd7Smrg outputname= 3141ea133fd7Smrg if test "$fast_install" = no && test -n "$relink_command"; then 3142ea133fd7Smrg $opt_dry_run || { 3143ea133fd7Smrg if test "$finalize" = yes; then 3144ea133fd7Smrg tmpdir=`func_mktempdir` 3145ea133fd7Smrg func_basename "$file$stripped_ext" 3146ea133fd7Smrg file="$func_basename_result" 3147ea133fd7Smrg outputname="$tmpdir/$file" 3148ea133fd7Smrg # Replace the output file specification. 314925b89263Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 3150ea133fd7Smrg 3151ea133fd7Smrg $opt_silent || { 3152ea133fd7Smrg func_quote_for_expand "$relink_command" 3153ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 3154ea133fd7Smrg } 3155ea133fd7Smrg if eval "$relink_command"; then : 3156ea133fd7Smrg else 3157ea133fd7Smrg func_error "error: relink \`$file' with the above command before installing it" 3158ea133fd7Smrg $opt_dry_run || ${RM}r "$tmpdir" 3159ea133fd7Smrg continue 3160ea133fd7Smrg fi 3161ea133fd7Smrg file="$outputname" 3162ea133fd7Smrg else 3163ea133fd7Smrg func_warning "cannot relink \`$file'" 3164ea133fd7Smrg fi 3165ea133fd7Smrg } 3166a253d6aeSmrg else 3167ea133fd7Smrg # Install the binary that we compiled earlier. 316825b89263Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 3169a253d6aeSmrg fi 3170ea133fd7Smrg fi 3171a253d6aeSmrg 3172ea133fd7Smrg # remove .exe since cygwin /usr/bin/install will append another 3173ea133fd7Smrg # one anyway 3174ea133fd7Smrg case $install_prog,$host in 3175ea133fd7Smrg */usr/bin/install*,*cygwin*) 3176ea133fd7Smrg case $file:$destfile in 3177ea133fd7Smrg *.exe:*.exe) 3178ea133fd7Smrg # this is ok 3179ea133fd7Smrg ;; 3180ea133fd7Smrg *.exe:*) 3181ea133fd7Smrg destfile=$destfile.exe 3182ea133fd7Smrg ;; 3183ea133fd7Smrg *:*.exe) 3184ea133fd7Smrg func_stripname '' '.exe' "$destfile" 3185ea133fd7Smrg destfile=$func_stripname_result 3186ea133fd7Smrg ;; 3187ea133fd7Smrg esac 3188a253d6aeSmrg ;; 3189a253d6aeSmrg esac 3190ea133fd7Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 3191ea133fd7Smrg $opt_dry_run || if test -n "$outputname"; then 3192ea133fd7Smrg ${RM}r "$tmpdir" 3193ea133fd7Smrg fi 3194ea133fd7Smrg ;; 3195ea133fd7Smrg esac 3196ea133fd7Smrg done 3197a253d6aeSmrg 3198ea133fd7Smrg for file in $staticlibs; do 3199ea133fd7Smrg func_basename "$file" 3200ea133fd7Smrg name="$func_basename_result" 3201a253d6aeSmrg 3202ea133fd7Smrg # Set up the ranlib parameters. 3203ea133fd7Smrg oldlib="$destdir/$name" 3204a253d6aeSmrg 3205ea133fd7Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 3206a253d6aeSmrg 3207ea133fd7Smrg if test -n "$stripme" && test -n "$old_striplib"; then 3208ea133fd7Smrg func_show_eval "$old_striplib $oldlib" 'exit $?' 3209ea133fd7Smrg fi 3210a253d6aeSmrg 3211ea133fd7Smrg # Do each command in the postinstall commands. 3212ea133fd7Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 3213ea133fd7Smrg done 3214a253d6aeSmrg 3215ea133fd7Smrg test -n "$future_libdirs" && \ 3216ea133fd7Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 3217a253d6aeSmrg 3218ea133fd7Smrg if test -n "$current_libdirs"; then 3219ea133fd7Smrg # Maybe just do a dry run. 3220ea133fd7Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 3221ea133fd7Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 3222ea133fd7Smrg else 3223ea133fd7Smrg exit $EXIT_SUCCESS 3224ea133fd7Smrg fi 3225ea133fd7Smrg} 3226a253d6aeSmrg 322706f32fbeSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 3228a253d6aeSmrg 3229a253d6aeSmrg 3230ea133fd7Smrg# func_generate_dlsyms outputname originator pic_p 3231ea133fd7Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 3232ea133fd7Smrg# a dlpreopen symbol table. 3233ea133fd7Smrgfunc_generate_dlsyms () 3234ea133fd7Smrg{ 3235ea133fd7Smrg $opt_debug 3236ea133fd7Smrg my_outputname="$1" 3237ea133fd7Smrg my_originator="$2" 3238ea133fd7Smrg my_pic_p="${3-no}" 3239ea133fd7Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 3240ea133fd7Smrg my_dlsyms= 3241ea133fd7Smrg 3242ea133fd7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 3243ea133fd7Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 3244ea133fd7Smrg my_dlsyms="${my_outputname}S.c" 3245ea133fd7Smrg else 3246ea133fd7Smrg func_error "not configured to extract global symbols from dlpreopened files" 3247ea133fd7Smrg fi 3248ea133fd7Smrg fi 3249a253d6aeSmrg 3250ea133fd7Smrg if test -n "$my_dlsyms"; then 3251ea133fd7Smrg case $my_dlsyms in 3252ea133fd7Smrg "") ;; 3253ea133fd7Smrg *.c) 3254ea133fd7Smrg # Discover the nlist of each of the dlfiles. 3255ea133fd7Smrg nlist="$output_objdir/${my_outputname}.nm" 3256ea133fd7Smrg 3257ea133fd7Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3258ea133fd7Smrg 3259ea133fd7Smrg # Parse the name list into a source file. 3260ea133fd7Smrg func_verbose "creating $output_objdir/$my_dlsyms" 3261ea133fd7Smrg 3262ea133fd7Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 3263ea133fd7Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 3264ea133fd7Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3265ea133fd7Smrg 3266ea133fd7Smrg#ifdef __cplusplus 3267ea133fd7Smrgextern \"C\" { 3268ea133fd7Smrg#endif 3269ea133fd7Smrg 327025b89263Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 327125b89263Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 327225b89263Smrg#endif 327325b89263Smrg 327406f32fbeSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 327506f32fbeSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 327606f32fbeSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 327706f32fbeSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 327806f32fbeSmrg# define LT_DLSYM_CONST 327906f32fbeSmrg#elif defined(__osf__) 328006f32fbeSmrg/* This system does not cope well with relocations in const data. */ 328106f32fbeSmrg# define LT_DLSYM_CONST 328206f32fbeSmrg#else 328306f32fbeSmrg# define LT_DLSYM_CONST const 328406f32fbeSmrg#endif 328506f32fbeSmrg 3286ea133fd7Smrg/* External symbol declarations for the compiler. */\ 3287ea133fd7Smrg" 3288ea133fd7Smrg 3289ea133fd7Smrg if test "$dlself" = yes; then 3290ea133fd7Smrg func_verbose "generating symbol list for \`$output'" 3291ea133fd7Smrg 3292ea133fd7Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3293ea133fd7Smrg 3294ea133fd7Smrg # Add our own program objects to the symbol list. 329525b89263Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 3296ea133fd7Smrg for progfile in $progfiles; do 329706f32fbeSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 329806f32fbeSmrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 329906f32fbeSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3300ea133fd7Smrg done 3301ea133fd7Smrg 3302ea133fd7Smrg if test -n "$exclude_expsyms"; then 3303ea133fd7Smrg $opt_dry_run || { 3304ea133fd7Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 3305ea133fd7Smrg eval '$MV "$nlist"T "$nlist"' 3306ea133fd7Smrg } 3307a253d6aeSmrg fi 3308a253d6aeSmrg 3309ea133fd7Smrg if test -n "$export_symbols_regex"; then 3310ea133fd7Smrg $opt_dry_run || { 3311ea133fd7Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 3312ea133fd7Smrg eval '$MV "$nlist"T "$nlist"' 3313ea133fd7Smrg } 3314a253d6aeSmrg fi 3315ea133fd7Smrg 3316ea133fd7Smrg # Prepare the list of exported symbols 3317ea133fd7Smrg if test -z "$export_symbols"; then 3318ea133fd7Smrg export_symbols="$output_objdir/$outputname.exp" 3319ea133fd7Smrg $opt_dry_run || { 3320ea133fd7Smrg $RM $export_symbols 3321ea133fd7Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 3322ea133fd7Smrg case $host in 3323ea133fd7Smrg *cygwin* | *mingw* | *cegcc* ) 3324ea133fd7Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3325ea133fd7Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 3326ea133fd7Smrg ;; 3327a253d6aeSmrg esac 3328ea133fd7Smrg } 3329ea133fd7Smrg else 3330ea133fd7Smrg $opt_dry_run || { 3331ea133fd7Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 3332ea133fd7Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 3333ea133fd7Smrg eval '$MV "$nlist"T "$nlist"' 3334ea133fd7Smrg case $host in 333525b89263Smrg *cygwin* | *mingw* | *cegcc* ) 3336ea133fd7Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3337ea133fd7Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 3338ea133fd7Smrg ;; 3339a253d6aeSmrg esac 3340ea133fd7Smrg } 3341a253d6aeSmrg fi 3342ea133fd7Smrg fi 3343a253d6aeSmrg 3344ea133fd7Smrg for dlprefile in $dlprefiles; do 3345ea133fd7Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 3346ea133fd7Smrg func_basename "$dlprefile" 3347ea133fd7Smrg name="$func_basename_result" 334806f32fbeSmrg case $host in 334906f32fbeSmrg *cygwin* | *mingw* | *cegcc* ) 335006f32fbeSmrg # if an import library, we need to obtain dlname 335106f32fbeSmrg if func_win32_import_lib_p "$dlprefile"; then 335206f32fbeSmrg func_tr_sh "$dlprefile" 335306f32fbeSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 335406f32fbeSmrg dlprefile_dlbasename="" 335506f32fbeSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 335606f32fbeSmrg # Use subshell, to avoid clobbering current variable values 335706f32fbeSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 335806f32fbeSmrg if test -n "$dlprefile_dlname" ; then 335906f32fbeSmrg func_basename "$dlprefile_dlname" 336006f32fbeSmrg dlprefile_dlbasename="$func_basename_result" 336106f32fbeSmrg else 336206f32fbeSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 336306f32fbeSmrg $sharedlib_from_linklib_cmd "$dlprefile" 336406f32fbeSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 336506f32fbeSmrg fi 336606f32fbeSmrg fi 336706f32fbeSmrg $opt_dry_run || { 336806f32fbeSmrg if test -n "$dlprefile_dlbasename" ; then 336906f32fbeSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 337006f32fbeSmrg else 337106f32fbeSmrg func_warning "Could not compute DLL name from $name" 337206f32fbeSmrg eval '$ECHO ": $name " >> "$nlist"' 337306f32fbeSmrg fi 337406f32fbeSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 337506f32fbeSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 337606f32fbeSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 337706f32fbeSmrg } 337806f32fbeSmrg else # not an import lib 337906f32fbeSmrg $opt_dry_run || { 338006f32fbeSmrg eval '$ECHO ": $name " >> "$nlist"' 338106f32fbeSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 338206f32fbeSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 338306f32fbeSmrg } 338406f32fbeSmrg fi 338506f32fbeSmrg ;; 338606f32fbeSmrg *) 338706f32fbeSmrg $opt_dry_run || { 338806f32fbeSmrg eval '$ECHO ": $name " >> "$nlist"' 338906f32fbeSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 339006f32fbeSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 339106f32fbeSmrg } 339206f32fbeSmrg ;; 339306f32fbeSmrg esac 3394ea133fd7Smrg done 3395a253d6aeSmrg 3396ea133fd7Smrg $opt_dry_run || { 3397ea133fd7Smrg # Make sure we have at least an empty file. 3398ea133fd7Smrg test -f "$nlist" || : > "$nlist" 3399a253d6aeSmrg 3400ea133fd7Smrg if test -n "$exclude_expsyms"; then 3401ea133fd7Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 3402ea133fd7Smrg $MV "$nlist"T "$nlist" 3403a253d6aeSmrg fi 3404a253d6aeSmrg 3405ea133fd7Smrg # Try sorting and uniquifying the output. 3406ea133fd7Smrg if $GREP -v "^: " < "$nlist" | 3407ea133fd7Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 3408ea133fd7Smrg sort -k 3 3409a253d6aeSmrg else 3410ea133fd7Smrg sort +2 3411ea133fd7Smrg fi | 3412ea133fd7Smrg uniq > "$nlist"S; then 3413ea133fd7Smrg : 3414a253d6aeSmrg else 3415ea133fd7Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 3416a253d6aeSmrg fi 3417a253d6aeSmrg 3418ea133fd7Smrg if test -f "$nlist"S; then 3419ea133fd7Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 3420a253d6aeSmrg else 342125b89263Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 3422a253d6aeSmrg fi 3423a253d6aeSmrg 342425b89263Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3425a253d6aeSmrg 3426ea133fd7Smrg/* The mapping between symbol names and symbols. */ 3427ea133fd7Smrgtypedef struct { 3428ea133fd7Smrg const char *name; 3429ea133fd7Smrg void *address; 3430ea133fd7Smrg} lt_dlsymlist; 343106f32fbeSmrgextern LT_DLSYM_CONST lt_dlsymlist 3432ea133fd7Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 343306f32fbeSmrgLT_DLSYM_CONST lt_dlsymlist 3434ea133fd7Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 3435ea133fd7Smrg{\ 3436ea133fd7Smrg { \"$my_originator\", (void *) 0 }," 3437ea133fd7Smrg 3438ea133fd7Smrg case $need_lib_prefix in 3439ea133fd7Smrg no) 3440ea133fd7Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3441ea133fd7Smrg ;; 3442ea133fd7Smrg *) 3443ea133fd7Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3444ea133fd7Smrg ;; 3445ea133fd7Smrg esac 344625b89263Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3447ea133fd7Smrg {0, (void *) 0} 3448ea133fd7Smrg}; 3449ea133fd7Smrg 3450ea133fd7Smrg/* This works around a problem in FreeBSD linker */ 3451ea133fd7Smrg#ifdef FREEBSD_WORKAROUND 3452ea133fd7Smrgstatic const void *lt_preloaded_setup() { 3453ea133fd7Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 3454ea133fd7Smrg} 3455ea133fd7Smrg#endif 3456ea133fd7Smrg 3457ea133fd7Smrg#ifdef __cplusplus 3458ea133fd7Smrg} 3459ea133fd7Smrg#endif\ 3460ea133fd7Smrg" 3461ea133fd7Smrg } # !$opt_dry_run 3462ea133fd7Smrg 3463ea133fd7Smrg pic_flag_for_symtable= 3464ea133fd7Smrg case "$compile_command " in 3465ea133fd7Smrg *" -static "*) ;; 3466ea133fd7Smrg *) 3467ea133fd7Smrg case $host in 3468ea133fd7Smrg # compiling the symbol table file with pic_flag works around 3469ea133fd7Smrg # a FreeBSD bug that causes programs to crash when -lm is 3470ea133fd7Smrg # linked before any other PIC object. But we must not use 3471ea133fd7Smrg # pic_flag when linking with -static. The problem exists in 3472ea133fd7Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 3473ea133fd7Smrg *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 3474ea133fd7Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 3475ea133fd7Smrg *-*-hpux*) 3476ea133fd7Smrg pic_flag_for_symtable=" $pic_flag" ;; 3477ea133fd7Smrg *) 3478ea133fd7Smrg if test "X$my_pic_p" != Xno; then 3479ea133fd7Smrg pic_flag_for_symtable=" $pic_flag" 3480a253d6aeSmrg fi 3481ea133fd7Smrg ;; 3482ea133fd7Smrg esac 3483ea133fd7Smrg ;; 3484ea133fd7Smrg esac 3485ea133fd7Smrg symtab_cflags= 3486ea133fd7Smrg for arg in $LTCFLAGS; do 3487ea133fd7Smrg case $arg in 3488ea133fd7Smrg -pie | -fpie | -fPIE) ;; 348906f32fbeSmrg *) func_append symtab_cflags " $arg" ;; 3490ea133fd7Smrg esac 3491ea133fd7Smrg done 3492a253d6aeSmrg 3493ea133fd7Smrg # Now compile the dynamic symbol file. 3494ea133fd7Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3495a253d6aeSmrg 3496ea133fd7Smrg # Clean up the generated files. 3497ea133fd7Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3498ea133fd7Smrg 3499ea133fd7Smrg # Transform the symbol file into the correct name. 3500ea133fd7Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 3501ea133fd7Smrg case $host in 3502ea133fd7Smrg *cygwin* | *mingw* | *cegcc* ) 3503ea133fd7Smrg if test -f "$output_objdir/$my_outputname.def"; then 350425b89263Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350525b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3506ea133fd7Smrg else 350725b89263Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 350825b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3509ea133fd7Smrg fi 3510ea133fd7Smrg ;; 3511ea133fd7Smrg *) 351225b89263Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351325b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3514a253d6aeSmrg ;; 3515a253d6aeSmrg esac 3516ea133fd7Smrg ;; 3517ea133fd7Smrg *) 3518ea133fd7Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 3519ea133fd7Smrg ;; 3520ea133fd7Smrg esac 3521ea133fd7Smrg else 3522ea133fd7Smrg # We keep going just in case the user didn't refer to 3523ea133fd7Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 3524ea133fd7Smrg # really was required. 3525ea133fd7Smrg 3526ea133fd7Smrg # Nullify the symbol file. 352725b89263Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 352825b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 3529a253d6aeSmrg fi 3530ea133fd7Smrg} 3531a253d6aeSmrg 3532ea133fd7Smrg# func_win32_libid arg 3533ea133fd7Smrg# return the library type of file 'arg' 3534ea133fd7Smrg# 3535ea133fd7Smrg# Need a lot of goo to handle *both* DLLs and import libs 3536ea133fd7Smrg# Has to be a shell function in order to 'eat' the argument 3537ea133fd7Smrg# that is supplied when $file_magic_command is called. 353825b89263Smrg# Despite the name, also deal with 64 bit binaries. 3539ea133fd7Smrgfunc_win32_libid () 3540ea133fd7Smrg{ 3541ea133fd7Smrg $opt_debug 3542ea133fd7Smrg win32_libid_type="unknown" 3543ea133fd7Smrg win32_fileres=`file -L $1 2>/dev/null` 3544ea133fd7Smrg case $win32_fileres in 3545ea133fd7Smrg *ar\ archive\ import\ library*) # definitely import 3546ea133fd7Smrg win32_libid_type="x86 archive import" 3547ea133fd7Smrg ;; 3548ea133fd7Smrg *ar\ archive*) # could be an import, or static 354925b89263Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 3550ea133fd7Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 355125b89263Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 355206f32fbeSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 355306f32fbeSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 3554ea133fd7Smrg $SED -n -e ' 3555ea133fd7Smrg 1,100{ 3556ea133fd7Smrg / I /{ 3557ea133fd7Smrg s,.*,import, 3558ea133fd7Smrg p 3559ea133fd7Smrg q 3560ea133fd7Smrg } 3561ea133fd7Smrg }'` 3562ea133fd7Smrg case $win32_nmres in 3563ea133fd7Smrg import*) win32_libid_type="x86 archive import";; 3564ea133fd7Smrg *) win32_libid_type="x86 archive static";; 3565ea133fd7Smrg esac 3566ea133fd7Smrg fi 3567ea133fd7Smrg ;; 3568ea133fd7Smrg *DLL*) 3569ea133fd7Smrg win32_libid_type="x86 DLL" 3570ea133fd7Smrg ;; 3571ea133fd7Smrg *executable*) # but shell scripts are "executable" too... 3572ea133fd7Smrg case $win32_fileres in 3573ea133fd7Smrg *MS\ Windows\ PE\ Intel*) 3574ea133fd7Smrg win32_libid_type="x86 DLL" 3575ea133fd7Smrg ;; 3576ea133fd7Smrg esac 3577ea133fd7Smrg ;; 3578ea133fd7Smrg esac 3579ea133fd7Smrg $ECHO "$win32_libid_type" 3580ea133fd7Smrg} 3581a253d6aeSmrg 358206f32fbeSmrg# func_cygming_dll_for_implib ARG 358306f32fbeSmrg# 358406f32fbeSmrg# Platform-specific function to extract the 358506f32fbeSmrg# name of the DLL associated with the specified 358606f32fbeSmrg# import library ARG. 358706f32fbeSmrg# Invoked by eval'ing the libtool variable 358806f32fbeSmrg# $sharedlib_from_linklib_cmd 358906f32fbeSmrg# Result is available in the variable 359006f32fbeSmrg# $sharedlib_from_linklib_result 359106f32fbeSmrgfunc_cygming_dll_for_implib () 359206f32fbeSmrg{ 359306f32fbeSmrg $opt_debug 359406f32fbeSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 359506f32fbeSmrg} 359606f32fbeSmrg 359706f32fbeSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 359806f32fbeSmrg# 359906f32fbeSmrg# The is the core of a fallback implementation of a 360006f32fbeSmrg# platform-specific function to extract the name of the 360106f32fbeSmrg# DLL associated with the specified import library LIBNAME. 360206f32fbeSmrg# 360306f32fbeSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 360406f32fbeSmrg# on the platform and compiler that created the implib. 360506f32fbeSmrg# 360606f32fbeSmrg# Echos the name of the DLL associated with the 360706f32fbeSmrg# specified import library. 360806f32fbeSmrgfunc_cygming_dll_for_implib_fallback_core () 360906f32fbeSmrg{ 361006f32fbeSmrg $opt_debug 361106f32fbeSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 361206f32fbeSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 361306f32fbeSmrg $SED '/^Contents of section '"$match_literal"':/{ 361406f32fbeSmrg # Place marker at beginning of archive member dllname section 361506f32fbeSmrg s/.*/====MARK====/ 361606f32fbeSmrg p 361706f32fbeSmrg d 361806f32fbeSmrg } 361906f32fbeSmrg # These lines can sometimes be longer than 43 characters, but 362006f32fbeSmrg # are always uninteresting 362106f32fbeSmrg /:[ ]*file format pe[i]\{,1\}-/d 362206f32fbeSmrg /^In archive [^:]*:/d 362306f32fbeSmrg # Ensure marker is printed 362406f32fbeSmrg /^====MARK====/p 362506f32fbeSmrg # Remove all lines with less than 43 characters 362606f32fbeSmrg /^.\{43\}/!d 362706f32fbeSmrg # From remaining lines, remove first 43 characters 362806f32fbeSmrg s/^.\{43\}//' | 362906f32fbeSmrg $SED -n ' 363006f32fbeSmrg # Join marker and all lines until next marker into a single line 363106f32fbeSmrg /^====MARK====/ b para 363206f32fbeSmrg H 363306f32fbeSmrg $ b para 363406f32fbeSmrg b 363506f32fbeSmrg :para 363606f32fbeSmrg x 363706f32fbeSmrg s/\n//g 363806f32fbeSmrg # Remove the marker 363906f32fbeSmrg s/^====MARK====// 364006f32fbeSmrg # Remove trailing dots and whitespace 364106f32fbeSmrg s/[\. \t]*$// 364206f32fbeSmrg # Print 364306f32fbeSmrg /./p' | 364406f32fbeSmrg # we now have a list, one entry per line, of the stringified 364506f32fbeSmrg # contents of the appropriate section of all members of the 364606f32fbeSmrg # archive which possess that section. Heuristic: eliminate 364706f32fbeSmrg # all those which have a first or second character that is 364806f32fbeSmrg # a '.' (that is, objdump's representation of an unprintable 364906f32fbeSmrg # character.) This should work for all archives with less than 365006f32fbeSmrg # 0x302f exports -- but will fail for DLLs whose name actually 365106f32fbeSmrg # begins with a literal '.' or a single character followed by 365206f32fbeSmrg # a '.'. 365306f32fbeSmrg # 365406f32fbeSmrg # Of those that remain, print the first one. 365506f32fbeSmrg $SED -e '/^\./d;/^.\./d;q' 365606f32fbeSmrg} 365706f32fbeSmrg 365806f32fbeSmrg# func_cygming_gnu_implib_p ARG 365906f32fbeSmrg# This predicate returns with zero status (TRUE) if 366006f32fbeSmrg# ARG is a GNU/binutils-style import library. Returns 366106f32fbeSmrg# with nonzero status (FALSE) otherwise. 366206f32fbeSmrgfunc_cygming_gnu_implib_p () 366306f32fbeSmrg{ 366406f32fbeSmrg $opt_debug 366506f32fbeSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 366606f32fbeSmrg func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` 366706f32fbeSmrg test -n "$func_cygming_gnu_implib_tmp" 366806f32fbeSmrg} 366906f32fbeSmrg 367006f32fbeSmrg# func_cygming_ms_implib_p ARG 367106f32fbeSmrg# This predicate returns with zero status (TRUE) if 367206f32fbeSmrg# ARG is an MS-style import library. Returns 367306f32fbeSmrg# with nonzero status (FALSE) otherwise. 367406f32fbeSmrgfunc_cygming_ms_implib_p () 367506f32fbeSmrg{ 367606f32fbeSmrg $opt_debug 367706f32fbeSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 367806f32fbeSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 367906f32fbeSmrg test -n "$func_cygming_ms_implib_tmp" 368006f32fbeSmrg} 368106f32fbeSmrg 368206f32fbeSmrg# func_cygming_dll_for_implib_fallback ARG 368306f32fbeSmrg# Platform-specific function to extract the 368406f32fbeSmrg# name of the DLL associated with the specified 368506f32fbeSmrg# import library ARG. 368606f32fbeSmrg# 368706f32fbeSmrg# This fallback implementation is for use when $DLLTOOL 368806f32fbeSmrg# does not support the --identify-strict option. 368906f32fbeSmrg# Invoked by eval'ing the libtool variable 369006f32fbeSmrg# $sharedlib_from_linklib_cmd 369106f32fbeSmrg# Result is available in the variable 369206f32fbeSmrg# $sharedlib_from_linklib_result 369306f32fbeSmrgfunc_cygming_dll_for_implib_fallback () 369406f32fbeSmrg{ 369506f32fbeSmrg $opt_debug 369606f32fbeSmrg if func_cygming_gnu_implib_p "$1" ; then 369706f32fbeSmrg # binutils import library 369806f32fbeSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 369906f32fbeSmrg elif func_cygming_ms_implib_p "$1" ; then 370006f32fbeSmrg # ms-generated import library 370106f32fbeSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 370206f32fbeSmrg else 370306f32fbeSmrg # unknown 370406f32fbeSmrg sharedlib_from_linklib_result="" 370506f32fbeSmrg fi 370606f32fbeSmrg} 3707a253d6aeSmrg 3708a253d6aeSmrg 3709ea133fd7Smrg# func_extract_an_archive dir oldlib 3710ea133fd7Smrgfunc_extract_an_archive () 3711ea133fd7Smrg{ 3712ea133fd7Smrg $opt_debug 3713ea133fd7Smrg f_ex_an_ar_dir="$1"; shift 3714ea133fd7Smrg f_ex_an_ar_oldlib="$1" 371525b89263Smrg if test "$lock_old_archive_extraction" = yes; then 371625b89263Smrg lockfile=$f_ex_an_ar_oldlib.lock 371725b89263Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 371825b89263Smrg func_echo "Waiting for $lockfile to be removed" 371925b89263Smrg sleep 2 372025b89263Smrg done 372125b89263Smrg fi 372225b89263Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 372325b89263Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 372425b89263Smrg if test "$lock_old_archive_extraction" = yes; then 372525b89263Smrg $opt_dry_run || rm -f "$lockfile" 372625b89263Smrg fi 3727ea133fd7Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 3728ea133fd7Smrg : 3729ea133fd7Smrg else 3730ea133fd7Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 3731ea133fd7Smrg fi 3732ea133fd7Smrg} 3733a253d6aeSmrg 3734a253d6aeSmrg 3735ea133fd7Smrg# func_extract_archives gentop oldlib ... 3736ea133fd7Smrgfunc_extract_archives () 3737ea133fd7Smrg{ 3738ea133fd7Smrg $opt_debug 3739ea133fd7Smrg my_gentop="$1"; shift 3740ea133fd7Smrg my_oldlibs=${1+"$@"} 3741ea133fd7Smrg my_oldobjs="" 3742ea133fd7Smrg my_xlib="" 3743ea133fd7Smrg my_xabs="" 3744ea133fd7Smrg my_xdir="" 3745a253d6aeSmrg 3746ea133fd7Smrg for my_xlib in $my_oldlibs; do 3747ea133fd7Smrg # Extract the objects. 3748ea133fd7Smrg case $my_xlib in 3749ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 3750ea133fd7Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 3751ea133fd7Smrg esac 3752ea133fd7Smrg func_basename "$my_xlib" 3753ea133fd7Smrg my_xlib="$func_basename_result" 3754ea133fd7Smrg my_xlib_u=$my_xlib 3755ea133fd7Smrg while :; do 3756ea133fd7Smrg case " $extracted_archives " in 3757ea133fd7Smrg *" $my_xlib_u "*) 3758ea133fd7Smrg func_arith $extracted_serial + 1 3759ea133fd7Smrg extracted_serial=$func_arith_result 3760ea133fd7Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 3761ea133fd7Smrg *) break ;; 3762ea133fd7Smrg esac 3763ea133fd7Smrg done 3764ea133fd7Smrg extracted_archives="$extracted_archives $my_xlib_u" 3765ea133fd7Smrg my_xdir="$my_gentop/$my_xlib_u" 3766a253d6aeSmrg 3767ea133fd7Smrg func_mkdir_p "$my_xdir" 3768a253d6aeSmrg 3769ea133fd7Smrg case $host in 3770ea133fd7Smrg *-darwin*) 3771ea133fd7Smrg func_verbose "Extracting $my_xabs" 3772ea133fd7Smrg # Do not bother doing anything if just a dry run 3773ea133fd7Smrg $opt_dry_run || { 3774ea133fd7Smrg darwin_orig_dir=`pwd` 3775ea133fd7Smrg cd $my_xdir || exit $? 3776ea133fd7Smrg darwin_archive=$my_xabs 3777ea133fd7Smrg darwin_curdir=`pwd` 3778ea133fd7Smrg darwin_base_archive=`basename "$darwin_archive"` 3779ea133fd7Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 3780ea133fd7Smrg if test -n "$darwin_arches"; then 3781ea133fd7Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 3782ea133fd7Smrg darwin_arch= 3783ea133fd7Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 3784ea133fd7Smrg for darwin_arch in $darwin_arches ; do 3785ea133fd7Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3786ea133fd7Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 3787ea133fd7Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3788ea133fd7Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 3789ea133fd7Smrg cd "$darwin_curdir" 3790ea133fd7Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 3791ea133fd7Smrg done # $darwin_arches 3792ea133fd7Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 3793ea133fd7Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 3794ea133fd7Smrg darwin_file= 3795ea133fd7Smrg darwin_files= 3796ea133fd7Smrg for darwin_file in $darwin_filelist; do 379725b89263Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 3798ea133fd7Smrg $LIPO -create -output "$darwin_file" $darwin_files 3799ea133fd7Smrg done # $darwin_filelist 3800ea133fd7Smrg $RM -rf unfat-$$ 3801ea133fd7Smrg cd "$darwin_orig_dir" 3802ea133fd7Smrg else 3803ea133fd7Smrg cd $darwin_orig_dir 3804ea133fd7Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 3805ea133fd7Smrg fi # $darwin_arches 3806ea133fd7Smrg } # !$opt_dry_run 3807ea133fd7Smrg ;; 3808ea133fd7Smrg *) 3809ea133fd7Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 3810ea133fd7Smrg ;; 3811a253d6aeSmrg esac 381225b89263Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 3813ea133fd7Smrg done 3814a253d6aeSmrg 3815ea133fd7Smrg func_extract_archives_result="$my_oldobjs" 3816ea133fd7Smrg} 3817a253d6aeSmrg 3818a253d6aeSmrg 381925b89263Smrg# func_emit_wrapper [arg=no] 382025b89263Smrg# 382125b89263Smrg# Emit a libtool wrapper script on stdout. 382225b89263Smrg# Don't directly open a file because we may want to 382325b89263Smrg# incorporate the script contents within a cygwin/mingw 382425b89263Smrg# wrapper executable. Must ONLY be called from within 382525b89263Smrg# func_mode_link because it depends on a number of variables 382625b89263Smrg# set therein. 3827ea133fd7Smrg# 382825b89263Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 382925b89263Smrg# variable will take. If 'yes', then the emitted script 383025b89263Smrg# will assume that the directory in which it is stored is 383125b89263Smrg# the $objdir directory. This is a cygwin/mingw-specific 383225b89263Smrg# behavior. 383325b89263Smrgfunc_emit_wrapper () 3834ea133fd7Smrg{ 383525b89263Smrg func_emit_wrapper_arg1=${1-no} 3836a253d6aeSmrg 3837ea133fd7Smrg $ECHO "\ 3838ea133fd7Smrg#! $SHELL 3839a253d6aeSmrg 3840ea133fd7Smrg# $output - temporary wrapper script for $objdir/$outputname 3841ea133fd7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3842ea133fd7Smrg# 3843ea133fd7Smrg# The $output program cannot be directly executed until all the libtool 3844ea133fd7Smrg# libraries that it depends on are installed. 3845ea133fd7Smrg# 3846ea133fd7Smrg# This wrapper script should never be moved out of the build directory. 3847ea133fd7Smrg# If it is, it will not operate correctly. 3848a253d6aeSmrg 3849ea133fd7Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3850ea133fd7Smrg# metacharacters that are still active within double-quoted strings. 3851ea133fd7Smrgsed_quote_subst='$sed_quote_subst' 3852a253d6aeSmrg 3853ea133fd7Smrg# Be Bourne compatible 3854ea133fd7Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 3855ea133fd7Smrg emulate sh 3856ea133fd7Smrg NULLCMD=: 3857ea133fd7Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 3858ea133fd7Smrg # is contrary to our usage. Disable this feature. 3859ea133fd7Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 3860ea133fd7Smrg setopt NO_GLOB_SUBST 3861ea133fd7Smrgelse 3862ea133fd7Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 3863ea133fd7Smrgfi 3864ea133fd7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 3865ea133fd7SmrgDUALCASE=1; export DUALCASE # for MKS sh 3866a253d6aeSmrg 3867ea133fd7Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 3868ea133fd7Smrg# if CDPATH is set. 3869ea133fd7Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3870a253d6aeSmrg 3871ea133fd7Smrgrelink_command=\"$relink_command\" 3872a253d6aeSmrg 3873ea133fd7Smrg# This environment variable determines our operation mode. 3874ea133fd7Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 3875ea133fd7Smrg # install mode needs the following variables: 3876ea133fd7Smrg generated_by_libtool_version='$macro_version' 3877ea133fd7Smrg notinst_deplibs='$notinst_deplibs' 3878ea133fd7Smrgelse 3879ea133fd7Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 3880ea133fd7Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 388125b89263Smrg file=\"\$0\"" 388225b89263Smrg 388325b89263Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 388425b89263Smrg $ECHO "\ 388525b89263Smrg 388625b89263Smrg# A function that is used when there is no print builtin or printf. 388725b89263Smrgfunc_fallback_echo () 388825b89263Smrg{ 388925b89263Smrg eval 'cat <<_LTECHO_EOF 389025b89263Smrg\$1 389125b89263Smrg_LTECHO_EOF' 389225b89263Smrg} 389325b89263Smrg ECHO=\"$qECHO\" 389425b89263Smrg fi 389525b89263Smrg 389625b89263Smrg# Very basic option parsing. These options are (a) specific to 389725b89263Smrg# the libtool wrapper, (b) are identical between the wrapper 389825b89263Smrg# /script/ and the wrapper /executable/ which is used only on 389925b89263Smrg# windows platforms, and (c) all begin with the string "--lt-" 390025b89263Smrg# (application programs are unlikely to have options which match 390125b89263Smrg# this pattern). 390225b89263Smrg# 390325b89263Smrg# There are only two supported options: --lt-debug and 390425b89263Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 390525b89263Smrg# 390625b89263Smrg# The first argument to this parsing function should be the 390725b89263Smrg# script's $0 value, followed by "$@". 390825b89263Smrglt_option_debug= 390925b89263Smrgfunc_parse_lt_options () 391025b89263Smrg{ 391125b89263Smrg lt_script_arg0=\$0 391225b89263Smrg shift 391325b89263Smrg for lt_opt 391425b89263Smrg do 391525b89263Smrg case \"\$lt_opt\" in 391625b89263Smrg --lt-debug) lt_option_debug=1 ;; 391725b89263Smrg --lt-dump-script) 391825b89263Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 391925b89263Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 392025b89263Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 392125b89263Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 392225b89263Smrg exit 0 392325b89263Smrg ;; 392425b89263Smrg --lt-*) 392525b89263Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 392625b89263Smrg exit 1 392725b89263Smrg ;; 392825b89263Smrg esac 392925b89263Smrg done 393025b89263Smrg 393125b89263Smrg # Print the debug banner immediately: 393225b89263Smrg if test -n \"\$lt_option_debug\"; then 393325b89263Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 393425b89263Smrg fi 393525b89263Smrg} 393625b89263Smrg 393725b89263Smrg# Used when --lt-debug. Prints its arguments to stdout 393825b89263Smrg# (redirection is the responsibility of the caller) 393925b89263Smrgfunc_lt_dump_args () 394025b89263Smrg{ 394125b89263Smrg lt_dump_args_N=1; 394225b89263Smrg for lt_arg 394325b89263Smrg do 394425b89263Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 394525b89263Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 394625b89263Smrg done 394725b89263Smrg} 394825b89263Smrg 394925b89263Smrg# Core function for launching the target application 395025b89263Smrgfunc_exec_program_core () 395125b89263Smrg{ 3952ea133fd7Smrg" 395325b89263Smrg case $host in 395425b89263Smrg # Backslashes separate directories on plain windows 395525b89263Smrg *-*-mingw | *-*-os2* | *-cegcc*) 395625b89263Smrg $ECHO "\ 395725b89263Smrg if test -n \"\$lt_option_debug\"; then 395825b89263Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 395925b89263Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 396025b89263Smrg fi 396125b89263Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 396225b89263Smrg" 396325b89263Smrg ;; 396425b89263Smrg 396525b89263Smrg *) 396625b89263Smrg $ECHO "\ 396725b89263Smrg if test -n \"\$lt_option_debug\"; then 396825b89263Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 396925b89263Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 397025b89263Smrg fi 397125b89263Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 397225b89263Smrg" 397325b89263Smrg ;; 397425b89263Smrg esac 397525b89263Smrg $ECHO "\ 397625b89263Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 397725b89263Smrg exit 1 397825b89263Smrg} 397925b89263Smrg 398025b89263Smrg# A function to encapsulate launching the target application 398125b89263Smrg# Strips options in the --lt-* namespace from \$@ and 398225b89263Smrg# launches target application with the remaining arguments. 398325b89263Smrgfunc_exec_program () 398425b89263Smrg{ 398525b89263Smrg for lt_wr_arg 398625b89263Smrg do 398725b89263Smrg case \$lt_wr_arg in 398825b89263Smrg --lt-*) ;; 398925b89263Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 399025b89263Smrg esac 399125b89263Smrg shift 399225b89263Smrg done 399325b89263Smrg func_exec_program_core \${1+\"\$@\"} 399425b89263Smrg} 399525b89263Smrg 399625b89263Smrg # Parse options 399725b89263Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 3998a253d6aeSmrg 3999ea133fd7Smrg # Find the directory that this script lives in. 400025b89263Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 4001ea133fd7Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4002a253d6aeSmrg 4003ea133fd7Smrg # Follow symbolic links until we get to the real thisdir. 400425b89263Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 4005ea133fd7Smrg while test -n \"\$file\"; do 400625b89263Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4007a253d6aeSmrg 4008ea133fd7Smrg # If there was a directory component, then change thisdir. 4009ea133fd7Smrg if test \"x\$destdir\" != \"x\$file\"; then 4010ea133fd7Smrg case \"\$destdir\" in 4011ea133fd7Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 4012ea133fd7Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 4013ea133fd7Smrg esac 4014ea133fd7Smrg fi 4015a253d6aeSmrg 401625b89263Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 401725b89263Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 4018ea133fd7Smrg done 4019a253d6aeSmrg 4020ea133fd7Smrg # Usually 'no', except on cygwin/mingw when embedded into 4021ea133fd7Smrg # the cwrapper. 402225b89263Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 4023ea133fd7Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 4024ea133fd7Smrg # special case for '.' 4025ea133fd7Smrg if test \"\$thisdir\" = \".\"; then 4026ea133fd7Smrg thisdir=\`pwd\` 4027ea133fd7Smrg fi 4028ea133fd7Smrg # remove .libs from thisdir 4029ea133fd7Smrg case \"\$thisdir\" in 403025b89263Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 4031ea133fd7Smrg $objdir ) thisdir=. ;; 4032ea133fd7Smrg esac 4033ea133fd7Smrg fi 4034a253d6aeSmrg 4035ea133fd7Smrg # Try to get the absolute directory name. 4036ea133fd7Smrg absdir=\`cd \"\$thisdir\" && pwd\` 4037ea133fd7Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 4038ea133fd7Smrg" 4039a253d6aeSmrg 4040ea133fd7Smrg if test "$fast_install" = yes; then 4041ea133fd7Smrg $ECHO "\ 4042ea133fd7Smrg program=lt-'$outputname'$exeext 4043ea133fd7Smrg progdir=\"\$thisdir/$objdir\" 4044a253d6aeSmrg 4045ea133fd7Smrg if test ! -f \"\$progdir/\$program\" || 4046ea133fd7Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 4047ea133fd7Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4048a253d6aeSmrg 4049ea133fd7Smrg file=\"\$\$-\$program\" 4050a253d6aeSmrg 4051ea133fd7Smrg if test ! -d \"\$progdir\"; then 4052ea133fd7Smrg $MKDIR \"\$progdir\" 4053ea133fd7Smrg else 4054ea133fd7Smrg $RM \"\$progdir/\$file\" 4055ea133fd7Smrg fi" 4056a253d6aeSmrg 4057ea133fd7Smrg $ECHO "\ 4058a253d6aeSmrg 4059ea133fd7Smrg # relink executable if necessary 4060ea133fd7Smrg if test -n \"\$relink_command\"; then 4061ea133fd7Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 4062ea133fd7Smrg else 4063ea133fd7Smrg $ECHO \"\$relink_command_output\" >&2 4064ea133fd7Smrg $RM \"\$progdir/\$file\" 4065ea133fd7Smrg exit 1 4066ea133fd7Smrg fi 4067ea133fd7Smrg fi 4068a253d6aeSmrg 4069ea133fd7Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 4070ea133fd7Smrg { $RM \"\$progdir/\$program\"; 4071ea133fd7Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 4072ea133fd7Smrg $RM \"\$progdir/\$file\" 4073ea133fd7Smrg fi" 4074ea133fd7Smrg else 4075ea133fd7Smrg $ECHO "\ 4076ea133fd7Smrg program='$outputname' 4077ea133fd7Smrg progdir=\"\$thisdir/$objdir\" 4078ea133fd7Smrg" 4079ea133fd7Smrg fi 4080a253d6aeSmrg 4081ea133fd7Smrg $ECHO "\ 4082a253d6aeSmrg 4083ea133fd7Smrg if test -f \"\$progdir/\$program\"; then" 4084a253d6aeSmrg 408506f32fbeSmrg # fixup the dll searchpath if we need to. 408606f32fbeSmrg # 408706f32fbeSmrg # Fix the DLL searchpath if we need to. Do this before prepending 408806f32fbeSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 408906f32fbeSmrg # libraries must come first. 409006f32fbeSmrg if test -n "$dllsearchpath"; then 409106f32fbeSmrg $ECHO "\ 409206f32fbeSmrg # Add the dll search path components to the executable PATH 409306f32fbeSmrg PATH=$dllsearchpath:\$PATH 409406f32fbeSmrg" 409506f32fbeSmrg fi 409606f32fbeSmrg 4097ea133fd7Smrg # Export our shlibpath_var if we have one. 4098ea133fd7Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4099ea133fd7Smrg $ECHO "\ 4100ea133fd7Smrg # Add our own library path to $shlibpath_var 4101ea133fd7Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4102a253d6aeSmrg 4103ea133fd7Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 4104ea133fd7Smrg # The second colon is a workaround for a bug in BeOS R4 sed 410525b89263Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4106a253d6aeSmrg 4107ea133fd7Smrg export $shlibpath_var 4108ea133fd7Smrg" 4109a253d6aeSmrg fi 4110a253d6aeSmrg 4111ea133fd7Smrg $ECHO "\ 4112ea133fd7Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 4113ea133fd7Smrg # Run the actual program with our arguments. 411425b89263Smrg func_exec_program \${1+\"\$@\"} 4115ea133fd7Smrg fi 4116ea133fd7Smrg else 4117ea133fd7Smrg # The program doesn't exist. 4118ea133fd7Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 4119ea133fd7Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 412025b89263Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 4121ea133fd7Smrg exit 1 4122ea133fd7Smrg fi 4123ea133fd7Smrgfi\ 4124ea133fd7Smrg" 4125ea133fd7Smrg} 4126a253d6aeSmrg 4127a253d6aeSmrg 4128ea133fd7Smrg# func_emit_cwrapperexe_src 4129ea133fd7Smrg# emit the source code for a wrapper executable on stdout 4130ea133fd7Smrg# Must ONLY be called from within func_mode_link because 4131ea133fd7Smrg# it depends on a number of variable set therein. 4132ea133fd7Smrgfunc_emit_cwrapperexe_src () 4133ea133fd7Smrg{ 4134ea133fd7Smrg cat <<EOF 4135a253d6aeSmrg 4136ea133fd7Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4137ea133fd7Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4138a253d6aeSmrg 4139ea133fd7Smrg The $output program cannot be directly executed until all the libtool 4140ea133fd7Smrg libraries that it depends on are installed. 4141a253d6aeSmrg 4142ea133fd7Smrg This wrapper executable should never be moved out of the build directory. 4143ea133fd7Smrg If it is, it will not operate correctly. 4144ea133fd7Smrg*/ 4145ea133fd7SmrgEOF 4146ea133fd7Smrg cat <<"EOF" 414725b89263Smrg#ifdef _MSC_VER 414825b89263Smrg# define _CRT_SECURE_NO_DEPRECATE 1 414925b89263Smrg#endif 4150ea133fd7Smrg#include <stdio.h> 4151ea133fd7Smrg#include <stdlib.h> 4152ea133fd7Smrg#ifdef _MSC_VER 4153ea133fd7Smrg# include <direct.h> 4154ea133fd7Smrg# include <process.h> 4155ea133fd7Smrg# include <io.h> 4156ea133fd7Smrg#else 4157ea133fd7Smrg# include <unistd.h> 4158ea133fd7Smrg# include <stdint.h> 4159ea133fd7Smrg# ifdef __CYGWIN__ 4160ea133fd7Smrg# include <io.h> 4161ea133fd7Smrg# endif 4162ea133fd7Smrg#endif 4163ea133fd7Smrg#include <malloc.h> 4164ea133fd7Smrg#include <stdarg.h> 4165ea133fd7Smrg#include <assert.h> 4166ea133fd7Smrg#include <string.h> 4167ea133fd7Smrg#include <ctype.h> 4168ea133fd7Smrg#include <errno.h> 4169ea133fd7Smrg#include <fcntl.h> 4170ea133fd7Smrg#include <sys/stat.h> 4171ea133fd7Smrg 417225b89263Smrg/* declarations of non-ANSI functions */ 417325b89263Smrg#if defined(__MINGW32__) 417425b89263Smrg# ifdef __STRICT_ANSI__ 417525b89263Smrgint _putenv (const char *); 417625b89263Smrg# endif 417725b89263Smrg#elif defined(__CYGWIN__) 417825b89263Smrg# ifdef __STRICT_ANSI__ 417925b89263Smrgchar *realpath (const char *, char *); 418025b89263Smrgint putenv (char *); 418125b89263Smrgint setenv (const char *, const char *, int); 418225b89263Smrg# endif 418325b89263Smrg/* #elif defined (other platforms) ... */ 418425b89263Smrg#endif 418525b89263Smrg 418625b89263Smrg/* portability defines, excluding path handling macros */ 418725b89263Smrg#if defined(_MSC_VER) 418825b89263Smrg# define setmode _setmode 418925b89263Smrg# define stat _stat 419025b89263Smrg# define chmod _chmod 419125b89263Smrg# define getcwd _getcwd 419225b89263Smrg# define putenv _putenv 419325b89263Smrg# define S_IXUSR _S_IEXEC 419425b89263Smrg# ifndef _INTPTR_T_DEFINED 419525b89263Smrg# define _INTPTR_T_DEFINED 419625b89263Smrg# define intptr_t int 419725b89263Smrg# endif 419825b89263Smrg#elif defined(__MINGW32__) 419925b89263Smrg# define setmode _setmode 420025b89263Smrg# define stat _stat 420125b89263Smrg# define chmod _chmod 420225b89263Smrg# define getcwd _getcwd 420325b89263Smrg# define putenv _putenv 420425b89263Smrg#elif defined(__CYGWIN__) 420525b89263Smrg# define HAVE_SETENV 420625b89263Smrg# define FOPEN_WB "wb" 420725b89263Smrg/* #elif defined (other platforms) ... */ 420825b89263Smrg#endif 420925b89263Smrg 4210ea133fd7Smrg#if defined(PATH_MAX) 4211ea133fd7Smrg# define LT_PATHMAX PATH_MAX 4212ea133fd7Smrg#elif defined(MAXPATHLEN) 4213ea133fd7Smrg# define LT_PATHMAX MAXPATHLEN 4214ea133fd7Smrg#else 4215ea133fd7Smrg# define LT_PATHMAX 1024 4216ea133fd7Smrg#endif 4217ea133fd7Smrg 4218ea133fd7Smrg#ifndef S_IXOTH 4219ea133fd7Smrg# define S_IXOTH 0 4220ea133fd7Smrg#endif 4221ea133fd7Smrg#ifndef S_IXGRP 4222ea133fd7Smrg# define S_IXGRP 0 4223ea133fd7Smrg#endif 4224ea133fd7Smrg 422525b89263Smrg/* path handling portability macros */ 4226ea133fd7Smrg#ifndef DIR_SEPARATOR 4227ea133fd7Smrg# define DIR_SEPARATOR '/' 4228ea133fd7Smrg# define PATH_SEPARATOR ':' 4229ea133fd7Smrg#endif 4230ea133fd7Smrg 4231ea133fd7Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4232ea133fd7Smrg defined (__OS2__) 4233ea133fd7Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 4234ea133fd7Smrg# define FOPEN_WB "wb" 4235ea133fd7Smrg# ifndef DIR_SEPARATOR_2 4236ea133fd7Smrg# define DIR_SEPARATOR_2 '\\' 4237ea133fd7Smrg# endif 4238ea133fd7Smrg# ifndef PATH_SEPARATOR_2 4239ea133fd7Smrg# define PATH_SEPARATOR_2 ';' 4240ea133fd7Smrg# endif 4241ea133fd7Smrg#endif 4242ea133fd7Smrg 4243ea133fd7Smrg#ifndef DIR_SEPARATOR_2 4244ea133fd7Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 4245ea133fd7Smrg#else /* DIR_SEPARATOR_2 */ 4246ea133fd7Smrg# define IS_DIR_SEPARATOR(ch) \ 4247ea133fd7Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 4248ea133fd7Smrg#endif /* DIR_SEPARATOR_2 */ 4249ea133fd7Smrg 4250ea133fd7Smrg#ifndef PATH_SEPARATOR_2 4251ea133fd7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 4252ea133fd7Smrg#else /* PATH_SEPARATOR_2 */ 4253ea133fd7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 4254ea133fd7Smrg#endif /* PATH_SEPARATOR_2 */ 4255ea133fd7Smrg 4256ea133fd7Smrg#ifndef FOPEN_WB 4257ea133fd7Smrg# define FOPEN_WB "w" 4258ea133fd7Smrg#endif 4259ea133fd7Smrg#ifndef _O_BINARY 4260ea133fd7Smrg# define _O_BINARY 0 4261ea133fd7Smrg#endif 4262ea133fd7Smrg 4263ea133fd7Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 4264ea133fd7Smrg#define XFREE(stale) do { \ 4265ea133fd7Smrg if (stale) { free ((void *) stale); stale = 0; } \ 4266ea133fd7Smrg} while (0) 4267ea133fd7Smrg 426825b89263Smrg#if defined(LT_DEBUGWRAPPER) 426925b89263Smrgstatic int lt_debug = 1; 4270ea133fd7Smrg#else 427125b89263Smrgstatic int lt_debug = 0; 4272ea133fd7Smrg#endif 4273ea133fd7Smrg 427425b89263Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4275ea133fd7Smrg 4276ea133fd7Smrgvoid *xmalloc (size_t num); 4277ea133fd7Smrgchar *xstrdup (const char *string); 4278ea133fd7Smrgconst char *base_name (const char *name); 4279ea133fd7Smrgchar *find_executable (const char *wrapper); 4280ea133fd7Smrgchar *chase_symlinks (const char *pathspec); 4281ea133fd7Smrgint make_executable (const char *path); 4282ea133fd7Smrgint check_executable (const char *path); 4283ea133fd7Smrgchar *strendzap (char *str, const char *pat); 428425b89263Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 428525b89263Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 428625b89263Smrgstatic const char *nonnull (const char *s); 428725b89263Smrgstatic const char *nonempty (const char *s); 4288ea133fd7Smrgvoid lt_setenv (const char *name, const char *value); 4289ea133fd7Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 4290ea133fd7Smrgvoid lt_update_exe_path (const char *name, const char *value); 4291ea133fd7Smrgvoid lt_update_lib_path (const char *name, const char *value); 429225b89263Smrgchar **prepare_spawn (char **argv); 429325b89263Smrgvoid lt_dump_script (FILE *f); 4294ea133fd7SmrgEOF 4295ea133fd7Smrg 4296ea133fd7Smrg cat <<EOF 429706f32fbeSmrgvolatile const char * MAGIC_EXE = "$magic_exe"; 4298ea133fd7Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 4299ea133fd7SmrgEOF 4300ea133fd7Smrg 4301ea133fd7Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 430206f32fbeSmrg func_to_host_path "$temp_rpath" 4303ea133fd7Smrg cat <<EOF 430406f32fbeSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 4305a253d6aeSmrgEOF 4306a253d6aeSmrg else 4307ea133fd7Smrg cat <<"EOF" 4308ea133fd7Smrgconst char * LIB_PATH_VALUE = ""; 4309ea133fd7SmrgEOF 4310a253d6aeSmrg fi 4311ea133fd7Smrg 4312ea133fd7Smrg if test -n "$dllsearchpath"; then 431306f32fbeSmrg func_to_host_path "$dllsearchpath:" 4314ea133fd7Smrg cat <<EOF 4315ea133fd7Smrgconst char * EXE_PATH_VARNAME = "PATH"; 431606f32fbeSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 4317ea133fd7SmrgEOF 4318a253d6aeSmrg else 4319ea133fd7Smrg cat <<"EOF" 4320ea133fd7Smrgconst char * EXE_PATH_VARNAME = ""; 4321ea133fd7Smrgconst char * EXE_PATH_VALUE = ""; 4322ea133fd7SmrgEOF 4323a253d6aeSmrg fi 4324ea133fd7Smrg 4325ea133fd7Smrg if test "$fast_install" = yes; then 4326ea133fd7Smrg cat <<EOF 4327ea133fd7Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 4328ea133fd7SmrgEOF 4329a253d6aeSmrg else 4330ea133fd7Smrg cat <<EOF 4331ea133fd7Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 4332ea133fd7SmrgEOF 4333a253d6aeSmrg fi 4334a253d6aeSmrg 4335a253d6aeSmrg 4336ea133fd7Smrg cat <<"EOF" 4337a253d6aeSmrg 4338ea133fd7Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 4339a253d6aeSmrg 4340ea133fd7Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 4341ea133fd7Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 434225b89263Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4343a253d6aeSmrg 4344ea133fd7Smrgint 4345ea133fd7Smrgmain (int argc, char *argv[]) 4346ea133fd7Smrg{ 4347ea133fd7Smrg char **newargz; 4348ea133fd7Smrg int newargc; 4349ea133fd7Smrg char *tmp_pathspec; 4350ea133fd7Smrg char *actual_cwrapper_path; 4351ea133fd7Smrg char *actual_cwrapper_name; 4352ea133fd7Smrg char *target_name; 4353ea133fd7Smrg char *lt_argv_zero; 4354ea133fd7Smrg intptr_t rval = 127; 4355a253d6aeSmrg 4356ea133fd7Smrg int i; 4357a253d6aeSmrg 4358ea133fd7Smrg program_name = (char *) xstrdup (base_name (argv[0])); 435925b89263Smrg newargz = XMALLOC (char *, argc + 1); 4360a253d6aeSmrg 436125b89263Smrg /* very simple arg parsing; don't want to rely on getopt 436225b89263Smrg * also, copy all non cwrapper options to newargz, except 436325b89263Smrg * argz[0], which is handled differently 436425b89263Smrg */ 436525b89263Smrg newargc=0; 4366ea133fd7Smrg for (i = 1; i < argc; i++) 4367ea133fd7Smrg { 4368ea133fd7Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 4369ea133fd7Smrg { 4370ea133fd7SmrgEOF 4371ea133fd7Smrg case "$host" in 4372ea133fd7Smrg *mingw* | *cygwin* ) 4373ea133fd7Smrg # make stdout use "unix" line endings 4374ea133fd7Smrg echo " setmode(1,_O_BINARY);" 4375ea133fd7Smrg ;; 4376ea133fd7Smrg esac 4377a253d6aeSmrg 4378ea133fd7Smrg cat <<"EOF" 437925b89263Smrg lt_dump_script (stdout); 4380ea133fd7Smrg return 0; 4381ea133fd7Smrg } 438225b89263Smrg if (strcmp (argv[i], debug_opt) == 0) 438325b89263Smrg { 438425b89263Smrg lt_debug = 1; 438525b89263Smrg continue; 438625b89263Smrg } 438725b89263Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 438825b89263Smrg { 438925b89263Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 439025b89263Smrg namespace, but it is not one of the ones we know about and 439125b89263Smrg have already dealt with, above (inluding dump-script), then 439225b89263Smrg report an error. Otherwise, targets might begin to believe 439325b89263Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 439425b89263Smrg namespace. The first time any user complains about this, we'll 439525b89263Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 439625b89263Smrg or a configure.ac-settable value. 439725b89263Smrg */ 439825b89263Smrg lt_fatal (__FILE__, __LINE__, 439925b89263Smrg "unrecognized %s option: '%s'", 440025b89263Smrg ltwrapper_option_prefix, argv[i]); 440125b89263Smrg } 440225b89263Smrg /* otherwise ... */ 440325b89263Smrg newargz[++newargc] = xstrdup (argv[i]); 4404ea133fd7Smrg } 440525b89263Smrg newargz[++newargc] = NULL; 440625b89263Smrg 440725b89263SmrgEOF 440825b89263Smrg cat <<EOF 440925b89263Smrg /* The GNU banner must be the first non-error debug message */ 441025b89263Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 441125b89263SmrgEOF 441225b89263Smrg cat <<"EOF" 441325b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 441425b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4415a253d6aeSmrg 4416ea133fd7Smrg tmp_pathspec = find_executable (argv[0]); 4417ea133fd7Smrg if (tmp_pathspec == NULL) 441825b89263Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 441925b89263Smrg lt_debugprintf (__FILE__, __LINE__, 442025b89263Smrg "(main) found exe (before symlink chase) at: %s\n", 442125b89263Smrg tmp_pathspec); 4422ea133fd7Smrg 4423ea133fd7Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 442425b89263Smrg lt_debugprintf (__FILE__, __LINE__, 442525b89263Smrg "(main) found exe (after symlink chase) at: %s\n", 442625b89263Smrg actual_cwrapper_path); 4427ea133fd7Smrg XFREE (tmp_pathspec); 4428ea133fd7Smrg 442925b89263Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 4430ea133fd7Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 4431ea133fd7Smrg 4432ea133fd7Smrg /* wrapper name transforms */ 4433ea133fd7Smrg strendzap (actual_cwrapper_name, ".exe"); 4434ea133fd7Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 4435ea133fd7Smrg XFREE (actual_cwrapper_name); 4436ea133fd7Smrg actual_cwrapper_name = tmp_pathspec; 4437ea133fd7Smrg tmp_pathspec = 0; 4438ea133fd7Smrg 4439ea133fd7Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 4440ea133fd7Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 4441ea133fd7Smrg strendzap (target_name, ".exe"); 4442ea133fd7Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 4443ea133fd7Smrg XFREE (target_name); 4444ea133fd7Smrg target_name = tmp_pathspec; 4445ea133fd7Smrg tmp_pathspec = 0; 4446ea133fd7Smrg 444725b89263Smrg lt_debugprintf (__FILE__, __LINE__, 444825b89263Smrg "(main) libtool target name: %s\n", 444925b89263Smrg target_name); 4450ea133fd7SmrgEOF 4451a253d6aeSmrg 4452ea133fd7Smrg cat <<EOF 4453ea133fd7Smrg newargz[0] = 4454ea133fd7Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 4455ea133fd7Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 4456ea133fd7Smrg strcpy (newargz[0], actual_cwrapper_path); 4457ea133fd7Smrg strcat (newargz[0], "$objdir"); 4458ea133fd7Smrg strcat (newargz[0], "/"); 4459ea133fd7SmrgEOF 4460a253d6aeSmrg 4461ea133fd7Smrg cat <<"EOF" 4462ea133fd7Smrg /* stop here, and copy so we don't have to do this twice */ 4463ea133fd7Smrg tmp_pathspec = xstrdup (newargz[0]); 4464a253d6aeSmrg 4465ea133fd7Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 4466ea133fd7Smrg strcat (newargz[0], actual_cwrapper_name); 4467a253d6aeSmrg 4468ea133fd7Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 4469ea133fd7Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 4470ea133fd7Smrg XFREE (tmp_pathspec); 4471ea133fd7Smrg tmp_pathspec = NULL; 4472ea133fd7SmrgEOF 4473a253d6aeSmrg 4474ea133fd7Smrg case $host_os in 4475ea133fd7Smrg mingw*) 4476ea133fd7Smrg cat <<"EOF" 4477ea133fd7Smrg { 4478ea133fd7Smrg char* p; 4479ea133fd7Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 4480ea133fd7Smrg { 4481ea133fd7Smrg *p = '/'; 4482ea133fd7Smrg } 4483ea133fd7Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 4484ea133fd7Smrg { 4485ea133fd7Smrg *p = '/'; 4486ea133fd7Smrg } 4487ea133fd7Smrg } 4488ea133fd7SmrgEOF 4489ea133fd7Smrg ;; 4490ea133fd7Smrg esac 4491a253d6aeSmrg 4492ea133fd7Smrg cat <<"EOF" 4493ea133fd7Smrg XFREE (target_name); 4494ea133fd7Smrg XFREE (actual_cwrapper_path); 4495ea133fd7Smrg XFREE (actual_cwrapper_name); 4496a253d6aeSmrg 4497ea133fd7Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 4498ea133fd7Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 449906f32fbeSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 450006f32fbeSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 450106f32fbeSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 450206f32fbeSmrg libraries must come first. */ 4503ea133fd7Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 450406f32fbeSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4505a253d6aeSmrg 450625b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 450725b89263Smrg nonnull (lt_argv_zero)); 4508ea133fd7Smrg for (i = 0; i < newargc; i++) 4509ea133fd7Smrg { 451025b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 451125b89263Smrg i, nonnull (newargz[i])); 4512ea133fd7Smrg } 4513a253d6aeSmrg 4514ea133fd7SmrgEOF 4515a253d6aeSmrg 4516ea133fd7Smrg case $host_os in 4517ea133fd7Smrg mingw*) 4518ea133fd7Smrg cat <<"EOF" 4519ea133fd7Smrg /* execv doesn't actually work on mingw as expected on unix */ 452025b89263Smrg newargz = prepare_spawn (newargz); 4521ea133fd7Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 4522ea133fd7Smrg if (rval == -1) 4523ea133fd7Smrg { 4524ea133fd7Smrg /* failed to start process */ 452525b89263Smrg lt_debugprintf (__FILE__, __LINE__, 452625b89263Smrg "(main) failed to launch target \"%s\": %s\n", 452725b89263Smrg lt_argv_zero, nonnull (strerror (errno))); 4528ea133fd7Smrg return 127; 4529ea133fd7Smrg } 4530ea133fd7Smrg return rval; 4531ea133fd7SmrgEOF 4532ea133fd7Smrg ;; 4533ea133fd7Smrg *) 4534ea133fd7Smrg cat <<"EOF" 4535ea133fd7Smrg execv (lt_argv_zero, newargz); 4536ea133fd7Smrg return rval; /* =127, but avoids unused variable warning */ 4537ea133fd7SmrgEOF 4538ea133fd7Smrg ;; 4539ea133fd7Smrg esac 4540a253d6aeSmrg 4541ea133fd7Smrg cat <<"EOF" 4542ea133fd7Smrg} 4543a253d6aeSmrg 4544ea133fd7Smrgvoid * 4545ea133fd7Smrgxmalloc (size_t num) 4546ea133fd7Smrg{ 4547ea133fd7Smrg void *p = (void *) malloc (num); 4548ea133fd7Smrg if (!p) 454925b89263Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4550a253d6aeSmrg 4551ea133fd7Smrg return p; 4552ea133fd7Smrg} 4553a253d6aeSmrg 4554ea133fd7Smrgchar * 4555ea133fd7Smrgxstrdup (const char *string) 4556ea133fd7Smrg{ 4557ea133fd7Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 4558ea133fd7Smrg string) : NULL; 4559ea133fd7Smrg} 4560a253d6aeSmrg 4561ea133fd7Smrgconst char * 4562ea133fd7Smrgbase_name (const char *name) 4563ea133fd7Smrg{ 4564ea133fd7Smrg const char *base; 4565a253d6aeSmrg 4566ea133fd7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4567ea133fd7Smrg /* Skip over the disk name in MSDOS pathnames. */ 4568ea133fd7Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 4569ea133fd7Smrg name += 2; 4570ea133fd7Smrg#endif 4571a253d6aeSmrg 4572ea133fd7Smrg for (base = name; *name; name++) 4573ea133fd7Smrg if (IS_DIR_SEPARATOR (*name)) 4574ea133fd7Smrg base = name + 1; 4575ea133fd7Smrg return base; 4576ea133fd7Smrg} 4577a253d6aeSmrg 4578ea133fd7Smrgint 4579ea133fd7Smrgcheck_executable (const char *path) 4580ea133fd7Smrg{ 4581ea133fd7Smrg struct stat st; 4582a253d6aeSmrg 458325b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 458425b89263Smrg nonempty (path)); 4585ea133fd7Smrg if ((!path) || (!*path)) 4586ea133fd7Smrg return 0; 4587a253d6aeSmrg 4588ea133fd7Smrg if ((stat (path, &st) >= 0) 4589ea133fd7Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 4590ea133fd7Smrg return 1; 4591ea133fd7Smrg else 4592ea133fd7Smrg return 0; 4593ea133fd7Smrg} 4594a253d6aeSmrg 4595ea133fd7Smrgint 4596ea133fd7Smrgmake_executable (const char *path) 4597ea133fd7Smrg{ 4598ea133fd7Smrg int rval = 0; 4599ea133fd7Smrg struct stat st; 4600a253d6aeSmrg 460125b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 460225b89263Smrg nonempty (path)); 4603ea133fd7Smrg if ((!path) || (!*path)) 4604ea133fd7Smrg return 0; 4605a253d6aeSmrg 4606ea133fd7Smrg if (stat (path, &st) >= 0) 4607ea133fd7Smrg { 4608ea133fd7Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 4609ea133fd7Smrg } 4610ea133fd7Smrg return rval; 4611ea133fd7Smrg} 4612a253d6aeSmrg 4613ea133fd7Smrg/* Searches for the full path of the wrapper. Returns 4614ea133fd7Smrg newly allocated full path name if found, NULL otherwise 4615ea133fd7Smrg Does not chase symlinks, even on platforms that support them. 4616ea133fd7Smrg*/ 4617ea133fd7Smrgchar * 4618ea133fd7Smrgfind_executable (const char *wrapper) 4619ea133fd7Smrg{ 4620ea133fd7Smrg int has_slash = 0; 4621ea133fd7Smrg const char *p; 4622ea133fd7Smrg const char *p_next; 4623ea133fd7Smrg /* static buffer for getcwd */ 4624ea133fd7Smrg char tmp[LT_PATHMAX + 1]; 4625ea133fd7Smrg int tmp_len; 4626ea133fd7Smrg char *concat_name; 4627a253d6aeSmrg 462825b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 462925b89263Smrg nonempty (wrapper)); 4630a253d6aeSmrg 4631ea133fd7Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 4632ea133fd7Smrg return NULL; 4633a253d6aeSmrg 4634ea133fd7Smrg /* Absolute path? */ 4635ea133fd7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4636ea133fd7Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 4637ea133fd7Smrg { 4638ea133fd7Smrg concat_name = xstrdup (wrapper); 4639ea133fd7Smrg if (check_executable (concat_name)) 4640ea133fd7Smrg return concat_name; 4641ea133fd7Smrg XFREE (concat_name); 4642ea133fd7Smrg } 4643ea133fd7Smrg else 4644ea133fd7Smrg { 4645ea133fd7Smrg#endif 4646ea133fd7Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 4647ea133fd7Smrg { 4648ea133fd7Smrg concat_name = xstrdup (wrapper); 4649ea133fd7Smrg if (check_executable (concat_name)) 4650ea133fd7Smrg return concat_name; 4651ea133fd7Smrg XFREE (concat_name); 4652ea133fd7Smrg } 4653ea133fd7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4654ea133fd7Smrg } 4655ea133fd7Smrg#endif 4656a253d6aeSmrg 4657ea133fd7Smrg for (p = wrapper; *p; p++) 4658ea133fd7Smrg if (*p == '/') 4659ea133fd7Smrg { 4660ea133fd7Smrg has_slash = 1; 4661ea133fd7Smrg break; 4662ea133fd7Smrg } 4663ea133fd7Smrg if (!has_slash) 4664ea133fd7Smrg { 4665ea133fd7Smrg /* no slashes; search PATH */ 4666ea133fd7Smrg const char *path = getenv ("PATH"); 4667ea133fd7Smrg if (path != NULL) 4668ea133fd7Smrg { 4669ea133fd7Smrg for (p = path; *p; p = p_next) 4670ea133fd7Smrg { 4671ea133fd7Smrg const char *q; 4672ea133fd7Smrg size_t p_len; 4673ea133fd7Smrg for (q = p; *q; q++) 4674ea133fd7Smrg if (IS_PATH_SEPARATOR (*q)) 4675ea133fd7Smrg break; 4676ea133fd7Smrg p_len = q - p; 4677ea133fd7Smrg p_next = (*q == '\0' ? q : q + 1); 4678ea133fd7Smrg if (p_len == 0) 4679ea133fd7Smrg { 4680ea133fd7Smrg /* empty path: current directory */ 4681ea133fd7Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 468225b89263Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 468325b89263Smrg nonnull (strerror (errno))); 4684ea133fd7Smrg tmp_len = strlen (tmp); 4685ea133fd7Smrg concat_name = 4686ea133fd7Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4687ea133fd7Smrg memcpy (concat_name, tmp, tmp_len); 4688ea133fd7Smrg concat_name[tmp_len] = '/'; 4689ea133fd7Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4690ea133fd7Smrg } 4691ea133fd7Smrg else 4692ea133fd7Smrg { 4693ea133fd7Smrg concat_name = 4694ea133fd7Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 4695ea133fd7Smrg memcpy (concat_name, p, p_len); 4696ea133fd7Smrg concat_name[p_len] = '/'; 4697ea133fd7Smrg strcpy (concat_name + p_len + 1, wrapper); 4698ea133fd7Smrg } 4699ea133fd7Smrg if (check_executable (concat_name)) 4700ea133fd7Smrg return concat_name; 4701ea133fd7Smrg XFREE (concat_name); 4702ea133fd7Smrg } 4703ea133fd7Smrg } 4704ea133fd7Smrg /* not found in PATH; assume curdir */ 4705ea133fd7Smrg } 4706ea133fd7Smrg /* Relative path | not found in path: prepend cwd */ 4707ea133fd7Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 470825b89263Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 470925b89263Smrg nonnull (strerror (errno))); 4710ea133fd7Smrg tmp_len = strlen (tmp); 4711ea133fd7Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4712ea133fd7Smrg memcpy (concat_name, tmp, tmp_len); 4713ea133fd7Smrg concat_name[tmp_len] = '/'; 4714ea133fd7Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4715a253d6aeSmrg 4716ea133fd7Smrg if (check_executable (concat_name)) 4717ea133fd7Smrg return concat_name; 4718ea133fd7Smrg XFREE (concat_name); 4719ea133fd7Smrg return NULL; 4720ea133fd7Smrg} 4721a253d6aeSmrg 4722ea133fd7Smrgchar * 4723ea133fd7Smrgchase_symlinks (const char *pathspec) 4724ea133fd7Smrg{ 4725ea133fd7Smrg#ifndef S_ISLNK 4726ea133fd7Smrg return xstrdup (pathspec); 4727ea133fd7Smrg#else 4728ea133fd7Smrg char buf[LT_PATHMAX]; 4729ea133fd7Smrg struct stat s; 4730ea133fd7Smrg char *tmp_pathspec = xstrdup (pathspec); 4731ea133fd7Smrg char *p; 4732ea133fd7Smrg int has_symlinks = 0; 4733ea133fd7Smrg while (strlen (tmp_pathspec) && !has_symlinks) 4734ea133fd7Smrg { 473525b89263Smrg lt_debugprintf (__FILE__, __LINE__, 473625b89263Smrg "checking path component for symlinks: %s\n", 473725b89263Smrg tmp_pathspec); 4738ea133fd7Smrg if (lstat (tmp_pathspec, &s) == 0) 4739ea133fd7Smrg { 4740ea133fd7Smrg if (S_ISLNK (s.st_mode) != 0) 4741ea133fd7Smrg { 4742ea133fd7Smrg has_symlinks = 1; 4743ea133fd7Smrg break; 4744ea133fd7Smrg } 4745a253d6aeSmrg 4746ea133fd7Smrg /* search backwards for last DIR_SEPARATOR */ 4747ea133fd7Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 4748ea133fd7Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4749ea133fd7Smrg p--; 4750ea133fd7Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4751ea133fd7Smrg { 4752ea133fd7Smrg /* no more DIR_SEPARATORS left */ 4753ea133fd7Smrg break; 4754ea133fd7Smrg } 4755ea133fd7Smrg *p = '\0'; 4756ea133fd7Smrg } 4757ea133fd7Smrg else 4758ea133fd7Smrg { 475925b89263Smrg lt_fatal (__FILE__, __LINE__, 476025b89263Smrg "error accessing file \"%s\": %s", 476125b89263Smrg tmp_pathspec, nonnull (strerror (errno))); 4762ea133fd7Smrg } 4763ea133fd7Smrg } 4764ea133fd7Smrg XFREE (tmp_pathspec); 4765a253d6aeSmrg 4766ea133fd7Smrg if (!has_symlinks) 4767ea133fd7Smrg { 4768ea133fd7Smrg return xstrdup (pathspec); 4769ea133fd7Smrg } 4770a253d6aeSmrg 4771ea133fd7Smrg tmp_pathspec = realpath (pathspec, buf); 4772ea133fd7Smrg if (tmp_pathspec == 0) 4773ea133fd7Smrg { 477425b89263Smrg lt_fatal (__FILE__, __LINE__, 477525b89263Smrg "could not follow symlinks for %s", pathspec); 4776ea133fd7Smrg } 4777ea133fd7Smrg return xstrdup (tmp_pathspec); 4778ea133fd7Smrg#endif 4779ea133fd7Smrg} 4780a253d6aeSmrg 4781ea133fd7Smrgchar * 4782ea133fd7Smrgstrendzap (char *str, const char *pat) 4783ea133fd7Smrg{ 4784ea133fd7Smrg size_t len, patlen; 4785a253d6aeSmrg 4786ea133fd7Smrg assert (str != NULL); 4787ea133fd7Smrg assert (pat != NULL); 4788a253d6aeSmrg 4789ea133fd7Smrg len = strlen (str); 4790ea133fd7Smrg patlen = strlen (pat); 4791a253d6aeSmrg 4792ea133fd7Smrg if (patlen <= len) 4793ea133fd7Smrg { 4794ea133fd7Smrg str += len - patlen; 4795ea133fd7Smrg if (strcmp (str, pat) == 0) 4796ea133fd7Smrg *str = '\0'; 4797ea133fd7Smrg } 4798ea133fd7Smrg return str; 4799ea133fd7Smrg} 4800a253d6aeSmrg 480125b89263Smrgvoid 480225b89263Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 480325b89263Smrg{ 480425b89263Smrg va_list args; 480525b89263Smrg if (lt_debug) 480625b89263Smrg { 480725b89263Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 480825b89263Smrg va_start (args, fmt); 480925b89263Smrg (void) vfprintf (stderr, fmt, args); 481025b89263Smrg va_end (args); 481125b89263Smrg } 481225b89263Smrg} 481325b89263Smrg 4814ea133fd7Smrgstatic void 481525b89263Smrglt_error_core (int exit_status, const char *file, 481625b89263Smrg int line, const char *mode, 4817ea133fd7Smrg const char *message, va_list ap) 4818ea133fd7Smrg{ 481925b89263Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 4820ea133fd7Smrg vfprintf (stderr, message, ap); 4821ea133fd7Smrg fprintf (stderr, ".\n"); 4822a253d6aeSmrg 4823ea133fd7Smrg if (exit_status >= 0) 4824ea133fd7Smrg exit (exit_status); 4825ea133fd7Smrg} 4826a253d6aeSmrg 4827ea133fd7Smrgvoid 482825b89263Smrglt_fatal (const char *file, int line, const char *message, ...) 4829ea133fd7Smrg{ 4830ea133fd7Smrg va_list ap; 4831ea133fd7Smrg va_start (ap, message); 483225b89263Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 4833ea133fd7Smrg va_end (ap); 4834ea133fd7Smrg} 4835a253d6aeSmrg 483625b89263Smrgstatic const char * 483725b89263Smrgnonnull (const char *s) 483825b89263Smrg{ 483925b89263Smrg return s ? s : "(null)"; 484025b89263Smrg} 484125b89263Smrg 484225b89263Smrgstatic const char * 484325b89263Smrgnonempty (const char *s) 484425b89263Smrg{ 484525b89263Smrg return (s && !*s) ? "(empty)" : nonnull (s); 484625b89263Smrg} 484725b89263Smrg 4848ea133fd7Smrgvoid 4849ea133fd7Smrglt_setenv (const char *name, const char *value) 4850ea133fd7Smrg{ 485125b89263Smrg lt_debugprintf (__FILE__, __LINE__, 485225b89263Smrg "(lt_setenv) setting '%s' to '%s'\n", 485325b89263Smrg nonnull (name), nonnull (value)); 4854ea133fd7Smrg { 4855ea133fd7Smrg#ifdef HAVE_SETENV 4856ea133fd7Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 4857ea133fd7Smrg char *str = xstrdup (value); 4858ea133fd7Smrg setenv (name, str, 1); 4859ea133fd7Smrg#else 4860ea133fd7Smrg int len = strlen (name) + 1 + strlen (value) + 1; 4861ea133fd7Smrg char *str = XMALLOC (char, len); 4862ea133fd7Smrg sprintf (str, "%s=%s", name, value); 4863ea133fd7Smrg if (putenv (str) != EXIT_SUCCESS) 4864ea133fd7Smrg { 4865ea133fd7Smrg XFREE (str); 4866ea133fd7Smrg } 4867ea133fd7Smrg#endif 4868ea133fd7Smrg } 4869ea133fd7Smrg} 4870a253d6aeSmrg 4871ea133fd7Smrgchar * 4872ea133fd7Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 4873ea133fd7Smrg{ 4874ea133fd7Smrg char *new_value; 4875ea133fd7Smrg if (orig_value && *orig_value) 4876ea133fd7Smrg { 4877ea133fd7Smrg int orig_value_len = strlen (orig_value); 4878ea133fd7Smrg int add_len = strlen (add); 4879ea133fd7Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 4880ea133fd7Smrg if (to_end) 4881ea133fd7Smrg { 4882ea133fd7Smrg strcpy (new_value, orig_value); 4883ea133fd7Smrg strcpy (new_value + orig_value_len, add); 4884ea133fd7Smrg } 4885ea133fd7Smrg else 4886ea133fd7Smrg { 4887ea133fd7Smrg strcpy (new_value, add); 4888ea133fd7Smrg strcpy (new_value + add_len, orig_value); 4889ea133fd7Smrg } 4890ea133fd7Smrg } 4891ea133fd7Smrg else 4892ea133fd7Smrg { 4893ea133fd7Smrg new_value = xstrdup (add); 4894ea133fd7Smrg } 4895ea133fd7Smrg return new_value; 4896ea133fd7Smrg} 4897a253d6aeSmrg 4898ea133fd7Smrgvoid 4899ea133fd7Smrglt_update_exe_path (const char *name, const char *value) 4900ea133fd7Smrg{ 490125b89263Smrg lt_debugprintf (__FILE__, __LINE__, 490225b89263Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 490325b89263Smrg nonnull (name), nonnull (value)); 4904a253d6aeSmrg 4905ea133fd7Smrg if (name && *name && value && *value) 4906ea133fd7Smrg { 4907ea133fd7Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4908ea133fd7Smrg /* some systems can't cope with a ':'-terminated path #' */ 4909ea133fd7Smrg int len = strlen (new_value); 4910ea133fd7Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 4911ea133fd7Smrg { 4912ea133fd7Smrg new_value[len-1] = '\0'; 4913ea133fd7Smrg } 4914ea133fd7Smrg lt_setenv (name, new_value); 4915ea133fd7Smrg XFREE (new_value); 4916ea133fd7Smrg } 4917ea133fd7Smrg} 4918a253d6aeSmrg 4919ea133fd7Smrgvoid 4920ea133fd7Smrglt_update_lib_path (const char *name, const char *value) 4921ea133fd7Smrg{ 492225b89263Smrg lt_debugprintf (__FILE__, __LINE__, 492325b89263Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 492425b89263Smrg nonnull (name), nonnull (value)); 4925a253d6aeSmrg 4926ea133fd7Smrg if (name && *name && value && *value) 4927ea133fd7Smrg { 4928ea133fd7Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4929ea133fd7Smrg lt_setenv (name, new_value); 4930ea133fd7Smrg XFREE (new_value); 4931ea133fd7Smrg } 4932ea133fd7Smrg} 4933a253d6aeSmrg 493425b89263SmrgEOF 493525b89263Smrg case $host_os in 493625b89263Smrg mingw*) 493725b89263Smrg cat <<"EOF" 493825b89263Smrg 493925b89263Smrg/* Prepares an argument vector before calling spawn(). 494025b89263Smrg Note that spawn() does not by itself call the command interpreter 494125b89263Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 494225b89263Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 494325b89263Smrg GetVersionEx(&v); 494425b89263Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 494525b89263Smrg }) ? "cmd.exe" : "command.com"). 494625b89263Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 494725b89263Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 494825b89263Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 494925b89263Smrg special way: 495025b89263Smrg - Space and tab are interpreted as delimiters. They are not treated as 495125b89263Smrg delimiters if they are surrounded by double quotes: "...". 495225b89263Smrg - Unescaped double quotes are removed from the input. Their only effect is 495325b89263Smrg that within double quotes, space and tab are treated like normal 495425b89263Smrg characters. 495525b89263Smrg - Backslashes not followed by double quotes are not special. 495625b89263Smrg - But 2*n+1 backslashes followed by a double quote become 495725b89263Smrg n backslashes followed by a double quote (n >= 0): 495825b89263Smrg \" -> " 495925b89263Smrg \\\" -> \" 496025b89263Smrg \\\\\" -> \\" 496125b89263Smrg */ 496225b89263Smrg#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" 496325b89263Smrg#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" 496425b89263Smrgchar ** 496525b89263Smrgprepare_spawn (char **argv) 496625b89263Smrg{ 496725b89263Smrg size_t argc; 496825b89263Smrg char **new_argv; 496925b89263Smrg size_t i; 497025b89263Smrg 497125b89263Smrg /* Count number of arguments. */ 497225b89263Smrg for (argc = 0; argv[argc] != NULL; argc++) 497325b89263Smrg ; 497425b89263Smrg 497525b89263Smrg /* Allocate new argument vector. */ 497625b89263Smrg new_argv = XMALLOC (char *, argc + 1); 497725b89263Smrg 497825b89263Smrg /* Put quoted arguments into the new argument vector. */ 497925b89263Smrg for (i = 0; i < argc; i++) 498025b89263Smrg { 498125b89263Smrg const char *string = argv[i]; 498225b89263Smrg 498325b89263Smrg if (string[0] == '\0') 498425b89263Smrg new_argv[i] = xstrdup ("\"\""); 498525b89263Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 498625b89263Smrg { 498725b89263Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 498825b89263Smrg size_t length; 498925b89263Smrg unsigned int backslashes; 499025b89263Smrg const char *s; 499125b89263Smrg char *quoted_string; 499225b89263Smrg char *p; 499325b89263Smrg 499425b89263Smrg length = 0; 499525b89263Smrg backslashes = 0; 499625b89263Smrg if (quote_around) 499725b89263Smrg length++; 499825b89263Smrg for (s = string; *s != '\0'; s++) 499925b89263Smrg { 500025b89263Smrg char c = *s; 500125b89263Smrg if (c == '"') 500225b89263Smrg length += backslashes + 1; 500325b89263Smrg length++; 500425b89263Smrg if (c == '\\') 500525b89263Smrg backslashes++; 500625b89263Smrg else 500725b89263Smrg backslashes = 0; 500825b89263Smrg } 500925b89263Smrg if (quote_around) 501025b89263Smrg length += backslashes + 1; 501125b89263Smrg 501225b89263Smrg quoted_string = XMALLOC (char, length + 1); 501325b89263Smrg 501425b89263Smrg p = quoted_string; 501525b89263Smrg backslashes = 0; 501625b89263Smrg if (quote_around) 501725b89263Smrg *p++ = '"'; 501825b89263Smrg for (s = string; *s != '\0'; s++) 501925b89263Smrg { 502025b89263Smrg char c = *s; 502125b89263Smrg if (c == '"') 502225b89263Smrg { 502325b89263Smrg unsigned int j; 502425b89263Smrg for (j = backslashes + 1; j > 0; j--) 502525b89263Smrg *p++ = '\\'; 502625b89263Smrg } 502725b89263Smrg *p++ = c; 502825b89263Smrg if (c == '\\') 502925b89263Smrg backslashes++; 503025b89263Smrg else 503125b89263Smrg backslashes = 0; 503225b89263Smrg } 503325b89263Smrg if (quote_around) 503425b89263Smrg { 503525b89263Smrg unsigned int j; 503625b89263Smrg for (j = backslashes; j > 0; j--) 503725b89263Smrg *p++ = '\\'; 503825b89263Smrg *p++ = '"'; 503925b89263Smrg } 504025b89263Smrg *p = '\0'; 504125b89263Smrg 504225b89263Smrg new_argv[i] = quoted_string; 504325b89263Smrg } 504425b89263Smrg else 504525b89263Smrg new_argv[i] = (char *) string; 504625b89263Smrg } 504725b89263Smrg new_argv[argc] = NULL; 504825b89263Smrg 504925b89263Smrg return new_argv; 505025b89263Smrg} 505125b89263SmrgEOF 505225b89263Smrg ;; 505325b89263Smrg esac 505425b89263Smrg 505525b89263Smrg cat <<"EOF" 505625b89263Smrgvoid lt_dump_script (FILE* f) 505725b89263Smrg{ 505825b89263SmrgEOF 505925b89263Smrg func_emit_wrapper yes | 506025b89263Smrg $SED -e 's/\([\\"]\)/\\\1/g' \ 506125b89263Smrg -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' 5062a253d6aeSmrg 506325b89263Smrg cat <<"EOF" 506425b89263Smrg} 5065ea133fd7SmrgEOF 5066ea133fd7Smrg} 5067ea133fd7Smrg# end: func_emit_cwrapperexe_src 5068a253d6aeSmrg 506925b89263Smrg# func_win32_import_lib_p ARG 507025b89263Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 507125b89263Smrgfunc_win32_import_lib_p () 507225b89263Smrg{ 507325b89263Smrg $opt_debug 507425b89263Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 507525b89263Smrg *import*) : ;; 507625b89263Smrg *) false ;; 507725b89263Smrg esac 507825b89263Smrg} 507925b89263Smrg 5080ea133fd7Smrg# func_mode_link arg... 5081ea133fd7Smrgfunc_mode_link () 5082ea133fd7Smrg{ 5083ea133fd7Smrg $opt_debug 5084ea133fd7Smrg case $host in 5085ea133fd7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5086ea133fd7Smrg # It is impossible to link a dll without this setting, and 5087ea133fd7Smrg # we shouldn't force the makefile maintainer to figure out 5088ea133fd7Smrg # which system we are compiling for in order to pass an extra 5089ea133fd7Smrg # flag for every libtool invocation. 5090ea133fd7Smrg # allow_undefined=no 5091a253d6aeSmrg 5092ea133fd7Smrg # FIXME: Unfortunately, there are problems with the above when trying 5093ea133fd7Smrg # to make a dll which has undefined symbols, in which case not 5094ea133fd7Smrg # even a static library is built. For now, we need to specify 5095ea133fd7Smrg # -no-undefined on the libtool link line when we can be certain 5096ea133fd7Smrg # that all symbols are satisfied, otherwise we get a static library. 5097ea133fd7Smrg allow_undefined=yes 5098ea133fd7Smrg ;; 5099ea133fd7Smrg *) 5100ea133fd7Smrg allow_undefined=yes 5101ea133fd7Smrg ;; 5102ea133fd7Smrg esac 5103ea133fd7Smrg libtool_args=$nonopt 5104ea133fd7Smrg base_compile="$nonopt $@" 5105ea133fd7Smrg compile_command=$nonopt 5106ea133fd7Smrg finalize_command=$nonopt 5107a253d6aeSmrg 5108ea133fd7Smrg compile_rpath= 5109ea133fd7Smrg finalize_rpath= 5110ea133fd7Smrg compile_shlibpath= 5111ea133fd7Smrg finalize_shlibpath= 5112ea133fd7Smrg convenience= 5113ea133fd7Smrg old_convenience= 5114ea133fd7Smrg deplibs= 5115ea133fd7Smrg old_deplibs= 5116ea133fd7Smrg compiler_flags= 5117ea133fd7Smrg linker_flags= 5118ea133fd7Smrg dllsearchpath= 5119ea133fd7Smrg lib_search_path=`pwd` 5120ea133fd7Smrg inst_prefix_dir= 5121ea133fd7Smrg new_inherited_linker_flags= 5122a253d6aeSmrg 5123ea133fd7Smrg avoid_version=no 512425b89263Smrg bindir= 5125ea133fd7Smrg dlfiles= 5126ea133fd7Smrg dlprefiles= 5127ea133fd7Smrg dlself=no 5128ea133fd7Smrg export_dynamic=no 5129ea133fd7Smrg export_symbols= 5130ea133fd7Smrg export_symbols_regex= 5131ea133fd7Smrg generated= 5132ea133fd7Smrg libobjs= 5133ea133fd7Smrg ltlibs= 5134ea133fd7Smrg module=no 5135ea133fd7Smrg no_install=no 5136ea133fd7Smrg objs= 5137ea133fd7Smrg non_pic_objects= 5138ea133fd7Smrg precious_files_regex= 5139ea133fd7Smrg prefer_static_libs=no 5140ea133fd7Smrg preload=no 5141ea133fd7Smrg prev= 5142ea133fd7Smrg prevarg= 5143ea133fd7Smrg release= 5144ea133fd7Smrg rpath= 5145ea133fd7Smrg xrpath= 5146ea133fd7Smrg perm_rpath= 5147ea133fd7Smrg temp_rpath= 5148ea133fd7Smrg thread_safe=no 5149ea133fd7Smrg vinfo= 5150ea133fd7Smrg vinfo_number=no 5151ea133fd7Smrg weak_libs= 5152ea133fd7Smrg single_module="${wl}-single_module" 5153ea133fd7Smrg func_infer_tag $base_compile 5154a253d6aeSmrg 5155ea133fd7Smrg # We need to know -static, to get the right output filenames. 5156ea133fd7Smrg for arg 5157ea133fd7Smrg do 5158ea133fd7Smrg case $arg in 5159ea133fd7Smrg -shared) 5160ea133fd7Smrg test "$build_libtool_libs" != yes && \ 5161ea133fd7Smrg func_fatal_configuration "can not build a shared library" 5162ea133fd7Smrg build_old_libs=no 5163ea133fd7Smrg break 5164ea133fd7Smrg ;; 5165ea133fd7Smrg -all-static | -static | -static-libtool-libs) 5166ea133fd7Smrg case $arg in 5167ea133fd7Smrg -all-static) 5168ea133fd7Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 5169ea133fd7Smrg func_warning "complete static linking is impossible in this configuration" 5170a253d6aeSmrg fi 5171ea133fd7Smrg if test -n "$link_static_flag"; then 5172ea133fd7Smrg dlopen_self=$dlopen_self_static 5173a253d6aeSmrg fi 5174ea133fd7Smrg prefer_static_libs=yes 5175a253d6aeSmrg ;; 5176ea133fd7Smrg -static) 5177ea133fd7Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5178ea133fd7Smrg dlopen_self=$dlopen_self_static 5179ea133fd7Smrg fi 5180ea133fd7Smrg prefer_static_libs=built 5181ea133fd7Smrg ;; 5182ea133fd7Smrg -static-libtool-libs) 5183ea133fd7Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5184ea133fd7Smrg dlopen_self=$dlopen_self_static 5185ea133fd7Smrg fi 5186ea133fd7Smrg prefer_static_libs=yes 5187a253d6aeSmrg ;; 5188a253d6aeSmrg esac 5189ea133fd7Smrg build_libtool_libs=no 5190ea133fd7Smrg build_old_libs=yes 5191ea133fd7Smrg break 5192ea133fd7Smrg ;; 5193ea133fd7Smrg esac 5194ea133fd7Smrg done 5195a253d6aeSmrg 5196ea133fd7Smrg # See if our shared archives depend on static archives. 5197ea133fd7Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5198a253d6aeSmrg 5199ea133fd7Smrg # Go through the arguments, transforming them on the way. 5200ea133fd7Smrg while test "$#" -gt 0; do 5201ea133fd7Smrg arg="$1" 5202ea133fd7Smrg shift 5203ea133fd7Smrg func_quote_for_eval "$arg" 5204ea133fd7Smrg qarg=$func_quote_for_eval_unquoted_result 5205ea133fd7Smrg func_append libtool_args " $func_quote_for_eval_result" 5206a253d6aeSmrg 5207ea133fd7Smrg # If the previous option needs an argument, assign it. 5208ea133fd7Smrg if test -n "$prev"; then 5209ea133fd7Smrg case $prev in 5210ea133fd7Smrg output) 5211ea133fd7Smrg func_append compile_command " @OUTPUT@" 5212ea133fd7Smrg func_append finalize_command " @OUTPUT@" 5213ea133fd7Smrg ;; 5214ea133fd7Smrg esac 5215a253d6aeSmrg 5216ea133fd7Smrg case $prev in 521725b89263Smrg bindir) 521825b89263Smrg bindir="$arg" 521925b89263Smrg prev= 522025b89263Smrg continue 522125b89263Smrg ;; 5222ea133fd7Smrg dlfiles|dlprefiles) 5223ea133fd7Smrg if test "$preload" = no; then 5224ea133fd7Smrg # Add the symbol object into the linking commands. 5225ea133fd7Smrg func_append compile_command " @SYMFILE@" 5226ea133fd7Smrg func_append finalize_command " @SYMFILE@" 5227ea133fd7Smrg preload=yes 5228ea133fd7Smrg fi 5229ea133fd7Smrg case $arg in 5230ea133fd7Smrg *.la | *.lo) ;; # We handle these cases below. 5231ea133fd7Smrg force) 5232ea133fd7Smrg if test "$dlself" = no; then 5233ea133fd7Smrg dlself=needless 5234ea133fd7Smrg export_dynamic=yes 5235ea133fd7Smrg fi 5236ea133fd7Smrg prev= 5237ea133fd7Smrg continue 5238ea133fd7Smrg ;; 5239ea133fd7Smrg self) 5240ea133fd7Smrg if test "$prev" = dlprefiles; then 5241ea133fd7Smrg dlself=yes 5242ea133fd7Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 5243ea133fd7Smrg dlself=yes 5244ea133fd7Smrg else 5245ea133fd7Smrg dlself=needless 5246ea133fd7Smrg export_dynamic=yes 5247ea133fd7Smrg fi 5248ea133fd7Smrg prev= 5249ea133fd7Smrg continue 5250a253d6aeSmrg ;; 5251a253d6aeSmrg *) 5252ea133fd7Smrg if test "$prev" = dlfiles; then 525306f32fbeSmrg func_append dlfiles " $arg" 5254ea133fd7Smrg else 525506f32fbeSmrg func_append dlprefiles " $arg" 5256ea133fd7Smrg fi 5257ea133fd7Smrg prev= 5258ea133fd7Smrg continue 5259a253d6aeSmrg ;; 5260a253d6aeSmrg esac 5261ea133fd7Smrg ;; 5262ea133fd7Smrg expsyms) 5263ea133fd7Smrg export_symbols="$arg" 5264ea133fd7Smrg test -f "$arg" \ 5265ea133fd7Smrg || func_fatal_error "symbol file \`$arg' does not exist" 5266ea133fd7Smrg prev= 5267ea133fd7Smrg continue 5268ea133fd7Smrg ;; 5269ea133fd7Smrg expsyms_regex) 5270ea133fd7Smrg export_symbols_regex="$arg" 5271ea133fd7Smrg prev= 5272ea133fd7Smrg continue 5273ea133fd7Smrg ;; 5274ea133fd7Smrg framework) 5275ea133fd7Smrg case $host in 5276ea133fd7Smrg *-*-darwin*) 5277ea133fd7Smrg case "$deplibs " in 5278ea133fd7Smrg *" $qarg.ltframework "*) ;; 527906f32fbeSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 5280ea133fd7Smrg ;; 5281ea133fd7Smrg esac 5282ea133fd7Smrg ;; 5283ea133fd7Smrg esac 5284ea133fd7Smrg prev= 5285ea133fd7Smrg continue 5286ea133fd7Smrg ;; 5287ea133fd7Smrg inst_prefix) 5288ea133fd7Smrg inst_prefix_dir="$arg" 5289ea133fd7Smrg prev= 5290ea133fd7Smrg continue 5291ea133fd7Smrg ;; 5292ea133fd7Smrg objectlist) 5293ea133fd7Smrg if test -f "$arg"; then 5294ea133fd7Smrg save_arg=$arg 5295ea133fd7Smrg moreargs= 5296ea133fd7Smrg for fil in `cat "$save_arg"` 5297ea133fd7Smrg do 529806f32fbeSmrg# func_append moreargs " $fil" 5299ea133fd7Smrg arg=$fil 5300ea133fd7Smrg # A libtool-controlled object. 5301a253d6aeSmrg 5302ea133fd7Smrg # Check to see that this really is a libtool object. 5303ea133fd7Smrg if func_lalib_unsafe_p "$arg"; then 5304ea133fd7Smrg pic_object= 5305ea133fd7Smrg non_pic_object= 5306a253d6aeSmrg 5307ea133fd7Smrg # Read the .lo file 5308ea133fd7Smrg func_source "$arg" 5309a253d6aeSmrg 5310ea133fd7Smrg if test -z "$pic_object" || 5311ea133fd7Smrg test -z "$non_pic_object" || 5312ea133fd7Smrg test "$pic_object" = none && 5313ea133fd7Smrg test "$non_pic_object" = none; then 5314ea133fd7Smrg func_fatal_error "cannot find name of object for \`$arg'" 5315ea133fd7Smrg fi 5316a253d6aeSmrg 5317ea133fd7Smrg # Extract subdirectory from the argument. 5318ea133fd7Smrg func_dirname "$arg" "/" "" 5319ea133fd7Smrg xdir="$func_dirname_result" 5320a253d6aeSmrg 5321ea133fd7Smrg if test "$pic_object" != none; then 5322ea133fd7Smrg # Prepend the subdirectory the object is found in. 5323ea133fd7Smrg pic_object="$xdir$pic_object" 5324a253d6aeSmrg 5325ea133fd7Smrg if test "$prev" = dlfiles; then 5326ea133fd7Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 532706f32fbeSmrg func_append dlfiles " $pic_object" 5328ea133fd7Smrg prev= 5329ea133fd7Smrg continue 5330ea133fd7Smrg else 5331ea133fd7Smrg # If libtool objects are unsupported, then we need to preload. 5332ea133fd7Smrg prev=dlprefiles 5333ea133fd7Smrg fi 5334ea133fd7Smrg fi 5335a253d6aeSmrg 5336ea133fd7Smrg # CHECK ME: I think I busted this. -Ossama 5337ea133fd7Smrg if test "$prev" = dlprefiles; then 5338ea133fd7Smrg # Preload the old-style object. 533906f32fbeSmrg func_append dlprefiles " $pic_object" 5340ea133fd7Smrg prev= 5341ea133fd7Smrg fi 5342a253d6aeSmrg 5343ea133fd7Smrg # A PIC object. 5344ea133fd7Smrg func_append libobjs " $pic_object" 5345ea133fd7Smrg arg="$pic_object" 5346ea133fd7Smrg fi 5347a253d6aeSmrg 5348ea133fd7Smrg # Non-PIC object. 5349ea133fd7Smrg if test "$non_pic_object" != none; then 5350ea133fd7Smrg # Prepend the subdirectory the object is found in. 5351ea133fd7Smrg non_pic_object="$xdir$non_pic_object" 5352a253d6aeSmrg 5353ea133fd7Smrg # A standard non-PIC object 5354ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5355ea133fd7Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5356ea133fd7Smrg arg="$non_pic_object" 5357ea133fd7Smrg fi 5358ea133fd7Smrg else 5359ea133fd7Smrg # If the PIC object exists, use it instead. 5360ea133fd7Smrg # $xdir was prepended to $pic_object above. 5361ea133fd7Smrg non_pic_object="$pic_object" 5362ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5363ea133fd7Smrg fi 5364ea133fd7Smrg else 5365ea133fd7Smrg # Only an error if not doing a dry-run. 5366ea133fd7Smrg if $opt_dry_run; then 5367ea133fd7Smrg # Extract subdirectory from the argument. 5368ea133fd7Smrg func_dirname "$arg" "/" "" 5369ea133fd7Smrg xdir="$func_dirname_result" 5370ea133fd7Smrg 5371ea133fd7Smrg func_lo2o "$arg" 5372ea133fd7Smrg pic_object=$xdir$objdir/$func_lo2o_result 5373ea133fd7Smrg non_pic_object=$xdir$func_lo2o_result 5374ea133fd7Smrg func_append libobjs " $pic_object" 5375ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5376ea133fd7Smrg else 5377ea133fd7Smrg func_fatal_error "\`$arg' is not a valid libtool object" 5378ea133fd7Smrg fi 5379ea133fd7Smrg fi 5380ea133fd7Smrg done 5381ea133fd7Smrg else 5382ea133fd7Smrg func_fatal_error "link input file \`$arg' does not exist" 5383ea133fd7Smrg fi 5384ea133fd7Smrg arg=$save_arg 5385ea133fd7Smrg prev= 5386ea133fd7Smrg continue 5387ea133fd7Smrg ;; 5388ea133fd7Smrg precious_regex) 5389ea133fd7Smrg precious_files_regex="$arg" 5390ea133fd7Smrg prev= 5391ea133fd7Smrg continue 5392ea133fd7Smrg ;; 5393ea133fd7Smrg release) 5394ea133fd7Smrg release="-$arg" 5395ea133fd7Smrg prev= 5396ea133fd7Smrg continue 5397ea133fd7Smrg ;; 5398ea133fd7Smrg rpath | xrpath) 5399ea133fd7Smrg # We need an absolute path. 5400ea133fd7Smrg case $arg in 5401ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5402ea133fd7Smrg *) 5403ea133fd7Smrg func_fatal_error "only absolute run-paths are allowed" 5404ea133fd7Smrg ;; 5405ea133fd7Smrg esac 5406ea133fd7Smrg if test "$prev" = rpath; then 5407ea133fd7Smrg case "$rpath " in 5408ea133fd7Smrg *" $arg "*) ;; 540906f32fbeSmrg *) func_append rpath " $arg" ;; 5410ea133fd7Smrg esac 5411ea133fd7Smrg else 5412ea133fd7Smrg case "$xrpath " in 5413ea133fd7Smrg *" $arg "*) ;; 541406f32fbeSmrg *) func_append xrpath " $arg" ;; 5415ea133fd7Smrg esac 5416ea133fd7Smrg fi 5417ea133fd7Smrg prev= 5418ea133fd7Smrg continue 5419ea133fd7Smrg ;; 5420ea133fd7Smrg shrext) 5421ea133fd7Smrg shrext_cmds="$arg" 5422ea133fd7Smrg prev= 5423ea133fd7Smrg continue 5424ea133fd7Smrg ;; 5425ea133fd7Smrg weak) 542606f32fbeSmrg func_append weak_libs " $arg" 5427ea133fd7Smrg prev= 5428ea133fd7Smrg continue 5429ea133fd7Smrg ;; 5430ea133fd7Smrg xcclinker) 543106f32fbeSmrg func_append linker_flags " $qarg" 543206f32fbeSmrg func_append compiler_flags " $qarg" 5433ea133fd7Smrg prev= 5434ea133fd7Smrg func_append compile_command " $qarg" 5435ea133fd7Smrg func_append finalize_command " $qarg" 5436ea133fd7Smrg continue 5437ea133fd7Smrg ;; 5438ea133fd7Smrg xcompiler) 543906f32fbeSmrg func_append compiler_flags " $qarg" 5440ea133fd7Smrg prev= 5441ea133fd7Smrg func_append compile_command " $qarg" 5442ea133fd7Smrg func_append finalize_command " $qarg" 5443ea133fd7Smrg continue 5444ea133fd7Smrg ;; 5445ea133fd7Smrg xlinker) 544606f32fbeSmrg func_append linker_flags " $qarg" 544706f32fbeSmrg func_append compiler_flags " $wl$qarg" 5448ea133fd7Smrg prev= 5449ea133fd7Smrg func_append compile_command " $wl$qarg" 5450ea133fd7Smrg func_append finalize_command " $wl$qarg" 5451ea133fd7Smrg continue 5452ea133fd7Smrg ;; 5453ea133fd7Smrg *) 5454ea133fd7Smrg eval "$prev=\"\$arg\"" 5455ea133fd7Smrg prev= 5456ea133fd7Smrg continue 5457ea133fd7Smrg ;; 5458a253d6aeSmrg esac 5459ea133fd7Smrg fi # test -n "$prev" 5460a253d6aeSmrg 5461ea133fd7Smrg prevarg="$arg" 5462a253d6aeSmrg 5463ea133fd7Smrg case $arg in 5464ea133fd7Smrg -all-static) 5465ea133fd7Smrg if test -n "$link_static_flag"; then 5466ea133fd7Smrg # See comment for -static flag below, for more details. 5467ea133fd7Smrg func_append compile_command " $link_static_flag" 5468ea133fd7Smrg func_append finalize_command " $link_static_flag" 5469ea133fd7Smrg fi 5470ea133fd7Smrg continue 5471ea133fd7Smrg ;; 5472a253d6aeSmrg 5473ea133fd7Smrg -allow-undefined) 5474ea133fd7Smrg # FIXME: remove this flag sometime in the future. 5475ea133fd7Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 5476ea133fd7Smrg ;; 5477a253d6aeSmrg 5478ea133fd7Smrg -avoid-version) 5479ea133fd7Smrg avoid_version=yes 5480ea133fd7Smrg continue 5481ea133fd7Smrg ;; 5482a253d6aeSmrg 548325b89263Smrg -bindir) 548425b89263Smrg prev=bindir 548525b89263Smrg continue 548625b89263Smrg ;; 548725b89263Smrg 5488ea133fd7Smrg -dlopen) 5489ea133fd7Smrg prev=dlfiles 5490ea133fd7Smrg continue 5491ea133fd7Smrg ;; 5492a253d6aeSmrg 5493ea133fd7Smrg -dlpreopen) 5494ea133fd7Smrg prev=dlprefiles 5495ea133fd7Smrg continue 5496ea133fd7Smrg ;; 5497a253d6aeSmrg 5498ea133fd7Smrg -export-dynamic) 5499ea133fd7Smrg export_dynamic=yes 5500ea133fd7Smrg continue 5501ea133fd7Smrg ;; 5502a253d6aeSmrg 5503ea133fd7Smrg -export-symbols | -export-symbols-regex) 5504ea133fd7Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 5505ea133fd7Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 5506ea133fd7Smrg fi 5507ea133fd7Smrg if test "X$arg" = "X-export-symbols"; then 5508ea133fd7Smrg prev=expsyms 5509ea133fd7Smrg else 5510ea133fd7Smrg prev=expsyms_regex 5511ea133fd7Smrg fi 5512ea133fd7Smrg continue 5513ea133fd7Smrg ;; 5514a253d6aeSmrg 5515ea133fd7Smrg -framework) 5516ea133fd7Smrg prev=framework 5517ea133fd7Smrg continue 5518ea133fd7Smrg ;; 5519a253d6aeSmrg 5520ea133fd7Smrg -inst-prefix-dir) 5521ea133fd7Smrg prev=inst_prefix 5522ea133fd7Smrg continue 5523ea133fd7Smrg ;; 5524a253d6aeSmrg 5525ea133fd7Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 5526ea133fd7Smrg # so, if we see these flags be careful not to treat them like -L 5527ea133fd7Smrg -L[A-Z][A-Z]*:*) 5528ea133fd7Smrg case $with_gcc/$host in 5529ea133fd7Smrg no/*-*-irix* | /*-*-irix*) 5530ea133fd7Smrg func_append compile_command " $arg" 5531ea133fd7Smrg func_append finalize_command " $arg" 5532ea133fd7Smrg ;; 5533ea133fd7Smrg esac 5534ea133fd7Smrg continue 5535ea133fd7Smrg ;; 5536a253d6aeSmrg 5537ea133fd7Smrg -L*) 553806f32fbeSmrg func_stripname "-L" '' "$arg" 553906f32fbeSmrg if test -z "$func_stripname_result"; then 5540ea133fd7Smrg if test "$#" -gt 0; then 5541ea133fd7Smrg func_fatal_error "require no space between \`-L' and \`$1'" 5542ea133fd7Smrg else 5543ea133fd7Smrg func_fatal_error "need path for \`-L' option" 5544ea133fd7Smrg fi 5545ea133fd7Smrg fi 554606f32fbeSmrg func_resolve_sysroot "$func_stripname_result" 554706f32fbeSmrg dir=$func_resolve_sysroot_result 5548ea133fd7Smrg # We need an absolute path. 5549ea133fd7Smrg case $dir in 5550ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5551ea133fd7Smrg *) 5552ea133fd7Smrg absdir=`cd "$dir" && pwd` 5553ea133fd7Smrg test -z "$absdir" && \ 5554ea133fd7Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 5555ea133fd7Smrg dir="$absdir" 5556ea133fd7Smrg ;; 5557ea133fd7Smrg esac 5558ea133fd7Smrg case "$deplibs " in 555906f32fbeSmrg *" -L$dir "* | *" $arg "*) 556006f32fbeSmrg # Will only happen for absolute or sysroot arguments 556106f32fbeSmrg ;; 5562ea133fd7Smrg *) 556306f32fbeSmrg # Preserve sysroot, but never include relative directories 556406f32fbeSmrg case $dir in 556506f32fbeSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 556606f32fbeSmrg *) func_append deplibs " -L$dir" ;; 556706f32fbeSmrg esac 556806f32fbeSmrg func_append lib_search_path " $dir" 5569ea133fd7Smrg ;; 5570ea133fd7Smrg esac 5571ea133fd7Smrg case $host in 5572ea133fd7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 557325b89263Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 5574ea133fd7Smrg case :$dllsearchpath: in 5575ea133fd7Smrg *":$dir:"*) ;; 5576ea133fd7Smrg ::) dllsearchpath=$dir;; 557706f32fbeSmrg *) func_append dllsearchpath ":$dir";; 5578ea133fd7Smrg esac 5579ea133fd7Smrg case :$dllsearchpath: in 5580ea133fd7Smrg *":$testbindir:"*) ;; 5581ea133fd7Smrg ::) dllsearchpath=$testbindir;; 558206f32fbeSmrg *) func_append dllsearchpath ":$testbindir";; 5583ea133fd7Smrg esac 5584ea133fd7Smrg ;; 5585ea133fd7Smrg esac 5586ea133fd7Smrg continue 5587ea133fd7Smrg ;; 5588a253d6aeSmrg 5589ea133fd7Smrg -l*) 5590ea133fd7Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 5591ea133fd7Smrg case $host in 559225b89263Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 5593ea133fd7Smrg # These systems don't actually have a C or math library (as such) 5594ea133fd7Smrg continue 5595ea133fd7Smrg ;; 5596ea133fd7Smrg *-*-os2*) 5597ea133fd7Smrg # These systems don't actually have a C library (as such) 5598ea133fd7Smrg test "X$arg" = "X-lc" && continue 5599ea133fd7Smrg ;; 5600ea133fd7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5601ea133fd7Smrg # Do not include libc due to us having libc/libc_r. 5602ea133fd7Smrg test "X$arg" = "X-lc" && continue 5603ea133fd7Smrg ;; 5604ea133fd7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 5605ea133fd7Smrg # Rhapsody C and math libraries are in the System framework 560606f32fbeSmrg func_append deplibs " System.ltframework" 5607ea133fd7Smrg continue 5608ea133fd7Smrg ;; 5609ea133fd7Smrg *-*-sco3.2v5* | *-*-sco5v6*) 5610ea133fd7Smrg # Causes problems with __ctype 5611ea133fd7Smrg test "X$arg" = "X-lc" && continue 5612ea133fd7Smrg ;; 5613ea133fd7Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 5614ea133fd7Smrg # Compiler inserts libc in the correct place for threads to work 5615ea133fd7Smrg test "X$arg" = "X-lc" && continue 5616ea133fd7Smrg ;; 5617ea133fd7Smrg esac 5618ea133fd7Smrg elif test "X$arg" = "X-lc_r"; then 5619ea133fd7Smrg case $host in 5620ea133fd7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5621ea133fd7Smrg # Do not include libc_r directly, use -pthread flag. 5622ea133fd7Smrg continue 5623ea133fd7Smrg ;; 5624ea133fd7Smrg esac 5625ea133fd7Smrg fi 562606f32fbeSmrg func_append deplibs " $arg" 5627ea133fd7Smrg continue 5628ea133fd7Smrg ;; 5629a253d6aeSmrg 5630ea133fd7Smrg -module) 5631ea133fd7Smrg module=yes 5632ea133fd7Smrg continue 5633ea133fd7Smrg ;; 5634a253d6aeSmrg 5635ea133fd7Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 5636ea133fd7Smrg # classes, name mangling, and exception handling. 5637ea133fd7Smrg # Darwin uses the -arch flag to determine output architecture. 563806f32fbeSmrg -model|-arch|-isysroot|--sysroot) 563906f32fbeSmrg func_append compiler_flags " $arg" 5640ea133fd7Smrg func_append compile_command " $arg" 5641ea133fd7Smrg func_append finalize_command " $arg" 5642ea133fd7Smrg prev=xcompiler 5643ea133fd7Smrg continue 5644ea133fd7Smrg ;; 5645a253d6aeSmrg 5646ea133fd7Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 564706f32fbeSmrg func_append compiler_flags " $arg" 5648ea133fd7Smrg func_append compile_command " $arg" 5649ea133fd7Smrg func_append finalize_command " $arg" 5650ea133fd7Smrg case "$new_inherited_linker_flags " in 5651ea133fd7Smrg *" $arg "*) ;; 565206f32fbeSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 5653ea133fd7Smrg esac 5654ea133fd7Smrg continue 5655ea133fd7Smrg ;; 5656a253d6aeSmrg 5657ea133fd7Smrg -multi_module) 5658ea133fd7Smrg single_module="${wl}-multi_module" 5659ea133fd7Smrg continue 5660ea133fd7Smrg ;; 5661a253d6aeSmrg 5662ea133fd7Smrg -no-fast-install) 5663ea133fd7Smrg fast_install=no 5664ea133fd7Smrg continue 5665ea133fd7Smrg ;; 5666a253d6aeSmrg 5667ea133fd7Smrg -no-install) 5668ea133fd7Smrg case $host in 5669ea133fd7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 5670ea133fd7Smrg # The PATH hackery in wrapper scripts is required on Windows 5671ea133fd7Smrg # and Darwin in order for the loader to find any dlls it needs. 5672ea133fd7Smrg func_warning "\`-no-install' is ignored for $host" 5673ea133fd7Smrg func_warning "assuming \`-no-fast-install' instead" 5674ea133fd7Smrg fast_install=no 5675ea133fd7Smrg ;; 5676ea133fd7Smrg *) no_install=yes ;; 5677ea133fd7Smrg esac 5678ea133fd7Smrg continue 5679ea133fd7Smrg ;; 5680a253d6aeSmrg 5681ea133fd7Smrg -no-undefined) 5682ea133fd7Smrg allow_undefined=no 5683ea133fd7Smrg continue 5684ea133fd7Smrg ;; 5685a253d6aeSmrg 5686ea133fd7Smrg -objectlist) 5687ea133fd7Smrg prev=objectlist 5688ea133fd7Smrg continue 5689ea133fd7Smrg ;; 5690a253d6aeSmrg 5691ea133fd7Smrg -o) prev=output ;; 5692a253d6aeSmrg 5693ea133fd7Smrg -precious-files-regex) 5694ea133fd7Smrg prev=precious_regex 5695ea133fd7Smrg continue 5696ea133fd7Smrg ;; 5697a253d6aeSmrg 5698ea133fd7Smrg -release) 5699ea133fd7Smrg prev=release 5700ea133fd7Smrg continue 5701ea133fd7Smrg ;; 5702a253d6aeSmrg 5703ea133fd7Smrg -rpath) 5704ea133fd7Smrg prev=rpath 5705ea133fd7Smrg continue 5706ea133fd7Smrg ;; 5707a253d6aeSmrg 5708ea133fd7Smrg -R) 5709ea133fd7Smrg prev=xrpath 5710ea133fd7Smrg continue 5711ea133fd7Smrg ;; 5712a253d6aeSmrg 5713ea133fd7Smrg -R*) 5714ea133fd7Smrg func_stripname '-R' '' "$arg" 5715ea133fd7Smrg dir=$func_stripname_result 5716ea133fd7Smrg # We need an absolute path. 5717ea133fd7Smrg case $dir in 5718ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 571906f32fbeSmrg =*) 572006f32fbeSmrg func_stripname '=' '' "$dir" 572106f32fbeSmrg dir=$lt_sysroot$func_stripname_result 572206f32fbeSmrg ;; 5723ea133fd7Smrg *) 5724ea133fd7Smrg func_fatal_error "only absolute run-paths are allowed" 5725ea133fd7Smrg ;; 5726ea133fd7Smrg esac 5727ea133fd7Smrg case "$xrpath " in 5728ea133fd7Smrg *" $dir "*) ;; 572906f32fbeSmrg *) func_append xrpath " $dir" ;; 5730ea133fd7Smrg esac 5731ea133fd7Smrg continue 5732ea133fd7Smrg ;; 5733a253d6aeSmrg 5734ea133fd7Smrg -shared) 5735ea133fd7Smrg # The effects of -shared are defined in a previous loop. 5736ea133fd7Smrg continue 5737ea133fd7Smrg ;; 5738a253d6aeSmrg 5739ea133fd7Smrg -shrext) 5740ea133fd7Smrg prev=shrext 5741ea133fd7Smrg continue 5742ea133fd7Smrg ;; 5743a253d6aeSmrg 5744ea133fd7Smrg -static | -static-libtool-libs) 5745ea133fd7Smrg # The effects of -static are defined in a previous loop. 5746ea133fd7Smrg # We used to do the same as -all-static on platforms that 5747ea133fd7Smrg # didn't have a PIC flag, but the assumption that the effects 5748ea133fd7Smrg # would be equivalent was wrong. It would break on at least 5749ea133fd7Smrg # Digital Unix and AIX. 5750ea133fd7Smrg continue 5751ea133fd7Smrg ;; 5752a253d6aeSmrg 5753ea133fd7Smrg -thread-safe) 5754ea133fd7Smrg thread_safe=yes 5755ea133fd7Smrg continue 5756ea133fd7Smrg ;; 5757a253d6aeSmrg 5758ea133fd7Smrg -version-info) 5759ea133fd7Smrg prev=vinfo 5760ea133fd7Smrg continue 5761ea133fd7Smrg ;; 5762a253d6aeSmrg 5763ea133fd7Smrg -version-number) 5764ea133fd7Smrg prev=vinfo 5765ea133fd7Smrg vinfo_number=yes 5766ea133fd7Smrg continue 5767ea133fd7Smrg ;; 5768a253d6aeSmrg 5769ea133fd7Smrg -weak) 5770ea133fd7Smrg prev=weak 5771ea133fd7Smrg continue 5772ea133fd7Smrg ;; 5773a253d6aeSmrg 5774ea133fd7Smrg -Wc,*) 5775ea133fd7Smrg func_stripname '-Wc,' '' "$arg" 5776ea133fd7Smrg args=$func_stripname_result 5777ea133fd7Smrg arg= 5778ea133fd7Smrg save_ifs="$IFS"; IFS=',' 5779ea133fd7Smrg for flag in $args; do 5780ea133fd7Smrg IFS="$save_ifs" 5781ea133fd7Smrg func_quote_for_eval "$flag" 578206f32fbeSmrg func_append arg " $func_quote_for_eval_result" 578306f32fbeSmrg func_append compiler_flags " $func_quote_for_eval_result" 5784ea133fd7Smrg done 5785ea133fd7Smrg IFS="$save_ifs" 5786ea133fd7Smrg func_stripname ' ' '' "$arg" 5787ea133fd7Smrg arg=$func_stripname_result 5788ea133fd7Smrg ;; 5789a253d6aeSmrg 5790ea133fd7Smrg -Wl,*) 5791ea133fd7Smrg func_stripname '-Wl,' '' "$arg" 5792ea133fd7Smrg args=$func_stripname_result 5793ea133fd7Smrg arg= 5794ea133fd7Smrg save_ifs="$IFS"; IFS=',' 5795ea133fd7Smrg for flag in $args; do 5796ea133fd7Smrg IFS="$save_ifs" 5797ea133fd7Smrg func_quote_for_eval "$flag" 579806f32fbeSmrg func_append arg " $wl$func_quote_for_eval_result" 579906f32fbeSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 580006f32fbeSmrg func_append linker_flags " $func_quote_for_eval_result" 5801ea133fd7Smrg done 5802ea133fd7Smrg IFS="$save_ifs" 5803ea133fd7Smrg func_stripname ' ' '' "$arg" 5804ea133fd7Smrg arg=$func_stripname_result 5805ea133fd7Smrg ;; 5806a253d6aeSmrg 5807ea133fd7Smrg -Xcompiler) 5808ea133fd7Smrg prev=xcompiler 5809ea133fd7Smrg continue 5810ea133fd7Smrg ;; 5811a253d6aeSmrg 5812ea133fd7Smrg -Xlinker) 5813ea133fd7Smrg prev=xlinker 5814ea133fd7Smrg continue 5815ea133fd7Smrg ;; 5816a253d6aeSmrg 5817ea133fd7Smrg -XCClinker) 5818ea133fd7Smrg prev=xcclinker 5819ea133fd7Smrg continue 5820ea133fd7Smrg ;; 5821a253d6aeSmrg 5822ea133fd7Smrg # -msg_* for osf cc 5823ea133fd7Smrg -msg_*) 5824ea133fd7Smrg func_quote_for_eval "$arg" 5825ea133fd7Smrg arg="$func_quote_for_eval_result" 5826ea133fd7Smrg ;; 5827a253d6aeSmrg 582825b89263Smrg # Flags to be passed through unchanged, with rationale: 582925b89263Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 583025b89263Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 583125b89263Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 583225b89263Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 583325b89263Smrg # -q* compiler args for the IBM compiler 583425b89263Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 583525b89263Smrg # -F/path path to uninstalled frameworks, gcc on darwin 583625b89263Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 583725b89263Smrg # @file GCC response files 583825b89263Smrg # -tp=* Portland pgcc target processor selection 583906f32fbeSmrg # --sysroot=* for sysroot support 584006f32fbeSmrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 5841ea133fd7Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 584206f32fbeSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 584306f32fbeSmrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 5844ea133fd7Smrg func_quote_for_eval "$arg" 5845ea133fd7Smrg arg="$func_quote_for_eval_result" 5846ea133fd7Smrg func_append compile_command " $arg" 5847ea133fd7Smrg func_append finalize_command " $arg" 584806f32fbeSmrg func_append compiler_flags " $arg" 5849ea133fd7Smrg continue 5850ea133fd7Smrg ;; 5851a253d6aeSmrg 5852ea133fd7Smrg # Some other compiler flag. 5853ea133fd7Smrg -* | +*) 5854ea133fd7Smrg func_quote_for_eval "$arg" 5855ea133fd7Smrg arg="$func_quote_for_eval_result" 5856ea133fd7Smrg ;; 5857a253d6aeSmrg 5858ea133fd7Smrg *.$objext) 5859ea133fd7Smrg # A standard object. 586006f32fbeSmrg func_append objs " $arg" 5861ea133fd7Smrg ;; 5862ea133fd7Smrg 5863ea133fd7Smrg *.lo) 5864ea133fd7Smrg # A libtool-controlled object. 5865ea133fd7Smrg 5866ea133fd7Smrg # Check to see that this really is a libtool object. 5867ea133fd7Smrg if func_lalib_unsafe_p "$arg"; then 5868ea133fd7Smrg pic_object= 5869ea133fd7Smrg non_pic_object= 5870ea133fd7Smrg 5871ea133fd7Smrg # Read the .lo file 5872ea133fd7Smrg func_source "$arg" 5873ea133fd7Smrg 5874ea133fd7Smrg if test -z "$pic_object" || 5875ea133fd7Smrg test -z "$non_pic_object" || 5876ea133fd7Smrg test "$pic_object" = none && 5877ea133fd7Smrg test "$non_pic_object" = none; then 5878ea133fd7Smrg func_fatal_error "cannot find name of object for \`$arg'" 5879ea133fd7Smrg fi 5880ea133fd7Smrg 5881ea133fd7Smrg # Extract subdirectory from the argument. 5882ea133fd7Smrg func_dirname "$arg" "/" "" 5883ea133fd7Smrg xdir="$func_dirname_result" 5884ea133fd7Smrg 5885ea133fd7Smrg if test "$pic_object" != none; then 5886ea133fd7Smrg # Prepend the subdirectory the object is found in. 5887ea133fd7Smrg pic_object="$xdir$pic_object" 5888ea133fd7Smrg 5889ea133fd7Smrg if test "$prev" = dlfiles; then 5890ea133fd7Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 589106f32fbeSmrg func_append dlfiles " $pic_object" 5892ea133fd7Smrg prev= 5893ea133fd7Smrg continue 5894ea133fd7Smrg else 5895ea133fd7Smrg # If libtool objects are unsupported, then we need to preload. 5896ea133fd7Smrg prev=dlprefiles 5897ea133fd7Smrg fi 5898ea133fd7Smrg fi 5899ea133fd7Smrg 5900ea133fd7Smrg # CHECK ME: I think I busted this. -Ossama 5901ea133fd7Smrg if test "$prev" = dlprefiles; then 5902ea133fd7Smrg # Preload the old-style object. 590306f32fbeSmrg func_append dlprefiles " $pic_object" 5904ea133fd7Smrg prev= 5905ea133fd7Smrg fi 5906ea133fd7Smrg 5907ea133fd7Smrg # A PIC object. 5908ea133fd7Smrg func_append libobjs " $pic_object" 5909ea133fd7Smrg arg="$pic_object" 5910ea133fd7Smrg fi 5911ea133fd7Smrg 5912ea133fd7Smrg # Non-PIC object. 5913ea133fd7Smrg if test "$non_pic_object" != none; then 5914ea133fd7Smrg # Prepend the subdirectory the object is found in. 5915ea133fd7Smrg non_pic_object="$xdir$non_pic_object" 5916ea133fd7Smrg 5917ea133fd7Smrg # A standard non-PIC object 5918ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5919ea133fd7Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5920ea133fd7Smrg arg="$non_pic_object" 5921ea133fd7Smrg fi 5922ea133fd7Smrg else 5923ea133fd7Smrg # If the PIC object exists, use it instead. 5924ea133fd7Smrg # $xdir was prepended to $pic_object above. 5925ea133fd7Smrg non_pic_object="$pic_object" 5926ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5927ea133fd7Smrg fi 5928ea133fd7Smrg else 5929ea133fd7Smrg # Only an error if not doing a dry-run. 5930ea133fd7Smrg if $opt_dry_run; then 5931ea133fd7Smrg # Extract subdirectory from the argument. 5932ea133fd7Smrg func_dirname "$arg" "/" "" 5933ea133fd7Smrg xdir="$func_dirname_result" 5934ea133fd7Smrg 5935ea133fd7Smrg func_lo2o "$arg" 5936ea133fd7Smrg pic_object=$xdir$objdir/$func_lo2o_result 5937ea133fd7Smrg non_pic_object=$xdir$func_lo2o_result 5938ea133fd7Smrg func_append libobjs " $pic_object" 5939ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5940ea133fd7Smrg else 5941ea133fd7Smrg func_fatal_error "\`$arg' is not a valid libtool object" 5942ea133fd7Smrg fi 5943ea133fd7Smrg fi 5944ea133fd7Smrg ;; 5945ea133fd7Smrg 5946ea133fd7Smrg *.$libext) 5947ea133fd7Smrg # An archive. 594806f32fbeSmrg func_append deplibs " $arg" 594906f32fbeSmrg func_append old_deplibs " $arg" 5950ea133fd7Smrg continue 5951ea133fd7Smrg ;; 5952ea133fd7Smrg 5953ea133fd7Smrg *.la) 5954ea133fd7Smrg # A libtool-controlled library. 5955ea133fd7Smrg 595606f32fbeSmrg func_resolve_sysroot "$arg" 5957ea133fd7Smrg if test "$prev" = dlfiles; then 5958ea133fd7Smrg # This library was specified with -dlopen. 595906f32fbeSmrg func_append dlfiles " $func_resolve_sysroot_result" 5960ea133fd7Smrg prev= 5961ea133fd7Smrg elif test "$prev" = dlprefiles; then 5962ea133fd7Smrg # The library was specified with -dlpreopen. 596306f32fbeSmrg func_append dlprefiles " $func_resolve_sysroot_result" 5964ea133fd7Smrg prev= 5965ea133fd7Smrg else 596606f32fbeSmrg func_append deplibs " $func_resolve_sysroot_result" 5967ea133fd7Smrg fi 5968ea133fd7Smrg continue 5969ea133fd7Smrg ;; 5970ea133fd7Smrg 5971ea133fd7Smrg # Some other compiler argument. 5972ea133fd7Smrg *) 5973ea133fd7Smrg # Unknown arguments in both finalize_command and compile_command need 5974ea133fd7Smrg # to be aesthetically quoted because they are evaled later. 5975ea133fd7Smrg func_quote_for_eval "$arg" 5976ea133fd7Smrg arg="$func_quote_for_eval_result" 5977ea133fd7Smrg ;; 5978ea133fd7Smrg esac # arg 5979ea133fd7Smrg 5980ea133fd7Smrg # Now actually substitute the argument into the commands. 5981ea133fd7Smrg if test -n "$arg"; then 5982ea133fd7Smrg func_append compile_command " $arg" 5983ea133fd7Smrg func_append finalize_command " $arg" 5984ea133fd7Smrg fi 5985ea133fd7Smrg done # argument parsing loop 5986ea133fd7Smrg 5987ea133fd7Smrg test -n "$prev" && \ 5988ea133fd7Smrg func_fatal_help "the \`$prevarg' option requires an argument" 5989ea133fd7Smrg 5990ea133fd7Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 5991ea133fd7Smrg eval arg=\"$export_dynamic_flag_spec\" 5992ea133fd7Smrg func_append compile_command " $arg" 5993ea133fd7Smrg func_append finalize_command " $arg" 5994ea133fd7Smrg fi 5995ea133fd7Smrg 5996ea133fd7Smrg oldlibs= 5997ea133fd7Smrg # calculate the name of the file, without its directory 5998ea133fd7Smrg func_basename "$output" 5999ea133fd7Smrg outputname="$func_basename_result" 6000ea133fd7Smrg libobjs_save="$libobjs" 6001ea133fd7Smrg 6002ea133fd7Smrg if test -n "$shlibpath_var"; then 6003ea133fd7Smrg # get the directories listed in $shlibpath_var 600425b89263Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 6005a253d6aeSmrg else 6006ea133fd7Smrg shlib_search_path= 6007a253d6aeSmrg fi 6008ea133fd7Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 6009ea133fd7Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 6010a253d6aeSmrg 6011ea133fd7Smrg func_dirname "$output" "/" "" 6012ea133fd7Smrg output_objdir="$func_dirname_result$objdir" 601306f32fbeSmrg func_to_tool_file "$output_objdir/" 601406f32fbeSmrg tool_output_objdir=$func_to_tool_file_result 6015ea133fd7Smrg # Create the object directory. 6016ea133fd7Smrg func_mkdir_p "$output_objdir" 6017a253d6aeSmrg 6018ea133fd7Smrg # Determine the type of output 6019ea133fd7Smrg case $output in 6020ea133fd7Smrg "") 6021ea133fd7Smrg func_fatal_help "you must specify an output file" 6022ea133fd7Smrg ;; 6023ea133fd7Smrg *.$libext) linkmode=oldlib ;; 6024ea133fd7Smrg *.lo | *.$objext) linkmode=obj ;; 6025ea133fd7Smrg *.la) linkmode=lib ;; 6026ea133fd7Smrg *) linkmode=prog ;; # Anything else should be a program. 6027ea133fd7Smrg esac 6028ea133fd7Smrg 6029ea133fd7Smrg specialdeplibs= 6030ea133fd7Smrg 6031ea133fd7Smrg libs= 6032ea133fd7Smrg # Find all interdependent deplibs by searching for libraries 6033ea133fd7Smrg # that are linked more than once (e.g. -la -lb -la) 6034ea133fd7Smrg for deplib in $deplibs; do 603506f32fbeSmrg if $opt_preserve_dup_deps ; then 6036ea133fd7Smrg case "$libs " in 603706f32fbeSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6038ea133fd7Smrg esac 6039ea133fd7Smrg fi 604006f32fbeSmrg func_append libs " $deplib" 6041ea133fd7Smrg done 6042ea133fd7Smrg 6043ea133fd7Smrg if test "$linkmode" = lib; then 6044ea133fd7Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 6045ea133fd7Smrg 6046ea133fd7Smrg # Compute libraries that are listed more than once in $predeps 6047ea133fd7Smrg # $postdeps and mark them as special (i.e., whose duplicates are 6048ea133fd7Smrg # not to be eliminated). 6049ea133fd7Smrg pre_post_deps= 6050ea133fd7Smrg if $opt_duplicate_compiler_generated_deps; then 6051ea133fd7Smrg for pre_post_dep in $predeps $postdeps; do 6052ea133fd7Smrg case "$pre_post_deps " in 605306f32fbeSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 6054ea133fd7Smrg esac 605506f32fbeSmrg func_append pre_post_deps " $pre_post_dep" 6056ea133fd7Smrg done 6057ea133fd7Smrg fi 6058ea133fd7Smrg pre_post_deps= 6059ea133fd7Smrg fi 6060ea133fd7Smrg 6061ea133fd7Smrg deplibs= 6062ea133fd7Smrg newdependency_libs= 6063ea133fd7Smrg newlib_search_path= 6064ea133fd7Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 6065ea133fd7Smrg notinst_deplibs= # not-installed libtool libraries 6066ea133fd7Smrg notinst_path= # paths that contain not-installed libtool libraries 6067ea133fd7Smrg 6068ea133fd7Smrg case $linkmode in 6069ea133fd7Smrg lib) 6070ea133fd7Smrg passes="conv dlpreopen link" 6071ea133fd7Smrg for file in $dlfiles $dlprefiles; do 6072ea133fd7Smrg case $file in 6073ea133fd7Smrg *.la) ;; 6074ea133fd7Smrg *) 6075ea133fd7Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 6076ea133fd7Smrg ;; 6077ea133fd7Smrg esac 6078ea133fd7Smrg done 6079ea133fd7Smrg ;; 6080ea133fd7Smrg prog) 6081ea133fd7Smrg compile_deplibs= 6082ea133fd7Smrg finalize_deplibs= 6083ea133fd7Smrg alldeplibs=no 6084ea133fd7Smrg newdlfiles= 6085ea133fd7Smrg newdlprefiles= 6086ea133fd7Smrg passes="conv scan dlopen dlpreopen link" 6087ea133fd7Smrg ;; 6088ea133fd7Smrg *) passes="conv" 6089ea133fd7Smrg ;; 6090ea133fd7Smrg esac 6091ea133fd7Smrg 6092ea133fd7Smrg for pass in $passes; do 6093ea133fd7Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 6094ea133fd7Smrg # so that -L comes before libs that need it for instance... 6095ea133fd7Smrg if test "$linkmode,$pass" = "lib,link"; then 6096ea133fd7Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 6097ea133fd7Smrg ## order, and fix it there properly 6098ea133fd7Smrg tmp_deplibs= 6099ea133fd7Smrg for deplib in $deplibs; do 6100ea133fd7Smrg tmp_deplibs="$deplib $tmp_deplibs" 6101ea133fd7Smrg done 6102ea133fd7Smrg deplibs="$tmp_deplibs" 6103ea133fd7Smrg fi 6104ea133fd7Smrg 6105ea133fd7Smrg if test "$linkmode,$pass" = "lib,link" || 6106ea133fd7Smrg test "$linkmode,$pass" = "prog,scan"; then 6107ea133fd7Smrg libs="$deplibs" 6108ea133fd7Smrg deplibs= 6109ea133fd7Smrg fi 6110ea133fd7Smrg if test "$linkmode" = prog; then 6111ea133fd7Smrg case $pass in 6112ea133fd7Smrg dlopen) libs="$dlfiles" ;; 6113ea133fd7Smrg dlpreopen) libs="$dlprefiles" ;; 6114ea133fd7Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 6115ea133fd7Smrg esac 6116ea133fd7Smrg fi 6117ea133fd7Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 6118ea133fd7Smrg # Collect and forward deplibs of preopened libtool libs 6119ea133fd7Smrg for lib in $dlprefiles; do 6120ea133fd7Smrg # Ignore non-libtool-libs 6121ea133fd7Smrg dependency_libs= 612206f32fbeSmrg func_resolve_sysroot "$lib" 6123ea133fd7Smrg case $lib in 612406f32fbeSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 6125ea133fd7Smrg esac 6126ea133fd7Smrg 6127ea133fd7Smrg # Collect preopened libtool deplibs, except any this library 6128ea133fd7Smrg # has declared as weak libs 6129ea133fd7Smrg for deplib in $dependency_libs; do 613025b89263Smrg func_basename "$deplib" 613125b89263Smrg deplib_base=$func_basename_result 6132ea133fd7Smrg case " $weak_libs " in 6133ea133fd7Smrg *" $deplib_base "*) ;; 613406f32fbeSmrg *) func_append deplibs " $deplib" ;; 6135ea133fd7Smrg esac 6136ea133fd7Smrg done 6137ea133fd7Smrg done 6138ea133fd7Smrg libs="$dlprefiles" 6139ea133fd7Smrg fi 6140ea133fd7Smrg if test "$pass" = dlopen; then 6141ea133fd7Smrg # Collect dlpreopened libraries 6142ea133fd7Smrg save_deplibs="$deplibs" 6143ea133fd7Smrg deplibs= 6144ea133fd7Smrg fi 6145ea133fd7Smrg 6146ea133fd7Smrg for deplib in $libs; do 6147ea133fd7Smrg lib= 6148ea133fd7Smrg found=no 6149ea133fd7Smrg case $deplib in 6150ea133fd7Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 6151ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 6152ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6153ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6154ea133fd7Smrg else 615506f32fbeSmrg func_append compiler_flags " $deplib" 6156ea133fd7Smrg if test "$linkmode" = lib ; then 6157ea133fd7Smrg case "$new_inherited_linker_flags " in 6158ea133fd7Smrg *" $deplib "*) ;; 615906f32fbeSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6160ea133fd7Smrg esac 6161ea133fd7Smrg fi 6162ea133fd7Smrg fi 6163ea133fd7Smrg continue 6164ea133fd7Smrg ;; 6165ea133fd7Smrg -l*) 6166ea133fd7Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 6167ea133fd7Smrg func_warning "\`-l' is ignored for archives/objects" 6168ea133fd7Smrg continue 6169ea133fd7Smrg fi 6170ea133fd7Smrg func_stripname '-l' '' "$deplib" 6171ea133fd7Smrg name=$func_stripname_result 6172ea133fd7Smrg if test "$linkmode" = lib; then 6173ea133fd7Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 6174ea133fd7Smrg else 6175ea133fd7Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 6176ea133fd7Smrg fi 6177ea133fd7Smrg for searchdir in $searchdirs; do 6178ea133fd7Smrg for search_ext in .la $std_shrext .so .a; do 6179ea133fd7Smrg # Search the libtool library 6180ea133fd7Smrg lib="$searchdir/lib${name}${search_ext}" 6181ea133fd7Smrg if test -f "$lib"; then 6182ea133fd7Smrg if test "$search_ext" = ".la"; then 6183ea133fd7Smrg found=yes 6184ea133fd7Smrg else 6185ea133fd7Smrg found=no 6186ea133fd7Smrg fi 6187ea133fd7Smrg break 2 6188ea133fd7Smrg fi 6189ea133fd7Smrg done 6190ea133fd7Smrg done 6191ea133fd7Smrg if test "$found" != yes; then 6192ea133fd7Smrg # deplib doesn't seem to be a libtool library 6193ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 6194ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6195ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6196ea133fd7Smrg else 6197ea133fd7Smrg deplibs="$deplib $deplibs" 6198ea133fd7Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6199ea133fd7Smrg fi 6200ea133fd7Smrg continue 6201ea133fd7Smrg else # deplib is a libtool library 6202ea133fd7Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 6203ea133fd7Smrg # We need to do some special things here, and not later. 6204ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6205ea133fd7Smrg case " $predeps $postdeps " in 6206ea133fd7Smrg *" $deplib "*) 6207ea133fd7Smrg if func_lalib_p "$lib"; then 6208ea133fd7Smrg library_names= 6209ea133fd7Smrg old_library= 6210ea133fd7Smrg func_source "$lib" 6211ea133fd7Smrg for l in $old_library $library_names; do 6212ea133fd7Smrg ll="$l" 6213ea133fd7Smrg done 6214ea133fd7Smrg if test "X$ll" = "X$old_library" ; then # only static version available 6215ea133fd7Smrg found=no 6216ea133fd7Smrg func_dirname "$lib" "" "." 6217ea133fd7Smrg ladir="$func_dirname_result" 6218ea133fd7Smrg lib=$ladir/$old_library 6219ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 6220ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6221ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6222ea133fd7Smrg else 6223ea133fd7Smrg deplibs="$deplib $deplibs" 6224ea133fd7Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6225ea133fd7Smrg fi 6226ea133fd7Smrg continue 6227ea133fd7Smrg fi 6228ea133fd7Smrg fi 6229ea133fd7Smrg ;; 6230ea133fd7Smrg *) ;; 6231ea133fd7Smrg esac 6232ea133fd7Smrg fi 6233ea133fd7Smrg fi 6234ea133fd7Smrg ;; # -l 6235ea133fd7Smrg *.ltframework) 6236ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 6237ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6238ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6239ea133fd7Smrg else 6240ea133fd7Smrg deplibs="$deplib $deplibs" 6241ea133fd7Smrg if test "$linkmode" = lib ; then 6242ea133fd7Smrg case "$new_inherited_linker_flags " in 6243ea133fd7Smrg *" $deplib "*) ;; 624406f32fbeSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6245ea133fd7Smrg esac 6246ea133fd7Smrg fi 6247ea133fd7Smrg fi 6248ea133fd7Smrg continue 6249ea133fd7Smrg ;; 6250ea133fd7Smrg -L*) 6251ea133fd7Smrg case $linkmode in 6252ea133fd7Smrg lib) 6253ea133fd7Smrg deplibs="$deplib $deplibs" 6254ea133fd7Smrg test "$pass" = conv && continue 6255ea133fd7Smrg newdependency_libs="$deplib $newdependency_libs" 6256ea133fd7Smrg func_stripname '-L' '' "$deplib" 625706f32fbeSmrg func_resolve_sysroot "$func_stripname_result" 625806f32fbeSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 6259ea133fd7Smrg ;; 6260ea133fd7Smrg prog) 6261ea133fd7Smrg if test "$pass" = conv; then 6262ea133fd7Smrg deplibs="$deplib $deplibs" 6263ea133fd7Smrg continue 6264ea133fd7Smrg fi 6265ea133fd7Smrg if test "$pass" = scan; then 6266ea133fd7Smrg deplibs="$deplib $deplibs" 6267ea133fd7Smrg else 6268ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6269ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6270ea133fd7Smrg fi 6271ea133fd7Smrg func_stripname '-L' '' "$deplib" 627206f32fbeSmrg func_resolve_sysroot "$func_stripname_result" 627306f32fbeSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 6274ea133fd7Smrg ;; 6275ea133fd7Smrg *) 6276ea133fd7Smrg func_warning "\`-L' is ignored for archives/objects" 6277ea133fd7Smrg ;; 6278ea133fd7Smrg esac # linkmode 6279ea133fd7Smrg continue 6280ea133fd7Smrg ;; # -L 6281ea133fd7Smrg -R*) 6282ea133fd7Smrg if test "$pass" = link; then 6283ea133fd7Smrg func_stripname '-R' '' "$deplib" 628406f32fbeSmrg func_resolve_sysroot "$func_stripname_result" 628506f32fbeSmrg dir=$func_resolve_sysroot_result 6286ea133fd7Smrg # Make sure the xrpath contains only unique directories. 6287ea133fd7Smrg case "$xrpath " in 6288ea133fd7Smrg *" $dir "*) ;; 628906f32fbeSmrg *) func_append xrpath " $dir" ;; 6290ea133fd7Smrg esac 6291ea133fd7Smrg fi 6292ea133fd7Smrg deplibs="$deplib $deplibs" 6293ea133fd7Smrg continue 6294ea133fd7Smrg ;; 629506f32fbeSmrg *.la) 629606f32fbeSmrg func_resolve_sysroot "$deplib" 629706f32fbeSmrg lib=$func_resolve_sysroot_result 629806f32fbeSmrg ;; 6299ea133fd7Smrg *.$libext) 6300ea133fd7Smrg if test "$pass" = conv; then 6301ea133fd7Smrg deplibs="$deplib $deplibs" 6302ea133fd7Smrg continue 6303ea133fd7Smrg fi 6304ea133fd7Smrg case $linkmode in 6305ea133fd7Smrg lib) 6306ea133fd7Smrg # Linking convenience modules into shared libraries is allowed, 6307ea133fd7Smrg # but linking other static libraries is non-portable. 6308ea133fd7Smrg case " $dlpreconveniencelibs " in 6309ea133fd7Smrg *" $deplib "*) ;; 6310ea133fd7Smrg *) 6311ea133fd7Smrg valid_a_lib=no 6312ea133fd7Smrg case $deplibs_check_method in 6313ea133fd7Smrg match_pattern*) 6314ea133fd7Smrg set dummy $deplibs_check_method; shift 6315ea133fd7Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 631625b89263Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 6317ea133fd7Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 6318ea133fd7Smrg valid_a_lib=yes 6319ea133fd7Smrg fi 6320ea133fd7Smrg ;; 6321ea133fd7Smrg pass_all) 6322ea133fd7Smrg valid_a_lib=yes 6323ea133fd7Smrg ;; 6324ea133fd7Smrg esac 6325ea133fd7Smrg if test "$valid_a_lib" != yes; then 632625b89263Smrg echo 6327ea133fd7Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 632825b89263Smrg echo "*** I have the capability to make that library automatically link in when" 632925b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 633025b89263Smrg echo "*** shared version of the library, which you do not appear to have" 633125b89263Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 633225b89263Smrg echo "*** that it is just a static archive that I should not use here." 6333ea133fd7Smrg else 633425b89263Smrg echo 6335ea133fd7Smrg $ECHO "*** Warning: Linking the shared library $output against the" 6336ea133fd7Smrg $ECHO "*** static library $deplib is not portable!" 6337ea133fd7Smrg deplibs="$deplib $deplibs" 6338ea133fd7Smrg fi 6339ea133fd7Smrg ;; 6340ea133fd7Smrg esac 6341ea133fd7Smrg continue 6342ea133fd7Smrg ;; 6343ea133fd7Smrg prog) 6344ea133fd7Smrg if test "$pass" != link; then 6345ea133fd7Smrg deplibs="$deplib $deplibs" 6346ea133fd7Smrg else 6347ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6348ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6349ea133fd7Smrg fi 6350ea133fd7Smrg continue 6351ea133fd7Smrg ;; 6352ea133fd7Smrg esac # linkmode 6353ea133fd7Smrg ;; # *.$libext 6354ea133fd7Smrg *.lo | *.$objext) 6355ea133fd7Smrg if test "$pass" = conv; then 6356ea133fd7Smrg deplibs="$deplib $deplibs" 6357ea133fd7Smrg elif test "$linkmode" = prog; then 6358ea133fd7Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 6359ea133fd7Smrg # If there is no dlopen support or we're linking statically, 6360ea133fd7Smrg # we need to preload. 636106f32fbeSmrg func_append newdlprefiles " $deplib" 6362ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6363ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6364ea133fd7Smrg else 636506f32fbeSmrg func_append newdlfiles " $deplib" 6366ea133fd7Smrg fi 6367ea133fd7Smrg fi 6368ea133fd7Smrg continue 6369ea133fd7Smrg ;; 6370ea133fd7Smrg %DEPLIBS%) 6371ea133fd7Smrg alldeplibs=yes 6372ea133fd7Smrg continue 6373ea133fd7Smrg ;; 6374ea133fd7Smrg esac # case $deplib 6375ea133fd7Smrg 6376ea133fd7Smrg if test "$found" = yes || test -f "$lib"; then : 6377ea133fd7Smrg else 6378ea133fd7Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 6379ea133fd7Smrg fi 6380ea133fd7Smrg 6381ea133fd7Smrg # Check to see that this really is a libtool archive. 6382ea133fd7Smrg func_lalib_unsafe_p "$lib" \ 6383ea133fd7Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 6384ea133fd7Smrg 6385ea133fd7Smrg func_dirname "$lib" "" "." 6386ea133fd7Smrg ladir="$func_dirname_result" 6387ea133fd7Smrg 6388ea133fd7Smrg dlname= 6389ea133fd7Smrg dlopen= 6390ea133fd7Smrg dlpreopen= 6391ea133fd7Smrg libdir= 6392ea133fd7Smrg library_names= 6393ea133fd7Smrg old_library= 6394ea133fd7Smrg inherited_linker_flags= 6395ea133fd7Smrg # If the library was installed with an old release of libtool, 6396ea133fd7Smrg # it will not redefine variables installed, or shouldnotlink 6397ea133fd7Smrg installed=yes 6398ea133fd7Smrg shouldnotlink=no 6399ea133fd7Smrg avoidtemprpath= 6400ea133fd7Smrg 6401ea133fd7Smrg 6402ea133fd7Smrg # Read the .la file 6403ea133fd7Smrg func_source "$lib" 6404ea133fd7Smrg 6405ea133fd7Smrg # Convert "-framework foo" to "foo.ltframework" 6406ea133fd7Smrg if test -n "$inherited_linker_flags"; then 640725b89263Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 6408ea133fd7Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 6409ea133fd7Smrg case " $new_inherited_linker_flags " in 6410ea133fd7Smrg *" $tmp_inherited_linker_flag "*) ;; 641106f32fbeSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 6412ea133fd7Smrg esac 6413ea133fd7Smrg done 6414ea133fd7Smrg fi 641525b89263Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 6416ea133fd7Smrg if test "$linkmode,$pass" = "lib,link" || 6417ea133fd7Smrg test "$linkmode,$pass" = "prog,scan" || 6418ea133fd7Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 641906f32fbeSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 642006f32fbeSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 6421ea133fd7Smrg fi 6422ea133fd7Smrg 6423ea133fd7Smrg if test "$pass" = conv; then 6424ea133fd7Smrg # Only check for convenience libraries 6425ea133fd7Smrg deplibs="$lib $deplibs" 6426ea133fd7Smrg if test -z "$libdir"; then 6427ea133fd7Smrg if test -z "$old_library"; then 6428ea133fd7Smrg func_fatal_error "cannot find name of link library for \`$lib'" 6429ea133fd7Smrg fi 6430ea133fd7Smrg # It is a libtool convenience library, so add in its objects. 643106f32fbeSmrg func_append convenience " $ladir/$objdir/$old_library" 643206f32fbeSmrg func_append old_convenience " $ladir/$objdir/$old_library" 6433ea133fd7Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 6434ea133fd7Smrg func_fatal_error "\`$lib' is not a convenience library" 6435ea133fd7Smrg fi 6436ea133fd7Smrg tmp_libs= 6437ea133fd7Smrg for deplib in $dependency_libs; do 6438ea133fd7Smrg deplibs="$deplib $deplibs" 643906f32fbeSmrg if $opt_preserve_dup_deps ; then 6440ea133fd7Smrg case "$tmp_libs " in 644106f32fbeSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6442ea133fd7Smrg esac 6443ea133fd7Smrg fi 644406f32fbeSmrg func_append tmp_libs " $deplib" 6445ea133fd7Smrg done 6446ea133fd7Smrg continue 6447ea133fd7Smrg fi # $pass = conv 6448ea133fd7Smrg 6449ea133fd7Smrg 6450ea133fd7Smrg # Get the name of the library we link against. 6451ea133fd7Smrg linklib= 645206f32fbeSmrg if test -n "$old_library" && 645306f32fbeSmrg { test "$prefer_static_libs" = yes || 645406f32fbeSmrg test "$prefer_static_libs,$installed" = "built,no"; }; then 645506f32fbeSmrg linklib=$old_library 645606f32fbeSmrg else 645706f32fbeSmrg for l in $old_library $library_names; do 645806f32fbeSmrg linklib="$l" 645906f32fbeSmrg done 646006f32fbeSmrg fi 6461ea133fd7Smrg if test -z "$linklib"; then 6462ea133fd7Smrg func_fatal_error "cannot find name of link library for \`$lib'" 6463ea133fd7Smrg fi 6464ea133fd7Smrg 6465ea133fd7Smrg # This library was specified with -dlopen. 6466ea133fd7Smrg if test "$pass" = dlopen; then 6467ea133fd7Smrg if test -z "$libdir"; then 6468ea133fd7Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 6469ea133fd7Smrg fi 6470ea133fd7Smrg if test -z "$dlname" || 6471ea133fd7Smrg test "$dlopen_support" != yes || 6472ea133fd7Smrg test "$build_libtool_libs" = no; then 6473ea133fd7Smrg # If there is no dlname, no dlopen support or we're linking 6474ea133fd7Smrg # statically, we need to preload. We also need to preload any 6475ea133fd7Smrg # dependent libraries so libltdl's deplib preloader doesn't 6476ea133fd7Smrg # bomb out in the load deplibs phase. 647706f32fbeSmrg func_append dlprefiles " $lib $dependency_libs" 6478ea133fd7Smrg else 647906f32fbeSmrg func_append newdlfiles " $lib" 6480ea133fd7Smrg fi 6481ea133fd7Smrg continue 6482ea133fd7Smrg fi # $pass = dlopen 6483ea133fd7Smrg 6484ea133fd7Smrg # We need an absolute path. 6485ea133fd7Smrg case $ladir in 6486ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 6487ea133fd7Smrg *) 6488ea133fd7Smrg abs_ladir=`cd "$ladir" && pwd` 6489ea133fd7Smrg if test -z "$abs_ladir"; then 6490ea133fd7Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 6491ea133fd7Smrg func_warning "passing it literally to the linker, although it might fail" 6492ea133fd7Smrg abs_ladir="$ladir" 6493ea133fd7Smrg fi 6494ea133fd7Smrg ;; 6495ea133fd7Smrg esac 6496ea133fd7Smrg func_basename "$lib" 6497ea133fd7Smrg laname="$func_basename_result" 6498ea133fd7Smrg 6499ea133fd7Smrg # Find the relevant object directory and library name. 6500ea133fd7Smrg if test "X$installed" = Xyes; then 650106f32fbeSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6502ea133fd7Smrg func_warning "library \`$lib' was moved." 6503ea133fd7Smrg dir="$ladir" 6504ea133fd7Smrg absdir="$abs_ladir" 6505ea133fd7Smrg libdir="$abs_ladir" 6506ea133fd7Smrg else 650706f32fbeSmrg dir="$lt_sysroot$libdir" 650806f32fbeSmrg absdir="$lt_sysroot$libdir" 6509ea133fd7Smrg fi 6510ea133fd7Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 6511ea133fd7Smrg else 6512ea133fd7Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6513ea133fd7Smrg dir="$ladir" 6514ea133fd7Smrg absdir="$abs_ladir" 6515ea133fd7Smrg # Remove this search path later 651606f32fbeSmrg func_append notinst_path " $abs_ladir" 6517ea133fd7Smrg else 6518ea133fd7Smrg dir="$ladir/$objdir" 6519ea133fd7Smrg absdir="$abs_ladir/$objdir" 6520ea133fd7Smrg # Remove this search path later 652106f32fbeSmrg func_append notinst_path " $abs_ladir" 6522ea133fd7Smrg fi 6523ea133fd7Smrg fi # $installed = yes 6524ea133fd7Smrg func_stripname 'lib' '.la' "$laname" 6525ea133fd7Smrg name=$func_stripname_result 6526ea133fd7Smrg 6527ea133fd7Smrg # This library was specified with -dlpreopen. 6528ea133fd7Smrg if test "$pass" = dlpreopen; then 6529ea133fd7Smrg if test -z "$libdir" && test "$linkmode" = prog; then 6530ea133fd7Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 6531ea133fd7Smrg fi 653206f32fbeSmrg case "$host" in 653306f32fbeSmrg # special handling for platforms with PE-DLLs. 653406f32fbeSmrg *cygwin* | *mingw* | *cegcc* ) 653506f32fbeSmrg # Linker will automatically link against shared library if both 653606f32fbeSmrg # static and shared are present. Therefore, ensure we extract 653706f32fbeSmrg # symbols from the import library if a shared library is present 653806f32fbeSmrg # (otherwise, the dlopen module name will be incorrect). We do 653906f32fbeSmrg # this by putting the import library name into $newdlprefiles. 654006f32fbeSmrg # We recover the dlopen module name by 'saving' the la file 654106f32fbeSmrg # name in a special purpose variable, and (later) extracting the 654206f32fbeSmrg # dlname from the la file. 654306f32fbeSmrg if test -n "$dlname"; then 654406f32fbeSmrg func_tr_sh "$dir/$linklib" 654506f32fbeSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 654606f32fbeSmrg func_append newdlprefiles " $dir/$linklib" 654706f32fbeSmrg else 654806f32fbeSmrg func_append newdlprefiles " $dir/$old_library" 654906f32fbeSmrg # Keep a list of preopened convenience libraries to check 655006f32fbeSmrg # that they are being used correctly in the link pass. 655106f32fbeSmrg test -z "$libdir" && \ 655206f32fbeSmrg func_append dlpreconveniencelibs " $dir/$old_library" 655306f32fbeSmrg fi 655406f32fbeSmrg ;; 655506f32fbeSmrg * ) 655606f32fbeSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 655706f32fbeSmrg # are required to link). 655806f32fbeSmrg if test -n "$old_library"; then 655906f32fbeSmrg func_append newdlprefiles " $dir/$old_library" 656006f32fbeSmrg # Keep a list of preopened convenience libraries to check 656106f32fbeSmrg # that they are being used correctly in the link pass. 656206f32fbeSmrg test -z "$libdir" && \ 656306f32fbeSmrg func_append dlpreconveniencelibs " $dir/$old_library" 656406f32fbeSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 656506f32fbeSmrg elif test -n "$dlname"; then 656606f32fbeSmrg func_append newdlprefiles " $dir/$dlname" 656706f32fbeSmrg else 656806f32fbeSmrg func_append newdlprefiles " $dir/$linklib" 656906f32fbeSmrg fi 657006f32fbeSmrg ;; 657106f32fbeSmrg esac 6572ea133fd7Smrg fi # $pass = dlpreopen 6573ea133fd7Smrg 6574ea133fd7Smrg if test -z "$libdir"; then 6575ea133fd7Smrg # Link the convenience library 6576ea133fd7Smrg if test "$linkmode" = lib; then 6577ea133fd7Smrg deplibs="$dir/$old_library $deplibs" 6578ea133fd7Smrg elif test "$linkmode,$pass" = "prog,link"; then 6579ea133fd7Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 6580ea133fd7Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 6581ea133fd7Smrg else 6582ea133fd7Smrg deplibs="$lib $deplibs" # used for prog,scan pass 6583ea133fd7Smrg fi 6584ea133fd7Smrg continue 6585ea133fd7Smrg fi 6586ea133fd7Smrg 6587ea133fd7Smrg 6588ea133fd7Smrg if test "$linkmode" = prog && test "$pass" != link; then 658906f32fbeSmrg func_append newlib_search_path " $ladir" 6590ea133fd7Smrg deplibs="$lib $deplibs" 6591ea133fd7Smrg 6592ea133fd7Smrg linkalldeplibs=no 6593ea133fd7Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 6594ea133fd7Smrg test "$build_libtool_libs" = no; then 6595ea133fd7Smrg linkalldeplibs=yes 6596ea133fd7Smrg fi 6597ea133fd7Smrg 6598ea133fd7Smrg tmp_libs= 6599ea133fd7Smrg for deplib in $dependency_libs; do 6600ea133fd7Smrg case $deplib in 6601ea133fd7Smrg -L*) func_stripname '-L' '' "$deplib" 660206f32fbeSmrg func_resolve_sysroot "$func_stripname_result" 660306f32fbeSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 6604ea133fd7Smrg ;; 6605ea133fd7Smrg esac 6606ea133fd7Smrg # Need to link against all dependency_libs? 6607ea133fd7Smrg if test "$linkalldeplibs" = yes; then 6608ea133fd7Smrg deplibs="$deplib $deplibs" 6609ea133fd7Smrg else 6610ea133fd7Smrg # Need to hardcode shared library paths 6611ea133fd7Smrg # or/and link against static libraries 6612ea133fd7Smrg newdependency_libs="$deplib $newdependency_libs" 6613ea133fd7Smrg fi 661406f32fbeSmrg if $opt_preserve_dup_deps ; then 6615ea133fd7Smrg case "$tmp_libs " in 661606f32fbeSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6617ea133fd7Smrg esac 6618ea133fd7Smrg fi 661906f32fbeSmrg func_append tmp_libs " $deplib" 6620ea133fd7Smrg done # for deplib 6621ea133fd7Smrg continue 6622ea133fd7Smrg fi # $linkmode = prog... 6623ea133fd7Smrg 6624ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 6625ea133fd7Smrg if test -n "$library_names" && 6626ea133fd7Smrg { { test "$prefer_static_libs" = no || 6627ea133fd7Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 6628ea133fd7Smrg test -z "$old_library"; }; then 6629ea133fd7Smrg # We need to hardcode the library path 6630ea133fd7Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 6631ea133fd7Smrg # Make sure the rpath contains only unique directories. 6632ea133fd7Smrg case "$temp_rpath:" in 6633ea133fd7Smrg *"$absdir:"*) ;; 663406f32fbeSmrg *) func_append temp_rpath "$absdir:" ;; 6635ea133fd7Smrg esac 6636ea133fd7Smrg fi 6637ea133fd7Smrg 6638ea133fd7Smrg # Hardcode the library path. 6639ea133fd7Smrg # Skip directories that are in the system default run-time 6640ea133fd7Smrg # search path. 6641ea133fd7Smrg case " $sys_lib_dlsearch_path " in 6642ea133fd7Smrg *" $absdir "*) ;; 6643ea133fd7Smrg *) 6644ea133fd7Smrg case "$compile_rpath " in 6645ea133fd7Smrg *" $absdir "*) ;; 664606f32fbeSmrg *) func_append compile_rpath " $absdir" ;; 6647ea133fd7Smrg esac 6648ea133fd7Smrg ;; 6649ea133fd7Smrg esac 6650ea133fd7Smrg case " $sys_lib_dlsearch_path " in 6651ea133fd7Smrg *" $libdir "*) ;; 6652ea133fd7Smrg *) 6653ea133fd7Smrg case "$finalize_rpath " in 6654ea133fd7Smrg *" $libdir "*) ;; 665506f32fbeSmrg *) func_append finalize_rpath " $libdir" ;; 6656ea133fd7Smrg esac 6657ea133fd7Smrg ;; 6658ea133fd7Smrg esac 6659ea133fd7Smrg fi # $linkmode,$pass = prog,link... 6660ea133fd7Smrg 6661ea133fd7Smrg if test "$alldeplibs" = yes && 6662ea133fd7Smrg { test "$deplibs_check_method" = pass_all || 6663ea133fd7Smrg { test "$build_libtool_libs" = yes && 6664ea133fd7Smrg test -n "$library_names"; }; }; then 6665ea133fd7Smrg # We only need to search for static libraries 6666ea133fd7Smrg continue 6667ea133fd7Smrg fi 6668ea133fd7Smrg fi 6669ea133fd7Smrg 6670ea133fd7Smrg link_static=no # Whether the deplib will be linked statically 6671ea133fd7Smrg use_static_libs=$prefer_static_libs 6672ea133fd7Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 6673ea133fd7Smrg use_static_libs=no 6674ea133fd7Smrg fi 6675ea133fd7Smrg if test -n "$library_names" && 6676ea133fd7Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 6677ea133fd7Smrg case $host in 6678ea133fd7Smrg *cygwin* | *mingw* | *cegcc*) 6679ea133fd7Smrg # No point in relinking DLLs because paths are not encoded 668006f32fbeSmrg func_append notinst_deplibs " $lib" 6681ea133fd7Smrg need_relink=no 6682ea133fd7Smrg ;; 6683ea133fd7Smrg *) 6684ea133fd7Smrg if test "$installed" = no; then 668506f32fbeSmrg func_append notinst_deplibs " $lib" 6686ea133fd7Smrg need_relink=yes 6687ea133fd7Smrg fi 6688ea133fd7Smrg ;; 6689ea133fd7Smrg esac 6690ea133fd7Smrg # This is a shared library 6691ea133fd7Smrg 6692ea133fd7Smrg # Warn about portability, can't link against -module's on some 6693ea133fd7Smrg # systems (darwin). Don't bleat about dlopened modules though! 6694ea133fd7Smrg dlopenmodule="" 6695ea133fd7Smrg for dlpremoduletest in $dlprefiles; do 6696ea133fd7Smrg if test "X$dlpremoduletest" = "X$lib"; then 6697ea133fd7Smrg dlopenmodule="$dlpremoduletest" 6698ea133fd7Smrg break 6699ea133fd7Smrg fi 6700ea133fd7Smrg done 6701ea133fd7Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 670225b89263Smrg echo 6703ea133fd7Smrg if test "$linkmode" = prog; then 6704ea133fd7Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 6705ea133fd7Smrg else 6706ea133fd7Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 6707ea133fd7Smrg fi 6708ea133fd7Smrg $ECHO "*** $linklib is not portable!" 6709ea133fd7Smrg fi 6710ea133fd7Smrg if test "$linkmode" = lib && 6711ea133fd7Smrg test "$hardcode_into_libs" = yes; then 6712ea133fd7Smrg # Hardcode the library path. 6713ea133fd7Smrg # Skip directories that are in the system default run-time 6714ea133fd7Smrg # search path. 6715ea133fd7Smrg case " $sys_lib_dlsearch_path " in 6716ea133fd7Smrg *" $absdir "*) ;; 6717ea133fd7Smrg *) 6718ea133fd7Smrg case "$compile_rpath " in 6719ea133fd7Smrg *" $absdir "*) ;; 672006f32fbeSmrg *) func_append compile_rpath " $absdir" ;; 6721ea133fd7Smrg esac 6722ea133fd7Smrg ;; 6723ea133fd7Smrg esac 6724ea133fd7Smrg case " $sys_lib_dlsearch_path " in 6725ea133fd7Smrg *" $libdir "*) ;; 6726ea133fd7Smrg *) 6727ea133fd7Smrg case "$finalize_rpath " in 6728ea133fd7Smrg *" $libdir "*) ;; 672906f32fbeSmrg *) func_append finalize_rpath " $libdir" ;; 6730ea133fd7Smrg esac 6731ea133fd7Smrg ;; 6732ea133fd7Smrg esac 6733ea133fd7Smrg fi 6734ea133fd7Smrg 6735ea133fd7Smrg if test -n "$old_archive_from_expsyms_cmds"; then 6736ea133fd7Smrg # figure out the soname 6737ea133fd7Smrg set dummy $library_names 6738ea133fd7Smrg shift 6739ea133fd7Smrg realname="$1" 6740ea133fd7Smrg shift 6741ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 6742ea133fd7Smrg # use dlname if we got it. it's perfectly good, no? 6743ea133fd7Smrg if test -n "$dlname"; then 6744ea133fd7Smrg soname="$dlname" 6745ea133fd7Smrg elif test -n "$soname_spec"; then 6746ea133fd7Smrg # bleh windows 6747ea133fd7Smrg case $host in 6748ea133fd7Smrg *cygwin* | mingw* | *cegcc*) 6749ea133fd7Smrg func_arith $current - $age 6750ea133fd7Smrg major=$func_arith_result 6751ea133fd7Smrg versuffix="-$major" 6752ea133fd7Smrg ;; 6753ea133fd7Smrg esac 6754ea133fd7Smrg eval soname=\"$soname_spec\" 6755ea133fd7Smrg else 6756ea133fd7Smrg soname="$realname" 6757ea133fd7Smrg fi 6758ea133fd7Smrg 6759ea133fd7Smrg # Make a new name for the extract_expsyms_cmds to use 6760ea133fd7Smrg soroot="$soname" 6761ea133fd7Smrg func_basename "$soroot" 6762ea133fd7Smrg soname="$func_basename_result" 6763ea133fd7Smrg func_stripname 'lib' '.dll' "$soname" 6764ea133fd7Smrg newlib=libimp-$func_stripname_result.a 6765ea133fd7Smrg 6766ea133fd7Smrg # If the library has no export list, then create one now 6767ea133fd7Smrg if test -f "$output_objdir/$soname-def"; then : 6768ea133fd7Smrg else 6769ea133fd7Smrg func_verbose "extracting exported symbol list from \`$soname'" 6770ea133fd7Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 6771ea133fd7Smrg fi 6772ea133fd7Smrg 6773ea133fd7Smrg # Create $newlib 6774ea133fd7Smrg if test -f "$output_objdir/$newlib"; then :; else 6775ea133fd7Smrg func_verbose "generating import library for \`$soname'" 6776ea133fd7Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 6777ea133fd7Smrg fi 6778ea133fd7Smrg # make sure the library variables are pointing to the new library 6779ea133fd7Smrg dir=$output_objdir 6780ea133fd7Smrg linklib=$newlib 6781ea133fd7Smrg fi # test -n "$old_archive_from_expsyms_cmds" 6782ea133fd7Smrg 678306f32fbeSmrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 6784ea133fd7Smrg add_shlibpath= 6785ea133fd7Smrg add_dir= 6786ea133fd7Smrg add= 6787ea133fd7Smrg lib_linked=yes 6788ea133fd7Smrg case $hardcode_action in 6789ea133fd7Smrg immediate | unsupported) 6790ea133fd7Smrg if test "$hardcode_direct" = no; then 6791ea133fd7Smrg add="$dir/$linklib" 6792ea133fd7Smrg case $host in 6793ea133fd7Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6794ea133fd7Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 6795ea133fd7Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6796ea133fd7Smrg *-*-unixware7*) add_dir="-L$dir" ;; 6797ea133fd7Smrg *-*-darwin* ) 6798ea133fd7Smrg # if the lib is a (non-dlopened) module then we can not 6799ea133fd7Smrg # link against it, someone is ignoring the earlier warnings 6800ea133fd7Smrg if /usr/bin/file -L $add 2> /dev/null | 6801ea133fd7Smrg $GREP ": [^:]* bundle" >/dev/null ; then 6802ea133fd7Smrg if test "X$dlopenmodule" != "X$lib"; then 6803ea133fd7Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6804ea133fd7Smrg if test -z "$old_library" ; then 680525b89263Smrg echo 680625b89263Smrg echo "*** And there doesn't seem to be a static archive available" 680725b89263Smrg echo "*** The link will probably fail, sorry" 6808ea133fd7Smrg else 6809ea133fd7Smrg add="$dir/$old_library" 6810ea133fd7Smrg fi 6811ea133fd7Smrg elif test -n "$old_library"; then 6812ea133fd7Smrg add="$dir/$old_library" 6813ea133fd7Smrg fi 6814ea133fd7Smrg fi 6815ea133fd7Smrg esac 6816ea133fd7Smrg elif test "$hardcode_minus_L" = no; then 6817ea133fd7Smrg case $host in 6818ea133fd7Smrg *-*-sunos*) add_shlibpath="$dir" ;; 6819ea133fd7Smrg esac 6820ea133fd7Smrg add_dir="-L$dir" 6821ea133fd7Smrg add="-l$name" 6822ea133fd7Smrg elif test "$hardcode_shlibpath_var" = no; then 6823ea133fd7Smrg add_shlibpath="$dir" 6824ea133fd7Smrg add="-l$name" 6825ea133fd7Smrg else 6826ea133fd7Smrg lib_linked=no 6827ea133fd7Smrg fi 6828ea133fd7Smrg ;; 6829ea133fd7Smrg relink) 6830ea133fd7Smrg if test "$hardcode_direct" = yes && 6831ea133fd7Smrg test "$hardcode_direct_absolute" = no; then 6832ea133fd7Smrg add="$dir/$linklib" 6833ea133fd7Smrg elif test "$hardcode_minus_L" = yes; then 6834ea133fd7Smrg add_dir="-L$dir" 6835ea133fd7Smrg # Try looking first in the location we're being installed to. 6836ea133fd7Smrg if test -n "$inst_prefix_dir"; then 6837ea133fd7Smrg case $libdir in 6838ea133fd7Smrg [\\/]*) 683906f32fbeSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 6840ea133fd7Smrg ;; 6841ea133fd7Smrg esac 6842ea133fd7Smrg fi 6843ea133fd7Smrg add="-l$name" 6844ea133fd7Smrg elif test "$hardcode_shlibpath_var" = yes; then 6845ea133fd7Smrg add_shlibpath="$dir" 6846ea133fd7Smrg add="-l$name" 6847ea133fd7Smrg else 6848ea133fd7Smrg lib_linked=no 6849ea133fd7Smrg fi 6850ea133fd7Smrg ;; 6851ea133fd7Smrg *) lib_linked=no ;; 6852ea133fd7Smrg esac 6853ea133fd7Smrg 6854ea133fd7Smrg if test "$lib_linked" != yes; then 6855ea133fd7Smrg func_fatal_configuration "unsupported hardcode properties" 6856ea133fd7Smrg fi 6857ea133fd7Smrg 6858ea133fd7Smrg if test -n "$add_shlibpath"; then 6859ea133fd7Smrg case :$compile_shlibpath: in 6860ea133fd7Smrg *":$add_shlibpath:"*) ;; 686106f32fbeSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 6862ea133fd7Smrg esac 6863ea133fd7Smrg fi 6864ea133fd7Smrg if test "$linkmode" = prog; then 6865ea133fd7Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 6866ea133fd7Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 6867ea133fd7Smrg else 6868ea133fd7Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6869ea133fd7Smrg test -n "$add" && deplibs="$add $deplibs" 6870ea133fd7Smrg if test "$hardcode_direct" != yes && 6871ea133fd7Smrg test "$hardcode_minus_L" != yes && 6872ea133fd7Smrg test "$hardcode_shlibpath_var" = yes; then 6873ea133fd7Smrg case :$finalize_shlibpath: in 6874ea133fd7Smrg *":$libdir:"*) ;; 687506f32fbeSmrg *) func_append finalize_shlibpath "$libdir:" ;; 6876ea133fd7Smrg esac 6877ea133fd7Smrg fi 6878ea133fd7Smrg fi 6879ea133fd7Smrg fi 6880ea133fd7Smrg 688106f32fbeSmrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 6882ea133fd7Smrg add_shlibpath= 6883ea133fd7Smrg add_dir= 6884ea133fd7Smrg add= 6885ea133fd7Smrg # Finalize command for both is simple: just hardcode it. 6886ea133fd7Smrg if test "$hardcode_direct" = yes && 6887ea133fd7Smrg test "$hardcode_direct_absolute" = no; then 6888ea133fd7Smrg add="$libdir/$linklib" 6889ea133fd7Smrg elif test "$hardcode_minus_L" = yes; then 6890ea133fd7Smrg add_dir="-L$libdir" 6891ea133fd7Smrg add="-l$name" 6892ea133fd7Smrg elif test "$hardcode_shlibpath_var" = yes; then 6893ea133fd7Smrg case :$finalize_shlibpath: in 6894ea133fd7Smrg *":$libdir:"*) ;; 689506f32fbeSmrg *) func_append finalize_shlibpath "$libdir:" ;; 6896ea133fd7Smrg esac 6897ea133fd7Smrg add="-l$name" 6898ea133fd7Smrg elif test "$hardcode_automatic" = yes; then 6899ea133fd7Smrg if test -n "$inst_prefix_dir" && 6900ea133fd7Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 6901ea133fd7Smrg add="$inst_prefix_dir$libdir/$linklib" 6902ea133fd7Smrg else 6903ea133fd7Smrg add="$libdir/$linklib" 6904ea133fd7Smrg fi 6905ea133fd7Smrg else 6906ea133fd7Smrg # We cannot seem to hardcode it, guess we'll fake it. 6907ea133fd7Smrg add_dir="-L$libdir" 6908ea133fd7Smrg # Try looking first in the location we're being installed to. 6909ea133fd7Smrg if test -n "$inst_prefix_dir"; then 6910ea133fd7Smrg case $libdir in 6911ea133fd7Smrg [\\/]*) 691206f32fbeSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 6913ea133fd7Smrg ;; 6914ea133fd7Smrg esac 6915ea133fd7Smrg fi 6916ea133fd7Smrg add="-l$name" 6917ea133fd7Smrg fi 6918ea133fd7Smrg 6919ea133fd7Smrg if test "$linkmode" = prog; then 6920ea133fd7Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 6921ea133fd7Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 6922ea133fd7Smrg else 6923ea133fd7Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6924ea133fd7Smrg test -n "$add" && deplibs="$add $deplibs" 6925ea133fd7Smrg fi 6926ea133fd7Smrg fi 6927ea133fd7Smrg elif test "$linkmode" = prog; then 6928ea133fd7Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 6929ea133fd7Smrg # is not unsupported. This is valid on all known static and 6930ea133fd7Smrg # shared platforms. 6931ea133fd7Smrg if test "$hardcode_direct" != unsupported; then 6932ea133fd7Smrg test -n "$old_library" && linklib="$old_library" 6933ea133fd7Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 6934ea133fd7Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 6935ea133fd7Smrg else 6936ea133fd7Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 6937ea133fd7Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 6938ea133fd7Smrg fi 6939ea133fd7Smrg elif test "$build_libtool_libs" = yes; then 6940ea133fd7Smrg # Not a shared library 6941ea133fd7Smrg if test "$deplibs_check_method" != pass_all; then 6942ea133fd7Smrg # We're trying link a shared library against a static one 6943ea133fd7Smrg # but the system doesn't support it. 6944ea133fd7Smrg 6945ea133fd7Smrg # Just print a warning and add the library to dependency_libs so 6946ea133fd7Smrg # that the program can be linked against the static library. 694725b89263Smrg echo 6948ea133fd7Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 694925b89263Smrg echo "*** I have the capability to make that library automatically link in when" 695025b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 695125b89263Smrg echo "*** shared version of the library, which you do not appear to have." 6952ea133fd7Smrg if test "$module" = yes; then 695325b89263Smrg echo "*** But as you try to build a module library, libtool will still create " 695425b89263Smrg echo "*** a static module, that should work as long as the dlopening application" 695525b89263Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 6956ea133fd7Smrg if test -z "$global_symbol_pipe"; then 695725b89263Smrg echo 695825b89263Smrg echo "*** However, this would only work if libtool was able to extract symbol" 695925b89263Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 696025b89263Smrg echo "*** not find such a program. So, this module is probably useless." 696125b89263Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 6962ea133fd7Smrg fi 6963ea133fd7Smrg if test "$build_old_libs" = no; then 6964ea133fd7Smrg build_libtool_libs=module 6965ea133fd7Smrg build_old_libs=yes 6966ea133fd7Smrg else 6967ea133fd7Smrg build_libtool_libs=no 6968ea133fd7Smrg fi 6969ea133fd7Smrg fi 6970ea133fd7Smrg else 6971ea133fd7Smrg deplibs="$dir/$old_library $deplibs" 6972ea133fd7Smrg link_static=yes 6973ea133fd7Smrg fi 6974ea133fd7Smrg fi # link shared/static library? 6975ea133fd7Smrg 6976ea133fd7Smrg if test "$linkmode" = lib; then 6977ea133fd7Smrg if test -n "$dependency_libs" && 6978ea133fd7Smrg { test "$hardcode_into_libs" != yes || 6979ea133fd7Smrg test "$build_old_libs" = yes || 6980ea133fd7Smrg test "$link_static" = yes; }; then 6981ea133fd7Smrg # Extract -R from dependency_libs 6982ea133fd7Smrg temp_deplibs= 6983ea133fd7Smrg for libdir in $dependency_libs; do 6984ea133fd7Smrg case $libdir in 6985ea133fd7Smrg -R*) func_stripname '-R' '' "$libdir" 6986ea133fd7Smrg temp_xrpath=$func_stripname_result 6987ea133fd7Smrg case " $xrpath " in 6988ea133fd7Smrg *" $temp_xrpath "*) ;; 698906f32fbeSmrg *) func_append xrpath " $temp_xrpath";; 6990ea133fd7Smrg esac;; 699106f32fbeSmrg *) func_append temp_deplibs " $libdir";; 6992ea133fd7Smrg esac 6993ea133fd7Smrg done 6994ea133fd7Smrg dependency_libs="$temp_deplibs" 6995ea133fd7Smrg fi 6996ea133fd7Smrg 699706f32fbeSmrg func_append newlib_search_path " $absdir" 6998ea133fd7Smrg # Link against this library 6999ea133fd7Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 7000ea133fd7Smrg # ... and its dependency_libs 7001ea133fd7Smrg tmp_libs= 7002ea133fd7Smrg for deplib in $dependency_libs; do 7003ea133fd7Smrg newdependency_libs="$deplib $newdependency_libs" 700406f32fbeSmrg case $deplib in 700506f32fbeSmrg -L*) func_stripname '-L' '' "$deplib" 700606f32fbeSmrg func_resolve_sysroot "$func_stripname_result";; 700706f32fbeSmrg *) func_resolve_sysroot "$deplib" ;; 700806f32fbeSmrg esac 700906f32fbeSmrg if $opt_preserve_dup_deps ; then 7010ea133fd7Smrg case "$tmp_libs " in 701106f32fbeSmrg *" $func_resolve_sysroot_result "*) 701206f32fbeSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 7013ea133fd7Smrg esac 7014ea133fd7Smrg fi 701506f32fbeSmrg func_append tmp_libs " $func_resolve_sysroot_result" 7016ea133fd7Smrg done 7017ea133fd7Smrg 7018ea133fd7Smrg if test "$link_all_deplibs" != no; then 7019ea133fd7Smrg # Add the search paths of all dependency libraries 7020ea133fd7Smrg for deplib in $dependency_libs; do 702125b89263Smrg path= 7022ea133fd7Smrg case $deplib in 7023ea133fd7Smrg -L*) path="$deplib" ;; 7024ea133fd7Smrg *.la) 702506f32fbeSmrg func_resolve_sysroot "$deplib" 702606f32fbeSmrg deplib=$func_resolve_sysroot_result 7027ea133fd7Smrg func_dirname "$deplib" "" "." 702806f32fbeSmrg dir=$func_dirname_result 7029ea133fd7Smrg # We need an absolute path. 7030ea133fd7Smrg case $dir in 7031ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 7032ea133fd7Smrg *) 7033ea133fd7Smrg absdir=`cd "$dir" && pwd` 7034ea133fd7Smrg if test -z "$absdir"; then 7035ea133fd7Smrg func_warning "cannot determine absolute directory name of \`$dir'" 7036ea133fd7Smrg absdir="$dir" 7037ea133fd7Smrg fi 7038ea133fd7Smrg ;; 7039ea133fd7Smrg esac 7040ea133fd7Smrg if $GREP "^installed=no" $deplib > /dev/null; then 7041ea133fd7Smrg case $host in 7042ea133fd7Smrg *-*-darwin*) 7043ea133fd7Smrg depdepl= 7044ea133fd7Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 7045ea133fd7Smrg if test -n "$deplibrary_names" ; then 7046ea133fd7Smrg for tmp in $deplibrary_names ; do 7047ea133fd7Smrg depdepl=$tmp 7048ea133fd7Smrg done 7049ea133fd7Smrg if test -f "$absdir/$objdir/$depdepl" ; then 7050ea133fd7Smrg depdepl="$absdir/$objdir/$depdepl" 7051ea133fd7Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7052ea133fd7Smrg if test -z "$darwin_install_name"; then 7053ea133fd7Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7054ea133fd7Smrg fi 705506f32fbeSmrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 705606f32fbeSmrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 7057ea133fd7Smrg path= 7058ea133fd7Smrg fi 7059ea133fd7Smrg fi 7060ea133fd7Smrg ;; 7061ea133fd7Smrg *) 7062ea133fd7Smrg path="-L$absdir/$objdir" 7063ea133fd7Smrg ;; 7064ea133fd7Smrg esac 7065ea133fd7Smrg else 7066ea133fd7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 7067ea133fd7Smrg test -z "$libdir" && \ 7068ea133fd7Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 7069ea133fd7Smrg test "$absdir" != "$libdir" && \ 7070ea133fd7Smrg func_warning "\`$deplib' seems to be moved" 7071ea133fd7Smrg 7072ea133fd7Smrg path="-L$absdir" 7073ea133fd7Smrg fi 7074ea133fd7Smrg ;; 7075ea133fd7Smrg esac 7076ea133fd7Smrg case " $deplibs " in 7077ea133fd7Smrg *" $path "*) ;; 7078ea133fd7Smrg *) deplibs="$path $deplibs" ;; 7079ea133fd7Smrg esac 7080ea133fd7Smrg done 7081ea133fd7Smrg fi # link_all_deplibs != no 7082ea133fd7Smrg fi # linkmode = lib 7083ea133fd7Smrg done # for deplib in $libs 7084ea133fd7Smrg if test "$pass" = link; then 7085ea133fd7Smrg if test "$linkmode" = "prog"; then 7086ea133fd7Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 7087ea133fd7Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 7088ea133fd7Smrg else 708925b89263Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7090ea133fd7Smrg fi 7091ea133fd7Smrg fi 7092ea133fd7Smrg dependency_libs="$newdependency_libs" 7093ea133fd7Smrg if test "$pass" = dlpreopen; then 7094ea133fd7Smrg # Link the dlpreopened libraries before other libraries 7095ea133fd7Smrg for deplib in $save_deplibs; do 7096ea133fd7Smrg deplibs="$deplib $deplibs" 7097ea133fd7Smrg done 7098ea133fd7Smrg fi 7099ea133fd7Smrg if test "$pass" != dlopen; then 7100ea133fd7Smrg if test "$pass" != conv; then 7101ea133fd7Smrg # Make sure lib_search_path contains only unique directories. 7102ea133fd7Smrg lib_search_path= 7103ea133fd7Smrg for dir in $newlib_search_path; do 7104ea133fd7Smrg case "$lib_search_path " in 7105ea133fd7Smrg *" $dir "*) ;; 710606f32fbeSmrg *) func_append lib_search_path " $dir" ;; 7107ea133fd7Smrg esac 7108ea133fd7Smrg done 7109ea133fd7Smrg newlib_search_path= 7110ea133fd7Smrg fi 7111ea133fd7Smrg 7112ea133fd7Smrg if test "$linkmode,$pass" != "prog,link"; then 7113ea133fd7Smrg vars="deplibs" 7114ea133fd7Smrg else 7115ea133fd7Smrg vars="compile_deplibs finalize_deplibs" 7116ea133fd7Smrg fi 7117ea133fd7Smrg for var in $vars dependency_libs; do 7118ea133fd7Smrg # Add libraries to $var in reverse order 7119ea133fd7Smrg eval tmp_libs=\"\$$var\" 7120ea133fd7Smrg new_libs= 7121ea133fd7Smrg for deplib in $tmp_libs; do 7122ea133fd7Smrg # FIXME: Pedantically, this is the right thing to do, so 7123ea133fd7Smrg # that some nasty dependency loop isn't accidentally 7124ea133fd7Smrg # broken: 7125ea133fd7Smrg #new_libs="$deplib $new_libs" 7126ea133fd7Smrg # Pragmatically, this seems to cause very few problems in 7127ea133fd7Smrg # practice: 7128ea133fd7Smrg case $deplib in 7129ea133fd7Smrg -L*) new_libs="$deplib $new_libs" ;; 7130ea133fd7Smrg -R*) ;; 7131ea133fd7Smrg *) 7132ea133fd7Smrg # And here is the reason: when a library appears more 7133ea133fd7Smrg # than once as an explicit dependence of a library, or 7134ea133fd7Smrg # is implicitly linked in more than once by the 7135ea133fd7Smrg # compiler, it is considered special, and multiple 7136ea133fd7Smrg # occurrences thereof are not removed. Compare this 7137ea133fd7Smrg # with having the same library being listed as a 7138ea133fd7Smrg # dependency of multiple other libraries: in this case, 7139ea133fd7Smrg # we know (pedantically, we assume) the library does not 7140ea133fd7Smrg # need to be listed more than once, so we keep only the 7141ea133fd7Smrg # last copy. This is not always right, but it is rare 7142ea133fd7Smrg # enough that we require users that really mean to play 7143ea133fd7Smrg # such unportable linking tricks to link the library 7144ea133fd7Smrg # using -Wl,-lname, so that libtool does not consider it 7145ea133fd7Smrg # for duplicate removal. 7146ea133fd7Smrg case " $specialdeplibs " in 7147ea133fd7Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 7148ea133fd7Smrg *) 7149ea133fd7Smrg case " $new_libs " in 7150ea133fd7Smrg *" $deplib "*) ;; 7151ea133fd7Smrg *) new_libs="$deplib $new_libs" ;; 7152ea133fd7Smrg esac 7153ea133fd7Smrg ;; 7154ea133fd7Smrg esac 7155ea133fd7Smrg ;; 7156ea133fd7Smrg esac 7157ea133fd7Smrg done 7158ea133fd7Smrg tmp_libs= 7159ea133fd7Smrg for deplib in $new_libs; do 7160ea133fd7Smrg case $deplib in 7161ea133fd7Smrg -L*) 7162ea133fd7Smrg case " $tmp_libs " in 7163ea133fd7Smrg *" $deplib "*) ;; 716406f32fbeSmrg *) func_append tmp_libs " $deplib" ;; 7165ea133fd7Smrg esac 7166ea133fd7Smrg ;; 716706f32fbeSmrg *) func_append tmp_libs " $deplib" ;; 7168ea133fd7Smrg esac 7169ea133fd7Smrg done 7170ea133fd7Smrg eval $var=\"$tmp_libs\" 7171ea133fd7Smrg done # for var 7172ea133fd7Smrg fi 7173ea133fd7Smrg # Last step: remove runtime libs from dependency_libs 7174ea133fd7Smrg # (they stay in deplibs) 7175ea133fd7Smrg tmp_libs= 7176ea133fd7Smrg for i in $dependency_libs ; do 7177ea133fd7Smrg case " $predeps $postdeps $compiler_lib_search_path " in 7178ea133fd7Smrg *" $i "*) 7179ea133fd7Smrg i="" 7180ea133fd7Smrg ;; 7181ea133fd7Smrg esac 7182ea133fd7Smrg if test -n "$i" ; then 718306f32fbeSmrg func_append tmp_libs " $i" 7184ea133fd7Smrg fi 7185ea133fd7Smrg done 7186ea133fd7Smrg dependency_libs=$tmp_libs 7187ea133fd7Smrg done # for pass 7188ea133fd7Smrg if test "$linkmode" = prog; then 7189ea133fd7Smrg dlfiles="$newdlfiles" 7190ea133fd7Smrg fi 7191ea133fd7Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 7192ea133fd7Smrg dlprefiles="$newdlprefiles" 7193ea133fd7Smrg fi 7194ea133fd7Smrg 7195ea133fd7Smrg case $linkmode in 7196ea133fd7Smrg oldlib) 7197ea133fd7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7198ea133fd7Smrg func_warning "\`-dlopen' is ignored for archives" 7199ea133fd7Smrg fi 7200ea133fd7Smrg 7201ea133fd7Smrg case " $deplibs" in 7202ea133fd7Smrg *\ -l* | *\ -L*) 7203ea133fd7Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 7204ea133fd7Smrg esac 7205ea133fd7Smrg 7206ea133fd7Smrg test -n "$rpath" && \ 7207ea133fd7Smrg func_warning "\`-rpath' is ignored for archives" 7208ea133fd7Smrg 7209ea133fd7Smrg test -n "$xrpath" && \ 7210ea133fd7Smrg func_warning "\`-R' is ignored for archives" 7211ea133fd7Smrg 7212ea133fd7Smrg test -n "$vinfo" && \ 7213ea133fd7Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 7214ea133fd7Smrg 7215ea133fd7Smrg test -n "$release" && \ 7216ea133fd7Smrg func_warning "\`-release' is ignored for archives" 7217ea133fd7Smrg 7218ea133fd7Smrg test -n "$export_symbols$export_symbols_regex" && \ 7219ea133fd7Smrg func_warning "\`-export-symbols' is ignored for archives" 7220ea133fd7Smrg 7221ea133fd7Smrg # Now set the variables for building old libraries. 7222ea133fd7Smrg build_libtool_libs=no 7223ea133fd7Smrg oldlibs="$output" 722406f32fbeSmrg func_append objs "$old_deplibs" 7225ea133fd7Smrg ;; 7226ea133fd7Smrg 7227ea133fd7Smrg lib) 7228ea133fd7Smrg # Make sure we only generate libraries of the form `libNAME.la'. 7229ea133fd7Smrg case $outputname in 7230ea133fd7Smrg lib*) 7231ea133fd7Smrg func_stripname 'lib' '.la' "$outputname" 7232ea133fd7Smrg name=$func_stripname_result 7233ea133fd7Smrg eval shared_ext=\"$shrext_cmds\" 7234ea133fd7Smrg eval libname=\"$libname_spec\" 7235ea133fd7Smrg ;; 7236ea133fd7Smrg *) 7237ea133fd7Smrg test "$module" = no && \ 7238ea133fd7Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 7239ea133fd7Smrg 7240ea133fd7Smrg if test "$need_lib_prefix" != no; then 7241ea133fd7Smrg # Add the "lib" prefix for modules if required 7242ea133fd7Smrg func_stripname '' '.la' "$outputname" 7243ea133fd7Smrg name=$func_stripname_result 7244ea133fd7Smrg eval shared_ext=\"$shrext_cmds\" 7245ea133fd7Smrg eval libname=\"$libname_spec\" 7246ea133fd7Smrg else 7247ea133fd7Smrg func_stripname '' '.la' "$outputname" 7248ea133fd7Smrg libname=$func_stripname_result 7249ea133fd7Smrg fi 7250ea133fd7Smrg ;; 7251ea133fd7Smrg esac 7252ea133fd7Smrg 7253ea133fd7Smrg if test -n "$objs"; then 7254ea133fd7Smrg if test "$deplibs_check_method" != pass_all; then 7255ea133fd7Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 7256ea133fd7Smrg else 725725b89263Smrg echo 7258ea133fd7Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 7259ea133fd7Smrg $ECHO "*** objects $objs is not portable!" 726006f32fbeSmrg func_append libobjs " $objs" 7261ea133fd7Smrg fi 7262ea133fd7Smrg fi 7263ea133fd7Smrg 7264ea133fd7Smrg test "$dlself" != no && \ 7265ea133fd7Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 7266ea133fd7Smrg 7267ea133fd7Smrg set dummy $rpath 7268ea133fd7Smrg shift 7269ea133fd7Smrg test "$#" -gt 1 && \ 7270ea133fd7Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 7271ea133fd7Smrg 7272ea133fd7Smrg install_libdir="$1" 7273ea133fd7Smrg 7274ea133fd7Smrg oldlibs= 7275ea133fd7Smrg if test -z "$rpath"; then 7276ea133fd7Smrg if test "$build_libtool_libs" = yes; then 7277ea133fd7Smrg # Building a libtool convenience library. 7278ea133fd7Smrg # Some compilers have problems with a `.al' extension so 7279ea133fd7Smrg # convenience libraries should have the same extension an 7280ea133fd7Smrg # archive normally would. 7281ea133fd7Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 7282ea133fd7Smrg build_libtool_libs=convenience 7283ea133fd7Smrg build_old_libs=yes 7284ea133fd7Smrg fi 7285ea133fd7Smrg 7286ea133fd7Smrg test -n "$vinfo" && \ 7287ea133fd7Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 7288ea133fd7Smrg 7289ea133fd7Smrg test -n "$release" && \ 7290ea133fd7Smrg func_warning "\`-release' is ignored for convenience libraries" 7291ea133fd7Smrg else 7292ea133fd7Smrg 7293ea133fd7Smrg # Parse the version information argument. 7294ea133fd7Smrg save_ifs="$IFS"; IFS=':' 7295ea133fd7Smrg set dummy $vinfo 0 0 0 7296ea133fd7Smrg shift 7297ea133fd7Smrg IFS="$save_ifs" 7298ea133fd7Smrg 7299ea133fd7Smrg test -n "$7" && \ 7300ea133fd7Smrg func_fatal_help "too many parameters to \`-version-info'" 7301ea133fd7Smrg 7302ea133fd7Smrg # convert absolute version numbers to libtool ages 7303ea133fd7Smrg # this retains compatibility with .la files and attempts 7304ea133fd7Smrg # to make the code below a bit more comprehensible 7305ea133fd7Smrg 7306ea133fd7Smrg case $vinfo_number in 7307ea133fd7Smrg yes) 7308ea133fd7Smrg number_major="$1" 7309ea133fd7Smrg number_minor="$2" 7310ea133fd7Smrg number_revision="$3" 7311ea133fd7Smrg # 7312ea133fd7Smrg # There are really only two kinds -- those that 7313ea133fd7Smrg # use the current revision as the major version 7314ea133fd7Smrg # and those that subtract age and use age as 7315ea133fd7Smrg # a minor version. But, then there is irix 7316ea133fd7Smrg # which has an extra 1 added just for fun 7317ea133fd7Smrg # 7318ea133fd7Smrg case $version_type in 7319ea133fd7Smrg darwin|linux|osf|windows|none) 7320ea133fd7Smrg func_arith $number_major + $number_minor 7321ea133fd7Smrg current=$func_arith_result 7322ea133fd7Smrg age="$number_minor" 7323ea133fd7Smrg revision="$number_revision" 7324ea133fd7Smrg ;; 732525b89263Smrg freebsd-aout|freebsd-elf|qnx|sunos) 7326ea133fd7Smrg current="$number_major" 7327ea133fd7Smrg revision="$number_minor" 7328ea133fd7Smrg age="0" 7329ea133fd7Smrg ;; 7330ea133fd7Smrg irix|nonstopux) 7331ea133fd7Smrg func_arith $number_major + $number_minor 7332ea133fd7Smrg current=$func_arith_result 7333ea133fd7Smrg age="$number_minor" 7334ea133fd7Smrg revision="$number_minor" 7335ea133fd7Smrg lt_irix_increment=no 7336ea133fd7Smrg ;; 7337ea133fd7Smrg esac 7338ea133fd7Smrg ;; 7339ea133fd7Smrg no) 7340ea133fd7Smrg current="$1" 7341ea133fd7Smrg revision="$2" 7342ea133fd7Smrg age="$3" 7343ea133fd7Smrg ;; 7344ea133fd7Smrg esac 7345ea133fd7Smrg 7346ea133fd7Smrg # Check that each of the things are valid numbers. 7347ea133fd7Smrg case $current in 7348ea133fd7Smrg 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]) ;; 7349ea133fd7Smrg *) 7350ea133fd7Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 7351ea133fd7Smrg func_fatal_error "\`$vinfo' is not valid version information" 7352ea133fd7Smrg ;; 7353ea133fd7Smrg esac 7354ea133fd7Smrg 7355ea133fd7Smrg case $revision in 7356ea133fd7Smrg 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]) ;; 7357ea133fd7Smrg *) 7358ea133fd7Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 7359ea133fd7Smrg func_fatal_error "\`$vinfo' is not valid version information" 7360ea133fd7Smrg ;; 7361ea133fd7Smrg esac 7362ea133fd7Smrg 7363ea133fd7Smrg case $age in 7364ea133fd7Smrg 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]) ;; 7365ea133fd7Smrg *) 7366ea133fd7Smrg func_error "AGE \`$age' must be a nonnegative integer" 7367ea133fd7Smrg func_fatal_error "\`$vinfo' is not valid version information" 7368ea133fd7Smrg ;; 7369ea133fd7Smrg esac 7370ea133fd7Smrg 7371ea133fd7Smrg if test "$age" -gt "$current"; then 7372ea133fd7Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 7373ea133fd7Smrg func_fatal_error "\`$vinfo' is not valid version information" 7374ea133fd7Smrg fi 7375ea133fd7Smrg 7376ea133fd7Smrg # Calculate the version variables. 7377ea133fd7Smrg major= 7378ea133fd7Smrg versuffix= 7379ea133fd7Smrg verstring= 7380ea133fd7Smrg case $version_type in 7381ea133fd7Smrg none) ;; 7382ea133fd7Smrg 7383ea133fd7Smrg darwin) 7384ea133fd7Smrg # Like Linux, but with the current version available in 7385ea133fd7Smrg # verstring for coding it into the library header 7386ea133fd7Smrg func_arith $current - $age 7387ea133fd7Smrg major=.$func_arith_result 7388ea133fd7Smrg versuffix="$major.$age.$revision" 7389ea133fd7Smrg # Darwin ld doesn't like 0 for these options... 7390ea133fd7Smrg func_arith $current + 1 7391ea133fd7Smrg minor_current=$func_arith_result 7392ea133fd7Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 7393ea133fd7Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 7394ea133fd7Smrg ;; 7395ea133fd7Smrg 7396ea133fd7Smrg freebsd-aout) 7397ea133fd7Smrg major=".$current" 7398ea133fd7Smrg versuffix=".$current.$revision"; 7399ea133fd7Smrg ;; 7400ea133fd7Smrg 7401ea133fd7Smrg freebsd-elf) 7402ea133fd7Smrg major=".$current" 7403ea133fd7Smrg versuffix=".$current" 7404ea133fd7Smrg ;; 7405ea133fd7Smrg 7406ea133fd7Smrg irix | nonstopux) 7407ea133fd7Smrg if test "X$lt_irix_increment" = "Xno"; then 7408ea133fd7Smrg func_arith $current - $age 7409ea133fd7Smrg else 7410ea133fd7Smrg func_arith $current - $age + 1 7411ea133fd7Smrg fi 7412ea133fd7Smrg major=$func_arith_result 7413ea133fd7Smrg 7414ea133fd7Smrg case $version_type in 7415ea133fd7Smrg nonstopux) verstring_prefix=nonstopux ;; 7416ea133fd7Smrg *) verstring_prefix=sgi ;; 7417ea133fd7Smrg esac 7418ea133fd7Smrg verstring="$verstring_prefix$major.$revision" 7419ea133fd7Smrg 7420ea133fd7Smrg # Add in all the interfaces that we are compatible with. 7421ea133fd7Smrg loop=$revision 7422ea133fd7Smrg while test "$loop" -ne 0; do 7423ea133fd7Smrg func_arith $revision - $loop 7424ea133fd7Smrg iface=$func_arith_result 7425ea133fd7Smrg func_arith $loop - 1 7426ea133fd7Smrg loop=$func_arith_result 7427ea133fd7Smrg verstring="$verstring_prefix$major.$iface:$verstring" 7428ea133fd7Smrg done 7429ea133fd7Smrg 7430ea133fd7Smrg # Before this point, $major must not contain `.'. 7431ea133fd7Smrg major=.$major 7432ea133fd7Smrg versuffix="$major.$revision" 7433ea133fd7Smrg ;; 7434ea133fd7Smrg 7435ea133fd7Smrg linux) 7436ea133fd7Smrg func_arith $current - $age 7437ea133fd7Smrg major=.$func_arith_result 7438ea133fd7Smrg versuffix="$major.$age.$revision" 7439ea133fd7Smrg ;; 7440ea133fd7Smrg 7441ea133fd7Smrg osf) 7442ea133fd7Smrg func_arith $current - $age 7443ea133fd7Smrg major=.$func_arith_result 7444ea133fd7Smrg versuffix=".$current.$age.$revision" 7445ea133fd7Smrg verstring="$current.$age.$revision" 7446ea133fd7Smrg 7447ea133fd7Smrg # Add in all the interfaces that we are compatible with. 7448ea133fd7Smrg loop=$age 7449ea133fd7Smrg while test "$loop" -ne 0; do 7450ea133fd7Smrg func_arith $current - $loop 7451ea133fd7Smrg iface=$func_arith_result 7452ea133fd7Smrg func_arith $loop - 1 7453ea133fd7Smrg loop=$func_arith_result 7454ea133fd7Smrg verstring="$verstring:${iface}.0" 7455ea133fd7Smrg done 7456ea133fd7Smrg 7457ea133fd7Smrg # Make executables depend on our current version. 745806f32fbeSmrg func_append verstring ":${current}.0" 7459ea133fd7Smrg ;; 7460ea133fd7Smrg 7461ea133fd7Smrg qnx) 7462ea133fd7Smrg major=".$current" 7463ea133fd7Smrg versuffix=".$current" 7464ea133fd7Smrg ;; 7465ea133fd7Smrg 7466ea133fd7Smrg sunos) 7467ea133fd7Smrg major=".$current" 7468ea133fd7Smrg versuffix=".$current.$revision" 7469ea133fd7Smrg ;; 7470ea133fd7Smrg 7471ea133fd7Smrg windows) 7472ea133fd7Smrg # Use '-' rather than '.', since we only want one 7473ea133fd7Smrg # extension on DOS 8.3 filesystems. 7474ea133fd7Smrg func_arith $current - $age 7475ea133fd7Smrg major=$func_arith_result 7476ea133fd7Smrg versuffix="-$major" 7477ea133fd7Smrg ;; 7478ea133fd7Smrg 7479ea133fd7Smrg *) 7480ea133fd7Smrg func_fatal_configuration "unknown library version type \`$version_type'" 7481ea133fd7Smrg ;; 7482ea133fd7Smrg esac 7483ea133fd7Smrg 7484ea133fd7Smrg # Clear the version info if we defaulted, and they specified a release. 7485ea133fd7Smrg if test -z "$vinfo" && test -n "$release"; then 7486ea133fd7Smrg major= 7487ea133fd7Smrg case $version_type in 7488ea133fd7Smrg darwin) 7489ea133fd7Smrg # we can't check for "0.0" in archive_cmds due to quoting 7490ea133fd7Smrg # problems, so we reset it completely 7491ea133fd7Smrg verstring= 7492ea133fd7Smrg ;; 7493ea133fd7Smrg *) 7494ea133fd7Smrg verstring="0.0" 7495ea133fd7Smrg ;; 7496ea133fd7Smrg esac 7497ea133fd7Smrg if test "$need_version" = no; then 7498ea133fd7Smrg versuffix= 7499ea133fd7Smrg else 7500ea133fd7Smrg versuffix=".0.0" 7501ea133fd7Smrg fi 7502ea133fd7Smrg fi 7503ea133fd7Smrg 7504ea133fd7Smrg # Remove version info from name if versioning should be avoided 7505ea133fd7Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 7506ea133fd7Smrg major= 7507ea133fd7Smrg versuffix= 7508ea133fd7Smrg verstring="" 7509ea133fd7Smrg fi 7510ea133fd7Smrg 7511ea133fd7Smrg # Check to see if the archive will have undefined symbols. 7512ea133fd7Smrg if test "$allow_undefined" = yes; then 7513ea133fd7Smrg if test "$allow_undefined_flag" = unsupported; then 7514ea133fd7Smrg func_warning "undefined symbols not allowed in $host shared libraries" 7515ea133fd7Smrg build_libtool_libs=no 7516ea133fd7Smrg build_old_libs=yes 7517ea133fd7Smrg fi 7518ea133fd7Smrg else 7519ea133fd7Smrg # Don't allow undefined symbols. 7520ea133fd7Smrg allow_undefined_flag="$no_undefined_flag" 7521ea133fd7Smrg fi 7522ea133fd7Smrg 7523ea133fd7Smrg fi 7524ea133fd7Smrg 7525ea133fd7Smrg func_generate_dlsyms "$libname" "$libname" "yes" 752606f32fbeSmrg func_append libobjs " $symfileobj" 7527ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 7528ea133fd7Smrg 752906f32fbeSmrg if test "$opt_mode" != relink; then 7530ea133fd7Smrg # Remove our outputs, but don't remove object files since they 7531ea133fd7Smrg # may have been created when compiling PIC objects. 7532ea133fd7Smrg removelist= 7533ea133fd7Smrg tempremovelist=`$ECHO "$output_objdir/*"` 7534ea133fd7Smrg for p in $tempremovelist; do 7535ea133fd7Smrg case $p in 7536ea133fd7Smrg *.$objext | *.gcno) 7537ea133fd7Smrg ;; 7538ea133fd7Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 7539ea133fd7Smrg if test "X$precious_files_regex" != "X"; then 7540ea133fd7Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 7541ea133fd7Smrg then 7542ea133fd7Smrg continue 7543ea133fd7Smrg fi 7544ea133fd7Smrg fi 754506f32fbeSmrg func_append removelist " $p" 7546ea133fd7Smrg ;; 7547ea133fd7Smrg *) ;; 7548ea133fd7Smrg esac 7549ea133fd7Smrg done 7550ea133fd7Smrg test -n "$removelist" && \ 7551ea133fd7Smrg func_show_eval "${RM}r \$removelist" 7552ea133fd7Smrg fi 7553ea133fd7Smrg 7554ea133fd7Smrg # Now set the variables for building old libraries. 7555ea133fd7Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 755606f32fbeSmrg func_append oldlibs " $output_objdir/$libname.$libext" 7557ea133fd7Smrg 7558ea133fd7Smrg # Transform .lo files to .o files. 755925b89263Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 7560ea133fd7Smrg fi 7561ea133fd7Smrg 7562ea133fd7Smrg # Eliminate all temporary directories. 7563ea133fd7Smrg #for path in $notinst_path; do 756425b89263Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 756525b89263Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 756625b89263Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 7567ea133fd7Smrg #done 7568ea133fd7Smrg 7569ea133fd7Smrg if test -n "$xrpath"; then 7570ea133fd7Smrg # If the user specified any rpath flags, then add them. 7571ea133fd7Smrg temp_xrpath= 7572ea133fd7Smrg for libdir in $xrpath; do 757306f32fbeSmrg func_replace_sysroot "$libdir" 757406f32fbeSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 7575ea133fd7Smrg case "$finalize_rpath " in 7576ea133fd7Smrg *" $libdir "*) ;; 757706f32fbeSmrg *) func_append finalize_rpath " $libdir" ;; 7578ea133fd7Smrg esac 7579ea133fd7Smrg done 7580ea133fd7Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 7581ea133fd7Smrg dependency_libs="$temp_xrpath $dependency_libs" 7582ea133fd7Smrg fi 7583ea133fd7Smrg fi 7584ea133fd7Smrg 7585ea133fd7Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 7586ea133fd7Smrg old_dlfiles="$dlfiles" 7587ea133fd7Smrg dlfiles= 7588ea133fd7Smrg for lib in $old_dlfiles; do 7589ea133fd7Smrg case " $dlprefiles $dlfiles " in 7590ea133fd7Smrg *" $lib "*) ;; 759106f32fbeSmrg *) func_append dlfiles " $lib" ;; 7592ea133fd7Smrg esac 7593ea133fd7Smrg done 7594ea133fd7Smrg 7595ea133fd7Smrg # Make sure dlprefiles contains only unique files 7596ea133fd7Smrg old_dlprefiles="$dlprefiles" 7597ea133fd7Smrg dlprefiles= 7598ea133fd7Smrg for lib in $old_dlprefiles; do 7599ea133fd7Smrg case "$dlprefiles " in 7600ea133fd7Smrg *" $lib "*) ;; 760106f32fbeSmrg *) func_append dlprefiles " $lib" ;; 7602ea133fd7Smrg esac 7603ea133fd7Smrg done 7604ea133fd7Smrg 7605ea133fd7Smrg if test "$build_libtool_libs" = yes; then 7606ea133fd7Smrg if test -n "$rpath"; then 7607ea133fd7Smrg case $host in 760825b89263Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 7609ea133fd7Smrg # these systems don't actually have a c library (as such)! 7610ea133fd7Smrg ;; 7611ea133fd7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7612ea133fd7Smrg # Rhapsody C library is in the System framework 761306f32fbeSmrg func_append deplibs " System.ltframework" 7614ea133fd7Smrg ;; 7615ea133fd7Smrg *-*-netbsd*) 7616ea133fd7Smrg # Don't link with libc until the a.out ld.so is fixed. 7617ea133fd7Smrg ;; 7618ea133fd7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 7619ea133fd7Smrg # Do not include libc due to us having libc/libc_r. 7620ea133fd7Smrg ;; 7621ea133fd7Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7622ea133fd7Smrg # Causes problems with __ctype 7623ea133fd7Smrg ;; 7624ea133fd7Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7625ea133fd7Smrg # Compiler inserts libc in the correct place for threads to work 7626ea133fd7Smrg ;; 7627ea133fd7Smrg *) 7628ea133fd7Smrg # Add libc to deplibs on all other systems if necessary. 7629ea133fd7Smrg if test "$build_libtool_need_lc" = "yes"; then 763006f32fbeSmrg func_append deplibs " -lc" 7631ea133fd7Smrg fi 7632ea133fd7Smrg ;; 7633ea133fd7Smrg esac 7634ea133fd7Smrg fi 7635ea133fd7Smrg 7636ea133fd7Smrg # Transform deplibs into only deplibs that can be linked in shared. 7637ea133fd7Smrg name_save=$name 7638ea133fd7Smrg libname_save=$libname 7639ea133fd7Smrg release_save=$release 7640ea133fd7Smrg versuffix_save=$versuffix 7641ea133fd7Smrg major_save=$major 7642ea133fd7Smrg # I'm not sure if I'm treating the release correctly. I think 7643ea133fd7Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 7644ea133fd7Smrg # add it in twice. Is that correct? 7645ea133fd7Smrg release="" 7646ea133fd7Smrg versuffix="" 7647ea133fd7Smrg major="" 7648ea133fd7Smrg newdeplibs= 7649ea133fd7Smrg droppeddeps=no 7650ea133fd7Smrg case $deplibs_check_method in 7651ea133fd7Smrg pass_all) 7652ea133fd7Smrg # Don't check for shared/static. Everything works. 7653ea133fd7Smrg # This might be a little naive. We might want to check 7654ea133fd7Smrg # whether the library exists or not. But this is on 7655ea133fd7Smrg # osf3 & osf4 and I'm not really sure... Just 7656ea133fd7Smrg # implementing what was already the behavior. 7657ea133fd7Smrg newdeplibs=$deplibs 7658ea133fd7Smrg ;; 7659ea133fd7Smrg test_compile) 7660ea133fd7Smrg # This code stresses the "libraries are programs" paradigm to its 7661ea133fd7Smrg # limits. Maybe even breaks it. We compile a program, linking it 7662ea133fd7Smrg # against the deplibs as a proxy for the library. Then we can check 7663ea133fd7Smrg # whether they linked in statically or dynamically with ldd. 7664ea133fd7Smrg $opt_dry_run || $RM conftest.c 7665ea133fd7Smrg cat > conftest.c <<EOF 7666ea133fd7Smrg int main() { return 0; } 7667ea133fd7SmrgEOF 7668ea133fd7Smrg $opt_dry_run || $RM conftest 7669ea133fd7Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 7670ea133fd7Smrg ldd_output=`ldd conftest` 7671ea133fd7Smrg for i in $deplibs; do 7672ea133fd7Smrg case $i in 7673ea133fd7Smrg -l*) 7674ea133fd7Smrg func_stripname -l '' "$i" 7675ea133fd7Smrg name=$func_stripname_result 7676ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7677ea133fd7Smrg case " $predeps $postdeps " in 7678ea133fd7Smrg *" $i "*) 767906f32fbeSmrg func_append newdeplibs " $i" 7680ea133fd7Smrg i="" 7681ea133fd7Smrg ;; 7682ea133fd7Smrg esac 7683ea133fd7Smrg fi 7684ea133fd7Smrg if test -n "$i" ; then 7685ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7686ea133fd7Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7687ea133fd7Smrg set dummy $deplib_matches; shift 7688ea133fd7Smrg deplib_match=$1 7689ea133fd7Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 769006f32fbeSmrg func_append newdeplibs " $i" 7691ea133fd7Smrg else 7692ea133fd7Smrg droppeddeps=yes 769325b89263Smrg echo 7694ea133fd7Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 769525b89263Smrg echo "*** I have the capability to make that library automatically link in when" 769625b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 769725b89263Smrg echo "*** shared version of the library, which I believe you do not have" 769825b89263Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 769925b89263Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 7700ea133fd7Smrg fi 7701ea133fd7Smrg fi 7702ea133fd7Smrg ;; 7703ea133fd7Smrg *) 770406f32fbeSmrg func_append newdeplibs " $i" 7705ea133fd7Smrg ;; 7706ea133fd7Smrg esac 7707ea133fd7Smrg done 7708ea133fd7Smrg else 7709ea133fd7Smrg # Error occurred in the first compile. Let's try to salvage 7710ea133fd7Smrg # the situation: Compile a separate program for each library. 7711ea133fd7Smrg for i in $deplibs; do 7712ea133fd7Smrg case $i in 7713ea133fd7Smrg -l*) 7714ea133fd7Smrg func_stripname -l '' "$i" 7715ea133fd7Smrg name=$func_stripname_result 7716ea133fd7Smrg $opt_dry_run || $RM conftest 7717ea133fd7Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 7718ea133fd7Smrg ldd_output=`ldd conftest` 7719ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7720ea133fd7Smrg case " $predeps $postdeps " in 7721ea133fd7Smrg *" $i "*) 772206f32fbeSmrg func_append newdeplibs " $i" 7723ea133fd7Smrg i="" 7724ea133fd7Smrg ;; 7725ea133fd7Smrg esac 7726ea133fd7Smrg fi 7727ea133fd7Smrg if test -n "$i" ; then 7728ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7729ea133fd7Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7730ea133fd7Smrg set dummy $deplib_matches; shift 7731ea133fd7Smrg deplib_match=$1 7732ea133fd7Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 773306f32fbeSmrg func_append newdeplibs " $i" 7734ea133fd7Smrg else 7735ea133fd7Smrg droppeddeps=yes 773625b89263Smrg echo 7737ea133fd7Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 773825b89263Smrg echo "*** I have the capability to make that library automatically link in when" 773925b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 774025b89263Smrg echo "*** shared version of the library, which you do not appear to have" 774125b89263Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 774225b89263Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 7743ea133fd7Smrg fi 7744ea133fd7Smrg fi 7745ea133fd7Smrg else 7746ea133fd7Smrg droppeddeps=yes 774725b89263Smrg echo 7748ea133fd7Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 774925b89263Smrg echo "*** make it link in! You will probably need to install it or some" 775025b89263Smrg echo "*** library that it depends on before this library will be fully" 775125b89263Smrg echo "*** functional. Installing it before continuing would be even better." 7752ea133fd7Smrg fi 7753ea133fd7Smrg ;; 7754ea133fd7Smrg *) 775506f32fbeSmrg func_append newdeplibs " $i" 7756ea133fd7Smrg ;; 7757ea133fd7Smrg esac 7758ea133fd7Smrg done 7759ea133fd7Smrg fi 7760ea133fd7Smrg ;; 7761ea133fd7Smrg file_magic*) 7762ea133fd7Smrg set dummy $deplibs_check_method; shift 7763ea133fd7Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7764ea133fd7Smrg for a_deplib in $deplibs; do 7765ea133fd7Smrg case $a_deplib in 7766ea133fd7Smrg -l*) 7767ea133fd7Smrg func_stripname -l '' "$a_deplib" 7768ea133fd7Smrg name=$func_stripname_result 7769ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7770ea133fd7Smrg case " $predeps $postdeps " in 7771ea133fd7Smrg *" $a_deplib "*) 777206f32fbeSmrg func_append newdeplibs " $a_deplib" 7773ea133fd7Smrg a_deplib="" 7774ea133fd7Smrg ;; 7775ea133fd7Smrg esac 7776ea133fd7Smrg fi 7777ea133fd7Smrg if test -n "$a_deplib" ; then 7778ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 777906f32fbeSmrg if test -n "$file_magic_glob"; then 778006f32fbeSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 778106f32fbeSmrg else 778206f32fbeSmrg libnameglob=$libname 778306f32fbeSmrg fi 778406f32fbeSmrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 7785ea133fd7Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 778606f32fbeSmrg if test "$want_nocaseglob" = yes; then 778706f32fbeSmrg shopt -s nocaseglob 778806f32fbeSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 778906f32fbeSmrg $nocaseglob 779006f32fbeSmrg else 779106f32fbeSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 779206f32fbeSmrg fi 7793ea133fd7Smrg for potent_lib in $potential_libs; do 7794ea133fd7Smrg # Follow soft links. 7795ea133fd7Smrg if ls -lLd "$potent_lib" 2>/dev/null | 7796ea133fd7Smrg $GREP " -> " >/dev/null; then 7797ea133fd7Smrg continue 7798ea133fd7Smrg fi 7799ea133fd7Smrg # The statement above tries to avoid entering an 7800ea133fd7Smrg # endless loop below, in case of cyclic links. 7801ea133fd7Smrg # We might still enter an endless loop, since a link 7802ea133fd7Smrg # loop can be closed while we follow links, 7803ea133fd7Smrg # but so what? 7804ea133fd7Smrg potlib="$potent_lib" 7805ea133fd7Smrg while test -h "$potlib" 2>/dev/null; do 7806ea133fd7Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 7807ea133fd7Smrg case $potliblink in 7808ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 780925b89263Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 7810ea133fd7Smrg esac 7811ea133fd7Smrg done 7812ea133fd7Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 7813ea133fd7Smrg $SED -e 10q | 7814ea133fd7Smrg $EGREP "$file_magic_regex" > /dev/null; then 781506f32fbeSmrg func_append newdeplibs " $a_deplib" 7816ea133fd7Smrg a_deplib="" 7817ea133fd7Smrg break 2 7818ea133fd7Smrg fi 7819ea133fd7Smrg done 7820ea133fd7Smrg done 7821ea133fd7Smrg fi 7822ea133fd7Smrg if test -n "$a_deplib" ; then 7823ea133fd7Smrg droppeddeps=yes 782425b89263Smrg echo 7825ea133fd7Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 782625b89263Smrg echo "*** I have the capability to make that library automatically link in when" 782725b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 782825b89263Smrg echo "*** shared version of the library, which you do not appear to have" 782925b89263Smrg echo "*** because I did check the linker path looking for a file starting" 7830ea133fd7Smrg if test -z "$potlib" ; then 7831ea133fd7Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 7832ea133fd7Smrg else 7833ea133fd7Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7834ea133fd7Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 7835ea133fd7Smrg fi 7836ea133fd7Smrg fi 7837ea133fd7Smrg ;; 7838ea133fd7Smrg *) 7839ea133fd7Smrg # Add a -L argument. 784006f32fbeSmrg func_append newdeplibs " $a_deplib" 7841ea133fd7Smrg ;; 7842ea133fd7Smrg esac 7843ea133fd7Smrg done # Gone through all deplibs. 7844ea133fd7Smrg ;; 7845ea133fd7Smrg match_pattern*) 7846ea133fd7Smrg set dummy $deplibs_check_method; shift 7847ea133fd7Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7848ea133fd7Smrg for a_deplib in $deplibs; do 7849ea133fd7Smrg case $a_deplib in 7850ea133fd7Smrg -l*) 7851ea133fd7Smrg func_stripname -l '' "$a_deplib" 7852ea133fd7Smrg name=$func_stripname_result 7853ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7854ea133fd7Smrg case " $predeps $postdeps " in 7855ea133fd7Smrg *" $a_deplib "*) 785606f32fbeSmrg func_append newdeplibs " $a_deplib" 7857ea133fd7Smrg a_deplib="" 7858ea133fd7Smrg ;; 7859ea133fd7Smrg esac 7860ea133fd7Smrg fi 7861ea133fd7Smrg if test -n "$a_deplib" ; then 7862ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7863ea133fd7Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7864ea133fd7Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 7865ea133fd7Smrg for potent_lib in $potential_libs; do 7866ea133fd7Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 786725b89263Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 7868ea133fd7Smrg $EGREP "$match_pattern_regex" > /dev/null; then 786906f32fbeSmrg func_append newdeplibs " $a_deplib" 7870ea133fd7Smrg a_deplib="" 7871ea133fd7Smrg break 2 7872ea133fd7Smrg fi 7873ea133fd7Smrg done 7874ea133fd7Smrg done 7875ea133fd7Smrg fi 7876ea133fd7Smrg if test -n "$a_deplib" ; then 7877ea133fd7Smrg droppeddeps=yes 787825b89263Smrg echo 7879ea133fd7Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 788025b89263Smrg echo "*** I have the capability to make that library automatically link in when" 788125b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 788225b89263Smrg echo "*** shared version of the library, which you do not appear to have" 788325b89263Smrg echo "*** because I did check the linker path looking for a file starting" 7884ea133fd7Smrg if test -z "$potlib" ; then 7885ea133fd7Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 7886ea133fd7Smrg else 7887ea133fd7Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7888ea133fd7Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 7889ea133fd7Smrg fi 7890ea133fd7Smrg fi 7891ea133fd7Smrg ;; 7892ea133fd7Smrg *) 7893ea133fd7Smrg # Add a -L argument. 789406f32fbeSmrg func_append newdeplibs " $a_deplib" 7895ea133fd7Smrg ;; 7896ea133fd7Smrg esac 7897ea133fd7Smrg done # Gone through all deplibs. 7898ea133fd7Smrg ;; 7899ea133fd7Smrg none | unknown | *) 7900ea133fd7Smrg newdeplibs="" 790125b89263Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7902ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7903ea133fd7Smrg for i in $predeps $postdeps ; do 7904ea133fd7Smrg # can't use Xsed below, because $i might contain '/' 790525b89263Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 7906ea133fd7Smrg done 7907ea133fd7Smrg fi 790825b89263Smrg case $tmp_deplibs in 790925b89263Smrg *[!\ \ ]*) 791025b89263Smrg echo 7911ea133fd7Smrg if test "X$deplibs_check_method" = "Xnone"; then 791225b89263Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 7913ea133fd7Smrg else 791425b89263Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 7915ea133fd7Smrg fi 791625b89263Smrg echo "*** All declared inter-library dependencies are being dropped." 7917ea133fd7Smrg droppeddeps=yes 791825b89263Smrg ;; 791925b89263Smrg esac 7920ea133fd7Smrg ;; 7921ea133fd7Smrg esac 7922ea133fd7Smrg versuffix=$versuffix_save 7923ea133fd7Smrg major=$major_save 7924ea133fd7Smrg release=$release_save 7925ea133fd7Smrg libname=$libname_save 7926ea133fd7Smrg name=$name_save 7927ea133fd7Smrg 7928ea133fd7Smrg case $host in 7929ea133fd7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7930ea133fd7Smrg # On Rhapsody replace the C library with the System framework 793125b89263Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 7932ea133fd7Smrg ;; 7933ea133fd7Smrg esac 7934ea133fd7Smrg 7935ea133fd7Smrg if test "$droppeddeps" = yes; then 7936ea133fd7Smrg if test "$module" = yes; then 793725b89263Smrg echo 793825b89263Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 7939ea133fd7Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 794025b89263Smrg echo "*** a static module, that should work as long as the dlopening" 794125b89263Smrg echo "*** application is linked with the -dlopen flag." 7942ea133fd7Smrg if test -z "$global_symbol_pipe"; then 794325b89263Smrg echo 794425b89263Smrg echo "*** However, this would only work if libtool was able to extract symbol" 794525b89263Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 794625b89263Smrg echo "*** not find such a program. So, this module is probably useless." 794725b89263Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 7948ea133fd7Smrg fi 7949ea133fd7Smrg if test "$build_old_libs" = no; then 7950ea133fd7Smrg oldlibs="$output_objdir/$libname.$libext" 7951ea133fd7Smrg build_libtool_libs=module 7952ea133fd7Smrg build_old_libs=yes 7953ea133fd7Smrg else 7954ea133fd7Smrg build_libtool_libs=no 7955ea133fd7Smrg fi 7956ea133fd7Smrg else 795725b89263Smrg echo "*** The inter-library dependencies that have been dropped here will be" 795825b89263Smrg echo "*** automatically added whenever a program is linked with this library" 795925b89263Smrg echo "*** or is declared to -dlopen it." 7960ea133fd7Smrg 7961ea133fd7Smrg if test "$allow_undefined" = no; then 796225b89263Smrg echo 796325b89263Smrg echo "*** Since this library must not contain undefined symbols," 796425b89263Smrg echo "*** because either the platform does not support them or" 796525b89263Smrg echo "*** it was explicitly requested with -no-undefined," 796625b89263Smrg echo "*** libtool will only create a static version of it." 7967ea133fd7Smrg if test "$build_old_libs" = no; then 7968ea133fd7Smrg oldlibs="$output_objdir/$libname.$libext" 7969ea133fd7Smrg build_libtool_libs=module 7970ea133fd7Smrg build_old_libs=yes 7971ea133fd7Smrg else 7972ea133fd7Smrg build_libtool_libs=no 7973ea133fd7Smrg fi 7974ea133fd7Smrg fi 7975ea133fd7Smrg fi 7976ea133fd7Smrg fi 7977ea133fd7Smrg # Done checking deplibs! 7978ea133fd7Smrg deplibs=$newdeplibs 7979ea133fd7Smrg fi 7980ea133fd7Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 7981ea133fd7Smrg case $host in 7982ea133fd7Smrg *-*-darwin*) 798325b89263Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 798425b89263Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 798525b89263Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7986ea133fd7Smrg ;; 7987ea133fd7Smrg esac 7988ea133fd7Smrg 7989ea133fd7Smrg # move library search paths that coincide with paths to not yet 7990ea133fd7Smrg # installed libraries to the beginning of the library search list 7991ea133fd7Smrg new_libs= 7992ea133fd7Smrg for path in $notinst_path; do 7993ea133fd7Smrg case " $new_libs " in 7994ea133fd7Smrg *" -L$path/$objdir "*) ;; 7995ea133fd7Smrg *) 7996ea133fd7Smrg case " $deplibs " in 7997ea133fd7Smrg *" -L$path/$objdir "*) 799806f32fbeSmrg func_append new_libs " -L$path/$objdir" ;; 7999ea133fd7Smrg esac 8000ea133fd7Smrg ;; 8001ea133fd7Smrg esac 8002ea133fd7Smrg done 8003ea133fd7Smrg for deplib in $deplibs; do 8004ea133fd7Smrg case $deplib in 8005ea133fd7Smrg -L*) 8006ea133fd7Smrg case " $new_libs " in 8007ea133fd7Smrg *" $deplib "*) ;; 800806f32fbeSmrg *) func_append new_libs " $deplib" ;; 8009ea133fd7Smrg esac 8010ea133fd7Smrg ;; 801106f32fbeSmrg *) func_append new_libs " $deplib" ;; 8012ea133fd7Smrg esac 8013ea133fd7Smrg done 8014ea133fd7Smrg deplibs="$new_libs" 8015ea133fd7Smrg 8016ea133fd7Smrg # All the library-specific variables (install_libdir is set above). 8017ea133fd7Smrg library_names= 8018ea133fd7Smrg old_library= 8019ea133fd7Smrg dlname= 8020ea133fd7Smrg 8021ea133fd7Smrg # Test again, we may have decided not to build it any more 8022ea133fd7Smrg if test "$build_libtool_libs" = yes; then 8023ea133fd7Smrg if test "$hardcode_into_libs" = yes; then 8024ea133fd7Smrg # Hardcode the library paths 8025ea133fd7Smrg hardcode_libdirs= 8026ea133fd7Smrg dep_rpath= 8027ea133fd7Smrg rpath="$finalize_rpath" 802806f32fbeSmrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 8029ea133fd7Smrg for libdir in $rpath; do 8030ea133fd7Smrg if test -n "$hardcode_libdir_flag_spec"; then 8031ea133fd7Smrg if test -n "$hardcode_libdir_separator"; then 803206f32fbeSmrg func_replace_sysroot "$libdir" 803306f32fbeSmrg libdir=$func_replace_sysroot_result 8034ea133fd7Smrg if test -z "$hardcode_libdirs"; then 8035ea133fd7Smrg hardcode_libdirs="$libdir" 8036ea133fd7Smrg else 8037ea133fd7Smrg # Just accumulate the unique libdirs. 8038ea133fd7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8039ea133fd7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8040ea133fd7Smrg ;; 8041ea133fd7Smrg *) 804206f32fbeSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8043ea133fd7Smrg ;; 8044ea133fd7Smrg esac 8045ea133fd7Smrg fi 8046ea133fd7Smrg else 8047ea133fd7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 804806f32fbeSmrg func_append dep_rpath " $flag" 8049ea133fd7Smrg fi 8050ea133fd7Smrg elif test -n "$runpath_var"; then 8051ea133fd7Smrg case "$perm_rpath " in 8052ea133fd7Smrg *" $libdir "*) ;; 805306f32fbeSmrg *) func_apped perm_rpath " $libdir" ;; 8054ea133fd7Smrg esac 8055ea133fd7Smrg fi 8056ea133fd7Smrg done 8057ea133fd7Smrg # Substitute the hardcoded libdirs into the rpath. 8058ea133fd7Smrg if test -n "$hardcode_libdir_separator" && 8059ea133fd7Smrg test -n "$hardcode_libdirs"; then 8060ea133fd7Smrg libdir="$hardcode_libdirs" 8061ea133fd7Smrg if test -n "$hardcode_libdir_flag_spec_ld"; then 8062ea133fd7Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 8063ea133fd7Smrg else 8064ea133fd7Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec\" 8065ea133fd7Smrg fi 8066ea133fd7Smrg fi 8067ea133fd7Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 8068ea133fd7Smrg # We should set the runpath_var. 8069ea133fd7Smrg rpath= 8070ea133fd7Smrg for dir in $perm_rpath; do 807106f32fbeSmrg func_append rpath "$dir:" 8072ea133fd7Smrg done 8073ea133fd7Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 8074ea133fd7Smrg fi 8075ea133fd7Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 8076ea133fd7Smrg fi 8077a253d6aeSmrg 8078ea133fd7Smrg shlibpath="$finalize_shlibpath" 807906f32fbeSmrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 8080ea133fd7Smrg if test -n "$shlibpath"; then 8081ea133fd7Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 8082ea133fd7Smrg fi 8083a253d6aeSmrg 8084ea133fd7Smrg # Get the real and link names of the library. 8085ea133fd7Smrg eval shared_ext=\"$shrext_cmds\" 8086ea133fd7Smrg eval library_names=\"$library_names_spec\" 8087ea133fd7Smrg set dummy $library_names 8088ea133fd7Smrg shift 8089ea133fd7Smrg realname="$1" 8090ea133fd7Smrg shift 8091a253d6aeSmrg 8092ea133fd7Smrg if test -n "$soname_spec"; then 8093ea133fd7Smrg eval soname=\"$soname_spec\" 8094ea133fd7Smrg else 8095ea133fd7Smrg soname="$realname" 8096ea133fd7Smrg fi 8097ea133fd7Smrg if test -z "$dlname"; then 8098ea133fd7Smrg dlname=$soname 8099ea133fd7Smrg fi 8100a253d6aeSmrg 8101ea133fd7Smrg lib="$output_objdir/$realname" 8102ea133fd7Smrg linknames= 8103ea133fd7Smrg for link 8104ea133fd7Smrg do 810506f32fbeSmrg func_append linknames " $link" 8106ea133fd7Smrg done 8107a253d6aeSmrg 8108ea133fd7Smrg # Use standard objects if they are pic 810925b89263Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 8110ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 8111a253d6aeSmrg 8112ea133fd7Smrg delfiles= 8113ea133fd7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8114ea133fd7Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 8115ea133fd7Smrg export_symbols="$output_objdir/$libname.uexp" 811606f32fbeSmrg func_append delfiles " $export_symbols" 8117ea133fd7Smrg fi 8118a253d6aeSmrg 8119ea133fd7Smrg orig_export_symbols= 8120ea133fd7Smrg case $host_os in 8121ea133fd7Smrg cygwin* | mingw* | cegcc*) 8122ea133fd7Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 8123ea133fd7Smrg # exporting using user supplied symfile 8124ea133fd7Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 8125ea133fd7Smrg # and it's NOT already a .def file. Must figure out 8126ea133fd7Smrg # which of the given symbols are data symbols and tag 8127ea133fd7Smrg # them as such. So, trigger use of export_symbols_cmds. 8128ea133fd7Smrg # export_symbols gets reassigned inside the "prepare 8129ea133fd7Smrg # the list of exported symbols" if statement, so the 8130ea133fd7Smrg # include_expsyms logic still works. 8131ea133fd7Smrg orig_export_symbols="$export_symbols" 8132ea133fd7Smrg export_symbols= 8133ea133fd7Smrg always_export_symbols=yes 8134ea133fd7Smrg fi 8135ea133fd7Smrg fi 8136ea133fd7Smrg ;; 8137ea133fd7Smrg esac 8138a253d6aeSmrg 8139ea133fd7Smrg # Prepare the list of exported symbols 8140ea133fd7Smrg if test -z "$export_symbols"; then 8141ea133fd7Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 8142ea133fd7Smrg func_verbose "generating symbol list for \`$libname.la'" 8143ea133fd7Smrg export_symbols="$output_objdir/$libname.exp" 8144ea133fd7Smrg $opt_dry_run || $RM $export_symbols 8145ea133fd7Smrg cmds=$export_symbols_cmds 8146ea133fd7Smrg save_ifs="$IFS"; IFS='~' 814706f32fbeSmrg for cmd1 in $cmds; do 8148ea133fd7Smrg IFS="$save_ifs" 814906f32fbeSmrg # Take the normal branch if the nm_file_list_spec branch 815006f32fbeSmrg # doesn't work or if tool conversion is not needed. 815106f32fbeSmrg case $nm_file_list_spec~$to_tool_file_cmd in 815206f32fbeSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 815306f32fbeSmrg try_normal_branch=yes 815406f32fbeSmrg eval cmd=\"$cmd1\" 815506f32fbeSmrg func_len " $cmd" 815606f32fbeSmrg len=$func_len_result 815706f32fbeSmrg ;; 815806f32fbeSmrg *) 815906f32fbeSmrg try_normal_branch=no 816006f32fbeSmrg ;; 816106f32fbeSmrg esac 816206f32fbeSmrg if test "$try_normal_branch" = yes \ 816306f32fbeSmrg && { test "$len" -lt "$max_cmd_len" \ 816406f32fbeSmrg || test "$max_cmd_len" -le -1; } 816506f32fbeSmrg then 816606f32fbeSmrg func_show_eval "$cmd" 'exit $?' 816706f32fbeSmrg skipped_export=false 816806f32fbeSmrg elif test -n "$nm_file_list_spec"; then 816906f32fbeSmrg func_basename "$output" 817006f32fbeSmrg output_la=$func_basename_result 817106f32fbeSmrg save_libobjs=$libobjs 817206f32fbeSmrg save_output=$output 817306f32fbeSmrg output=${output_objdir}/${output_la}.nm 817406f32fbeSmrg func_to_tool_file "$output" 817506f32fbeSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 817606f32fbeSmrg func_append delfiles " $output" 817706f32fbeSmrg func_verbose "creating $NM input file list: $output" 817806f32fbeSmrg for obj in $save_libobjs; do 817906f32fbeSmrg func_to_tool_file "$obj" 818006f32fbeSmrg $ECHO "$func_to_tool_file_result" 818106f32fbeSmrg done > "$output" 818206f32fbeSmrg eval cmd=\"$cmd1\" 8183ea133fd7Smrg func_show_eval "$cmd" 'exit $?' 818406f32fbeSmrg output=$save_output 818506f32fbeSmrg libobjs=$save_libobjs 8186ea133fd7Smrg skipped_export=false 8187ea133fd7Smrg else 8188ea133fd7Smrg # The command line is too long to execute in one step. 8189ea133fd7Smrg func_verbose "using reloadable object file for export list..." 8190ea133fd7Smrg skipped_export=: 8191ea133fd7Smrg # Break out early, otherwise skipped_export may be 8192ea133fd7Smrg # set to false by a later but shorter cmd. 8193ea133fd7Smrg break 8194ea133fd7Smrg fi 8195ea133fd7Smrg done 8196ea133fd7Smrg IFS="$save_ifs" 8197ea133fd7Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 8198ea133fd7Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8199ea133fd7Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8200ea133fd7Smrg fi 8201ea133fd7Smrg fi 8202ea133fd7Smrg fi 8203a253d6aeSmrg 8204ea133fd7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8205ea133fd7Smrg tmp_export_symbols="$export_symbols" 8206ea133fd7Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 820725b89263Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8208ea133fd7Smrg fi 8209a253d6aeSmrg 8210ea133fd7Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 8211ea133fd7Smrg # The given exports_symbols file has to be filtered, so filter it. 8212ea133fd7Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8213ea133fd7Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8214ea133fd7Smrg # 's' commands which not all seds can handle. GNU sed should be fine 8215ea133fd7Smrg # though. Also, the filter scales superlinearly with the number of 8216ea133fd7Smrg # global variables. join(1) would be nice here, but unfortunately 8217ea133fd7Smrg # isn't a blessed tool. 8218ea133fd7Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 821906f32fbeSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8220ea133fd7Smrg export_symbols=$output_objdir/$libname.def 8221ea133fd7Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8222a253d6aeSmrg fi 8223a253d6aeSmrg 8224ea133fd7Smrg tmp_deplibs= 8225ea133fd7Smrg for test_deplib in $deplibs; do 8226ea133fd7Smrg case " $convenience " in 8227ea133fd7Smrg *" $test_deplib "*) ;; 8228ea133fd7Smrg *) 822906f32fbeSmrg func_append tmp_deplibs " $test_deplib" 8230ea133fd7Smrg ;; 8231ea133fd7Smrg esac 8232ea133fd7Smrg done 8233ea133fd7Smrg deplibs="$tmp_deplibs" 8234a253d6aeSmrg 8235ea133fd7Smrg if test -n "$convenience"; then 8236ea133fd7Smrg if test -n "$whole_archive_flag_spec" && 8237ea133fd7Smrg test "$compiler_needs_object" = yes && 8238ea133fd7Smrg test -z "$libobjs"; then 8239ea133fd7Smrg # extract the archives, so we have objects to list. 8240ea133fd7Smrg # TODO: could optimize this to just extract one archive. 8241ea133fd7Smrg whole_archive_flag_spec= 8242ea133fd7Smrg fi 8243ea133fd7Smrg if test -n "$whole_archive_flag_spec"; then 8244ea133fd7Smrg save_libobjs=$libobjs 8245ea133fd7Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8246ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 8247ea133fd7Smrg else 8248ea133fd7Smrg gentop="$output_objdir/${outputname}x" 824906f32fbeSmrg func_append generated " $gentop" 8250a253d6aeSmrg 8251ea133fd7Smrg func_extract_archives $gentop $convenience 825206f32fbeSmrg func_append libobjs " $func_extract_archives_result" 8253ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 8254ea133fd7Smrg fi 8255ea133fd7Smrg fi 8256a253d6aeSmrg 8257ea133fd7Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 8258ea133fd7Smrg eval flag=\"$thread_safe_flag_spec\" 825906f32fbeSmrg func_append linker_flags " $flag" 8260ea133fd7Smrg fi 8261a253d6aeSmrg 8262ea133fd7Smrg # Make a backup of the uninstalled library when relinking 826306f32fbeSmrg if test "$opt_mode" = relink; then 8264ea133fd7Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 8265a253d6aeSmrg fi 8266a253d6aeSmrg 8267ea133fd7Smrg # Do each of the archive commands. 8268ea133fd7Smrg if test "$module" = yes && test -n "$module_cmds" ; then 8269ea133fd7Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8270ea133fd7Smrg eval test_cmds=\"$module_expsym_cmds\" 8271ea133fd7Smrg cmds=$module_expsym_cmds 8272ea133fd7Smrg else 8273ea133fd7Smrg eval test_cmds=\"$module_cmds\" 8274ea133fd7Smrg cmds=$module_cmds 8275ea133fd7Smrg fi 8276ea133fd7Smrg else 8277ea133fd7Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8278ea133fd7Smrg eval test_cmds=\"$archive_expsym_cmds\" 8279ea133fd7Smrg cmds=$archive_expsym_cmds 8280ea133fd7Smrg else 8281ea133fd7Smrg eval test_cmds=\"$archive_cmds\" 8282ea133fd7Smrg cmds=$archive_cmds 8283ea133fd7Smrg fi 8284a253d6aeSmrg fi 8285a253d6aeSmrg 8286ea133fd7Smrg if test "X$skipped_export" != "X:" && 8287ea133fd7Smrg func_len " $test_cmds" && 8288ea133fd7Smrg len=$func_len_result && 8289ea133fd7Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8290ea133fd7Smrg : 8291ea133fd7Smrg else 8292ea133fd7Smrg # The command line is too long to link in one step, link piecewise 8293ea133fd7Smrg # or, if using GNU ld and skipped_export is not :, use a linker 8294ea133fd7Smrg # script. 8295a253d6aeSmrg 8296ea133fd7Smrg # Save the value of $output and $libobjs because we want to 8297ea133fd7Smrg # use them later. If we have whole_archive_flag_spec, we 8298ea133fd7Smrg # want to use save_libobjs as it was before 8299ea133fd7Smrg # whole_archive_flag_spec was expanded, because we can't 8300ea133fd7Smrg # assume the linker understands whole_archive_flag_spec. 8301ea133fd7Smrg # This may have to be revisited, in case too many 8302ea133fd7Smrg # convenience libraries get linked in and end up exceeding 8303ea133fd7Smrg # the spec. 8304ea133fd7Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 8305ea133fd7Smrg save_libobjs=$libobjs 8306ea133fd7Smrg fi 8307ea133fd7Smrg save_output=$output 830825b89263Smrg func_basename "$output" 830925b89263Smrg output_la=$func_basename_result 8310a253d6aeSmrg 8311ea133fd7Smrg # Clear the reloadable object creation command queue and 8312ea133fd7Smrg # initialize k to one. 8313ea133fd7Smrg test_cmds= 8314ea133fd7Smrg concat_cmds= 8315ea133fd7Smrg objlist= 8316ea133fd7Smrg last_robj= 8317ea133fd7Smrg k=1 8318a253d6aeSmrg 8319ea133fd7Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 8320ea133fd7Smrg output=${output_objdir}/${output_la}.lnkscript 8321ea133fd7Smrg func_verbose "creating GNU ld script: $output" 832225b89263Smrg echo 'INPUT (' > $output 8323ea133fd7Smrg for obj in $save_libobjs 8324ea133fd7Smrg do 832506f32fbeSmrg func_to_tool_file "$obj" 832606f32fbeSmrg $ECHO "$func_to_tool_file_result" >> $output 8327ea133fd7Smrg done 832825b89263Smrg echo ')' >> $output 832906f32fbeSmrg func_append delfiles " $output" 833006f32fbeSmrg func_to_tool_file "$output" 833106f32fbeSmrg output=$func_to_tool_file_result 8332ea133fd7Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 8333ea133fd7Smrg output=${output_objdir}/${output_la}.lnk 8334ea133fd7Smrg func_verbose "creating linker input file list: $output" 8335ea133fd7Smrg : > $output 8336ea133fd7Smrg set x $save_libobjs 8337ea133fd7Smrg shift 8338ea133fd7Smrg firstobj= 8339ea133fd7Smrg if test "$compiler_needs_object" = yes; then 8340ea133fd7Smrg firstobj="$1 " 8341ea133fd7Smrg shift 8342ea133fd7Smrg fi 8343ea133fd7Smrg for obj 8344ea133fd7Smrg do 834506f32fbeSmrg func_to_tool_file "$obj" 834606f32fbeSmrg $ECHO "$func_to_tool_file_result" >> $output 8347ea133fd7Smrg done 834806f32fbeSmrg func_append delfiles " $output" 834906f32fbeSmrg func_to_tool_file "$output" 835006f32fbeSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 8351ea133fd7Smrg else 8352ea133fd7Smrg if test -n "$save_libobjs"; then 8353ea133fd7Smrg func_verbose "creating reloadable object files..." 8354ea133fd7Smrg output=$output_objdir/$output_la-${k}.$objext 8355ea133fd7Smrg eval test_cmds=\"$reload_cmds\" 8356ea133fd7Smrg func_len " $test_cmds" 8357ea133fd7Smrg len0=$func_len_result 8358ea133fd7Smrg len=$len0 8359ea133fd7Smrg 8360ea133fd7Smrg # Loop over the list of objects to be linked. 8361ea133fd7Smrg for obj in $save_libobjs 8362ea133fd7Smrg do 8363ea133fd7Smrg func_len " $obj" 8364ea133fd7Smrg func_arith $len + $func_len_result 8365ea133fd7Smrg len=$func_arith_result 8366ea133fd7Smrg if test "X$objlist" = X || 8367ea133fd7Smrg test "$len" -lt "$max_cmd_len"; then 8368ea133fd7Smrg func_append objlist " $obj" 8369ea133fd7Smrg else 8370ea133fd7Smrg # The command $test_cmds is almost too long, add a 8371ea133fd7Smrg # command to the queue. 8372ea133fd7Smrg if test "$k" -eq 1 ; then 8373ea133fd7Smrg # The first file doesn't have a previous command to add. 837425b89263Smrg reload_objs=$objlist 837525b89263Smrg eval concat_cmds=\"$reload_cmds\" 8376ea133fd7Smrg else 8377ea133fd7Smrg # All subsequent reloadable object files will link in 8378ea133fd7Smrg # the last one created. 837925b89263Smrg reload_objs="$objlist $last_robj" 838025b89263Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 8381ea133fd7Smrg fi 8382ea133fd7Smrg last_robj=$output_objdir/$output_la-${k}.$objext 8383ea133fd7Smrg func_arith $k + 1 8384ea133fd7Smrg k=$func_arith_result 8385ea133fd7Smrg output=$output_objdir/$output_la-${k}.$objext 838625b89263Smrg objlist=" $obj" 8387ea133fd7Smrg func_len " $last_robj" 8388ea133fd7Smrg func_arith $len0 + $func_len_result 8389ea133fd7Smrg len=$func_arith_result 8390ea133fd7Smrg fi 8391ea133fd7Smrg done 8392ea133fd7Smrg # Handle the remaining objects by creating one last 8393ea133fd7Smrg # reloadable object file. All subsequent reloadable object 8394ea133fd7Smrg # files will link in the last one created. 8395ea133fd7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 839625b89263Smrg reload_objs="$objlist $last_robj" 839725b89263Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 8398ea133fd7Smrg if test -n "$last_robj"; then 8399ea133fd7Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8400ea133fd7Smrg fi 840106f32fbeSmrg func_append delfiles " $output" 8402a253d6aeSmrg 8403ea133fd7Smrg else 8404ea133fd7Smrg output= 8405ea133fd7Smrg fi 8406a253d6aeSmrg 8407ea133fd7Smrg if ${skipped_export-false}; then 8408ea133fd7Smrg func_verbose "generating symbol list for \`$libname.la'" 8409ea133fd7Smrg export_symbols="$output_objdir/$libname.exp" 8410ea133fd7Smrg $opt_dry_run || $RM $export_symbols 8411ea133fd7Smrg libobjs=$output 8412ea133fd7Smrg # Append the command to create the export file. 8413ea133fd7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8414ea133fd7Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 8415ea133fd7Smrg if test -n "$last_robj"; then 8416ea133fd7Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8417ea133fd7Smrg fi 8418ea133fd7Smrg fi 8419a253d6aeSmrg 8420ea133fd7Smrg test -n "$save_libobjs" && 8421ea133fd7Smrg func_verbose "creating a temporary reloadable object file: $output" 8422a253d6aeSmrg 8423ea133fd7Smrg # Loop through the commands generated above and execute them. 8424ea133fd7Smrg save_ifs="$IFS"; IFS='~' 8425ea133fd7Smrg for cmd in $concat_cmds; do 8426ea133fd7Smrg IFS="$save_ifs" 8427ea133fd7Smrg $opt_silent || { 8428ea133fd7Smrg func_quote_for_expand "$cmd" 8429ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 8430ea133fd7Smrg } 8431ea133fd7Smrg $opt_dry_run || eval "$cmd" || { 8432ea133fd7Smrg lt_exit=$? 8433ea133fd7Smrg 8434ea133fd7Smrg # Restore the uninstalled library and exit 843506f32fbeSmrg if test "$opt_mode" = relink; then 8436ea133fd7Smrg ( cd "$output_objdir" && \ 8437ea133fd7Smrg $RM "${realname}T" && \ 8438ea133fd7Smrg $MV "${realname}U" "$realname" ) 8439ea133fd7Smrg fi 8440a253d6aeSmrg 8441ea133fd7Smrg exit $lt_exit 8442ea133fd7Smrg } 8443ea133fd7Smrg done 8444ea133fd7Smrg IFS="$save_ifs" 8445ea133fd7Smrg 8446ea133fd7Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 8447ea133fd7Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8448ea133fd7Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8449a253d6aeSmrg fi 8450a253d6aeSmrg fi 8451a253d6aeSmrg 8452ea133fd7Smrg if ${skipped_export-false}; then 8453ea133fd7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8454ea133fd7Smrg tmp_export_symbols="$export_symbols" 8455ea133fd7Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 845625b89263Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8457ea133fd7Smrg fi 8458a253d6aeSmrg 8459ea133fd7Smrg if test -n "$orig_export_symbols"; then 8460ea133fd7Smrg # The given exports_symbols file has to be filtered, so filter it. 8461ea133fd7Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8462ea133fd7Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8463ea133fd7Smrg # 's' commands which not all seds can handle. GNU sed should be fine 8464ea133fd7Smrg # though. Also, the filter scales superlinearly with the number of 8465ea133fd7Smrg # global variables. join(1) would be nice here, but unfortunately 8466ea133fd7Smrg # isn't a blessed tool. 8467ea133fd7Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 846806f32fbeSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8469ea133fd7Smrg export_symbols=$output_objdir/$libname.def 8470ea133fd7Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8471ea133fd7Smrg fi 8472ea133fd7Smrg fi 8473a253d6aeSmrg 8474ea133fd7Smrg libobjs=$output 8475ea133fd7Smrg # Restore the value of output. 8476ea133fd7Smrg output=$save_output 8477a253d6aeSmrg 8478ea133fd7Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 8479ea133fd7Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8480ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 8481ea133fd7Smrg fi 8482ea133fd7Smrg # Expand the library linking commands again to reset the 8483ea133fd7Smrg # value of $libobjs for piecewise linking. 8484ea133fd7Smrg 8485ea133fd7Smrg # Do each of the archive commands. 8486ea133fd7Smrg if test "$module" = yes && test -n "$module_cmds" ; then 8487ea133fd7Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8488ea133fd7Smrg cmds=$module_expsym_cmds 8489a253d6aeSmrg else 8490ea133fd7Smrg cmds=$module_cmds 8491a253d6aeSmrg fi 8492a253d6aeSmrg else 8493ea133fd7Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8494ea133fd7Smrg cmds=$archive_expsym_cmds 8495ea133fd7Smrg else 8496ea133fd7Smrg cmds=$archive_cmds 8497ea133fd7Smrg fi 8498a253d6aeSmrg fi 8499a253d6aeSmrg fi 8500a253d6aeSmrg 8501ea133fd7Smrg if test -n "$delfiles"; then 8502ea133fd7Smrg # Append the command to remove temporary files to $cmds. 8503ea133fd7Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 8504ea133fd7Smrg fi 8505a253d6aeSmrg 8506ea133fd7Smrg # Add any objects from preloaded convenience libraries 8507ea133fd7Smrg if test -n "$dlprefiles"; then 8508ea133fd7Smrg gentop="$output_objdir/${outputname}x" 850906f32fbeSmrg func_append generated " $gentop" 8510a253d6aeSmrg 8511ea133fd7Smrg func_extract_archives $gentop $dlprefiles 851206f32fbeSmrg func_append libobjs " $func_extract_archives_result" 8513ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 8514a253d6aeSmrg fi 8515a253d6aeSmrg 8516ea133fd7Smrg save_ifs="$IFS"; IFS='~' 8517ea133fd7Smrg for cmd in $cmds; do 8518ea133fd7Smrg IFS="$save_ifs" 8519ea133fd7Smrg eval cmd=\"$cmd\" 8520ea133fd7Smrg $opt_silent || { 8521ea133fd7Smrg func_quote_for_expand "$cmd" 8522ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 8523ea133fd7Smrg } 8524ea133fd7Smrg $opt_dry_run || eval "$cmd" || { 8525ea133fd7Smrg lt_exit=$? 8526a253d6aeSmrg 8527ea133fd7Smrg # Restore the uninstalled library and exit 852806f32fbeSmrg if test "$opt_mode" = relink; then 8529ea133fd7Smrg ( cd "$output_objdir" && \ 8530ea133fd7Smrg $RM "${realname}T" && \ 8531ea133fd7Smrg $MV "${realname}U" "$realname" ) 8532ea133fd7Smrg fi 8533ea133fd7Smrg 8534ea133fd7Smrg exit $lt_exit 8535ea133fd7Smrg } 8536ea133fd7Smrg done 8537ea133fd7Smrg IFS="$save_ifs" 8538ea133fd7Smrg 8539ea133fd7Smrg # Restore the uninstalled library and exit 854006f32fbeSmrg if test "$opt_mode" = relink; then 8541ea133fd7Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8542ea133fd7Smrg 8543ea133fd7Smrg if test -n "$convenience"; then 8544ea133fd7Smrg if test -z "$whole_archive_flag_spec"; then 8545ea133fd7Smrg func_show_eval '${RM}r "$gentop"' 8546a253d6aeSmrg fi 8547a253d6aeSmrg fi 8548a253d6aeSmrg 8549ea133fd7Smrg exit $EXIT_SUCCESS 8550ea133fd7Smrg fi 8551a253d6aeSmrg 8552ea133fd7Smrg # Create links to the real library. 8553ea133fd7Smrg for linkname in $linknames; do 8554ea133fd7Smrg if test "$realname" != "$linkname"; then 8555ea133fd7Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8556ea133fd7Smrg fi 8557ea133fd7Smrg done 8558ea133fd7Smrg 8559ea133fd7Smrg # If -module or -export-dynamic was specified, set the dlname. 8560ea133fd7Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 8561ea133fd7Smrg # On all known operating systems, these are identical. 8562ea133fd7Smrg dlname="$soname" 8563ea133fd7Smrg fi 8564ea133fd7Smrg fi 8565ea133fd7Smrg ;; 8566ea133fd7Smrg 8567ea133fd7Smrg obj) 8568ea133fd7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 8569ea133fd7Smrg func_warning "\`-dlopen' is ignored for objects" 8570ea133fd7Smrg fi 8571ea133fd7Smrg 8572ea133fd7Smrg case " $deplibs" in 8573ea133fd7Smrg *\ -l* | *\ -L*) 8574ea133fd7Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 8575ea133fd7Smrg esac 8576ea133fd7Smrg 8577ea133fd7Smrg test -n "$rpath" && \ 8578ea133fd7Smrg func_warning "\`-rpath' is ignored for objects" 8579ea133fd7Smrg 8580ea133fd7Smrg test -n "$xrpath" && \ 8581ea133fd7Smrg func_warning "\`-R' is ignored for objects" 8582ea133fd7Smrg 8583ea133fd7Smrg test -n "$vinfo" && \ 8584ea133fd7Smrg func_warning "\`-version-info' is ignored for objects" 8585ea133fd7Smrg 8586ea133fd7Smrg test -n "$release" && \ 8587ea133fd7Smrg func_warning "\`-release' is ignored for objects" 8588ea133fd7Smrg 8589ea133fd7Smrg case $output in 8590ea133fd7Smrg *.lo) 8591ea133fd7Smrg test -n "$objs$old_deplibs" && \ 8592ea133fd7Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 8593ea133fd7Smrg 8594ea133fd7Smrg libobj=$output 8595ea133fd7Smrg func_lo2o "$libobj" 8596ea133fd7Smrg obj=$func_lo2o_result 8597ea133fd7Smrg ;; 8598ea133fd7Smrg *) 8599ea133fd7Smrg libobj= 8600ea133fd7Smrg obj="$output" 8601ea133fd7Smrg ;; 8602ea133fd7Smrg esac 8603ea133fd7Smrg 8604ea133fd7Smrg # Delete the old objects. 8605ea133fd7Smrg $opt_dry_run || $RM $obj $libobj 8606ea133fd7Smrg 8607ea133fd7Smrg # Objects from convenience libraries. This assumes 8608ea133fd7Smrg # single-version convenience libraries. Whenever we create 8609ea133fd7Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 8610ea133fd7Smrg # the extraction. 8611ea133fd7Smrg reload_conv_objs= 8612ea133fd7Smrg gentop= 8613ea133fd7Smrg # reload_cmds runs $LD directly, so let us get rid of 8614ea133fd7Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 8615ea133fd7Smrg # turning comma into space.. 8616ea133fd7Smrg wl= 8617ea133fd7Smrg 8618ea133fd7Smrg if test -n "$convenience"; then 8619ea133fd7Smrg if test -n "$whole_archive_flag_spec"; then 8620ea133fd7Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 862125b89263Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 8622ea133fd7Smrg else 8623ea133fd7Smrg gentop="$output_objdir/${obj}x" 862406f32fbeSmrg func_append generated " $gentop" 8625ea133fd7Smrg 8626ea133fd7Smrg func_extract_archives $gentop $convenience 8627ea133fd7Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 8628ea133fd7Smrg fi 8629ea133fd7Smrg fi 8630a253d6aeSmrg 863106f32fbeSmrg # If we're not building shared, we need to use non_pic_objs 863206f32fbeSmrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 863306f32fbeSmrg 8634ea133fd7Smrg # Create the old-style object. 863525b89263Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8636a253d6aeSmrg 8637ea133fd7Smrg output="$obj" 8638ea133fd7Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8639a253d6aeSmrg 8640ea133fd7Smrg # Exit if we aren't doing a library object file. 8641ea133fd7Smrg if test -z "$libobj"; then 8642ea133fd7Smrg if test -n "$gentop"; then 8643ea133fd7Smrg func_show_eval '${RM}r "$gentop"' 8644ea133fd7Smrg fi 8645a253d6aeSmrg 8646ea133fd7Smrg exit $EXIT_SUCCESS 8647ea133fd7Smrg fi 8648a253d6aeSmrg 8649ea133fd7Smrg if test "$build_libtool_libs" != yes; then 8650ea133fd7Smrg if test -n "$gentop"; then 8651ea133fd7Smrg func_show_eval '${RM}r "$gentop"' 8652ea133fd7Smrg fi 8653a253d6aeSmrg 8654ea133fd7Smrg # Create an invalid libtool object if no PIC, so that we don't 8655ea133fd7Smrg # accidentally link it into a program. 8656ea133fd7Smrg # $show "echo timestamp > $libobj" 8657ea133fd7Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 8658ea133fd7Smrg exit $EXIT_SUCCESS 8659ea133fd7Smrg fi 8660a253d6aeSmrg 8661ea133fd7Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 8662ea133fd7Smrg # Only do commands if we really have different PIC objects. 8663ea133fd7Smrg reload_objs="$libobjs $reload_conv_objs" 8664ea133fd7Smrg output="$libobj" 8665ea133fd7Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8666a253d6aeSmrg fi 8667a253d6aeSmrg 8668ea133fd7Smrg if test -n "$gentop"; then 8669ea133fd7Smrg func_show_eval '${RM}r "$gentop"' 8670ea133fd7Smrg fi 8671a253d6aeSmrg 8672ea133fd7Smrg exit $EXIT_SUCCESS 8673ea133fd7Smrg ;; 8674a253d6aeSmrg 8675ea133fd7Smrg prog) 8676ea133fd7Smrg case $host in 8677ea133fd7Smrg *cygwin*) func_stripname '' '.exe' "$output" 8678ea133fd7Smrg output=$func_stripname_result.exe;; 8679a253d6aeSmrg esac 8680ea133fd7Smrg test -n "$vinfo" && \ 8681ea133fd7Smrg func_warning "\`-version-info' is ignored for programs" 8682a253d6aeSmrg 8683ea133fd7Smrg test -n "$release" && \ 8684ea133fd7Smrg func_warning "\`-release' is ignored for programs" 8685a253d6aeSmrg 8686ea133fd7Smrg test "$preload" = yes \ 8687ea133fd7Smrg && test "$dlopen_support" = unknown \ 8688ea133fd7Smrg && test "$dlopen_self" = unknown \ 8689ea133fd7Smrg && test "$dlopen_self_static" = unknown && \ 8690ea133fd7Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 8691a253d6aeSmrg 8692ea133fd7Smrg case $host in 8693ea133fd7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 8694ea133fd7Smrg # On Rhapsody replace the C library is the System framework 869525b89263Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 869625b89263Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8697a253d6aeSmrg ;; 8698a253d6aeSmrg esac 8699a253d6aeSmrg 8700ea133fd7Smrg case $host in 8701ea133fd7Smrg *-*-darwin*) 8702ea133fd7Smrg # Don't allow lazy linking, it breaks C++ global constructors 8703ea133fd7Smrg # But is supposedly fixed on 10.4 or later (yay!). 8704ea133fd7Smrg if test "$tagname" = CXX ; then 8705ea133fd7Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 8706ea133fd7Smrg 10.[0123]) 870706f32fbeSmrg func_append compile_command " ${wl}-bind_at_load" 870806f32fbeSmrg func_append finalize_command " ${wl}-bind_at_load" 8709ea133fd7Smrg ;; 8710ea133fd7Smrg esac 8711ea133fd7Smrg fi 8712ea133fd7Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 871325b89263Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 871425b89263Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8715a253d6aeSmrg ;; 8716a253d6aeSmrg esac 8717a253d6aeSmrg 8718a253d6aeSmrg 8719ea133fd7Smrg # move library search paths that coincide with paths to not yet 8720ea133fd7Smrg # installed libraries to the beginning of the library search list 8721ea133fd7Smrg new_libs= 8722ea133fd7Smrg for path in $notinst_path; do 8723ea133fd7Smrg case " $new_libs " in 8724ea133fd7Smrg *" -L$path/$objdir "*) ;; 8725a253d6aeSmrg *) 8726ea133fd7Smrg case " $compile_deplibs " in 8727ea133fd7Smrg *" -L$path/$objdir "*) 872806f32fbeSmrg func_append new_libs " -L$path/$objdir" ;; 8729ea133fd7Smrg esac 8730a253d6aeSmrg ;; 8731a253d6aeSmrg esac 8732a253d6aeSmrg done 8733ea133fd7Smrg for deplib in $compile_deplibs; do 8734ea133fd7Smrg case $deplib in 8735ea133fd7Smrg -L*) 8736ea133fd7Smrg case " $new_libs " in 8737ea133fd7Smrg *" $deplib "*) ;; 873806f32fbeSmrg *) func_append new_libs " $deplib" ;; 8739ea133fd7Smrg esac 8740ea133fd7Smrg ;; 874106f32fbeSmrg *) func_append new_libs " $deplib" ;; 8742ea133fd7Smrg esac 8743ea133fd7Smrg done 8744ea133fd7Smrg compile_deplibs="$new_libs" 8745a253d6aeSmrg 8746a253d6aeSmrg 874706f32fbeSmrg func_append compile_command " $compile_deplibs" 874806f32fbeSmrg func_append finalize_command " $finalize_deplibs" 8749a253d6aeSmrg 8750ea133fd7Smrg if test -n "$rpath$xrpath"; then 8751ea133fd7Smrg # If the user specified any rpath flags, then add them. 8752ea133fd7Smrg for libdir in $rpath $xrpath; do 8753ea133fd7Smrg # This is the magic to use -rpath. 8754ea133fd7Smrg case "$finalize_rpath " in 8755ea133fd7Smrg *" $libdir "*) ;; 875606f32fbeSmrg *) func_append finalize_rpath " $libdir" ;; 8757ea133fd7Smrg esac 8758ea133fd7Smrg done 8759ea133fd7Smrg fi 8760a253d6aeSmrg 8761ea133fd7Smrg # Now hardcode the library paths 8762ea133fd7Smrg rpath= 8763ea133fd7Smrg hardcode_libdirs= 8764ea133fd7Smrg for libdir in $compile_rpath $finalize_rpath; do 8765ea133fd7Smrg if test -n "$hardcode_libdir_flag_spec"; then 8766ea133fd7Smrg if test -n "$hardcode_libdir_separator"; then 8767ea133fd7Smrg if test -z "$hardcode_libdirs"; then 8768ea133fd7Smrg hardcode_libdirs="$libdir" 8769ea133fd7Smrg else 8770ea133fd7Smrg # Just accumulate the unique libdirs. 8771ea133fd7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8772ea133fd7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8773ea133fd7Smrg ;; 8774ea133fd7Smrg *) 877506f32fbeSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8776ea133fd7Smrg ;; 8777ea133fd7Smrg esac 8778ea133fd7Smrg fi 8779ea133fd7Smrg else 8780ea133fd7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 878106f32fbeSmrg func_append rpath " $flag" 8782ea133fd7Smrg fi 8783ea133fd7Smrg elif test -n "$runpath_var"; then 8784ea133fd7Smrg case "$perm_rpath " in 8785a253d6aeSmrg *" $libdir "*) ;; 878606f32fbeSmrg *) func_append perm_rpath " $libdir" ;; 8787a253d6aeSmrg esac 8788ea133fd7Smrg fi 8789ea133fd7Smrg case $host in 8790ea133fd7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 8791ea133fd7Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 8792ea133fd7Smrg case :$dllsearchpath: in 8793ea133fd7Smrg *":$libdir:"*) ;; 8794ea133fd7Smrg ::) dllsearchpath=$libdir;; 879506f32fbeSmrg *) func_append dllsearchpath ":$libdir";; 8796ea133fd7Smrg esac 8797ea133fd7Smrg case :$dllsearchpath: in 8798ea133fd7Smrg *":$testbindir:"*) ;; 8799ea133fd7Smrg ::) dllsearchpath=$testbindir;; 880006f32fbeSmrg *) func_append dllsearchpath ":$testbindir";; 8801ea133fd7Smrg esac 8802ea133fd7Smrg ;; 8803ea133fd7Smrg esac 8804ea133fd7Smrg done 8805ea133fd7Smrg # Substitute the hardcoded libdirs into the rpath. 8806ea133fd7Smrg if test -n "$hardcode_libdir_separator" && 8807ea133fd7Smrg test -n "$hardcode_libdirs"; then 8808ea133fd7Smrg libdir="$hardcode_libdirs" 8809ea133fd7Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 8810ea133fd7Smrg fi 8811ea133fd7Smrg compile_rpath="$rpath" 8812ea133fd7Smrg 8813ea133fd7Smrg rpath= 8814ea133fd7Smrg hardcode_libdirs= 8815ea133fd7Smrg for libdir in $finalize_rpath; do 8816ea133fd7Smrg if test -n "$hardcode_libdir_flag_spec"; then 8817ea133fd7Smrg if test -n "$hardcode_libdir_separator"; then 8818ea133fd7Smrg if test -z "$hardcode_libdirs"; then 8819ea133fd7Smrg hardcode_libdirs="$libdir" 8820ea133fd7Smrg else 8821ea133fd7Smrg # Just accumulate the unique libdirs. 8822ea133fd7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8823ea133fd7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8824ea133fd7Smrg ;; 8825ea133fd7Smrg *) 882606f32fbeSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8827ea133fd7Smrg ;; 8828ea133fd7Smrg esac 8829ea133fd7Smrg fi 8830ea133fd7Smrg else 8831ea133fd7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 883206f32fbeSmrg func_append rpath " $flag" 8833ea133fd7Smrg fi 8834ea133fd7Smrg elif test -n "$runpath_var"; then 8835ea133fd7Smrg case "$finalize_perm_rpath " in 8836a253d6aeSmrg *" $libdir "*) ;; 883706f32fbeSmrg *) func_append finalize_perm_rpath " $libdir" ;; 8838a253d6aeSmrg esac 8839a253d6aeSmrg fi 8840ea133fd7Smrg done 8841ea133fd7Smrg # Substitute the hardcoded libdirs into the rpath. 8842ea133fd7Smrg if test -n "$hardcode_libdir_separator" && 8843ea133fd7Smrg test -n "$hardcode_libdirs"; then 8844ea133fd7Smrg libdir="$hardcode_libdirs" 8845ea133fd7Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 8846ea133fd7Smrg fi 8847ea133fd7Smrg finalize_rpath="$rpath" 8848a253d6aeSmrg 8849ea133fd7Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 8850ea133fd7Smrg # Transform all the library objects into standard objects. 885125b89263Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 885225b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8853ea133fd7Smrg fi 8854a253d6aeSmrg 8855ea133fd7Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8856a253d6aeSmrg 8857ea133fd7Smrg # template prelinking step 8858ea133fd7Smrg if test -n "$prelink_cmds"; then 8859ea133fd7Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 8860ea133fd7Smrg fi 8861a253d6aeSmrg 8862ea133fd7Smrg wrappers_required=yes 8863ea133fd7Smrg case $host in 886425b89263Smrg *cegcc* | *mingw32ce*) 886525b89263Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 886625b89263Smrg wrappers_required=no 886725b89263Smrg ;; 8868ea133fd7Smrg *cygwin* | *mingw* ) 8869ea133fd7Smrg if test "$build_libtool_libs" != yes; then 8870ea133fd7Smrg wrappers_required=no 8871ea133fd7Smrg fi 8872ea133fd7Smrg ;; 8873ea133fd7Smrg *) 8874ea133fd7Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8875ea133fd7Smrg wrappers_required=no 8876ea133fd7Smrg fi 8877ea133fd7Smrg ;; 8878ea133fd7Smrg esac 8879ea133fd7Smrg if test "$wrappers_required" = no; then 8880ea133fd7Smrg # Replace the output file specification. 888125b89263Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8882ea133fd7Smrg link_command="$compile_command$compile_rpath" 8883a253d6aeSmrg 8884ea133fd7Smrg # We have no uninstalled library dependencies, so finalize right now. 8885ea133fd7Smrg exit_status=0 8886ea133fd7Smrg func_show_eval "$link_command" 'exit_status=$?' 8887a253d6aeSmrg 888806f32fbeSmrg if test -n "$postlink_cmds"; then 888906f32fbeSmrg func_to_tool_file "$output" 889006f32fbeSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 889106f32fbeSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 889206f32fbeSmrg fi 889306f32fbeSmrg 8894ea133fd7Smrg # Delete the generated files. 8895ea133fd7Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 8896ea133fd7Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8897ea133fd7Smrg fi 8898a253d6aeSmrg 8899ea133fd7Smrg exit $exit_status 8900ea133fd7Smrg fi 8901a253d6aeSmrg 8902ea133fd7Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 8903ea133fd7Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 8904ea133fd7Smrg fi 8905ea133fd7Smrg if test -n "$finalize_shlibpath"; then 8906ea133fd7Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 8907ea133fd7Smrg fi 8908a253d6aeSmrg 8909ea133fd7Smrg compile_var= 8910ea133fd7Smrg finalize_var= 8911ea133fd7Smrg if test -n "$runpath_var"; then 8912ea133fd7Smrg if test -n "$perm_rpath"; then 8913ea133fd7Smrg # We should set the runpath_var. 8914ea133fd7Smrg rpath= 8915ea133fd7Smrg for dir in $perm_rpath; do 891606f32fbeSmrg func_append rpath "$dir:" 8917a253d6aeSmrg done 8918ea133fd7Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8919a253d6aeSmrg fi 8920ea133fd7Smrg if test -n "$finalize_perm_rpath"; then 8921ea133fd7Smrg # We should set the runpath_var. 8922ea133fd7Smrg rpath= 8923ea133fd7Smrg for dir in $finalize_perm_rpath; do 892406f32fbeSmrg func_append rpath "$dir:" 8925ea133fd7Smrg done 8926ea133fd7Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8927ea133fd7Smrg fi 8928ea133fd7Smrg fi 8929a253d6aeSmrg 8930ea133fd7Smrg if test "$no_install" = yes; then 8931ea133fd7Smrg # We don't need to create a wrapper script. 8932ea133fd7Smrg link_command="$compile_var$compile_command$compile_rpath" 8933ea133fd7Smrg # Replace the output file specification. 893425b89263Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8935ea133fd7Smrg # Delete the old output file. 8936ea133fd7Smrg $opt_dry_run || $RM $output 8937ea133fd7Smrg # Link the executable and exit 8938ea133fd7Smrg func_show_eval "$link_command" 'exit $?' 893906f32fbeSmrg 894006f32fbeSmrg if test -n "$postlink_cmds"; then 894106f32fbeSmrg func_to_tool_file "$output" 894206f32fbeSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 894306f32fbeSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 894406f32fbeSmrg fi 894506f32fbeSmrg 8946ea133fd7Smrg exit $EXIT_SUCCESS 8947ea133fd7Smrg fi 8948a253d6aeSmrg 8949ea133fd7Smrg if test "$hardcode_action" = relink; then 8950ea133fd7Smrg # Fast installation is not supported 8951ea133fd7Smrg link_command="$compile_var$compile_command$compile_rpath" 8952ea133fd7Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8953a253d6aeSmrg 8954ea133fd7Smrg func_warning "this platform does not like uninstalled shared libraries" 8955ea133fd7Smrg func_warning "\`$output' will be relinked during installation" 8956ea133fd7Smrg else 8957ea133fd7Smrg if test "$fast_install" != no; then 8958ea133fd7Smrg link_command="$finalize_var$compile_command$finalize_rpath" 8959ea133fd7Smrg if test "$fast_install" = yes; then 896025b89263Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 8961ea133fd7Smrg else 8962ea133fd7Smrg # fast_install is set to needless 8963ea133fd7Smrg relink_command= 8964ea133fd7Smrg fi 8965a253d6aeSmrg else 8966ea133fd7Smrg link_command="$compile_var$compile_command$compile_rpath" 8967ea133fd7Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8968a253d6aeSmrg fi 8969ea133fd7Smrg fi 8970a253d6aeSmrg 8971ea133fd7Smrg # Replace the output file specification. 897225b89263Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8973a253d6aeSmrg 8974ea133fd7Smrg # Delete the old output files. 8975ea133fd7Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8976a253d6aeSmrg 8977ea133fd7Smrg func_show_eval "$link_command" 'exit $?' 8978a253d6aeSmrg 897906f32fbeSmrg if test -n "$postlink_cmds"; then 898006f32fbeSmrg func_to_tool_file "$output_objdir/$outputname" 898106f32fbeSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 898206f32fbeSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 898306f32fbeSmrg fi 898406f32fbeSmrg 8985ea133fd7Smrg # Now create the wrapper script. 8986ea133fd7Smrg func_verbose "creating $output" 8987a253d6aeSmrg 8988ea133fd7Smrg # Quote the relink command for shipping. 8989ea133fd7Smrg if test -n "$relink_command"; then 8990ea133fd7Smrg # Preserve any variables that may affect compiler behavior 8991ea133fd7Smrg for var in $variables_saved_for_relink; do 8992ea133fd7Smrg if eval test -z \"\${$var+set}\"; then 8993ea133fd7Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 8994ea133fd7Smrg elif eval var_value=\$$var; test -z "$var_value"; then 8995ea133fd7Smrg relink_command="$var=; export $var; $relink_command" 8996ea133fd7Smrg else 8997ea133fd7Smrg func_quote_for_eval "$var_value" 8998ea133fd7Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 8999ea133fd7Smrg fi 9000ea133fd7Smrg done 9001ea133fd7Smrg relink_command="(cd `pwd`; $relink_command)" 900225b89263Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9003ea133fd7Smrg fi 9004a253d6aeSmrg 9005ea133fd7Smrg # Only actually do things if not in dry run mode. 9006ea133fd7Smrg $opt_dry_run || { 9007ea133fd7Smrg # win32 will think the script is a binary if it has 9008ea133fd7Smrg # a .exe suffix, so we strip it off here. 9009ea133fd7Smrg case $output in 9010ea133fd7Smrg *.exe) func_stripname '' '.exe' "$output" 9011ea133fd7Smrg output=$func_stripname_result ;; 9012ea133fd7Smrg esac 9013ea133fd7Smrg # test for cygwin because mv fails w/o .exe extensions 9014a253d6aeSmrg case $host in 9015ea133fd7Smrg *cygwin*) 9016ea133fd7Smrg exeext=.exe 9017ea133fd7Smrg func_stripname '' '.exe' "$outputname" 9018ea133fd7Smrg outputname=$func_stripname_result ;; 9019ea133fd7Smrg *) exeext= ;; 9020a253d6aeSmrg esac 9021ea133fd7Smrg case $host in 9022ea133fd7Smrg *cygwin* | *mingw* ) 9023ea133fd7Smrg func_dirname_and_basename "$output" "" "." 9024ea133fd7Smrg output_name=$func_basename_result 9025ea133fd7Smrg output_path=$func_dirname_result 9026ea133fd7Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 9027ea133fd7Smrg cwrapper="$output_path/$output_name.exe" 9028ea133fd7Smrg $RM $cwrappersource $cwrapper 9029ea133fd7Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 9030ea133fd7Smrg 9031ea133fd7Smrg func_emit_cwrapperexe_src > $cwrappersource 9032ea133fd7Smrg 9033ea133fd7Smrg # The wrapper executable is built using the $host compiler, 9034ea133fd7Smrg # because it contains $host paths and files. If cross- 9035ea133fd7Smrg # compiling, it, like the target executable, must be 9036ea133fd7Smrg # executed on the $host or under an emulation environment. 9037ea133fd7Smrg $opt_dry_run || { 9038ea133fd7Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 9039ea133fd7Smrg $STRIP $cwrapper 9040ea133fd7Smrg } 9041a253d6aeSmrg 9042ea133fd7Smrg # Now, create the wrapper script for func_source use: 9043ea133fd7Smrg func_ltwrapper_scriptname $cwrapper 9044ea133fd7Smrg $RM $func_ltwrapper_scriptname_result 9045ea133fd7Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 9046ea133fd7Smrg $opt_dry_run || { 9047ea133fd7Smrg # note: this script will not be executed, so do not chmod. 9048ea133fd7Smrg if test "x$build" = "x$host" ; then 9049ea133fd7Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 9050a253d6aeSmrg else 9051ea133fd7Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 9052a253d6aeSmrg fi 9053ea133fd7Smrg } 9054ea133fd7Smrg ;; 9055ea133fd7Smrg * ) 9056ea133fd7Smrg $RM $output 9057ea133fd7Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9058a253d6aeSmrg 9059ea133fd7Smrg func_emit_wrapper no > $output 9060ea133fd7Smrg chmod +x $output 9061a253d6aeSmrg ;; 9062a253d6aeSmrg esac 9063ea133fd7Smrg } 9064ea133fd7Smrg exit $EXIT_SUCCESS 9065ea133fd7Smrg ;; 9066ea133fd7Smrg esac 9067a253d6aeSmrg 9068ea133fd7Smrg # See if we need to build an old-fashioned archive. 9069ea133fd7Smrg for oldlib in $oldlibs; do 9070a253d6aeSmrg 9071ea133fd7Smrg if test "$build_libtool_libs" = convenience; then 9072ea133fd7Smrg oldobjs="$libobjs_save $symfileobj" 9073ea133fd7Smrg addlibs="$convenience" 9074ea133fd7Smrg build_libtool_libs=no 9075ea133fd7Smrg else 9076ea133fd7Smrg if test "$build_libtool_libs" = module; then 9077ea133fd7Smrg oldobjs="$libobjs_save" 9078ea133fd7Smrg build_libtool_libs=no 9079ea133fd7Smrg else 9080ea133fd7Smrg oldobjs="$old_deplibs $non_pic_objects" 9081ea133fd7Smrg if test "$preload" = yes && test -f "$symfileobj"; then 908206f32fbeSmrg func_append oldobjs " $symfileobj" 9083ea133fd7Smrg fi 9084ea133fd7Smrg fi 9085ea133fd7Smrg addlibs="$old_convenience" 9086a253d6aeSmrg fi 9087a253d6aeSmrg 9088ea133fd7Smrg if test -n "$addlibs"; then 9089ea133fd7Smrg gentop="$output_objdir/${outputname}x" 909006f32fbeSmrg func_append generated " $gentop" 9091a253d6aeSmrg 9092ea133fd7Smrg func_extract_archives $gentop $addlibs 909306f32fbeSmrg func_append oldobjs " $func_extract_archives_result" 9094ea133fd7Smrg fi 9095a253d6aeSmrg 9096ea133fd7Smrg # Do each command in the archive commands. 9097ea133fd7Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 9098ea133fd7Smrg cmds=$old_archive_from_new_cmds 9099ea133fd7Smrg else 9100a253d6aeSmrg 9101ea133fd7Smrg # Add any objects from preloaded convenience libraries 9102ea133fd7Smrg if test -n "$dlprefiles"; then 9103ea133fd7Smrg gentop="$output_objdir/${outputname}x" 910406f32fbeSmrg func_append generated " $gentop" 9105a253d6aeSmrg 9106ea133fd7Smrg func_extract_archives $gentop $dlprefiles 910706f32fbeSmrg func_append oldobjs " $func_extract_archives_result" 9108ea133fd7Smrg fi 9109a253d6aeSmrg 9110ea133fd7Smrg # POSIX demands no paths to be encoded in archives. We have 9111ea133fd7Smrg # to avoid creating archives with duplicate basenames if we 9112ea133fd7Smrg # might have to extract them afterwards, e.g., when creating a 9113ea133fd7Smrg # static archive out of a convenience library, or when linking 9114ea133fd7Smrg # the entirety of a libtool archive into another (currently 9115ea133fd7Smrg # not supported by libtool). 9116ea133fd7Smrg if (for obj in $oldobjs 9117ea133fd7Smrg do 9118ea133fd7Smrg func_basename "$obj" 9119ea133fd7Smrg $ECHO "$func_basename_result" 9120ea133fd7Smrg done | sort | sort -uc >/dev/null 2>&1); then 9121ea133fd7Smrg : 9122ea133fd7Smrg else 912325b89263Smrg echo "copying selected object files to avoid basename conflicts..." 9124ea133fd7Smrg gentop="$output_objdir/${outputname}x" 912506f32fbeSmrg func_append generated " $gentop" 9126ea133fd7Smrg func_mkdir_p "$gentop" 9127ea133fd7Smrg save_oldobjs=$oldobjs 9128ea133fd7Smrg oldobjs= 9129ea133fd7Smrg counter=1 9130ea133fd7Smrg for obj in $save_oldobjs 9131ea133fd7Smrg do 9132ea133fd7Smrg func_basename "$obj" 9133ea133fd7Smrg objbase="$func_basename_result" 9134ea133fd7Smrg case " $oldobjs " in 9135ea133fd7Smrg " ") oldobjs=$obj ;; 9136ea133fd7Smrg *[\ /]"$objbase "*) 9137ea133fd7Smrg while :; do 9138ea133fd7Smrg # Make sure we don't pick an alternate name that also 9139ea133fd7Smrg # overlaps. 9140ea133fd7Smrg newobj=lt$counter-$objbase 9141ea133fd7Smrg func_arith $counter + 1 9142ea133fd7Smrg counter=$func_arith_result 9143ea133fd7Smrg case " $oldobjs " in 9144ea133fd7Smrg *[\ /]"$newobj "*) ;; 9145ea133fd7Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 9146ea133fd7Smrg esac 9147ea133fd7Smrg done 9148ea133fd7Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 914906f32fbeSmrg func_append oldobjs " $gentop/$newobj" 9150ea133fd7Smrg ;; 915106f32fbeSmrg *) func_append oldobjs " $obj" ;; 9152ea133fd7Smrg esac 9153a253d6aeSmrg done 9154a253d6aeSmrg fi 9155ea133fd7Smrg eval cmds=\"$old_archive_cmds\" 9156a253d6aeSmrg 9157ea133fd7Smrg func_len " $cmds" 9158ea133fd7Smrg len=$func_len_result 9159ea133fd7Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9160ea133fd7Smrg cmds=$old_archive_cmds 916106f32fbeSmrg elif test -n "$archiver_list_spec"; then 916206f32fbeSmrg func_verbose "using command file archive linking..." 916306f32fbeSmrg for obj in $oldobjs 916406f32fbeSmrg do 916506f32fbeSmrg func_to_tool_file "$obj" 916606f32fbeSmrg $ECHO "$func_to_tool_file_result" 916706f32fbeSmrg done > $output_objdir/$libname.libcmd 916806f32fbeSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 916906f32fbeSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 917006f32fbeSmrg cmds=$old_archive_cmds 9171ea133fd7Smrg else 9172ea133fd7Smrg # the command line is too long to link in one step, link in parts 9173ea133fd7Smrg func_verbose "using piecewise archive linking..." 9174ea133fd7Smrg save_RANLIB=$RANLIB 9175ea133fd7Smrg RANLIB=: 9176ea133fd7Smrg objlist= 9177ea133fd7Smrg concat_cmds= 9178ea133fd7Smrg save_oldobjs=$oldobjs 9179ea133fd7Smrg oldobjs= 9180ea133fd7Smrg # Is there a better way of finding the last object in the list? 9181ea133fd7Smrg for obj in $save_oldobjs 9182ea133fd7Smrg do 9183ea133fd7Smrg last_oldobj=$obj 9184ea133fd7Smrg done 9185ea133fd7Smrg eval test_cmds=\"$old_archive_cmds\" 9186ea133fd7Smrg func_len " $test_cmds" 9187ea133fd7Smrg len0=$func_len_result 9188ea133fd7Smrg len=$len0 9189ea133fd7Smrg for obj in $save_oldobjs 9190ea133fd7Smrg do 9191ea133fd7Smrg func_len " $obj" 9192ea133fd7Smrg func_arith $len + $func_len_result 9193ea133fd7Smrg len=$func_arith_result 9194ea133fd7Smrg func_append objlist " $obj" 9195ea133fd7Smrg if test "$len" -lt "$max_cmd_len"; then 9196ea133fd7Smrg : 9197ea133fd7Smrg else 9198ea133fd7Smrg # the above command should be used before it gets too long 9199ea133fd7Smrg oldobjs=$objlist 9200ea133fd7Smrg if test "$obj" = "$last_oldobj" ; then 9201ea133fd7Smrg RANLIB=$save_RANLIB 9202ea133fd7Smrg fi 9203ea133fd7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9204ea133fd7Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 9205ea133fd7Smrg objlist= 9206ea133fd7Smrg len=$len0 9207ea133fd7Smrg fi 9208ea133fd7Smrg done 9209ea133fd7Smrg RANLIB=$save_RANLIB 9210ea133fd7Smrg oldobjs=$objlist 9211ea133fd7Smrg if test "X$oldobjs" = "X" ; then 9212ea133fd7Smrg eval cmds=\"\$concat_cmds\" 9213ea133fd7Smrg else 9214ea133fd7Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 9215ea133fd7Smrg fi 9216ea133fd7Smrg fi 9217ea133fd7Smrg fi 9218ea133fd7Smrg func_execute_cmds "$cmds" 'exit $?' 9219a253d6aeSmrg done 9220a253d6aeSmrg 9221ea133fd7Smrg test -n "$generated" && \ 9222ea133fd7Smrg func_show_eval "${RM}r$generated" 9223a253d6aeSmrg 9224ea133fd7Smrg # Now create the libtool archive. 9225ea133fd7Smrg case $output in 9226ea133fd7Smrg *.la) 9227ea133fd7Smrg old_library= 9228ea133fd7Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 9229ea133fd7Smrg func_verbose "creating $output" 9230a253d6aeSmrg 9231ea133fd7Smrg # Preserve any variables that may affect compiler behavior 9232ea133fd7Smrg for var in $variables_saved_for_relink; do 9233ea133fd7Smrg if eval test -z \"\${$var+set}\"; then 9234ea133fd7Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9235ea133fd7Smrg elif eval var_value=\$$var; test -z "$var_value"; then 9236ea133fd7Smrg relink_command="$var=; export $var; $relink_command" 9237a253d6aeSmrg else 9238ea133fd7Smrg func_quote_for_eval "$var_value" 9239ea133fd7Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9240a253d6aeSmrg fi 9241ea133fd7Smrg done 9242ea133fd7Smrg # Quote the link command for shipping. 9243ea133fd7Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 924425b89263Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9245ea133fd7Smrg if test "$hardcode_automatic" = yes ; then 9246ea133fd7Smrg relink_command= 9247ea133fd7Smrg fi 9248a253d6aeSmrg 9249ea133fd7Smrg # Only create the output if not a dry run. 9250ea133fd7Smrg $opt_dry_run || { 9251ea133fd7Smrg for installed in no yes; do 9252ea133fd7Smrg if test "$installed" = yes; then 9253ea133fd7Smrg if test -z "$install_libdir"; then 9254ea133fd7Smrg break 9255ea133fd7Smrg fi 9256ea133fd7Smrg output="$output_objdir/$outputname"i 9257ea133fd7Smrg # Replace all uninstalled libtool libraries with the installed ones 9258ea133fd7Smrg newdependency_libs= 9259ea133fd7Smrg for deplib in $dependency_libs; do 9260ea133fd7Smrg case $deplib in 9261ea133fd7Smrg *.la) 9262ea133fd7Smrg func_basename "$deplib" 9263ea133fd7Smrg name="$func_basename_result" 9264ea133fd7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 9265ea133fd7Smrg test -z "$libdir" && \ 9266ea133fd7Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 926706f32fbeSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 926806f32fbeSmrg ;; 926906f32fbeSmrg -L*) 927006f32fbeSmrg func_stripname -L '' "$deplib" 927106f32fbeSmrg func_replace_sysroot "$func_stripname_result" 927206f32fbeSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 927306f32fbeSmrg ;; 927406f32fbeSmrg -R*) 927506f32fbeSmrg func_stripname -R '' "$deplib" 927606f32fbeSmrg func_replace_sysroot "$func_stripname_result" 927706f32fbeSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 9278ea133fd7Smrg ;; 927906f32fbeSmrg *) func_append newdependency_libs " $deplib" ;; 9280ea133fd7Smrg esac 9281ea133fd7Smrg done 9282ea133fd7Smrg dependency_libs="$newdependency_libs" 9283ea133fd7Smrg newdlfiles= 9284ea133fd7Smrg 9285ea133fd7Smrg for lib in $dlfiles; do 9286ea133fd7Smrg case $lib in 9287ea133fd7Smrg *.la) 9288ea133fd7Smrg func_basename "$lib" 9289ea133fd7Smrg name="$func_basename_result" 9290ea133fd7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9291ea133fd7Smrg test -z "$libdir" && \ 9292ea133fd7Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 929306f32fbeSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 9294ea133fd7Smrg ;; 929506f32fbeSmrg *) func_append newdlfiles " $lib" ;; 9296ea133fd7Smrg esac 9297ea133fd7Smrg done 9298ea133fd7Smrg dlfiles="$newdlfiles" 9299ea133fd7Smrg newdlprefiles= 9300ea133fd7Smrg for lib in $dlprefiles; do 9301ea133fd7Smrg case $lib in 9302ea133fd7Smrg *.la) 9303ea133fd7Smrg # Only pass preopened files to the pseudo-archive (for 9304ea133fd7Smrg # eventual linking with the app. that links it) if we 9305ea133fd7Smrg # didn't already link the preopened objects directly into 9306ea133fd7Smrg # the library: 9307ea133fd7Smrg func_basename "$lib" 9308ea133fd7Smrg name="$func_basename_result" 9309ea133fd7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9310ea133fd7Smrg test -z "$libdir" && \ 9311ea133fd7Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 931206f32fbeSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 9313ea133fd7Smrg ;; 9314ea133fd7Smrg esac 9315ea133fd7Smrg done 9316ea133fd7Smrg dlprefiles="$newdlprefiles" 9317ea133fd7Smrg else 9318ea133fd7Smrg newdlfiles= 9319ea133fd7Smrg for lib in $dlfiles; do 9320ea133fd7Smrg case $lib in 9321ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9322ea133fd7Smrg *) abs=`pwd`"/$lib" ;; 9323ea133fd7Smrg esac 932406f32fbeSmrg func_append newdlfiles " $abs" 9325ea133fd7Smrg done 9326ea133fd7Smrg dlfiles="$newdlfiles" 9327ea133fd7Smrg newdlprefiles= 9328ea133fd7Smrg for lib in $dlprefiles; do 9329ea133fd7Smrg case $lib in 9330ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9331ea133fd7Smrg *) abs=`pwd`"/$lib" ;; 9332ea133fd7Smrg esac 933306f32fbeSmrg func_append newdlprefiles " $abs" 9334ea133fd7Smrg done 9335ea133fd7Smrg dlprefiles="$newdlprefiles" 9336ea133fd7Smrg fi 9337ea133fd7Smrg $RM $output 9338ea133fd7Smrg # place dlname in correct position for cygwin 933925b89263Smrg # In fact, it would be nice if we could use this code for all target 934025b89263Smrg # systems that can't hard-code library paths into their executables 934125b89263Smrg # and that have no shared library path variable independent of PATH, 934225b89263Smrg # but it turns out we can't easily determine that from inspecting 934325b89263Smrg # libtool variables, so we have to hard-code the OSs to which it 934425b89263Smrg # applies here; at the moment, that means platforms that use the PE 934525b89263Smrg # object format with DLL files. See the long comment at the top of 934625b89263Smrg # tests/bindir.at for full details. 9347ea133fd7Smrg tdlname=$dlname 9348ea133fd7Smrg case $host,$output,$installed,$module,$dlname in 934925b89263Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 935025b89263Smrg # If a -bindir argument was supplied, place the dll there. 935125b89263Smrg if test "x$bindir" != x ; 935225b89263Smrg then 935325b89263Smrg func_relative_path "$install_libdir" "$bindir" 935425b89263Smrg tdlname=$func_relative_path_result$dlname 935525b89263Smrg else 935625b89263Smrg # Otherwise fall back on heuristic. 935725b89263Smrg tdlname=../bin/$dlname 935825b89263Smrg fi 935925b89263Smrg ;; 9360ea133fd7Smrg esac 9361ea133fd7Smrg $ECHO > $output "\ 9362ea133fd7Smrg# $outputname - a libtool library file 9363ea133fd7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 9364ea133fd7Smrg# 9365ea133fd7Smrg# Please DO NOT delete this file! 9366ea133fd7Smrg# It is necessary for linking the library. 9367a253d6aeSmrg 9368ea133fd7Smrg# The name that we can dlopen(3). 9369ea133fd7Smrgdlname='$tdlname' 9370a253d6aeSmrg 9371ea133fd7Smrg# Names of this library. 9372ea133fd7Smrglibrary_names='$library_names' 9373a253d6aeSmrg 9374ea133fd7Smrg# The name of the static archive. 9375ea133fd7Smrgold_library='$old_library' 9376a253d6aeSmrg 9377ea133fd7Smrg# Linker flags that can not go in dependency_libs. 9378ea133fd7Smrginherited_linker_flags='$new_inherited_linker_flags' 9379a253d6aeSmrg 9380ea133fd7Smrg# Libraries that this one depends upon. 9381ea133fd7Smrgdependency_libs='$dependency_libs' 9382a253d6aeSmrg 9383ea133fd7Smrg# Names of additional weak libraries provided by this library 9384ea133fd7Smrgweak_library_names='$weak_libs' 9385a253d6aeSmrg 9386ea133fd7Smrg# Version information for $libname. 9387ea133fd7Smrgcurrent=$current 9388ea133fd7Smrgage=$age 9389ea133fd7Smrgrevision=$revision 9390a253d6aeSmrg 9391ea133fd7Smrg# Is this an already installed library? 9392ea133fd7Smrginstalled=$installed 9393a253d6aeSmrg 9394ea133fd7Smrg# Should we warn about portability when linking against -modules? 9395ea133fd7Smrgshouldnotlink=$module 9396a253d6aeSmrg 9397ea133fd7Smrg# Files to dlopen/dlpreopen 9398ea133fd7Smrgdlopen='$dlfiles' 9399ea133fd7Smrgdlpreopen='$dlprefiles' 9400a253d6aeSmrg 9401ea133fd7Smrg# Directory that this library needs to be installed in: 9402ea133fd7Smrglibdir='$install_libdir'" 9403ea133fd7Smrg if test "$installed" = no && test "$need_relink" = yes; then 9404ea133fd7Smrg $ECHO >> $output "\ 9405ea133fd7Smrgrelink_command=\"$relink_command\"" 9406ea133fd7Smrg fi 9407ea133fd7Smrg done 9408ea133fd7Smrg } 9409a253d6aeSmrg 9410ea133fd7Smrg # Do a symbolic link so that the libtool archive can be found in 9411ea133fd7Smrg # LD_LIBRARY_PATH before the program is installed. 9412ea133fd7Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 9413ea133fd7Smrg ;; 9414ea133fd7Smrg esac 9415ea133fd7Smrg exit $EXIT_SUCCESS 9416ea133fd7Smrg} 9417a253d6aeSmrg 941806f32fbeSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 9419ea133fd7Smrg func_mode_link ${1+"$@"} 9420a253d6aeSmrg 9421a253d6aeSmrg 9422ea133fd7Smrg# func_mode_uninstall arg... 9423ea133fd7Smrgfunc_mode_uninstall () 9424ea133fd7Smrg{ 9425ea133fd7Smrg $opt_debug 9426ea133fd7Smrg RM="$nonopt" 9427a253d6aeSmrg files= 9428a253d6aeSmrg rmforce= 9429a253d6aeSmrg exit_status=0 9430a253d6aeSmrg 9431a253d6aeSmrg # This variable tells wrapper scripts just to set variables rather 9432a253d6aeSmrg # than running their programs. 9433a253d6aeSmrg libtool_install_magic="$magic" 9434a253d6aeSmrg 9435a253d6aeSmrg for arg 9436a253d6aeSmrg do 9437a253d6aeSmrg case $arg in 943806f32fbeSmrg -f) func_append RM " $arg"; rmforce=yes ;; 943906f32fbeSmrg -*) func_append RM " $arg" ;; 944006f32fbeSmrg *) func_append files " $arg" ;; 9441a253d6aeSmrg esac 9442a253d6aeSmrg done 9443a253d6aeSmrg 9444ea133fd7Smrg test -z "$RM" && \ 9445ea133fd7Smrg func_fatal_help "you must specify an RM program" 9446a253d6aeSmrg 9447a253d6aeSmrg rmdirs= 9448a253d6aeSmrg 9449a253d6aeSmrg for file in $files; do 9450ea133fd7Smrg func_dirname "$file" "" "." 9451ea133fd7Smrg dir="$func_dirname_result" 9452ea133fd7Smrg if test "X$dir" = X.; then 945306f32fbeSmrg odir="$objdir" 9454a253d6aeSmrg else 945506f32fbeSmrg odir="$dir/$objdir" 9456a253d6aeSmrg fi 9457ea133fd7Smrg func_basename "$file" 9458ea133fd7Smrg name="$func_basename_result" 945906f32fbeSmrg test "$opt_mode" = uninstall && odir="$dir" 9460a253d6aeSmrg 946106f32fbeSmrg # Remember odir for removal later, being careful to avoid duplicates 946206f32fbeSmrg if test "$opt_mode" = clean; then 9463a253d6aeSmrg case " $rmdirs " in 946406f32fbeSmrg *" $odir "*) ;; 946506f32fbeSmrg *) func_append rmdirs " $odir" ;; 9466a253d6aeSmrg esac 9467a253d6aeSmrg fi 9468a253d6aeSmrg 9469a253d6aeSmrg # Don't error if the file doesn't exist and rm -f was used. 9470ea133fd7Smrg if { test -L "$file"; } >/dev/null 2>&1 || 9471ea133fd7Smrg { test -h "$file"; } >/dev/null 2>&1 || 9472ea133fd7Smrg test -f "$file"; then 9473a253d6aeSmrg : 9474a253d6aeSmrg elif test -d "$file"; then 9475a253d6aeSmrg exit_status=1 9476a253d6aeSmrg continue 9477a253d6aeSmrg elif test "$rmforce" = yes; then 9478a253d6aeSmrg continue 9479a253d6aeSmrg fi 9480a253d6aeSmrg 9481a253d6aeSmrg rmfiles="$file" 9482a253d6aeSmrg 9483a253d6aeSmrg case $name in 9484a253d6aeSmrg *.la) 9485a253d6aeSmrg # Possibly a libtool archive, so verify it. 9486ea133fd7Smrg if func_lalib_p "$file"; then 9487ea133fd7Smrg func_source $dir/$name 9488a253d6aeSmrg 9489a253d6aeSmrg # Delete the libtool libraries and symlinks. 9490a253d6aeSmrg for n in $library_names; do 949106f32fbeSmrg func_append rmfiles " $odir/$n" 9492a253d6aeSmrg done 949306f32fbeSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9494a253d6aeSmrg 949506f32fbeSmrg case "$opt_mode" in 9496a253d6aeSmrg clean) 949706f32fbeSmrg case " $library_names " in 9498a253d6aeSmrg *" $dlname "*) ;; 949906f32fbeSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9500a253d6aeSmrg esac 950106f32fbeSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9502a253d6aeSmrg ;; 9503a253d6aeSmrg uninstall) 9504a253d6aeSmrg if test -n "$library_names"; then 9505a253d6aeSmrg # Do each command in the postuninstall commands. 9506ea133fd7Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9507a253d6aeSmrg fi 9508a253d6aeSmrg 9509a253d6aeSmrg if test -n "$old_library"; then 9510a253d6aeSmrg # Do each command in the old_postuninstall commands. 9511ea133fd7Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9512a253d6aeSmrg fi 9513a253d6aeSmrg # FIXME: should reinstall the best remaining shared library. 9514a253d6aeSmrg ;; 9515a253d6aeSmrg esac 9516a253d6aeSmrg fi 9517a253d6aeSmrg ;; 9518a253d6aeSmrg 9519a253d6aeSmrg *.lo) 9520a253d6aeSmrg # Possibly a libtool object, so verify it. 9521ea133fd7Smrg if func_lalib_p "$file"; then 9522a253d6aeSmrg 9523a253d6aeSmrg # Read the .lo file 9524ea133fd7Smrg func_source $dir/$name 9525a253d6aeSmrg 9526a253d6aeSmrg # Add PIC object to the list of files to remove. 9527ea133fd7Smrg if test -n "$pic_object" && 9528ea133fd7Smrg test "$pic_object" != none; then 952906f32fbeSmrg func_append rmfiles " $dir/$pic_object" 9530a253d6aeSmrg fi 9531a253d6aeSmrg 9532a253d6aeSmrg # Add non-PIC object to the list of files to remove. 9533ea133fd7Smrg if test -n "$non_pic_object" && 9534ea133fd7Smrg test "$non_pic_object" != none; then 953506f32fbeSmrg func_append rmfiles " $dir/$non_pic_object" 9536a253d6aeSmrg fi 9537a253d6aeSmrg fi 9538a253d6aeSmrg ;; 9539a253d6aeSmrg 9540a253d6aeSmrg *) 954106f32fbeSmrg if test "$opt_mode" = clean ; then 9542a253d6aeSmrg noexename=$name 9543a253d6aeSmrg case $file in 9544a253d6aeSmrg *.exe) 9545ea133fd7Smrg func_stripname '' '.exe' "$file" 9546ea133fd7Smrg file=$func_stripname_result 9547ea133fd7Smrg func_stripname '' '.exe' "$name" 9548ea133fd7Smrg noexename=$func_stripname_result 9549a253d6aeSmrg # $file with .exe has already been added to rmfiles, 9550a253d6aeSmrg # add $file without .exe 955106f32fbeSmrg func_append rmfiles " $file" 9552a253d6aeSmrg ;; 9553a253d6aeSmrg esac 9554a253d6aeSmrg # Do a test to see if this is a libtool program. 9555ea133fd7Smrg if func_ltwrapper_p "$file"; then 9556ea133fd7Smrg if func_ltwrapper_executable_p "$file"; then 9557ea133fd7Smrg func_ltwrapper_scriptname "$file" 9558ea133fd7Smrg relink_command= 9559ea133fd7Smrg func_source $func_ltwrapper_scriptname_result 956006f32fbeSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 9561ea133fd7Smrg else 9562ea133fd7Smrg relink_command= 9563ea133fd7Smrg func_source $dir/$noexename 9564ea133fd7Smrg fi 9565a253d6aeSmrg 9566a253d6aeSmrg # note $name still contains .exe if it was in $file originally 9567a253d6aeSmrg # as does the version of $file that was added into $rmfiles 956806f32fbeSmrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9569a253d6aeSmrg if test "$fast_install" = yes && test -n "$relink_command"; then 957006f32fbeSmrg func_append rmfiles " $odir/lt-$name" 9571a253d6aeSmrg fi 9572a253d6aeSmrg if test "X$noexename" != "X$name" ; then 957306f32fbeSmrg func_append rmfiles " $odir/lt-${noexename}.c" 9574a253d6aeSmrg fi 9575a253d6aeSmrg fi 9576a253d6aeSmrg fi 9577a253d6aeSmrg ;; 9578a253d6aeSmrg esac 9579ea133fd7Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 9580a253d6aeSmrg done 9581a253d6aeSmrg 9582a253d6aeSmrg # Try to remove the ${objdir}s in the directories where we deleted files 9583a253d6aeSmrg for dir in $rmdirs; do 9584a253d6aeSmrg if test -d "$dir"; then 9585ea133fd7Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 9586a253d6aeSmrg fi 9587a253d6aeSmrg done 9588a253d6aeSmrg 9589a253d6aeSmrg exit $exit_status 9590ea133fd7Smrg} 9591a253d6aeSmrg 959206f32fbeSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 9593ea133fd7Smrg func_mode_uninstall ${1+"$@"} 9594a253d6aeSmrg 959506f32fbeSmrgtest -z "$opt_mode" && { 9596ea133fd7Smrg help="$generic_help" 9597ea133fd7Smrg func_fatal_help "you must specify a MODE" 9598ea133fd7Smrg} 9599ea133fd7Smrg 9600ea133fd7Smrgtest -z "$exec_cmd" && \ 960106f32fbeSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 9602a253d6aeSmrg 9603a253d6aeSmrgif test -n "$exec_cmd"; then 9604ea133fd7Smrg eval exec "$exec_cmd" 9605a253d6aeSmrg exit $EXIT_FAILURE 9606a253d6aeSmrgfi 9607a253d6aeSmrg 9608ea133fd7Smrgexit $exit_status 9609a253d6aeSmrg 9610a253d6aeSmrg 9611a253d6aeSmrg# The TAGs below are defined such that we never get into a situation 9612a253d6aeSmrg# in which we disable both kinds of libraries. Given conflicting 9613a253d6aeSmrg# choices, we go for a static library, that is the most portable, 9614a253d6aeSmrg# since we can't tell whether shared libraries were disabled because 9615a253d6aeSmrg# the user asked for that or because the platform doesn't support 9616a253d6aeSmrg# them. This is particularly important on AIX, because we don't 9617a253d6aeSmrg# support having both static and shared libraries enabled at the same 9618a253d6aeSmrg# time on that platform, so we default to a shared-only configuration. 9619a253d6aeSmrg# If a disable-shared tag is given, we'll fallback to a static-only 9620a253d6aeSmrg# configuration. But we'll never go from static-only to shared-only. 9621a253d6aeSmrg 9622a253d6aeSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 9623ea133fd7Smrgbuild_libtool_libs=no 9624ea133fd7Smrgbuild_old_libs=yes 9625a253d6aeSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 9626a253d6aeSmrg 9627a253d6aeSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 9628ea133fd7Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9629a253d6aeSmrg# ### END LIBTOOL TAG CONFIG: disable-static 9630a253d6aeSmrg 9631a253d6aeSmrg# Local Variables: 9632a253d6aeSmrg# mode:shell-script 9633a253d6aeSmrg# sh-indentation:2 9634a253d6aeSmrg# End: 9635ea133fd7Smrg# vi:sw=2 9636ea133fd7Smrg 9637