ltmain.sh revision 57ee1794
1ea133fd7Smrg 257ee1794Smrg# libtool (GNU libtool) 2.4.2 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, 657ee1794Smrg# 2007, 2008, 2009, 2010, 2011 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) 4457ee1794Smrg# --no-warn don't display warning messages 4525b89263Smrg# --tag=TAG use configuration variables from tag TAG 4625b89263Smrg# -v, --verbose print more informational messages than default 4725b89263Smrg# --no-verbose don't print the extra informational messages 4825b89263Smrg# --version print version information 4925b89263Smrg# -h, --help, --help-all print short, long, or detailed help message 50ea133fd7Smrg# 51ea133fd7Smrg# MODE must be one of the following: 52ea133fd7Smrg# 5325b89263Smrg# clean remove files from the build directory 5425b89263Smrg# compile compile a source file into a libtool object 5525b89263Smrg# execute automatically set library path, then run a program 5625b89263Smrg# finish complete the installation of libtool libraries 5725b89263Smrg# install install libraries or executables 5825b89263Smrg# link create a library or an executable 5925b89263Smrg# uninstall remove libraries from an installed directory 60ea133fd7Smrg# 6125b89263Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 6225b89263Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 63ea133fd7Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 64ea133fd7Smrg# 65ea133fd7Smrg# When reporting a bug, please describe a test case to reproduce it and 66ea133fd7Smrg# include the following information: 67ea133fd7Smrg# 6825b89263Smrg# host-triplet: $host 6925b89263Smrg# shell: $SHELL 7025b89263Smrg# compiler: $LTCC 7125b89263Smrg# compiler flags: $LTCFLAGS 7225b89263Smrg# linker: $LD (gnu? $with_gnu_ld) 7357ee1794Smrg# $progname: (GNU libtool) 2.4.2 7425b89263Smrg# automake: $automake_version 7525b89263Smrg# autoconf: $autoconf_version 76ea133fd7Smrg# 77ea133fd7Smrg# Report bugs to <bug-libtool@gnu.org>. 7806f32fbeSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 7906f32fbeSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 80ea133fd7Smrg 8125b89263SmrgPROGRAM=libtool 82ea133fd7SmrgPACKAGE=libtool 8357ee1794SmrgVERSION=2.4.2 84ea133fd7SmrgTIMESTAMP="" 8557ee1794Smrgpackage_revision=1.3337 86ea133fd7Smrg 87ea133fd7Smrg# Be Bourne compatible 88ea133fd7Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 89ea133fd7Smrg emulate sh 90ea133fd7Smrg NULLCMD=: 91ea133fd7Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 92ea133fd7Smrg # is contrary to our usage. Disable this feature. 93ea133fd7Smrg alias -g '${1+"$@"}'='"$@"' 94ea133fd7Smrg setopt NO_GLOB_SUBST 95ea133fd7Smrgelse 96ea133fd7Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 97ea133fd7Smrgfi 98ea133fd7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 99ea133fd7SmrgDUALCASE=1; export DUALCASE # for MKS sh 100ea133fd7Smrg 10125b89263Smrg# A function that is used when there is no print builtin or printf. 10225b89263Smrgfunc_fallback_echo () 10325b89263Smrg{ 10425b89263Smrg eval 'cat <<_LTECHO_EOF 10525b89263Smrg$1 10625b89263Smrg_LTECHO_EOF' 10725b89263Smrg} 10825b89263Smrg 109ea133fd7Smrg# NLS nuisances: We save the old values to restore during execute mode. 110ea133fd7Smrglt_user_locale= 111ea133fd7Smrglt_safe_locale= 112ea133fd7Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 113ea133fd7Smrgdo 114ea133fd7Smrg eval "if test \"\${$lt_var+set}\" = set; then 115ea133fd7Smrg save_$lt_var=\$$lt_var 116ea133fd7Smrg $lt_var=C 117ea133fd7Smrg export $lt_var 118ea133fd7Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 119ea133fd7Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 120ea133fd7Smrg fi" 121ea133fd7Smrgdone 12225b89263SmrgLC_ALL=C 12325b89263SmrgLANGUAGE=C 12425b89263Smrgexport LANGUAGE LC_ALL 125ea133fd7Smrg 126ea133fd7Smrg$lt_unset CDPATH 127ea133fd7Smrg 128ea133fd7Smrg 12925b89263Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 13025b89263Smrg# is ksh but when the shell is invoked as "sh" and the current value of 13125b89263Smrg# the _XPG environment variable is not equal to 1 (one), the special 13225b89263Smrg# positional parameter $0, within a function call, is the name of the 13325b89263Smrg# function. 13425b89263Smrgprogpath="$0" 135ea133fd7Smrg 136ea133fd7Smrg 137ea133fd7Smrg 138ea133fd7Smrg: ${CP="cp -f"} 13925b89263Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 140ea133fd7Smrg: ${MAKE="make"} 141ea133fd7Smrg: ${MKDIR="mkdir"} 142ea133fd7Smrg: ${MV="mv -f"} 143ea133fd7Smrg: ${RM="rm -f"} 144ea133fd7Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 145ea133fd7Smrg: ${Xsed="$SED -e 1s/^X//"} 146a253d6aeSmrg 147ea133fd7Smrg# Global variables: 148ea133fd7SmrgEXIT_SUCCESS=0 149ea133fd7SmrgEXIT_FAILURE=1 150ea133fd7SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 151ea133fd7SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 152ea133fd7Smrg 153ea133fd7Smrgexit_status=$EXIT_SUCCESS 154ea133fd7Smrg 155ea133fd7Smrg# Make sure IFS has a sensible default 156ea133fd7Smrglt_nl=' 157ea133fd7Smrg' 158ea133fd7SmrgIFS=" $lt_nl" 159ea133fd7Smrg 160ea133fd7Smrgdirname="s,/[^/]*$,," 161ea133fd7Smrgbasename="s,^.*/,," 162ea133fd7Smrg 16306f32fbeSmrg# func_dirname file append nondir_replacement 16406f32fbeSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 16506f32fbeSmrg# otherwise set result to NONDIR_REPLACEMENT. 16606f32fbeSmrgfunc_dirname () 16706f32fbeSmrg{ 16806f32fbeSmrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 16906f32fbeSmrg if test "X$func_dirname_result" = "X${1}"; then 17006f32fbeSmrg func_dirname_result="${3}" 17106f32fbeSmrg else 17206f32fbeSmrg func_dirname_result="$func_dirname_result${2}" 17306f32fbeSmrg fi 17406f32fbeSmrg} # func_dirname may be replaced by extended shell implementation 17506f32fbeSmrg 17606f32fbeSmrg 17706f32fbeSmrg# func_basename file 17806f32fbeSmrgfunc_basename () 17906f32fbeSmrg{ 18006f32fbeSmrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 18106f32fbeSmrg} # func_basename may be replaced by extended shell implementation 18206f32fbeSmrg 18306f32fbeSmrg 184ea133fd7Smrg# func_dirname_and_basename file append nondir_replacement 185ea133fd7Smrg# perform func_basename and func_dirname in a single function 186ea133fd7Smrg# call: 187ea133fd7Smrg# dirname: Compute the dirname of FILE. If nonempty, 188ea133fd7Smrg# add APPEND to the result, otherwise set result 189ea133fd7Smrg# to NONDIR_REPLACEMENT. 190ea133fd7Smrg# value returned in "$func_dirname_result" 191ea133fd7Smrg# basename: Compute filename of FILE. 192ea133fd7Smrg# value retuned in "$func_basename_result" 193ea133fd7Smrg# Implementation must be kept synchronized with func_dirname 194ea133fd7Smrg# and func_basename. For efficiency, we do not delegate to 195ea133fd7Smrg# those functions but instead duplicate the functionality here. 196ea133fd7Smrgfunc_dirname_and_basename () 197ea133fd7Smrg{ 19806f32fbeSmrg # Extract subdirectory from the argument. 19906f32fbeSmrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 20006f32fbeSmrg if test "X$func_dirname_result" = "X${1}"; then 20106f32fbeSmrg func_dirname_result="${3}" 20206f32fbeSmrg else 20306f32fbeSmrg func_dirname_result="$func_dirname_result${2}" 20406f32fbeSmrg fi 20506f32fbeSmrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 20606f32fbeSmrg} # func_dirname_and_basename may be replaced by extended shell implementation 20706f32fbeSmrg 20806f32fbeSmrg 20906f32fbeSmrg# func_stripname prefix suffix name 21006f32fbeSmrg# strip PREFIX and SUFFIX off of NAME. 21106f32fbeSmrg# PREFIX and SUFFIX must not contain globbing or regex special 21206f32fbeSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 21306f32fbeSmrg# dot (in which case that matches only a dot). 21406f32fbeSmrg# func_strip_suffix prefix name 21506f32fbeSmrgfunc_stripname () 21606f32fbeSmrg{ 21706f32fbeSmrg case ${2} in 21806f32fbeSmrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 21906f32fbeSmrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 22006f32fbeSmrg esac 22106f32fbeSmrg} # func_stripname may be replaced by extended shell implementation 222ea133fd7Smrg 223a253d6aeSmrg 22425b89263Smrg# These SED scripts presuppose an absolute path with a trailing slash. 22525b89263Smrgpathcar='s,^/\([^/]*\).*$,\1,' 22625b89263Smrgpathcdr='s,^/[^/]*,,' 22725b89263Smrgremovedotparts=':dotsl 22825b89263Smrg s@/\./@/@g 22925b89263Smrg t dotsl 23025b89263Smrg s,/\.$,/,' 23125b89263Smrgcollapseslashes='s@/\{1,\}@/@g' 23225b89263Smrgfinalslash='s,/*$,/,' 23325b89263Smrg 23425b89263Smrg# func_normal_abspath PATH 23525b89263Smrg# Remove doubled-up and trailing slashes, "." path components, 23625b89263Smrg# and cancel out any ".." path components in PATH after making 23725b89263Smrg# it an absolute path. 23825b89263Smrg# value returned in "$func_normal_abspath_result" 23925b89263Smrgfunc_normal_abspath () 24025b89263Smrg{ 24125b89263Smrg # Start from root dir and reassemble the path. 24225b89263Smrg func_normal_abspath_result= 24325b89263Smrg func_normal_abspath_tpath=$1 24425b89263Smrg func_normal_abspath_altnamespace= 24525b89263Smrg case $func_normal_abspath_tpath in 24625b89263Smrg "") 24725b89263Smrg # Empty path, that just means $cwd. 24825b89263Smrg func_stripname '' '/' "`pwd`" 24925b89263Smrg func_normal_abspath_result=$func_stripname_result 25025b89263Smrg return 25125b89263Smrg ;; 25225b89263Smrg # The next three entries are used to spot a run of precisely 25325b89263Smrg # two leading slashes without using negated character classes; 25425b89263Smrg # we take advantage of case's first-match behaviour. 25525b89263Smrg ///*) 25625b89263Smrg # Unusual form of absolute path, do nothing. 25725b89263Smrg ;; 25825b89263Smrg //*) 25925b89263Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 26025b89263Smrg # and for example Cygwin uses it to access remote file shares 26125b89263Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 26225b89263Smrg func_normal_abspath_altnamespace=/ 26325b89263Smrg ;; 26425b89263Smrg /*) 26525b89263Smrg # Absolute path, do nothing. 26625b89263Smrg ;; 26725b89263Smrg *) 26825b89263Smrg # Relative path, prepend $cwd. 26925b89263Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 27025b89263Smrg ;; 27125b89263Smrg esac 27225b89263Smrg # Cancel out all the simple stuff to save iterations. We also want 27325b89263Smrg # the path to end with a slash for ease of parsing, so make sure 27425b89263Smrg # there is one (and only one) here. 27525b89263Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 27625b89263Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 27725b89263Smrg while :; do 27825b89263Smrg # Processed it all yet? 27925b89263Smrg if test "$func_normal_abspath_tpath" = / ; then 28025b89263Smrg # If we ascended to the root using ".." the result may be empty now. 28125b89263Smrg if test -z "$func_normal_abspath_result" ; then 28225b89263Smrg func_normal_abspath_result=/ 28325b89263Smrg fi 28425b89263Smrg break 28525b89263Smrg fi 28625b89263Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 28725b89263Smrg -e "$pathcar"` 28825b89263Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 28925b89263Smrg -e "$pathcdr"` 29025b89263Smrg # Figure out what to do with it 29125b89263Smrg case $func_normal_abspath_tcomponent in 29225b89263Smrg "") 29325b89263Smrg # Trailing empty path component, ignore it. 29425b89263Smrg ;; 29525b89263Smrg ..) 29625b89263Smrg # Parent dir; strip last assembled component from result. 29725b89263Smrg func_dirname "$func_normal_abspath_result" 29825b89263Smrg func_normal_abspath_result=$func_dirname_result 29925b89263Smrg ;; 30025b89263Smrg *) 30125b89263Smrg # Actual path component, append it. 30225b89263Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 30325b89263Smrg ;; 30425b89263Smrg esac 30525b89263Smrg done 30625b89263Smrg # Restore leading double-slash if one was found on entry. 30725b89263Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 30825b89263Smrg} 30925b89263Smrg 31025b89263Smrg# func_relative_path SRCDIR DSTDIR 31125b89263Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 31225b89263Smrg# slash if non-empty, suitable for immediately appending a filename 31325b89263Smrg# without needing to append a separator. 31425b89263Smrg# value returned in "$func_relative_path_result" 31525b89263Smrgfunc_relative_path () 31625b89263Smrg{ 31725b89263Smrg func_relative_path_result= 31825b89263Smrg func_normal_abspath "$1" 31925b89263Smrg func_relative_path_tlibdir=$func_normal_abspath_result 32025b89263Smrg func_normal_abspath "$2" 32125b89263Smrg func_relative_path_tbindir=$func_normal_abspath_result 32225b89263Smrg 32325b89263Smrg # Ascend the tree starting from libdir 32425b89263Smrg while :; do 32525b89263Smrg # check if we have found a prefix of bindir 32625b89263Smrg case $func_relative_path_tbindir in 32725b89263Smrg $func_relative_path_tlibdir) 32825b89263Smrg # found an exact match 32925b89263Smrg func_relative_path_tcancelled= 33025b89263Smrg break 33125b89263Smrg ;; 33225b89263Smrg $func_relative_path_tlibdir*) 33325b89263Smrg # found a matching prefix 33425b89263Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 33525b89263Smrg func_relative_path_tcancelled=$func_stripname_result 33625b89263Smrg if test -z "$func_relative_path_result"; then 33725b89263Smrg func_relative_path_result=. 33825b89263Smrg fi 33925b89263Smrg break 34025b89263Smrg ;; 34125b89263Smrg *) 34225b89263Smrg func_dirname $func_relative_path_tlibdir 34325b89263Smrg func_relative_path_tlibdir=${func_dirname_result} 34425b89263Smrg if test "x$func_relative_path_tlibdir" = x ; then 34525b89263Smrg # Have to descend all the way to the root! 34625b89263Smrg func_relative_path_result=../$func_relative_path_result 34725b89263Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 34825b89263Smrg break 34925b89263Smrg fi 35025b89263Smrg func_relative_path_result=../$func_relative_path_result 35125b89263Smrg ;; 35225b89263Smrg esac 35325b89263Smrg done 35425b89263Smrg 35525b89263Smrg # Now calculate path; take care to avoid doubling-up slashes. 35625b89263Smrg func_stripname '' '/' "$func_relative_path_result" 35725b89263Smrg func_relative_path_result=$func_stripname_result 35825b89263Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 35925b89263Smrg if test "x$func_stripname_result" != x ; then 36025b89263Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 36125b89263Smrg fi 36225b89263Smrg 36325b89263Smrg # Normalisation. If bindir is libdir, return empty string, 36425b89263Smrg # else relative path ending with a slash; either way, target 36525b89263Smrg # file name can be directly appended. 36625b89263Smrg if test ! -z "$func_relative_path_result"; then 36725b89263Smrg func_stripname './' '' "$func_relative_path_result/" 36825b89263Smrg func_relative_path_result=$func_stripname_result 36925b89263Smrg fi 37025b89263Smrg} 371a253d6aeSmrg 372a253d6aeSmrg# The name of this program: 373ea133fd7Smrgfunc_dirname_and_basename "$progpath" 374ea133fd7Smrgprogname=$func_basename_result 375a253d6aeSmrg 376ea133fd7Smrg# Make sure we have an absolute path for reexecution: 377ea133fd7Smrgcase $progpath in 378ea133fd7Smrg [\\/]*|[A-Za-z]:\\*) ;; 379ea133fd7Smrg *[\\/]*) 380ea133fd7Smrg progdir=$func_dirname_result 381ea133fd7Smrg progdir=`cd "$progdir" && pwd` 382ea133fd7Smrg progpath="$progdir/$progname" 383ea133fd7Smrg ;; 384ea133fd7Smrg *) 385ea133fd7Smrg save_IFS="$IFS" 38657ee1794Smrg IFS=${PATH_SEPARATOR-:} 387ea133fd7Smrg for progdir in $PATH; do 388ea133fd7Smrg IFS="$save_IFS" 389ea133fd7Smrg test -x "$progdir/$progname" && break 390ea133fd7Smrg done 391ea133fd7Smrg IFS="$save_IFS" 392ea133fd7Smrg test -n "$progdir" || progdir=`pwd` 393ea133fd7Smrg progpath="$progdir/$progname" 394ea133fd7Smrg ;; 395ea133fd7Smrgesac 396a253d6aeSmrg 397ea133fd7Smrg# Sed substitution that helps us do robust quoting. It backslashifies 398ea133fd7Smrg# metacharacters that are still active within double-quoted strings. 399ea133fd7SmrgXsed="${SED}"' -e 1s/^X//' 400ea133fd7Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 401ea133fd7Smrg 402ea133fd7Smrg# Same as above, but do not quote variable references. 403ea133fd7Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 404ea133fd7Smrg 40506f32fbeSmrg# Sed substitution that turns a string into a regex matching for the 40606f32fbeSmrg# string literally. 40706f32fbeSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 40806f32fbeSmrg 40906f32fbeSmrg# Sed substitution that converts a w32 file name or path 41006f32fbeSmrg# which contains forward slashes, into one that contains 41106f32fbeSmrg# (escaped) backslashes. A very naive implementation. 41206f32fbeSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 41306f32fbeSmrg 414ea133fd7Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 415ea133fd7Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 416ea133fd7Smrg# in input to double_quote_subst, that '$' was protected from expansion. 417ea133fd7Smrg# Since each input `\' is now two `\'s, look for any number of runs of 418ea133fd7Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 419ea133fd7Smrgbs='\\' 420ea133fd7Smrgbs2='\\\\' 421ea133fd7Smrgbs4='\\\\\\\\' 422ea133fd7Smrgdollar='\$' 423ea133fd7Smrgsed_double_backslash="\ 424ea133fd7Smrg s/$bs4/&\\ 425ea133fd7Smrg/g 426ea133fd7Smrg s/^$bs2$dollar/$bs&/ 427ea133fd7Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 428ea133fd7Smrg s/\n//g" 429ea133fd7Smrg 430ea133fd7Smrg# Standard options: 431ea133fd7Smrgopt_dry_run=false 432ea133fd7Smrgopt_help=false 433ea133fd7Smrgopt_quiet=false 434ea133fd7Smrgopt_verbose=false 435ea133fd7Smrgopt_warning=: 436ea133fd7Smrg 437ea133fd7Smrg# func_echo arg... 438ea133fd7Smrg# Echo program name prefixed message, along with the current mode 439ea133fd7Smrg# name if it has been set yet. 440ea133fd7Smrgfunc_echo () 441ea133fd7Smrg{ 44206f32fbeSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 443ea133fd7Smrg} 444a253d6aeSmrg 445ea133fd7Smrg# func_verbose arg... 446ea133fd7Smrg# Echo program name prefixed message in verbose mode only. 447ea133fd7Smrgfunc_verbose () 448ea133fd7Smrg{ 449ea133fd7Smrg $opt_verbose && func_echo ${1+"$@"} 450a253d6aeSmrg 451ea133fd7Smrg # A bug in bash halts the script if the last line of a function 452ea133fd7Smrg # fails when set -e is in force, so we need another command to 453ea133fd7Smrg # work around that: 454ea133fd7Smrg : 455ea133fd7Smrg} 456a253d6aeSmrg 45725b89263Smrg# func_echo_all arg... 45825b89263Smrg# Invoke $ECHO with all args, space-separated. 45925b89263Smrgfunc_echo_all () 46025b89263Smrg{ 46125b89263Smrg $ECHO "$*" 46225b89263Smrg} 46325b89263Smrg 464ea133fd7Smrg# func_error arg... 465ea133fd7Smrg# Echo program name prefixed message to standard error. 466ea133fd7Smrgfunc_error () 467ea133fd7Smrg{ 46806f32fbeSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 469ea133fd7Smrg} 470a253d6aeSmrg 471ea133fd7Smrg# func_warning arg... 472ea133fd7Smrg# Echo program name prefixed warning message to standard error. 473ea133fd7Smrgfunc_warning () 474ea133fd7Smrg{ 47506f32fbeSmrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 476a253d6aeSmrg 477ea133fd7Smrg # bash bug again: 478ea133fd7Smrg : 479ea133fd7Smrg} 480a253d6aeSmrg 481ea133fd7Smrg# func_fatal_error arg... 482ea133fd7Smrg# Echo program name prefixed message to standard error, and exit. 483ea133fd7Smrgfunc_fatal_error () 484ea133fd7Smrg{ 485ea133fd7Smrg func_error ${1+"$@"} 486ea133fd7Smrg exit $EXIT_FAILURE 487ea133fd7Smrg} 488a253d6aeSmrg 489ea133fd7Smrg# func_fatal_help arg... 490ea133fd7Smrg# Echo program name prefixed message to standard error, followed by 491ea133fd7Smrg# a help hint, and exit. 492ea133fd7Smrgfunc_fatal_help () 493ea133fd7Smrg{ 494ea133fd7Smrg func_error ${1+"$@"} 495ea133fd7Smrg func_fatal_error "$help" 496ea133fd7Smrg} 497ea133fd7Smrghelp="Try \`$progname --help' for more information." ## default 498a253d6aeSmrg 499a253d6aeSmrg 500ea133fd7Smrg# func_grep expression filename 501ea133fd7Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 502ea133fd7Smrgfunc_grep () 503ea133fd7Smrg{ 504ea133fd7Smrg $GREP "$1" "$2" >/dev/null 2>&1 505ea133fd7Smrg} 506ea133fd7Smrg 507ea133fd7Smrg 508ea133fd7Smrg# func_mkdir_p directory-path 509ea133fd7Smrg# Make sure the entire path to DIRECTORY-PATH is available. 510ea133fd7Smrgfunc_mkdir_p () 511ea133fd7Smrg{ 512ea133fd7Smrg my_directory_path="$1" 513ea133fd7Smrg my_dir_list= 514ea133fd7Smrg 515ea133fd7Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 516ea133fd7Smrg 517ea133fd7Smrg # Protect directory names starting with `-' 518ea133fd7Smrg case $my_directory_path in 519ea133fd7Smrg -*) my_directory_path="./$my_directory_path" ;; 520ea133fd7Smrg esac 521ea133fd7Smrg 522ea133fd7Smrg # While some portion of DIR does not yet exist... 523ea133fd7Smrg while test ! -d "$my_directory_path"; do 524ea133fd7Smrg # ...make a list in topmost first order. Use a colon delimited 525ea133fd7Smrg # list incase some portion of path contains whitespace. 526ea133fd7Smrg my_dir_list="$my_directory_path:$my_dir_list" 527ea133fd7Smrg 528ea133fd7Smrg # If the last portion added has no slash in it, the list is done 529ea133fd7Smrg case $my_directory_path in */*) ;; *) break ;; esac 530ea133fd7Smrg 531ea133fd7Smrg # ...otherwise throw away the child directory and loop 53225b89263Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 533ea133fd7Smrg done 53425b89263Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 535ea133fd7Smrg 536ea133fd7Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 537ea133fd7Smrg for my_dir in $my_dir_list; do 538ea133fd7Smrg IFS="$save_mkdir_p_IFS" 539ea133fd7Smrg # mkdir can fail with a `File exist' error if two processes 540ea133fd7Smrg # try to create one of the directories concurrently. Don't 541ea133fd7Smrg # stop in that case! 542ea133fd7Smrg $MKDIR "$my_dir" 2>/dev/null || : 543ea133fd7Smrg done 544ea133fd7Smrg IFS="$save_mkdir_p_IFS" 545ea133fd7Smrg 546ea133fd7Smrg # Bail out if we (or some other process) failed to create a directory. 547ea133fd7Smrg test -d "$my_directory_path" || \ 548ea133fd7Smrg func_fatal_error "Failed to create \`$1'" 549ea133fd7Smrg fi 550ea133fd7Smrg} 551a253d6aeSmrg 552a253d6aeSmrg 553a253d6aeSmrg# func_mktempdir [string] 554a253d6aeSmrg# Make a temporary directory that won't clash with other running 555a253d6aeSmrg# libtool processes, and avoids race conditions if possible. If 556a253d6aeSmrg# given, STRING is the basename for that directory. 557a253d6aeSmrgfunc_mktempdir () 558a253d6aeSmrg{ 559a253d6aeSmrg my_template="${TMPDIR-/tmp}/${1-$progname}" 560a253d6aeSmrg 561ea133fd7Smrg if test "$opt_dry_run" = ":"; then 562a253d6aeSmrg # Return a directory name, but don't create it in dry-run mode 563a253d6aeSmrg my_tmpdir="${my_template}-$$" 564a253d6aeSmrg else 565a253d6aeSmrg 566a253d6aeSmrg # If mktemp works, use that first and foremost 567a253d6aeSmrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 568a253d6aeSmrg 569a253d6aeSmrg if test ! -d "$my_tmpdir"; then 570ea133fd7Smrg # Failing that, at least try and use $RANDOM to avoid a race 571ea133fd7Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 572a253d6aeSmrg 573ea133fd7Smrg save_mktempdir_umask=`umask` 574ea133fd7Smrg umask 0077 575ea133fd7Smrg $MKDIR "$my_tmpdir" 576ea133fd7Smrg umask $save_mktempdir_umask 577a253d6aeSmrg fi 578a253d6aeSmrg 579a253d6aeSmrg # If we're not in dry-run mode, bomb out on failure 580ea133fd7Smrg test -d "$my_tmpdir" || \ 581ea133fd7Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 582a253d6aeSmrg fi 583a253d6aeSmrg 58425b89263Smrg $ECHO "$my_tmpdir" 585a253d6aeSmrg} 586a253d6aeSmrg 587a253d6aeSmrg 588ea133fd7Smrg# func_quote_for_eval arg 589ea133fd7Smrg# Aesthetically quote ARG to be evaled later. 590ea133fd7Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 591ea133fd7Smrg# is double-quoted, suitable for a subsequent eval, whereas 592ea133fd7Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 593ea133fd7Smrg# which are still active within double quotes backslashified. 594ea133fd7Smrgfunc_quote_for_eval () 595a253d6aeSmrg{ 596ea133fd7Smrg case $1 in 597ea133fd7Smrg *[\\\`\"\$]*) 59825b89263Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 599ea133fd7Smrg *) 600ea133fd7Smrg func_quote_for_eval_unquoted_result="$1" ;; 601ea133fd7Smrg esac 602ea133fd7Smrg 603ea133fd7Smrg case $func_quote_for_eval_unquoted_result in 604ea133fd7Smrg # Double-quote args containing shell metacharacters to delay 605ea133fd7Smrg # word splitting, command substitution and and variable 606ea133fd7Smrg # expansion for a subsequent eval. 607ea133fd7Smrg # Many Bourne shells cannot handle close brackets correctly 608ea133fd7Smrg # in scan sets, so we specify it separately. 609ea133fd7Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 610ea133fd7Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 611ea133fd7Smrg ;; 612ea133fd7Smrg *) 613ea133fd7Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 614a253d6aeSmrg esac 615a253d6aeSmrg} 616a253d6aeSmrg 617a253d6aeSmrg 618ea133fd7Smrg# func_quote_for_expand arg 619ea133fd7Smrg# Aesthetically quote ARG to be evaled later; same as above, 620ea133fd7Smrg# but do not quote variable references. 621ea133fd7Smrgfunc_quote_for_expand () 622a253d6aeSmrg{ 623ea133fd7Smrg case $1 in 624ea133fd7Smrg *[\\\`\"]*) 62525b89263Smrg my_arg=`$ECHO "$1" | $SED \ 626ea133fd7Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 627a253d6aeSmrg *) 628ea133fd7Smrg my_arg="$1" ;; 629ea133fd7Smrg esac 630ea133fd7Smrg 631ea133fd7Smrg case $my_arg in 632ea133fd7Smrg # Double-quote args containing shell metacharacters to delay 633ea133fd7Smrg # word splitting and command substitution for a subsequent eval. 634ea133fd7Smrg # Many Bourne shells cannot handle close brackets correctly 635ea133fd7Smrg # in scan sets, so we specify it separately. 636ea133fd7Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 637ea133fd7Smrg my_arg="\"$my_arg\"" 638ea133fd7Smrg ;; 639ea133fd7Smrg esac 640ea133fd7Smrg 641ea133fd7Smrg func_quote_for_expand_result="$my_arg" 642a253d6aeSmrg} 643a253d6aeSmrg 644a253d6aeSmrg 645ea133fd7Smrg# func_show_eval cmd [fail_exp] 646ea133fd7Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 647ea133fd7Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 648ea133fd7Smrg# is given, then evaluate it. 649ea133fd7Smrgfunc_show_eval () 650a253d6aeSmrg{ 651ea133fd7Smrg my_cmd="$1" 652ea133fd7Smrg my_fail_exp="${2-:}" 653a253d6aeSmrg 654ea133fd7Smrg ${opt_silent-false} || { 655ea133fd7Smrg func_quote_for_expand "$my_cmd" 656ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 657ea133fd7Smrg } 658ea133fd7Smrg 659ea133fd7Smrg if ${opt_dry_run-false}; then :; else 660ea133fd7Smrg eval "$my_cmd" 661ea133fd7Smrg my_status=$? 662ea133fd7Smrg if test "$my_status" -eq 0; then :; else 663ea133fd7Smrg eval "(exit $my_status); $my_fail_exp" 664ea133fd7Smrg fi 665a253d6aeSmrg fi 666a253d6aeSmrg} 667a253d6aeSmrg 668ea133fd7Smrg 669ea133fd7Smrg# func_show_eval_locale cmd [fail_exp] 670ea133fd7Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 671ea133fd7Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 672ea133fd7Smrg# is given, then evaluate it. Use the saved locale for evaluation. 673ea133fd7Smrgfunc_show_eval_locale () 674a253d6aeSmrg{ 675ea133fd7Smrg my_cmd="$1" 676ea133fd7Smrg my_fail_exp="${2-:}" 677a253d6aeSmrg 678ea133fd7Smrg ${opt_silent-false} || { 679ea133fd7Smrg func_quote_for_expand "$my_cmd" 680ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 681ea133fd7Smrg } 682ea133fd7Smrg 683ea133fd7Smrg if ${opt_dry_run-false}; then :; else 684ea133fd7Smrg eval "$lt_user_locale 685ea133fd7Smrg $my_cmd" 686ea133fd7Smrg my_status=$? 687ea133fd7Smrg eval "$lt_safe_locale" 688ea133fd7Smrg if test "$my_status" -eq 0; then :; else 689ea133fd7Smrg eval "(exit $my_status); $my_fail_exp" 690a253d6aeSmrg fi 691ea133fd7Smrg fi 692a253d6aeSmrg} 693a253d6aeSmrg 69406f32fbeSmrg# func_tr_sh 69506f32fbeSmrg# Turn $1 into a string suitable for a shell variable name. 69606f32fbeSmrg# Result is stored in $func_tr_sh_result. All characters 69706f32fbeSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 69806f32fbeSmrg# if $1 begins with a digit, a '_' is prepended as well. 69906f32fbeSmrgfunc_tr_sh () 70006f32fbeSmrg{ 70106f32fbeSmrg case $1 in 70206f32fbeSmrg [0-9]* | *[!a-zA-Z0-9_]*) 70306f32fbeSmrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 70406f32fbeSmrg ;; 70506f32fbeSmrg * ) 70606f32fbeSmrg func_tr_sh_result=$1 70706f32fbeSmrg ;; 70806f32fbeSmrg esac 70906f32fbeSmrg} 71006f32fbeSmrg 711a253d6aeSmrg 712ea133fd7Smrg# func_version 713ea133fd7Smrg# Echo version message to standard output and exit. 714ea133fd7Smrgfunc_version () 715ea133fd7Smrg{ 71606f32fbeSmrg $opt_debug 71706f32fbeSmrg 71825b89263Smrg $SED -n '/(C)/!b go 71925b89263Smrg :more 72025b89263Smrg /\./!{ 72125b89263Smrg N 72225b89263Smrg s/\n# / / 72325b89263Smrg b more 72425b89263Smrg } 72525b89263Smrg :go 72625b89263Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 727ea133fd7Smrg s/^# // 728ea133fd7Smrg s/^# *$// 729ea133fd7Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 730ea133fd7Smrg p 731ea133fd7Smrg }' < "$progpath" 732ea133fd7Smrg exit $? 733ea133fd7Smrg} 734ea133fd7Smrg 735ea133fd7Smrg# func_usage 736ea133fd7Smrg# Echo short help message to standard output and exit. 737ea133fd7Smrgfunc_usage () 738ea133fd7Smrg{ 73906f32fbeSmrg $opt_debug 74006f32fbeSmrg 74125b89263Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 742ea133fd7Smrg s/^# // 743ea133fd7Smrg s/^# *$// 744ea133fd7Smrg s/\$progname/'$progname'/ 745ea133fd7Smrg p 746ea133fd7Smrg }' < "$progpath" 74725b89263Smrg echo 748ea133fd7Smrg $ECHO "run \`$progname --help | more' for full usage" 749ea133fd7Smrg exit $? 750ea133fd7Smrg} 751ea133fd7Smrg 75225b89263Smrg# func_help [NOEXIT] 75325b89263Smrg# Echo long help message to standard output and exit, 75425b89263Smrg# unless 'noexit' is passed as argument. 755ea133fd7Smrgfunc_help () 756ea133fd7Smrg{ 75706f32fbeSmrg $opt_debug 75806f32fbeSmrg 759ea133fd7Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 76006f32fbeSmrg :print 761ea133fd7Smrg s/^# // 762ea133fd7Smrg s/^# *$// 763ea133fd7Smrg s*\$progname*'$progname'* 764ea133fd7Smrg s*\$host*'"$host"'* 765ea133fd7Smrg s*\$SHELL*'"$SHELL"'* 766ea133fd7Smrg s*\$LTCC*'"$LTCC"'* 767ea133fd7Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 768ea133fd7Smrg s*\$LD*'"$LD"'* 769ea133fd7Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 77057ee1794Smrg s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 77157ee1794Smrg s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 772ea133fd7Smrg p 77306f32fbeSmrg d 77406f32fbeSmrg } 77506f32fbeSmrg /^# .* home page:/b print 77606f32fbeSmrg /^# General help using/b print 77706f32fbeSmrg ' < "$progpath" 77825b89263Smrg ret=$? 77925b89263Smrg if test -z "$1"; then 78025b89263Smrg exit $ret 78125b89263Smrg fi 782ea133fd7Smrg} 783ea133fd7Smrg 784ea133fd7Smrg# func_missing_arg argname 785ea133fd7Smrg# Echo program name prefixed message to standard error and set global 786ea133fd7Smrg# exit_cmd. 787ea133fd7Smrgfunc_missing_arg () 788ea133fd7Smrg{ 78906f32fbeSmrg $opt_debug 79006f32fbeSmrg 79125b89263Smrg func_error "missing argument for $1." 792ea133fd7Smrg exit_cmd=exit 793ea133fd7Smrg} 794ea133fd7Smrg 795ea133fd7Smrg 79606f32fbeSmrg# func_split_short_opt shortopt 79706f32fbeSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 79806f32fbeSmrg# variables after splitting SHORTOPT after the 2nd character. 79906f32fbeSmrgfunc_split_short_opt () 80006f32fbeSmrg{ 80106f32fbeSmrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 80206f32fbeSmrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 80306f32fbeSmrg 80406f32fbeSmrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 80506f32fbeSmrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 80606f32fbeSmrg} # func_split_short_opt may be replaced by extended shell implementation 80706f32fbeSmrg 80806f32fbeSmrg 80906f32fbeSmrg# func_split_long_opt longopt 81006f32fbeSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 81106f32fbeSmrg# variables after splitting LONGOPT at the `=' sign. 81206f32fbeSmrgfunc_split_long_opt () 81306f32fbeSmrg{ 81406f32fbeSmrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 81506f32fbeSmrg my_sed_long_arg='1s/^--[^=]*=//' 81606f32fbeSmrg 81706f32fbeSmrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 81806f32fbeSmrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 81906f32fbeSmrg} # func_split_long_opt may be replaced by extended shell implementation 82006f32fbeSmrg 82106f32fbeSmrgexit_cmd=: 822ea133fd7Smrg 823ea133fd7Smrg 824ea133fd7Smrg 825ea133fd7Smrg 826a253d6aeSmrg 827ea133fd7Smrgmagic="%%%MAGIC variable%%%" 828ea133fd7Smrgmagic_exe="%%%MAGIC EXE variable%%%" 829a253d6aeSmrg 830ea133fd7Smrg# Global variables. 831ea133fd7Smrgnonopt= 832ea133fd7Smrgpreserve_args= 833ea133fd7Smrglo2o="s/\\.lo\$/.${objext}/" 834ea133fd7Smrgo2lo="s/\\.${objext}\$/.lo/" 835ea133fd7Smrgextracted_archives= 836ea133fd7Smrgextracted_serial=0 837a253d6aeSmrg 838ea133fd7Smrg# If this variable is set in any of the actions, the command in it 839ea133fd7Smrg# will be execed at the end. This prevents here-documents from being 840ea133fd7Smrg# left over by shells. 841ea133fd7Smrgexec_cmd= 842a253d6aeSmrg 84306f32fbeSmrg# func_append var value 84406f32fbeSmrg# Append VALUE to the end of shell variable VAR. 84506f32fbeSmrgfunc_append () 84606f32fbeSmrg{ 84706f32fbeSmrg eval "${1}=\$${1}\${2}" 84806f32fbeSmrg} # func_append may be replaced by extended shell implementation 84906f32fbeSmrg 85006f32fbeSmrg# func_append_quoted var value 85106f32fbeSmrg# Quote VALUE and append to the end of shell variable VAR, separated 85206f32fbeSmrg# by a space. 85306f32fbeSmrgfunc_append_quoted () 85406f32fbeSmrg{ 85506f32fbeSmrg func_quote_for_eval "${2}" 85606f32fbeSmrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 85706f32fbeSmrg} # func_append_quoted may be replaced by extended shell implementation 85806f32fbeSmrg 85906f32fbeSmrg 86006f32fbeSmrg# func_arith arithmetic-term... 86106f32fbeSmrgfunc_arith () 86206f32fbeSmrg{ 86306f32fbeSmrg func_arith_result=`expr "${@}"` 86406f32fbeSmrg} # func_arith may be replaced by extended shell implementation 86506f32fbeSmrg 86606f32fbeSmrg 86706f32fbeSmrg# func_len string 86806f32fbeSmrg# STRING may not start with a hyphen. 86906f32fbeSmrgfunc_len () 87006f32fbeSmrg{ 87106f32fbeSmrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 87206f32fbeSmrg} # func_len may be replaced by extended shell implementation 87306f32fbeSmrg 87406f32fbeSmrg 87506f32fbeSmrg# func_lo2o object 87606f32fbeSmrgfunc_lo2o () 87706f32fbeSmrg{ 87806f32fbeSmrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 87906f32fbeSmrg} # func_lo2o may be replaced by extended shell implementation 88006f32fbeSmrg 88106f32fbeSmrg 88206f32fbeSmrg# func_xform libobj-or-source 88306f32fbeSmrgfunc_xform () 88406f32fbeSmrg{ 88506f32fbeSmrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 88606f32fbeSmrg} # func_xform may be replaced by extended shell implementation 88706f32fbeSmrg 88806f32fbeSmrg 889ea133fd7Smrg# func_fatal_configuration arg... 890ea133fd7Smrg# Echo program name prefixed message to standard error, followed by 891ea133fd7Smrg# a configuration failure hint, and exit. 892ea133fd7Smrgfunc_fatal_configuration () 893ea133fd7Smrg{ 894ea133fd7Smrg func_error ${1+"$@"} 895ea133fd7Smrg func_error "See the $PACKAGE documentation for more information." 896ea133fd7Smrg func_fatal_error "Fatal configuration error." 897ea133fd7Smrg} 898ea133fd7Smrg 899ea133fd7Smrg 900ea133fd7Smrg# func_config 901ea133fd7Smrg# Display the configuration for all the tags in this script. 902ea133fd7Smrgfunc_config () 903ea133fd7Smrg{ 904ea133fd7Smrg re_begincf='^# ### BEGIN LIBTOOL' 905ea133fd7Smrg re_endcf='^# ### END LIBTOOL' 906ea133fd7Smrg 907ea133fd7Smrg # Default configuration. 908ea133fd7Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 909a253d6aeSmrg 910a253d6aeSmrg # Now print the configurations for the tags. 911a253d6aeSmrg for tagname in $taglist; do 912ea133fd7Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 913a253d6aeSmrg done 914a253d6aeSmrg 915ea133fd7Smrg exit $? 916ea133fd7Smrg} 917a253d6aeSmrg 918ea133fd7Smrg# func_features 919ea133fd7Smrg# Display the features supported by this script. 920ea133fd7Smrgfunc_features () 921ea133fd7Smrg{ 92225b89263Smrg echo "host: $host" 923a253d6aeSmrg if test "$build_libtool_libs" = yes; then 92425b89263Smrg echo "enable shared libraries" 925a253d6aeSmrg else 92625b89263Smrg echo "disable shared libraries" 927a253d6aeSmrg fi 928a253d6aeSmrg if test "$build_old_libs" = yes; then 92925b89263Smrg echo "enable static libraries" 930a253d6aeSmrg else 93125b89263Smrg echo "disable static libraries" 932a253d6aeSmrg fi 933ea133fd7Smrg 934a253d6aeSmrg exit $? 935ea133fd7Smrg} 936ea133fd7Smrg 937ea133fd7Smrg# func_enable_tag tagname 938ea133fd7Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 939ea133fd7Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 940ea133fd7Smrg# variable here. 941ea133fd7Smrgfunc_enable_tag () 942ea133fd7Smrg{ 943ea133fd7Smrg # Global variable: 944ea133fd7Smrg tagname="$1" 945a253d6aeSmrg 946ea133fd7Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 947ea133fd7Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 948ea133fd7Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 949a253d6aeSmrg 950ea133fd7Smrg # Validate tagname. 951ea133fd7Smrg case $tagname in 952ea133fd7Smrg *[!-_A-Za-z0-9,/]*) 953ea133fd7Smrg func_fatal_error "invalid tag name: $tagname" 954ea133fd7Smrg ;; 955ea133fd7Smrg esac 956a253d6aeSmrg 957ea133fd7Smrg # Don't test for the "default" C tag, as we know it's 958ea133fd7Smrg # there but not specially marked. 959ea133fd7Smrg case $tagname in 960ea133fd7Smrg CC) ;; 961ea133fd7Smrg *) 962ea133fd7Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 963ea133fd7Smrg taglist="$taglist $tagname" 964ea133fd7Smrg 965ea133fd7Smrg # Evaluate the configuration. Be careful to quote the path 966ea133fd7Smrg # and the sed script, to avoid splitting on whitespace, but 967ea133fd7Smrg # also don't use non-portable quotes within backquotes within 968ea133fd7Smrg # quotes we have to do it in 2 steps: 969ea133fd7Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 970ea133fd7Smrg eval "$extractedcf" 971ea133fd7Smrg else 972ea133fd7Smrg func_error "ignoring unknown tag $tagname" 973ea133fd7Smrg fi 974ea133fd7Smrg ;; 975ea133fd7Smrg esac 976ea133fd7Smrg} 977a253d6aeSmrg 97806f32fbeSmrg# func_check_version_match 97906f32fbeSmrg# Ensure that we are using m4 macros, and libtool script from the same 98006f32fbeSmrg# release of libtool. 98106f32fbeSmrgfunc_check_version_match () 982ea133fd7Smrg{ 98306f32fbeSmrg if test "$package_revision" != "$macro_revision"; then 98406f32fbeSmrg if test "$VERSION" != "$macro_version"; then 98506f32fbeSmrg if test -z "$macro_version"; then 98606f32fbeSmrg cat >&2 <<_LT_EOF 98706f32fbeSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 98806f32fbeSmrg$progname: definition of this LT_INIT comes from an older release. 98906f32fbeSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99006f32fbeSmrg$progname: and run autoconf again. 99106f32fbeSmrg_LT_EOF 99206f32fbeSmrg else 99306f32fbeSmrg cat >&2 <<_LT_EOF 99406f32fbeSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99506f32fbeSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 99606f32fbeSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99706f32fbeSmrg$progname: and run autoconf again. 99806f32fbeSmrg_LT_EOF 99906f32fbeSmrg fi 100006f32fbeSmrg else 100106f32fbeSmrg cat >&2 <<_LT_EOF 100206f32fbeSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 100306f32fbeSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 100406f32fbeSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 100506f32fbeSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 100606f32fbeSmrg_LT_EOF 100706f32fbeSmrg fi 1008a253d6aeSmrg 100906f32fbeSmrg exit $EXIT_MISMATCH 101006f32fbeSmrg fi 101106f32fbeSmrg} 101206f32fbeSmrg 101306f32fbeSmrg 101406f32fbeSmrg# Shorthand for --mode=foo, only valid as the first argument 101506f32fbeSmrgcase $1 in 101606f32fbeSmrgclean|clea|cle|cl) 101706f32fbeSmrg shift; set dummy --mode clean ${1+"$@"}; shift 101806f32fbeSmrg ;; 101906f32fbeSmrgcompile|compil|compi|comp|com|co|c) 102006f32fbeSmrg shift; set dummy --mode compile ${1+"$@"}; shift 102106f32fbeSmrg ;; 102206f32fbeSmrgexecute|execut|execu|exec|exe|ex|e) 102306f32fbeSmrg shift; set dummy --mode execute ${1+"$@"}; shift 102406f32fbeSmrg ;; 102506f32fbeSmrgfinish|finis|fini|fin|fi|f) 102606f32fbeSmrg shift; set dummy --mode finish ${1+"$@"}; shift 102706f32fbeSmrg ;; 102806f32fbeSmrginstall|instal|insta|inst|ins|in|i) 102906f32fbeSmrg shift; set dummy --mode install ${1+"$@"}; shift 103006f32fbeSmrg ;; 103106f32fbeSmrglink|lin|li|l) 103206f32fbeSmrg shift; set dummy --mode link ${1+"$@"}; shift 103306f32fbeSmrg ;; 103406f32fbeSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 103506f32fbeSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 103606f32fbeSmrg ;; 103706f32fbeSmrgesac 1038a253d6aeSmrg 103906f32fbeSmrg 104006f32fbeSmrg 104106f32fbeSmrg# Option defaults: 104206f32fbeSmrgopt_debug=: 104306f32fbeSmrgopt_dry_run=false 104406f32fbeSmrgopt_config=false 104506f32fbeSmrgopt_preserve_dup_deps=false 104606f32fbeSmrgopt_features=false 104706f32fbeSmrgopt_finish=false 104806f32fbeSmrgopt_help=false 104906f32fbeSmrgopt_help_all=false 105006f32fbeSmrgopt_silent=: 105157ee1794Smrgopt_warning=: 105206f32fbeSmrgopt_verbose=: 105306f32fbeSmrgopt_silent=false 105406f32fbeSmrgopt_verbose=false 105506f32fbeSmrg 105606f32fbeSmrg 105706f32fbeSmrg# Parse options once, thoroughly. This comes as soon as possible in the 105806f32fbeSmrg# script to make things like `--version' happen as quickly as we can. 105906f32fbeSmrg{ 106006f32fbeSmrg # this just eases exit handling 106106f32fbeSmrg while test $# -gt 0; do 1062ea133fd7Smrg opt="$1" 1063ea133fd7Smrg shift 1064ea133fd7Smrg case $opt in 106506f32fbeSmrg --debug|-x) opt_debug='set -x' 1066ea133fd7Smrg func_echo "enabling shell trace mode" 1067ea133fd7Smrg $opt_debug 1068ea133fd7Smrg ;; 106906f32fbeSmrg --dry-run|--dryrun|-n) 107006f32fbeSmrg opt_dry_run=: 1071ea133fd7Smrg ;; 107206f32fbeSmrg --config) 107306f32fbeSmrg opt_config=: 107406f32fbeSmrgfunc_config 107506f32fbeSmrg ;; 107606f32fbeSmrg --dlopen|-dlopen) 107706f32fbeSmrg optarg="$1" 107806f32fbeSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 107906f32fbeSmrg}$optarg" 1080ea133fd7Smrg shift 1081ea133fd7Smrg ;; 1082ea133fd7Smrg --preserve-dup-deps) 108306f32fbeSmrg opt_preserve_dup_deps=: 108425b89263Smrg ;; 108506f32fbeSmrg --features) 108606f32fbeSmrg opt_features=: 108706f32fbeSmrgfunc_features 1088ea133fd7Smrg ;; 108906f32fbeSmrg --finish) 109006f32fbeSmrg opt_finish=: 109106f32fbeSmrgset dummy --mode finish ${1+"$@"}; shift 109206f32fbeSmrg ;; 109306f32fbeSmrg --help) 109406f32fbeSmrg opt_help=: 109506f32fbeSmrg ;; 109606f32fbeSmrg --help-all) 109706f32fbeSmrg opt_help_all=: 109806f32fbeSmrgopt_help=': help-all' 109906f32fbeSmrg ;; 110006f32fbeSmrg --mode) 110106f32fbeSmrg test $# = 0 && func_missing_arg $opt && break 110206f32fbeSmrg optarg="$1" 110306f32fbeSmrg opt_mode="$optarg" 110406f32fbeSmrgcase $optarg in 110506f32fbeSmrg # Valid mode arguments: 110606f32fbeSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 110706f32fbeSmrg 110806f32fbeSmrg # Catch anything else as an error 110906f32fbeSmrg *) func_error "invalid argument for $opt" 111006f32fbeSmrg exit_cmd=exit 111106f32fbeSmrg break 111206f32fbeSmrg ;; 111306f32fbeSmrgesac 111406f32fbeSmrg shift 111506f32fbeSmrg ;; 111606f32fbeSmrg --no-silent|--no-quiet) 1117ea133fd7Smrg opt_silent=false 111857ee1794Smrgfunc_append preserve_args " $opt" 111957ee1794Smrg ;; 112057ee1794Smrg --no-warning|--no-warn) 112157ee1794Smrg opt_warning=false 112206f32fbeSmrgfunc_append preserve_args " $opt" 112325b89263Smrg ;; 112406f32fbeSmrg --no-verbose) 112525b89263Smrg opt_verbose=false 112606f32fbeSmrgfunc_append preserve_args " $opt" 1127ea133fd7Smrg ;; 112806f32fbeSmrg --silent|--quiet) 112906f32fbeSmrg opt_silent=: 113006f32fbeSmrgfunc_append preserve_args " $opt" 113106f32fbeSmrg opt_verbose=false 113206f32fbeSmrg ;; 113306f32fbeSmrg --verbose|-v) 113406f32fbeSmrg opt_verbose=: 113506f32fbeSmrgfunc_append preserve_args " $opt" 113606f32fbeSmrgopt_silent=false 113706f32fbeSmrg ;; 113806f32fbeSmrg --tag) 113906f32fbeSmrg test $# = 0 && func_missing_arg $opt && break 114006f32fbeSmrg optarg="$1" 114106f32fbeSmrg opt_tag="$optarg" 114206f32fbeSmrgfunc_append preserve_args " $opt $optarg" 114306f32fbeSmrgfunc_enable_tag "$optarg" 1144ea133fd7Smrg shift 1145ea133fd7Smrg ;; 1146ea133fd7Smrg 114706f32fbeSmrg -\?|-h) func_usage ;; 114806f32fbeSmrg --help) func_help ;; 114906f32fbeSmrg --version) func_version ;; 115006f32fbeSmrg 1151ea133fd7Smrg # Separate optargs to long options: 115206f32fbeSmrg --*=*) 115306f32fbeSmrg func_split_long_opt "$opt" 115406f32fbeSmrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 1155ea133fd7Smrg shift 1156ea133fd7Smrg ;; 1157ea133fd7Smrg 115806f32fbeSmrg # Separate non-argument short options: 115906f32fbeSmrg -\?*|-h*|-n*|-v*) 116006f32fbeSmrg func_split_short_opt "$opt" 116106f32fbeSmrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 116206f32fbeSmrg shift 1163ea133fd7Smrg ;; 116406f32fbeSmrg 116506f32fbeSmrg --) break ;; 116606f32fbeSmrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 116706f32fbeSmrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1168ea133fd7Smrg esac 1169ea133fd7Smrg done 1170ea133fd7Smrg 117106f32fbeSmrg # Validate options: 117206f32fbeSmrg 117306f32fbeSmrg # save first non-option argument 117406f32fbeSmrg if test "$#" -gt 0; then 117506f32fbeSmrg nonopt="$opt" 117606f32fbeSmrg shift 117706f32fbeSmrg fi 117806f32fbeSmrg 117906f32fbeSmrg # preserve --debug 118006f32fbeSmrg test "$opt_debug" = : || func_append preserve_args " --debug" 1181ea133fd7Smrg 1182ea133fd7Smrg case $host in 1183ea133fd7Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 1184ea133fd7Smrg # don't eliminate duplications in $postdeps and $predeps 1185ea133fd7Smrg opt_duplicate_compiler_generated_deps=: 1186a253d6aeSmrg ;; 1187a253d6aeSmrg *) 118806f32fbeSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 1189ea133fd7Smrg ;; 1190ea133fd7Smrg esac 1191a253d6aeSmrg 119206f32fbeSmrg $opt_help || { 119306f32fbeSmrg # Sanity checks first: 119406f32fbeSmrg func_check_version_match 1195ea133fd7Smrg 119606f32fbeSmrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 119706f32fbeSmrg func_fatal_configuration "not configured to build any kind of library" 1198ea133fd7Smrg fi 1199ea133fd7Smrg 120006f32fbeSmrg # Darwin sucks 120106f32fbeSmrg eval std_shrext=\"$shrext_cmds\" 1202ea133fd7Smrg 120306f32fbeSmrg # Only execute mode is allowed to have -dlopen flags. 120406f32fbeSmrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 120506f32fbeSmrg func_error "unrecognized option \`-dlopen'" 120606f32fbeSmrg $ECHO "$help" 1>&2 120706f32fbeSmrg exit $EXIT_FAILURE 120806f32fbeSmrg fi 1209ea133fd7Smrg 121006f32fbeSmrg # Change the help message to a mode-specific one. 121106f32fbeSmrg generic_help="$help" 121206f32fbeSmrg help="Try \`$progname --help --mode=$opt_mode' for more information." 121306f32fbeSmrg } 1214ea133fd7Smrg 1215ea133fd7Smrg 121606f32fbeSmrg # Bail if the options were screwed 121706f32fbeSmrg $exit_cmd $EXIT_FAILURE 121806f32fbeSmrg} 1219ea133fd7Smrg 1220ea133fd7Smrg 1221a253d6aeSmrg 1222a253d6aeSmrg 122306f32fbeSmrg## ----------- ## 122406f32fbeSmrg## Main. ## 122506f32fbeSmrg## ----------- ## 1226a253d6aeSmrg 1227ea133fd7Smrg# func_lalib_p file 1228ea133fd7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1229ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out 1230ea133fd7Smrg# determined imposters. 1231ea133fd7Smrgfunc_lalib_p () 1232ea133fd7Smrg{ 1233ea133fd7Smrg test -f "$1" && 1234ea133fd7Smrg $SED -e 4q "$1" 2>/dev/null \ 1235ea133fd7Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 1236ea133fd7Smrg} 1237a253d6aeSmrg 1238ea133fd7Smrg# func_lalib_unsafe_p file 1239ea133fd7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1240ea133fd7Smrg# This function implements the same check as func_lalib_p without 1241ea133fd7Smrg# resorting to external programs. To this end, it redirects stdin and 1242ea133fd7Smrg# closes it afterwards, without saving the original file descriptor. 1243ea133fd7Smrg# As a safety measure, use it only where a negative result would be 1244ea133fd7Smrg# fatal anyway. Works if `file' does not exist. 1245ea133fd7Smrgfunc_lalib_unsafe_p () 1246ea133fd7Smrg{ 1247ea133fd7Smrg lalib_p=no 1248ea133fd7Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 1249ea133fd7Smrg for lalib_p_l in 1 2 3 4 1250ea133fd7Smrg do 1251ea133fd7Smrg read lalib_p_line 1252ea133fd7Smrg case "$lalib_p_line" in 1253ea133fd7Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 1254ea133fd7Smrg esac 1255ea133fd7Smrg done 1256ea133fd7Smrg exec 0<&5 5<&- 1257ea133fd7Smrg fi 1258ea133fd7Smrg test "$lalib_p" = yes 1259ea133fd7Smrg} 1260a253d6aeSmrg 1261ea133fd7Smrg# func_ltwrapper_script_p file 1262ea133fd7Smrg# True iff FILE is a libtool wrapper script 1263ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out 1264ea133fd7Smrg# determined imposters. 1265ea133fd7Smrgfunc_ltwrapper_script_p () 1266ea133fd7Smrg{ 1267ea133fd7Smrg func_lalib_p "$1" 1268ea133fd7Smrg} 1269a253d6aeSmrg 1270ea133fd7Smrg# func_ltwrapper_executable_p file 1271ea133fd7Smrg# True iff FILE is a libtool wrapper executable 1272ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out 1273ea133fd7Smrg# determined imposters. 1274ea133fd7Smrgfunc_ltwrapper_executable_p () 1275ea133fd7Smrg{ 1276ea133fd7Smrg func_ltwrapper_exec_suffix= 1277ea133fd7Smrg case $1 in 1278ea133fd7Smrg *.exe) ;; 1279ea133fd7Smrg *) func_ltwrapper_exec_suffix=.exe ;; 1280ea133fd7Smrg esac 1281ea133fd7Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 1282ea133fd7Smrg} 1283a253d6aeSmrg 1284ea133fd7Smrg# func_ltwrapper_scriptname file 1285ea133fd7Smrg# Assumes file is an ltwrapper_executable 1286ea133fd7Smrg# uses $file to determine the appropriate filename for a 1287ea133fd7Smrg# temporary ltwrapper_script. 1288ea133fd7Smrgfunc_ltwrapper_scriptname () 1289ea133fd7Smrg{ 129006f32fbeSmrg func_dirname_and_basename "$1" "" "." 129106f32fbeSmrg func_stripname '' '.exe' "$func_basename_result" 129206f32fbeSmrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 1293ea133fd7Smrg} 1294a253d6aeSmrg 1295ea133fd7Smrg# func_ltwrapper_p file 1296ea133fd7Smrg# True iff FILE is a libtool wrapper script or wrapper executable 1297ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out 1298ea133fd7Smrg# determined imposters. 1299ea133fd7Smrgfunc_ltwrapper_p () 1300ea133fd7Smrg{ 1301ea133fd7Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 1302ea133fd7Smrg} 1303a253d6aeSmrg 1304a253d6aeSmrg 1305ea133fd7Smrg# func_execute_cmds commands fail_cmd 1306ea133fd7Smrg# Execute tilde-delimited COMMANDS. 1307ea133fd7Smrg# If FAIL_CMD is given, eval that upon failure. 1308ea133fd7Smrg# FAIL_CMD may read-access the current command in variable CMD! 1309ea133fd7Smrgfunc_execute_cmds () 1310ea133fd7Smrg{ 1311ea133fd7Smrg $opt_debug 1312ea133fd7Smrg save_ifs=$IFS; IFS='~' 1313ea133fd7Smrg for cmd in $1; do 1314ea133fd7Smrg IFS=$save_ifs 1315ea133fd7Smrg eval cmd=\"$cmd\" 1316ea133fd7Smrg func_show_eval "$cmd" "${2-:}" 1317ea133fd7Smrg done 1318ea133fd7Smrg IFS=$save_ifs 1319ea133fd7Smrg} 1320ea133fd7Smrg 1321ea133fd7Smrg 1322ea133fd7Smrg# func_source file 1323ea133fd7Smrg# Source FILE, adding directory component if necessary. 1324ea133fd7Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 1325ea133fd7Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 1326ea133fd7Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 1327ea133fd7Smrg# `FILE.' does not work on cygwin managed mounts. 1328ea133fd7Smrgfunc_source () 1329ea133fd7Smrg{ 1330ea133fd7Smrg $opt_debug 1331ea133fd7Smrg case $1 in 1332ea133fd7Smrg */* | *\\*) . "$1" ;; 1333ea133fd7Smrg *) . "./$1" ;; 1334ea133fd7Smrg esac 1335ea133fd7Smrg} 1336ea133fd7Smrg 1337ea133fd7Smrg 133806f32fbeSmrg# func_resolve_sysroot PATH 133906f32fbeSmrg# Replace a leading = in PATH with a sysroot. Store the result into 134006f32fbeSmrg# func_resolve_sysroot_result 134106f32fbeSmrgfunc_resolve_sysroot () 134206f32fbeSmrg{ 134306f32fbeSmrg func_resolve_sysroot_result=$1 134406f32fbeSmrg case $func_resolve_sysroot_result in 134506f32fbeSmrg =*) 134606f32fbeSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 134706f32fbeSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 134806f32fbeSmrg ;; 134906f32fbeSmrg esac 135006f32fbeSmrg} 135106f32fbeSmrg 135206f32fbeSmrg# func_replace_sysroot PATH 135306f32fbeSmrg# If PATH begins with the sysroot, replace it with = and 135406f32fbeSmrg# store the result into func_replace_sysroot_result. 135506f32fbeSmrgfunc_replace_sysroot () 135606f32fbeSmrg{ 135706f32fbeSmrg case "$lt_sysroot:$1" in 135806f32fbeSmrg ?*:"$lt_sysroot"*) 135906f32fbeSmrg func_stripname "$lt_sysroot" '' "$1" 136006f32fbeSmrg func_replace_sysroot_result="=$func_stripname_result" 136106f32fbeSmrg ;; 136206f32fbeSmrg *) 136306f32fbeSmrg # Including no sysroot. 136406f32fbeSmrg func_replace_sysroot_result=$1 136506f32fbeSmrg ;; 136606f32fbeSmrg esac 136706f32fbeSmrg} 136806f32fbeSmrg 1369ea133fd7Smrg# func_infer_tag arg 1370ea133fd7Smrg# Infer tagged configuration to use if any are available and 1371ea133fd7Smrg# if one wasn't chosen via the "--tag" command line option. 1372ea133fd7Smrg# Only attempt this if the compiler in the base compile 1373ea133fd7Smrg# command doesn't match the default compiler. 1374ea133fd7Smrg# arg is usually of the form 'gcc ...' 1375ea133fd7Smrgfunc_infer_tag () 1376ea133fd7Smrg{ 1377ea133fd7Smrg $opt_debug 1378ea133fd7Smrg if test -n "$available_tags" && test -z "$tagname"; then 1379ea133fd7Smrg CC_quoted= 1380ea133fd7Smrg for arg in $CC; do 138106f32fbeSmrg func_append_quoted CC_quoted "$arg" 1382ea133fd7Smrg done 138325b89263Smrg CC_expanded=`func_echo_all $CC` 138425b89263Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1385ea133fd7Smrg case $@ in 1386ea133fd7Smrg # Blanks in the command may have been stripped by the calling shell, 1387ea133fd7Smrg # but not from the CC environment variable when configure was run. 138825b89263Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 138925b89263Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 1390ea133fd7Smrg # Blanks at the start of $base_compile will cause this to fail 1391ea133fd7Smrg # if we don't check for them as well. 1392ea133fd7Smrg *) 1393ea133fd7Smrg for z in $available_tags; do 1394ea133fd7Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 1395ea133fd7Smrg # Evaluate the configuration. 1396ea133fd7Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 1397ea133fd7Smrg CC_quoted= 1398ea133fd7Smrg for arg in $CC; do 1399ea133fd7Smrg # Double-quote args containing other shell metacharacters. 140006f32fbeSmrg func_append_quoted CC_quoted "$arg" 1401ea133fd7Smrg done 140225b89263Smrg CC_expanded=`func_echo_all $CC` 140325b89263Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1404ea133fd7Smrg case "$@ " in 140525b89263Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 140625b89263Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 1407ea133fd7Smrg # The compiler in the base compile command matches 1408ea133fd7Smrg # the one in the tagged configuration. 1409ea133fd7Smrg # Assume this is the tagged configuration we want. 1410ea133fd7Smrg tagname=$z 1411ea133fd7Smrg break 1412ea133fd7Smrg ;; 1413a253d6aeSmrg esac 1414ea133fd7Smrg fi 1415ea133fd7Smrg done 1416ea133fd7Smrg # If $tagname still isn't set, then no tagged configuration 1417ea133fd7Smrg # was found and let the user know that the "--tag" command 1418ea133fd7Smrg # line option must be used. 1419ea133fd7Smrg if test -z "$tagname"; then 1420ea133fd7Smrg func_echo "unable to infer tagged configuration" 1421ea133fd7Smrg func_fatal_error "specify a tag with \`--tag'" 1422ea133fd7Smrg# else 1423ea133fd7Smrg# func_verbose "using $tagname tagged configuration" 1424ea133fd7Smrg fi 1425ea133fd7Smrg ;; 1426ea133fd7Smrg esac 1427ea133fd7Smrg fi 1428ea133fd7Smrg} 1429ea133fd7Smrg 1430ea133fd7Smrg 1431ea133fd7Smrg 143206f32fbeSmrg# func_write_libtool_object output_name pic_name nonpic_name 143306f32fbeSmrg# Create a libtool object file (analogous to a ".la" file), 143406f32fbeSmrg# but don't create it if we're doing a dry run. 143506f32fbeSmrgfunc_write_libtool_object () 143606f32fbeSmrg{ 143706f32fbeSmrg write_libobj=${1} 143806f32fbeSmrg if test "$build_libtool_libs" = yes; then 143906f32fbeSmrg write_lobj=\'${2}\' 144006f32fbeSmrg else 144106f32fbeSmrg write_lobj=none 144206f32fbeSmrg fi 144306f32fbeSmrg 144406f32fbeSmrg if test "$build_old_libs" = yes; then 144506f32fbeSmrg write_oldobj=\'${3}\' 144606f32fbeSmrg else 144706f32fbeSmrg write_oldobj=none 144806f32fbeSmrg fi 144906f32fbeSmrg 145006f32fbeSmrg $opt_dry_run || { 145106f32fbeSmrg cat >${write_libobj}T <<EOF 145206f32fbeSmrg# $write_libobj - a libtool object file 145306f32fbeSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 145406f32fbeSmrg# 145506f32fbeSmrg# Please DO NOT delete this file! 145606f32fbeSmrg# It is necessary for linking the library. 145706f32fbeSmrg 145806f32fbeSmrg# Name of the PIC object. 145906f32fbeSmrgpic_object=$write_lobj 146006f32fbeSmrg 146106f32fbeSmrg# Name of the non-PIC object 146206f32fbeSmrgnon_pic_object=$write_oldobj 146306f32fbeSmrg 146406f32fbeSmrgEOF 146506f32fbeSmrg $MV "${write_libobj}T" "${write_libobj}" 146606f32fbeSmrg } 146706f32fbeSmrg} 146806f32fbeSmrg 146906f32fbeSmrg 147006f32fbeSmrg################################################## 147106f32fbeSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 147206f32fbeSmrg################################################## 147306f32fbeSmrg 147406f32fbeSmrg# func_convert_core_file_wine_to_w32 ARG 147506f32fbeSmrg# Helper function used by file name conversion functions when $build is *nix, 147606f32fbeSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 147706f32fbeSmrg# correctly configured wine environment available, with the winepath program 147806f32fbeSmrg# in $build's $PATH. 147906f32fbeSmrg# 148006f32fbeSmrg# ARG is the $build file name to be converted to w32 format. 148106f32fbeSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 148206f32fbeSmrg# be empty on error (or when ARG is empty) 148306f32fbeSmrgfunc_convert_core_file_wine_to_w32 () 148406f32fbeSmrg{ 148506f32fbeSmrg $opt_debug 148606f32fbeSmrg func_convert_core_file_wine_to_w32_result="$1" 148706f32fbeSmrg if test -n "$1"; then 148806f32fbeSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 148906f32fbeSmrg # are forced to check the contents of stdout. On the other hand, if the 149006f32fbeSmrg # command is not found, the shell will set an exit code of 127 and print 149106f32fbeSmrg # *an error message* to stdout. So we must check for both error code of 149206f32fbeSmrg # zero AND non-empty stdout, which explains the odd construction: 149306f32fbeSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 149406f32fbeSmrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 149506f32fbeSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 149606f32fbeSmrg $SED -e "$lt_sed_naive_backslashify"` 149706f32fbeSmrg else 149806f32fbeSmrg func_convert_core_file_wine_to_w32_result= 149906f32fbeSmrg fi 150006f32fbeSmrg fi 150106f32fbeSmrg} 150206f32fbeSmrg# end: func_convert_core_file_wine_to_w32 150306f32fbeSmrg 150406f32fbeSmrg 150506f32fbeSmrg# func_convert_core_path_wine_to_w32 ARG 150606f32fbeSmrg# Helper function used by path conversion functions when $build is *nix, and 150706f32fbeSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 150806f32fbeSmrg# configured wine environment available, with the winepath program in $build's 150906f32fbeSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 151006f32fbeSmrg# 151106f32fbeSmrg# ARG is path to be converted from $build format to win32. 151206f32fbeSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 151306f32fbeSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 151406f32fbeSmrg# are convertible, then the result may be empty. 151506f32fbeSmrgfunc_convert_core_path_wine_to_w32 () 151606f32fbeSmrg{ 151706f32fbeSmrg $opt_debug 151806f32fbeSmrg # unfortunately, winepath doesn't convert paths, only file names 151906f32fbeSmrg func_convert_core_path_wine_to_w32_result="" 152006f32fbeSmrg if test -n "$1"; then 152106f32fbeSmrg oldIFS=$IFS 152206f32fbeSmrg IFS=: 152306f32fbeSmrg for func_convert_core_path_wine_to_w32_f in $1; do 152406f32fbeSmrg IFS=$oldIFS 152506f32fbeSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 152606f32fbeSmrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 152706f32fbeSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 152806f32fbeSmrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 152906f32fbeSmrg else 153006f32fbeSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 153106f32fbeSmrg fi 153206f32fbeSmrg fi 153306f32fbeSmrg done 153406f32fbeSmrg IFS=$oldIFS 153506f32fbeSmrg fi 153606f32fbeSmrg} 153706f32fbeSmrg# end: func_convert_core_path_wine_to_w32 153806f32fbeSmrg 153906f32fbeSmrg 154006f32fbeSmrg# func_cygpath ARGS... 154106f32fbeSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 154206f32fbeSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 154306f32fbeSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 154406f32fbeSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 154506f32fbeSmrg# file name or path is assumed to be in w32 format, as previously converted 154606f32fbeSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 154706f32fbeSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 154806f32fbeSmrg# Cygwin format). Returns an empty string on error. 154906f32fbeSmrg# 155006f32fbeSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 155106f32fbeSmrg# be converted. 155206f32fbeSmrg# 155306f32fbeSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 155406f32fbeSmrg# environment variable; do not put it in $PATH. 155506f32fbeSmrgfunc_cygpath () 155606f32fbeSmrg{ 155706f32fbeSmrg $opt_debug 155806f32fbeSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 155906f32fbeSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 156006f32fbeSmrg if test "$?" -ne 0; then 156106f32fbeSmrg # on failure, ensure result is empty 156206f32fbeSmrg func_cygpath_result= 156306f32fbeSmrg fi 156406f32fbeSmrg else 156506f32fbeSmrg func_cygpath_result= 156606f32fbeSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 156706f32fbeSmrg fi 156806f32fbeSmrg} 156906f32fbeSmrg#end: func_cygpath 157006f32fbeSmrg 157106f32fbeSmrg 157206f32fbeSmrg# func_convert_core_msys_to_w32 ARG 157306f32fbeSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 157406f32fbeSmrg# result in func_convert_core_msys_to_w32_result. 157506f32fbeSmrgfunc_convert_core_msys_to_w32 () 157606f32fbeSmrg{ 157706f32fbeSmrg $opt_debug 157806f32fbeSmrg # awkward: cmd appends spaces to result 157906f32fbeSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 158006f32fbeSmrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 158106f32fbeSmrg} 158206f32fbeSmrg#end: func_convert_core_msys_to_w32 158306f32fbeSmrg 158406f32fbeSmrg 158506f32fbeSmrg# func_convert_file_check ARG1 ARG2 158606f32fbeSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 158706f32fbeSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 158806f32fbeSmrg# func_to_host_file_result to ARG1). 158906f32fbeSmrgfunc_convert_file_check () 159006f32fbeSmrg{ 159106f32fbeSmrg $opt_debug 159206f32fbeSmrg if test -z "$2" && test -n "$1" ; then 159306f32fbeSmrg func_error "Could not determine host file name corresponding to" 159406f32fbeSmrg func_error " \`$1'" 159506f32fbeSmrg func_error "Continuing, but uninstalled executables may not work." 159606f32fbeSmrg # Fallback: 159706f32fbeSmrg func_to_host_file_result="$1" 159806f32fbeSmrg fi 159906f32fbeSmrg} 160006f32fbeSmrg# end func_convert_file_check 160106f32fbeSmrg 160206f32fbeSmrg 160306f32fbeSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 160406f32fbeSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 160506f32fbeSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 160606f32fbeSmrg# func_to_host_file_result to a simplistic fallback value (see below). 160706f32fbeSmrgfunc_convert_path_check () 160806f32fbeSmrg{ 160906f32fbeSmrg $opt_debug 161006f32fbeSmrg if test -z "$4" && test -n "$3"; then 161106f32fbeSmrg func_error "Could not determine the host path corresponding to" 161206f32fbeSmrg func_error " \`$3'" 161306f32fbeSmrg func_error "Continuing, but uninstalled executables may not work." 161406f32fbeSmrg # Fallback. This is a deliberately simplistic "conversion" and 161506f32fbeSmrg # should not be "improved". See libtool.info. 161606f32fbeSmrg if test "x$1" != "x$2"; then 161706f32fbeSmrg lt_replace_pathsep_chars="s|$1|$2|g" 161806f32fbeSmrg func_to_host_path_result=`echo "$3" | 161906f32fbeSmrg $SED -e "$lt_replace_pathsep_chars"` 162006f32fbeSmrg else 162106f32fbeSmrg func_to_host_path_result="$3" 162206f32fbeSmrg fi 162306f32fbeSmrg fi 162406f32fbeSmrg} 162506f32fbeSmrg# end func_convert_path_check 162606f32fbeSmrg 162706f32fbeSmrg 162806f32fbeSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 162906f32fbeSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 163006f32fbeSmrg# and appending REPL if ORIG matches BACKPAT. 163106f32fbeSmrgfunc_convert_path_front_back_pathsep () 163206f32fbeSmrg{ 163306f32fbeSmrg $opt_debug 163406f32fbeSmrg case $4 in 163506f32fbeSmrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 163606f32fbeSmrg ;; 163706f32fbeSmrg esac 163806f32fbeSmrg case $4 in 163906f32fbeSmrg $2 ) func_append func_to_host_path_result "$3" 164006f32fbeSmrg ;; 164106f32fbeSmrg esac 164206f32fbeSmrg} 164306f32fbeSmrg# end func_convert_path_front_back_pathsep 164406f32fbeSmrg 164506f32fbeSmrg 164606f32fbeSmrg################################################## 164706f32fbeSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 164806f32fbeSmrg################################################## 164906f32fbeSmrg# invoked via `$to_host_file_cmd ARG' 165006f32fbeSmrg# 165106f32fbeSmrg# In each case, ARG is the path to be converted from $build to $host format. 165206f32fbeSmrg# Result will be available in $func_to_host_file_result. 165306f32fbeSmrg 165406f32fbeSmrg 165506f32fbeSmrg# func_to_host_file ARG 165606f32fbeSmrg# Converts the file name ARG from $build format to $host format. Return result 165706f32fbeSmrg# in func_to_host_file_result. 165806f32fbeSmrgfunc_to_host_file () 165906f32fbeSmrg{ 166006f32fbeSmrg $opt_debug 166106f32fbeSmrg $to_host_file_cmd "$1" 166206f32fbeSmrg} 166306f32fbeSmrg# end func_to_host_file 166406f32fbeSmrg 166506f32fbeSmrg 166606f32fbeSmrg# func_to_tool_file ARG LAZY 166706f32fbeSmrg# converts the file name ARG from $build format to toolchain format. Return 166806f32fbeSmrg# result in func_to_tool_file_result. If the conversion in use is listed 166906f32fbeSmrg# in (the comma separated) LAZY, no conversion takes place. 167006f32fbeSmrgfunc_to_tool_file () 167106f32fbeSmrg{ 167206f32fbeSmrg $opt_debug 167306f32fbeSmrg case ,$2, in 167406f32fbeSmrg *,"$to_tool_file_cmd",*) 167506f32fbeSmrg func_to_tool_file_result=$1 167606f32fbeSmrg ;; 167706f32fbeSmrg *) 167806f32fbeSmrg $to_tool_file_cmd "$1" 167906f32fbeSmrg func_to_tool_file_result=$func_to_host_file_result 168006f32fbeSmrg ;; 168106f32fbeSmrg esac 168206f32fbeSmrg} 168306f32fbeSmrg# end func_to_tool_file 168406f32fbeSmrg 168506f32fbeSmrg 168606f32fbeSmrg# func_convert_file_noop ARG 168706f32fbeSmrg# Copy ARG to func_to_host_file_result. 168806f32fbeSmrgfunc_convert_file_noop () 168906f32fbeSmrg{ 169006f32fbeSmrg func_to_host_file_result="$1" 169106f32fbeSmrg} 169206f32fbeSmrg# end func_convert_file_noop 169306f32fbeSmrg 169406f32fbeSmrg 169506f32fbeSmrg# func_convert_file_msys_to_w32 ARG 169606f32fbeSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 169706f32fbeSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 169806f32fbeSmrg# func_to_host_file_result. 169906f32fbeSmrgfunc_convert_file_msys_to_w32 () 170006f32fbeSmrg{ 170106f32fbeSmrg $opt_debug 170206f32fbeSmrg func_to_host_file_result="$1" 170306f32fbeSmrg if test -n "$1"; then 170406f32fbeSmrg func_convert_core_msys_to_w32 "$1" 170506f32fbeSmrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 170606f32fbeSmrg fi 170706f32fbeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 170806f32fbeSmrg} 170906f32fbeSmrg# end func_convert_file_msys_to_w32 171006f32fbeSmrg 171106f32fbeSmrg 171206f32fbeSmrg# func_convert_file_cygwin_to_w32 ARG 171306f32fbeSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 171406f32fbeSmrg# func_to_host_file_result. 171506f32fbeSmrgfunc_convert_file_cygwin_to_w32 () 171606f32fbeSmrg{ 171706f32fbeSmrg $opt_debug 171806f32fbeSmrg func_to_host_file_result="$1" 171906f32fbeSmrg if test -n "$1"; then 172006f32fbeSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 172106f32fbeSmrg # LT_CYGPATH in this case. 172206f32fbeSmrg func_to_host_file_result=`cygpath -m "$1"` 172306f32fbeSmrg fi 172406f32fbeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 172506f32fbeSmrg} 172606f32fbeSmrg# end func_convert_file_cygwin_to_w32 172706f32fbeSmrg 172806f32fbeSmrg 172906f32fbeSmrg# func_convert_file_nix_to_w32 ARG 173006f32fbeSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 173106f32fbeSmrg# and a working winepath. Returns result in func_to_host_file_result. 173206f32fbeSmrgfunc_convert_file_nix_to_w32 () 173306f32fbeSmrg{ 173406f32fbeSmrg $opt_debug 173506f32fbeSmrg func_to_host_file_result="$1" 173606f32fbeSmrg if test -n "$1"; then 173706f32fbeSmrg func_convert_core_file_wine_to_w32 "$1" 173806f32fbeSmrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 173906f32fbeSmrg fi 174006f32fbeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 174106f32fbeSmrg} 174206f32fbeSmrg# end func_convert_file_nix_to_w32 174306f32fbeSmrg 174406f32fbeSmrg 174506f32fbeSmrg# func_convert_file_msys_to_cygwin ARG 174606f32fbeSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 174706f32fbeSmrg# Returns result in func_to_host_file_result. 174806f32fbeSmrgfunc_convert_file_msys_to_cygwin () 174906f32fbeSmrg{ 175006f32fbeSmrg $opt_debug 175106f32fbeSmrg func_to_host_file_result="$1" 175206f32fbeSmrg if test -n "$1"; then 175306f32fbeSmrg func_convert_core_msys_to_w32 "$1" 175406f32fbeSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 175506f32fbeSmrg func_to_host_file_result="$func_cygpath_result" 175606f32fbeSmrg fi 175706f32fbeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 175806f32fbeSmrg} 175906f32fbeSmrg# end func_convert_file_msys_to_cygwin 176006f32fbeSmrg 176106f32fbeSmrg 176206f32fbeSmrg# func_convert_file_nix_to_cygwin ARG 176306f32fbeSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 176406f32fbeSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 176506f32fbeSmrg# in func_to_host_file_result. 176606f32fbeSmrgfunc_convert_file_nix_to_cygwin () 176706f32fbeSmrg{ 176806f32fbeSmrg $opt_debug 176906f32fbeSmrg func_to_host_file_result="$1" 177006f32fbeSmrg if test -n "$1"; then 177106f32fbeSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 177206f32fbeSmrg func_convert_core_file_wine_to_w32 "$1" 177306f32fbeSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 177406f32fbeSmrg func_to_host_file_result="$func_cygpath_result" 177506f32fbeSmrg fi 177606f32fbeSmrg func_convert_file_check "$1" "$func_to_host_file_result" 177706f32fbeSmrg} 177806f32fbeSmrg# end func_convert_file_nix_to_cygwin 177906f32fbeSmrg 178006f32fbeSmrg 178106f32fbeSmrg############################################# 178206f32fbeSmrg# $build to $host PATH CONVERSION FUNCTIONS # 178306f32fbeSmrg############################################# 178406f32fbeSmrg# invoked via `$to_host_path_cmd ARG' 178506f32fbeSmrg# 178606f32fbeSmrg# In each case, ARG is the path to be converted from $build to $host format. 178706f32fbeSmrg# The result will be available in $func_to_host_path_result. 178806f32fbeSmrg# 178906f32fbeSmrg# Path separators are also converted from $build format to $host format. If 179006f32fbeSmrg# ARG begins or ends with a path separator character, it is preserved (but 179106f32fbeSmrg# converted to $host format) on output. 179206f32fbeSmrg# 179306f32fbeSmrg# All path conversion functions are named using the following convention: 179406f32fbeSmrg# file name conversion function : func_convert_file_X_to_Y () 179506f32fbeSmrg# path conversion function : func_convert_path_X_to_Y () 179606f32fbeSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 179706f32fbeSmrg# same. If conversion functions are added for new $build/$host combinations, 179806f32fbeSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 179906f32fbeSmrg# will break. 180006f32fbeSmrg 180106f32fbeSmrg 180206f32fbeSmrg# func_init_to_host_path_cmd 180306f32fbeSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 180406f32fbeSmrg# appropriate value, based on the value of $to_host_file_cmd. 180506f32fbeSmrgto_host_path_cmd= 180606f32fbeSmrgfunc_init_to_host_path_cmd () 180706f32fbeSmrg{ 180806f32fbeSmrg $opt_debug 180906f32fbeSmrg if test -z "$to_host_path_cmd"; then 181006f32fbeSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 181106f32fbeSmrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 181206f32fbeSmrg fi 181306f32fbeSmrg} 181406f32fbeSmrg 181506f32fbeSmrg 181606f32fbeSmrg# func_to_host_path ARG 181706f32fbeSmrg# Converts the path ARG from $build format to $host format. Return result 181806f32fbeSmrg# in func_to_host_path_result. 181906f32fbeSmrgfunc_to_host_path () 182006f32fbeSmrg{ 182106f32fbeSmrg $opt_debug 182206f32fbeSmrg func_init_to_host_path_cmd 182306f32fbeSmrg $to_host_path_cmd "$1" 182406f32fbeSmrg} 182506f32fbeSmrg# end func_to_host_path 182606f32fbeSmrg 182706f32fbeSmrg 182806f32fbeSmrg# func_convert_path_noop ARG 182906f32fbeSmrg# Copy ARG to func_to_host_path_result. 183006f32fbeSmrgfunc_convert_path_noop () 183106f32fbeSmrg{ 183206f32fbeSmrg func_to_host_path_result="$1" 183306f32fbeSmrg} 183406f32fbeSmrg# end func_convert_path_noop 183506f32fbeSmrg 183606f32fbeSmrg 183706f32fbeSmrg# func_convert_path_msys_to_w32 ARG 183806f32fbeSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 183906f32fbeSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 184006f32fbeSmrg# func_to_host_path_result. 184106f32fbeSmrgfunc_convert_path_msys_to_w32 () 1842ea133fd7Smrg{ 184306f32fbeSmrg $opt_debug 184406f32fbeSmrg func_to_host_path_result="$1" 184506f32fbeSmrg if test -n "$1"; then 184606f32fbeSmrg # Remove leading and trailing path separator characters from ARG. MSYS 184706f32fbeSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 184806f32fbeSmrg # and winepath ignores them completely. 184906f32fbeSmrg func_stripname : : "$1" 185006f32fbeSmrg func_to_host_path_tmp1=$func_stripname_result 185106f32fbeSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 185206f32fbeSmrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 185306f32fbeSmrg func_convert_path_check : ";" \ 185406f32fbeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 185506f32fbeSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 185606f32fbeSmrg fi 185706f32fbeSmrg} 185806f32fbeSmrg# end func_convert_path_msys_to_w32 1859ea133fd7Smrg 1860ea133fd7Smrg 186106f32fbeSmrg# func_convert_path_cygwin_to_w32 ARG 186206f32fbeSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 186306f32fbeSmrg# func_to_host_file_result. 186406f32fbeSmrgfunc_convert_path_cygwin_to_w32 () 186506f32fbeSmrg{ 186606f32fbeSmrg $opt_debug 186706f32fbeSmrg func_to_host_path_result="$1" 186806f32fbeSmrg if test -n "$1"; then 186906f32fbeSmrg # See func_convert_path_msys_to_w32: 187006f32fbeSmrg func_stripname : : "$1" 187106f32fbeSmrg func_to_host_path_tmp1=$func_stripname_result 187206f32fbeSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 187306f32fbeSmrg func_convert_path_check : ";" \ 187406f32fbeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 187506f32fbeSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 187606f32fbeSmrg fi 187706f32fbeSmrg} 187806f32fbeSmrg# end func_convert_path_cygwin_to_w32 1879ea133fd7Smrg 1880ea133fd7Smrg 188106f32fbeSmrg# func_convert_path_nix_to_w32 ARG 188206f32fbeSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 188306f32fbeSmrg# a working winepath. Returns result in func_to_host_file_result. 188406f32fbeSmrgfunc_convert_path_nix_to_w32 () 188506f32fbeSmrg{ 188606f32fbeSmrg $opt_debug 188706f32fbeSmrg func_to_host_path_result="$1" 188806f32fbeSmrg if test -n "$1"; then 188906f32fbeSmrg # See func_convert_path_msys_to_w32: 189006f32fbeSmrg func_stripname : : "$1" 189106f32fbeSmrg func_to_host_path_tmp1=$func_stripname_result 189206f32fbeSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 189306f32fbeSmrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 189406f32fbeSmrg func_convert_path_check : ";" \ 189506f32fbeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 189606f32fbeSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 189706f32fbeSmrg fi 189806f32fbeSmrg} 189906f32fbeSmrg# end func_convert_path_nix_to_w32 1900ea133fd7Smrg 190106f32fbeSmrg 190206f32fbeSmrg# func_convert_path_msys_to_cygwin ARG 190306f32fbeSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 190406f32fbeSmrg# Returns result in func_to_host_file_result. 190506f32fbeSmrgfunc_convert_path_msys_to_cygwin () 190606f32fbeSmrg{ 190706f32fbeSmrg $opt_debug 190806f32fbeSmrg func_to_host_path_result="$1" 190906f32fbeSmrg if test -n "$1"; then 191006f32fbeSmrg # See func_convert_path_msys_to_w32: 191106f32fbeSmrg func_stripname : : "$1" 191206f32fbeSmrg func_to_host_path_tmp1=$func_stripname_result 191306f32fbeSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 191406f32fbeSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 191506f32fbeSmrg func_to_host_path_result="$func_cygpath_result" 191606f32fbeSmrg func_convert_path_check : : \ 191706f32fbeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 191806f32fbeSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 191906f32fbeSmrg fi 192006f32fbeSmrg} 192106f32fbeSmrg# end func_convert_path_msys_to_cygwin 192206f32fbeSmrg 192306f32fbeSmrg 192406f32fbeSmrg# func_convert_path_nix_to_cygwin ARG 192506f32fbeSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 192606f32fbeSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 192706f32fbeSmrg# func_to_host_file_result. 192806f32fbeSmrgfunc_convert_path_nix_to_cygwin () 192906f32fbeSmrg{ 193006f32fbeSmrg $opt_debug 193106f32fbeSmrg func_to_host_path_result="$1" 193206f32fbeSmrg if test -n "$1"; then 193306f32fbeSmrg # Remove leading and trailing path separator characters from 193406f32fbeSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 193506f32fbeSmrg # into '.;' and ';.', and winepath ignores them completely. 193606f32fbeSmrg func_stripname : : "$1" 193706f32fbeSmrg func_to_host_path_tmp1=$func_stripname_result 193806f32fbeSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 193906f32fbeSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 194006f32fbeSmrg func_to_host_path_result="$func_cygpath_result" 194106f32fbeSmrg func_convert_path_check : : \ 194206f32fbeSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 194306f32fbeSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 194406f32fbeSmrg fi 1945ea133fd7Smrg} 194606f32fbeSmrg# end func_convert_path_nix_to_cygwin 194706f32fbeSmrg 1948ea133fd7Smrg 1949ea133fd7Smrg# func_mode_compile arg... 1950ea133fd7Smrgfunc_mode_compile () 1951ea133fd7Smrg{ 1952ea133fd7Smrg $opt_debug 1953ea133fd7Smrg # Get the compilation command and the source file. 1954ea133fd7Smrg base_compile= 1955ea133fd7Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 1956ea133fd7Smrg suppress_opt=yes 1957ea133fd7Smrg suppress_output= 1958ea133fd7Smrg arg_mode=normal 1959ea133fd7Smrg libobj= 1960ea133fd7Smrg later= 1961ea133fd7Smrg pie_flag= 1962ea133fd7Smrg 1963ea133fd7Smrg for arg 1964ea133fd7Smrg do 1965ea133fd7Smrg case $arg_mode in 1966ea133fd7Smrg arg ) 1967ea133fd7Smrg # do not "continue". Instead, add this to base_compile 1968ea133fd7Smrg lastarg="$arg" 1969ea133fd7Smrg arg_mode=normal 1970ea133fd7Smrg ;; 1971ea133fd7Smrg 1972ea133fd7Smrg target ) 1973ea133fd7Smrg libobj="$arg" 1974ea133fd7Smrg arg_mode=normal 1975ea133fd7Smrg continue 1976ea133fd7Smrg ;; 1977ea133fd7Smrg 1978ea133fd7Smrg normal ) 1979ea133fd7Smrg # Accept any command-line options. 1980ea133fd7Smrg case $arg in 1981ea133fd7Smrg -o) 1982ea133fd7Smrg test -n "$libobj" && \ 1983ea133fd7Smrg func_fatal_error "you cannot specify \`-o' more than once" 1984ea133fd7Smrg arg_mode=target 1985ea133fd7Smrg continue 1986ea133fd7Smrg ;; 1987ea133fd7Smrg 1988ea133fd7Smrg -pie | -fpie | -fPIE) 198906f32fbeSmrg func_append pie_flag " $arg" 1990ea133fd7Smrg continue 1991ea133fd7Smrg ;; 1992ea133fd7Smrg 1993ea133fd7Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 199406f32fbeSmrg func_append later " $arg" 1995ea133fd7Smrg continue 1996ea133fd7Smrg ;; 1997ea133fd7Smrg 1998ea133fd7Smrg -no-suppress) 1999ea133fd7Smrg suppress_opt=no 2000ea133fd7Smrg continue 2001ea133fd7Smrg ;; 2002ea133fd7Smrg 2003ea133fd7Smrg -Xcompiler) 2004ea133fd7Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 2005ea133fd7Smrg continue # The current "srcfile" will either be retained or 2006ea133fd7Smrg ;; # replaced later. I would guess that would be a bug. 2007ea133fd7Smrg 2008ea133fd7Smrg -Wc,*) 2009ea133fd7Smrg func_stripname '-Wc,' '' "$arg" 2010ea133fd7Smrg args=$func_stripname_result 2011ea133fd7Smrg lastarg= 2012ea133fd7Smrg save_ifs="$IFS"; IFS=',' 2013ea133fd7Smrg for arg in $args; do 2014ea133fd7Smrg IFS="$save_ifs" 201506f32fbeSmrg func_append_quoted lastarg "$arg" 2016a253d6aeSmrg done 2017a253d6aeSmrg IFS="$save_ifs" 2018ea133fd7Smrg func_stripname ' ' '' "$lastarg" 2019ea133fd7Smrg lastarg=$func_stripname_result 2020a253d6aeSmrg 2021a253d6aeSmrg # Add the arguments to base_compile. 202206f32fbeSmrg func_append base_compile " $lastarg" 2023a253d6aeSmrg continue 2024a253d6aeSmrg ;; 2025a253d6aeSmrg 2026ea133fd7Smrg *) 2027a253d6aeSmrg # Accept the current argument as the source file. 2028a253d6aeSmrg # The previous "srcfile" becomes the current argument. 2029a253d6aeSmrg # 2030a253d6aeSmrg lastarg="$srcfile" 2031a253d6aeSmrg srcfile="$arg" 2032a253d6aeSmrg ;; 2033a253d6aeSmrg esac # case $arg 2034a253d6aeSmrg ;; 2035a253d6aeSmrg esac # case $arg_mode 2036a253d6aeSmrg 2037a253d6aeSmrg # Aesthetically quote the previous argument. 203806f32fbeSmrg func_append_quoted base_compile "$lastarg" 2039a253d6aeSmrg done # for arg 2040a253d6aeSmrg 2041a253d6aeSmrg case $arg_mode in 2042a253d6aeSmrg arg) 2043ea133fd7Smrg func_fatal_error "you must specify an argument for -Xcompile" 2044a253d6aeSmrg ;; 2045a253d6aeSmrg target) 2046ea133fd7Smrg func_fatal_error "you must specify a target with \`-o'" 2047a253d6aeSmrg ;; 2048a253d6aeSmrg *) 2049a253d6aeSmrg # Get the name of the library object. 2050ea133fd7Smrg test -z "$libobj" && { 2051ea133fd7Smrg func_basename "$srcfile" 2052ea133fd7Smrg libobj="$func_basename_result" 2053ea133fd7Smrg } 2054a253d6aeSmrg ;; 2055a253d6aeSmrg esac 2056a253d6aeSmrg 2057a253d6aeSmrg # Recognize several different file suffixes. 2058a253d6aeSmrg # If the user specifies -o file.o, it is replaced with file.lo 2059a253d6aeSmrg case $libobj in 2060ea133fd7Smrg *.[cCFSifmso] | \ 2061ea133fd7Smrg *.ada | *.adb | *.ads | *.asm | \ 2062ea133fd7Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 206357ee1794Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 2064ea133fd7Smrg func_xform "$libobj" 2065ea133fd7Smrg libobj=$func_xform_result 2066ea133fd7Smrg ;; 2067a253d6aeSmrg esac 2068a253d6aeSmrg 2069a253d6aeSmrg case $libobj in 2070ea133fd7Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2071a253d6aeSmrg *) 2072ea133fd7Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 2073a253d6aeSmrg ;; 2074a253d6aeSmrg esac 2075a253d6aeSmrg 2076a253d6aeSmrg func_infer_tag $base_compile 2077a253d6aeSmrg 2078a253d6aeSmrg for arg in $later; do 2079a253d6aeSmrg case $arg in 2080ea133fd7Smrg -shared) 2081ea133fd7Smrg test "$build_libtool_libs" != yes && \ 2082ea133fd7Smrg func_fatal_configuration "can not build a shared library" 2083ea133fd7Smrg build_old_libs=no 2084ea133fd7Smrg continue 2085ea133fd7Smrg ;; 2086ea133fd7Smrg 2087a253d6aeSmrg -static) 2088ea133fd7Smrg build_libtool_libs=no 2089a253d6aeSmrg build_old_libs=yes 2090a253d6aeSmrg continue 2091a253d6aeSmrg ;; 2092a253d6aeSmrg 2093a253d6aeSmrg -prefer-pic) 2094a253d6aeSmrg pic_mode=yes 2095a253d6aeSmrg continue 2096a253d6aeSmrg ;; 2097a253d6aeSmrg 2098a253d6aeSmrg -prefer-non-pic) 2099a253d6aeSmrg pic_mode=no 2100a253d6aeSmrg continue 2101a253d6aeSmrg ;; 2102a253d6aeSmrg esac 2103a253d6aeSmrg done 2104a253d6aeSmrg 2105ea133fd7Smrg func_quote_for_eval "$libobj" 2106ea133fd7Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 2107ea133fd7Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 2108ea133fd7Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 2109ea133fd7Smrg func_dirname_and_basename "$obj" "/" "" 2110ea133fd7Smrg objname="$func_basename_result" 2111ea133fd7Smrg xdir="$func_dirname_result" 2112a253d6aeSmrg lobj=${xdir}$objdir/$objname 2113a253d6aeSmrg 2114ea133fd7Smrg test -z "$base_compile" && \ 2115ea133fd7Smrg func_fatal_help "you must specify a compilation command" 2116a253d6aeSmrg 2117a253d6aeSmrg # Delete any leftover library objects. 2118a253d6aeSmrg if test "$build_old_libs" = yes; then 2119a253d6aeSmrg removelist="$obj $lobj $libobj ${libobj}T" 2120a253d6aeSmrg else 2121a253d6aeSmrg removelist="$lobj $libobj ${libobj}T" 2122a253d6aeSmrg fi 2123a253d6aeSmrg 2124a253d6aeSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 2125a253d6aeSmrg case $host_os in 2126ea133fd7Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 2127a253d6aeSmrg pic_mode=default 2128a253d6aeSmrg ;; 2129a253d6aeSmrg esac 2130a253d6aeSmrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2131a253d6aeSmrg # non-PIC code in shared libraries is not supported 2132a253d6aeSmrg pic_mode=default 2133a253d6aeSmrg fi 2134a253d6aeSmrg 2135a253d6aeSmrg # Calculate the filename of the output object if compiler does 2136a253d6aeSmrg # not support -o with -c 2137a253d6aeSmrg if test "$compiler_c_o" = no; then 213825b89263Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2139a253d6aeSmrg lockfile="$output_obj.lock" 2140a253d6aeSmrg else 2141a253d6aeSmrg output_obj= 2142a253d6aeSmrg need_locks=no 2143a253d6aeSmrg lockfile= 2144a253d6aeSmrg fi 2145a253d6aeSmrg 2146a253d6aeSmrg # Lock this critical section if it is needed 2147a253d6aeSmrg # We use this script file to make the link, it avoids creating a new file 2148a253d6aeSmrg if test "$need_locks" = yes; then 2149ea133fd7Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 2150ea133fd7Smrg func_echo "Waiting for $lockfile to be removed" 2151a253d6aeSmrg sleep 2 2152a253d6aeSmrg done 2153a253d6aeSmrg elif test "$need_locks" = warn; then 2154a253d6aeSmrg if test -f "$lockfile"; then 2155ea133fd7Smrg $ECHO "\ 2156a253d6aeSmrg*** ERROR, $lockfile exists and contains: 2157a253d6aeSmrg`cat $lockfile 2>/dev/null` 2158a253d6aeSmrg 2159a253d6aeSmrgThis indicates that another process is trying to use the same 2160a253d6aeSmrgtemporary object file, and libtool could not work around it because 2161a253d6aeSmrgyour compiler does not support \`-c' and \`-o' together. If you 2162a253d6aeSmrgrepeat this compilation, it may succeed, by chance, but you had better 2163a253d6aeSmrgavoid parallel builds (make -j) in this platform, or get a better 2164a253d6aeSmrgcompiler." 2165a253d6aeSmrg 2166ea133fd7Smrg $opt_dry_run || $RM $removelist 2167a253d6aeSmrg exit $EXIT_FAILURE 2168a253d6aeSmrg fi 216906f32fbeSmrg func_append removelist " $output_obj" 2170ea133fd7Smrg $ECHO "$srcfile" > "$lockfile" 2171a253d6aeSmrg fi 2172a253d6aeSmrg 2173ea133fd7Smrg $opt_dry_run || $RM $removelist 217406f32fbeSmrg func_append removelist " $lockfile" 2175ea133fd7Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 2176ea133fd7Smrg 217706f32fbeSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 217806f32fbeSmrg srcfile=$func_to_tool_file_result 2179ea133fd7Smrg func_quote_for_eval "$srcfile" 2180ea133fd7Smrg qsrcfile=$func_quote_for_eval_result 2181a253d6aeSmrg 2182a253d6aeSmrg # Only build a PIC object if we are building libtool libraries. 2183a253d6aeSmrg if test "$build_libtool_libs" = yes; then 2184a253d6aeSmrg # Without this assignment, base_compile gets emptied. 2185a253d6aeSmrg fbsd_hideous_sh_bug=$base_compile 2186a253d6aeSmrg 2187a253d6aeSmrg if test "$pic_mode" != no; then 2188a253d6aeSmrg command="$base_compile $qsrcfile $pic_flag" 2189a253d6aeSmrg else 2190a253d6aeSmrg # Don't build PIC code 2191a253d6aeSmrg command="$base_compile $qsrcfile" 2192a253d6aeSmrg fi 2193a253d6aeSmrg 2194ea133fd7Smrg func_mkdir_p "$xdir$objdir" 2195a253d6aeSmrg 2196a253d6aeSmrg if test -z "$output_obj"; then 2197a253d6aeSmrg # Place PIC objects in $objdir 219806f32fbeSmrg func_append command " -o $lobj" 2199a253d6aeSmrg fi 2200a253d6aeSmrg 2201ea133fd7Smrg func_show_eval_locale "$command" \ 2202ea133fd7Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2203a253d6aeSmrg 2204a253d6aeSmrg if test "$need_locks" = warn && 2205a253d6aeSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2206ea133fd7Smrg $ECHO "\ 2207a253d6aeSmrg*** ERROR, $lockfile contains: 2208a253d6aeSmrg`cat $lockfile 2>/dev/null` 2209a253d6aeSmrg 2210a253d6aeSmrgbut it should contain: 2211a253d6aeSmrg$srcfile 2212a253d6aeSmrg 2213a253d6aeSmrgThis indicates that another process is trying to use the same 2214a253d6aeSmrgtemporary object file, and libtool could not work around it because 2215a253d6aeSmrgyour compiler does not support \`-c' and \`-o' together. If you 2216a253d6aeSmrgrepeat this compilation, it may succeed, by chance, but you had better 2217a253d6aeSmrgavoid parallel builds (make -j) in this platform, or get a better 2218a253d6aeSmrgcompiler." 2219a253d6aeSmrg 2220ea133fd7Smrg $opt_dry_run || $RM $removelist 2221a253d6aeSmrg exit $EXIT_FAILURE 2222a253d6aeSmrg fi 2223a253d6aeSmrg 2224a253d6aeSmrg # Just move the object if needed, then go on to compile the next one 2225a253d6aeSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 2226ea133fd7Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 2227ea133fd7Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2228a253d6aeSmrg fi 2229a253d6aeSmrg 2230a253d6aeSmrg # Allow error messages only from the first compilation. 2231a253d6aeSmrg if test "$suppress_opt" = yes; then 2232ea133fd7Smrg suppress_output=' >/dev/null 2>&1' 2233a253d6aeSmrg fi 2234a253d6aeSmrg fi 2235a253d6aeSmrg 2236a253d6aeSmrg # Only build a position-dependent object if we build old libraries. 2237a253d6aeSmrg if test "$build_old_libs" = yes; then 2238a253d6aeSmrg if test "$pic_mode" != yes; then 2239a253d6aeSmrg # Don't build PIC code 2240ea133fd7Smrg command="$base_compile $qsrcfile$pie_flag" 2241a253d6aeSmrg else 2242a253d6aeSmrg command="$base_compile $qsrcfile $pic_flag" 2243a253d6aeSmrg fi 2244a253d6aeSmrg if test "$compiler_c_o" = yes; then 224506f32fbeSmrg func_append command " -o $obj" 2246a253d6aeSmrg fi 2247a253d6aeSmrg 2248a253d6aeSmrg # Suppress compiler output if we already did a PIC compilation. 224906f32fbeSmrg func_append command "$suppress_output" 2250ea133fd7Smrg func_show_eval_locale "$command" \ 2251ea133fd7Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2252a253d6aeSmrg 2253a253d6aeSmrg if test "$need_locks" = warn && 2254a253d6aeSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2255ea133fd7Smrg $ECHO "\ 2256a253d6aeSmrg*** ERROR, $lockfile contains: 2257a253d6aeSmrg`cat $lockfile 2>/dev/null` 2258a253d6aeSmrg 2259a253d6aeSmrgbut it should contain: 2260a253d6aeSmrg$srcfile 2261a253d6aeSmrg 2262a253d6aeSmrgThis indicates that another process is trying to use the same 2263a253d6aeSmrgtemporary object file, and libtool could not work around it because 2264a253d6aeSmrgyour compiler does not support \`-c' and \`-o' together. If you 2265a253d6aeSmrgrepeat this compilation, it may succeed, by chance, but you had better 2266a253d6aeSmrgavoid parallel builds (make -j) in this platform, or get a better 2267a253d6aeSmrgcompiler." 2268a253d6aeSmrg 2269ea133fd7Smrg $opt_dry_run || $RM $removelist 2270a253d6aeSmrg exit $EXIT_FAILURE 2271a253d6aeSmrg fi 2272a253d6aeSmrg 2273a253d6aeSmrg # Just move the object if needed 2274a253d6aeSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 2275ea133fd7Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 2276ea133fd7Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2277a253d6aeSmrg fi 2278a253d6aeSmrg fi 2279a253d6aeSmrg 2280ea133fd7Smrg $opt_dry_run || { 2281ea133fd7Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2282a253d6aeSmrg 2283ea133fd7Smrg # Unlock the critical section if it was locked 2284ea133fd7Smrg if test "$need_locks" != no; then 2285ea133fd7Smrg removelist=$lockfile 2286ea133fd7Smrg $RM "$lockfile" 2287ea133fd7Smrg fi 2288ea133fd7Smrg } 2289a253d6aeSmrg 2290a253d6aeSmrg exit $EXIT_SUCCESS 2291ea133fd7Smrg} 2292a253d6aeSmrg 2293ea133fd7Smrg$opt_help || { 229406f32fbeSmrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 2295ea133fd7Smrg} 2296a253d6aeSmrg 2297ea133fd7Smrgfunc_mode_help () 2298ea133fd7Smrg{ 2299ea133fd7Smrg # We need to display help for each of the modes. 230006f32fbeSmrg case $opt_mode in 2301ea133fd7Smrg "") 2302ea133fd7Smrg # Generic help is extracted from the usage comments 2303ea133fd7Smrg # at the start of this file. 2304ea133fd7Smrg func_help 2305ea133fd7Smrg ;; 2306a253d6aeSmrg 2307ea133fd7Smrg clean) 2308ea133fd7Smrg $ECHO \ 2309ea133fd7Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2310a253d6aeSmrg 2311ea133fd7SmrgRemove files from the build directory. 2312a253d6aeSmrg 2313ea133fd7SmrgRM is the name of the program to use to delete files associated with each FILE 2314ea133fd7Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2315ea133fd7Smrgto RM. 2316a253d6aeSmrg 2317ea133fd7SmrgIf FILE is a libtool library, object or program, all the files associated 2318ea133fd7Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 2319ea133fd7Smrg ;; 2320a253d6aeSmrg 2321ea133fd7Smrg compile) 2322ea133fd7Smrg $ECHO \ 2323ea133fd7Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2324a253d6aeSmrg 2325ea133fd7SmrgCompile a source file into a libtool library object. 2326a253d6aeSmrg 2327ea133fd7SmrgThis mode accepts the following additional options: 2328a253d6aeSmrg 2329ea133fd7Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 2330ea133fd7Smrg -no-suppress do not suppress compiler output for multiple passes 233125b89263Smrg -prefer-pic try to build PIC objects only 233225b89263Smrg -prefer-non-pic try to build non-PIC objects only 2333ea133fd7Smrg -shared do not build a \`.o' file suitable for static linking 2334ea133fd7Smrg -static only build a \`.o' file suitable for static linking 233525b89263Smrg -Wc,FLAG pass FLAG directly to the compiler 2336a253d6aeSmrg 2337ea133fd7SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 2338ea133fd7Smrgfrom the given SOURCEFILE. 2339a253d6aeSmrg 2340ea133fd7SmrgThe output file name is determined by removing the directory component from 2341ea133fd7SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 2342ea133fd7Smrglibrary object suffix, \`.lo'." 2343ea133fd7Smrg ;; 2344a253d6aeSmrg 2345ea133fd7Smrg execute) 2346ea133fd7Smrg $ECHO \ 2347ea133fd7Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2348a253d6aeSmrg 2349ea133fd7SmrgAutomatically set library path, then run a program. 2350a253d6aeSmrg 2351ea133fd7SmrgThis mode accepts the following additional options: 2352a253d6aeSmrg 2353ea133fd7Smrg -dlopen FILE add the directory containing FILE to the library path 2354a253d6aeSmrg 2355ea133fd7SmrgThis mode sets the library path environment variable according to \`-dlopen' 2356ea133fd7Smrgflags. 2357a253d6aeSmrg 2358ea133fd7SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 2359ea133fd7Smrginto their corresponding uninstalled binary, and any of their required library 2360ea133fd7Smrgdirectories are added to the library path. 2361a253d6aeSmrg 2362ea133fd7SmrgThen, COMMAND is executed, with ARGS as arguments." 2363ea133fd7Smrg ;; 2364a253d6aeSmrg 2365ea133fd7Smrg finish) 2366ea133fd7Smrg $ECHO \ 2367ea133fd7Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2368a253d6aeSmrg 2369ea133fd7SmrgComplete the installation of libtool libraries. 2370a253d6aeSmrg 2371ea133fd7SmrgEach LIBDIR is a directory that contains libtool libraries. 2372a253d6aeSmrg 2373ea133fd7SmrgThe commands that this mode executes may require superuser privileges. Use 2374ea133fd7Smrgthe \`--dry-run' option if you just want to see what would be executed." 2375ea133fd7Smrg ;; 2376a253d6aeSmrg 2377ea133fd7Smrg install) 2378ea133fd7Smrg $ECHO \ 2379ea133fd7Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2380a253d6aeSmrg 2381ea133fd7SmrgInstall executables or libraries. 2382a253d6aeSmrg 2383ea133fd7SmrgINSTALL-COMMAND is the installation command. The first component should be 2384ea133fd7Smrgeither the \`install' or \`cp' program. 2385a253d6aeSmrg 2386ea133fd7SmrgThe following components of INSTALL-COMMAND are treated specially: 2387a253d6aeSmrg 238825b89263Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2389a253d6aeSmrg 2390ea133fd7SmrgThe rest of the components are interpreted as arguments to that command (only 2391ea133fd7SmrgBSD-compatible install options are recognized)." 2392ea133fd7Smrg ;; 2393a253d6aeSmrg 2394ea133fd7Smrg link) 2395ea133fd7Smrg $ECHO \ 2396ea133fd7Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2397a253d6aeSmrg 2398ea133fd7SmrgLink object files or libraries together to form another library, or to 2399ea133fd7Smrgcreate an executable program. 2400a253d6aeSmrg 2401ea133fd7SmrgLINK-COMMAND is a command using the C compiler that you would use to create 2402ea133fd7Smrga program from several object files. 2403a253d6aeSmrg 2404ea133fd7SmrgThe following components of LINK-COMMAND are treated specially: 2405a253d6aeSmrg 2406ea133fd7Smrg -all-static do not do any dynamic linking at all 2407ea133fd7Smrg -avoid-version do not add a version suffix if possible 240825b89263Smrg -bindir BINDIR specify path to binaries directory (for systems where 240925b89263Smrg libraries must be found in the PATH setting at runtime) 2410ea133fd7Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 2411ea133fd7Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 2412ea133fd7Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 2413ea133fd7Smrg -export-symbols SYMFILE 2414ea133fd7Smrg try to export only the symbols listed in SYMFILE 2415ea133fd7Smrg -export-symbols-regex REGEX 2416ea133fd7Smrg try to export only the symbols matching REGEX 2417ea133fd7Smrg -LLIBDIR search LIBDIR for required installed libraries 2418ea133fd7Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 2419ea133fd7Smrg -module build a library that can dlopened 2420ea133fd7Smrg -no-fast-install disable the fast-install mode 2421ea133fd7Smrg -no-install link a not-installable executable 2422ea133fd7Smrg -no-undefined declare that a library does not refer to external symbols 2423ea133fd7Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 2424ea133fd7Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 2425ea133fd7Smrg -precious-files-regex REGEX 2426ea133fd7Smrg don't remove output files matching REGEX 2427ea133fd7Smrg -release RELEASE specify package release information 2428ea133fd7Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 2429ea133fd7Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 2430ea133fd7Smrg -shared only do dynamic linking of libtool libraries 2431ea133fd7Smrg -shrext SUFFIX override the standard shared library file extension 2432ea133fd7Smrg -static do not do any dynamic linking of uninstalled libtool libraries 2433ea133fd7Smrg -static-libtool-libs 2434ea133fd7Smrg do not do any dynamic linking of libtool libraries 2435ea133fd7Smrg -version-info CURRENT[:REVISION[:AGE]] 2436ea133fd7Smrg specify library version info [each variable defaults to 0] 2437ea133fd7Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 243825b89263Smrg -Wc,FLAG 243925b89263Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 244025b89263Smrg -Wl,FLAG 244125b89263Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 244225b89263Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2443a253d6aeSmrg 2444ea133fd7SmrgAll other options (arguments beginning with \`-') are ignored. 2445a253d6aeSmrg 2446ea133fd7SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 2447ea133fd7Smrgtreated as uninstalled libtool libraries, other files are standard or library 2448ea133fd7Smrgobject files. 2449a253d6aeSmrg 2450ea133fd7SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 2451ea133fd7Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 2452ea133fd7Smrgrequired, except when creating a convenience library. 2453a253d6aeSmrg 2454ea133fd7SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 2455ea133fd7Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 2456a253d6aeSmrg 2457ea133fd7SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 2458ea133fd7Smrgis created, otherwise an executable program is created." 2459a253d6aeSmrg ;; 2460a253d6aeSmrg 2461ea133fd7Smrg uninstall) 2462ea133fd7Smrg $ECHO \ 2463ea133fd7Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2464a253d6aeSmrg 2465ea133fd7SmrgRemove libraries from an installation directory. 2466a253d6aeSmrg 2467ea133fd7SmrgRM is the name of the program to use to delete files associated with each FILE 2468ea133fd7Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2469ea133fd7Smrgto RM. 2470a253d6aeSmrg 2471ea133fd7SmrgIf FILE is a libtool library, all the files associated with it are deleted. 2472ea133fd7SmrgOtherwise, only FILE itself is deleted using RM." 2473ea133fd7Smrg ;; 2474a253d6aeSmrg 2475ea133fd7Smrg *) 247606f32fbeSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 2477ea133fd7Smrg ;; 2478ea133fd7Smrg esac 2479a253d6aeSmrg 248025b89263Smrg echo 2481ea133fd7Smrg $ECHO "Try \`$progname --help' for more information about other modes." 2482ea133fd7Smrg} 2483a253d6aeSmrg 248425b89263Smrg# Now that we've collected a possible --mode arg, show help if necessary 248525b89263Smrgif $opt_help; then 248625b89263Smrg if test "$opt_help" = :; then 248725b89263Smrg func_mode_help 248825b89263Smrg else 248925b89263Smrg { 249025b89263Smrg func_help noexit 249106f32fbeSmrg for opt_mode in compile link execute install finish uninstall clean; do 249225b89263Smrg func_mode_help 249325b89263Smrg done 249425b89263Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 249525b89263Smrg { 249625b89263Smrg func_help noexit 249706f32fbeSmrg for opt_mode in compile link execute install finish uninstall clean; do 249825b89263Smrg echo 249925b89263Smrg func_mode_help 250025b89263Smrg done 250125b89263Smrg } | 250225b89263Smrg sed '1d 250325b89263Smrg /^When reporting/,/^Report/{ 250425b89263Smrg H 250525b89263Smrg d 250625b89263Smrg } 250725b89263Smrg $x 250825b89263Smrg /information about other modes/d 250925b89263Smrg /more detailed .*MODE/d 251025b89263Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 251125b89263Smrg fi 251225b89263Smrg exit $? 251325b89263Smrgfi 2514a253d6aeSmrg 2515a253d6aeSmrg 2516ea133fd7Smrg# func_mode_execute arg... 2517ea133fd7Smrgfunc_mode_execute () 2518ea133fd7Smrg{ 2519ea133fd7Smrg $opt_debug 2520ea133fd7Smrg # The first argument is the command name. 2521ea133fd7Smrg cmd="$nonopt" 2522ea133fd7Smrg test -z "$cmd" && \ 2523ea133fd7Smrg func_fatal_help "you must specify a COMMAND" 2524a253d6aeSmrg 2525ea133fd7Smrg # Handle -dlopen flags immediately. 252606f32fbeSmrg for file in $opt_dlopen; do 2527ea133fd7Smrg test -f "$file" \ 2528ea133fd7Smrg || func_fatal_help "\`$file' is not a file" 2529a253d6aeSmrg 2530ea133fd7Smrg dir= 2531ea133fd7Smrg case $file in 2532ea133fd7Smrg *.la) 253306f32fbeSmrg func_resolve_sysroot "$file" 253406f32fbeSmrg file=$func_resolve_sysroot_result 253506f32fbeSmrg 2536ea133fd7Smrg # Check to see that this really is a libtool archive. 2537ea133fd7Smrg func_lalib_unsafe_p "$file" \ 2538ea133fd7Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 2539a253d6aeSmrg 2540ea133fd7Smrg # Read the libtool library. 2541ea133fd7Smrg dlname= 2542ea133fd7Smrg library_names= 2543ea133fd7Smrg func_source "$file" 2544a253d6aeSmrg 2545ea133fd7Smrg # Skip this library if it cannot be dlopened. 2546ea133fd7Smrg if test -z "$dlname"; then 2547ea133fd7Smrg # Warn if it was a shared library. 2548ea133fd7Smrg test -n "$library_names" && \ 2549ea133fd7Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 2550ea133fd7Smrg continue 2551ea133fd7Smrg fi 2552a253d6aeSmrg 2553ea133fd7Smrg func_dirname "$file" "" "." 2554ea133fd7Smrg dir="$func_dirname_result" 2555a253d6aeSmrg 2556ea133fd7Smrg if test -f "$dir/$objdir/$dlname"; then 255706f32fbeSmrg func_append dir "/$objdir" 2558ea133fd7Smrg else 2559ea133fd7Smrg if test ! -f "$dir/$dlname"; then 2560ea133fd7Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 2561ea133fd7Smrg fi 2562ea133fd7Smrg fi 2563a253d6aeSmrg ;; 2564a253d6aeSmrg 2565ea133fd7Smrg *.lo) 2566ea133fd7Smrg # Just add the directory containing the .lo file. 2567ea133fd7Smrg func_dirname "$file" "" "." 2568ea133fd7Smrg dir="$func_dirname_result" 2569a253d6aeSmrg ;; 2570a253d6aeSmrg 2571ea133fd7Smrg *) 2572ea133fd7Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 2573a253d6aeSmrg continue 2574a253d6aeSmrg ;; 2575ea133fd7Smrg esac 2576a253d6aeSmrg 2577ea133fd7Smrg # Get the absolute pathname. 2578ea133fd7Smrg absdir=`cd "$dir" && pwd` 2579ea133fd7Smrg test -n "$absdir" && dir="$absdir" 2580a253d6aeSmrg 2581ea133fd7Smrg # Now add the directory to shlibpath_var. 2582ea133fd7Smrg if eval "test -z \"\$$shlibpath_var\""; then 2583ea133fd7Smrg eval "$shlibpath_var=\"\$dir\"" 2584ea133fd7Smrg else 2585ea133fd7Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2586ea133fd7Smrg fi 2587ea133fd7Smrg done 2588a253d6aeSmrg 2589ea133fd7Smrg # This variable tells wrapper scripts just to set shlibpath_var 2590ea133fd7Smrg # rather than running their programs. 2591ea133fd7Smrg libtool_execute_magic="$magic" 2592a253d6aeSmrg 2593ea133fd7Smrg # Check if any of the arguments is a wrapper script. 2594ea133fd7Smrg args= 2595ea133fd7Smrg for file 2596ea133fd7Smrg do 2597ea133fd7Smrg case $file in 259825b89263Smrg -* | *.la | *.lo ) ;; 2599ea133fd7Smrg *) 2600ea133fd7Smrg # Do a test to see if this is really a libtool program. 2601ea133fd7Smrg if func_ltwrapper_script_p "$file"; then 2602ea133fd7Smrg func_source "$file" 2603ea133fd7Smrg # Transform arg to wrapped name. 2604ea133fd7Smrg file="$progdir/$program" 2605ea133fd7Smrg elif func_ltwrapper_executable_p "$file"; then 2606ea133fd7Smrg func_ltwrapper_scriptname "$file" 2607ea133fd7Smrg func_source "$func_ltwrapper_scriptname_result" 2608ea133fd7Smrg # Transform arg to wrapped name. 2609ea133fd7Smrg file="$progdir/$program" 2610ea133fd7Smrg fi 2611ea133fd7Smrg ;; 2612ea133fd7Smrg esac 2613ea133fd7Smrg # Quote arguments (to preserve shell metacharacters). 261406f32fbeSmrg func_append_quoted args "$file" 2615ea133fd7Smrg done 2616a253d6aeSmrg 2617ea133fd7Smrg if test "X$opt_dry_run" = Xfalse; then 2618ea133fd7Smrg if test -n "$shlibpath_var"; then 2619ea133fd7Smrg # Export the shlibpath_var. 2620ea133fd7Smrg eval "export $shlibpath_var" 2621ea133fd7Smrg fi 2622a253d6aeSmrg 2623ea133fd7Smrg # Restore saved environment variables 2624ea133fd7Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 2625ea133fd7Smrg do 2626ea133fd7Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 2627ea133fd7Smrg $lt_var=\$save_$lt_var; export $lt_var 2628ea133fd7Smrg else 2629ea133fd7Smrg $lt_unset $lt_var 2630ea133fd7Smrg fi" 2631ea133fd7Smrg done 2632a253d6aeSmrg 2633ea133fd7Smrg # Now prepare to actually exec the command. 2634ea133fd7Smrg exec_cmd="\$cmd$args" 2635ea133fd7Smrg else 2636ea133fd7Smrg # Display what would be done. 2637ea133fd7Smrg if test -n "$shlibpath_var"; then 2638ea133fd7Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 263925b89263Smrg echo "export $shlibpath_var" 2640ea133fd7Smrg fi 2641ea133fd7Smrg $ECHO "$cmd$args" 2642ea133fd7Smrg exit $EXIT_SUCCESS 2643ea133fd7Smrg fi 2644ea133fd7Smrg} 2645a253d6aeSmrg 264606f32fbeSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2647a253d6aeSmrg 2648a253d6aeSmrg 2649ea133fd7Smrg# func_mode_finish arg... 2650ea133fd7Smrgfunc_mode_finish () 2651ea133fd7Smrg{ 2652ea133fd7Smrg $opt_debug 265306f32fbeSmrg libs= 265406f32fbeSmrg libdirs= 2655ea133fd7Smrg admincmds= 2656a253d6aeSmrg 265706f32fbeSmrg for opt in "$nonopt" ${1+"$@"} 265806f32fbeSmrg do 265906f32fbeSmrg if test -d "$opt"; then 266006f32fbeSmrg func_append libdirs " $opt" 266106f32fbeSmrg 266206f32fbeSmrg elif test -f "$opt"; then 266306f32fbeSmrg if func_lalib_unsafe_p "$opt"; then 266406f32fbeSmrg func_append libs " $opt" 266506f32fbeSmrg else 266606f32fbeSmrg func_warning "\`$opt' is not a valid libtool archive" 266706f32fbeSmrg fi 266806f32fbeSmrg 266906f32fbeSmrg else 267006f32fbeSmrg func_fatal_error "invalid argument \`$opt'" 267106f32fbeSmrg fi 267206f32fbeSmrg done 267306f32fbeSmrg 267406f32fbeSmrg if test -n "$libs"; then 267506f32fbeSmrg if test -n "$lt_sysroot"; then 267606f32fbeSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 267706f32fbeSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 267806f32fbeSmrg else 267906f32fbeSmrg sysroot_cmd= 268006f32fbeSmrg fi 268106f32fbeSmrg 268206f32fbeSmrg # Remove sysroot references 268306f32fbeSmrg if $opt_dry_run; then 268406f32fbeSmrg for lib in $libs; do 268506f32fbeSmrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 268606f32fbeSmrg done 268706f32fbeSmrg else 268806f32fbeSmrg tmpdir=`func_mktempdir` 268906f32fbeSmrg for lib in $libs; do 269006f32fbeSmrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 269106f32fbeSmrg > $tmpdir/tmp-la 269206f32fbeSmrg mv -f $tmpdir/tmp-la $lib 269306f32fbeSmrg done 269406f32fbeSmrg ${RM}r "$tmpdir" 269506f32fbeSmrg fi 269606f32fbeSmrg fi 2697a253d6aeSmrg 269806f32fbeSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2699ea133fd7Smrg for libdir in $libdirs; do 2700ea133fd7Smrg if test -n "$finish_cmds"; then 2701ea133fd7Smrg # Do each command in the finish commands. 2702ea133fd7Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 2703ea133fd7Smrg'"$cmd"'"' 2704ea133fd7Smrg fi 2705ea133fd7Smrg if test -n "$finish_eval"; then 2706ea133fd7Smrg # Do the single finish_eval. 2707ea133fd7Smrg eval cmds=\"$finish_eval\" 270806f32fbeSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 2709ea133fd7Smrg $cmds" 2710ea133fd7Smrg fi 2711ea133fd7Smrg done 2712ea133fd7Smrg fi 2713a253d6aeSmrg 2714ea133fd7Smrg # Exit here if they wanted silent mode. 2715ea133fd7Smrg $opt_silent && exit $EXIT_SUCCESS 2716a253d6aeSmrg 271706f32fbeSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 271806f32fbeSmrg echo "----------------------------------------------------------------------" 271906f32fbeSmrg echo "Libraries have been installed in:" 272006f32fbeSmrg for libdir in $libdirs; do 272106f32fbeSmrg $ECHO " $libdir" 272206f32fbeSmrg done 272306f32fbeSmrg echo 272406f32fbeSmrg echo "If you ever happen to want to link against installed libraries" 272506f32fbeSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 272606f32fbeSmrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 272706f32fbeSmrg echo "flag during linking and do at least one of the following:" 272806f32fbeSmrg if test -n "$shlibpath_var"; then 272906f32fbeSmrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 273006f32fbeSmrg echo " during execution" 273106f32fbeSmrg fi 273206f32fbeSmrg if test -n "$runpath_var"; then 273306f32fbeSmrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 273406f32fbeSmrg echo " during linking" 273506f32fbeSmrg fi 273606f32fbeSmrg if test -n "$hardcode_libdir_flag_spec"; then 273706f32fbeSmrg libdir=LIBDIR 273806f32fbeSmrg eval flag=\"$hardcode_libdir_flag_spec\" 2739a253d6aeSmrg 274006f32fbeSmrg $ECHO " - use the \`$flag' linker flag" 274106f32fbeSmrg fi 274206f32fbeSmrg if test -n "$admincmds"; then 274306f32fbeSmrg $ECHO " - have your system administrator run these commands:$admincmds" 274406f32fbeSmrg fi 274506f32fbeSmrg if test -f /etc/ld.so.conf; then 274606f32fbeSmrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 274706f32fbeSmrg fi 274806f32fbeSmrg echo 2749a253d6aeSmrg 275006f32fbeSmrg echo "See any operating system documentation about shared libraries for" 275106f32fbeSmrg case $host in 275206f32fbeSmrg solaris2.[6789]|solaris2.1[0-9]) 275306f32fbeSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 275406f32fbeSmrg echo "pages." 275506f32fbeSmrg ;; 275606f32fbeSmrg *) 275706f32fbeSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 275806f32fbeSmrg ;; 275906f32fbeSmrg esac 276006f32fbeSmrg echo "----------------------------------------------------------------------" 276106f32fbeSmrg fi 2762ea133fd7Smrg exit $EXIT_SUCCESS 2763ea133fd7Smrg} 2764a253d6aeSmrg 276506f32fbeSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2766a253d6aeSmrg 2767a253d6aeSmrg 2768ea133fd7Smrg# func_mode_install arg... 2769ea133fd7Smrgfunc_mode_install () 2770ea133fd7Smrg{ 2771ea133fd7Smrg $opt_debug 2772ea133fd7Smrg # There may be an optional sh(1) argument at the beginning of 2773ea133fd7Smrg # install_prog (especially on Windows NT). 2774ea133fd7Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 2775ea133fd7Smrg # Allow the use of GNU shtool's install command. 277625b89263Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 2777ea133fd7Smrg # Aesthetically quote it. 2778ea133fd7Smrg func_quote_for_eval "$nonopt" 2779ea133fd7Smrg install_prog="$func_quote_for_eval_result " 2780ea133fd7Smrg arg=$1 2781ea133fd7Smrg shift 2782ea133fd7Smrg else 2783ea133fd7Smrg install_prog= 2784ea133fd7Smrg arg=$nonopt 2785ea133fd7Smrg fi 2786a253d6aeSmrg 2787ea133fd7Smrg # The real first argument should be the name of the installation program. 2788ea133fd7Smrg # Aesthetically quote it. 2789ea133fd7Smrg func_quote_for_eval "$arg" 279006f32fbeSmrg func_append install_prog "$func_quote_for_eval_result" 279125b89263Smrg install_shared_prog=$install_prog 279225b89263Smrg case " $install_prog " in 279325b89263Smrg *[\\\ /]cp\ *) install_cp=: ;; 279425b89263Smrg *) install_cp=false ;; 279525b89263Smrg esac 2796ea133fd7Smrg 2797ea133fd7Smrg # We need to accept at least all the BSD install flags. 2798ea133fd7Smrg dest= 2799ea133fd7Smrg files= 2800ea133fd7Smrg opts= 2801ea133fd7Smrg prev= 2802ea133fd7Smrg install_type= 2803ea133fd7Smrg isdir=no 2804ea133fd7Smrg stripme= 280525b89263Smrg no_mode=: 2806ea133fd7Smrg for arg 2807ea133fd7Smrg do 280825b89263Smrg arg2= 2809ea133fd7Smrg if test -n "$dest"; then 281006f32fbeSmrg func_append files " $dest" 2811ea133fd7Smrg dest=$arg 2812ea133fd7Smrg continue 2813a253d6aeSmrg fi 2814a253d6aeSmrg 2815ea133fd7Smrg case $arg in 2816ea133fd7Smrg -d) isdir=yes ;; 2817ea133fd7Smrg -f) 281825b89263Smrg if $install_cp; then :; else 281925b89263Smrg prev=$arg 282025b89263Smrg fi 2821ea133fd7Smrg ;; 2822ea133fd7Smrg -g | -m | -o) 2823ea133fd7Smrg prev=$arg 2824ea133fd7Smrg ;; 2825ea133fd7Smrg -s) 2826ea133fd7Smrg stripme=" -s" 2827ea133fd7Smrg continue 2828ea133fd7Smrg ;; 2829ea133fd7Smrg -*) 2830ea133fd7Smrg ;; 2831ea133fd7Smrg *) 2832ea133fd7Smrg # If the previous option needed an argument, then skip it. 2833ea133fd7Smrg if test -n "$prev"; then 283425b89263Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 283525b89263Smrg arg2=$install_override_mode 283625b89263Smrg no_mode=false 283725b89263Smrg fi 2838ea133fd7Smrg prev= 2839ea133fd7Smrg else 2840ea133fd7Smrg dest=$arg 2841ea133fd7Smrg continue 2842ea133fd7Smrg fi 2843ea133fd7Smrg ;; 2844ea133fd7Smrg esac 2845a253d6aeSmrg 2846ea133fd7Smrg # Aesthetically quote the argument. 2847ea133fd7Smrg func_quote_for_eval "$arg" 284806f32fbeSmrg func_append install_prog " $func_quote_for_eval_result" 284925b89263Smrg if test -n "$arg2"; then 285025b89263Smrg func_quote_for_eval "$arg2" 285125b89263Smrg fi 285206f32fbeSmrg func_append install_shared_prog " $func_quote_for_eval_result" 2853ea133fd7Smrg done 2854a253d6aeSmrg 2855ea133fd7Smrg test -z "$install_prog" && \ 2856ea133fd7Smrg func_fatal_help "you must specify an install program" 2857a253d6aeSmrg 2858ea133fd7Smrg test -n "$prev" && \ 2859ea133fd7Smrg func_fatal_help "the \`$prev' option requires an argument" 2860a253d6aeSmrg 286125b89263Smrg if test -n "$install_override_mode" && $no_mode; then 286225b89263Smrg if $install_cp; then :; else 286325b89263Smrg func_quote_for_eval "$install_override_mode" 286406f32fbeSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 286525b89263Smrg fi 286625b89263Smrg fi 286725b89263Smrg 2868ea133fd7Smrg if test -z "$files"; then 2869ea133fd7Smrg if test -z "$dest"; then 2870ea133fd7Smrg func_fatal_help "no file or destination specified" 2871ea133fd7Smrg else 2872ea133fd7Smrg func_fatal_help "you must specify a destination" 2873a253d6aeSmrg fi 2874a253d6aeSmrg fi 2875a253d6aeSmrg 2876ea133fd7Smrg # Strip any trailing slash from the destination. 2877ea133fd7Smrg func_stripname '' '/' "$dest" 2878ea133fd7Smrg dest=$func_stripname_result 2879a253d6aeSmrg 2880ea133fd7Smrg # Check to see that the destination is a directory. 2881ea133fd7Smrg test -d "$dest" && isdir=yes 2882ea133fd7Smrg if test "$isdir" = yes; then 2883ea133fd7Smrg destdir="$dest" 2884ea133fd7Smrg destname= 2885ea133fd7Smrg else 2886ea133fd7Smrg func_dirname_and_basename "$dest" "" "." 2887ea133fd7Smrg destdir="$func_dirname_result" 2888ea133fd7Smrg destname="$func_basename_result" 2889ea133fd7Smrg 2890ea133fd7Smrg # Not a directory, so check to see that there is only one file specified. 2891ea133fd7Smrg set dummy $files; shift 2892ea133fd7Smrg test "$#" -gt 1 && \ 2893ea133fd7Smrg func_fatal_help "\`$dest' is not a directory" 2894ea133fd7Smrg fi 2895ea133fd7Smrg case $destdir in 2896ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 2897a253d6aeSmrg *) 2898ea133fd7Smrg for file in $files; do 2899ea133fd7Smrg case $file in 2900ea133fd7Smrg *.lo) ;; 2901ea133fd7Smrg *) 2902ea133fd7Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 2903ea133fd7Smrg ;; 2904ea133fd7Smrg esac 2905ea133fd7Smrg done 2906a253d6aeSmrg ;; 2907a253d6aeSmrg esac 2908a253d6aeSmrg 2909ea133fd7Smrg # This variable tells wrapper scripts just to set variables rather 2910ea133fd7Smrg # than running their programs. 2911ea133fd7Smrg libtool_install_magic="$magic" 2912a253d6aeSmrg 2913ea133fd7Smrg staticlibs= 2914ea133fd7Smrg future_libdirs= 2915ea133fd7Smrg current_libdirs= 2916ea133fd7Smrg for file in $files; do 2917a253d6aeSmrg 2918ea133fd7Smrg # Do each installation. 2919ea133fd7Smrg case $file in 2920ea133fd7Smrg *.$libext) 2921ea133fd7Smrg # Do the static libraries later. 292206f32fbeSmrg func_append staticlibs " $file" 2923ea133fd7Smrg ;; 2924ea133fd7Smrg 2925ea133fd7Smrg *.la) 292606f32fbeSmrg func_resolve_sysroot "$file" 292706f32fbeSmrg file=$func_resolve_sysroot_result 292806f32fbeSmrg 2929ea133fd7Smrg # Check to see that this really is a libtool archive. 2930ea133fd7Smrg func_lalib_unsafe_p "$file" \ 2931ea133fd7Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 2932ea133fd7Smrg 2933ea133fd7Smrg library_names= 2934ea133fd7Smrg old_library= 2935ea133fd7Smrg relink_command= 2936ea133fd7Smrg func_source "$file" 2937ea133fd7Smrg 2938ea133fd7Smrg # Add the libdir to current_libdirs if it is the destination. 2939ea133fd7Smrg if test "X$destdir" = "X$libdir"; then 2940ea133fd7Smrg case "$current_libdirs " in 2941ea133fd7Smrg *" $libdir "*) ;; 294206f32fbeSmrg *) func_append current_libdirs " $libdir" ;; 2943a253d6aeSmrg esac 2944ea133fd7Smrg else 2945ea133fd7Smrg # Note the libdir as a future libdir. 2946ea133fd7Smrg case "$future_libdirs " in 2947ea133fd7Smrg *" $libdir "*) ;; 294806f32fbeSmrg *) func_append future_libdirs " $libdir" ;; 2949ea133fd7Smrg esac 2950ea133fd7Smrg fi 2951a253d6aeSmrg 2952ea133fd7Smrg func_dirname "$file" "/" "" 2953ea133fd7Smrg dir="$func_dirname_result" 295406f32fbeSmrg func_append dir "$objdir" 2955ea133fd7Smrg 2956ea133fd7Smrg if test -n "$relink_command"; then 2957ea133fd7Smrg # Determine the prefix the user has applied to our future dir. 295825b89263Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2959ea133fd7Smrg 2960ea133fd7Smrg # Don't allow the user to place us outside of our expected 2961ea133fd7Smrg # location b/c this prevents finding dependent libraries that 2962ea133fd7Smrg # are installed to the same prefix. 2963ea133fd7Smrg # At present, this check doesn't affect windows .dll's that 2964ea133fd7Smrg # are installed into $libdir/../bin (currently, that works fine) 2965ea133fd7Smrg # but it's something to keep an eye on. 2966ea133fd7Smrg test "$inst_prefix_dir" = "$destdir" && \ 2967ea133fd7Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 2968ea133fd7Smrg 2969ea133fd7Smrg if test -n "$inst_prefix_dir"; then 2970ea133fd7Smrg # Stick the inst_prefix_dir data into the link command. 297125b89263Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2972ea133fd7Smrg else 297325b89263Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2974ea133fd7Smrg fi 2975ea133fd7Smrg 2976ea133fd7Smrg func_warning "relinking \`$file'" 2977ea133fd7Smrg func_show_eval "$relink_command" \ 2978ea133fd7Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 2979ea133fd7Smrg fi 2980ea133fd7Smrg 2981ea133fd7Smrg # See the names of the shared library. 2982ea133fd7Smrg set dummy $library_names; shift 2983ea133fd7Smrg if test -n "$1"; then 2984ea133fd7Smrg realname="$1" 2985ea133fd7Smrg shift 2986ea133fd7Smrg 2987ea133fd7Smrg srcname="$realname" 2988ea133fd7Smrg test -n "$relink_command" && srcname="$realname"T 2989ea133fd7Smrg 2990ea133fd7Smrg # Install the shared library and build the symlinks. 299125b89263Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 2992ea133fd7Smrg 'exit $?' 2993ea133fd7Smrg tstripme="$stripme" 2994ea133fd7Smrg case $host_os in 2995ea133fd7Smrg cygwin* | mingw* | pw32* | cegcc*) 2996ea133fd7Smrg case $realname in 2997ea133fd7Smrg *.dll.a) 2998ea133fd7Smrg tstripme="" 2999ea133fd7Smrg ;; 3000ea133fd7Smrg esac 3001a253d6aeSmrg ;; 3002a253d6aeSmrg esac 3003ea133fd7Smrg if test -n "$tstripme" && test -n "$striplib"; then 3004ea133fd7Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 3005a253d6aeSmrg fi 3006ea133fd7Smrg 3007ea133fd7Smrg if test "$#" -gt 0; then 3008ea133fd7Smrg # Delete the old symlinks, and create new ones. 3009ea133fd7Smrg # Try `ln -sf' first, because the `ln' binary might depend on 3010ea133fd7Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 3011ea133fd7Smrg # so we also need to try rm && ln -s. 3012ea133fd7Smrg for linkname 3013ea133fd7Smrg do 3014ea133fd7Smrg test "$linkname" != "$realname" \ 3015ea133fd7Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3016a253d6aeSmrg done 3017a253d6aeSmrg fi 3018a253d6aeSmrg 3019ea133fd7Smrg # Do each command in the postinstall commands. 3020ea133fd7Smrg lib="$destdir/$realname" 3021ea133fd7Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 3022a253d6aeSmrg fi 3023a253d6aeSmrg 3024ea133fd7Smrg # Install the pseudo-library for information purposes. 3025ea133fd7Smrg func_basename "$file" 3026ea133fd7Smrg name="$func_basename_result" 3027ea133fd7Smrg instname="$dir/$name"i 3028ea133fd7Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3029a253d6aeSmrg 3030ea133fd7Smrg # Maybe install the static library, too. 303106f32fbeSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 3032ea133fd7Smrg ;; 3033a253d6aeSmrg 3034ea133fd7Smrg *.lo) 3035ea133fd7Smrg # Install (i.e. copy) a libtool object. 3036a253d6aeSmrg 3037ea133fd7Smrg # Figure out destination file name, if it wasn't already specified. 3038ea133fd7Smrg if test -n "$destname"; then 3039ea133fd7Smrg destfile="$destdir/$destname" 3040ea133fd7Smrg else 3041ea133fd7Smrg func_basename "$file" 3042ea133fd7Smrg destfile="$func_basename_result" 3043ea133fd7Smrg destfile="$destdir/$destfile" 3044ea133fd7Smrg fi 3045ea133fd7Smrg 3046ea133fd7Smrg # Deduce the name of the destination old-style object file. 3047ea133fd7Smrg case $destfile in 3048ea133fd7Smrg *.lo) 3049ea133fd7Smrg func_lo2o "$destfile" 3050ea133fd7Smrg staticdest=$func_lo2o_result 3051ea133fd7Smrg ;; 3052ea133fd7Smrg *.$objext) 3053ea133fd7Smrg staticdest="$destfile" 3054ea133fd7Smrg destfile= 3055ea133fd7Smrg ;; 3056ea133fd7Smrg *) 3057ea133fd7Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 3058ea133fd7Smrg ;; 3059a253d6aeSmrg esac 3060a253d6aeSmrg 3061ea133fd7Smrg # Install the libtool object if requested. 3062ea133fd7Smrg test -n "$destfile" && \ 3063ea133fd7Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 3064ea133fd7Smrg 3065ea133fd7Smrg # Install the old object if enabled. 3066ea133fd7Smrg if test "$build_old_libs" = yes; then 3067ea133fd7Smrg # Deduce the name of the old-style object file. 3068ea133fd7Smrg func_lo2o "$file" 3069ea133fd7Smrg staticobj=$func_lo2o_result 3070ea133fd7Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3071a253d6aeSmrg fi 3072ea133fd7Smrg exit $EXIT_SUCCESS 3073ea133fd7Smrg ;; 3074a253d6aeSmrg 3075ea133fd7Smrg *) 3076ea133fd7Smrg # Figure out destination file name, if it wasn't already specified. 3077ea133fd7Smrg if test -n "$destname"; then 3078ea133fd7Smrg destfile="$destdir/$destname" 3079ea133fd7Smrg else 3080ea133fd7Smrg func_basename "$file" 3081ea133fd7Smrg destfile="$func_basename_result" 3082ea133fd7Smrg destfile="$destdir/$destfile" 3083ea133fd7Smrg fi 3084ea133fd7Smrg 3085ea133fd7Smrg # If the file is missing, and there is a .exe on the end, strip it 3086ea133fd7Smrg # because it is most likely a libtool script we actually want to 3087ea133fd7Smrg # install 3088ea133fd7Smrg stripped_ext="" 3089ea133fd7Smrg case $file in 3090ea133fd7Smrg *.exe) 3091ea133fd7Smrg if test ! -f "$file"; then 3092ea133fd7Smrg func_stripname '' '.exe' "$file" 3093ea133fd7Smrg file=$func_stripname_result 3094ea133fd7Smrg stripped_ext=".exe" 3095a253d6aeSmrg fi 3096ea133fd7Smrg ;; 3097ea133fd7Smrg esac 3098a253d6aeSmrg 3099ea133fd7Smrg # Do a test to see if this is really a libtool program. 3100ea133fd7Smrg case $host in 3101ea133fd7Smrg *cygwin* | *mingw*) 3102ea133fd7Smrg if func_ltwrapper_executable_p "$file"; then 3103ea133fd7Smrg func_ltwrapper_scriptname "$file" 3104ea133fd7Smrg wrapper=$func_ltwrapper_scriptname_result 3105ea133fd7Smrg else 3106ea133fd7Smrg func_stripname '' '.exe' "$file" 3107ea133fd7Smrg wrapper=$func_stripname_result 3108ea133fd7Smrg fi 3109ea133fd7Smrg ;; 3110ea133fd7Smrg *) 3111ea133fd7Smrg wrapper=$file 3112ea133fd7Smrg ;; 3113ea133fd7Smrg esac 3114ea133fd7Smrg if func_ltwrapper_script_p "$wrapper"; then 3115ea133fd7Smrg notinst_deplibs= 3116ea133fd7Smrg relink_command= 3117a253d6aeSmrg 3118ea133fd7Smrg func_source "$wrapper" 3119a253d6aeSmrg 3120ea133fd7Smrg # Check the variables that should have been set. 3121ea133fd7Smrg test -z "$generated_by_libtool_version" && \ 3122ea133fd7Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3123ea133fd7Smrg 3124ea133fd7Smrg finalize=yes 3125ea133fd7Smrg for lib in $notinst_deplibs; do 3126ea133fd7Smrg # Check to see that each library is installed. 3127ea133fd7Smrg libdir= 3128ea133fd7Smrg if test -f "$lib"; then 3129ea133fd7Smrg func_source "$lib" 3130ea133fd7Smrg fi 313125b89263Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 3132ea133fd7Smrg if test -n "$libdir" && test ! -f "$libfile"; then 3133ea133fd7Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 3134ea133fd7Smrg finalize=no 3135ea133fd7Smrg fi 3136ea133fd7Smrg done 3137ea133fd7Smrg 3138ea133fd7Smrg relink_command= 3139ea133fd7Smrg func_source "$wrapper" 3140ea133fd7Smrg 3141ea133fd7Smrg outputname= 3142ea133fd7Smrg if test "$fast_install" = no && test -n "$relink_command"; then 3143ea133fd7Smrg $opt_dry_run || { 3144ea133fd7Smrg if test "$finalize" = yes; then 3145ea133fd7Smrg tmpdir=`func_mktempdir` 3146ea133fd7Smrg func_basename "$file$stripped_ext" 3147ea133fd7Smrg file="$func_basename_result" 3148ea133fd7Smrg outputname="$tmpdir/$file" 3149ea133fd7Smrg # Replace the output file specification. 315025b89263Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 3151ea133fd7Smrg 3152ea133fd7Smrg $opt_silent || { 3153ea133fd7Smrg func_quote_for_expand "$relink_command" 3154ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 3155ea133fd7Smrg } 3156ea133fd7Smrg if eval "$relink_command"; then : 3157ea133fd7Smrg else 3158ea133fd7Smrg func_error "error: relink \`$file' with the above command before installing it" 3159ea133fd7Smrg $opt_dry_run || ${RM}r "$tmpdir" 3160ea133fd7Smrg continue 3161ea133fd7Smrg fi 3162ea133fd7Smrg file="$outputname" 3163ea133fd7Smrg else 3164ea133fd7Smrg func_warning "cannot relink \`$file'" 3165ea133fd7Smrg fi 3166ea133fd7Smrg } 3167a253d6aeSmrg else 3168ea133fd7Smrg # Install the binary that we compiled earlier. 316925b89263Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 3170a253d6aeSmrg fi 3171ea133fd7Smrg fi 3172a253d6aeSmrg 3173ea133fd7Smrg # remove .exe since cygwin /usr/bin/install will append another 3174ea133fd7Smrg # one anyway 3175ea133fd7Smrg case $install_prog,$host in 3176ea133fd7Smrg */usr/bin/install*,*cygwin*) 3177ea133fd7Smrg case $file:$destfile in 3178ea133fd7Smrg *.exe:*.exe) 3179ea133fd7Smrg # this is ok 3180ea133fd7Smrg ;; 3181ea133fd7Smrg *.exe:*) 3182ea133fd7Smrg destfile=$destfile.exe 3183ea133fd7Smrg ;; 3184ea133fd7Smrg *:*.exe) 3185ea133fd7Smrg func_stripname '' '.exe' "$destfile" 3186ea133fd7Smrg destfile=$func_stripname_result 3187ea133fd7Smrg ;; 3188ea133fd7Smrg esac 3189a253d6aeSmrg ;; 3190a253d6aeSmrg esac 3191ea133fd7Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 3192ea133fd7Smrg $opt_dry_run || if test -n "$outputname"; then 3193ea133fd7Smrg ${RM}r "$tmpdir" 3194ea133fd7Smrg fi 3195ea133fd7Smrg ;; 3196ea133fd7Smrg esac 3197ea133fd7Smrg done 3198a253d6aeSmrg 3199ea133fd7Smrg for file in $staticlibs; do 3200ea133fd7Smrg func_basename "$file" 3201ea133fd7Smrg name="$func_basename_result" 3202a253d6aeSmrg 3203ea133fd7Smrg # Set up the ranlib parameters. 3204ea133fd7Smrg oldlib="$destdir/$name" 320557ee1794Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 320657ee1794Smrg tool_oldlib=$func_to_tool_file_result 3207a253d6aeSmrg 3208ea133fd7Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 3209a253d6aeSmrg 3210ea133fd7Smrg if test -n "$stripme" && test -n "$old_striplib"; then 321157ee1794Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 3212ea133fd7Smrg fi 3213a253d6aeSmrg 3214ea133fd7Smrg # Do each command in the postinstall commands. 3215ea133fd7Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 3216ea133fd7Smrg done 3217a253d6aeSmrg 3218ea133fd7Smrg test -n "$future_libdirs" && \ 3219ea133fd7Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 3220a253d6aeSmrg 3221ea133fd7Smrg if test -n "$current_libdirs"; then 3222ea133fd7Smrg # Maybe just do a dry run. 3223ea133fd7Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 3224ea133fd7Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 3225ea133fd7Smrg else 3226ea133fd7Smrg exit $EXIT_SUCCESS 3227ea133fd7Smrg fi 3228ea133fd7Smrg} 3229a253d6aeSmrg 323006f32fbeSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 3231a253d6aeSmrg 3232a253d6aeSmrg 3233ea133fd7Smrg# func_generate_dlsyms outputname originator pic_p 3234ea133fd7Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 3235ea133fd7Smrg# a dlpreopen symbol table. 3236ea133fd7Smrgfunc_generate_dlsyms () 3237ea133fd7Smrg{ 3238ea133fd7Smrg $opt_debug 3239ea133fd7Smrg my_outputname="$1" 3240ea133fd7Smrg my_originator="$2" 3241ea133fd7Smrg my_pic_p="${3-no}" 3242ea133fd7Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 3243ea133fd7Smrg my_dlsyms= 3244ea133fd7Smrg 3245ea133fd7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 3246ea133fd7Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 3247ea133fd7Smrg my_dlsyms="${my_outputname}S.c" 3248ea133fd7Smrg else 3249ea133fd7Smrg func_error "not configured to extract global symbols from dlpreopened files" 3250ea133fd7Smrg fi 3251ea133fd7Smrg fi 3252a253d6aeSmrg 3253ea133fd7Smrg if test -n "$my_dlsyms"; then 3254ea133fd7Smrg case $my_dlsyms in 3255ea133fd7Smrg "") ;; 3256ea133fd7Smrg *.c) 3257ea133fd7Smrg # Discover the nlist of each of the dlfiles. 3258ea133fd7Smrg nlist="$output_objdir/${my_outputname}.nm" 3259ea133fd7Smrg 3260ea133fd7Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3261ea133fd7Smrg 3262ea133fd7Smrg # Parse the name list into a source file. 3263ea133fd7Smrg func_verbose "creating $output_objdir/$my_dlsyms" 3264ea133fd7Smrg 3265ea133fd7Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 3266ea133fd7Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 3267ea133fd7Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3268ea133fd7Smrg 3269ea133fd7Smrg#ifdef __cplusplus 3270ea133fd7Smrgextern \"C\" { 3271ea133fd7Smrg#endif 3272ea133fd7Smrg 327325b89263Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 327425b89263Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 327525b89263Smrg#endif 327625b89263Smrg 327706f32fbeSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 327806f32fbeSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 327906f32fbeSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 328006f32fbeSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 328106f32fbeSmrg# define LT_DLSYM_CONST 328206f32fbeSmrg#elif defined(__osf__) 328306f32fbeSmrg/* This system does not cope well with relocations in const data. */ 328406f32fbeSmrg# define LT_DLSYM_CONST 328506f32fbeSmrg#else 328606f32fbeSmrg# define LT_DLSYM_CONST const 328706f32fbeSmrg#endif 328806f32fbeSmrg 3289ea133fd7Smrg/* External symbol declarations for the compiler. */\ 3290ea133fd7Smrg" 3291ea133fd7Smrg 3292ea133fd7Smrg if test "$dlself" = yes; then 3293ea133fd7Smrg func_verbose "generating symbol list for \`$output'" 3294ea133fd7Smrg 3295ea133fd7Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3296ea133fd7Smrg 3297ea133fd7Smrg # Add our own program objects to the symbol list. 329825b89263Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 3299ea133fd7Smrg for progfile in $progfiles; do 330006f32fbeSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 330106f32fbeSmrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 330206f32fbeSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3303ea133fd7Smrg done 3304ea133fd7Smrg 3305ea133fd7Smrg if test -n "$exclude_expsyms"; then 3306ea133fd7Smrg $opt_dry_run || { 3307ea133fd7Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 3308ea133fd7Smrg eval '$MV "$nlist"T "$nlist"' 3309ea133fd7Smrg } 3310a253d6aeSmrg fi 3311a253d6aeSmrg 3312ea133fd7Smrg if test -n "$export_symbols_regex"; then 3313ea133fd7Smrg $opt_dry_run || { 3314ea133fd7Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 3315ea133fd7Smrg eval '$MV "$nlist"T "$nlist"' 3316ea133fd7Smrg } 3317a253d6aeSmrg fi 3318ea133fd7Smrg 3319ea133fd7Smrg # Prepare the list of exported symbols 3320ea133fd7Smrg if test -z "$export_symbols"; then 3321ea133fd7Smrg export_symbols="$output_objdir/$outputname.exp" 3322ea133fd7Smrg $opt_dry_run || { 3323ea133fd7Smrg $RM $export_symbols 3324ea133fd7Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 3325ea133fd7Smrg case $host in 3326ea133fd7Smrg *cygwin* | *mingw* | *cegcc* ) 3327ea133fd7Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3328ea133fd7Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 3329ea133fd7Smrg ;; 3330a253d6aeSmrg esac 3331ea133fd7Smrg } 3332ea133fd7Smrg else 3333ea133fd7Smrg $opt_dry_run || { 3334ea133fd7Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 3335ea133fd7Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 3336ea133fd7Smrg eval '$MV "$nlist"T "$nlist"' 3337ea133fd7Smrg case $host in 333825b89263Smrg *cygwin* | *mingw* | *cegcc* ) 3339ea133fd7Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3340ea133fd7Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 3341ea133fd7Smrg ;; 3342a253d6aeSmrg esac 3343ea133fd7Smrg } 3344a253d6aeSmrg fi 3345ea133fd7Smrg fi 3346a253d6aeSmrg 3347ea133fd7Smrg for dlprefile in $dlprefiles; do 3348ea133fd7Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 3349ea133fd7Smrg func_basename "$dlprefile" 3350ea133fd7Smrg name="$func_basename_result" 335106f32fbeSmrg case $host in 335206f32fbeSmrg *cygwin* | *mingw* | *cegcc* ) 335306f32fbeSmrg # if an import library, we need to obtain dlname 335406f32fbeSmrg if func_win32_import_lib_p "$dlprefile"; then 335506f32fbeSmrg func_tr_sh "$dlprefile" 335606f32fbeSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 335706f32fbeSmrg dlprefile_dlbasename="" 335806f32fbeSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 335906f32fbeSmrg # Use subshell, to avoid clobbering current variable values 336006f32fbeSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 336106f32fbeSmrg if test -n "$dlprefile_dlname" ; then 336206f32fbeSmrg func_basename "$dlprefile_dlname" 336306f32fbeSmrg dlprefile_dlbasename="$func_basename_result" 336406f32fbeSmrg else 336506f32fbeSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 336606f32fbeSmrg $sharedlib_from_linklib_cmd "$dlprefile" 336706f32fbeSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 336806f32fbeSmrg fi 336906f32fbeSmrg fi 337006f32fbeSmrg $opt_dry_run || { 337106f32fbeSmrg if test -n "$dlprefile_dlbasename" ; then 337206f32fbeSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 337306f32fbeSmrg else 337406f32fbeSmrg func_warning "Could not compute DLL name from $name" 337506f32fbeSmrg eval '$ECHO ": $name " >> "$nlist"' 337606f32fbeSmrg fi 337706f32fbeSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 337806f32fbeSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 337906f32fbeSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 338006f32fbeSmrg } 338106f32fbeSmrg else # not an import lib 338206f32fbeSmrg $opt_dry_run || { 338306f32fbeSmrg eval '$ECHO ": $name " >> "$nlist"' 338406f32fbeSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 338506f32fbeSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 338606f32fbeSmrg } 338706f32fbeSmrg fi 338806f32fbeSmrg ;; 338906f32fbeSmrg *) 339006f32fbeSmrg $opt_dry_run || { 339106f32fbeSmrg eval '$ECHO ": $name " >> "$nlist"' 339206f32fbeSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 339306f32fbeSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 339406f32fbeSmrg } 339506f32fbeSmrg ;; 339606f32fbeSmrg esac 3397ea133fd7Smrg done 3398a253d6aeSmrg 3399ea133fd7Smrg $opt_dry_run || { 3400ea133fd7Smrg # Make sure we have at least an empty file. 3401ea133fd7Smrg test -f "$nlist" || : > "$nlist" 3402a253d6aeSmrg 3403ea133fd7Smrg if test -n "$exclude_expsyms"; then 3404ea133fd7Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 3405ea133fd7Smrg $MV "$nlist"T "$nlist" 3406a253d6aeSmrg fi 3407a253d6aeSmrg 3408ea133fd7Smrg # Try sorting and uniquifying the output. 3409ea133fd7Smrg if $GREP -v "^: " < "$nlist" | 3410ea133fd7Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 3411ea133fd7Smrg sort -k 3 3412a253d6aeSmrg else 3413ea133fd7Smrg sort +2 3414ea133fd7Smrg fi | 3415ea133fd7Smrg uniq > "$nlist"S; then 3416ea133fd7Smrg : 3417a253d6aeSmrg else 3418ea133fd7Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 3419a253d6aeSmrg fi 3420a253d6aeSmrg 3421ea133fd7Smrg if test -f "$nlist"S; then 3422ea133fd7Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 3423a253d6aeSmrg else 342425b89263Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 3425a253d6aeSmrg fi 3426a253d6aeSmrg 342725b89263Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3428a253d6aeSmrg 3429ea133fd7Smrg/* The mapping between symbol names and symbols. */ 3430ea133fd7Smrgtypedef struct { 3431ea133fd7Smrg const char *name; 3432ea133fd7Smrg void *address; 3433ea133fd7Smrg} lt_dlsymlist; 343406f32fbeSmrgextern LT_DLSYM_CONST lt_dlsymlist 3435ea133fd7Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 343606f32fbeSmrgLT_DLSYM_CONST lt_dlsymlist 3437ea133fd7Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 3438ea133fd7Smrg{\ 3439ea133fd7Smrg { \"$my_originator\", (void *) 0 }," 3440ea133fd7Smrg 3441ea133fd7Smrg case $need_lib_prefix in 3442ea133fd7Smrg no) 3443ea133fd7Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3444ea133fd7Smrg ;; 3445ea133fd7Smrg *) 3446ea133fd7Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3447ea133fd7Smrg ;; 3448ea133fd7Smrg esac 344925b89263Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3450ea133fd7Smrg {0, (void *) 0} 3451ea133fd7Smrg}; 3452ea133fd7Smrg 3453ea133fd7Smrg/* This works around a problem in FreeBSD linker */ 3454ea133fd7Smrg#ifdef FREEBSD_WORKAROUND 3455ea133fd7Smrgstatic const void *lt_preloaded_setup() { 3456ea133fd7Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 3457ea133fd7Smrg} 3458ea133fd7Smrg#endif 3459ea133fd7Smrg 3460ea133fd7Smrg#ifdef __cplusplus 3461ea133fd7Smrg} 3462ea133fd7Smrg#endif\ 3463ea133fd7Smrg" 3464ea133fd7Smrg } # !$opt_dry_run 3465ea133fd7Smrg 3466ea133fd7Smrg pic_flag_for_symtable= 3467ea133fd7Smrg case "$compile_command " in 3468ea133fd7Smrg *" -static "*) ;; 3469ea133fd7Smrg *) 3470ea133fd7Smrg case $host in 3471ea133fd7Smrg # compiling the symbol table file with pic_flag works around 3472ea133fd7Smrg # a FreeBSD bug that causes programs to crash when -lm is 3473ea133fd7Smrg # linked before any other PIC object. But we must not use 3474ea133fd7Smrg # pic_flag when linking with -static. The problem exists in 3475ea133fd7Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 347657ee1794Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 3477ea133fd7Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 3478ea133fd7Smrg *-*-hpux*) 3479ea133fd7Smrg pic_flag_for_symtable=" $pic_flag" ;; 3480ea133fd7Smrg *) 3481ea133fd7Smrg if test "X$my_pic_p" != Xno; then 3482ea133fd7Smrg pic_flag_for_symtable=" $pic_flag" 3483a253d6aeSmrg fi 3484ea133fd7Smrg ;; 3485ea133fd7Smrg esac 3486ea133fd7Smrg ;; 3487ea133fd7Smrg esac 3488ea133fd7Smrg symtab_cflags= 3489ea133fd7Smrg for arg in $LTCFLAGS; do 3490ea133fd7Smrg case $arg in 3491ea133fd7Smrg -pie | -fpie | -fPIE) ;; 349206f32fbeSmrg *) func_append symtab_cflags " $arg" ;; 3493ea133fd7Smrg esac 3494ea133fd7Smrg done 3495a253d6aeSmrg 3496ea133fd7Smrg # Now compile the dynamic symbol file. 3497ea133fd7Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3498a253d6aeSmrg 3499ea133fd7Smrg # Clean up the generated files. 3500ea133fd7Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3501ea133fd7Smrg 3502ea133fd7Smrg # Transform the symbol file into the correct name. 3503ea133fd7Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 3504ea133fd7Smrg case $host in 3505ea133fd7Smrg *cygwin* | *mingw* | *cegcc* ) 3506ea133fd7Smrg if test -f "$output_objdir/$my_outputname.def"; then 350725b89263Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350825b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3509ea133fd7Smrg else 351025b89263Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351125b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3512ea133fd7Smrg fi 3513ea133fd7Smrg ;; 3514ea133fd7Smrg *) 351525b89263Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351625b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3517a253d6aeSmrg ;; 3518a253d6aeSmrg esac 3519ea133fd7Smrg ;; 3520ea133fd7Smrg *) 3521ea133fd7Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 3522ea133fd7Smrg ;; 3523ea133fd7Smrg esac 3524ea133fd7Smrg else 3525ea133fd7Smrg # We keep going just in case the user didn't refer to 3526ea133fd7Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 3527ea133fd7Smrg # really was required. 3528ea133fd7Smrg 3529ea133fd7Smrg # Nullify the symbol file. 353025b89263Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 353125b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 3532a253d6aeSmrg fi 3533ea133fd7Smrg} 3534a253d6aeSmrg 3535ea133fd7Smrg# func_win32_libid arg 3536ea133fd7Smrg# return the library type of file 'arg' 3537ea133fd7Smrg# 3538ea133fd7Smrg# Need a lot of goo to handle *both* DLLs and import libs 3539ea133fd7Smrg# Has to be a shell function in order to 'eat' the argument 3540ea133fd7Smrg# that is supplied when $file_magic_command is called. 354125b89263Smrg# Despite the name, also deal with 64 bit binaries. 3542ea133fd7Smrgfunc_win32_libid () 3543ea133fd7Smrg{ 3544ea133fd7Smrg $opt_debug 3545ea133fd7Smrg win32_libid_type="unknown" 3546ea133fd7Smrg win32_fileres=`file -L $1 2>/dev/null` 3547ea133fd7Smrg case $win32_fileres in 3548ea133fd7Smrg *ar\ archive\ import\ library*) # definitely import 3549ea133fd7Smrg win32_libid_type="x86 archive import" 3550ea133fd7Smrg ;; 3551ea133fd7Smrg *ar\ archive*) # could be an import, or static 355225b89263Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 3553ea133fd7Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 355425b89263Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 355506f32fbeSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 355606f32fbeSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 3557ea133fd7Smrg $SED -n -e ' 3558ea133fd7Smrg 1,100{ 3559ea133fd7Smrg / I /{ 3560ea133fd7Smrg s,.*,import, 3561ea133fd7Smrg p 3562ea133fd7Smrg q 3563ea133fd7Smrg } 3564ea133fd7Smrg }'` 3565ea133fd7Smrg case $win32_nmres in 3566ea133fd7Smrg import*) win32_libid_type="x86 archive import";; 3567ea133fd7Smrg *) win32_libid_type="x86 archive static";; 3568ea133fd7Smrg esac 3569ea133fd7Smrg fi 3570ea133fd7Smrg ;; 3571ea133fd7Smrg *DLL*) 3572ea133fd7Smrg win32_libid_type="x86 DLL" 3573ea133fd7Smrg ;; 3574ea133fd7Smrg *executable*) # but shell scripts are "executable" too... 3575ea133fd7Smrg case $win32_fileres in 3576ea133fd7Smrg *MS\ Windows\ PE\ Intel*) 3577ea133fd7Smrg win32_libid_type="x86 DLL" 3578ea133fd7Smrg ;; 3579ea133fd7Smrg esac 3580ea133fd7Smrg ;; 3581ea133fd7Smrg esac 3582ea133fd7Smrg $ECHO "$win32_libid_type" 3583ea133fd7Smrg} 3584a253d6aeSmrg 358506f32fbeSmrg# func_cygming_dll_for_implib ARG 358606f32fbeSmrg# 358706f32fbeSmrg# Platform-specific function to extract the 358806f32fbeSmrg# name of the DLL associated with the specified 358906f32fbeSmrg# import library ARG. 359006f32fbeSmrg# Invoked by eval'ing the libtool variable 359106f32fbeSmrg# $sharedlib_from_linklib_cmd 359206f32fbeSmrg# Result is available in the variable 359306f32fbeSmrg# $sharedlib_from_linklib_result 359406f32fbeSmrgfunc_cygming_dll_for_implib () 359506f32fbeSmrg{ 359606f32fbeSmrg $opt_debug 359706f32fbeSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 359806f32fbeSmrg} 359906f32fbeSmrg 360006f32fbeSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 360106f32fbeSmrg# 360206f32fbeSmrg# The is the core of a fallback implementation of a 360306f32fbeSmrg# platform-specific function to extract the name of the 360406f32fbeSmrg# DLL associated with the specified import library LIBNAME. 360506f32fbeSmrg# 360606f32fbeSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 360706f32fbeSmrg# on the platform and compiler that created the implib. 360806f32fbeSmrg# 360906f32fbeSmrg# Echos the name of the DLL associated with the 361006f32fbeSmrg# specified import library. 361106f32fbeSmrgfunc_cygming_dll_for_implib_fallback_core () 361206f32fbeSmrg{ 361306f32fbeSmrg $opt_debug 361406f32fbeSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 361506f32fbeSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 361606f32fbeSmrg $SED '/^Contents of section '"$match_literal"':/{ 361706f32fbeSmrg # Place marker at beginning of archive member dllname section 361806f32fbeSmrg s/.*/====MARK====/ 361906f32fbeSmrg p 362006f32fbeSmrg d 362106f32fbeSmrg } 362206f32fbeSmrg # These lines can sometimes be longer than 43 characters, but 362306f32fbeSmrg # are always uninteresting 362406f32fbeSmrg /:[ ]*file format pe[i]\{,1\}-/d 362506f32fbeSmrg /^In archive [^:]*:/d 362606f32fbeSmrg # Ensure marker is printed 362706f32fbeSmrg /^====MARK====/p 362806f32fbeSmrg # Remove all lines with less than 43 characters 362906f32fbeSmrg /^.\{43\}/!d 363006f32fbeSmrg # From remaining lines, remove first 43 characters 363106f32fbeSmrg s/^.\{43\}//' | 363206f32fbeSmrg $SED -n ' 363306f32fbeSmrg # Join marker and all lines until next marker into a single line 363406f32fbeSmrg /^====MARK====/ b para 363506f32fbeSmrg H 363606f32fbeSmrg $ b para 363706f32fbeSmrg b 363806f32fbeSmrg :para 363906f32fbeSmrg x 364006f32fbeSmrg s/\n//g 364106f32fbeSmrg # Remove the marker 364206f32fbeSmrg s/^====MARK====// 364306f32fbeSmrg # Remove trailing dots and whitespace 364406f32fbeSmrg s/[\. \t]*$// 364506f32fbeSmrg # Print 364606f32fbeSmrg /./p' | 364706f32fbeSmrg # we now have a list, one entry per line, of the stringified 364806f32fbeSmrg # contents of the appropriate section of all members of the 364906f32fbeSmrg # archive which possess that section. Heuristic: eliminate 365006f32fbeSmrg # all those which have a first or second character that is 365106f32fbeSmrg # a '.' (that is, objdump's representation of an unprintable 365206f32fbeSmrg # character.) This should work for all archives with less than 365306f32fbeSmrg # 0x302f exports -- but will fail for DLLs whose name actually 365406f32fbeSmrg # begins with a literal '.' or a single character followed by 365506f32fbeSmrg # a '.'. 365606f32fbeSmrg # 365706f32fbeSmrg # Of those that remain, print the first one. 365806f32fbeSmrg $SED -e '/^\./d;/^.\./d;q' 365906f32fbeSmrg} 366006f32fbeSmrg 366106f32fbeSmrg# func_cygming_gnu_implib_p ARG 366206f32fbeSmrg# This predicate returns with zero status (TRUE) if 366306f32fbeSmrg# ARG is a GNU/binutils-style import library. Returns 366406f32fbeSmrg# with nonzero status (FALSE) otherwise. 366506f32fbeSmrgfunc_cygming_gnu_implib_p () 366606f32fbeSmrg{ 366706f32fbeSmrg $opt_debug 366806f32fbeSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 366906f32fbeSmrg 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)$'` 367006f32fbeSmrg test -n "$func_cygming_gnu_implib_tmp" 367106f32fbeSmrg} 367206f32fbeSmrg 367306f32fbeSmrg# func_cygming_ms_implib_p ARG 367406f32fbeSmrg# This predicate returns with zero status (TRUE) if 367506f32fbeSmrg# ARG is an MS-style import library. Returns 367606f32fbeSmrg# with nonzero status (FALSE) otherwise. 367706f32fbeSmrgfunc_cygming_ms_implib_p () 367806f32fbeSmrg{ 367906f32fbeSmrg $opt_debug 368006f32fbeSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 368106f32fbeSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 368206f32fbeSmrg test -n "$func_cygming_ms_implib_tmp" 368306f32fbeSmrg} 368406f32fbeSmrg 368506f32fbeSmrg# func_cygming_dll_for_implib_fallback ARG 368606f32fbeSmrg# Platform-specific function to extract the 368706f32fbeSmrg# name of the DLL associated with the specified 368806f32fbeSmrg# import library ARG. 368906f32fbeSmrg# 369006f32fbeSmrg# This fallback implementation is for use when $DLLTOOL 369106f32fbeSmrg# does not support the --identify-strict option. 369206f32fbeSmrg# Invoked by eval'ing the libtool variable 369306f32fbeSmrg# $sharedlib_from_linklib_cmd 369406f32fbeSmrg# Result is available in the variable 369506f32fbeSmrg# $sharedlib_from_linklib_result 369606f32fbeSmrgfunc_cygming_dll_for_implib_fallback () 369706f32fbeSmrg{ 369806f32fbeSmrg $opt_debug 369906f32fbeSmrg if func_cygming_gnu_implib_p "$1" ; then 370006f32fbeSmrg # binutils import library 370106f32fbeSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 370206f32fbeSmrg elif func_cygming_ms_implib_p "$1" ; then 370306f32fbeSmrg # ms-generated import library 370406f32fbeSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 370506f32fbeSmrg else 370606f32fbeSmrg # unknown 370706f32fbeSmrg sharedlib_from_linklib_result="" 370806f32fbeSmrg fi 370906f32fbeSmrg} 3710a253d6aeSmrg 3711a253d6aeSmrg 3712ea133fd7Smrg# func_extract_an_archive dir oldlib 3713ea133fd7Smrgfunc_extract_an_archive () 3714ea133fd7Smrg{ 3715ea133fd7Smrg $opt_debug 3716ea133fd7Smrg f_ex_an_ar_dir="$1"; shift 3717ea133fd7Smrg f_ex_an_ar_oldlib="$1" 371825b89263Smrg if test "$lock_old_archive_extraction" = yes; then 371925b89263Smrg lockfile=$f_ex_an_ar_oldlib.lock 372025b89263Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 372125b89263Smrg func_echo "Waiting for $lockfile to be removed" 372225b89263Smrg sleep 2 372325b89263Smrg done 372425b89263Smrg fi 372525b89263Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 372625b89263Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 372725b89263Smrg if test "$lock_old_archive_extraction" = yes; then 372825b89263Smrg $opt_dry_run || rm -f "$lockfile" 372925b89263Smrg fi 3730ea133fd7Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 3731ea133fd7Smrg : 3732ea133fd7Smrg else 3733ea133fd7Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 3734ea133fd7Smrg fi 3735ea133fd7Smrg} 3736a253d6aeSmrg 3737a253d6aeSmrg 3738ea133fd7Smrg# func_extract_archives gentop oldlib ... 3739ea133fd7Smrgfunc_extract_archives () 3740ea133fd7Smrg{ 3741ea133fd7Smrg $opt_debug 3742ea133fd7Smrg my_gentop="$1"; shift 3743ea133fd7Smrg my_oldlibs=${1+"$@"} 3744ea133fd7Smrg my_oldobjs="" 3745ea133fd7Smrg my_xlib="" 3746ea133fd7Smrg my_xabs="" 3747ea133fd7Smrg my_xdir="" 3748a253d6aeSmrg 3749ea133fd7Smrg for my_xlib in $my_oldlibs; do 3750ea133fd7Smrg # Extract the objects. 3751ea133fd7Smrg case $my_xlib in 3752ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 3753ea133fd7Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 3754ea133fd7Smrg esac 3755ea133fd7Smrg func_basename "$my_xlib" 3756ea133fd7Smrg my_xlib="$func_basename_result" 3757ea133fd7Smrg my_xlib_u=$my_xlib 3758ea133fd7Smrg while :; do 3759ea133fd7Smrg case " $extracted_archives " in 3760ea133fd7Smrg *" $my_xlib_u "*) 3761ea133fd7Smrg func_arith $extracted_serial + 1 3762ea133fd7Smrg extracted_serial=$func_arith_result 3763ea133fd7Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 3764ea133fd7Smrg *) break ;; 3765ea133fd7Smrg esac 3766ea133fd7Smrg done 3767ea133fd7Smrg extracted_archives="$extracted_archives $my_xlib_u" 3768ea133fd7Smrg my_xdir="$my_gentop/$my_xlib_u" 3769a253d6aeSmrg 3770ea133fd7Smrg func_mkdir_p "$my_xdir" 3771a253d6aeSmrg 3772ea133fd7Smrg case $host in 3773ea133fd7Smrg *-darwin*) 3774ea133fd7Smrg func_verbose "Extracting $my_xabs" 3775ea133fd7Smrg # Do not bother doing anything if just a dry run 3776ea133fd7Smrg $opt_dry_run || { 3777ea133fd7Smrg darwin_orig_dir=`pwd` 3778ea133fd7Smrg cd $my_xdir || exit $? 3779ea133fd7Smrg darwin_archive=$my_xabs 3780ea133fd7Smrg darwin_curdir=`pwd` 3781ea133fd7Smrg darwin_base_archive=`basename "$darwin_archive"` 3782ea133fd7Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 3783ea133fd7Smrg if test -n "$darwin_arches"; then 3784ea133fd7Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 3785ea133fd7Smrg darwin_arch= 3786ea133fd7Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 3787ea133fd7Smrg for darwin_arch in $darwin_arches ; do 3788ea133fd7Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3789ea133fd7Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 3790ea133fd7Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3791ea133fd7Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 3792ea133fd7Smrg cd "$darwin_curdir" 3793ea133fd7Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 3794ea133fd7Smrg done # $darwin_arches 3795ea133fd7Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 3796ea133fd7Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 3797ea133fd7Smrg darwin_file= 3798ea133fd7Smrg darwin_files= 3799ea133fd7Smrg for darwin_file in $darwin_filelist; do 380025b89263Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 3801ea133fd7Smrg $LIPO -create -output "$darwin_file" $darwin_files 3802ea133fd7Smrg done # $darwin_filelist 3803ea133fd7Smrg $RM -rf unfat-$$ 3804ea133fd7Smrg cd "$darwin_orig_dir" 3805ea133fd7Smrg else 3806ea133fd7Smrg cd $darwin_orig_dir 3807ea133fd7Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 3808ea133fd7Smrg fi # $darwin_arches 3809ea133fd7Smrg } # !$opt_dry_run 3810ea133fd7Smrg ;; 3811ea133fd7Smrg *) 3812ea133fd7Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 3813ea133fd7Smrg ;; 3814a253d6aeSmrg esac 381525b89263Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 3816ea133fd7Smrg done 3817a253d6aeSmrg 3818ea133fd7Smrg func_extract_archives_result="$my_oldobjs" 3819ea133fd7Smrg} 3820a253d6aeSmrg 3821a253d6aeSmrg 382225b89263Smrg# func_emit_wrapper [arg=no] 382325b89263Smrg# 382425b89263Smrg# Emit a libtool wrapper script on stdout. 382525b89263Smrg# Don't directly open a file because we may want to 382625b89263Smrg# incorporate the script contents within a cygwin/mingw 382725b89263Smrg# wrapper executable. Must ONLY be called from within 382825b89263Smrg# func_mode_link because it depends on a number of variables 382925b89263Smrg# set therein. 3830ea133fd7Smrg# 383125b89263Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 383225b89263Smrg# variable will take. If 'yes', then the emitted script 383325b89263Smrg# will assume that the directory in which it is stored is 383425b89263Smrg# the $objdir directory. This is a cygwin/mingw-specific 383525b89263Smrg# behavior. 383625b89263Smrgfunc_emit_wrapper () 3837ea133fd7Smrg{ 383825b89263Smrg func_emit_wrapper_arg1=${1-no} 3839a253d6aeSmrg 3840ea133fd7Smrg $ECHO "\ 3841ea133fd7Smrg#! $SHELL 3842a253d6aeSmrg 3843ea133fd7Smrg# $output - temporary wrapper script for $objdir/$outputname 3844ea133fd7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3845ea133fd7Smrg# 3846ea133fd7Smrg# The $output program cannot be directly executed until all the libtool 3847ea133fd7Smrg# libraries that it depends on are installed. 3848ea133fd7Smrg# 3849ea133fd7Smrg# This wrapper script should never be moved out of the build directory. 3850ea133fd7Smrg# If it is, it will not operate correctly. 3851a253d6aeSmrg 3852ea133fd7Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3853ea133fd7Smrg# metacharacters that are still active within double-quoted strings. 3854ea133fd7Smrgsed_quote_subst='$sed_quote_subst' 3855a253d6aeSmrg 3856ea133fd7Smrg# Be Bourne compatible 3857ea133fd7Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 3858ea133fd7Smrg emulate sh 3859ea133fd7Smrg NULLCMD=: 3860ea133fd7Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 3861ea133fd7Smrg # is contrary to our usage. Disable this feature. 3862ea133fd7Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 3863ea133fd7Smrg setopt NO_GLOB_SUBST 3864ea133fd7Smrgelse 3865ea133fd7Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 3866ea133fd7Smrgfi 3867ea133fd7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 3868ea133fd7SmrgDUALCASE=1; export DUALCASE # for MKS sh 3869a253d6aeSmrg 3870ea133fd7Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 3871ea133fd7Smrg# if CDPATH is set. 3872ea133fd7Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3873a253d6aeSmrg 3874ea133fd7Smrgrelink_command=\"$relink_command\" 3875a253d6aeSmrg 3876ea133fd7Smrg# This environment variable determines our operation mode. 3877ea133fd7Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 3878ea133fd7Smrg # install mode needs the following variables: 3879ea133fd7Smrg generated_by_libtool_version='$macro_version' 3880ea133fd7Smrg notinst_deplibs='$notinst_deplibs' 3881ea133fd7Smrgelse 3882ea133fd7Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 3883ea133fd7Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 388425b89263Smrg file=\"\$0\"" 388525b89263Smrg 388625b89263Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 388725b89263Smrg $ECHO "\ 388825b89263Smrg 388925b89263Smrg# A function that is used when there is no print builtin or printf. 389025b89263Smrgfunc_fallback_echo () 389125b89263Smrg{ 389225b89263Smrg eval 'cat <<_LTECHO_EOF 389325b89263Smrg\$1 389425b89263Smrg_LTECHO_EOF' 389525b89263Smrg} 389625b89263Smrg ECHO=\"$qECHO\" 389725b89263Smrg fi 389825b89263Smrg 389925b89263Smrg# Very basic option parsing. These options are (a) specific to 390025b89263Smrg# the libtool wrapper, (b) are identical between the wrapper 390125b89263Smrg# /script/ and the wrapper /executable/ which is used only on 390225b89263Smrg# windows platforms, and (c) all begin with the string "--lt-" 390325b89263Smrg# (application programs are unlikely to have options which match 390425b89263Smrg# this pattern). 390525b89263Smrg# 390625b89263Smrg# There are only two supported options: --lt-debug and 390725b89263Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 390825b89263Smrg# 390925b89263Smrg# The first argument to this parsing function should be the 391025b89263Smrg# script's $0 value, followed by "$@". 391125b89263Smrglt_option_debug= 391225b89263Smrgfunc_parse_lt_options () 391325b89263Smrg{ 391425b89263Smrg lt_script_arg0=\$0 391525b89263Smrg shift 391625b89263Smrg for lt_opt 391725b89263Smrg do 391825b89263Smrg case \"\$lt_opt\" in 391925b89263Smrg --lt-debug) lt_option_debug=1 ;; 392025b89263Smrg --lt-dump-script) 392125b89263Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 392225b89263Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 392325b89263Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 392425b89263Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 392525b89263Smrg exit 0 392625b89263Smrg ;; 392725b89263Smrg --lt-*) 392825b89263Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 392925b89263Smrg exit 1 393025b89263Smrg ;; 393125b89263Smrg esac 393225b89263Smrg done 393325b89263Smrg 393425b89263Smrg # Print the debug banner immediately: 393525b89263Smrg if test -n \"\$lt_option_debug\"; then 393625b89263Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 393725b89263Smrg fi 393825b89263Smrg} 393925b89263Smrg 394025b89263Smrg# Used when --lt-debug. Prints its arguments to stdout 394125b89263Smrg# (redirection is the responsibility of the caller) 394225b89263Smrgfunc_lt_dump_args () 394325b89263Smrg{ 394425b89263Smrg lt_dump_args_N=1; 394525b89263Smrg for lt_arg 394625b89263Smrg do 394725b89263Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 394825b89263Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 394925b89263Smrg done 395025b89263Smrg} 395125b89263Smrg 395225b89263Smrg# Core function for launching the target application 395325b89263Smrgfunc_exec_program_core () 395425b89263Smrg{ 3955ea133fd7Smrg" 395625b89263Smrg case $host in 395725b89263Smrg # Backslashes separate directories on plain windows 395825b89263Smrg *-*-mingw | *-*-os2* | *-cegcc*) 395925b89263Smrg $ECHO "\ 396025b89263Smrg if test -n \"\$lt_option_debug\"; then 396125b89263Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 396225b89263Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 396325b89263Smrg fi 396425b89263Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 396525b89263Smrg" 396625b89263Smrg ;; 396725b89263Smrg 396825b89263Smrg *) 396925b89263Smrg $ECHO "\ 397025b89263Smrg if test -n \"\$lt_option_debug\"; then 397125b89263Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 397225b89263Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 397325b89263Smrg fi 397425b89263Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 397525b89263Smrg" 397625b89263Smrg ;; 397725b89263Smrg esac 397825b89263Smrg $ECHO "\ 397925b89263Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 398025b89263Smrg exit 1 398125b89263Smrg} 398225b89263Smrg 398325b89263Smrg# A function to encapsulate launching the target application 398425b89263Smrg# Strips options in the --lt-* namespace from \$@ and 398525b89263Smrg# launches target application with the remaining arguments. 398625b89263Smrgfunc_exec_program () 398725b89263Smrg{ 398857ee1794Smrg case \" \$* \" in 398957ee1794Smrg *\\ --lt-*) 399057ee1794Smrg for lt_wr_arg 399157ee1794Smrg do 399257ee1794Smrg case \$lt_wr_arg in 399357ee1794Smrg --lt-*) ;; 399457ee1794Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 399557ee1794Smrg esac 399657ee1794Smrg shift 399757ee1794Smrg done ;; 399857ee1794Smrg esac 399925b89263Smrg func_exec_program_core \${1+\"\$@\"} 400025b89263Smrg} 400125b89263Smrg 400225b89263Smrg # Parse options 400325b89263Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 4004a253d6aeSmrg 4005ea133fd7Smrg # Find the directory that this script lives in. 400625b89263Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 4007ea133fd7Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4008a253d6aeSmrg 4009ea133fd7Smrg # Follow symbolic links until we get to the real thisdir. 401025b89263Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 4011ea133fd7Smrg while test -n \"\$file\"; do 401225b89263Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4013a253d6aeSmrg 4014ea133fd7Smrg # If there was a directory component, then change thisdir. 4015ea133fd7Smrg if test \"x\$destdir\" != \"x\$file\"; then 4016ea133fd7Smrg case \"\$destdir\" in 4017ea133fd7Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 4018ea133fd7Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 4019ea133fd7Smrg esac 4020ea133fd7Smrg fi 4021a253d6aeSmrg 402225b89263Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 402325b89263Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 4024ea133fd7Smrg done 4025a253d6aeSmrg 4026ea133fd7Smrg # Usually 'no', except on cygwin/mingw when embedded into 4027ea133fd7Smrg # the cwrapper. 402825b89263Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 4029ea133fd7Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 4030ea133fd7Smrg # special case for '.' 4031ea133fd7Smrg if test \"\$thisdir\" = \".\"; then 4032ea133fd7Smrg thisdir=\`pwd\` 4033ea133fd7Smrg fi 4034ea133fd7Smrg # remove .libs from thisdir 4035ea133fd7Smrg case \"\$thisdir\" in 403625b89263Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 4037ea133fd7Smrg $objdir ) thisdir=. ;; 4038ea133fd7Smrg esac 4039ea133fd7Smrg fi 4040a253d6aeSmrg 4041ea133fd7Smrg # Try to get the absolute directory name. 4042ea133fd7Smrg absdir=\`cd \"\$thisdir\" && pwd\` 4043ea133fd7Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 4044ea133fd7Smrg" 4045a253d6aeSmrg 4046ea133fd7Smrg if test "$fast_install" = yes; then 4047ea133fd7Smrg $ECHO "\ 4048ea133fd7Smrg program=lt-'$outputname'$exeext 4049ea133fd7Smrg progdir=\"\$thisdir/$objdir\" 4050a253d6aeSmrg 4051ea133fd7Smrg if test ! -f \"\$progdir/\$program\" || 4052ea133fd7Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 4053ea133fd7Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4054a253d6aeSmrg 4055ea133fd7Smrg file=\"\$\$-\$program\" 4056a253d6aeSmrg 4057ea133fd7Smrg if test ! -d \"\$progdir\"; then 4058ea133fd7Smrg $MKDIR \"\$progdir\" 4059ea133fd7Smrg else 4060ea133fd7Smrg $RM \"\$progdir/\$file\" 4061ea133fd7Smrg fi" 4062a253d6aeSmrg 4063ea133fd7Smrg $ECHO "\ 4064a253d6aeSmrg 4065ea133fd7Smrg # relink executable if necessary 4066ea133fd7Smrg if test -n \"\$relink_command\"; then 4067ea133fd7Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 4068ea133fd7Smrg else 4069ea133fd7Smrg $ECHO \"\$relink_command_output\" >&2 4070ea133fd7Smrg $RM \"\$progdir/\$file\" 4071ea133fd7Smrg exit 1 4072ea133fd7Smrg fi 4073ea133fd7Smrg fi 4074a253d6aeSmrg 4075ea133fd7Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 4076ea133fd7Smrg { $RM \"\$progdir/\$program\"; 4077ea133fd7Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 4078ea133fd7Smrg $RM \"\$progdir/\$file\" 4079ea133fd7Smrg fi" 4080ea133fd7Smrg else 4081ea133fd7Smrg $ECHO "\ 4082ea133fd7Smrg program='$outputname' 4083ea133fd7Smrg progdir=\"\$thisdir/$objdir\" 4084ea133fd7Smrg" 4085ea133fd7Smrg fi 4086a253d6aeSmrg 4087ea133fd7Smrg $ECHO "\ 4088a253d6aeSmrg 4089ea133fd7Smrg if test -f \"\$progdir/\$program\"; then" 4090a253d6aeSmrg 409106f32fbeSmrg # fixup the dll searchpath if we need to. 409206f32fbeSmrg # 409306f32fbeSmrg # Fix the DLL searchpath if we need to. Do this before prepending 409406f32fbeSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 409506f32fbeSmrg # libraries must come first. 409606f32fbeSmrg if test -n "$dllsearchpath"; then 409706f32fbeSmrg $ECHO "\ 409806f32fbeSmrg # Add the dll search path components to the executable PATH 409906f32fbeSmrg PATH=$dllsearchpath:\$PATH 410006f32fbeSmrg" 410106f32fbeSmrg fi 410206f32fbeSmrg 4103ea133fd7Smrg # Export our shlibpath_var if we have one. 4104ea133fd7Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4105ea133fd7Smrg $ECHO "\ 4106ea133fd7Smrg # Add our own library path to $shlibpath_var 4107ea133fd7Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4108a253d6aeSmrg 4109ea133fd7Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 4110ea133fd7Smrg # The second colon is a workaround for a bug in BeOS R4 sed 411125b89263Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4112a253d6aeSmrg 4113ea133fd7Smrg export $shlibpath_var 4114ea133fd7Smrg" 4115a253d6aeSmrg fi 4116a253d6aeSmrg 4117ea133fd7Smrg $ECHO "\ 4118ea133fd7Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 4119ea133fd7Smrg # Run the actual program with our arguments. 412025b89263Smrg func_exec_program \${1+\"\$@\"} 4121ea133fd7Smrg fi 4122ea133fd7Smrg else 4123ea133fd7Smrg # The program doesn't exist. 4124ea133fd7Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 4125ea133fd7Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 412625b89263Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 4127ea133fd7Smrg exit 1 4128ea133fd7Smrg fi 4129ea133fd7Smrgfi\ 4130ea133fd7Smrg" 4131ea133fd7Smrg} 4132a253d6aeSmrg 4133a253d6aeSmrg 4134ea133fd7Smrg# func_emit_cwrapperexe_src 4135ea133fd7Smrg# emit the source code for a wrapper executable on stdout 4136ea133fd7Smrg# Must ONLY be called from within func_mode_link because 4137ea133fd7Smrg# it depends on a number of variable set therein. 4138ea133fd7Smrgfunc_emit_cwrapperexe_src () 4139ea133fd7Smrg{ 4140ea133fd7Smrg cat <<EOF 4141a253d6aeSmrg 4142ea133fd7Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4143ea133fd7Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4144a253d6aeSmrg 4145ea133fd7Smrg The $output program cannot be directly executed until all the libtool 4146ea133fd7Smrg libraries that it depends on are installed. 4147a253d6aeSmrg 4148ea133fd7Smrg This wrapper executable should never be moved out of the build directory. 4149ea133fd7Smrg If it is, it will not operate correctly. 4150ea133fd7Smrg*/ 4151ea133fd7SmrgEOF 4152ea133fd7Smrg cat <<"EOF" 415325b89263Smrg#ifdef _MSC_VER 415425b89263Smrg# define _CRT_SECURE_NO_DEPRECATE 1 415525b89263Smrg#endif 4156ea133fd7Smrg#include <stdio.h> 4157ea133fd7Smrg#include <stdlib.h> 4158ea133fd7Smrg#ifdef _MSC_VER 4159ea133fd7Smrg# include <direct.h> 4160ea133fd7Smrg# include <process.h> 4161ea133fd7Smrg# include <io.h> 4162ea133fd7Smrg#else 4163ea133fd7Smrg# include <unistd.h> 4164ea133fd7Smrg# include <stdint.h> 4165ea133fd7Smrg# ifdef __CYGWIN__ 4166ea133fd7Smrg# include <io.h> 4167ea133fd7Smrg# endif 4168ea133fd7Smrg#endif 4169ea133fd7Smrg#include <malloc.h> 4170ea133fd7Smrg#include <stdarg.h> 4171ea133fd7Smrg#include <assert.h> 4172ea133fd7Smrg#include <string.h> 4173ea133fd7Smrg#include <ctype.h> 4174ea133fd7Smrg#include <errno.h> 4175ea133fd7Smrg#include <fcntl.h> 4176ea133fd7Smrg#include <sys/stat.h> 4177ea133fd7Smrg 417825b89263Smrg/* declarations of non-ANSI functions */ 417925b89263Smrg#if defined(__MINGW32__) 418025b89263Smrg# ifdef __STRICT_ANSI__ 418125b89263Smrgint _putenv (const char *); 418225b89263Smrg# endif 418325b89263Smrg#elif defined(__CYGWIN__) 418425b89263Smrg# ifdef __STRICT_ANSI__ 418525b89263Smrgchar *realpath (const char *, char *); 418625b89263Smrgint putenv (char *); 418725b89263Smrgint setenv (const char *, const char *, int); 418825b89263Smrg# endif 418925b89263Smrg/* #elif defined (other platforms) ... */ 419025b89263Smrg#endif 419125b89263Smrg 419225b89263Smrg/* portability defines, excluding path handling macros */ 419325b89263Smrg#if defined(_MSC_VER) 419425b89263Smrg# define setmode _setmode 419525b89263Smrg# define stat _stat 419625b89263Smrg# define chmod _chmod 419725b89263Smrg# define getcwd _getcwd 419825b89263Smrg# define putenv _putenv 419925b89263Smrg# define S_IXUSR _S_IEXEC 420025b89263Smrg# ifndef _INTPTR_T_DEFINED 420125b89263Smrg# define _INTPTR_T_DEFINED 420225b89263Smrg# define intptr_t int 420325b89263Smrg# endif 420425b89263Smrg#elif defined(__MINGW32__) 420525b89263Smrg# define setmode _setmode 420625b89263Smrg# define stat _stat 420725b89263Smrg# define chmod _chmod 420825b89263Smrg# define getcwd _getcwd 420925b89263Smrg# define putenv _putenv 421025b89263Smrg#elif defined(__CYGWIN__) 421125b89263Smrg# define HAVE_SETENV 421225b89263Smrg# define FOPEN_WB "wb" 421325b89263Smrg/* #elif defined (other platforms) ... */ 421425b89263Smrg#endif 421525b89263Smrg 4216ea133fd7Smrg#if defined(PATH_MAX) 4217ea133fd7Smrg# define LT_PATHMAX PATH_MAX 4218ea133fd7Smrg#elif defined(MAXPATHLEN) 4219ea133fd7Smrg# define LT_PATHMAX MAXPATHLEN 4220ea133fd7Smrg#else 4221ea133fd7Smrg# define LT_PATHMAX 1024 4222ea133fd7Smrg#endif 4223ea133fd7Smrg 4224ea133fd7Smrg#ifndef S_IXOTH 4225ea133fd7Smrg# define S_IXOTH 0 4226ea133fd7Smrg#endif 4227ea133fd7Smrg#ifndef S_IXGRP 4228ea133fd7Smrg# define S_IXGRP 0 4229ea133fd7Smrg#endif 4230ea133fd7Smrg 423125b89263Smrg/* path handling portability macros */ 4232ea133fd7Smrg#ifndef DIR_SEPARATOR 4233ea133fd7Smrg# define DIR_SEPARATOR '/' 4234ea133fd7Smrg# define PATH_SEPARATOR ':' 4235ea133fd7Smrg#endif 4236ea133fd7Smrg 4237ea133fd7Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4238ea133fd7Smrg defined (__OS2__) 4239ea133fd7Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 4240ea133fd7Smrg# define FOPEN_WB "wb" 4241ea133fd7Smrg# ifndef DIR_SEPARATOR_2 4242ea133fd7Smrg# define DIR_SEPARATOR_2 '\\' 4243ea133fd7Smrg# endif 4244ea133fd7Smrg# ifndef PATH_SEPARATOR_2 4245ea133fd7Smrg# define PATH_SEPARATOR_2 ';' 4246ea133fd7Smrg# endif 4247ea133fd7Smrg#endif 4248ea133fd7Smrg 4249ea133fd7Smrg#ifndef DIR_SEPARATOR_2 4250ea133fd7Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 4251ea133fd7Smrg#else /* DIR_SEPARATOR_2 */ 4252ea133fd7Smrg# define IS_DIR_SEPARATOR(ch) \ 4253ea133fd7Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 4254ea133fd7Smrg#endif /* DIR_SEPARATOR_2 */ 4255ea133fd7Smrg 4256ea133fd7Smrg#ifndef PATH_SEPARATOR_2 4257ea133fd7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 4258ea133fd7Smrg#else /* PATH_SEPARATOR_2 */ 4259ea133fd7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 4260ea133fd7Smrg#endif /* PATH_SEPARATOR_2 */ 4261ea133fd7Smrg 4262ea133fd7Smrg#ifndef FOPEN_WB 4263ea133fd7Smrg# define FOPEN_WB "w" 4264ea133fd7Smrg#endif 4265ea133fd7Smrg#ifndef _O_BINARY 4266ea133fd7Smrg# define _O_BINARY 0 4267ea133fd7Smrg#endif 4268ea133fd7Smrg 4269ea133fd7Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 4270ea133fd7Smrg#define XFREE(stale) do { \ 4271ea133fd7Smrg if (stale) { free ((void *) stale); stale = 0; } \ 4272ea133fd7Smrg} while (0) 4273ea133fd7Smrg 427425b89263Smrg#if defined(LT_DEBUGWRAPPER) 427525b89263Smrgstatic int lt_debug = 1; 4276ea133fd7Smrg#else 427725b89263Smrgstatic int lt_debug = 0; 4278ea133fd7Smrg#endif 4279ea133fd7Smrg 428025b89263Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4281ea133fd7Smrg 4282ea133fd7Smrgvoid *xmalloc (size_t num); 4283ea133fd7Smrgchar *xstrdup (const char *string); 4284ea133fd7Smrgconst char *base_name (const char *name); 4285ea133fd7Smrgchar *find_executable (const char *wrapper); 4286ea133fd7Smrgchar *chase_symlinks (const char *pathspec); 4287ea133fd7Smrgint make_executable (const char *path); 4288ea133fd7Smrgint check_executable (const char *path); 4289ea133fd7Smrgchar *strendzap (char *str, const char *pat); 429025b89263Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 429125b89263Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 429225b89263Smrgstatic const char *nonnull (const char *s); 429325b89263Smrgstatic const char *nonempty (const char *s); 4294ea133fd7Smrgvoid lt_setenv (const char *name, const char *value); 4295ea133fd7Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 4296ea133fd7Smrgvoid lt_update_exe_path (const char *name, const char *value); 4297ea133fd7Smrgvoid lt_update_lib_path (const char *name, const char *value); 429825b89263Smrgchar **prepare_spawn (char **argv); 429925b89263Smrgvoid lt_dump_script (FILE *f); 4300ea133fd7SmrgEOF 4301ea133fd7Smrg 4302ea133fd7Smrg cat <<EOF 430306f32fbeSmrgvolatile const char * MAGIC_EXE = "$magic_exe"; 4304ea133fd7Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 4305ea133fd7SmrgEOF 4306ea133fd7Smrg 4307ea133fd7Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 430806f32fbeSmrg func_to_host_path "$temp_rpath" 4309ea133fd7Smrg cat <<EOF 431006f32fbeSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 4311a253d6aeSmrgEOF 4312a253d6aeSmrg else 4313ea133fd7Smrg cat <<"EOF" 4314ea133fd7Smrgconst char * LIB_PATH_VALUE = ""; 4315ea133fd7SmrgEOF 4316a253d6aeSmrg fi 4317ea133fd7Smrg 4318ea133fd7Smrg if test -n "$dllsearchpath"; then 431906f32fbeSmrg func_to_host_path "$dllsearchpath:" 4320ea133fd7Smrg cat <<EOF 4321ea133fd7Smrgconst char * EXE_PATH_VARNAME = "PATH"; 432206f32fbeSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 4323ea133fd7SmrgEOF 4324a253d6aeSmrg else 4325ea133fd7Smrg cat <<"EOF" 4326ea133fd7Smrgconst char * EXE_PATH_VARNAME = ""; 4327ea133fd7Smrgconst char * EXE_PATH_VALUE = ""; 4328ea133fd7SmrgEOF 4329a253d6aeSmrg fi 4330ea133fd7Smrg 4331ea133fd7Smrg if test "$fast_install" = yes; then 4332ea133fd7Smrg cat <<EOF 4333ea133fd7Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 4334ea133fd7SmrgEOF 4335a253d6aeSmrg else 4336ea133fd7Smrg cat <<EOF 4337ea133fd7Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 4338ea133fd7SmrgEOF 4339a253d6aeSmrg fi 4340a253d6aeSmrg 4341a253d6aeSmrg 4342ea133fd7Smrg cat <<"EOF" 4343a253d6aeSmrg 4344ea133fd7Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 4345a253d6aeSmrg 4346ea133fd7Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 4347ea133fd7Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 434825b89263Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4349a253d6aeSmrg 4350ea133fd7Smrgint 4351ea133fd7Smrgmain (int argc, char *argv[]) 4352ea133fd7Smrg{ 4353ea133fd7Smrg char **newargz; 4354ea133fd7Smrg int newargc; 4355ea133fd7Smrg char *tmp_pathspec; 4356ea133fd7Smrg char *actual_cwrapper_path; 4357ea133fd7Smrg char *actual_cwrapper_name; 4358ea133fd7Smrg char *target_name; 4359ea133fd7Smrg char *lt_argv_zero; 4360ea133fd7Smrg intptr_t rval = 127; 4361a253d6aeSmrg 4362ea133fd7Smrg int i; 4363a253d6aeSmrg 4364ea133fd7Smrg program_name = (char *) xstrdup (base_name (argv[0])); 436525b89263Smrg newargz = XMALLOC (char *, argc + 1); 4366a253d6aeSmrg 436725b89263Smrg /* very simple arg parsing; don't want to rely on getopt 436825b89263Smrg * also, copy all non cwrapper options to newargz, except 436925b89263Smrg * argz[0], which is handled differently 437025b89263Smrg */ 437125b89263Smrg newargc=0; 4372ea133fd7Smrg for (i = 1; i < argc; i++) 4373ea133fd7Smrg { 4374ea133fd7Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 4375ea133fd7Smrg { 4376ea133fd7SmrgEOF 4377ea133fd7Smrg case "$host" in 4378ea133fd7Smrg *mingw* | *cygwin* ) 4379ea133fd7Smrg # make stdout use "unix" line endings 4380ea133fd7Smrg echo " setmode(1,_O_BINARY);" 4381ea133fd7Smrg ;; 4382ea133fd7Smrg esac 4383a253d6aeSmrg 4384ea133fd7Smrg cat <<"EOF" 438525b89263Smrg lt_dump_script (stdout); 4386ea133fd7Smrg return 0; 4387ea133fd7Smrg } 438825b89263Smrg if (strcmp (argv[i], debug_opt) == 0) 438925b89263Smrg { 439025b89263Smrg lt_debug = 1; 439125b89263Smrg continue; 439225b89263Smrg } 439325b89263Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 439425b89263Smrg { 439525b89263Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 439625b89263Smrg namespace, but it is not one of the ones we know about and 439725b89263Smrg have already dealt with, above (inluding dump-script), then 439825b89263Smrg report an error. Otherwise, targets might begin to believe 439925b89263Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 440025b89263Smrg namespace. The first time any user complains about this, we'll 440125b89263Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 440225b89263Smrg or a configure.ac-settable value. 440325b89263Smrg */ 440425b89263Smrg lt_fatal (__FILE__, __LINE__, 440525b89263Smrg "unrecognized %s option: '%s'", 440625b89263Smrg ltwrapper_option_prefix, argv[i]); 440725b89263Smrg } 440825b89263Smrg /* otherwise ... */ 440925b89263Smrg newargz[++newargc] = xstrdup (argv[i]); 4410ea133fd7Smrg } 441125b89263Smrg newargz[++newargc] = NULL; 441225b89263Smrg 441325b89263SmrgEOF 441425b89263Smrg cat <<EOF 441525b89263Smrg /* The GNU banner must be the first non-error debug message */ 441625b89263Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 441725b89263SmrgEOF 441825b89263Smrg cat <<"EOF" 441925b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 442025b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4421a253d6aeSmrg 4422ea133fd7Smrg tmp_pathspec = find_executable (argv[0]); 4423ea133fd7Smrg if (tmp_pathspec == NULL) 442425b89263Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 442525b89263Smrg lt_debugprintf (__FILE__, __LINE__, 442625b89263Smrg "(main) found exe (before symlink chase) at: %s\n", 442725b89263Smrg tmp_pathspec); 4428ea133fd7Smrg 4429ea133fd7Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 443025b89263Smrg lt_debugprintf (__FILE__, __LINE__, 443125b89263Smrg "(main) found exe (after symlink chase) at: %s\n", 443225b89263Smrg actual_cwrapper_path); 4433ea133fd7Smrg XFREE (tmp_pathspec); 4434ea133fd7Smrg 443525b89263Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 4436ea133fd7Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 4437ea133fd7Smrg 4438ea133fd7Smrg /* wrapper name transforms */ 4439ea133fd7Smrg strendzap (actual_cwrapper_name, ".exe"); 4440ea133fd7Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 4441ea133fd7Smrg XFREE (actual_cwrapper_name); 4442ea133fd7Smrg actual_cwrapper_name = tmp_pathspec; 4443ea133fd7Smrg tmp_pathspec = 0; 4444ea133fd7Smrg 4445ea133fd7Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 4446ea133fd7Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 4447ea133fd7Smrg strendzap (target_name, ".exe"); 4448ea133fd7Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 4449ea133fd7Smrg XFREE (target_name); 4450ea133fd7Smrg target_name = tmp_pathspec; 4451ea133fd7Smrg tmp_pathspec = 0; 4452ea133fd7Smrg 445325b89263Smrg lt_debugprintf (__FILE__, __LINE__, 445425b89263Smrg "(main) libtool target name: %s\n", 445525b89263Smrg target_name); 4456ea133fd7SmrgEOF 4457a253d6aeSmrg 4458ea133fd7Smrg cat <<EOF 4459ea133fd7Smrg newargz[0] = 4460ea133fd7Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 4461ea133fd7Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 4462ea133fd7Smrg strcpy (newargz[0], actual_cwrapper_path); 4463ea133fd7Smrg strcat (newargz[0], "$objdir"); 4464ea133fd7Smrg strcat (newargz[0], "/"); 4465ea133fd7SmrgEOF 4466a253d6aeSmrg 4467ea133fd7Smrg cat <<"EOF" 4468ea133fd7Smrg /* stop here, and copy so we don't have to do this twice */ 4469ea133fd7Smrg tmp_pathspec = xstrdup (newargz[0]); 4470a253d6aeSmrg 4471ea133fd7Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 4472ea133fd7Smrg strcat (newargz[0], actual_cwrapper_name); 4473a253d6aeSmrg 4474ea133fd7Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 4475ea133fd7Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 4476ea133fd7Smrg XFREE (tmp_pathspec); 4477ea133fd7Smrg tmp_pathspec = NULL; 4478ea133fd7SmrgEOF 4479a253d6aeSmrg 4480ea133fd7Smrg case $host_os in 4481ea133fd7Smrg mingw*) 4482ea133fd7Smrg cat <<"EOF" 4483ea133fd7Smrg { 4484ea133fd7Smrg char* p; 4485ea133fd7Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 4486ea133fd7Smrg { 4487ea133fd7Smrg *p = '/'; 4488ea133fd7Smrg } 4489ea133fd7Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 4490ea133fd7Smrg { 4491ea133fd7Smrg *p = '/'; 4492ea133fd7Smrg } 4493ea133fd7Smrg } 4494ea133fd7SmrgEOF 4495ea133fd7Smrg ;; 4496ea133fd7Smrg esac 4497a253d6aeSmrg 4498ea133fd7Smrg cat <<"EOF" 4499ea133fd7Smrg XFREE (target_name); 4500ea133fd7Smrg XFREE (actual_cwrapper_path); 4501ea133fd7Smrg XFREE (actual_cwrapper_name); 4502a253d6aeSmrg 4503ea133fd7Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 4504ea133fd7Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 450506f32fbeSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 450606f32fbeSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 450706f32fbeSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 450806f32fbeSmrg libraries must come first. */ 4509ea133fd7Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 451006f32fbeSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4511a253d6aeSmrg 451225b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 451325b89263Smrg nonnull (lt_argv_zero)); 4514ea133fd7Smrg for (i = 0; i < newargc; i++) 4515ea133fd7Smrg { 451625b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 451725b89263Smrg i, nonnull (newargz[i])); 4518ea133fd7Smrg } 4519a253d6aeSmrg 4520ea133fd7SmrgEOF 4521a253d6aeSmrg 4522ea133fd7Smrg case $host_os in 4523ea133fd7Smrg mingw*) 4524ea133fd7Smrg cat <<"EOF" 4525ea133fd7Smrg /* execv doesn't actually work on mingw as expected on unix */ 452625b89263Smrg newargz = prepare_spawn (newargz); 4527ea133fd7Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 4528ea133fd7Smrg if (rval == -1) 4529ea133fd7Smrg { 4530ea133fd7Smrg /* failed to start process */ 453125b89263Smrg lt_debugprintf (__FILE__, __LINE__, 453225b89263Smrg "(main) failed to launch target \"%s\": %s\n", 453325b89263Smrg lt_argv_zero, nonnull (strerror (errno))); 4534ea133fd7Smrg return 127; 4535ea133fd7Smrg } 4536ea133fd7Smrg return rval; 4537ea133fd7SmrgEOF 4538ea133fd7Smrg ;; 4539ea133fd7Smrg *) 4540ea133fd7Smrg cat <<"EOF" 4541ea133fd7Smrg execv (lt_argv_zero, newargz); 4542ea133fd7Smrg return rval; /* =127, but avoids unused variable warning */ 4543ea133fd7SmrgEOF 4544ea133fd7Smrg ;; 4545ea133fd7Smrg esac 4546a253d6aeSmrg 4547ea133fd7Smrg cat <<"EOF" 4548ea133fd7Smrg} 4549a253d6aeSmrg 4550ea133fd7Smrgvoid * 4551ea133fd7Smrgxmalloc (size_t num) 4552ea133fd7Smrg{ 4553ea133fd7Smrg void *p = (void *) malloc (num); 4554ea133fd7Smrg if (!p) 455525b89263Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4556a253d6aeSmrg 4557ea133fd7Smrg return p; 4558ea133fd7Smrg} 4559a253d6aeSmrg 4560ea133fd7Smrgchar * 4561ea133fd7Smrgxstrdup (const char *string) 4562ea133fd7Smrg{ 4563ea133fd7Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 4564ea133fd7Smrg string) : NULL; 4565ea133fd7Smrg} 4566a253d6aeSmrg 4567ea133fd7Smrgconst char * 4568ea133fd7Smrgbase_name (const char *name) 4569ea133fd7Smrg{ 4570ea133fd7Smrg const char *base; 4571a253d6aeSmrg 4572ea133fd7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4573ea133fd7Smrg /* Skip over the disk name in MSDOS pathnames. */ 4574ea133fd7Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 4575ea133fd7Smrg name += 2; 4576ea133fd7Smrg#endif 4577a253d6aeSmrg 4578ea133fd7Smrg for (base = name; *name; name++) 4579ea133fd7Smrg if (IS_DIR_SEPARATOR (*name)) 4580ea133fd7Smrg base = name + 1; 4581ea133fd7Smrg return base; 4582ea133fd7Smrg} 4583a253d6aeSmrg 4584ea133fd7Smrgint 4585ea133fd7Smrgcheck_executable (const char *path) 4586ea133fd7Smrg{ 4587ea133fd7Smrg struct stat st; 4588a253d6aeSmrg 458925b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 459025b89263Smrg nonempty (path)); 4591ea133fd7Smrg if ((!path) || (!*path)) 4592ea133fd7Smrg return 0; 4593a253d6aeSmrg 4594ea133fd7Smrg if ((stat (path, &st) >= 0) 4595ea133fd7Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 4596ea133fd7Smrg return 1; 4597ea133fd7Smrg else 4598ea133fd7Smrg return 0; 4599ea133fd7Smrg} 4600a253d6aeSmrg 4601ea133fd7Smrgint 4602ea133fd7Smrgmake_executable (const char *path) 4603ea133fd7Smrg{ 4604ea133fd7Smrg int rval = 0; 4605ea133fd7Smrg struct stat st; 4606a253d6aeSmrg 460725b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 460825b89263Smrg nonempty (path)); 4609ea133fd7Smrg if ((!path) || (!*path)) 4610ea133fd7Smrg return 0; 4611a253d6aeSmrg 4612ea133fd7Smrg if (stat (path, &st) >= 0) 4613ea133fd7Smrg { 4614ea133fd7Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 4615ea133fd7Smrg } 4616ea133fd7Smrg return rval; 4617ea133fd7Smrg} 4618a253d6aeSmrg 4619ea133fd7Smrg/* Searches for the full path of the wrapper. Returns 4620ea133fd7Smrg newly allocated full path name if found, NULL otherwise 4621ea133fd7Smrg Does not chase symlinks, even on platforms that support them. 4622ea133fd7Smrg*/ 4623ea133fd7Smrgchar * 4624ea133fd7Smrgfind_executable (const char *wrapper) 4625ea133fd7Smrg{ 4626ea133fd7Smrg int has_slash = 0; 4627ea133fd7Smrg const char *p; 4628ea133fd7Smrg const char *p_next; 4629ea133fd7Smrg /* static buffer for getcwd */ 4630ea133fd7Smrg char tmp[LT_PATHMAX + 1]; 4631ea133fd7Smrg int tmp_len; 4632ea133fd7Smrg char *concat_name; 4633a253d6aeSmrg 463425b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 463525b89263Smrg nonempty (wrapper)); 4636a253d6aeSmrg 4637ea133fd7Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 4638ea133fd7Smrg return NULL; 4639a253d6aeSmrg 4640ea133fd7Smrg /* Absolute path? */ 4641ea133fd7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4642ea133fd7Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 4643ea133fd7Smrg { 4644ea133fd7Smrg concat_name = xstrdup (wrapper); 4645ea133fd7Smrg if (check_executable (concat_name)) 4646ea133fd7Smrg return concat_name; 4647ea133fd7Smrg XFREE (concat_name); 4648ea133fd7Smrg } 4649ea133fd7Smrg else 4650ea133fd7Smrg { 4651ea133fd7Smrg#endif 4652ea133fd7Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 4653ea133fd7Smrg { 4654ea133fd7Smrg concat_name = xstrdup (wrapper); 4655ea133fd7Smrg if (check_executable (concat_name)) 4656ea133fd7Smrg return concat_name; 4657ea133fd7Smrg XFREE (concat_name); 4658ea133fd7Smrg } 4659ea133fd7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4660ea133fd7Smrg } 4661ea133fd7Smrg#endif 4662a253d6aeSmrg 4663ea133fd7Smrg for (p = wrapper; *p; p++) 4664ea133fd7Smrg if (*p == '/') 4665ea133fd7Smrg { 4666ea133fd7Smrg has_slash = 1; 4667ea133fd7Smrg break; 4668ea133fd7Smrg } 4669ea133fd7Smrg if (!has_slash) 4670ea133fd7Smrg { 4671ea133fd7Smrg /* no slashes; search PATH */ 4672ea133fd7Smrg const char *path = getenv ("PATH"); 4673ea133fd7Smrg if (path != NULL) 4674ea133fd7Smrg { 4675ea133fd7Smrg for (p = path; *p; p = p_next) 4676ea133fd7Smrg { 4677ea133fd7Smrg const char *q; 4678ea133fd7Smrg size_t p_len; 4679ea133fd7Smrg for (q = p; *q; q++) 4680ea133fd7Smrg if (IS_PATH_SEPARATOR (*q)) 4681ea133fd7Smrg break; 4682ea133fd7Smrg p_len = q - p; 4683ea133fd7Smrg p_next = (*q == '\0' ? q : q + 1); 4684ea133fd7Smrg if (p_len == 0) 4685ea133fd7Smrg { 4686ea133fd7Smrg /* empty path: current directory */ 4687ea133fd7Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 468825b89263Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 468925b89263Smrg nonnull (strerror (errno))); 4690ea133fd7Smrg tmp_len = strlen (tmp); 4691ea133fd7Smrg concat_name = 4692ea133fd7Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4693ea133fd7Smrg memcpy (concat_name, tmp, tmp_len); 4694ea133fd7Smrg concat_name[tmp_len] = '/'; 4695ea133fd7Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4696ea133fd7Smrg } 4697ea133fd7Smrg else 4698ea133fd7Smrg { 4699ea133fd7Smrg concat_name = 4700ea133fd7Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 4701ea133fd7Smrg memcpy (concat_name, p, p_len); 4702ea133fd7Smrg concat_name[p_len] = '/'; 4703ea133fd7Smrg strcpy (concat_name + p_len + 1, wrapper); 4704ea133fd7Smrg } 4705ea133fd7Smrg if (check_executable (concat_name)) 4706ea133fd7Smrg return concat_name; 4707ea133fd7Smrg XFREE (concat_name); 4708ea133fd7Smrg } 4709ea133fd7Smrg } 4710ea133fd7Smrg /* not found in PATH; assume curdir */ 4711ea133fd7Smrg } 4712ea133fd7Smrg /* Relative path | not found in path: prepend cwd */ 4713ea133fd7Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 471425b89263Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 471525b89263Smrg nonnull (strerror (errno))); 4716ea133fd7Smrg tmp_len = strlen (tmp); 4717ea133fd7Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4718ea133fd7Smrg memcpy (concat_name, tmp, tmp_len); 4719ea133fd7Smrg concat_name[tmp_len] = '/'; 4720ea133fd7Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4721a253d6aeSmrg 4722ea133fd7Smrg if (check_executable (concat_name)) 4723ea133fd7Smrg return concat_name; 4724ea133fd7Smrg XFREE (concat_name); 4725ea133fd7Smrg return NULL; 4726ea133fd7Smrg} 4727a253d6aeSmrg 4728ea133fd7Smrgchar * 4729ea133fd7Smrgchase_symlinks (const char *pathspec) 4730ea133fd7Smrg{ 4731ea133fd7Smrg#ifndef S_ISLNK 4732ea133fd7Smrg return xstrdup (pathspec); 4733ea133fd7Smrg#else 4734ea133fd7Smrg char buf[LT_PATHMAX]; 4735ea133fd7Smrg struct stat s; 4736ea133fd7Smrg char *tmp_pathspec = xstrdup (pathspec); 4737ea133fd7Smrg char *p; 4738ea133fd7Smrg int has_symlinks = 0; 4739ea133fd7Smrg while (strlen (tmp_pathspec) && !has_symlinks) 4740ea133fd7Smrg { 474125b89263Smrg lt_debugprintf (__FILE__, __LINE__, 474225b89263Smrg "checking path component for symlinks: %s\n", 474325b89263Smrg tmp_pathspec); 4744ea133fd7Smrg if (lstat (tmp_pathspec, &s) == 0) 4745ea133fd7Smrg { 4746ea133fd7Smrg if (S_ISLNK (s.st_mode) != 0) 4747ea133fd7Smrg { 4748ea133fd7Smrg has_symlinks = 1; 4749ea133fd7Smrg break; 4750ea133fd7Smrg } 4751a253d6aeSmrg 4752ea133fd7Smrg /* search backwards for last DIR_SEPARATOR */ 4753ea133fd7Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 4754ea133fd7Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4755ea133fd7Smrg p--; 4756ea133fd7Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4757ea133fd7Smrg { 4758ea133fd7Smrg /* no more DIR_SEPARATORS left */ 4759ea133fd7Smrg break; 4760ea133fd7Smrg } 4761ea133fd7Smrg *p = '\0'; 4762ea133fd7Smrg } 4763ea133fd7Smrg else 4764ea133fd7Smrg { 476525b89263Smrg lt_fatal (__FILE__, __LINE__, 476625b89263Smrg "error accessing file \"%s\": %s", 476725b89263Smrg tmp_pathspec, nonnull (strerror (errno))); 4768ea133fd7Smrg } 4769ea133fd7Smrg } 4770ea133fd7Smrg XFREE (tmp_pathspec); 4771a253d6aeSmrg 4772ea133fd7Smrg if (!has_symlinks) 4773ea133fd7Smrg { 4774ea133fd7Smrg return xstrdup (pathspec); 4775ea133fd7Smrg } 4776a253d6aeSmrg 4777ea133fd7Smrg tmp_pathspec = realpath (pathspec, buf); 4778ea133fd7Smrg if (tmp_pathspec == 0) 4779ea133fd7Smrg { 478025b89263Smrg lt_fatal (__FILE__, __LINE__, 478125b89263Smrg "could not follow symlinks for %s", pathspec); 4782ea133fd7Smrg } 4783ea133fd7Smrg return xstrdup (tmp_pathspec); 4784ea133fd7Smrg#endif 4785ea133fd7Smrg} 4786a253d6aeSmrg 4787ea133fd7Smrgchar * 4788ea133fd7Smrgstrendzap (char *str, const char *pat) 4789ea133fd7Smrg{ 4790ea133fd7Smrg size_t len, patlen; 4791a253d6aeSmrg 4792ea133fd7Smrg assert (str != NULL); 4793ea133fd7Smrg assert (pat != NULL); 4794a253d6aeSmrg 4795ea133fd7Smrg len = strlen (str); 4796ea133fd7Smrg patlen = strlen (pat); 4797a253d6aeSmrg 4798ea133fd7Smrg if (patlen <= len) 4799ea133fd7Smrg { 4800ea133fd7Smrg str += len - patlen; 4801ea133fd7Smrg if (strcmp (str, pat) == 0) 4802ea133fd7Smrg *str = '\0'; 4803ea133fd7Smrg } 4804ea133fd7Smrg return str; 4805ea133fd7Smrg} 4806a253d6aeSmrg 480725b89263Smrgvoid 480825b89263Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 480925b89263Smrg{ 481025b89263Smrg va_list args; 481125b89263Smrg if (lt_debug) 481225b89263Smrg { 481325b89263Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 481425b89263Smrg va_start (args, fmt); 481525b89263Smrg (void) vfprintf (stderr, fmt, args); 481625b89263Smrg va_end (args); 481725b89263Smrg } 481825b89263Smrg} 481925b89263Smrg 4820ea133fd7Smrgstatic void 482125b89263Smrglt_error_core (int exit_status, const char *file, 482225b89263Smrg int line, const char *mode, 4823ea133fd7Smrg const char *message, va_list ap) 4824ea133fd7Smrg{ 482525b89263Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 4826ea133fd7Smrg vfprintf (stderr, message, ap); 4827ea133fd7Smrg fprintf (stderr, ".\n"); 4828a253d6aeSmrg 4829ea133fd7Smrg if (exit_status >= 0) 4830ea133fd7Smrg exit (exit_status); 4831ea133fd7Smrg} 4832a253d6aeSmrg 4833ea133fd7Smrgvoid 483425b89263Smrglt_fatal (const char *file, int line, const char *message, ...) 4835ea133fd7Smrg{ 4836ea133fd7Smrg va_list ap; 4837ea133fd7Smrg va_start (ap, message); 483825b89263Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 4839ea133fd7Smrg va_end (ap); 4840ea133fd7Smrg} 4841a253d6aeSmrg 484225b89263Smrgstatic const char * 484325b89263Smrgnonnull (const char *s) 484425b89263Smrg{ 484525b89263Smrg return s ? s : "(null)"; 484625b89263Smrg} 484725b89263Smrg 484825b89263Smrgstatic const char * 484925b89263Smrgnonempty (const char *s) 485025b89263Smrg{ 485125b89263Smrg return (s && !*s) ? "(empty)" : nonnull (s); 485225b89263Smrg} 485325b89263Smrg 4854ea133fd7Smrgvoid 4855ea133fd7Smrglt_setenv (const char *name, const char *value) 4856ea133fd7Smrg{ 485725b89263Smrg lt_debugprintf (__FILE__, __LINE__, 485825b89263Smrg "(lt_setenv) setting '%s' to '%s'\n", 485925b89263Smrg nonnull (name), nonnull (value)); 4860ea133fd7Smrg { 4861ea133fd7Smrg#ifdef HAVE_SETENV 4862ea133fd7Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 4863ea133fd7Smrg char *str = xstrdup (value); 4864ea133fd7Smrg setenv (name, str, 1); 4865ea133fd7Smrg#else 4866ea133fd7Smrg int len = strlen (name) + 1 + strlen (value) + 1; 4867ea133fd7Smrg char *str = XMALLOC (char, len); 4868ea133fd7Smrg sprintf (str, "%s=%s", name, value); 4869ea133fd7Smrg if (putenv (str) != EXIT_SUCCESS) 4870ea133fd7Smrg { 4871ea133fd7Smrg XFREE (str); 4872ea133fd7Smrg } 4873ea133fd7Smrg#endif 4874ea133fd7Smrg } 4875ea133fd7Smrg} 4876a253d6aeSmrg 4877ea133fd7Smrgchar * 4878ea133fd7Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 4879ea133fd7Smrg{ 4880ea133fd7Smrg char *new_value; 4881ea133fd7Smrg if (orig_value && *orig_value) 4882ea133fd7Smrg { 4883ea133fd7Smrg int orig_value_len = strlen (orig_value); 4884ea133fd7Smrg int add_len = strlen (add); 4885ea133fd7Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 4886ea133fd7Smrg if (to_end) 4887ea133fd7Smrg { 4888ea133fd7Smrg strcpy (new_value, orig_value); 4889ea133fd7Smrg strcpy (new_value + orig_value_len, add); 4890ea133fd7Smrg } 4891ea133fd7Smrg else 4892ea133fd7Smrg { 4893ea133fd7Smrg strcpy (new_value, add); 4894ea133fd7Smrg strcpy (new_value + add_len, orig_value); 4895ea133fd7Smrg } 4896ea133fd7Smrg } 4897ea133fd7Smrg else 4898ea133fd7Smrg { 4899ea133fd7Smrg new_value = xstrdup (add); 4900ea133fd7Smrg } 4901ea133fd7Smrg return new_value; 4902ea133fd7Smrg} 4903a253d6aeSmrg 4904ea133fd7Smrgvoid 4905ea133fd7Smrglt_update_exe_path (const char *name, const char *value) 4906ea133fd7Smrg{ 490725b89263Smrg lt_debugprintf (__FILE__, __LINE__, 490825b89263Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 490925b89263Smrg nonnull (name), nonnull (value)); 4910a253d6aeSmrg 4911ea133fd7Smrg if (name && *name && value && *value) 4912ea133fd7Smrg { 4913ea133fd7Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4914ea133fd7Smrg /* some systems can't cope with a ':'-terminated path #' */ 4915ea133fd7Smrg int len = strlen (new_value); 4916ea133fd7Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 4917ea133fd7Smrg { 4918ea133fd7Smrg new_value[len-1] = '\0'; 4919ea133fd7Smrg } 4920ea133fd7Smrg lt_setenv (name, new_value); 4921ea133fd7Smrg XFREE (new_value); 4922ea133fd7Smrg } 4923ea133fd7Smrg} 4924a253d6aeSmrg 4925ea133fd7Smrgvoid 4926ea133fd7Smrglt_update_lib_path (const char *name, const char *value) 4927ea133fd7Smrg{ 492825b89263Smrg lt_debugprintf (__FILE__, __LINE__, 492925b89263Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 493025b89263Smrg nonnull (name), nonnull (value)); 4931a253d6aeSmrg 4932ea133fd7Smrg if (name && *name && value && *value) 4933ea133fd7Smrg { 4934ea133fd7Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4935ea133fd7Smrg lt_setenv (name, new_value); 4936ea133fd7Smrg XFREE (new_value); 4937ea133fd7Smrg } 4938ea133fd7Smrg} 4939a253d6aeSmrg 494025b89263SmrgEOF 494125b89263Smrg case $host_os in 494225b89263Smrg mingw*) 494325b89263Smrg cat <<"EOF" 494425b89263Smrg 494525b89263Smrg/* Prepares an argument vector before calling spawn(). 494625b89263Smrg Note that spawn() does not by itself call the command interpreter 494725b89263Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 494825b89263Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 494925b89263Smrg GetVersionEx(&v); 495025b89263Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 495125b89263Smrg }) ? "cmd.exe" : "command.com"). 495225b89263Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 495325b89263Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 495425b89263Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 495525b89263Smrg special way: 495625b89263Smrg - Space and tab are interpreted as delimiters. They are not treated as 495725b89263Smrg delimiters if they are surrounded by double quotes: "...". 495825b89263Smrg - Unescaped double quotes are removed from the input. Their only effect is 495925b89263Smrg that within double quotes, space and tab are treated like normal 496025b89263Smrg characters. 496125b89263Smrg - Backslashes not followed by double quotes are not special. 496225b89263Smrg - But 2*n+1 backslashes followed by a double quote become 496325b89263Smrg n backslashes followed by a double quote (n >= 0): 496425b89263Smrg \" -> " 496525b89263Smrg \\\" -> \" 496625b89263Smrg \\\\\" -> \\" 496725b89263Smrg */ 496825b89263Smrg#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" 496925b89263Smrg#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" 497025b89263Smrgchar ** 497125b89263Smrgprepare_spawn (char **argv) 497225b89263Smrg{ 497325b89263Smrg size_t argc; 497425b89263Smrg char **new_argv; 497525b89263Smrg size_t i; 497625b89263Smrg 497725b89263Smrg /* Count number of arguments. */ 497825b89263Smrg for (argc = 0; argv[argc] != NULL; argc++) 497925b89263Smrg ; 498025b89263Smrg 498125b89263Smrg /* Allocate new argument vector. */ 498225b89263Smrg new_argv = XMALLOC (char *, argc + 1); 498325b89263Smrg 498425b89263Smrg /* Put quoted arguments into the new argument vector. */ 498525b89263Smrg for (i = 0; i < argc; i++) 498625b89263Smrg { 498725b89263Smrg const char *string = argv[i]; 498825b89263Smrg 498925b89263Smrg if (string[0] == '\0') 499025b89263Smrg new_argv[i] = xstrdup ("\"\""); 499125b89263Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 499225b89263Smrg { 499325b89263Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 499425b89263Smrg size_t length; 499525b89263Smrg unsigned int backslashes; 499625b89263Smrg const char *s; 499725b89263Smrg char *quoted_string; 499825b89263Smrg char *p; 499925b89263Smrg 500025b89263Smrg length = 0; 500125b89263Smrg backslashes = 0; 500225b89263Smrg if (quote_around) 500325b89263Smrg length++; 500425b89263Smrg for (s = string; *s != '\0'; s++) 500525b89263Smrg { 500625b89263Smrg char c = *s; 500725b89263Smrg if (c == '"') 500825b89263Smrg length += backslashes + 1; 500925b89263Smrg length++; 501025b89263Smrg if (c == '\\') 501125b89263Smrg backslashes++; 501225b89263Smrg else 501325b89263Smrg backslashes = 0; 501425b89263Smrg } 501525b89263Smrg if (quote_around) 501625b89263Smrg length += backslashes + 1; 501725b89263Smrg 501825b89263Smrg quoted_string = XMALLOC (char, length + 1); 501925b89263Smrg 502025b89263Smrg p = quoted_string; 502125b89263Smrg backslashes = 0; 502225b89263Smrg if (quote_around) 502325b89263Smrg *p++ = '"'; 502425b89263Smrg for (s = string; *s != '\0'; s++) 502525b89263Smrg { 502625b89263Smrg char c = *s; 502725b89263Smrg if (c == '"') 502825b89263Smrg { 502925b89263Smrg unsigned int j; 503025b89263Smrg for (j = backslashes + 1; j > 0; j--) 503125b89263Smrg *p++ = '\\'; 503225b89263Smrg } 503325b89263Smrg *p++ = c; 503425b89263Smrg if (c == '\\') 503525b89263Smrg backslashes++; 503625b89263Smrg else 503725b89263Smrg backslashes = 0; 503825b89263Smrg } 503925b89263Smrg if (quote_around) 504025b89263Smrg { 504125b89263Smrg unsigned int j; 504225b89263Smrg for (j = backslashes; j > 0; j--) 504325b89263Smrg *p++ = '\\'; 504425b89263Smrg *p++ = '"'; 504525b89263Smrg } 504625b89263Smrg *p = '\0'; 504725b89263Smrg 504825b89263Smrg new_argv[i] = quoted_string; 504925b89263Smrg } 505025b89263Smrg else 505125b89263Smrg new_argv[i] = (char *) string; 505225b89263Smrg } 505325b89263Smrg new_argv[argc] = NULL; 505425b89263Smrg 505525b89263Smrg return new_argv; 505625b89263Smrg} 505725b89263SmrgEOF 505825b89263Smrg ;; 505925b89263Smrg esac 506025b89263Smrg 506125b89263Smrg cat <<"EOF" 506225b89263Smrgvoid lt_dump_script (FILE* f) 506325b89263Smrg{ 506425b89263SmrgEOF 506525b89263Smrg func_emit_wrapper yes | 506657ee1794Smrg $SED -n -e ' 506757ee1794Smrgs/^\(.\{79\}\)\(..*\)/\1\ 506857ee1794Smrg\2/ 506957ee1794Smrgh 507057ee1794Smrgs/\([\\"]\)/\\\1/g 507157ee1794Smrgs/$/\\n/ 507257ee1794Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 507357ee1794Smrgg 507457ee1794SmrgD' 507525b89263Smrg cat <<"EOF" 507625b89263Smrg} 5077ea133fd7SmrgEOF 5078ea133fd7Smrg} 5079ea133fd7Smrg# end: func_emit_cwrapperexe_src 5080a253d6aeSmrg 508125b89263Smrg# func_win32_import_lib_p ARG 508225b89263Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 508325b89263Smrgfunc_win32_import_lib_p () 508425b89263Smrg{ 508525b89263Smrg $opt_debug 508625b89263Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 508725b89263Smrg *import*) : ;; 508825b89263Smrg *) false ;; 508925b89263Smrg esac 509025b89263Smrg} 509125b89263Smrg 5092ea133fd7Smrg# func_mode_link arg... 5093ea133fd7Smrgfunc_mode_link () 5094ea133fd7Smrg{ 5095ea133fd7Smrg $opt_debug 5096ea133fd7Smrg case $host in 5097ea133fd7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5098ea133fd7Smrg # It is impossible to link a dll without this setting, and 5099ea133fd7Smrg # we shouldn't force the makefile maintainer to figure out 5100ea133fd7Smrg # which system we are compiling for in order to pass an extra 5101ea133fd7Smrg # flag for every libtool invocation. 5102ea133fd7Smrg # allow_undefined=no 5103a253d6aeSmrg 5104ea133fd7Smrg # FIXME: Unfortunately, there are problems with the above when trying 5105ea133fd7Smrg # to make a dll which has undefined symbols, in which case not 5106ea133fd7Smrg # even a static library is built. For now, we need to specify 5107ea133fd7Smrg # -no-undefined on the libtool link line when we can be certain 5108ea133fd7Smrg # that all symbols are satisfied, otherwise we get a static library. 5109ea133fd7Smrg allow_undefined=yes 5110ea133fd7Smrg ;; 5111ea133fd7Smrg *) 5112ea133fd7Smrg allow_undefined=yes 5113ea133fd7Smrg ;; 5114ea133fd7Smrg esac 5115ea133fd7Smrg libtool_args=$nonopt 5116ea133fd7Smrg base_compile="$nonopt $@" 5117ea133fd7Smrg compile_command=$nonopt 5118ea133fd7Smrg finalize_command=$nonopt 5119a253d6aeSmrg 5120ea133fd7Smrg compile_rpath= 5121ea133fd7Smrg finalize_rpath= 5122ea133fd7Smrg compile_shlibpath= 5123ea133fd7Smrg finalize_shlibpath= 5124ea133fd7Smrg convenience= 5125ea133fd7Smrg old_convenience= 5126ea133fd7Smrg deplibs= 5127ea133fd7Smrg old_deplibs= 5128ea133fd7Smrg compiler_flags= 5129ea133fd7Smrg linker_flags= 5130ea133fd7Smrg dllsearchpath= 5131ea133fd7Smrg lib_search_path=`pwd` 5132ea133fd7Smrg inst_prefix_dir= 5133ea133fd7Smrg new_inherited_linker_flags= 5134a253d6aeSmrg 5135ea133fd7Smrg avoid_version=no 513625b89263Smrg bindir= 5137ea133fd7Smrg dlfiles= 5138ea133fd7Smrg dlprefiles= 5139ea133fd7Smrg dlself=no 5140ea133fd7Smrg export_dynamic=no 5141ea133fd7Smrg export_symbols= 5142ea133fd7Smrg export_symbols_regex= 5143ea133fd7Smrg generated= 5144ea133fd7Smrg libobjs= 5145ea133fd7Smrg ltlibs= 5146ea133fd7Smrg module=no 5147ea133fd7Smrg no_install=no 5148ea133fd7Smrg objs= 5149ea133fd7Smrg non_pic_objects= 5150ea133fd7Smrg precious_files_regex= 5151ea133fd7Smrg prefer_static_libs=no 5152ea133fd7Smrg preload=no 5153ea133fd7Smrg prev= 5154ea133fd7Smrg prevarg= 5155ea133fd7Smrg release= 5156ea133fd7Smrg rpath= 5157ea133fd7Smrg xrpath= 5158ea133fd7Smrg perm_rpath= 5159ea133fd7Smrg temp_rpath= 5160ea133fd7Smrg thread_safe=no 5161ea133fd7Smrg vinfo= 5162ea133fd7Smrg vinfo_number=no 5163ea133fd7Smrg weak_libs= 5164ea133fd7Smrg single_module="${wl}-single_module" 5165ea133fd7Smrg func_infer_tag $base_compile 5166a253d6aeSmrg 5167ea133fd7Smrg # We need to know -static, to get the right output filenames. 5168ea133fd7Smrg for arg 5169ea133fd7Smrg do 5170ea133fd7Smrg case $arg in 5171ea133fd7Smrg -shared) 5172ea133fd7Smrg test "$build_libtool_libs" != yes && \ 5173ea133fd7Smrg func_fatal_configuration "can not build a shared library" 5174ea133fd7Smrg build_old_libs=no 5175ea133fd7Smrg break 5176ea133fd7Smrg ;; 5177ea133fd7Smrg -all-static | -static | -static-libtool-libs) 5178ea133fd7Smrg case $arg in 5179ea133fd7Smrg -all-static) 5180ea133fd7Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 5181ea133fd7Smrg func_warning "complete static linking is impossible in this configuration" 5182a253d6aeSmrg fi 5183ea133fd7Smrg if test -n "$link_static_flag"; then 5184ea133fd7Smrg dlopen_self=$dlopen_self_static 5185a253d6aeSmrg fi 5186ea133fd7Smrg prefer_static_libs=yes 5187a253d6aeSmrg ;; 5188ea133fd7Smrg -static) 5189ea133fd7Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5190ea133fd7Smrg dlopen_self=$dlopen_self_static 5191ea133fd7Smrg fi 5192ea133fd7Smrg prefer_static_libs=built 5193ea133fd7Smrg ;; 5194ea133fd7Smrg -static-libtool-libs) 5195ea133fd7Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5196ea133fd7Smrg dlopen_self=$dlopen_self_static 5197ea133fd7Smrg fi 5198ea133fd7Smrg prefer_static_libs=yes 5199a253d6aeSmrg ;; 5200a253d6aeSmrg esac 5201ea133fd7Smrg build_libtool_libs=no 5202ea133fd7Smrg build_old_libs=yes 5203ea133fd7Smrg break 5204ea133fd7Smrg ;; 5205ea133fd7Smrg esac 5206ea133fd7Smrg done 5207a253d6aeSmrg 5208ea133fd7Smrg # See if our shared archives depend on static archives. 5209ea133fd7Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5210a253d6aeSmrg 5211ea133fd7Smrg # Go through the arguments, transforming them on the way. 5212ea133fd7Smrg while test "$#" -gt 0; do 5213ea133fd7Smrg arg="$1" 5214ea133fd7Smrg shift 5215ea133fd7Smrg func_quote_for_eval "$arg" 5216ea133fd7Smrg qarg=$func_quote_for_eval_unquoted_result 5217ea133fd7Smrg func_append libtool_args " $func_quote_for_eval_result" 5218a253d6aeSmrg 5219ea133fd7Smrg # If the previous option needs an argument, assign it. 5220ea133fd7Smrg if test -n "$prev"; then 5221ea133fd7Smrg case $prev in 5222ea133fd7Smrg output) 5223ea133fd7Smrg func_append compile_command " @OUTPUT@" 5224ea133fd7Smrg func_append finalize_command " @OUTPUT@" 5225ea133fd7Smrg ;; 5226ea133fd7Smrg esac 5227a253d6aeSmrg 5228ea133fd7Smrg case $prev in 522925b89263Smrg bindir) 523025b89263Smrg bindir="$arg" 523125b89263Smrg prev= 523225b89263Smrg continue 523325b89263Smrg ;; 5234ea133fd7Smrg dlfiles|dlprefiles) 5235ea133fd7Smrg if test "$preload" = no; then 5236ea133fd7Smrg # Add the symbol object into the linking commands. 5237ea133fd7Smrg func_append compile_command " @SYMFILE@" 5238ea133fd7Smrg func_append finalize_command " @SYMFILE@" 5239ea133fd7Smrg preload=yes 5240ea133fd7Smrg fi 5241ea133fd7Smrg case $arg in 5242ea133fd7Smrg *.la | *.lo) ;; # We handle these cases below. 5243ea133fd7Smrg force) 5244ea133fd7Smrg if test "$dlself" = no; then 5245ea133fd7Smrg dlself=needless 5246ea133fd7Smrg export_dynamic=yes 5247ea133fd7Smrg fi 5248ea133fd7Smrg prev= 5249ea133fd7Smrg continue 5250ea133fd7Smrg ;; 5251ea133fd7Smrg self) 5252ea133fd7Smrg if test "$prev" = dlprefiles; then 5253ea133fd7Smrg dlself=yes 5254ea133fd7Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 5255ea133fd7Smrg dlself=yes 5256ea133fd7Smrg else 5257ea133fd7Smrg dlself=needless 5258ea133fd7Smrg export_dynamic=yes 5259ea133fd7Smrg fi 5260ea133fd7Smrg prev= 5261ea133fd7Smrg continue 5262a253d6aeSmrg ;; 5263a253d6aeSmrg *) 5264ea133fd7Smrg if test "$prev" = dlfiles; then 526506f32fbeSmrg func_append dlfiles " $arg" 5266ea133fd7Smrg else 526706f32fbeSmrg func_append dlprefiles " $arg" 5268ea133fd7Smrg fi 5269ea133fd7Smrg prev= 5270ea133fd7Smrg continue 5271a253d6aeSmrg ;; 5272a253d6aeSmrg esac 5273ea133fd7Smrg ;; 5274ea133fd7Smrg expsyms) 5275ea133fd7Smrg export_symbols="$arg" 5276ea133fd7Smrg test -f "$arg" \ 5277ea133fd7Smrg || func_fatal_error "symbol file \`$arg' does not exist" 5278ea133fd7Smrg prev= 5279ea133fd7Smrg continue 5280ea133fd7Smrg ;; 5281ea133fd7Smrg expsyms_regex) 5282ea133fd7Smrg export_symbols_regex="$arg" 5283ea133fd7Smrg prev= 5284ea133fd7Smrg continue 5285ea133fd7Smrg ;; 5286ea133fd7Smrg framework) 5287ea133fd7Smrg case $host in 5288ea133fd7Smrg *-*-darwin*) 5289ea133fd7Smrg case "$deplibs " in 5290ea133fd7Smrg *" $qarg.ltframework "*) ;; 529106f32fbeSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 5292ea133fd7Smrg ;; 5293ea133fd7Smrg esac 5294ea133fd7Smrg ;; 5295ea133fd7Smrg esac 5296ea133fd7Smrg prev= 5297ea133fd7Smrg continue 5298ea133fd7Smrg ;; 5299ea133fd7Smrg inst_prefix) 5300ea133fd7Smrg inst_prefix_dir="$arg" 5301ea133fd7Smrg prev= 5302ea133fd7Smrg continue 5303ea133fd7Smrg ;; 5304ea133fd7Smrg objectlist) 5305ea133fd7Smrg if test -f "$arg"; then 5306ea133fd7Smrg save_arg=$arg 5307ea133fd7Smrg moreargs= 5308ea133fd7Smrg for fil in `cat "$save_arg"` 5309ea133fd7Smrg do 531006f32fbeSmrg# func_append moreargs " $fil" 5311ea133fd7Smrg arg=$fil 5312ea133fd7Smrg # A libtool-controlled object. 5313a253d6aeSmrg 5314ea133fd7Smrg # Check to see that this really is a libtool object. 5315ea133fd7Smrg if func_lalib_unsafe_p "$arg"; then 5316ea133fd7Smrg pic_object= 5317ea133fd7Smrg non_pic_object= 5318a253d6aeSmrg 5319ea133fd7Smrg # Read the .lo file 5320ea133fd7Smrg func_source "$arg" 5321a253d6aeSmrg 5322ea133fd7Smrg if test -z "$pic_object" || 5323ea133fd7Smrg test -z "$non_pic_object" || 5324ea133fd7Smrg test "$pic_object" = none && 5325ea133fd7Smrg test "$non_pic_object" = none; then 5326ea133fd7Smrg func_fatal_error "cannot find name of object for \`$arg'" 5327ea133fd7Smrg fi 5328a253d6aeSmrg 5329ea133fd7Smrg # Extract subdirectory from the argument. 5330ea133fd7Smrg func_dirname "$arg" "/" "" 5331ea133fd7Smrg xdir="$func_dirname_result" 5332a253d6aeSmrg 5333ea133fd7Smrg if test "$pic_object" != none; then 5334ea133fd7Smrg # Prepend the subdirectory the object is found in. 5335ea133fd7Smrg pic_object="$xdir$pic_object" 5336a253d6aeSmrg 5337ea133fd7Smrg if test "$prev" = dlfiles; then 5338ea133fd7Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 533906f32fbeSmrg func_append dlfiles " $pic_object" 5340ea133fd7Smrg prev= 5341ea133fd7Smrg continue 5342ea133fd7Smrg else 5343ea133fd7Smrg # If libtool objects are unsupported, then we need to preload. 5344ea133fd7Smrg prev=dlprefiles 5345ea133fd7Smrg fi 5346ea133fd7Smrg fi 5347a253d6aeSmrg 5348ea133fd7Smrg # CHECK ME: I think I busted this. -Ossama 5349ea133fd7Smrg if test "$prev" = dlprefiles; then 5350ea133fd7Smrg # Preload the old-style object. 535106f32fbeSmrg func_append dlprefiles " $pic_object" 5352ea133fd7Smrg prev= 5353ea133fd7Smrg fi 5354a253d6aeSmrg 5355ea133fd7Smrg # A PIC object. 5356ea133fd7Smrg func_append libobjs " $pic_object" 5357ea133fd7Smrg arg="$pic_object" 5358ea133fd7Smrg fi 5359a253d6aeSmrg 5360ea133fd7Smrg # Non-PIC object. 5361ea133fd7Smrg if test "$non_pic_object" != none; then 5362ea133fd7Smrg # Prepend the subdirectory the object is found in. 5363ea133fd7Smrg non_pic_object="$xdir$non_pic_object" 5364a253d6aeSmrg 5365ea133fd7Smrg # A standard non-PIC object 5366ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5367ea133fd7Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5368ea133fd7Smrg arg="$non_pic_object" 5369ea133fd7Smrg fi 5370ea133fd7Smrg else 5371ea133fd7Smrg # If the PIC object exists, use it instead. 5372ea133fd7Smrg # $xdir was prepended to $pic_object above. 5373ea133fd7Smrg non_pic_object="$pic_object" 5374ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5375ea133fd7Smrg fi 5376ea133fd7Smrg else 5377ea133fd7Smrg # Only an error if not doing a dry-run. 5378ea133fd7Smrg if $opt_dry_run; then 5379ea133fd7Smrg # Extract subdirectory from the argument. 5380ea133fd7Smrg func_dirname "$arg" "/" "" 5381ea133fd7Smrg xdir="$func_dirname_result" 5382ea133fd7Smrg 5383ea133fd7Smrg func_lo2o "$arg" 5384ea133fd7Smrg pic_object=$xdir$objdir/$func_lo2o_result 5385ea133fd7Smrg non_pic_object=$xdir$func_lo2o_result 5386ea133fd7Smrg func_append libobjs " $pic_object" 5387ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5388ea133fd7Smrg else 5389ea133fd7Smrg func_fatal_error "\`$arg' is not a valid libtool object" 5390ea133fd7Smrg fi 5391ea133fd7Smrg fi 5392ea133fd7Smrg done 5393ea133fd7Smrg else 5394ea133fd7Smrg func_fatal_error "link input file \`$arg' does not exist" 5395ea133fd7Smrg fi 5396ea133fd7Smrg arg=$save_arg 5397ea133fd7Smrg prev= 5398ea133fd7Smrg continue 5399ea133fd7Smrg ;; 5400ea133fd7Smrg precious_regex) 5401ea133fd7Smrg precious_files_regex="$arg" 5402ea133fd7Smrg prev= 5403ea133fd7Smrg continue 5404ea133fd7Smrg ;; 5405ea133fd7Smrg release) 5406ea133fd7Smrg release="-$arg" 5407ea133fd7Smrg prev= 5408ea133fd7Smrg continue 5409ea133fd7Smrg ;; 5410ea133fd7Smrg rpath | xrpath) 5411ea133fd7Smrg # We need an absolute path. 5412ea133fd7Smrg case $arg in 5413ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5414ea133fd7Smrg *) 5415ea133fd7Smrg func_fatal_error "only absolute run-paths are allowed" 5416ea133fd7Smrg ;; 5417ea133fd7Smrg esac 5418ea133fd7Smrg if test "$prev" = rpath; then 5419ea133fd7Smrg case "$rpath " in 5420ea133fd7Smrg *" $arg "*) ;; 542106f32fbeSmrg *) func_append rpath " $arg" ;; 5422ea133fd7Smrg esac 5423ea133fd7Smrg else 5424ea133fd7Smrg case "$xrpath " in 5425ea133fd7Smrg *" $arg "*) ;; 542606f32fbeSmrg *) func_append xrpath " $arg" ;; 5427ea133fd7Smrg esac 5428ea133fd7Smrg fi 5429ea133fd7Smrg prev= 5430ea133fd7Smrg continue 5431ea133fd7Smrg ;; 5432ea133fd7Smrg shrext) 5433ea133fd7Smrg shrext_cmds="$arg" 5434ea133fd7Smrg prev= 5435ea133fd7Smrg continue 5436ea133fd7Smrg ;; 5437ea133fd7Smrg weak) 543806f32fbeSmrg func_append weak_libs " $arg" 5439ea133fd7Smrg prev= 5440ea133fd7Smrg continue 5441ea133fd7Smrg ;; 5442ea133fd7Smrg xcclinker) 544306f32fbeSmrg func_append linker_flags " $qarg" 544406f32fbeSmrg func_append compiler_flags " $qarg" 5445ea133fd7Smrg prev= 5446ea133fd7Smrg func_append compile_command " $qarg" 5447ea133fd7Smrg func_append finalize_command " $qarg" 5448ea133fd7Smrg continue 5449ea133fd7Smrg ;; 5450ea133fd7Smrg xcompiler) 545106f32fbeSmrg func_append compiler_flags " $qarg" 5452ea133fd7Smrg prev= 5453ea133fd7Smrg func_append compile_command " $qarg" 5454ea133fd7Smrg func_append finalize_command " $qarg" 5455ea133fd7Smrg continue 5456ea133fd7Smrg ;; 5457ea133fd7Smrg xlinker) 545806f32fbeSmrg func_append linker_flags " $qarg" 545906f32fbeSmrg func_append compiler_flags " $wl$qarg" 5460ea133fd7Smrg prev= 5461ea133fd7Smrg func_append compile_command " $wl$qarg" 5462ea133fd7Smrg func_append finalize_command " $wl$qarg" 5463ea133fd7Smrg continue 5464ea133fd7Smrg ;; 5465ea133fd7Smrg *) 5466ea133fd7Smrg eval "$prev=\"\$arg\"" 5467ea133fd7Smrg prev= 5468ea133fd7Smrg continue 5469ea133fd7Smrg ;; 5470a253d6aeSmrg esac 5471ea133fd7Smrg fi # test -n "$prev" 5472a253d6aeSmrg 5473ea133fd7Smrg prevarg="$arg" 5474a253d6aeSmrg 5475ea133fd7Smrg case $arg in 5476ea133fd7Smrg -all-static) 5477ea133fd7Smrg if test -n "$link_static_flag"; then 5478ea133fd7Smrg # See comment for -static flag below, for more details. 5479ea133fd7Smrg func_append compile_command " $link_static_flag" 5480ea133fd7Smrg func_append finalize_command " $link_static_flag" 5481ea133fd7Smrg fi 5482ea133fd7Smrg continue 5483ea133fd7Smrg ;; 5484a253d6aeSmrg 5485ea133fd7Smrg -allow-undefined) 5486ea133fd7Smrg # FIXME: remove this flag sometime in the future. 5487ea133fd7Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 5488ea133fd7Smrg ;; 5489a253d6aeSmrg 5490ea133fd7Smrg -avoid-version) 5491ea133fd7Smrg avoid_version=yes 5492ea133fd7Smrg continue 5493ea133fd7Smrg ;; 5494a253d6aeSmrg 549525b89263Smrg -bindir) 549625b89263Smrg prev=bindir 549725b89263Smrg continue 549825b89263Smrg ;; 549925b89263Smrg 5500ea133fd7Smrg -dlopen) 5501ea133fd7Smrg prev=dlfiles 5502ea133fd7Smrg continue 5503ea133fd7Smrg ;; 5504a253d6aeSmrg 5505ea133fd7Smrg -dlpreopen) 5506ea133fd7Smrg prev=dlprefiles 5507ea133fd7Smrg continue 5508ea133fd7Smrg ;; 5509a253d6aeSmrg 5510ea133fd7Smrg -export-dynamic) 5511ea133fd7Smrg export_dynamic=yes 5512ea133fd7Smrg continue 5513ea133fd7Smrg ;; 5514a253d6aeSmrg 5515ea133fd7Smrg -export-symbols | -export-symbols-regex) 5516ea133fd7Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 5517ea133fd7Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 5518ea133fd7Smrg fi 5519ea133fd7Smrg if test "X$arg" = "X-export-symbols"; then 5520ea133fd7Smrg prev=expsyms 5521ea133fd7Smrg else 5522ea133fd7Smrg prev=expsyms_regex 5523ea133fd7Smrg fi 5524ea133fd7Smrg continue 5525ea133fd7Smrg ;; 5526a253d6aeSmrg 5527ea133fd7Smrg -framework) 5528ea133fd7Smrg prev=framework 5529ea133fd7Smrg continue 5530ea133fd7Smrg ;; 5531a253d6aeSmrg 5532ea133fd7Smrg -inst-prefix-dir) 5533ea133fd7Smrg prev=inst_prefix 5534ea133fd7Smrg continue 5535ea133fd7Smrg ;; 5536a253d6aeSmrg 5537ea133fd7Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 5538ea133fd7Smrg # so, if we see these flags be careful not to treat them like -L 5539ea133fd7Smrg -L[A-Z][A-Z]*:*) 5540ea133fd7Smrg case $with_gcc/$host in 5541ea133fd7Smrg no/*-*-irix* | /*-*-irix*) 5542ea133fd7Smrg func_append compile_command " $arg" 5543ea133fd7Smrg func_append finalize_command " $arg" 5544ea133fd7Smrg ;; 5545ea133fd7Smrg esac 5546ea133fd7Smrg continue 5547ea133fd7Smrg ;; 5548a253d6aeSmrg 5549ea133fd7Smrg -L*) 555006f32fbeSmrg func_stripname "-L" '' "$arg" 555106f32fbeSmrg if test -z "$func_stripname_result"; then 5552ea133fd7Smrg if test "$#" -gt 0; then 5553ea133fd7Smrg func_fatal_error "require no space between \`-L' and \`$1'" 5554ea133fd7Smrg else 5555ea133fd7Smrg func_fatal_error "need path for \`-L' option" 5556ea133fd7Smrg fi 5557ea133fd7Smrg fi 555806f32fbeSmrg func_resolve_sysroot "$func_stripname_result" 555906f32fbeSmrg dir=$func_resolve_sysroot_result 5560ea133fd7Smrg # We need an absolute path. 5561ea133fd7Smrg case $dir in 5562ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5563ea133fd7Smrg *) 5564ea133fd7Smrg absdir=`cd "$dir" && pwd` 5565ea133fd7Smrg test -z "$absdir" && \ 5566ea133fd7Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 5567ea133fd7Smrg dir="$absdir" 5568ea133fd7Smrg ;; 5569ea133fd7Smrg esac 5570ea133fd7Smrg case "$deplibs " in 557106f32fbeSmrg *" -L$dir "* | *" $arg "*) 557206f32fbeSmrg # Will only happen for absolute or sysroot arguments 557306f32fbeSmrg ;; 5574ea133fd7Smrg *) 557506f32fbeSmrg # Preserve sysroot, but never include relative directories 557606f32fbeSmrg case $dir in 557706f32fbeSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 557806f32fbeSmrg *) func_append deplibs " -L$dir" ;; 557906f32fbeSmrg esac 558006f32fbeSmrg func_append lib_search_path " $dir" 5581ea133fd7Smrg ;; 5582ea133fd7Smrg esac 5583ea133fd7Smrg case $host in 5584ea133fd7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 558525b89263Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 5586ea133fd7Smrg case :$dllsearchpath: in 5587ea133fd7Smrg *":$dir:"*) ;; 5588ea133fd7Smrg ::) dllsearchpath=$dir;; 558906f32fbeSmrg *) func_append dllsearchpath ":$dir";; 5590ea133fd7Smrg esac 5591ea133fd7Smrg case :$dllsearchpath: in 5592ea133fd7Smrg *":$testbindir:"*) ;; 5593ea133fd7Smrg ::) dllsearchpath=$testbindir;; 559406f32fbeSmrg *) func_append dllsearchpath ":$testbindir";; 5595ea133fd7Smrg esac 5596ea133fd7Smrg ;; 5597ea133fd7Smrg esac 5598ea133fd7Smrg continue 5599ea133fd7Smrg ;; 5600a253d6aeSmrg 5601ea133fd7Smrg -l*) 5602ea133fd7Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 5603ea133fd7Smrg case $host in 560425b89263Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 5605ea133fd7Smrg # These systems don't actually have a C or math library (as such) 5606ea133fd7Smrg continue 5607ea133fd7Smrg ;; 5608ea133fd7Smrg *-*-os2*) 5609ea133fd7Smrg # These systems don't actually have a C library (as such) 5610ea133fd7Smrg test "X$arg" = "X-lc" && continue 5611ea133fd7Smrg ;; 5612ea133fd7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5613ea133fd7Smrg # Do not include libc due to us having libc/libc_r. 5614ea133fd7Smrg test "X$arg" = "X-lc" && continue 5615ea133fd7Smrg ;; 5616ea133fd7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 5617ea133fd7Smrg # Rhapsody C and math libraries are in the System framework 561806f32fbeSmrg func_append deplibs " System.ltframework" 5619ea133fd7Smrg continue 5620ea133fd7Smrg ;; 5621ea133fd7Smrg *-*-sco3.2v5* | *-*-sco5v6*) 5622ea133fd7Smrg # Causes problems with __ctype 5623ea133fd7Smrg test "X$arg" = "X-lc" && continue 5624ea133fd7Smrg ;; 5625ea133fd7Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 5626ea133fd7Smrg # Compiler inserts libc in the correct place for threads to work 5627ea133fd7Smrg test "X$arg" = "X-lc" && continue 5628ea133fd7Smrg ;; 5629ea133fd7Smrg esac 5630ea133fd7Smrg elif test "X$arg" = "X-lc_r"; then 5631ea133fd7Smrg case $host in 5632ea133fd7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5633ea133fd7Smrg # Do not include libc_r directly, use -pthread flag. 5634ea133fd7Smrg continue 5635ea133fd7Smrg ;; 5636ea133fd7Smrg esac 5637ea133fd7Smrg fi 563806f32fbeSmrg func_append deplibs " $arg" 5639ea133fd7Smrg continue 5640ea133fd7Smrg ;; 5641a253d6aeSmrg 5642ea133fd7Smrg -module) 5643ea133fd7Smrg module=yes 5644ea133fd7Smrg continue 5645ea133fd7Smrg ;; 5646a253d6aeSmrg 5647ea133fd7Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 5648ea133fd7Smrg # classes, name mangling, and exception handling. 5649ea133fd7Smrg # Darwin uses the -arch flag to determine output architecture. 565006f32fbeSmrg -model|-arch|-isysroot|--sysroot) 565106f32fbeSmrg func_append compiler_flags " $arg" 5652ea133fd7Smrg func_append compile_command " $arg" 5653ea133fd7Smrg func_append finalize_command " $arg" 5654ea133fd7Smrg prev=xcompiler 5655ea133fd7Smrg continue 5656ea133fd7Smrg ;; 5657a253d6aeSmrg 565857ee1794Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 565957ee1794Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 566006f32fbeSmrg func_append compiler_flags " $arg" 5661ea133fd7Smrg func_append compile_command " $arg" 5662ea133fd7Smrg func_append finalize_command " $arg" 5663ea133fd7Smrg case "$new_inherited_linker_flags " in 5664ea133fd7Smrg *" $arg "*) ;; 566506f32fbeSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 5666ea133fd7Smrg esac 5667ea133fd7Smrg continue 5668ea133fd7Smrg ;; 5669a253d6aeSmrg 5670ea133fd7Smrg -multi_module) 5671ea133fd7Smrg single_module="${wl}-multi_module" 5672ea133fd7Smrg continue 5673ea133fd7Smrg ;; 5674a253d6aeSmrg 5675ea133fd7Smrg -no-fast-install) 5676ea133fd7Smrg fast_install=no 5677ea133fd7Smrg continue 5678ea133fd7Smrg ;; 5679a253d6aeSmrg 5680ea133fd7Smrg -no-install) 5681ea133fd7Smrg case $host in 5682ea133fd7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 5683ea133fd7Smrg # The PATH hackery in wrapper scripts is required on Windows 5684ea133fd7Smrg # and Darwin in order for the loader to find any dlls it needs. 5685ea133fd7Smrg func_warning "\`-no-install' is ignored for $host" 5686ea133fd7Smrg func_warning "assuming \`-no-fast-install' instead" 5687ea133fd7Smrg fast_install=no 5688ea133fd7Smrg ;; 5689ea133fd7Smrg *) no_install=yes ;; 5690ea133fd7Smrg esac 5691ea133fd7Smrg continue 5692ea133fd7Smrg ;; 5693a253d6aeSmrg 5694ea133fd7Smrg -no-undefined) 5695ea133fd7Smrg allow_undefined=no 5696ea133fd7Smrg continue 5697ea133fd7Smrg ;; 5698a253d6aeSmrg 5699ea133fd7Smrg -objectlist) 5700ea133fd7Smrg prev=objectlist 5701ea133fd7Smrg continue 5702ea133fd7Smrg ;; 5703a253d6aeSmrg 5704ea133fd7Smrg -o) prev=output ;; 5705a253d6aeSmrg 5706ea133fd7Smrg -precious-files-regex) 5707ea133fd7Smrg prev=precious_regex 5708ea133fd7Smrg continue 5709ea133fd7Smrg ;; 5710a253d6aeSmrg 5711ea133fd7Smrg -release) 5712ea133fd7Smrg prev=release 5713ea133fd7Smrg continue 5714ea133fd7Smrg ;; 5715a253d6aeSmrg 5716ea133fd7Smrg -rpath) 5717ea133fd7Smrg prev=rpath 5718ea133fd7Smrg continue 5719ea133fd7Smrg ;; 5720a253d6aeSmrg 5721ea133fd7Smrg -R) 5722ea133fd7Smrg prev=xrpath 5723ea133fd7Smrg continue 5724ea133fd7Smrg ;; 5725a253d6aeSmrg 5726ea133fd7Smrg -R*) 5727ea133fd7Smrg func_stripname '-R' '' "$arg" 5728ea133fd7Smrg dir=$func_stripname_result 5729ea133fd7Smrg # We need an absolute path. 5730ea133fd7Smrg case $dir in 5731ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 573206f32fbeSmrg =*) 573306f32fbeSmrg func_stripname '=' '' "$dir" 573406f32fbeSmrg dir=$lt_sysroot$func_stripname_result 573506f32fbeSmrg ;; 5736ea133fd7Smrg *) 5737ea133fd7Smrg func_fatal_error "only absolute run-paths are allowed" 5738ea133fd7Smrg ;; 5739ea133fd7Smrg esac 5740ea133fd7Smrg case "$xrpath " in 5741ea133fd7Smrg *" $dir "*) ;; 574206f32fbeSmrg *) func_append xrpath " $dir" ;; 5743ea133fd7Smrg esac 5744ea133fd7Smrg continue 5745ea133fd7Smrg ;; 5746a253d6aeSmrg 5747ea133fd7Smrg -shared) 5748ea133fd7Smrg # The effects of -shared are defined in a previous loop. 5749ea133fd7Smrg continue 5750ea133fd7Smrg ;; 5751a253d6aeSmrg 5752ea133fd7Smrg -shrext) 5753ea133fd7Smrg prev=shrext 5754ea133fd7Smrg continue 5755ea133fd7Smrg ;; 5756a253d6aeSmrg 5757ea133fd7Smrg -static | -static-libtool-libs) 5758ea133fd7Smrg # The effects of -static are defined in a previous loop. 5759ea133fd7Smrg # We used to do the same as -all-static on platforms that 5760ea133fd7Smrg # didn't have a PIC flag, but the assumption that the effects 5761ea133fd7Smrg # would be equivalent was wrong. It would break on at least 5762ea133fd7Smrg # Digital Unix and AIX. 5763ea133fd7Smrg continue 5764ea133fd7Smrg ;; 5765a253d6aeSmrg 5766ea133fd7Smrg -thread-safe) 5767ea133fd7Smrg thread_safe=yes 5768ea133fd7Smrg continue 5769ea133fd7Smrg ;; 5770a253d6aeSmrg 5771ea133fd7Smrg -version-info) 5772ea133fd7Smrg prev=vinfo 5773ea133fd7Smrg continue 5774ea133fd7Smrg ;; 5775a253d6aeSmrg 5776ea133fd7Smrg -version-number) 5777ea133fd7Smrg prev=vinfo 5778ea133fd7Smrg vinfo_number=yes 5779ea133fd7Smrg continue 5780ea133fd7Smrg ;; 5781a253d6aeSmrg 5782ea133fd7Smrg -weak) 5783ea133fd7Smrg prev=weak 5784ea133fd7Smrg continue 5785ea133fd7Smrg ;; 5786a253d6aeSmrg 5787ea133fd7Smrg -Wc,*) 5788ea133fd7Smrg func_stripname '-Wc,' '' "$arg" 5789ea133fd7Smrg args=$func_stripname_result 5790ea133fd7Smrg arg= 5791ea133fd7Smrg save_ifs="$IFS"; IFS=',' 5792ea133fd7Smrg for flag in $args; do 5793ea133fd7Smrg IFS="$save_ifs" 5794ea133fd7Smrg func_quote_for_eval "$flag" 579506f32fbeSmrg func_append arg " $func_quote_for_eval_result" 579606f32fbeSmrg func_append compiler_flags " $func_quote_for_eval_result" 5797ea133fd7Smrg done 5798ea133fd7Smrg IFS="$save_ifs" 5799ea133fd7Smrg func_stripname ' ' '' "$arg" 5800ea133fd7Smrg arg=$func_stripname_result 5801ea133fd7Smrg ;; 5802a253d6aeSmrg 5803ea133fd7Smrg -Wl,*) 5804ea133fd7Smrg func_stripname '-Wl,' '' "$arg" 5805ea133fd7Smrg args=$func_stripname_result 5806ea133fd7Smrg arg= 5807ea133fd7Smrg save_ifs="$IFS"; IFS=',' 5808ea133fd7Smrg for flag in $args; do 5809ea133fd7Smrg IFS="$save_ifs" 5810ea133fd7Smrg func_quote_for_eval "$flag" 581106f32fbeSmrg func_append arg " $wl$func_quote_for_eval_result" 581206f32fbeSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 581306f32fbeSmrg func_append linker_flags " $func_quote_for_eval_result" 5814ea133fd7Smrg done 5815ea133fd7Smrg IFS="$save_ifs" 5816ea133fd7Smrg func_stripname ' ' '' "$arg" 5817ea133fd7Smrg arg=$func_stripname_result 5818ea133fd7Smrg ;; 5819a253d6aeSmrg 5820ea133fd7Smrg -Xcompiler) 5821ea133fd7Smrg prev=xcompiler 5822ea133fd7Smrg continue 5823ea133fd7Smrg ;; 5824a253d6aeSmrg 5825ea133fd7Smrg -Xlinker) 5826ea133fd7Smrg prev=xlinker 5827ea133fd7Smrg continue 5828ea133fd7Smrg ;; 5829a253d6aeSmrg 5830ea133fd7Smrg -XCClinker) 5831ea133fd7Smrg prev=xcclinker 5832ea133fd7Smrg continue 5833ea133fd7Smrg ;; 5834a253d6aeSmrg 5835ea133fd7Smrg # -msg_* for osf cc 5836ea133fd7Smrg -msg_*) 5837ea133fd7Smrg func_quote_for_eval "$arg" 5838ea133fd7Smrg arg="$func_quote_for_eval_result" 5839ea133fd7Smrg ;; 5840a253d6aeSmrg 584125b89263Smrg # Flags to be passed through unchanged, with rationale: 584225b89263Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 584325b89263Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 584425b89263Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 584525b89263Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 584625b89263Smrg # -q* compiler args for the IBM compiler 584725b89263Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 584825b89263Smrg # -F/path path to uninstalled frameworks, gcc on darwin 584925b89263Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 585025b89263Smrg # @file GCC response files 585125b89263Smrg # -tp=* Portland pgcc target processor selection 585206f32fbeSmrg # --sysroot=* for sysroot support 585306f32fbeSmrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 5854ea133fd7Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 585506f32fbeSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 585606f32fbeSmrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 5857ea133fd7Smrg func_quote_for_eval "$arg" 5858ea133fd7Smrg arg="$func_quote_for_eval_result" 5859ea133fd7Smrg func_append compile_command " $arg" 5860ea133fd7Smrg func_append finalize_command " $arg" 586106f32fbeSmrg func_append compiler_flags " $arg" 5862ea133fd7Smrg continue 5863ea133fd7Smrg ;; 5864a253d6aeSmrg 5865ea133fd7Smrg # Some other compiler flag. 5866ea133fd7Smrg -* | +*) 5867ea133fd7Smrg func_quote_for_eval "$arg" 5868ea133fd7Smrg arg="$func_quote_for_eval_result" 5869ea133fd7Smrg ;; 5870a253d6aeSmrg 5871ea133fd7Smrg *.$objext) 5872ea133fd7Smrg # A standard object. 587306f32fbeSmrg func_append objs " $arg" 5874ea133fd7Smrg ;; 5875ea133fd7Smrg 5876ea133fd7Smrg *.lo) 5877ea133fd7Smrg # A libtool-controlled object. 5878ea133fd7Smrg 5879ea133fd7Smrg # Check to see that this really is a libtool object. 5880ea133fd7Smrg if func_lalib_unsafe_p "$arg"; then 5881ea133fd7Smrg pic_object= 5882ea133fd7Smrg non_pic_object= 5883ea133fd7Smrg 5884ea133fd7Smrg # Read the .lo file 5885ea133fd7Smrg func_source "$arg" 5886ea133fd7Smrg 5887ea133fd7Smrg if test -z "$pic_object" || 5888ea133fd7Smrg test -z "$non_pic_object" || 5889ea133fd7Smrg test "$pic_object" = none && 5890ea133fd7Smrg test "$non_pic_object" = none; then 5891ea133fd7Smrg func_fatal_error "cannot find name of object for \`$arg'" 5892ea133fd7Smrg fi 5893ea133fd7Smrg 5894ea133fd7Smrg # Extract subdirectory from the argument. 5895ea133fd7Smrg func_dirname "$arg" "/" "" 5896ea133fd7Smrg xdir="$func_dirname_result" 5897ea133fd7Smrg 5898ea133fd7Smrg if test "$pic_object" != none; then 5899ea133fd7Smrg # Prepend the subdirectory the object is found in. 5900ea133fd7Smrg pic_object="$xdir$pic_object" 5901ea133fd7Smrg 5902ea133fd7Smrg if test "$prev" = dlfiles; then 5903ea133fd7Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 590406f32fbeSmrg func_append dlfiles " $pic_object" 5905ea133fd7Smrg prev= 5906ea133fd7Smrg continue 5907ea133fd7Smrg else 5908ea133fd7Smrg # If libtool objects are unsupported, then we need to preload. 5909ea133fd7Smrg prev=dlprefiles 5910ea133fd7Smrg fi 5911ea133fd7Smrg fi 5912ea133fd7Smrg 5913ea133fd7Smrg # CHECK ME: I think I busted this. -Ossama 5914ea133fd7Smrg if test "$prev" = dlprefiles; then 5915ea133fd7Smrg # Preload the old-style object. 591606f32fbeSmrg func_append dlprefiles " $pic_object" 5917ea133fd7Smrg prev= 5918ea133fd7Smrg fi 5919ea133fd7Smrg 5920ea133fd7Smrg # A PIC object. 5921ea133fd7Smrg func_append libobjs " $pic_object" 5922ea133fd7Smrg arg="$pic_object" 5923ea133fd7Smrg fi 5924ea133fd7Smrg 5925ea133fd7Smrg # Non-PIC object. 5926ea133fd7Smrg if test "$non_pic_object" != none; then 5927ea133fd7Smrg # Prepend the subdirectory the object is found in. 5928ea133fd7Smrg non_pic_object="$xdir$non_pic_object" 5929ea133fd7Smrg 5930ea133fd7Smrg # A standard non-PIC object 5931ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5932ea133fd7Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5933ea133fd7Smrg arg="$non_pic_object" 5934ea133fd7Smrg fi 5935ea133fd7Smrg else 5936ea133fd7Smrg # If the PIC object exists, use it instead. 5937ea133fd7Smrg # $xdir was prepended to $pic_object above. 5938ea133fd7Smrg non_pic_object="$pic_object" 5939ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5940ea133fd7Smrg fi 5941ea133fd7Smrg else 5942ea133fd7Smrg # Only an error if not doing a dry-run. 5943ea133fd7Smrg if $opt_dry_run; then 5944ea133fd7Smrg # Extract subdirectory from the argument. 5945ea133fd7Smrg func_dirname "$arg" "/" "" 5946ea133fd7Smrg xdir="$func_dirname_result" 5947ea133fd7Smrg 5948ea133fd7Smrg func_lo2o "$arg" 5949ea133fd7Smrg pic_object=$xdir$objdir/$func_lo2o_result 5950ea133fd7Smrg non_pic_object=$xdir$func_lo2o_result 5951ea133fd7Smrg func_append libobjs " $pic_object" 5952ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5953ea133fd7Smrg else 5954ea133fd7Smrg func_fatal_error "\`$arg' is not a valid libtool object" 5955ea133fd7Smrg fi 5956ea133fd7Smrg fi 5957ea133fd7Smrg ;; 5958ea133fd7Smrg 5959ea133fd7Smrg *.$libext) 5960ea133fd7Smrg # An archive. 596106f32fbeSmrg func_append deplibs " $arg" 596206f32fbeSmrg func_append old_deplibs " $arg" 5963ea133fd7Smrg continue 5964ea133fd7Smrg ;; 5965ea133fd7Smrg 5966ea133fd7Smrg *.la) 5967ea133fd7Smrg # A libtool-controlled library. 5968ea133fd7Smrg 596906f32fbeSmrg func_resolve_sysroot "$arg" 5970ea133fd7Smrg if test "$prev" = dlfiles; then 5971ea133fd7Smrg # This library was specified with -dlopen. 597206f32fbeSmrg func_append dlfiles " $func_resolve_sysroot_result" 5973ea133fd7Smrg prev= 5974ea133fd7Smrg elif test "$prev" = dlprefiles; then 5975ea133fd7Smrg # The library was specified with -dlpreopen. 597606f32fbeSmrg func_append dlprefiles " $func_resolve_sysroot_result" 5977ea133fd7Smrg prev= 5978ea133fd7Smrg else 597906f32fbeSmrg func_append deplibs " $func_resolve_sysroot_result" 5980ea133fd7Smrg fi 5981ea133fd7Smrg continue 5982ea133fd7Smrg ;; 5983ea133fd7Smrg 5984ea133fd7Smrg # Some other compiler argument. 5985ea133fd7Smrg *) 5986ea133fd7Smrg # Unknown arguments in both finalize_command and compile_command need 5987ea133fd7Smrg # to be aesthetically quoted because they are evaled later. 5988ea133fd7Smrg func_quote_for_eval "$arg" 5989ea133fd7Smrg arg="$func_quote_for_eval_result" 5990ea133fd7Smrg ;; 5991ea133fd7Smrg esac # arg 5992ea133fd7Smrg 5993ea133fd7Smrg # Now actually substitute the argument into the commands. 5994ea133fd7Smrg if test -n "$arg"; then 5995ea133fd7Smrg func_append compile_command " $arg" 5996ea133fd7Smrg func_append finalize_command " $arg" 5997ea133fd7Smrg fi 5998ea133fd7Smrg done # argument parsing loop 5999ea133fd7Smrg 6000ea133fd7Smrg test -n "$prev" && \ 6001ea133fd7Smrg func_fatal_help "the \`$prevarg' option requires an argument" 6002ea133fd7Smrg 6003ea133fd7Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 6004ea133fd7Smrg eval arg=\"$export_dynamic_flag_spec\" 6005ea133fd7Smrg func_append compile_command " $arg" 6006ea133fd7Smrg func_append finalize_command " $arg" 6007ea133fd7Smrg fi 6008ea133fd7Smrg 6009ea133fd7Smrg oldlibs= 6010ea133fd7Smrg # calculate the name of the file, without its directory 6011ea133fd7Smrg func_basename "$output" 6012ea133fd7Smrg outputname="$func_basename_result" 6013ea133fd7Smrg libobjs_save="$libobjs" 6014ea133fd7Smrg 6015ea133fd7Smrg if test -n "$shlibpath_var"; then 6016ea133fd7Smrg # get the directories listed in $shlibpath_var 601725b89263Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 6018a253d6aeSmrg else 6019ea133fd7Smrg shlib_search_path= 6020a253d6aeSmrg fi 6021ea133fd7Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 6022ea133fd7Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 6023a253d6aeSmrg 6024ea133fd7Smrg func_dirname "$output" "/" "" 6025ea133fd7Smrg output_objdir="$func_dirname_result$objdir" 602606f32fbeSmrg func_to_tool_file "$output_objdir/" 602706f32fbeSmrg tool_output_objdir=$func_to_tool_file_result 6028ea133fd7Smrg # Create the object directory. 6029ea133fd7Smrg func_mkdir_p "$output_objdir" 6030a253d6aeSmrg 6031ea133fd7Smrg # Determine the type of output 6032ea133fd7Smrg case $output in 6033ea133fd7Smrg "") 6034ea133fd7Smrg func_fatal_help "you must specify an output file" 6035ea133fd7Smrg ;; 6036ea133fd7Smrg *.$libext) linkmode=oldlib ;; 6037ea133fd7Smrg *.lo | *.$objext) linkmode=obj ;; 6038ea133fd7Smrg *.la) linkmode=lib ;; 6039ea133fd7Smrg *) linkmode=prog ;; # Anything else should be a program. 6040ea133fd7Smrg esac 6041ea133fd7Smrg 6042ea133fd7Smrg specialdeplibs= 6043ea133fd7Smrg 6044ea133fd7Smrg libs= 6045ea133fd7Smrg # Find all interdependent deplibs by searching for libraries 6046ea133fd7Smrg # that are linked more than once (e.g. -la -lb -la) 6047ea133fd7Smrg for deplib in $deplibs; do 604806f32fbeSmrg if $opt_preserve_dup_deps ; then 6049ea133fd7Smrg case "$libs " in 605006f32fbeSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6051ea133fd7Smrg esac 6052ea133fd7Smrg fi 605306f32fbeSmrg func_append libs " $deplib" 6054ea133fd7Smrg done 6055ea133fd7Smrg 6056ea133fd7Smrg if test "$linkmode" = lib; then 6057ea133fd7Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 6058ea133fd7Smrg 6059ea133fd7Smrg # Compute libraries that are listed more than once in $predeps 6060ea133fd7Smrg # $postdeps and mark them as special (i.e., whose duplicates are 6061ea133fd7Smrg # not to be eliminated). 6062ea133fd7Smrg pre_post_deps= 6063ea133fd7Smrg if $opt_duplicate_compiler_generated_deps; then 6064ea133fd7Smrg for pre_post_dep in $predeps $postdeps; do 6065ea133fd7Smrg case "$pre_post_deps " in 606606f32fbeSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 6067ea133fd7Smrg esac 606806f32fbeSmrg func_append pre_post_deps " $pre_post_dep" 6069ea133fd7Smrg done 6070ea133fd7Smrg fi 6071ea133fd7Smrg pre_post_deps= 6072ea133fd7Smrg fi 6073ea133fd7Smrg 6074ea133fd7Smrg deplibs= 6075ea133fd7Smrg newdependency_libs= 6076ea133fd7Smrg newlib_search_path= 6077ea133fd7Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 6078ea133fd7Smrg notinst_deplibs= # not-installed libtool libraries 6079ea133fd7Smrg notinst_path= # paths that contain not-installed libtool libraries 6080ea133fd7Smrg 6081ea133fd7Smrg case $linkmode in 6082ea133fd7Smrg lib) 6083ea133fd7Smrg passes="conv dlpreopen link" 6084ea133fd7Smrg for file in $dlfiles $dlprefiles; do 6085ea133fd7Smrg case $file in 6086ea133fd7Smrg *.la) ;; 6087ea133fd7Smrg *) 6088ea133fd7Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 6089ea133fd7Smrg ;; 6090ea133fd7Smrg esac 6091ea133fd7Smrg done 6092ea133fd7Smrg ;; 6093ea133fd7Smrg prog) 6094ea133fd7Smrg compile_deplibs= 6095ea133fd7Smrg finalize_deplibs= 6096ea133fd7Smrg alldeplibs=no 6097ea133fd7Smrg newdlfiles= 6098ea133fd7Smrg newdlprefiles= 6099ea133fd7Smrg passes="conv scan dlopen dlpreopen link" 6100ea133fd7Smrg ;; 6101ea133fd7Smrg *) passes="conv" 6102ea133fd7Smrg ;; 6103ea133fd7Smrg esac 6104ea133fd7Smrg 6105ea133fd7Smrg for pass in $passes; do 6106ea133fd7Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 6107ea133fd7Smrg # so that -L comes before libs that need it for instance... 6108ea133fd7Smrg if test "$linkmode,$pass" = "lib,link"; then 6109ea133fd7Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 6110ea133fd7Smrg ## order, and fix it there properly 6111ea133fd7Smrg tmp_deplibs= 6112ea133fd7Smrg for deplib in $deplibs; do 6113ea133fd7Smrg tmp_deplibs="$deplib $tmp_deplibs" 6114ea133fd7Smrg done 6115ea133fd7Smrg deplibs="$tmp_deplibs" 6116ea133fd7Smrg fi 6117ea133fd7Smrg 6118ea133fd7Smrg if test "$linkmode,$pass" = "lib,link" || 6119ea133fd7Smrg test "$linkmode,$pass" = "prog,scan"; then 6120ea133fd7Smrg libs="$deplibs" 6121ea133fd7Smrg deplibs= 6122ea133fd7Smrg fi 6123ea133fd7Smrg if test "$linkmode" = prog; then 6124ea133fd7Smrg case $pass in 6125ea133fd7Smrg dlopen) libs="$dlfiles" ;; 6126ea133fd7Smrg dlpreopen) libs="$dlprefiles" ;; 6127ea133fd7Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 6128ea133fd7Smrg esac 6129ea133fd7Smrg fi 6130ea133fd7Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 6131ea133fd7Smrg # Collect and forward deplibs of preopened libtool libs 6132ea133fd7Smrg for lib in $dlprefiles; do 6133ea133fd7Smrg # Ignore non-libtool-libs 6134ea133fd7Smrg dependency_libs= 613506f32fbeSmrg func_resolve_sysroot "$lib" 6136ea133fd7Smrg case $lib in 613706f32fbeSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 6138ea133fd7Smrg esac 6139ea133fd7Smrg 6140ea133fd7Smrg # Collect preopened libtool deplibs, except any this library 6141ea133fd7Smrg # has declared as weak libs 6142ea133fd7Smrg for deplib in $dependency_libs; do 614325b89263Smrg func_basename "$deplib" 614425b89263Smrg deplib_base=$func_basename_result 6145ea133fd7Smrg case " $weak_libs " in 6146ea133fd7Smrg *" $deplib_base "*) ;; 614706f32fbeSmrg *) func_append deplibs " $deplib" ;; 6148ea133fd7Smrg esac 6149ea133fd7Smrg done 6150ea133fd7Smrg done 6151ea133fd7Smrg libs="$dlprefiles" 6152ea133fd7Smrg fi 6153ea133fd7Smrg if test "$pass" = dlopen; then 6154ea133fd7Smrg # Collect dlpreopened libraries 6155ea133fd7Smrg save_deplibs="$deplibs" 6156ea133fd7Smrg deplibs= 6157ea133fd7Smrg fi 6158ea133fd7Smrg 6159ea133fd7Smrg for deplib in $libs; do 6160ea133fd7Smrg lib= 6161ea133fd7Smrg found=no 6162ea133fd7Smrg case $deplib in 616357ee1794Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 616457ee1794Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 6165ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 6166ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6167ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6168ea133fd7Smrg else 616906f32fbeSmrg func_append compiler_flags " $deplib" 6170ea133fd7Smrg if test "$linkmode" = lib ; then 6171ea133fd7Smrg case "$new_inherited_linker_flags " in 6172ea133fd7Smrg *" $deplib "*) ;; 617306f32fbeSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6174ea133fd7Smrg esac 6175ea133fd7Smrg fi 6176ea133fd7Smrg fi 6177ea133fd7Smrg continue 6178ea133fd7Smrg ;; 6179ea133fd7Smrg -l*) 6180ea133fd7Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 6181ea133fd7Smrg func_warning "\`-l' is ignored for archives/objects" 6182ea133fd7Smrg continue 6183ea133fd7Smrg fi 6184ea133fd7Smrg func_stripname '-l' '' "$deplib" 6185ea133fd7Smrg name=$func_stripname_result 6186ea133fd7Smrg if test "$linkmode" = lib; then 6187ea133fd7Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 6188ea133fd7Smrg else 6189ea133fd7Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 6190ea133fd7Smrg fi 6191ea133fd7Smrg for searchdir in $searchdirs; do 6192ea133fd7Smrg for search_ext in .la $std_shrext .so .a; do 6193ea133fd7Smrg # Search the libtool library 6194ea133fd7Smrg lib="$searchdir/lib${name}${search_ext}" 6195ea133fd7Smrg if test -f "$lib"; then 6196ea133fd7Smrg if test "$search_ext" = ".la"; then 6197ea133fd7Smrg found=yes 6198ea133fd7Smrg else 6199ea133fd7Smrg found=no 6200ea133fd7Smrg fi 6201ea133fd7Smrg break 2 6202ea133fd7Smrg fi 6203ea133fd7Smrg done 6204ea133fd7Smrg done 6205ea133fd7Smrg if test "$found" != yes; then 6206ea133fd7Smrg # deplib doesn't seem to be a libtool library 6207ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 6208ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6209ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6210ea133fd7Smrg else 6211ea133fd7Smrg deplibs="$deplib $deplibs" 6212ea133fd7Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6213ea133fd7Smrg fi 6214ea133fd7Smrg continue 6215ea133fd7Smrg else # deplib is a libtool library 6216ea133fd7Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 6217ea133fd7Smrg # We need to do some special things here, and not later. 6218ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6219ea133fd7Smrg case " $predeps $postdeps " in 6220ea133fd7Smrg *" $deplib "*) 6221ea133fd7Smrg if func_lalib_p "$lib"; then 6222ea133fd7Smrg library_names= 6223ea133fd7Smrg old_library= 6224ea133fd7Smrg func_source "$lib" 6225ea133fd7Smrg for l in $old_library $library_names; do 6226ea133fd7Smrg ll="$l" 6227ea133fd7Smrg done 6228ea133fd7Smrg if test "X$ll" = "X$old_library" ; then # only static version available 6229ea133fd7Smrg found=no 6230ea133fd7Smrg func_dirname "$lib" "" "." 6231ea133fd7Smrg ladir="$func_dirname_result" 6232ea133fd7Smrg lib=$ladir/$old_library 6233ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 6234ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6235ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6236ea133fd7Smrg else 6237ea133fd7Smrg deplibs="$deplib $deplibs" 6238ea133fd7Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6239ea133fd7Smrg fi 6240ea133fd7Smrg continue 6241ea133fd7Smrg fi 6242ea133fd7Smrg fi 6243ea133fd7Smrg ;; 6244ea133fd7Smrg *) ;; 6245ea133fd7Smrg esac 6246ea133fd7Smrg fi 6247ea133fd7Smrg fi 6248ea133fd7Smrg ;; # -l 6249ea133fd7Smrg *.ltframework) 6250ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 6251ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6252ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6253ea133fd7Smrg else 6254ea133fd7Smrg deplibs="$deplib $deplibs" 6255ea133fd7Smrg if test "$linkmode" = lib ; then 6256ea133fd7Smrg case "$new_inherited_linker_flags " in 6257ea133fd7Smrg *" $deplib "*) ;; 625806f32fbeSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6259ea133fd7Smrg esac 6260ea133fd7Smrg fi 6261ea133fd7Smrg fi 6262ea133fd7Smrg continue 6263ea133fd7Smrg ;; 6264ea133fd7Smrg -L*) 6265ea133fd7Smrg case $linkmode in 6266ea133fd7Smrg lib) 6267ea133fd7Smrg deplibs="$deplib $deplibs" 6268ea133fd7Smrg test "$pass" = conv && continue 6269ea133fd7Smrg newdependency_libs="$deplib $newdependency_libs" 6270ea133fd7Smrg func_stripname '-L' '' "$deplib" 627106f32fbeSmrg func_resolve_sysroot "$func_stripname_result" 627206f32fbeSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 6273ea133fd7Smrg ;; 6274ea133fd7Smrg prog) 6275ea133fd7Smrg if test "$pass" = conv; then 6276ea133fd7Smrg deplibs="$deplib $deplibs" 6277ea133fd7Smrg continue 6278ea133fd7Smrg fi 6279ea133fd7Smrg if test "$pass" = scan; then 6280ea133fd7Smrg deplibs="$deplib $deplibs" 6281ea133fd7Smrg else 6282ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6283ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6284ea133fd7Smrg fi 6285ea133fd7Smrg func_stripname '-L' '' "$deplib" 628606f32fbeSmrg func_resolve_sysroot "$func_stripname_result" 628706f32fbeSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 6288ea133fd7Smrg ;; 6289ea133fd7Smrg *) 6290ea133fd7Smrg func_warning "\`-L' is ignored for archives/objects" 6291ea133fd7Smrg ;; 6292ea133fd7Smrg esac # linkmode 6293ea133fd7Smrg continue 6294ea133fd7Smrg ;; # -L 6295ea133fd7Smrg -R*) 6296ea133fd7Smrg if test "$pass" = link; then 6297ea133fd7Smrg func_stripname '-R' '' "$deplib" 629806f32fbeSmrg func_resolve_sysroot "$func_stripname_result" 629906f32fbeSmrg dir=$func_resolve_sysroot_result 6300ea133fd7Smrg # Make sure the xrpath contains only unique directories. 6301ea133fd7Smrg case "$xrpath " in 6302ea133fd7Smrg *" $dir "*) ;; 630306f32fbeSmrg *) func_append xrpath " $dir" ;; 6304ea133fd7Smrg esac 6305ea133fd7Smrg fi 6306ea133fd7Smrg deplibs="$deplib $deplibs" 6307ea133fd7Smrg continue 6308ea133fd7Smrg ;; 630906f32fbeSmrg *.la) 631006f32fbeSmrg func_resolve_sysroot "$deplib" 631106f32fbeSmrg lib=$func_resolve_sysroot_result 631206f32fbeSmrg ;; 6313ea133fd7Smrg *.$libext) 6314ea133fd7Smrg if test "$pass" = conv; then 6315ea133fd7Smrg deplibs="$deplib $deplibs" 6316ea133fd7Smrg continue 6317ea133fd7Smrg fi 6318ea133fd7Smrg case $linkmode in 6319ea133fd7Smrg lib) 6320ea133fd7Smrg # Linking convenience modules into shared libraries is allowed, 6321ea133fd7Smrg # but linking other static libraries is non-portable. 6322ea133fd7Smrg case " $dlpreconveniencelibs " in 6323ea133fd7Smrg *" $deplib "*) ;; 6324ea133fd7Smrg *) 6325ea133fd7Smrg valid_a_lib=no 6326ea133fd7Smrg case $deplibs_check_method in 6327ea133fd7Smrg match_pattern*) 6328ea133fd7Smrg set dummy $deplibs_check_method; shift 6329ea133fd7Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 633025b89263Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 6331ea133fd7Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 6332ea133fd7Smrg valid_a_lib=yes 6333ea133fd7Smrg fi 6334ea133fd7Smrg ;; 6335ea133fd7Smrg pass_all) 6336ea133fd7Smrg valid_a_lib=yes 6337ea133fd7Smrg ;; 6338ea133fd7Smrg esac 6339ea133fd7Smrg if test "$valid_a_lib" != yes; then 634025b89263Smrg echo 6341ea133fd7Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 634225b89263Smrg echo "*** I have the capability to make that library automatically link in when" 634325b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 634425b89263Smrg echo "*** shared version of the library, which you do not appear to have" 634525b89263Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 634625b89263Smrg echo "*** that it is just a static archive that I should not use here." 6347ea133fd7Smrg else 634825b89263Smrg echo 6349ea133fd7Smrg $ECHO "*** Warning: Linking the shared library $output against the" 6350ea133fd7Smrg $ECHO "*** static library $deplib is not portable!" 6351ea133fd7Smrg deplibs="$deplib $deplibs" 6352ea133fd7Smrg fi 6353ea133fd7Smrg ;; 6354ea133fd7Smrg esac 6355ea133fd7Smrg continue 6356ea133fd7Smrg ;; 6357ea133fd7Smrg prog) 6358ea133fd7Smrg if test "$pass" != link; then 6359ea133fd7Smrg deplibs="$deplib $deplibs" 6360ea133fd7Smrg else 6361ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6362ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6363ea133fd7Smrg fi 6364ea133fd7Smrg continue 6365ea133fd7Smrg ;; 6366ea133fd7Smrg esac # linkmode 6367ea133fd7Smrg ;; # *.$libext 6368ea133fd7Smrg *.lo | *.$objext) 6369ea133fd7Smrg if test "$pass" = conv; then 6370ea133fd7Smrg deplibs="$deplib $deplibs" 6371ea133fd7Smrg elif test "$linkmode" = prog; then 6372ea133fd7Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 6373ea133fd7Smrg # If there is no dlopen support or we're linking statically, 6374ea133fd7Smrg # we need to preload. 637506f32fbeSmrg func_append newdlprefiles " $deplib" 6376ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 6377ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 6378ea133fd7Smrg else 637906f32fbeSmrg func_append newdlfiles " $deplib" 6380ea133fd7Smrg fi 6381ea133fd7Smrg fi 6382ea133fd7Smrg continue 6383ea133fd7Smrg ;; 6384ea133fd7Smrg %DEPLIBS%) 6385ea133fd7Smrg alldeplibs=yes 6386ea133fd7Smrg continue 6387ea133fd7Smrg ;; 6388ea133fd7Smrg esac # case $deplib 6389ea133fd7Smrg 6390ea133fd7Smrg if test "$found" = yes || test -f "$lib"; then : 6391ea133fd7Smrg else 6392ea133fd7Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 6393ea133fd7Smrg fi 6394ea133fd7Smrg 6395ea133fd7Smrg # Check to see that this really is a libtool archive. 6396ea133fd7Smrg func_lalib_unsafe_p "$lib" \ 6397ea133fd7Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 6398ea133fd7Smrg 6399ea133fd7Smrg func_dirname "$lib" "" "." 6400ea133fd7Smrg ladir="$func_dirname_result" 6401ea133fd7Smrg 6402ea133fd7Smrg dlname= 6403ea133fd7Smrg dlopen= 6404ea133fd7Smrg dlpreopen= 6405ea133fd7Smrg libdir= 6406ea133fd7Smrg library_names= 6407ea133fd7Smrg old_library= 6408ea133fd7Smrg inherited_linker_flags= 6409ea133fd7Smrg # If the library was installed with an old release of libtool, 6410ea133fd7Smrg # it will not redefine variables installed, or shouldnotlink 6411ea133fd7Smrg installed=yes 6412ea133fd7Smrg shouldnotlink=no 6413ea133fd7Smrg avoidtemprpath= 6414ea133fd7Smrg 6415ea133fd7Smrg 6416ea133fd7Smrg # Read the .la file 6417ea133fd7Smrg func_source "$lib" 6418ea133fd7Smrg 6419ea133fd7Smrg # Convert "-framework foo" to "foo.ltframework" 6420ea133fd7Smrg if test -n "$inherited_linker_flags"; then 642125b89263Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 6422ea133fd7Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 6423ea133fd7Smrg case " $new_inherited_linker_flags " in 6424ea133fd7Smrg *" $tmp_inherited_linker_flag "*) ;; 642506f32fbeSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 6426ea133fd7Smrg esac 6427ea133fd7Smrg done 6428ea133fd7Smrg fi 642925b89263Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 6430ea133fd7Smrg if test "$linkmode,$pass" = "lib,link" || 6431ea133fd7Smrg test "$linkmode,$pass" = "prog,scan" || 6432ea133fd7Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 643306f32fbeSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 643406f32fbeSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 6435ea133fd7Smrg fi 6436ea133fd7Smrg 6437ea133fd7Smrg if test "$pass" = conv; then 6438ea133fd7Smrg # Only check for convenience libraries 6439ea133fd7Smrg deplibs="$lib $deplibs" 6440ea133fd7Smrg if test -z "$libdir"; then 6441ea133fd7Smrg if test -z "$old_library"; then 6442ea133fd7Smrg func_fatal_error "cannot find name of link library for \`$lib'" 6443ea133fd7Smrg fi 6444ea133fd7Smrg # It is a libtool convenience library, so add in its objects. 644506f32fbeSmrg func_append convenience " $ladir/$objdir/$old_library" 644606f32fbeSmrg func_append old_convenience " $ladir/$objdir/$old_library" 6447ea133fd7Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 6448ea133fd7Smrg func_fatal_error "\`$lib' is not a convenience library" 6449ea133fd7Smrg fi 6450ea133fd7Smrg tmp_libs= 6451ea133fd7Smrg for deplib in $dependency_libs; do 6452ea133fd7Smrg deplibs="$deplib $deplibs" 645306f32fbeSmrg if $opt_preserve_dup_deps ; then 6454ea133fd7Smrg case "$tmp_libs " in 645506f32fbeSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6456ea133fd7Smrg esac 6457ea133fd7Smrg fi 645806f32fbeSmrg func_append tmp_libs " $deplib" 6459ea133fd7Smrg done 6460ea133fd7Smrg continue 6461ea133fd7Smrg fi # $pass = conv 6462ea133fd7Smrg 6463ea133fd7Smrg 6464ea133fd7Smrg # Get the name of the library we link against. 6465ea133fd7Smrg linklib= 646606f32fbeSmrg if test -n "$old_library" && 646706f32fbeSmrg { test "$prefer_static_libs" = yes || 646806f32fbeSmrg test "$prefer_static_libs,$installed" = "built,no"; }; then 646906f32fbeSmrg linklib=$old_library 647006f32fbeSmrg else 647106f32fbeSmrg for l in $old_library $library_names; do 647206f32fbeSmrg linklib="$l" 647306f32fbeSmrg done 647406f32fbeSmrg fi 6475ea133fd7Smrg if test -z "$linklib"; then 6476ea133fd7Smrg func_fatal_error "cannot find name of link library for \`$lib'" 6477ea133fd7Smrg fi 6478ea133fd7Smrg 6479ea133fd7Smrg # This library was specified with -dlopen. 6480ea133fd7Smrg if test "$pass" = dlopen; then 6481ea133fd7Smrg if test -z "$libdir"; then 6482ea133fd7Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 6483ea133fd7Smrg fi 6484ea133fd7Smrg if test -z "$dlname" || 6485ea133fd7Smrg test "$dlopen_support" != yes || 6486ea133fd7Smrg test "$build_libtool_libs" = no; then 6487ea133fd7Smrg # If there is no dlname, no dlopen support or we're linking 6488ea133fd7Smrg # statically, we need to preload. We also need to preload any 6489ea133fd7Smrg # dependent libraries so libltdl's deplib preloader doesn't 6490ea133fd7Smrg # bomb out in the load deplibs phase. 649106f32fbeSmrg func_append dlprefiles " $lib $dependency_libs" 6492ea133fd7Smrg else 649306f32fbeSmrg func_append newdlfiles " $lib" 6494ea133fd7Smrg fi 6495ea133fd7Smrg continue 6496ea133fd7Smrg fi # $pass = dlopen 6497ea133fd7Smrg 6498ea133fd7Smrg # We need an absolute path. 6499ea133fd7Smrg case $ladir in 6500ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 6501ea133fd7Smrg *) 6502ea133fd7Smrg abs_ladir=`cd "$ladir" && pwd` 6503ea133fd7Smrg if test -z "$abs_ladir"; then 6504ea133fd7Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 6505ea133fd7Smrg func_warning "passing it literally to the linker, although it might fail" 6506ea133fd7Smrg abs_ladir="$ladir" 6507ea133fd7Smrg fi 6508ea133fd7Smrg ;; 6509ea133fd7Smrg esac 6510ea133fd7Smrg func_basename "$lib" 6511ea133fd7Smrg laname="$func_basename_result" 6512ea133fd7Smrg 6513ea133fd7Smrg # Find the relevant object directory and library name. 6514ea133fd7Smrg if test "X$installed" = Xyes; then 651506f32fbeSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6516ea133fd7Smrg func_warning "library \`$lib' was moved." 6517ea133fd7Smrg dir="$ladir" 6518ea133fd7Smrg absdir="$abs_ladir" 6519ea133fd7Smrg libdir="$abs_ladir" 6520ea133fd7Smrg else 652106f32fbeSmrg dir="$lt_sysroot$libdir" 652206f32fbeSmrg absdir="$lt_sysroot$libdir" 6523ea133fd7Smrg fi 6524ea133fd7Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 6525ea133fd7Smrg else 6526ea133fd7Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6527ea133fd7Smrg dir="$ladir" 6528ea133fd7Smrg absdir="$abs_ladir" 6529ea133fd7Smrg # Remove this search path later 653006f32fbeSmrg func_append notinst_path " $abs_ladir" 6531ea133fd7Smrg else 6532ea133fd7Smrg dir="$ladir/$objdir" 6533ea133fd7Smrg absdir="$abs_ladir/$objdir" 6534ea133fd7Smrg # Remove this search path later 653506f32fbeSmrg func_append notinst_path " $abs_ladir" 6536ea133fd7Smrg fi 6537ea133fd7Smrg fi # $installed = yes 6538ea133fd7Smrg func_stripname 'lib' '.la' "$laname" 6539ea133fd7Smrg name=$func_stripname_result 6540ea133fd7Smrg 6541ea133fd7Smrg # This library was specified with -dlpreopen. 6542ea133fd7Smrg if test "$pass" = dlpreopen; then 6543ea133fd7Smrg if test -z "$libdir" && test "$linkmode" = prog; then 6544ea133fd7Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 6545ea133fd7Smrg fi 654606f32fbeSmrg case "$host" in 654706f32fbeSmrg # special handling for platforms with PE-DLLs. 654806f32fbeSmrg *cygwin* | *mingw* | *cegcc* ) 654906f32fbeSmrg # Linker will automatically link against shared library if both 655006f32fbeSmrg # static and shared are present. Therefore, ensure we extract 655106f32fbeSmrg # symbols from the import library if a shared library is present 655206f32fbeSmrg # (otherwise, the dlopen module name will be incorrect). We do 655306f32fbeSmrg # this by putting the import library name into $newdlprefiles. 655406f32fbeSmrg # We recover the dlopen module name by 'saving' the la file 655506f32fbeSmrg # name in a special purpose variable, and (later) extracting the 655606f32fbeSmrg # dlname from the la file. 655706f32fbeSmrg if test -n "$dlname"; then 655806f32fbeSmrg func_tr_sh "$dir/$linklib" 655906f32fbeSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 656006f32fbeSmrg func_append newdlprefiles " $dir/$linklib" 656106f32fbeSmrg else 656206f32fbeSmrg func_append newdlprefiles " $dir/$old_library" 656306f32fbeSmrg # Keep a list of preopened convenience libraries to check 656406f32fbeSmrg # that they are being used correctly in the link pass. 656506f32fbeSmrg test -z "$libdir" && \ 656606f32fbeSmrg func_append dlpreconveniencelibs " $dir/$old_library" 656706f32fbeSmrg fi 656806f32fbeSmrg ;; 656906f32fbeSmrg * ) 657006f32fbeSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 657106f32fbeSmrg # are required to link). 657206f32fbeSmrg if test -n "$old_library"; then 657306f32fbeSmrg func_append newdlprefiles " $dir/$old_library" 657406f32fbeSmrg # Keep a list of preopened convenience libraries to check 657506f32fbeSmrg # that they are being used correctly in the link pass. 657606f32fbeSmrg test -z "$libdir" && \ 657706f32fbeSmrg func_append dlpreconveniencelibs " $dir/$old_library" 657806f32fbeSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 657906f32fbeSmrg elif test -n "$dlname"; then 658006f32fbeSmrg func_append newdlprefiles " $dir/$dlname" 658106f32fbeSmrg else 658206f32fbeSmrg func_append newdlprefiles " $dir/$linklib" 658306f32fbeSmrg fi 658406f32fbeSmrg ;; 658506f32fbeSmrg esac 6586ea133fd7Smrg fi # $pass = dlpreopen 6587ea133fd7Smrg 6588ea133fd7Smrg if test -z "$libdir"; then 6589ea133fd7Smrg # Link the convenience library 6590ea133fd7Smrg if test "$linkmode" = lib; then 6591ea133fd7Smrg deplibs="$dir/$old_library $deplibs" 6592ea133fd7Smrg elif test "$linkmode,$pass" = "prog,link"; then 6593ea133fd7Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 6594ea133fd7Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 6595ea133fd7Smrg else 6596ea133fd7Smrg deplibs="$lib $deplibs" # used for prog,scan pass 6597ea133fd7Smrg fi 6598ea133fd7Smrg continue 6599ea133fd7Smrg fi 6600ea133fd7Smrg 6601ea133fd7Smrg 6602ea133fd7Smrg if test "$linkmode" = prog && test "$pass" != link; then 660306f32fbeSmrg func_append newlib_search_path " $ladir" 6604ea133fd7Smrg deplibs="$lib $deplibs" 6605ea133fd7Smrg 6606ea133fd7Smrg linkalldeplibs=no 6607ea133fd7Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 6608ea133fd7Smrg test "$build_libtool_libs" = no; then 6609ea133fd7Smrg linkalldeplibs=yes 6610ea133fd7Smrg fi 6611ea133fd7Smrg 6612ea133fd7Smrg tmp_libs= 6613ea133fd7Smrg for deplib in $dependency_libs; do 6614ea133fd7Smrg case $deplib in 6615ea133fd7Smrg -L*) func_stripname '-L' '' "$deplib" 661606f32fbeSmrg func_resolve_sysroot "$func_stripname_result" 661706f32fbeSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 6618ea133fd7Smrg ;; 6619ea133fd7Smrg esac 6620ea133fd7Smrg # Need to link against all dependency_libs? 6621ea133fd7Smrg if test "$linkalldeplibs" = yes; then 6622ea133fd7Smrg deplibs="$deplib $deplibs" 6623ea133fd7Smrg else 6624ea133fd7Smrg # Need to hardcode shared library paths 6625ea133fd7Smrg # or/and link against static libraries 6626ea133fd7Smrg newdependency_libs="$deplib $newdependency_libs" 6627ea133fd7Smrg fi 662806f32fbeSmrg if $opt_preserve_dup_deps ; then 6629ea133fd7Smrg case "$tmp_libs " in 663006f32fbeSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6631ea133fd7Smrg esac 6632ea133fd7Smrg fi 663306f32fbeSmrg func_append tmp_libs " $deplib" 6634ea133fd7Smrg done # for deplib 6635ea133fd7Smrg continue 6636ea133fd7Smrg fi # $linkmode = prog... 6637ea133fd7Smrg 6638ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 6639ea133fd7Smrg if test -n "$library_names" && 6640ea133fd7Smrg { { test "$prefer_static_libs" = no || 6641ea133fd7Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 6642ea133fd7Smrg test -z "$old_library"; }; then 6643ea133fd7Smrg # We need to hardcode the library path 6644ea133fd7Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 6645ea133fd7Smrg # Make sure the rpath contains only unique directories. 6646ea133fd7Smrg case "$temp_rpath:" in 6647ea133fd7Smrg *"$absdir:"*) ;; 664806f32fbeSmrg *) func_append temp_rpath "$absdir:" ;; 6649ea133fd7Smrg esac 6650ea133fd7Smrg fi 6651ea133fd7Smrg 6652ea133fd7Smrg # Hardcode the library path. 6653ea133fd7Smrg # Skip directories that are in the system default run-time 6654ea133fd7Smrg # search path. 6655ea133fd7Smrg case " $sys_lib_dlsearch_path " in 6656ea133fd7Smrg *" $absdir "*) ;; 6657ea133fd7Smrg *) 6658ea133fd7Smrg case "$compile_rpath " in 6659ea133fd7Smrg *" $absdir "*) ;; 666006f32fbeSmrg *) func_append compile_rpath " $absdir" ;; 6661ea133fd7Smrg esac 6662ea133fd7Smrg ;; 6663ea133fd7Smrg esac 6664ea133fd7Smrg case " $sys_lib_dlsearch_path " in 6665ea133fd7Smrg *" $libdir "*) ;; 6666ea133fd7Smrg *) 6667ea133fd7Smrg case "$finalize_rpath " in 6668ea133fd7Smrg *" $libdir "*) ;; 666906f32fbeSmrg *) func_append finalize_rpath " $libdir" ;; 6670ea133fd7Smrg esac 6671ea133fd7Smrg ;; 6672ea133fd7Smrg esac 6673ea133fd7Smrg fi # $linkmode,$pass = prog,link... 6674ea133fd7Smrg 6675ea133fd7Smrg if test "$alldeplibs" = yes && 6676ea133fd7Smrg { test "$deplibs_check_method" = pass_all || 6677ea133fd7Smrg { test "$build_libtool_libs" = yes && 6678ea133fd7Smrg test -n "$library_names"; }; }; then 6679ea133fd7Smrg # We only need to search for static libraries 6680ea133fd7Smrg continue 6681ea133fd7Smrg fi 6682ea133fd7Smrg fi 6683ea133fd7Smrg 6684ea133fd7Smrg link_static=no # Whether the deplib will be linked statically 6685ea133fd7Smrg use_static_libs=$prefer_static_libs 6686ea133fd7Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 6687ea133fd7Smrg use_static_libs=no 6688ea133fd7Smrg fi 6689ea133fd7Smrg if test -n "$library_names" && 6690ea133fd7Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 6691ea133fd7Smrg case $host in 6692ea133fd7Smrg *cygwin* | *mingw* | *cegcc*) 6693ea133fd7Smrg # No point in relinking DLLs because paths are not encoded 669406f32fbeSmrg func_append notinst_deplibs " $lib" 6695ea133fd7Smrg need_relink=no 6696ea133fd7Smrg ;; 6697ea133fd7Smrg *) 6698ea133fd7Smrg if test "$installed" = no; then 669906f32fbeSmrg func_append notinst_deplibs " $lib" 6700ea133fd7Smrg need_relink=yes 6701ea133fd7Smrg fi 6702ea133fd7Smrg ;; 6703ea133fd7Smrg esac 6704ea133fd7Smrg # This is a shared library 6705ea133fd7Smrg 6706ea133fd7Smrg # Warn about portability, can't link against -module's on some 6707ea133fd7Smrg # systems (darwin). Don't bleat about dlopened modules though! 6708ea133fd7Smrg dlopenmodule="" 6709ea133fd7Smrg for dlpremoduletest in $dlprefiles; do 6710ea133fd7Smrg if test "X$dlpremoduletest" = "X$lib"; then 6711ea133fd7Smrg dlopenmodule="$dlpremoduletest" 6712ea133fd7Smrg break 6713ea133fd7Smrg fi 6714ea133fd7Smrg done 6715ea133fd7Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 671625b89263Smrg echo 6717ea133fd7Smrg if test "$linkmode" = prog; then 6718ea133fd7Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 6719ea133fd7Smrg else 6720ea133fd7Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 6721ea133fd7Smrg fi 6722ea133fd7Smrg $ECHO "*** $linklib is not portable!" 6723ea133fd7Smrg fi 6724ea133fd7Smrg if test "$linkmode" = lib && 6725ea133fd7Smrg test "$hardcode_into_libs" = yes; then 6726ea133fd7Smrg # Hardcode the library path. 6727ea133fd7Smrg # Skip directories that are in the system default run-time 6728ea133fd7Smrg # search path. 6729ea133fd7Smrg case " $sys_lib_dlsearch_path " in 6730ea133fd7Smrg *" $absdir "*) ;; 6731ea133fd7Smrg *) 6732ea133fd7Smrg case "$compile_rpath " in 6733ea133fd7Smrg *" $absdir "*) ;; 673406f32fbeSmrg *) func_append compile_rpath " $absdir" ;; 6735ea133fd7Smrg esac 6736ea133fd7Smrg ;; 6737ea133fd7Smrg esac 6738ea133fd7Smrg case " $sys_lib_dlsearch_path " in 6739ea133fd7Smrg *" $libdir "*) ;; 6740ea133fd7Smrg *) 6741ea133fd7Smrg case "$finalize_rpath " in 6742ea133fd7Smrg *" $libdir "*) ;; 674306f32fbeSmrg *) func_append finalize_rpath " $libdir" ;; 6744ea133fd7Smrg esac 6745ea133fd7Smrg ;; 6746ea133fd7Smrg esac 6747ea133fd7Smrg fi 6748ea133fd7Smrg 6749ea133fd7Smrg if test -n "$old_archive_from_expsyms_cmds"; then 6750ea133fd7Smrg # figure out the soname 6751ea133fd7Smrg set dummy $library_names 6752ea133fd7Smrg shift 6753ea133fd7Smrg realname="$1" 6754ea133fd7Smrg shift 6755ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 6756ea133fd7Smrg # use dlname if we got it. it's perfectly good, no? 6757ea133fd7Smrg if test -n "$dlname"; then 6758ea133fd7Smrg soname="$dlname" 6759ea133fd7Smrg elif test -n "$soname_spec"; then 6760ea133fd7Smrg # bleh windows 6761ea133fd7Smrg case $host in 6762ea133fd7Smrg *cygwin* | mingw* | *cegcc*) 6763ea133fd7Smrg func_arith $current - $age 6764ea133fd7Smrg major=$func_arith_result 6765ea133fd7Smrg versuffix="-$major" 6766ea133fd7Smrg ;; 6767ea133fd7Smrg esac 6768ea133fd7Smrg eval soname=\"$soname_spec\" 6769ea133fd7Smrg else 6770ea133fd7Smrg soname="$realname" 6771ea133fd7Smrg fi 6772ea133fd7Smrg 6773ea133fd7Smrg # Make a new name for the extract_expsyms_cmds to use 6774ea133fd7Smrg soroot="$soname" 6775ea133fd7Smrg func_basename "$soroot" 6776ea133fd7Smrg soname="$func_basename_result" 6777ea133fd7Smrg func_stripname 'lib' '.dll' "$soname" 6778ea133fd7Smrg newlib=libimp-$func_stripname_result.a 6779ea133fd7Smrg 6780ea133fd7Smrg # If the library has no export list, then create one now 6781ea133fd7Smrg if test -f "$output_objdir/$soname-def"; then : 6782ea133fd7Smrg else 6783ea133fd7Smrg func_verbose "extracting exported symbol list from \`$soname'" 6784ea133fd7Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 6785ea133fd7Smrg fi 6786ea133fd7Smrg 6787ea133fd7Smrg # Create $newlib 6788ea133fd7Smrg if test -f "$output_objdir/$newlib"; then :; else 6789ea133fd7Smrg func_verbose "generating import library for \`$soname'" 6790ea133fd7Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 6791ea133fd7Smrg fi 6792ea133fd7Smrg # make sure the library variables are pointing to the new library 6793ea133fd7Smrg dir=$output_objdir 6794ea133fd7Smrg linklib=$newlib 6795ea133fd7Smrg fi # test -n "$old_archive_from_expsyms_cmds" 6796ea133fd7Smrg 679706f32fbeSmrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 6798ea133fd7Smrg add_shlibpath= 6799ea133fd7Smrg add_dir= 6800ea133fd7Smrg add= 6801ea133fd7Smrg lib_linked=yes 6802ea133fd7Smrg case $hardcode_action in 6803ea133fd7Smrg immediate | unsupported) 6804ea133fd7Smrg if test "$hardcode_direct" = no; then 6805ea133fd7Smrg add="$dir/$linklib" 6806ea133fd7Smrg case $host in 6807ea133fd7Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6808ea133fd7Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 6809ea133fd7Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6810ea133fd7Smrg *-*-unixware7*) add_dir="-L$dir" ;; 6811ea133fd7Smrg *-*-darwin* ) 6812ea133fd7Smrg # if the lib is a (non-dlopened) module then we can not 6813ea133fd7Smrg # link against it, someone is ignoring the earlier warnings 6814ea133fd7Smrg if /usr/bin/file -L $add 2> /dev/null | 6815ea133fd7Smrg $GREP ": [^:]* bundle" >/dev/null ; then 6816ea133fd7Smrg if test "X$dlopenmodule" != "X$lib"; then 6817ea133fd7Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6818ea133fd7Smrg if test -z "$old_library" ; then 681925b89263Smrg echo 682025b89263Smrg echo "*** And there doesn't seem to be a static archive available" 682125b89263Smrg echo "*** The link will probably fail, sorry" 6822ea133fd7Smrg else 6823ea133fd7Smrg add="$dir/$old_library" 6824ea133fd7Smrg fi 6825ea133fd7Smrg elif test -n "$old_library"; then 6826ea133fd7Smrg add="$dir/$old_library" 6827ea133fd7Smrg fi 6828ea133fd7Smrg fi 6829ea133fd7Smrg esac 6830ea133fd7Smrg elif test "$hardcode_minus_L" = no; then 6831ea133fd7Smrg case $host in 6832ea133fd7Smrg *-*-sunos*) add_shlibpath="$dir" ;; 6833ea133fd7Smrg esac 6834ea133fd7Smrg add_dir="-L$dir" 6835ea133fd7Smrg add="-l$name" 6836ea133fd7Smrg elif test "$hardcode_shlibpath_var" = no; then 6837ea133fd7Smrg add_shlibpath="$dir" 6838ea133fd7Smrg add="-l$name" 6839ea133fd7Smrg else 6840ea133fd7Smrg lib_linked=no 6841ea133fd7Smrg fi 6842ea133fd7Smrg ;; 6843ea133fd7Smrg relink) 6844ea133fd7Smrg if test "$hardcode_direct" = yes && 6845ea133fd7Smrg test "$hardcode_direct_absolute" = no; then 6846ea133fd7Smrg add="$dir/$linklib" 6847ea133fd7Smrg elif test "$hardcode_minus_L" = yes; then 684857ee1794Smrg add_dir="-L$absdir" 6849ea133fd7Smrg # Try looking first in the location we're being installed to. 6850ea133fd7Smrg if test -n "$inst_prefix_dir"; then 6851ea133fd7Smrg case $libdir in 6852ea133fd7Smrg [\\/]*) 685306f32fbeSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 6854ea133fd7Smrg ;; 6855ea133fd7Smrg esac 6856ea133fd7Smrg fi 6857ea133fd7Smrg add="-l$name" 6858ea133fd7Smrg elif test "$hardcode_shlibpath_var" = yes; then 6859ea133fd7Smrg add_shlibpath="$dir" 6860ea133fd7Smrg add="-l$name" 6861ea133fd7Smrg else 6862ea133fd7Smrg lib_linked=no 6863ea133fd7Smrg fi 6864ea133fd7Smrg ;; 6865ea133fd7Smrg *) lib_linked=no ;; 6866ea133fd7Smrg esac 6867ea133fd7Smrg 6868ea133fd7Smrg if test "$lib_linked" != yes; then 6869ea133fd7Smrg func_fatal_configuration "unsupported hardcode properties" 6870ea133fd7Smrg fi 6871ea133fd7Smrg 6872ea133fd7Smrg if test -n "$add_shlibpath"; then 6873ea133fd7Smrg case :$compile_shlibpath: in 6874ea133fd7Smrg *":$add_shlibpath:"*) ;; 687506f32fbeSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 6876ea133fd7Smrg esac 6877ea133fd7Smrg fi 6878ea133fd7Smrg if test "$linkmode" = prog; then 6879ea133fd7Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 6880ea133fd7Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 6881ea133fd7Smrg else 6882ea133fd7Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6883ea133fd7Smrg test -n "$add" && deplibs="$add $deplibs" 6884ea133fd7Smrg if test "$hardcode_direct" != yes && 6885ea133fd7Smrg test "$hardcode_minus_L" != yes && 6886ea133fd7Smrg test "$hardcode_shlibpath_var" = yes; then 6887ea133fd7Smrg case :$finalize_shlibpath: in 6888ea133fd7Smrg *":$libdir:"*) ;; 688906f32fbeSmrg *) func_append finalize_shlibpath "$libdir:" ;; 6890ea133fd7Smrg esac 6891ea133fd7Smrg fi 6892ea133fd7Smrg fi 6893ea133fd7Smrg fi 6894ea133fd7Smrg 689506f32fbeSmrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 6896ea133fd7Smrg add_shlibpath= 6897ea133fd7Smrg add_dir= 6898ea133fd7Smrg add= 6899ea133fd7Smrg # Finalize command for both is simple: just hardcode it. 6900ea133fd7Smrg if test "$hardcode_direct" = yes && 6901ea133fd7Smrg test "$hardcode_direct_absolute" = no; then 6902ea133fd7Smrg add="$libdir/$linklib" 6903ea133fd7Smrg elif test "$hardcode_minus_L" = yes; then 6904ea133fd7Smrg add_dir="-L$libdir" 6905ea133fd7Smrg add="-l$name" 6906ea133fd7Smrg elif test "$hardcode_shlibpath_var" = yes; then 6907ea133fd7Smrg case :$finalize_shlibpath: in 6908ea133fd7Smrg *":$libdir:"*) ;; 690906f32fbeSmrg *) func_append finalize_shlibpath "$libdir:" ;; 6910ea133fd7Smrg esac 6911ea133fd7Smrg add="-l$name" 6912ea133fd7Smrg elif test "$hardcode_automatic" = yes; then 6913ea133fd7Smrg if test -n "$inst_prefix_dir" && 6914ea133fd7Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 6915ea133fd7Smrg add="$inst_prefix_dir$libdir/$linklib" 6916ea133fd7Smrg else 6917ea133fd7Smrg add="$libdir/$linklib" 6918ea133fd7Smrg fi 6919ea133fd7Smrg else 6920ea133fd7Smrg # We cannot seem to hardcode it, guess we'll fake it. 6921ea133fd7Smrg add_dir="-L$libdir" 6922ea133fd7Smrg # Try looking first in the location we're being installed to. 6923ea133fd7Smrg if test -n "$inst_prefix_dir"; then 6924ea133fd7Smrg case $libdir in 6925ea133fd7Smrg [\\/]*) 692606f32fbeSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 6927ea133fd7Smrg ;; 6928ea133fd7Smrg esac 6929ea133fd7Smrg fi 6930ea133fd7Smrg add="-l$name" 6931ea133fd7Smrg fi 6932ea133fd7Smrg 6933ea133fd7Smrg if test "$linkmode" = prog; then 6934ea133fd7Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 6935ea133fd7Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 6936ea133fd7Smrg else 6937ea133fd7Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6938ea133fd7Smrg test -n "$add" && deplibs="$add $deplibs" 6939ea133fd7Smrg fi 6940ea133fd7Smrg fi 6941ea133fd7Smrg elif test "$linkmode" = prog; then 6942ea133fd7Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 6943ea133fd7Smrg # is not unsupported. This is valid on all known static and 6944ea133fd7Smrg # shared platforms. 6945ea133fd7Smrg if test "$hardcode_direct" != unsupported; then 6946ea133fd7Smrg test -n "$old_library" && linklib="$old_library" 6947ea133fd7Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 6948ea133fd7Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 6949ea133fd7Smrg else 6950ea133fd7Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 6951ea133fd7Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 6952ea133fd7Smrg fi 6953ea133fd7Smrg elif test "$build_libtool_libs" = yes; then 6954ea133fd7Smrg # Not a shared library 6955ea133fd7Smrg if test "$deplibs_check_method" != pass_all; then 6956ea133fd7Smrg # We're trying link a shared library against a static one 6957ea133fd7Smrg # but the system doesn't support it. 6958ea133fd7Smrg 6959ea133fd7Smrg # Just print a warning and add the library to dependency_libs so 6960ea133fd7Smrg # that the program can be linked against the static library. 696125b89263Smrg echo 6962ea133fd7Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 696325b89263Smrg echo "*** I have the capability to make that library automatically link in when" 696425b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 696525b89263Smrg echo "*** shared version of the library, which you do not appear to have." 6966ea133fd7Smrg if test "$module" = yes; then 696725b89263Smrg echo "*** But as you try to build a module library, libtool will still create " 696825b89263Smrg echo "*** a static module, that should work as long as the dlopening application" 696925b89263Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 6970ea133fd7Smrg if test -z "$global_symbol_pipe"; then 697125b89263Smrg echo 697225b89263Smrg echo "*** However, this would only work if libtool was able to extract symbol" 697325b89263Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 697425b89263Smrg echo "*** not find such a program. So, this module is probably useless." 697525b89263Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 6976ea133fd7Smrg fi 6977ea133fd7Smrg if test "$build_old_libs" = no; then 6978ea133fd7Smrg build_libtool_libs=module 6979ea133fd7Smrg build_old_libs=yes 6980ea133fd7Smrg else 6981ea133fd7Smrg build_libtool_libs=no 6982ea133fd7Smrg fi 6983ea133fd7Smrg fi 6984ea133fd7Smrg else 6985ea133fd7Smrg deplibs="$dir/$old_library $deplibs" 6986ea133fd7Smrg link_static=yes 6987ea133fd7Smrg fi 6988ea133fd7Smrg fi # link shared/static library? 6989ea133fd7Smrg 6990ea133fd7Smrg if test "$linkmode" = lib; then 6991ea133fd7Smrg if test -n "$dependency_libs" && 6992ea133fd7Smrg { test "$hardcode_into_libs" != yes || 6993ea133fd7Smrg test "$build_old_libs" = yes || 6994ea133fd7Smrg test "$link_static" = yes; }; then 6995ea133fd7Smrg # Extract -R from dependency_libs 6996ea133fd7Smrg temp_deplibs= 6997ea133fd7Smrg for libdir in $dependency_libs; do 6998ea133fd7Smrg case $libdir in 6999ea133fd7Smrg -R*) func_stripname '-R' '' "$libdir" 7000ea133fd7Smrg temp_xrpath=$func_stripname_result 7001ea133fd7Smrg case " $xrpath " in 7002ea133fd7Smrg *" $temp_xrpath "*) ;; 700306f32fbeSmrg *) func_append xrpath " $temp_xrpath";; 7004ea133fd7Smrg esac;; 700506f32fbeSmrg *) func_append temp_deplibs " $libdir";; 7006ea133fd7Smrg esac 7007ea133fd7Smrg done 7008ea133fd7Smrg dependency_libs="$temp_deplibs" 7009ea133fd7Smrg fi 7010ea133fd7Smrg 701106f32fbeSmrg func_append newlib_search_path " $absdir" 7012ea133fd7Smrg # Link against this library 7013ea133fd7Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 7014ea133fd7Smrg # ... and its dependency_libs 7015ea133fd7Smrg tmp_libs= 7016ea133fd7Smrg for deplib in $dependency_libs; do 7017ea133fd7Smrg newdependency_libs="$deplib $newdependency_libs" 701806f32fbeSmrg case $deplib in 701906f32fbeSmrg -L*) func_stripname '-L' '' "$deplib" 702006f32fbeSmrg func_resolve_sysroot "$func_stripname_result";; 702106f32fbeSmrg *) func_resolve_sysroot "$deplib" ;; 702206f32fbeSmrg esac 702306f32fbeSmrg if $opt_preserve_dup_deps ; then 7024ea133fd7Smrg case "$tmp_libs " in 702506f32fbeSmrg *" $func_resolve_sysroot_result "*) 702606f32fbeSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 7027ea133fd7Smrg esac 7028ea133fd7Smrg fi 702906f32fbeSmrg func_append tmp_libs " $func_resolve_sysroot_result" 7030ea133fd7Smrg done 7031ea133fd7Smrg 7032ea133fd7Smrg if test "$link_all_deplibs" != no; then 7033ea133fd7Smrg # Add the search paths of all dependency libraries 7034ea133fd7Smrg for deplib in $dependency_libs; do 703525b89263Smrg path= 7036ea133fd7Smrg case $deplib in 7037ea133fd7Smrg -L*) path="$deplib" ;; 7038ea133fd7Smrg *.la) 703906f32fbeSmrg func_resolve_sysroot "$deplib" 704006f32fbeSmrg deplib=$func_resolve_sysroot_result 7041ea133fd7Smrg func_dirname "$deplib" "" "." 704206f32fbeSmrg dir=$func_dirname_result 7043ea133fd7Smrg # We need an absolute path. 7044ea133fd7Smrg case $dir in 7045ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 7046ea133fd7Smrg *) 7047ea133fd7Smrg absdir=`cd "$dir" && pwd` 7048ea133fd7Smrg if test -z "$absdir"; then 7049ea133fd7Smrg func_warning "cannot determine absolute directory name of \`$dir'" 7050ea133fd7Smrg absdir="$dir" 7051ea133fd7Smrg fi 7052ea133fd7Smrg ;; 7053ea133fd7Smrg esac 7054ea133fd7Smrg if $GREP "^installed=no" $deplib > /dev/null; then 7055ea133fd7Smrg case $host in 7056ea133fd7Smrg *-*-darwin*) 7057ea133fd7Smrg depdepl= 7058ea133fd7Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 7059ea133fd7Smrg if test -n "$deplibrary_names" ; then 7060ea133fd7Smrg for tmp in $deplibrary_names ; do 7061ea133fd7Smrg depdepl=$tmp 7062ea133fd7Smrg done 7063ea133fd7Smrg if test -f "$absdir/$objdir/$depdepl" ; then 7064ea133fd7Smrg depdepl="$absdir/$objdir/$depdepl" 7065ea133fd7Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7066ea133fd7Smrg if test -z "$darwin_install_name"; then 7067ea133fd7Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7068ea133fd7Smrg fi 706906f32fbeSmrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 707006f32fbeSmrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 7071ea133fd7Smrg path= 7072ea133fd7Smrg fi 7073ea133fd7Smrg fi 7074ea133fd7Smrg ;; 7075ea133fd7Smrg *) 7076ea133fd7Smrg path="-L$absdir/$objdir" 7077ea133fd7Smrg ;; 7078ea133fd7Smrg esac 7079ea133fd7Smrg else 7080ea133fd7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 7081ea133fd7Smrg test -z "$libdir" && \ 7082ea133fd7Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 7083ea133fd7Smrg test "$absdir" != "$libdir" && \ 7084ea133fd7Smrg func_warning "\`$deplib' seems to be moved" 7085ea133fd7Smrg 7086ea133fd7Smrg path="-L$absdir" 7087ea133fd7Smrg fi 7088ea133fd7Smrg ;; 7089ea133fd7Smrg esac 7090ea133fd7Smrg case " $deplibs " in 7091ea133fd7Smrg *" $path "*) ;; 7092ea133fd7Smrg *) deplibs="$path $deplibs" ;; 7093ea133fd7Smrg esac 7094ea133fd7Smrg done 7095ea133fd7Smrg fi # link_all_deplibs != no 7096ea133fd7Smrg fi # linkmode = lib 7097ea133fd7Smrg done # for deplib in $libs 7098ea133fd7Smrg if test "$pass" = link; then 7099ea133fd7Smrg if test "$linkmode" = "prog"; then 7100ea133fd7Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 7101ea133fd7Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 7102ea133fd7Smrg else 710325b89263Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7104ea133fd7Smrg fi 7105ea133fd7Smrg fi 7106ea133fd7Smrg dependency_libs="$newdependency_libs" 7107ea133fd7Smrg if test "$pass" = dlpreopen; then 7108ea133fd7Smrg # Link the dlpreopened libraries before other libraries 7109ea133fd7Smrg for deplib in $save_deplibs; do 7110ea133fd7Smrg deplibs="$deplib $deplibs" 7111ea133fd7Smrg done 7112ea133fd7Smrg fi 7113ea133fd7Smrg if test "$pass" != dlopen; then 7114ea133fd7Smrg if test "$pass" != conv; then 7115ea133fd7Smrg # Make sure lib_search_path contains only unique directories. 7116ea133fd7Smrg lib_search_path= 7117ea133fd7Smrg for dir in $newlib_search_path; do 7118ea133fd7Smrg case "$lib_search_path " in 7119ea133fd7Smrg *" $dir "*) ;; 712006f32fbeSmrg *) func_append lib_search_path " $dir" ;; 7121ea133fd7Smrg esac 7122ea133fd7Smrg done 7123ea133fd7Smrg newlib_search_path= 7124ea133fd7Smrg fi 7125ea133fd7Smrg 7126ea133fd7Smrg if test "$linkmode,$pass" != "prog,link"; then 7127ea133fd7Smrg vars="deplibs" 7128ea133fd7Smrg else 7129ea133fd7Smrg vars="compile_deplibs finalize_deplibs" 7130ea133fd7Smrg fi 7131ea133fd7Smrg for var in $vars dependency_libs; do 7132ea133fd7Smrg # Add libraries to $var in reverse order 7133ea133fd7Smrg eval tmp_libs=\"\$$var\" 7134ea133fd7Smrg new_libs= 7135ea133fd7Smrg for deplib in $tmp_libs; do 7136ea133fd7Smrg # FIXME: Pedantically, this is the right thing to do, so 7137ea133fd7Smrg # that some nasty dependency loop isn't accidentally 7138ea133fd7Smrg # broken: 7139ea133fd7Smrg #new_libs="$deplib $new_libs" 7140ea133fd7Smrg # Pragmatically, this seems to cause very few problems in 7141ea133fd7Smrg # practice: 7142ea133fd7Smrg case $deplib in 7143ea133fd7Smrg -L*) new_libs="$deplib $new_libs" ;; 7144ea133fd7Smrg -R*) ;; 7145ea133fd7Smrg *) 7146ea133fd7Smrg # And here is the reason: when a library appears more 7147ea133fd7Smrg # than once as an explicit dependence of a library, or 7148ea133fd7Smrg # is implicitly linked in more than once by the 7149ea133fd7Smrg # compiler, it is considered special, and multiple 7150ea133fd7Smrg # occurrences thereof are not removed. Compare this 7151ea133fd7Smrg # with having the same library being listed as a 7152ea133fd7Smrg # dependency of multiple other libraries: in this case, 7153ea133fd7Smrg # we know (pedantically, we assume) the library does not 7154ea133fd7Smrg # need to be listed more than once, so we keep only the 7155ea133fd7Smrg # last copy. This is not always right, but it is rare 7156ea133fd7Smrg # enough that we require users that really mean to play 7157ea133fd7Smrg # such unportable linking tricks to link the library 7158ea133fd7Smrg # using -Wl,-lname, so that libtool does not consider it 7159ea133fd7Smrg # for duplicate removal. 7160ea133fd7Smrg case " $specialdeplibs " in 7161ea133fd7Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 7162ea133fd7Smrg *) 7163ea133fd7Smrg case " $new_libs " in 7164ea133fd7Smrg *" $deplib "*) ;; 7165ea133fd7Smrg *) new_libs="$deplib $new_libs" ;; 7166ea133fd7Smrg esac 7167ea133fd7Smrg ;; 7168ea133fd7Smrg esac 7169ea133fd7Smrg ;; 7170ea133fd7Smrg esac 7171ea133fd7Smrg done 7172ea133fd7Smrg tmp_libs= 7173ea133fd7Smrg for deplib in $new_libs; do 7174ea133fd7Smrg case $deplib in 7175ea133fd7Smrg -L*) 7176ea133fd7Smrg case " $tmp_libs " in 7177ea133fd7Smrg *" $deplib "*) ;; 717806f32fbeSmrg *) func_append tmp_libs " $deplib" ;; 7179ea133fd7Smrg esac 7180ea133fd7Smrg ;; 718106f32fbeSmrg *) func_append tmp_libs " $deplib" ;; 7182ea133fd7Smrg esac 7183ea133fd7Smrg done 7184ea133fd7Smrg eval $var=\"$tmp_libs\" 7185ea133fd7Smrg done # for var 7186ea133fd7Smrg fi 7187ea133fd7Smrg # Last step: remove runtime libs from dependency_libs 7188ea133fd7Smrg # (they stay in deplibs) 7189ea133fd7Smrg tmp_libs= 7190ea133fd7Smrg for i in $dependency_libs ; do 7191ea133fd7Smrg case " $predeps $postdeps $compiler_lib_search_path " in 7192ea133fd7Smrg *" $i "*) 7193ea133fd7Smrg i="" 7194ea133fd7Smrg ;; 7195ea133fd7Smrg esac 7196ea133fd7Smrg if test -n "$i" ; then 719706f32fbeSmrg func_append tmp_libs " $i" 7198ea133fd7Smrg fi 7199ea133fd7Smrg done 7200ea133fd7Smrg dependency_libs=$tmp_libs 7201ea133fd7Smrg done # for pass 7202ea133fd7Smrg if test "$linkmode" = prog; then 7203ea133fd7Smrg dlfiles="$newdlfiles" 7204ea133fd7Smrg fi 7205ea133fd7Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 7206ea133fd7Smrg dlprefiles="$newdlprefiles" 7207ea133fd7Smrg fi 7208ea133fd7Smrg 7209ea133fd7Smrg case $linkmode in 7210ea133fd7Smrg oldlib) 7211ea133fd7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7212ea133fd7Smrg func_warning "\`-dlopen' is ignored for archives" 7213ea133fd7Smrg fi 7214ea133fd7Smrg 7215ea133fd7Smrg case " $deplibs" in 7216ea133fd7Smrg *\ -l* | *\ -L*) 7217ea133fd7Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 7218ea133fd7Smrg esac 7219ea133fd7Smrg 7220ea133fd7Smrg test -n "$rpath" && \ 7221ea133fd7Smrg func_warning "\`-rpath' is ignored for archives" 7222ea133fd7Smrg 7223ea133fd7Smrg test -n "$xrpath" && \ 7224ea133fd7Smrg func_warning "\`-R' is ignored for archives" 7225ea133fd7Smrg 7226ea133fd7Smrg test -n "$vinfo" && \ 7227ea133fd7Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 7228ea133fd7Smrg 7229ea133fd7Smrg test -n "$release" && \ 7230ea133fd7Smrg func_warning "\`-release' is ignored for archives" 7231ea133fd7Smrg 7232ea133fd7Smrg test -n "$export_symbols$export_symbols_regex" && \ 7233ea133fd7Smrg func_warning "\`-export-symbols' is ignored for archives" 7234ea133fd7Smrg 7235ea133fd7Smrg # Now set the variables for building old libraries. 7236ea133fd7Smrg build_libtool_libs=no 7237ea133fd7Smrg oldlibs="$output" 723806f32fbeSmrg func_append objs "$old_deplibs" 7239ea133fd7Smrg ;; 7240ea133fd7Smrg 7241ea133fd7Smrg lib) 7242ea133fd7Smrg # Make sure we only generate libraries of the form `libNAME.la'. 7243ea133fd7Smrg case $outputname in 7244ea133fd7Smrg lib*) 7245ea133fd7Smrg func_stripname 'lib' '.la' "$outputname" 7246ea133fd7Smrg name=$func_stripname_result 7247ea133fd7Smrg eval shared_ext=\"$shrext_cmds\" 7248ea133fd7Smrg eval libname=\"$libname_spec\" 7249ea133fd7Smrg ;; 7250ea133fd7Smrg *) 7251ea133fd7Smrg test "$module" = no && \ 7252ea133fd7Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 7253ea133fd7Smrg 7254ea133fd7Smrg if test "$need_lib_prefix" != no; then 7255ea133fd7Smrg # Add the "lib" prefix for modules if required 7256ea133fd7Smrg func_stripname '' '.la' "$outputname" 7257ea133fd7Smrg name=$func_stripname_result 7258ea133fd7Smrg eval shared_ext=\"$shrext_cmds\" 7259ea133fd7Smrg eval libname=\"$libname_spec\" 7260ea133fd7Smrg else 7261ea133fd7Smrg func_stripname '' '.la' "$outputname" 7262ea133fd7Smrg libname=$func_stripname_result 7263ea133fd7Smrg fi 7264ea133fd7Smrg ;; 7265ea133fd7Smrg esac 7266ea133fd7Smrg 7267ea133fd7Smrg if test -n "$objs"; then 7268ea133fd7Smrg if test "$deplibs_check_method" != pass_all; then 7269ea133fd7Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 7270ea133fd7Smrg else 727125b89263Smrg echo 7272ea133fd7Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 7273ea133fd7Smrg $ECHO "*** objects $objs is not portable!" 727406f32fbeSmrg func_append libobjs " $objs" 7275ea133fd7Smrg fi 7276ea133fd7Smrg fi 7277ea133fd7Smrg 7278ea133fd7Smrg test "$dlself" != no && \ 7279ea133fd7Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 7280ea133fd7Smrg 7281ea133fd7Smrg set dummy $rpath 7282ea133fd7Smrg shift 7283ea133fd7Smrg test "$#" -gt 1 && \ 7284ea133fd7Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 7285ea133fd7Smrg 7286ea133fd7Smrg install_libdir="$1" 7287ea133fd7Smrg 7288ea133fd7Smrg oldlibs= 7289ea133fd7Smrg if test -z "$rpath"; then 7290ea133fd7Smrg if test "$build_libtool_libs" = yes; then 7291ea133fd7Smrg # Building a libtool convenience library. 7292ea133fd7Smrg # Some compilers have problems with a `.al' extension so 7293ea133fd7Smrg # convenience libraries should have the same extension an 7294ea133fd7Smrg # archive normally would. 7295ea133fd7Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 7296ea133fd7Smrg build_libtool_libs=convenience 7297ea133fd7Smrg build_old_libs=yes 7298ea133fd7Smrg fi 7299ea133fd7Smrg 7300ea133fd7Smrg test -n "$vinfo" && \ 7301ea133fd7Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 7302ea133fd7Smrg 7303ea133fd7Smrg test -n "$release" && \ 7304ea133fd7Smrg func_warning "\`-release' is ignored for convenience libraries" 7305ea133fd7Smrg else 7306ea133fd7Smrg 7307ea133fd7Smrg # Parse the version information argument. 7308ea133fd7Smrg save_ifs="$IFS"; IFS=':' 7309ea133fd7Smrg set dummy $vinfo 0 0 0 7310ea133fd7Smrg shift 7311ea133fd7Smrg IFS="$save_ifs" 7312ea133fd7Smrg 7313ea133fd7Smrg test -n "$7" && \ 7314ea133fd7Smrg func_fatal_help "too many parameters to \`-version-info'" 7315ea133fd7Smrg 7316ea133fd7Smrg # convert absolute version numbers to libtool ages 7317ea133fd7Smrg # this retains compatibility with .la files and attempts 7318ea133fd7Smrg # to make the code below a bit more comprehensible 7319ea133fd7Smrg 7320ea133fd7Smrg case $vinfo_number in 7321ea133fd7Smrg yes) 7322ea133fd7Smrg number_major="$1" 7323ea133fd7Smrg number_minor="$2" 7324ea133fd7Smrg number_revision="$3" 7325ea133fd7Smrg # 7326ea133fd7Smrg # There are really only two kinds -- those that 7327ea133fd7Smrg # use the current revision as the major version 7328ea133fd7Smrg # and those that subtract age and use age as 7329ea133fd7Smrg # a minor version. But, then there is irix 7330ea133fd7Smrg # which has an extra 1 added just for fun 7331ea133fd7Smrg # 7332ea133fd7Smrg case $version_type in 733357ee1794Smrg # correct linux to gnu/linux during the next big refactor 7334ea133fd7Smrg darwin|linux|osf|windows|none) 7335ea133fd7Smrg func_arith $number_major + $number_minor 7336ea133fd7Smrg current=$func_arith_result 7337ea133fd7Smrg age="$number_minor" 7338ea133fd7Smrg revision="$number_revision" 7339ea133fd7Smrg ;; 734025b89263Smrg freebsd-aout|freebsd-elf|qnx|sunos) 7341ea133fd7Smrg current="$number_major" 7342ea133fd7Smrg revision="$number_minor" 7343ea133fd7Smrg age="0" 7344ea133fd7Smrg ;; 7345ea133fd7Smrg irix|nonstopux) 7346ea133fd7Smrg func_arith $number_major + $number_minor 7347ea133fd7Smrg current=$func_arith_result 7348ea133fd7Smrg age="$number_minor" 7349ea133fd7Smrg revision="$number_minor" 7350ea133fd7Smrg lt_irix_increment=no 7351ea133fd7Smrg ;; 7352ea133fd7Smrg esac 7353ea133fd7Smrg ;; 7354ea133fd7Smrg no) 7355ea133fd7Smrg current="$1" 7356ea133fd7Smrg revision="$2" 7357ea133fd7Smrg age="$3" 7358ea133fd7Smrg ;; 7359ea133fd7Smrg esac 7360ea133fd7Smrg 7361ea133fd7Smrg # Check that each of the things are valid numbers. 7362ea133fd7Smrg case $current in 7363ea133fd7Smrg 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]) ;; 7364ea133fd7Smrg *) 7365ea133fd7Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 7366ea133fd7Smrg func_fatal_error "\`$vinfo' is not valid version information" 7367ea133fd7Smrg ;; 7368ea133fd7Smrg esac 7369ea133fd7Smrg 7370ea133fd7Smrg case $revision in 7371ea133fd7Smrg 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]) ;; 7372ea133fd7Smrg *) 7373ea133fd7Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 7374ea133fd7Smrg func_fatal_error "\`$vinfo' is not valid version information" 7375ea133fd7Smrg ;; 7376ea133fd7Smrg esac 7377ea133fd7Smrg 7378ea133fd7Smrg case $age in 7379ea133fd7Smrg 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]) ;; 7380ea133fd7Smrg *) 7381ea133fd7Smrg func_error "AGE \`$age' must be a nonnegative integer" 7382ea133fd7Smrg func_fatal_error "\`$vinfo' is not valid version information" 7383ea133fd7Smrg ;; 7384ea133fd7Smrg esac 7385ea133fd7Smrg 7386ea133fd7Smrg if test "$age" -gt "$current"; then 7387ea133fd7Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 7388ea133fd7Smrg func_fatal_error "\`$vinfo' is not valid version information" 7389ea133fd7Smrg fi 7390ea133fd7Smrg 7391ea133fd7Smrg # Calculate the version variables. 7392ea133fd7Smrg major= 7393ea133fd7Smrg versuffix= 7394ea133fd7Smrg verstring= 7395ea133fd7Smrg case $version_type in 7396ea133fd7Smrg none) ;; 7397ea133fd7Smrg 7398ea133fd7Smrg darwin) 7399ea133fd7Smrg # Like Linux, but with the current version available in 7400ea133fd7Smrg # verstring for coding it into the library header 7401ea133fd7Smrg func_arith $current - $age 7402ea133fd7Smrg major=.$func_arith_result 7403ea133fd7Smrg versuffix="$major.$age.$revision" 7404ea133fd7Smrg # Darwin ld doesn't like 0 for these options... 7405ea133fd7Smrg func_arith $current + 1 7406ea133fd7Smrg minor_current=$func_arith_result 7407ea133fd7Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 7408ea133fd7Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 7409ea133fd7Smrg ;; 7410ea133fd7Smrg 7411ea133fd7Smrg freebsd-aout) 7412ea133fd7Smrg major=".$current" 7413ea133fd7Smrg versuffix=".$current.$revision"; 7414ea133fd7Smrg ;; 7415ea133fd7Smrg 7416ea133fd7Smrg freebsd-elf) 7417ea133fd7Smrg major=".$current" 7418ea133fd7Smrg versuffix=".$current" 7419ea133fd7Smrg ;; 7420ea133fd7Smrg 7421ea133fd7Smrg irix | nonstopux) 7422ea133fd7Smrg if test "X$lt_irix_increment" = "Xno"; then 7423ea133fd7Smrg func_arith $current - $age 7424ea133fd7Smrg else 7425ea133fd7Smrg func_arith $current - $age + 1 7426ea133fd7Smrg fi 7427ea133fd7Smrg major=$func_arith_result 7428ea133fd7Smrg 7429ea133fd7Smrg case $version_type in 7430ea133fd7Smrg nonstopux) verstring_prefix=nonstopux ;; 7431ea133fd7Smrg *) verstring_prefix=sgi ;; 7432ea133fd7Smrg esac 7433ea133fd7Smrg verstring="$verstring_prefix$major.$revision" 7434ea133fd7Smrg 7435ea133fd7Smrg # Add in all the interfaces that we are compatible with. 7436ea133fd7Smrg loop=$revision 7437ea133fd7Smrg while test "$loop" -ne 0; do 7438ea133fd7Smrg func_arith $revision - $loop 7439ea133fd7Smrg iface=$func_arith_result 7440ea133fd7Smrg func_arith $loop - 1 7441ea133fd7Smrg loop=$func_arith_result 7442ea133fd7Smrg verstring="$verstring_prefix$major.$iface:$verstring" 7443ea133fd7Smrg done 7444ea133fd7Smrg 7445ea133fd7Smrg # Before this point, $major must not contain `.'. 7446ea133fd7Smrg major=.$major 7447ea133fd7Smrg versuffix="$major.$revision" 7448ea133fd7Smrg ;; 7449ea133fd7Smrg 745057ee1794Smrg linux) # correct to gnu/linux during the next big refactor 7451ea133fd7Smrg func_arith $current - $age 7452ea133fd7Smrg major=.$func_arith_result 7453ea133fd7Smrg versuffix="$major.$age.$revision" 7454ea133fd7Smrg ;; 7455ea133fd7Smrg 7456ea133fd7Smrg osf) 7457ea133fd7Smrg func_arith $current - $age 7458ea133fd7Smrg major=.$func_arith_result 7459ea133fd7Smrg versuffix=".$current.$age.$revision" 7460ea133fd7Smrg verstring="$current.$age.$revision" 7461ea133fd7Smrg 7462ea133fd7Smrg # Add in all the interfaces that we are compatible with. 7463ea133fd7Smrg loop=$age 7464ea133fd7Smrg while test "$loop" -ne 0; do 7465ea133fd7Smrg func_arith $current - $loop 7466ea133fd7Smrg iface=$func_arith_result 7467ea133fd7Smrg func_arith $loop - 1 7468ea133fd7Smrg loop=$func_arith_result 7469ea133fd7Smrg verstring="$verstring:${iface}.0" 7470ea133fd7Smrg done 7471ea133fd7Smrg 7472ea133fd7Smrg # Make executables depend on our current version. 747306f32fbeSmrg func_append verstring ":${current}.0" 7474ea133fd7Smrg ;; 7475ea133fd7Smrg 7476ea133fd7Smrg qnx) 7477ea133fd7Smrg major=".$current" 7478ea133fd7Smrg versuffix=".$current" 7479ea133fd7Smrg ;; 7480ea133fd7Smrg 7481ea133fd7Smrg sunos) 7482ea133fd7Smrg major=".$current" 7483ea133fd7Smrg versuffix=".$current.$revision" 7484ea133fd7Smrg ;; 7485ea133fd7Smrg 7486ea133fd7Smrg windows) 7487ea133fd7Smrg # Use '-' rather than '.', since we only want one 7488ea133fd7Smrg # extension on DOS 8.3 filesystems. 7489ea133fd7Smrg func_arith $current - $age 7490ea133fd7Smrg major=$func_arith_result 7491ea133fd7Smrg versuffix="-$major" 7492ea133fd7Smrg ;; 7493ea133fd7Smrg 7494ea133fd7Smrg *) 7495ea133fd7Smrg func_fatal_configuration "unknown library version type \`$version_type'" 7496ea133fd7Smrg ;; 7497ea133fd7Smrg esac 7498ea133fd7Smrg 7499ea133fd7Smrg # Clear the version info if we defaulted, and they specified a release. 7500ea133fd7Smrg if test -z "$vinfo" && test -n "$release"; then 7501ea133fd7Smrg major= 7502ea133fd7Smrg case $version_type in 7503ea133fd7Smrg darwin) 7504ea133fd7Smrg # we can't check for "0.0" in archive_cmds due to quoting 7505ea133fd7Smrg # problems, so we reset it completely 7506ea133fd7Smrg verstring= 7507ea133fd7Smrg ;; 7508ea133fd7Smrg *) 7509ea133fd7Smrg verstring="0.0" 7510ea133fd7Smrg ;; 7511ea133fd7Smrg esac 7512ea133fd7Smrg if test "$need_version" = no; then 7513ea133fd7Smrg versuffix= 7514ea133fd7Smrg else 7515ea133fd7Smrg versuffix=".0.0" 7516ea133fd7Smrg fi 7517ea133fd7Smrg fi 7518ea133fd7Smrg 7519ea133fd7Smrg # Remove version info from name if versioning should be avoided 7520ea133fd7Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 7521ea133fd7Smrg major= 7522ea133fd7Smrg versuffix= 7523ea133fd7Smrg verstring="" 7524ea133fd7Smrg fi 7525ea133fd7Smrg 7526ea133fd7Smrg # Check to see if the archive will have undefined symbols. 7527ea133fd7Smrg if test "$allow_undefined" = yes; then 7528ea133fd7Smrg if test "$allow_undefined_flag" = unsupported; then 7529ea133fd7Smrg func_warning "undefined symbols not allowed in $host shared libraries" 7530ea133fd7Smrg build_libtool_libs=no 7531ea133fd7Smrg build_old_libs=yes 7532ea133fd7Smrg fi 7533ea133fd7Smrg else 7534ea133fd7Smrg # Don't allow undefined symbols. 7535ea133fd7Smrg allow_undefined_flag="$no_undefined_flag" 7536ea133fd7Smrg fi 7537ea133fd7Smrg 7538ea133fd7Smrg fi 7539ea133fd7Smrg 7540ea133fd7Smrg func_generate_dlsyms "$libname" "$libname" "yes" 754106f32fbeSmrg func_append libobjs " $symfileobj" 7542ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 7543ea133fd7Smrg 754406f32fbeSmrg if test "$opt_mode" != relink; then 7545ea133fd7Smrg # Remove our outputs, but don't remove object files since they 7546ea133fd7Smrg # may have been created when compiling PIC objects. 7547ea133fd7Smrg removelist= 7548ea133fd7Smrg tempremovelist=`$ECHO "$output_objdir/*"` 7549ea133fd7Smrg for p in $tempremovelist; do 7550ea133fd7Smrg case $p in 7551ea133fd7Smrg *.$objext | *.gcno) 7552ea133fd7Smrg ;; 7553ea133fd7Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 7554ea133fd7Smrg if test "X$precious_files_regex" != "X"; then 7555ea133fd7Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 7556ea133fd7Smrg then 7557ea133fd7Smrg continue 7558ea133fd7Smrg fi 7559ea133fd7Smrg fi 756006f32fbeSmrg func_append removelist " $p" 7561ea133fd7Smrg ;; 7562ea133fd7Smrg *) ;; 7563ea133fd7Smrg esac 7564ea133fd7Smrg done 7565ea133fd7Smrg test -n "$removelist" && \ 7566ea133fd7Smrg func_show_eval "${RM}r \$removelist" 7567ea133fd7Smrg fi 7568ea133fd7Smrg 7569ea133fd7Smrg # Now set the variables for building old libraries. 7570ea133fd7Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 757106f32fbeSmrg func_append oldlibs " $output_objdir/$libname.$libext" 7572ea133fd7Smrg 7573ea133fd7Smrg # Transform .lo files to .o files. 757425b89263Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 7575ea133fd7Smrg fi 7576ea133fd7Smrg 7577ea133fd7Smrg # Eliminate all temporary directories. 7578ea133fd7Smrg #for path in $notinst_path; do 757925b89263Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 758025b89263Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 758125b89263Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 7582ea133fd7Smrg #done 7583ea133fd7Smrg 7584ea133fd7Smrg if test -n "$xrpath"; then 7585ea133fd7Smrg # If the user specified any rpath flags, then add them. 7586ea133fd7Smrg temp_xrpath= 7587ea133fd7Smrg for libdir in $xrpath; do 758806f32fbeSmrg func_replace_sysroot "$libdir" 758906f32fbeSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 7590ea133fd7Smrg case "$finalize_rpath " in 7591ea133fd7Smrg *" $libdir "*) ;; 759206f32fbeSmrg *) func_append finalize_rpath " $libdir" ;; 7593ea133fd7Smrg esac 7594ea133fd7Smrg done 7595ea133fd7Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 7596ea133fd7Smrg dependency_libs="$temp_xrpath $dependency_libs" 7597ea133fd7Smrg fi 7598ea133fd7Smrg fi 7599ea133fd7Smrg 7600ea133fd7Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 7601ea133fd7Smrg old_dlfiles="$dlfiles" 7602ea133fd7Smrg dlfiles= 7603ea133fd7Smrg for lib in $old_dlfiles; do 7604ea133fd7Smrg case " $dlprefiles $dlfiles " in 7605ea133fd7Smrg *" $lib "*) ;; 760606f32fbeSmrg *) func_append dlfiles " $lib" ;; 7607ea133fd7Smrg esac 7608ea133fd7Smrg done 7609ea133fd7Smrg 7610ea133fd7Smrg # Make sure dlprefiles contains only unique files 7611ea133fd7Smrg old_dlprefiles="$dlprefiles" 7612ea133fd7Smrg dlprefiles= 7613ea133fd7Smrg for lib in $old_dlprefiles; do 7614ea133fd7Smrg case "$dlprefiles " in 7615ea133fd7Smrg *" $lib "*) ;; 761606f32fbeSmrg *) func_append dlprefiles " $lib" ;; 7617ea133fd7Smrg esac 7618ea133fd7Smrg done 7619ea133fd7Smrg 7620ea133fd7Smrg if test "$build_libtool_libs" = yes; then 7621ea133fd7Smrg if test -n "$rpath"; then 7622ea133fd7Smrg case $host in 762325b89263Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 7624ea133fd7Smrg # these systems don't actually have a c library (as such)! 7625ea133fd7Smrg ;; 7626ea133fd7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7627ea133fd7Smrg # Rhapsody C library is in the System framework 762806f32fbeSmrg func_append deplibs " System.ltframework" 7629ea133fd7Smrg ;; 7630ea133fd7Smrg *-*-netbsd*) 7631ea133fd7Smrg # Don't link with libc until the a.out ld.so is fixed. 7632ea133fd7Smrg ;; 7633ea133fd7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 7634ea133fd7Smrg # Do not include libc due to us having libc/libc_r. 7635ea133fd7Smrg ;; 7636ea133fd7Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7637ea133fd7Smrg # Causes problems with __ctype 7638ea133fd7Smrg ;; 7639ea133fd7Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7640ea133fd7Smrg # Compiler inserts libc in the correct place for threads to work 7641ea133fd7Smrg ;; 7642ea133fd7Smrg *) 7643ea133fd7Smrg # Add libc to deplibs on all other systems if necessary. 7644ea133fd7Smrg if test "$build_libtool_need_lc" = "yes"; then 764506f32fbeSmrg func_append deplibs " -lc" 7646ea133fd7Smrg fi 7647ea133fd7Smrg ;; 7648ea133fd7Smrg esac 7649ea133fd7Smrg fi 7650ea133fd7Smrg 7651ea133fd7Smrg # Transform deplibs into only deplibs that can be linked in shared. 7652ea133fd7Smrg name_save=$name 7653ea133fd7Smrg libname_save=$libname 7654ea133fd7Smrg release_save=$release 7655ea133fd7Smrg versuffix_save=$versuffix 7656ea133fd7Smrg major_save=$major 7657ea133fd7Smrg # I'm not sure if I'm treating the release correctly. I think 7658ea133fd7Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 7659ea133fd7Smrg # add it in twice. Is that correct? 7660ea133fd7Smrg release="" 7661ea133fd7Smrg versuffix="" 7662ea133fd7Smrg major="" 7663ea133fd7Smrg newdeplibs= 7664ea133fd7Smrg droppeddeps=no 7665ea133fd7Smrg case $deplibs_check_method in 7666ea133fd7Smrg pass_all) 7667ea133fd7Smrg # Don't check for shared/static. Everything works. 7668ea133fd7Smrg # This might be a little naive. We might want to check 7669ea133fd7Smrg # whether the library exists or not. But this is on 7670ea133fd7Smrg # osf3 & osf4 and I'm not really sure... Just 7671ea133fd7Smrg # implementing what was already the behavior. 7672ea133fd7Smrg newdeplibs=$deplibs 7673ea133fd7Smrg ;; 7674ea133fd7Smrg test_compile) 7675ea133fd7Smrg # This code stresses the "libraries are programs" paradigm to its 7676ea133fd7Smrg # limits. Maybe even breaks it. We compile a program, linking it 7677ea133fd7Smrg # against the deplibs as a proxy for the library. Then we can check 7678ea133fd7Smrg # whether they linked in statically or dynamically with ldd. 7679ea133fd7Smrg $opt_dry_run || $RM conftest.c 7680ea133fd7Smrg cat > conftest.c <<EOF 7681ea133fd7Smrg int main() { return 0; } 7682ea133fd7SmrgEOF 7683ea133fd7Smrg $opt_dry_run || $RM conftest 7684ea133fd7Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 7685ea133fd7Smrg ldd_output=`ldd conftest` 7686ea133fd7Smrg for i in $deplibs; do 7687ea133fd7Smrg case $i in 7688ea133fd7Smrg -l*) 7689ea133fd7Smrg func_stripname -l '' "$i" 7690ea133fd7Smrg name=$func_stripname_result 7691ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7692ea133fd7Smrg case " $predeps $postdeps " in 7693ea133fd7Smrg *" $i "*) 769406f32fbeSmrg func_append newdeplibs " $i" 7695ea133fd7Smrg i="" 7696ea133fd7Smrg ;; 7697ea133fd7Smrg esac 7698ea133fd7Smrg fi 7699ea133fd7Smrg if test -n "$i" ; then 7700ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7701ea133fd7Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7702ea133fd7Smrg set dummy $deplib_matches; shift 7703ea133fd7Smrg deplib_match=$1 7704ea133fd7Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 770506f32fbeSmrg func_append newdeplibs " $i" 7706ea133fd7Smrg else 7707ea133fd7Smrg droppeddeps=yes 770825b89263Smrg echo 7709ea133fd7Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 771025b89263Smrg echo "*** I have the capability to make that library automatically link in when" 771125b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 771225b89263Smrg echo "*** shared version of the library, which I believe you do not have" 771325b89263Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 771425b89263Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 7715ea133fd7Smrg fi 7716ea133fd7Smrg fi 7717ea133fd7Smrg ;; 7718ea133fd7Smrg *) 771906f32fbeSmrg func_append newdeplibs " $i" 7720ea133fd7Smrg ;; 7721ea133fd7Smrg esac 7722ea133fd7Smrg done 7723ea133fd7Smrg else 7724ea133fd7Smrg # Error occurred in the first compile. Let's try to salvage 7725ea133fd7Smrg # the situation: Compile a separate program for each library. 7726ea133fd7Smrg for i in $deplibs; do 7727ea133fd7Smrg case $i in 7728ea133fd7Smrg -l*) 7729ea133fd7Smrg func_stripname -l '' "$i" 7730ea133fd7Smrg name=$func_stripname_result 7731ea133fd7Smrg $opt_dry_run || $RM conftest 7732ea133fd7Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 7733ea133fd7Smrg ldd_output=`ldd conftest` 7734ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7735ea133fd7Smrg case " $predeps $postdeps " in 7736ea133fd7Smrg *" $i "*) 773706f32fbeSmrg func_append newdeplibs " $i" 7738ea133fd7Smrg i="" 7739ea133fd7Smrg ;; 7740ea133fd7Smrg esac 7741ea133fd7Smrg fi 7742ea133fd7Smrg if test -n "$i" ; then 7743ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7744ea133fd7Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7745ea133fd7Smrg set dummy $deplib_matches; shift 7746ea133fd7Smrg deplib_match=$1 7747ea133fd7Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 774806f32fbeSmrg func_append newdeplibs " $i" 7749ea133fd7Smrg else 7750ea133fd7Smrg droppeddeps=yes 775125b89263Smrg echo 7752ea133fd7Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 775325b89263Smrg echo "*** I have the capability to make that library automatically link in when" 775425b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 775525b89263Smrg echo "*** shared version of the library, which you do not appear to have" 775625b89263Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 775725b89263Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 7758ea133fd7Smrg fi 7759ea133fd7Smrg fi 7760ea133fd7Smrg else 7761ea133fd7Smrg droppeddeps=yes 776225b89263Smrg echo 7763ea133fd7Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 776425b89263Smrg echo "*** make it link in! You will probably need to install it or some" 776525b89263Smrg echo "*** library that it depends on before this library will be fully" 776625b89263Smrg echo "*** functional. Installing it before continuing would be even better." 7767ea133fd7Smrg fi 7768ea133fd7Smrg ;; 7769ea133fd7Smrg *) 777006f32fbeSmrg func_append newdeplibs " $i" 7771ea133fd7Smrg ;; 7772ea133fd7Smrg esac 7773ea133fd7Smrg done 7774ea133fd7Smrg fi 7775ea133fd7Smrg ;; 7776ea133fd7Smrg file_magic*) 7777ea133fd7Smrg set dummy $deplibs_check_method; shift 7778ea133fd7Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7779ea133fd7Smrg for a_deplib in $deplibs; do 7780ea133fd7Smrg case $a_deplib in 7781ea133fd7Smrg -l*) 7782ea133fd7Smrg func_stripname -l '' "$a_deplib" 7783ea133fd7Smrg name=$func_stripname_result 7784ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7785ea133fd7Smrg case " $predeps $postdeps " in 7786ea133fd7Smrg *" $a_deplib "*) 778706f32fbeSmrg func_append newdeplibs " $a_deplib" 7788ea133fd7Smrg a_deplib="" 7789ea133fd7Smrg ;; 7790ea133fd7Smrg esac 7791ea133fd7Smrg fi 7792ea133fd7Smrg if test -n "$a_deplib" ; then 7793ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 779406f32fbeSmrg if test -n "$file_magic_glob"; then 779506f32fbeSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 779606f32fbeSmrg else 779706f32fbeSmrg libnameglob=$libname 779806f32fbeSmrg fi 779906f32fbeSmrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 7800ea133fd7Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 780106f32fbeSmrg if test "$want_nocaseglob" = yes; then 780206f32fbeSmrg shopt -s nocaseglob 780306f32fbeSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 780406f32fbeSmrg $nocaseglob 780506f32fbeSmrg else 780606f32fbeSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 780706f32fbeSmrg fi 7808ea133fd7Smrg for potent_lib in $potential_libs; do 7809ea133fd7Smrg # Follow soft links. 7810ea133fd7Smrg if ls -lLd "$potent_lib" 2>/dev/null | 7811ea133fd7Smrg $GREP " -> " >/dev/null; then 7812ea133fd7Smrg continue 7813ea133fd7Smrg fi 7814ea133fd7Smrg # The statement above tries to avoid entering an 7815ea133fd7Smrg # endless loop below, in case of cyclic links. 7816ea133fd7Smrg # We might still enter an endless loop, since a link 7817ea133fd7Smrg # loop can be closed while we follow links, 7818ea133fd7Smrg # but so what? 7819ea133fd7Smrg potlib="$potent_lib" 7820ea133fd7Smrg while test -h "$potlib" 2>/dev/null; do 7821ea133fd7Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 7822ea133fd7Smrg case $potliblink in 7823ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 782425b89263Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 7825ea133fd7Smrg esac 7826ea133fd7Smrg done 7827ea133fd7Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 7828ea133fd7Smrg $SED -e 10q | 7829ea133fd7Smrg $EGREP "$file_magic_regex" > /dev/null; then 783006f32fbeSmrg func_append newdeplibs " $a_deplib" 7831ea133fd7Smrg a_deplib="" 7832ea133fd7Smrg break 2 7833ea133fd7Smrg fi 7834ea133fd7Smrg done 7835ea133fd7Smrg done 7836ea133fd7Smrg fi 7837ea133fd7Smrg if test -n "$a_deplib" ; then 7838ea133fd7Smrg droppeddeps=yes 783925b89263Smrg echo 7840ea133fd7Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 784125b89263Smrg echo "*** I have the capability to make that library automatically link in when" 784225b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 784325b89263Smrg echo "*** shared version of the library, which you do not appear to have" 784425b89263Smrg echo "*** because I did check the linker path looking for a file starting" 7845ea133fd7Smrg if test -z "$potlib" ; then 7846ea133fd7Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 7847ea133fd7Smrg else 7848ea133fd7Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7849ea133fd7Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 7850ea133fd7Smrg fi 7851ea133fd7Smrg fi 7852ea133fd7Smrg ;; 7853ea133fd7Smrg *) 7854ea133fd7Smrg # Add a -L argument. 785506f32fbeSmrg func_append newdeplibs " $a_deplib" 7856ea133fd7Smrg ;; 7857ea133fd7Smrg esac 7858ea133fd7Smrg done # Gone through all deplibs. 7859ea133fd7Smrg ;; 7860ea133fd7Smrg match_pattern*) 7861ea133fd7Smrg set dummy $deplibs_check_method; shift 7862ea133fd7Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7863ea133fd7Smrg for a_deplib in $deplibs; do 7864ea133fd7Smrg case $a_deplib in 7865ea133fd7Smrg -l*) 7866ea133fd7Smrg func_stripname -l '' "$a_deplib" 7867ea133fd7Smrg name=$func_stripname_result 7868ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7869ea133fd7Smrg case " $predeps $postdeps " in 7870ea133fd7Smrg *" $a_deplib "*) 787106f32fbeSmrg func_append newdeplibs " $a_deplib" 7872ea133fd7Smrg a_deplib="" 7873ea133fd7Smrg ;; 7874ea133fd7Smrg esac 7875ea133fd7Smrg fi 7876ea133fd7Smrg if test -n "$a_deplib" ; then 7877ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7878ea133fd7Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7879ea133fd7Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 7880ea133fd7Smrg for potent_lib in $potential_libs; do 7881ea133fd7Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 788225b89263Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 7883ea133fd7Smrg $EGREP "$match_pattern_regex" > /dev/null; then 788406f32fbeSmrg func_append newdeplibs " $a_deplib" 7885ea133fd7Smrg a_deplib="" 7886ea133fd7Smrg break 2 7887ea133fd7Smrg fi 7888ea133fd7Smrg done 7889ea133fd7Smrg done 7890ea133fd7Smrg fi 7891ea133fd7Smrg if test -n "$a_deplib" ; then 7892ea133fd7Smrg droppeddeps=yes 789325b89263Smrg echo 7894ea133fd7Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 789525b89263Smrg echo "*** I have the capability to make that library automatically link in when" 789625b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 789725b89263Smrg echo "*** shared version of the library, which you do not appear to have" 789825b89263Smrg echo "*** because I did check the linker path looking for a file starting" 7899ea133fd7Smrg if test -z "$potlib" ; then 7900ea133fd7Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 7901ea133fd7Smrg else 7902ea133fd7Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7903ea133fd7Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 7904ea133fd7Smrg fi 7905ea133fd7Smrg fi 7906ea133fd7Smrg ;; 7907ea133fd7Smrg *) 7908ea133fd7Smrg # Add a -L argument. 790906f32fbeSmrg func_append newdeplibs " $a_deplib" 7910ea133fd7Smrg ;; 7911ea133fd7Smrg esac 7912ea133fd7Smrg done # Gone through all deplibs. 7913ea133fd7Smrg ;; 7914ea133fd7Smrg none | unknown | *) 7915ea133fd7Smrg newdeplibs="" 791625b89263Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7917ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7918ea133fd7Smrg for i in $predeps $postdeps ; do 7919ea133fd7Smrg # can't use Xsed below, because $i might contain '/' 792025b89263Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 7921ea133fd7Smrg done 7922ea133fd7Smrg fi 792325b89263Smrg case $tmp_deplibs in 792425b89263Smrg *[!\ \ ]*) 792525b89263Smrg echo 7926ea133fd7Smrg if test "X$deplibs_check_method" = "Xnone"; then 792725b89263Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 7928ea133fd7Smrg else 792925b89263Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 7930ea133fd7Smrg fi 793125b89263Smrg echo "*** All declared inter-library dependencies are being dropped." 7932ea133fd7Smrg droppeddeps=yes 793325b89263Smrg ;; 793425b89263Smrg esac 7935ea133fd7Smrg ;; 7936ea133fd7Smrg esac 7937ea133fd7Smrg versuffix=$versuffix_save 7938ea133fd7Smrg major=$major_save 7939ea133fd7Smrg release=$release_save 7940ea133fd7Smrg libname=$libname_save 7941ea133fd7Smrg name=$name_save 7942ea133fd7Smrg 7943ea133fd7Smrg case $host in 7944ea133fd7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7945ea133fd7Smrg # On Rhapsody replace the C library with the System framework 794625b89263Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 7947ea133fd7Smrg ;; 7948ea133fd7Smrg esac 7949ea133fd7Smrg 7950ea133fd7Smrg if test "$droppeddeps" = yes; then 7951ea133fd7Smrg if test "$module" = yes; then 795225b89263Smrg echo 795325b89263Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 7954ea133fd7Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 795525b89263Smrg echo "*** a static module, that should work as long as the dlopening" 795625b89263Smrg echo "*** application is linked with the -dlopen flag." 7957ea133fd7Smrg if test -z "$global_symbol_pipe"; then 795825b89263Smrg echo 795925b89263Smrg echo "*** However, this would only work if libtool was able to extract symbol" 796025b89263Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 796125b89263Smrg echo "*** not find such a program. So, this module is probably useless." 796225b89263Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 7963ea133fd7Smrg fi 7964ea133fd7Smrg if test "$build_old_libs" = no; then 7965ea133fd7Smrg oldlibs="$output_objdir/$libname.$libext" 7966ea133fd7Smrg build_libtool_libs=module 7967ea133fd7Smrg build_old_libs=yes 7968ea133fd7Smrg else 7969ea133fd7Smrg build_libtool_libs=no 7970ea133fd7Smrg fi 7971ea133fd7Smrg else 797225b89263Smrg echo "*** The inter-library dependencies that have been dropped here will be" 797325b89263Smrg echo "*** automatically added whenever a program is linked with this library" 797425b89263Smrg echo "*** or is declared to -dlopen it." 7975ea133fd7Smrg 7976ea133fd7Smrg if test "$allow_undefined" = no; then 797725b89263Smrg echo 797825b89263Smrg echo "*** Since this library must not contain undefined symbols," 797925b89263Smrg echo "*** because either the platform does not support them or" 798025b89263Smrg echo "*** it was explicitly requested with -no-undefined," 798125b89263Smrg echo "*** libtool will only create a static version of it." 7982ea133fd7Smrg if test "$build_old_libs" = no; then 7983ea133fd7Smrg oldlibs="$output_objdir/$libname.$libext" 7984ea133fd7Smrg build_libtool_libs=module 7985ea133fd7Smrg build_old_libs=yes 7986ea133fd7Smrg else 7987ea133fd7Smrg build_libtool_libs=no 7988ea133fd7Smrg fi 7989ea133fd7Smrg fi 7990ea133fd7Smrg fi 7991ea133fd7Smrg fi 7992ea133fd7Smrg # Done checking deplibs! 7993ea133fd7Smrg deplibs=$newdeplibs 7994ea133fd7Smrg fi 7995ea133fd7Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 7996ea133fd7Smrg case $host in 7997ea133fd7Smrg *-*-darwin*) 799825b89263Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 799925b89263Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 800025b89263Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8001ea133fd7Smrg ;; 8002ea133fd7Smrg esac 8003ea133fd7Smrg 8004ea133fd7Smrg # move library search paths that coincide with paths to not yet 8005ea133fd7Smrg # installed libraries to the beginning of the library search list 8006ea133fd7Smrg new_libs= 8007ea133fd7Smrg for path in $notinst_path; do 8008ea133fd7Smrg case " $new_libs " in 8009ea133fd7Smrg *" -L$path/$objdir "*) ;; 8010ea133fd7Smrg *) 8011ea133fd7Smrg case " $deplibs " in 8012ea133fd7Smrg *" -L$path/$objdir "*) 801306f32fbeSmrg func_append new_libs " -L$path/$objdir" ;; 8014ea133fd7Smrg esac 8015ea133fd7Smrg ;; 8016ea133fd7Smrg esac 8017ea133fd7Smrg done 8018ea133fd7Smrg for deplib in $deplibs; do 8019ea133fd7Smrg case $deplib in 8020ea133fd7Smrg -L*) 8021ea133fd7Smrg case " $new_libs " in 8022ea133fd7Smrg *" $deplib "*) ;; 802306f32fbeSmrg *) func_append new_libs " $deplib" ;; 8024ea133fd7Smrg esac 8025ea133fd7Smrg ;; 802606f32fbeSmrg *) func_append new_libs " $deplib" ;; 8027ea133fd7Smrg esac 8028ea133fd7Smrg done 8029ea133fd7Smrg deplibs="$new_libs" 8030ea133fd7Smrg 8031ea133fd7Smrg # All the library-specific variables (install_libdir is set above). 8032ea133fd7Smrg library_names= 8033ea133fd7Smrg old_library= 8034ea133fd7Smrg dlname= 8035ea133fd7Smrg 8036ea133fd7Smrg # Test again, we may have decided not to build it any more 8037ea133fd7Smrg if test "$build_libtool_libs" = yes; then 803857ee1794Smrg # Remove ${wl} instances when linking with ld. 803957ee1794Smrg # FIXME: should test the right _cmds variable. 804057ee1794Smrg case $archive_cmds in 804157ee1794Smrg *\$LD\ *) wl= ;; 804257ee1794Smrg esac 8043ea133fd7Smrg if test "$hardcode_into_libs" = yes; then 8044ea133fd7Smrg # Hardcode the library paths 8045ea133fd7Smrg hardcode_libdirs= 8046ea133fd7Smrg dep_rpath= 8047ea133fd7Smrg rpath="$finalize_rpath" 804806f32fbeSmrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 8049ea133fd7Smrg for libdir in $rpath; do 8050ea133fd7Smrg if test -n "$hardcode_libdir_flag_spec"; then 8051ea133fd7Smrg if test -n "$hardcode_libdir_separator"; then 805206f32fbeSmrg func_replace_sysroot "$libdir" 805306f32fbeSmrg libdir=$func_replace_sysroot_result 8054ea133fd7Smrg if test -z "$hardcode_libdirs"; then 8055ea133fd7Smrg hardcode_libdirs="$libdir" 8056ea133fd7Smrg else 8057ea133fd7Smrg # Just accumulate the unique libdirs. 8058ea133fd7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8059ea133fd7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8060ea133fd7Smrg ;; 8061ea133fd7Smrg *) 806206f32fbeSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8063ea133fd7Smrg ;; 8064ea133fd7Smrg esac 8065ea133fd7Smrg fi 8066ea133fd7Smrg else 8067ea133fd7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 806806f32fbeSmrg func_append dep_rpath " $flag" 8069ea133fd7Smrg fi 8070ea133fd7Smrg elif test -n "$runpath_var"; then 8071ea133fd7Smrg case "$perm_rpath " in 8072ea133fd7Smrg *" $libdir "*) ;; 807357ee1794Smrg *) func_append perm_rpath " $libdir" ;; 8074ea133fd7Smrg esac 8075ea133fd7Smrg fi 8076ea133fd7Smrg done 8077ea133fd7Smrg # Substitute the hardcoded libdirs into the rpath. 8078ea133fd7Smrg if test -n "$hardcode_libdir_separator" && 8079ea133fd7Smrg test -n "$hardcode_libdirs"; then 8080ea133fd7Smrg libdir="$hardcode_libdirs" 808157ee1794Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 8082ea133fd7Smrg fi 8083ea133fd7Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 8084ea133fd7Smrg # We should set the runpath_var. 8085ea133fd7Smrg rpath= 8086ea133fd7Smrg for dir in $perm_rpath; do 808706f32fbeSmrg func_append rpath "$dir:" 8088ea133fd7Smrg done 8089ea133fd7Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 8090ea133fd7Smrg fi 8091ea133fd7Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 8092ea133fd7Smrg fi 8093a253d6aeSmrg 8094ea133fd7Smrg shlibpath="$finalize_shlibpath" 809506f32fbeSmrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 8096ea133fd7Smrg if test -n "$shlibpath"; then 8097ea133fd7Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 8098ea133fd7Smrg fi 8099a253d6aeSmrg 8100ea133fd7Smrg # Get the real and link names of the library. 8101ea133fd7Smrg eval shared_ext=\"$shrext_cmds\" 8102ea133fd7Smrg eval library_names=\"$library_names_spec\" 8103ea133fd7Smrg set dummy $library_names 8104ea133fd7Smrg shift 8105ea133fd7Smrg realname="$1" 8106ea133fd7Smrg shift 8107a253d6aeSmrg 8108ea133fd7Smrg if test -n "$soname_spec"; then 8109ea133fd7Smrg eval soname=\"$soname_spec\" 8110ea133fd7Smrg else 8111ea133fd7Smrg soname="$realname" 8112ea133fd7Smrg fi 8113ea133fd7Smrg if test -z "$dlname"; then 8114ea133fd7Smrg dlname=$soname 8115ea133fd7Smrg fi 8116a253d6aeSmrg 8117ea133fd7Smrg lib="$output_objdir/$realname" 8118ea133fd7Smrg linknames= 8119ea133fd7Smrg for link 8120ea133fd7Smrg do 812106f32fbeSmrg func_append linknames " $link" 8122ea133fd7Smrg done 8123a253d6aeSmrg 8124ea133fd7Smrg # Use standard objects if they are pic 812525b89263Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 8126ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 8127a253d6aeSmrg 8128ea133fd7Smrg delfiles= 8129ea133fd7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8130ea133fd7Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 8131ea133fd7Smrg export_symbols="$output_objdir/$libname.uexp" 813206f32fbeSmrg func_append delfiles " $export_symbols" 8133ea133fd7Smrg fi 8134a253d6aeSmrg 8135ea133fd7Smrg orig_export_symbols= 8136ea133fd7Smrg case $host_os in 8137ea133fd7Smrg cygwin* | mingw* | cegcc*) 8138ea133fd7Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 8139ea133fd7Smrg # exporting using user supplied symfile 8140ea133fd7Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 8141ea133fd7Smrg # and it's NOT already a .def file. Must figure out 8142ea133fd7Smrg # which of the given symbols are data symbols and tag 8143ea133fd7Smrg # them as such. So, trigger use of export_symbols_cmds. 8144ea133fd7Smrg # export_symbols gets reassigned inside the "prepare 8145ea133fd7Smrg # the list of exported symbols" if statement, so the 8146ea133fd7Smrg # include_expsyms logic still works. 8147ea133fd7Smrg orig_export_symbols="$export_symbols" 8148ea133fd7Smrg export_symbols= 8149ea133fd7Smrg always_export_symbols=yes 8150ea133fd7Smrg fi 8151ea133fd7Smrg fi 8152ea133fd7Smrg ;; 8153ea133fd7Smrg esac 8154a253d6aeSmrg 8155ea133fd7Smrg # Prepare the list of exported symbols 8156ea133fd7Smrg if test -z "$export_symbols"; then 8157ea133fd7Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 8158ea133fd7Smrg func_verbose "generating symbol list for \`$libname.la'" 8159ea133fd7Smrg export_symbols="$output_objdir/$libname.exp" 8160ea133fd7Smrg $opt_dry_run || $RM $export_symbols 8161ea133fd7Smrg cmds=$export_symbols_cmds 8162ea133fd7Smrg save_ifs="$IFS"; IFS='~' 816306f32fbeSmrg for cmd1 in $cmds; do 8164ea133fd7Smrg IFS="$save_ifs" 816506f32fbeSmrg # Take the normal branch if the nm_file_list_spec branch 816606f32fbeSmrg # doesn't work or if tool conversion is not needed. 816706f32fbeSmrg case $nm_file_list_spec~$to_tool_file_cmd in 816806f32fbeSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 816906f32fbeSmrg try_normal_branch=yes 817006f32fbeSmrg eval cmd=\"$cmd1\" 817106f32fbeSmrg func_len " $cmd" 817206f32fbeSmrg len=$func_len_result 817306f32fbeSmrg ;; 817406f32fbeSmrg *) 817506f32fbeSmrg try_normal_branch=no 817606f32fbeSmrg ;; 817706f32fbeSmrg esac 817806f32fbeSmrg if test "$try_normal_branch" = yes \ 817906f32fbeSmrg && { test "$len" -lt "$max_cmd_len" \ 818006f32fbeSmrg || test "$max_cmd_len" -le -1; } 818106f32fbeSmrg then 818206f32fbeSmrg func_show_eval "$cmd" 'exit $?' 818306f32fbeSmrg skipped_export=false 818406f32fbeSmrg elif test -n "$nm_file_list_spec"; then 818506f32fbeSmrg func_basename "$output" 818606f32fbeSmrg output_la=$func_basename_result 818706f32fbeSmrg save_libobjs=$libobjs 818806f32fbeSmrg save_output=$output 818906f32fbeSmrg output=${output_objdir}/${output_la}.nm 819006f32fbeSmrg func_to_tool_file "$output" 819106f32fbeSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 819206f32fbeSmrg func_append delfiles " $output" 819306f32fbeSmrg func_verbose "creating $NM input file list: $output" 819406f32fbeSmrg for obj in $save_libobjs; do 819506f32fbeSmrg func_to_tool_file "$obj" 819606f32fbeSmrg $ECHO "$func_to_tool_file_result" 819706f32fbeSmrg done > "$output" 819806f32fbeSmrg eval cmd=\"$cmd1\" 8199ea133fd7Smrg func_show_eval "$cmd" 'exit $?' 820006f32fbeSmrg output=$save_output 820106f32fbeSmrg libobjs=$save_libobjs 8202ea133fd7Smrg skipped_export=false 8203ea133fd7Smrg else 8204ea133fd7Smrg # The command line is too long to execute in one step. 8205ea133fd7Smrg func_verbose "using reloadable object file for export list..." 8206ea133fd7Smrg skipped_export=: 8207ea133fd7Smrg # Break out early, otherwise skipped_export may be 8208ea133fd7Smrg # set to false by a later but shorter cmd. 8209ea133fd7Smrg break 8210ea133fd7Smrg fi 8211ea133fd7Smrg done 8212ea133fd7Smrg IFS="$save_ifs" 8213ea133fd7Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 8214ea133fd7Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8215ea133fd7Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8216ea133fd7Smrg fi 8217ea133fd7Smrg fi 8218ea133fd7Smrg fi 8219a253d6aeSmrg 8220ea133fd7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8221ea133fd7Smrg tmp_export_symbols="$export_symbols" 8222ea133fd7Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 822325b89263Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8224ea133fd7Smrg fi 8225a253d6aeSmrg 8226ea133fd7Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 8227ea133fd7Smrg # The given exports_symbols file has to be filtered, so filter it. 8228ea133fd7Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8229ea133fd7Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8230ea133fd7Smrg # 's' commands which not all seds can handle. GNU sed should be fine 8231ea133fd7Smrg # though. Also, the filter scales superlinearly with the number of 8232ea133fd7Smrg # global variables. join(1) would be nice here, but unfortunately 8233ea133fd7Smrg # isn't a blessed tool. 8234ea133fd7Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 823506f32fbeSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8236ea133fd7Smrg export_symbols=$output_objdir/$libname.def 8237ea133fd7Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8238a253d6aeSmrg fi 8239a253d6aeSmrg 8240ea133fd7Smrg tmp_deplibs= 8241ea133fd7Smrg for test_deplib in $deplibs; do 8242ea133fd7Smrg case " $convenience " in 8243ea133fd7Smrg *" $test_deplib "*) ;; 8244ea133fd7Smrg *) 824506f32fbeSmrg func_append tmp_deplibs " $test_deplib" 8246ea133fd7Smrg ;; 8247ea133fd7Smrg esac 8248ea133fd7Smrg done 8249ea133fd7Smrg deplibs="$tmp_deplibs" 8250a253d6aeSmrg 8251ea133fd7Smrg if test -n "$convenience"; then 8252ea133fd7Smrg if test -n "$whole_archive_flag_spec" && 8253ea133fd7Smrg test "$compiler_needs_object" = yes && 8254ea133fd7Smrg test -z "$libobjs"; then 8255ea133fd7Smrg # extract the archives, so we have objects to list. 8256ea133fd7Smrg # TODO: could optimize this to just extract one archive. 8257ea133fd7Smrg whole_archive_flag_spec= 8258ea133fd7Smrg fi 8259ea133fd7Smrg if test -n "$whole_archive_flag_spec"; then 8260ea133fd7Smrg save_libobjs=$libobjs 8261ea133fd7Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8262ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 8263ea133fd7Smrg else 8264ea133fd7Smrg gentop="$output_objdir/${outputname}x" 826506f32fbeSmrg func_append generated " $gentop" 8266a253d6aeSmrg 8267ea133fd7Smrg func_extract_archives $gentop $convenience 826806f32fbeSmrg func_append libobjs " $func_extract_archives_result" 8269ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 8270ea133fd7Smrg fi 8271ea133fd7Smrg fi 8272a253d6aeSmrg 8273ea133fd7Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 8274ea133fd7Smrg eval flag=\"$thread_safe_flag_spec\" 827506f32fbeSmrg func_append linker_flags " $flag" 8276ea133fd7Smrg fi 8277a253d6aeSmrg 8278ea133fd7Smrg # Make a backup of the uninstalled library when relinking 827906f32fbeSmrg if test "$opt_mode" = relink; then 8280ea133fd7Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 8281a253d6aeSmrg fi 8282a253d6aeSmrg 8283ea133fd7Smrg # Do each of the archive commands. 8284ea133fd7Smrg if test "$module" = yes && test -n "$module_cmds" ; then 8285ea133fd7Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8286ea133fd7Smrg eval test_cmds=\"$module_expsym_cmds\" 8287ea133fd7Smrg cmds=$module_expsym_cmds 8288ea133fd7Smrg else 8289ea133fd7Smrg eval test_cmds=\"$module_cmds\" 8290ea133fd7Smrg cmds=$module_cmds 8291ea133fd7Smrg fi 8292ea133fd7Smrg else 8293ea133fd7Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8294ea133fd7Smrg eval test_cmds=\"$archive_expsym_cmds\" 8295ea133fd7Smrg cmds=$archive_expsym_cmds 8296ea133fd7Smrg else 8297ea133fd7Smrg eval test_cmds=\"$archive_cmds\" 8298ea133fd7Smrg cmds=$archive_cmds 8299ea133fd7Smrg fi 8300a253d6aeSmrg fi 8301a253d6aeSmrg 8302ea133fd7Smrg if test "X$skipped_export" != "X:" && 8303ea133fd7Smrg func_len " $test_cmds" && 8304ea133fd7Smrg len=$func_len_result && 8305ea133fd7Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8306ea133fd7Smrg : 8307ea133fd7Smrg else 8308ea133fd7Smrg # The command line is too long to link in one step, link piecewise 8309ea133fd7Smrg # or, if using GNU ld and skipped_export is not :, use a linker 8310ea133fd7Smrg # script. 8311a253d6aeSmrg 8312ea133fd7Smrg # Save the value of $output and $libobjs because we want to 8313ea133fd7Smrg # use them later. If we have whole_archive_flag_spec, we 8314ea133fd7Smrg # want to use save_libobjs as it was before 8315ea133fd7Smrg # whole_archive_flag_spec was expanded, because we can't 8316ea133fd7Smrg # assume the linker understands whole_archive_flag_spec. 8317ea133fd7Smrg # This may have to be revisited, in case too many 8318ea133fd7Smrg # convenience libraries get linked in and end up exceeding 8319ea133fd7Smrg # the spec. 8320ea133fd7Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 8321ea133fd7Smrg save_libobjs=$libobjs 8322ea133fd7Smrg fi 8323ea133fd7Smrg save_output=$output 832425b89263Smrg func_basename "$output" 832525b89263Smrg output_la=$func_basename_result 8326a253d6aeSmrg 8327ea133fd7Smrg # Clear the reloadable object creation command queue and 8328ea133fd7Smrg # initialize k to one. 8329ea133fd7Smrg test_cmds= 8330ea133fd7Smrg concat_cmds= 8331ea133fd7Smrg objlist= 8332ea133fd7Smrg last_robj= 8333ea133fd7Smrg k=1 8334a253d6aeSmrg 8335ea133fd7Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 8336ea133fd7Smrg output=${output_objdir}/${output_la}.lnkscript 8337ea133fd7Smrg func_verbose "creating GNU ld script: $output" 833825b89263Smrg echo 'INPUT (' > $output 8339ea133fd7Smrg for obj in $save_libobjs 8340ea133fd7Smrg do 834106f32fbeSmrg func_to_tool_file "$obj" 834206f32fbeSmrg $ECHO "$func_to_tool_file_result" >> $output 8343ea133fd7Smrg done 834425b89263Smrg echo ')' >> $output 834506f32fbeSmrg func_append delfiles " $output" 834606f32fbeSmrg func_to_tool_file "$output" 834706f32fbeSmrg output=$func_to_tool_file_result 8348ea133fd7Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 8349ea133fd7Smrg output=${output_objdir}/${output_la}.lnk 8350ea133fd7Smrg func_verbose "creating linker input file list: $output" 8351ea133fd7Smrg : > $output 8352ea133fd7Smrg set x $save_libobjs 8353ea133fd7Smrg shift 8354ea133fd7Smrg firstobj= 8355ea133fd7Smrg if test "$compiler_needs_object" = yes; then 8356ea133fd7Smrg firstobj="$1 " 8357ea133fd7Smrg shift 8358ea133fd7Smrg fi 8359ea133fd7Smrg for obj 8360ea133fd7Smrg do 836106f32fbeSmrg func_to_tool_file "$obj" 836206f32fbeSmrg $ECHO "$func_to_tool_file_result" >> $output 8363ea133fd7Smrg done 836406f32fbeSmrg func_append delfiles " $output" 836506f32fbeSmrg func_to_tool_file "$output" 836606f32fbeSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 8367ea133fd7Smrg else 8368ea133fd7Smrg if test -n "$save_libobjs"; then 8369ea133fd7Smrg func_verbose "creating reloadable object files..." 8370ea133fd7Smrg output=$output_objdir/$output_la-${k}.$objext 8371ea133fd7Smrg eval test_cmds=\"$reload_cmds\" 8372ea133fd7Smrg func_len " $test_cmds" 8373ea133fd7Smrg len0=$func_len_result 8374ea133fd7Smrg len=$len0 8375ea133fd7Smrg 8376ea133fd7Smrg # Loop over the list of objects to be linked. 8377ea133fd7Smrg for obj in $save_libobjs 8378ea133fd7Smrg do 8379ea133fd7Smrg func_len " $obj" 8380ea133fd7Smrg func_arith $len + $func_len_result 8381ea133fd7Smrg len=$func_arith_result 8382ea133fd7Smrg if test "X$objlist" = X || 8383ea133fd7Smrg test "$len" -lt "$max_cmd_len"; then 8384ea133fd7Smrg func_append objlist " $obj" 8385ea133fd7Smrg else 8386ea133fd7Smrg # The command $test_cmds is almost too long, add a 8387ea133fd7Smrg # command to the queue. 8388ea133fd7Smrg if test "$k" -eq 1 ; then 8389ea133fd7Smrg # The first file doesn't have a previous command to add. 839025b89263Smrg reload_objs=$objlist 839125b89263Smrg eval concat_cmds=\"$reload_cmds\" 8392ea133fd7Smrg else 8393ea133fd7Smrg # All subsequent reloadable object files will link in 8394ea133fd7Smrg # the last one created. 839525b89263Smrg reload_objs="$objlist $last_robj" 839625b89263Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 8397ea133fd7Smrg fi 8398ea133fd7Smrg last_robj=$output_objdir/$output_la-${k}.$objext 8399ea133fd7Smrg func_arith $k + 1 8400ea133fd7Smrg k=$func_arith_result 8401ea133fd7Smrg output=$output_objdir/$output_la-${k}.$objext 840225b89263Smrg objlist=" $obj" 8403ea133fd7Smrg func_len " $last_robj" 8404ea133fd7Smrg func_arith $len0 + $func_len_result 8405ea133fd7Smrg len=$func_arith_result 8406ea133fd7Smrg fi 8407ea133fd7Smrg done 8408ea133fd7Smrg # Handle the remaining objects by creating one last 8409ea133fd7Smrg # reloadable object file. All subsequent reloadable object 8410ea133fd7Smrg # files will link in the last one created. 8411ea133fd7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 841225b89263Smrg reload_objs="$objlist $last_robj" 841325b89263Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 8414ea133fd7Smrg if test -n "$last_robj"; then 8415ea133fd7Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8416ea133fd7Smrg fi 841706f32fbeSmrg func_append delfiles " $output" 8418a253d6aeSmrg 8419ea133fd7Smrg else 8420ea133fd7Smrg output= 8421ea133fd7Smrg fi 8422a253d6aeSmrg 8423ea133fd7Smrg if ${skipped_export-false}; then 8424ea133fd7Smrg func_verbose "generating symbol list for \`$libname.la'" 8425ea133fd7Smrg export_symbols="$output_objdir/$libname.exp" 8426ea133fd7Smrg $opt_dry_run || $RM $export_symbols 8427ea133fd7Smrg libobjs=$output 8428ea133fd7Smrg # Append the command to create the export file. 8429ea133fd7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8430ea133fd7Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 8431ea133fd7Smrg if test -n "$last_robj"; then 8432ea133fd7Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8433ea133fd7Smrg fi 8434ea133fd7Smrg fi 8435a253d6aeSmrg 8436ea133fd7Smrg test -n "$save_libobjs" && 8437ea133fd7Smrg func_verbose "creating a temporary reloadable object file: $output" 8438a253d6aeSmrg 8439ea133fd7Smrg # Loop through the commands generated above and execute them. 8440ea133fd7Smrg save_ifs="$IFS"; IFS='~' 8441ea133fd7Smrg for cmd in $concat_cmds; do 8442ea133fd7Smrg IFS="$save_ifs" 8443ea133fd7Smrg $opt_silent || { 8444ea133fd7Smrg func_quote_for_expand "$cmd" 8445ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 8446ea133fd7Smrg } 8447ea133fd7Smrg $opt_dry_run || eval "$cmd" || { 8448ea133fd7Smrg lt_exit=$? 8449ea133fd7Smrg 8450ea133fd7Smrg # Restore the uninstalled library and exit 845106f32fbeSmrg if test "$opt_mode" = relink; then 8452ea133fd7Smrg ( cd "$output_objdir" && \ 8453ea133fd7Smrg $RM "${realname}T" && \ 8454ea133fd7Smrg $MV "${realname}U" "$realname" ) 8455ea133fd7Smrg fi 8456a253d6aeSmrg 8457ea133fd7Smrg exit $lt_exit 8458ea133fd7Smrg } 8459ea133fd7Smrg done 8460ea133fd7Smrg IFS="$save_ifs" 8461ea133fd7Smrg 8462ea133fd7Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 8463ea133fd7Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8464ea133fd7Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8465a253d6aeSmrg fi 8466a253d6aeSmrg fi 8467a253d6aeSmrg 8468ea133fd7Smrg if ${skipped_export-false}; then 8469ea133fd7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8470ea133fd7Smrg tmp_export_symbols="$export_symbols" 8471ea133fd7Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 847225b89263Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8473ea133fd7Smrg fi 8474a253d6aeSmrg 8475ea133fd7Smrg if test -n "$orig_export_symbols"; then 8476ea133fd7Smrg # The given exports_symbols file has to be filtered, so filter it. 8477ea133fd7Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8478ea133fd7Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8479ea133fd7Smrg # 's' commands which not all seds can handle. GNU sed should be fine 8480ea133fd7Smrg # though. Also, the filter scales superlinearly with the number of 8481ea133fd7Smrg # global variables. join(1) would be nice here, but unfortunately 8482ea133fd7Smrg # isn't a blessed tool. 8483ea133fd7Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 848406f32fbeSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8485ea133fd7Smrg export_symbols=$output_objdir/$libname.def 8486ea133fd7Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8487ea133fd7Smrg fi 8488ea133fd7Smrg fi 8489a253d6aeSmrg 8490ea133fd7Smrg libobjs=$output 8491ea133fd7Smrg # Restore the value of output. 8492ea133fd7Smrg output=$save_output 8493a253d6aeSmrg 8494ea133fd7Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 8495ea133fd7Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8496ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 8497ea133fd7Smrg fi 8498ea133fd7Smrg # Expand the library linking commands again to reset the 8499ea133fd7Smrg # value of $libobjs for piecewise linking. 8500ea133fd7Smrg 8501ea133fd7Smrg # Do each of the archive commands. 8502ea133fd7Smrg if test "$module" = yes && test -n "$module_cmds" ; then 8503ea133fd7Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8504ea133fd7Smrg cmds=$module_expsym_cmds 8505a253d6aeSmrg else 8506ea133fd7Smrg cmds=$module_cmds 8507a253d6aeSmrg fi 8508a253d6aeSmrg else 8509ea133fd7Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8510ea133fd7Smrg cmds=$archive_expsym_cmds 8511ea133fd7Smrg else 8512ea133fd7Smrg cmds=$archive_cmds 8513ea133fd7Smrg fi 8514a253d6aeSmrg fi 8515a253d6aeSmrg fi 8516a253d6aeSmrg 8517ea133fd7Smrg if test -n "$delfiles"; then 8518ea133fd7Smrg # Append the command to remove temporary files to $cmds. 8519ea133fd7Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 8520ea133fd7Smrg fi 8521a253d6aeSmrg 8522ea133fd7Smrg # Add any objects from preloaded convenience libraries 8523ea133fd7Smrg if test -n "$dlprefiles"; then 8524ea133fd7Smrg gentop="$output_objdir/${outputname}x" 852506f32fbeSmrg func_append generated " $gentop" 8526a253d6aeSmrg 8527ea133fd7Smrg func_extract_archives $gentop $dlprefiles 852806f32fbeSmrg func_append libobjs " $func_extract_archives_result" 8529ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 8530a253d6aeSmrg fi 8531a253d6aeSmrg 8532ea133fd7Smrg save_ifs="$IFS"; IFS='~' 8533ea133fd7Smrg for cmd in $cmds; do 8534ea133fd7Smrg IFS="$save_ifs" 8535ea133fd7Smrg eval cmd=\"$cmd\" 8536ea133fd7Smrg $opt_silent || { 8537ea133fd7Smrg func_quote_for_expand "$cmd" 8538ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 8539ea133fd7Smrg } 8540ea133fd7Smrg $opt_dry_run || eval "$cmd" || { 8541ea133fd7Smrg lt_exit=$? 8542a253d6aeSmrg 8543ea133fd7Smrg # Restore the uninstalled library and exit 854406f32fbeSmrg if test "$opt_mode" = relink; then 8545ea133fd7Smrg ( cd "$output_objdir" && \ 8546ea133fd7Smrg $RM "${realname}T" && \ 8547ea133fd7Smrg $MV "${realname}U" "$realname" ) 8548ea133fd7Smrg fi 8549ea133fd7Smrg 8550ea133fd7Smrg exit $lt_exit 8551ea133fd7Smrg } 8552ea133fd7Smrg done 8553ea133fd7Smrg IFS="$save_ifs" 8554ea133fd7Smrg 8555ea133fd7Smrg # Restore the uninstalled library and exit 855606f32fbeSmrg if test "$opt_mode" = relink; then 8557ea133fd7Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8558ea133fd7Smrg 8559ea133fd7Smrg if test -n "$convenience"; then 8560ea133fd7Smrg if test -z "$whole_archive_flag_spec"; then 8561ea133fd7Smrg func_show_eval '${RM}r "$gentop"' 8562a253d6aeSmrg fi 8563a253d6aeSmrg fi 8564a253d6aeSmrg 8565ea133fd7Smrg exit $EXIT_SUCCESS 8566ea133fd7Smrg fi 8567a253d6aeSmrg 8568ea133fd7Smrg # Create links to the real library. 8569ea133fd7Smrg for linkname in $linknames; do 8570ea133fd7Smrg if test "$realname" != "$linkname"; then 8571ea133fd7Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8572ea133fd7Smrg fi 8573ea133fd7Smrg done 8574ea133fd7Smrg 8575ea133fd7Smrg # If -module or -export-dynamic was specified, set the dlname. 8576ea133fd7Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 8577ea133fd7Smrg # On all known operating systems, these are identical. 8578ea133fd7Smrg dlname="$soname" 8579ea133fd7Smrg fi 8580ea133fd7Smrg fi 8581ea133fd7Smrg ;; 8582ea133fd7Smrg 8583ea133fd7Smrg obj) 8584ea133fd7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 8585ea133fd7Smrg func_warning "\`-dlopen' is ignored for objects" 8586ea133fd7Smrg fi 8587ea133fd7Smrg 8588ea133fd7Smrg case " $deplibs" in 8589ea133fd7Smrg *\ -l* | *\ -L*) 8590ea133fd7Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 8591ea133fd7Smrg esac 8592ea133fd7Smrg 8593ea133fd7Smrg test -n "$rpath" && \ 8594ea133fd7Smrg func_warning "\`-rpath' is ignored for objects" 8595ea133fd7Smrg 8596ea133fd7Smrg test -n "$xrpath" && \ 8597ea133fd7Smrg func_warning "\`-R' is ignored for objects" 8598ea133fd7Smrg 8599ea133fd7Smrg test -n "$vinfo" && \ 8600ea133fd7Smrg func_warning "\`-version-info' is ignored for objects" 8601ea133fd7Smrg 8602ea133fd7Smrg test -n "$release" && \ 8603ea133fd7Smrg func_warning "\`-release' is ignored for objects" 8604ea133fd7Smrg 8605ea133fd7Smrg case $output in 8606ea133fd7Smrg *.lo) 8607ea133fd7Smrg test -n "$objs$old_deplibs" && \ 8608ea133fd7Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 8609ea133fd7Smrg 8610ea133fd7Smrg libobj=$output 8611ea133fd7Smrg func_lo2o "$libobj" 8612ea133fd7Smrg obj=$func_lo2o_result 8613ea133fd7Smrg ;; 8614ea133fd7Smrg *) 8615ea133fd7Smrg libobj= 8616ea133fd7Smrg obj="$output" 8617ea133fd7Smrg ;; 8618ea133fd7Smrg esac 8619ea133fd7Smrg 8620ea133fd7Smrg # Delete the old objects. 8621ea133fd7Smrg $opt_dry_run || $RM $obj $libobj 8622ea133fd7Smrg 8623ea133fd7Smrg # Objects from convenience libraries. This assumes 8624ea133fd7Smrg # single-version convenience libraries. Whenever we create 8625ea133fd7Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 8626ea133fd7Smrg # the extraction. 8627ea133fd7Smrg reload_conv_objs= 8628ea133fd7Smrg gentop= 8629ea133fd7Smrg # reload_cmds runs $LD directly, so let us get rid of 8630ea133fd7Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 8631ea133fd7Smrg # turning comma into space.. 8632ea133fd7Smrg wl= 8633ea133fd7Smrg 8634ea133fd7Smrg if test -n "$convenience"; then 8635ea133fd7Smrg if test -n "$whole_archive_flag_spec"; then 8636ea133fd7Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 863725b89263Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 8638ea133fd7Smrg else 8639ea133fd7Smrg gentop="$output_objdir/${obj}x" 864006f32fbeSmrg func_append generated " $gentop" 8641ea133fd7Smrg 8642ea133fd7Smrg func_extract_archives $gentop $convenience 8643ea133fd7Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 8644ea133fd7Smrg fi 8645ea133fd7Smrg fi 8646a253d6aeSmrg 864706f32fbeSmrg # If we're not building shared, we need to use non_pic_objs 864806f32fbeSmrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 864906f32fbeSmrg 8650ea133fd7Smrg # Create the old-style object. 865125b89263Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8652a253d6aeSmrg 8653ea133fd7Smrg output="$obj" 8654ea133fd7Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8655a253d6aeSmrg 8656ea133fd7Smrg # Exit if we aren't doing a library object file. 8657ea133fd7Smrg if test -z "$libobj"; then 8658ea133fd7Smrg if test -n "$gentop"; then 8659ea133fd7Smrg func_show_eval '${RM}r "$gentop"' 8660ea133fd7Smrg fi 8661a253d6aeSmrg 8662ea133fd7Smrg exit $EXIT_SUCCESS 8663ea133fd7Smrg fi 8664a253d6aeSmrg 8665ea133fd7Smrg if test "$build_libtool_libs" != yes; then 8666ea133fd7Smrg if test -n "$gentop"; then 8667ea133fd7Smrg func_show_eval '${RM}r "$gentop"' 8668ea133fd7Smrg fi 8669a253d6aeSmrg 8670ea133fd7Smrg # Create an invalid libtool object if no PIC, so that we don't 8671ea133fd7Smrg # accidentally link it into a program. 8672ea133fd7Smrg # $show "echo timestamp > $libobj" 8673ea133fd7Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 8674ea133fd7Smrg exit $EXIT_SUCCESS 8675ea133fd7Smrg fi 8676a253d6aeSmrg 8677ea133fd7Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 8678ea133fd7Smrg # Only do commands if we really have different PIC objects. 8679ea133fd7Smrg reload_objs="$libobjs $reload_conv_objs" 8680ea133fd7Smrg output="$libobj" 8681ea133fd7Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8682a253d6aeSmrg fi 8683a253d6aeSmrg 8684ea133fd7Smrg if test -n "$gentop"; then 8685ea133fd7Smrg func_show_eval '${RM}r "$gentop"' 8686ea133fd7Smrg fi 8687a253d6aeSmrg 8688ea133fd7Smrg exit $EXIT_SUCCESS 8689ea133fd7Smrg ;; 8690a253d6aeSmrg 8691ea133fd7Smrg prog) 8692ea133fd7Smrg case $host in 8693ea133fd7Smrg *cygwin*) func_stripname '' '.exe' "$output" 8694ea133fd7Smrg output=$func_stripname_result.exe;; 8695a253d6aeSmrg esac 8696ea133fd7Smrg test -n "$vinfo" && \ 8697ea133fd7Smrg func_warning "\`-version-info' is ignored for programs" 8698a253d6aeSmrg 8699ea133fd7Smrg test -n "$release" && \ 8700ea133fd7Smrg func_warning "\`-release' is ignored for programs" 8701a253d6aeSmrg 8702ea133fd7Smrg test "$preload" = yes \ 8703ea133fd7Smrg && test "$dlopen_support" = unknown \ 8704ea133fd7Smrg && test "$dlopen_self" = unknown \ 8705ea133fd7Smrg && test "$dlopen_self_static" = unknown && \ 8706ea133fd7Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 8707a253d6aeSmrg 8708ea133fd7Smrg case $host in 8709ea133fd7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 8710ea133fd7Smrg # On Rhapsody replace the C library is the System framework 871125b89263Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 871225b89263Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8713a253d6aeSmrg ;; 8714a253d6aeSmrg esac 8715a253d6aeSmrg 8716ea133fd7Smrg case $host in 8717ea133fd7Smrg *-*-darwin*) 8718ea133fd7Smrg # Don't allow lazy linking, it breaks C++ global constructors 8719ea133fd7Smrg # But is supposedly fixed on 10.4 or later (yay!). 8720ea133fd7Smrg if test "$tagname" = CXX ; then 8721ea133fd7Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 8722ea133fd7Smrg 10.[0123]) 872306f32fbeSmrg func_append compile_command " ${wl}-bind_at_load" 872406f32fbeSmrg func_append finalize_command " ${wl}-bind_at_load" 8725ea133fd7Smrg ;; 8726ea133fd7Smrg esac 8727ea133fd7Smrg fi 8728ea133fd7Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 872925b89263Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 873025b89263Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8731a253d6aeSmrg ;; 8732a253d6aeSmrg esac 8733a253d6aeSmrg 8734a253d6aeSmrg 8735ea133fd7Smrg # move library search paths that coincide with paths to not yet 8736ea133fd7Smrg # installed libraries to the beginning of the library search list 8737ea133fd7Smrg new_libs= 8738ea133fd7Smrg for path in $notinst_path; do 8739ea133fd7Smrg case " $new_libs " in 8740ea133fd7Smrg *" -L$path/$objdir "*) ;; 8741a253d6aeSmrg *) 8742ea133fd7Smrg case " $compile_deplibs " in 8743ea133fd7Smrg *" -L$path/$objdir "*) 874406f32fbeSmrg func_append new_libs " -L$path/$objdir" ;; 8745ea133fd7Smrg esac 8746a253d6aeSmrg ;; 8747a253d6aeSmrg esac 8748a253d6aeSmrg done 8749ea133fd7Smrg for deplib in $compile_deplibs; do 8750ea133fd7Smrg case $deplib in 8751ea133fd7Smrg -L*) 8752ea133fd7Smrg case " $new_libs " in 8753ea133fd7Smrg *" $deplib "*) ;; 875406f32fbeSmrg *) func_append new_libs " $deplib" ;; 8755ea133fd7Smrg esac 8756ea133fd7Smrg ;; 875706f32fbeSmrg *) func_append new_libs " $deplib" ;; 8758ea133fd7Smrg esac 8759ea133fd7Smrg done 8760ea133fd7Smrg compile_deplibs="$new_libs" 8761a253d6aeSmrg 8762a253d6aeSmrg 876306f32fbeSmrg func_append compile_command " $compile_deplibs" 876406f32fbeSmrg func_append finalize_command " $finalize_deplibs" 8765a253d6aeSmrg 8766ea133fd7Smrg if test -n "$rpath$xrpath"; then 8767ea133fd7Smrg # If the user specified any rpath flags, then add them. 8768ea133fd7Smrg for libdir in $rpath $xrpath; do 8769ea133fd7Smrg # This is the magic to use -rpath. 8770ea133fd7Smrg case "$finalize_rpath " in 8771ea133fd7Smrg *" $libdir "*) ;; 877206f32fbeSmrg *) func_append finalize_rpath " $libdir" ;; 8773ea133fd7Smrg esac 8774ea133fd7Smrg done 8775ea133fd7Smrg fi 8776a253d6aeSmrg 8777ea133fd7Smrg # Now hardcode the library paths 8778ea133fd7Smrg rpath= 8779ea133fd7Smrg hardcode_libdirs= 8780ea133fd7Smrg for libdir in $compile_rpath $finalize_rpath; do 8781ea133fd7Smrg if test -n "$hardcode_libdir_flag_spec"; then 8782ea133fd7Smrg if test -n "$hardcode_libdir_separator"; then 8783ea133fd7Smrg if test -z "$hardcode_libdirs"; then 8784ea133fd7Smrg hardcode_libdirs="$libdir" 8785ea133fd7Smrg else 8786ea133fd7Smrg # Just accumulate the unique libdirs. 8787ea133fd7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8788ea133fd7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8789ea133fd7Smrg ;; 8790ea133fd7Smrg *) 879106f32fbeSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8792ea133fd7Smrg ;; 8793ea133fd7Smrg esac 8794ea133fd7Smrg fi 8795ea133fd7Smrg else 8796ea133fd7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 879706f32fbeSmrg func_append rpath " $flag" 8798ea133fd7Smrg fi 8799ea133fd7Smrg elif test -n "$runpath_var"; then 8800ea133fd7Smrg case "$perm_rpath " in 8801a253d6aeSmrg *" $libdir "*) ;; 880206f32fbeSmrg *) func_append perm_rpath " $libdir" ;; 8803a253d6aeSmrg esac 8804ea133fd7Smrg fi 8805ea133fd7Smrg case $host in 8806ea133fd7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 8807ea133fd7Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 8808ea133fd7Smrg case :$dllsearchpath: in 8809ea133fd7Smrg *":$libdir:"*) ;; 8810ea133fd7Smrg ::) dllsearchpath=$libdir;; 881106f32fbeSmrg *) func_append dllsearchpath ":$libdir";; 8812ea133fd7Smrg esac 8813ea133fd7Smrg case :$dllsearchpath: in 8814ea133fd7Smrg *":$testbindir:"*) ;; 8815ea133fd7Smrg ::) dllsearchpath=$testbindir;; 881606f32fbeSmrg *) func_append dllsearchpath ":$testbindir";; 8817ea133fd7Smrg esac 8818ea133fd7Smrg ;; 8819ea133fd7Smrg esac 8820ea133fd7Smrg done 8821ea133fd7Smrg # Substitute the hardcoded libdirs into the rpath. 8822ea133fd7Smrg if test -n "$hardcode_libdir_separator" && 8823ea133fd7Smrg test -n "$hardcode_libdirs"; then 8824ea133fd7Smrg libdir="$hardcode_libdirs" 8825ea133fd7Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 8826ea133fd7Smrg fi 8827ea133fd7Smrg compile_rpath="$rpath" 8828ea133fd7Smrg 8829ea133fd7Smrg rpath= 8830ea133fd7Smrg hardcode_libdirs= 8831ea133fd7Smrg for libdir in $finalize_rpath; do 8832ea133fd7Smrg if test -n "$hardcode_libdir_flag_spec"; then 8833ea133fd7Smrg if test -n "$hardcode_libdir_separator"; then 8834ea133fd7Smrg if test -z "$hardcode_libdirs"; then 8835ea133fd7Smrg hardcode_libdirs="$libdir" 8836ea133fd7Smrg else 8837ea133fd7Smrg # Just accumulate the unique libdirs. 8838ea133fd7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8839ea133fd7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8840ea133fd7Smrg ;; 8841ea133fd7Smrg *) 884206f32fbeSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8843ea133fd7Smrg ;; 8844ea133fd7Smrg esac 8845ea133fd7Smrg fi 8846ea133fd7Smrg else 8847ea133fd7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 884806f32fbeSmrg func_append rpath " $flag" 8849ea133fd7Smrg fi 8850ea133fd7Smrg elif test -n "$runpath_var"; then 8851ea133fd7Smrg case "$finalize_perm_rpath " in 8852a253d6aeSmrg *" $libdir "*) ;; 885306f32fbeSmrg *) func_append finalize_perm_rpath " $libdir" ;; 8854a253d6aeSmrg esac 8855a253d6aeSmrg fi 8856ea133fd7Smrg done 8857ea133fd7Smrg # Substitute the hardcoded libdirs into the rpath. 8858ea133fd7Smrg if test -n "$hardcode_libdir_separator" && 8859ea133fd7Smrg test -n "$hardcode_libdirs"; then 8860ea133fd7Smrg libdir="$hardcode_libdirs" 8861ea133fd7Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 8862ea133fd7Smrg fi 8863ea133fd7Smrg finalize_rpath="$rpath" 8864a253d6aeSmrg 8865ea133fd7Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 8866ea133fd7Smrg # Transform all the library objects into standard objects. 886725b89263Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 886825b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8869ea133fd7Smrg fi 8870a253d6aeSmrg 8871ea133fd7Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8872a253d6aeSmrg 8873ea133fd7Smrg # template prelinking step 8874ea133fd7Smrg if test -n "$prelink_cmds"; then 8875ea133fd7Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 8876ea133fd7Smrg fi 8877a253d6aeSmrg 8878ea133fd7Smrg wrappers_required=yes 8879ea133fd7Smrg case $host in 888025b89263Smrg *cegcc* | *mingw32ce*) 888125b89263Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 888225b89263Smrg wrappers_required=no 888325b89263Smrg ;; 8884ea133fd7Smrg *cygwin* | *mingw* ) 8885ea133fd7Smrg if test "$build_libtool_libs" != yes; then 8886ea133fd7Smrg wrappers_required=no 8887ea133fd7Smrg fi 8888ea133fd7Smrg ;; 8889ea133fd7Smrg *) 8890ea133fd7Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8891ea133fd7Smrg wrappers_required=no 8892ea133fd7Smrg fi 8893ea133fd7Smrg ;; 8894ea133fd7Smrg esac 8895ea133fd7Smrg if test "$wrappers_required" = no; then 8896ea133fd7Smrg # Replace the output file specification. 889725b89263Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8898ea133fd7Smrg link_command="$compile_command$compile_rpath" 8899a253d6aeSmrg 8900ea133fd7Smrg # We have no uninstalled library dependencies, so finalize right now. 8901ea133fd7Smrg exit_status=0 8902ea133fd7Smrg func_show_eval "$link_command" 'exit_status=$?' 8903a253d6aeSmrg 890406f32fbeSmrg if test -n "$postlink_cmds"; then 890506f32fbeSmrg func_to_tool_file "$output" 890606f32fbeSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 890706f32fbeSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 890806f32fbeSmrg fi 890906f32fbeSmrg 8910ea133fd7Smrg # Delete the generated files. 8911ea133fd7Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 8912ea133fd7Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8913ea133fd7Smrg fi 8914a253d6aeSmrg 8915ea133fd7Smrg exit $exit_status 8916ea133fd7Smrg fi 8917a253d6aeSmrg 8918ea133fd7Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 8919ea133fd7Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 8920ea133fd7Smrg fi 8921ea133fd7Smrg if test -n "$finalize_shlibpath"; then 8922ea133fd7Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 8923ea133fd7Smrg fi 8924a253d6aeSmrg 8925ea133fd7Smrg compile_var= 8926ea133fd7Smrg finalize_var= 8927ea133fd7Smrg if test -n "$runpath_var"; then 8928ea133fd7Smrg if test -n "$perm_rpath"; then 8929ea133fd7Smrg # We should set the runpath_var. 8930ea133fd7Smrg rpath= 8931ea133fd7Smrg for dir in $perm_rpath; do 893206f32fbeSmrg func_append rpath "$dir:" 8933a253d6aeSmrg done 8934ea133fd7Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8935a253d6aeSmrg fi 8936ea133fd7Smrg if test -n "$finalize_perm_rpath"; then 8937ea133fd7Smrg # We should set the runpath_var. 8938ea133fd7Smrg rpath= 8939ea133fd7Smrg for dir in $finalize_perm_rpath; do 894006f32fbeSmrg func_append rpath "$dir:" 8941ea133fd7Smrg done 8942ea133fd7Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8943ea133fd7Smrg fi 8944ea133fd7Smrg fi 8945a253d6aeSmrg 8946ea133fd7Smrg if test "$no_install" = yes; then 8947ea133fd7Smrg # We don't need to create a wrapper script. 8948ea133fd7Smrg link_command="$compile_var$compile_command$compile_rpath" 8949ea133fd7Smrg # Replace the output file specification. 895025b89263Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8951ea133fd7Smrg # Delete the old output file. 8952ea133fd7Smrg $opt_dry_run || $RM $output 8953ea133fd7Smrg # Link the executable and exit 8954ea133fd7Smrg func_show_eval "$link_command" 'exit $?' 895506f32fbeSmrg 895606f32fbeSmrg if test -n "$postlink_cmds"; then 895706f32fbeSmrg func_to_tool_file "$output" 895806f32fbeSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 895906f32fbeSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 896006f32fbeSmrg fi 896106f32fbeSmrg 8962ea133fd7Smrg exit $EXIT_SUCCESS 8963ea133fd7Smrg fi 8964a253d6aeSmrg 8965ea133fd7Smrg if test "$hardcode_action" = relink; then 8966ea133fd7Smrg # Fast installation is not supported 8967ea133fd7Smrg link_command="$compile_var$compile_command$compile_rpath" 8968ea133fd7Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8969a253d6aeSmrg 8970ea133fd7Smrg func_warning "this platform does not like uninstalled shared libraries" 8971ea133fd7Smrg func_warning "\`$output' will be relinked during installation" 8972ea133fd7Smrg else 8973ea133fd7Smrg if test "$fast_install" != no; then 8974ea133fd7Smrg link_command="$finalize_var$compile_command$finalize_rpath" 8975ea133fd7Smrg if test "$fast_install" = yes; then 897625b89263Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 8977ea133fd7Smrg else 8978ea133fd7Smrg # fast_install is set to needless 8979ea133fd7Smrg relink_command= 8980ea133fd7Smrg fi 8981a253d6aeSmrg else 8982ea133fd7Smrg link_command="$compile_var$compile_command$compile_rpath" 8983ea133fd7Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8984a253d6aeSmrg fi 8985ea133fd7Smrg fi 8986a253d6aeSmrg 8987ea133fd7Smrg # Replace the output file specification. 898825b89263Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8989a253d6aeSmrg 8990ea133fd7Smrg # Delete the old output files. 8991ea133fd7Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8992a253d6aeSmrg 8993ea133fd7Smrg func_show_eval "$link_command" 'exit $?' 8994a253d6aeSmrg 899506f32fbeSmrg if test -n "$postlink_cmds"; then 899606f32fbeSmrg func_to_tool_file "$output_objdir/$outputname" 899706f32fbeSmrg 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'` 899806f32fbeSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 899906f32fbeSmrg fi 900006f32fbeSmrg 9001ea133fd7Smrg # Now create the wrapper script. 9002ea133fd7Smrg func_verbose "creating $output" 9003a253d6aeSmrg 9004ea133fd7Smrg # Quote the relink command for shipping. 9005ea133fd7Smrg if test -n "$relink_command"; then 9006ea133fd7Smrg # Preserve any variables that may affect compiler behavior 9007ea133fd7Smrg for var in $variables_saved_for_relink; do 9008ea133fd7Smrg if eval test -z \"\${$var+set}\"; then 9009ea133fd7Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9010ea133fd7Smrg elif eval var_value=\$$var; test -z "$var_value"; then 9011ea133fd7Smrg relink_command="$var=; export $var; $relink_command" 9012ea133fd7Smrg else 9013ea133fd7Smrg func_quote_for_eval "$var_value" 9014ea133fd7Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9015ea133fd7Smrg fi 9016ea133fd7Smrg done 9017ea133fd7Smrg relink_command="(cd `pwd`; $relink_command)" 901825b89263Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9019ea133fd7Smrg fi 9020a253d6aeSmrg 9021ea133fd7Smrg # Only actually do things if not in dry run mode. 9022ea133fd7Smrg $opt_dry_run || { 9023ea133fd7Smrg # win32 will think the script is a binary if it has 9024ea133fd7Smrg # a .exe suffix, so we strip it off here. 9025ea133fd7Smrg case $output in 9026ea133fd7Smrg *.exe) func_stripname '' '.exe' "$output" 9027ea133fd7Smrg output=$func_stripname_result ;; 9028ea133fd7Smrg esac 9029ea133fd7Smrg # test for cygwin because mv fails w/o .exe extensions 9030a253d6aeSmrg case $host in 9031ea133fd7Smrg *cygwin*) 9032ea133fd7Smrg exeext=.exe 9033ea133fd7Smrg func_stripname '' '.exe' "$outputname" 9034ea133fd7Smrg outputname=$func_stripname_result ;; 9035ea133fd7Smrg *) exeext= ;; 9036a253d6aeSmrg esac 9037ea133fd7Smrg case $host in 9038ea133fd7Smrg *cygwin* | *mingw* ) 9039ea133fd7Smrg func_dirname_and_basename "$output" "" "." 9040ea133fd7Smrg output_name=$func_basename_result 9041ea133fd7Smrg output_path=$func_dirname_result 9042ea133fd7Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 9043ea133fd7Smrg cwrapper="$output_path/$output_name.exe" 9044ea133fd7Smrg $RM $cwrappersource $cwrapper 9045ea133fd7Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 9046ea133fd7Smrg 9047ea133fd7Smrg func_emit_cwrapperexe_src > $cwrappersource 9048ea133fd7Smrg 9049ea133fd7Smrg # The wrapper executable is built using the $host compiler, 9050ea133fd7Smrg # because it contains $host paths and files. If cross- 9051ea133fd7Smrg # compiling, it, like the target executable, must be 9052ea133fd7Smrg # executed on the $host or under an emulation environment. 9053ea133fd7Smrg $opt_dry_run || { 9054ea133fd7Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 9055ea133fd7Smrg $STRIP $cwrapper 9056ea133fd7Smrg } 9057a253d6aeSmrg 9058ea133fd7Smrg # Now, create the wrapper script for func_source use: 9059ea133fd7Smrg func_ltwrapper_scriptname $cwrapper 9060ea133fd7Smrg $RM $func_ltwrapper_scriptname_result 9061ea133fd7Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 9062ea133fd7Smrg $opt_dry_run || { 9063ea133fd7Smrg # note: this script will not be executed, so do not chmod. 9064ea133fd7Smrg if test "x$build" = "x$host" ; then 9065ea133fd7Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 9066a253d6aeSmrg else 9067ea133fd7Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 9068a253d6aeSmrg fi 9069ea133fd7Smrg } 9070ea133fd7Smrg ;; 9071ea133fd7Smrg * ) 9072ea133fd7Smrg $RM $output 9073ea133fd7Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9074a253d6aeSmrg 9075ea133fd7Smrg func_emit_wrapper no > $output 9076ea133fd7Smrg chmod +x $output 9077a253d6aeSmrg ;; 9078a253d6aeSmrg esac 9079ea133fd7Smrg } 9080ea133fd7Smrg exit $EXIT_SUCCESS 9081ea133fd7Smrg ;; 9082ea133fd7Smrg esac 9083a253d6aeSmrg 9084ea133fd7Smrg # See if we need to build an old-fashioned archive. 9085ea133fd7Smrg for oldlib in $oldlibs; do 9086a253d6aeSmrg 9087ea133fd7Smrg if test "$build_libtool_libs" = convenience; then 9088ea133fd7Smrg oldobjs="$libobjs_save $symfileobj" 9089ea133fd7Smrg addlibs="$convenience" 9090ea133fd7Smrg build_libtool_libs=no 9091ea133fd7Smrg else 9092ea133fd7Smrg if test "$build_libtool_libs" = module; then 9093ea133fd7Smrg oldobjs="$libobjs_save" 9094ea133fd7Smrg build_libtool_libs=no 9095ea133fd7Smrg else 9096ea133fd7Smrg oldobjs="$old_deplibs $non_pic_objects" 9097ea133fd7Smrg if test "$preload" = yes && test -f "$symfileobj"; then 909806f32fbeSmrg func_append oldobjs " $symfileobj" 9099ea133fd7Smrg fi 9100ea133fd7Smrg fi 9101ea133fd7Smrg addlibs="$old_convenience" 9102a253d6aeSmrg fi 9103a253d6aeSmrg 9104ea133fd7Smrg if test -n "$addlibs"; then 9105ea133fd7Smrg gentop="$output_objdir/${outputname}x" 910606f32fbeSmrg func_append generated " $gentop" 9107a253d6aeSmrg 9108ea133fd7Smrg func_extract_archives $gentop $addlibs 910906f32fbeSmrg func_append oldobjs " $func_extract_archives_result" 9110ea133fd7Smrg fi 9111a253d6aeSmrg 9112ea133fd7Smrg # Do each command in the archive commands. 9113ea133fd7Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 9114ea133fd7Smrg cmds=$old_archive_from_new_cmds 9115ea133fd7Smrg else 9116a253d6aeSmrg 9117ea133fd7Smrg # Add any objects from preloaded convenience libraries 9118ea133fd7Smrg if test -n "$dlprefiles"; then 9119ea133fd7Smrg gentop="$output_objdir/${outputname}x" 912006f32fbeSmrg func_append generated " $gentop" 9121a253d6aeSmrg 9122ea133fd7Smrg func_extract_archives $gentop $dlprefiles 912306f32fbeSmrg func_append oldobjs " $func_extract_archives_result" 9124ea133fd7Smrg fi 9125a253d6aeSmrg 9126ea133fd7Smrg # POSIX demands no paths to be encoded in archives. We have 9127ea133fd7Smrg # to avoid creating archives with duplicate basenames if we 9128ea133fd7Smrg # might have to extract them afterwards, e.g., when creating a 9129ea133fd7Smrg # static archive out of a convenience library, or when linking 9130ea133fd7Smrg # the entirety of a libtool archive into another (currently 9131ea133fd7Smrg # not supported by libtool). 9132ea133fd7Smrg if (for obj in $oldobjs 9133ea133fd7Smrg do 9134ea133fd7Smrg func_basename "$obj" 9135ea133fd7Smrg $ECHO "$func_basename_result" 9136ea133fd7Smrg done | sort | sort -uc >/dev/null 2>&1); then 9137ea133fd7Smrg : 9138ea133fd7Smrg else 913925b89263Smrg echo "copying selected object files to avoid basename conflicts..." 9140ea133fd7Smrg gentop="$output_objdir/${outputname}x" 914106f32fbeSmrg func_append generated " $gentop" 9142ea133fd7Smrg func_mkdir_p "$gentop" 9143ea133fd7Smrg save_oldobjs=$oldobjs 9144ea133fd7Smrg oldobjs= 9145ea133fd7Smrg counter=1 9146ea133fd7Smrg for obj in $save_oldobjs 9147ea133fd7Smrg do 9148ea133fd7Smrg func_basename "$obj" 9149ea133fd7Smrg objbase="$func_basename_result" 9150ea133fd7Smrg case " $oldobjs " in 9151ea133fd7Smrg " ") oldobjs=$obj ;; 9152ea133fd7Smrg *[\ /]"$objbase "*) 9153ea133fd7Smrg while :; do 9154ea133fd7Smrg # Make sure we don't pick an alternate name that also 9155ea133fd7Smrg # overlaps. 9156ea133fd7Smrg newobj=lt$counter-$objbase 9157ea133fd7Smrg func_arith $counter + 1 9158ea133fd7Smrg counter=$func_arith_result 9159ea133fd7Smrg case " $oldobjs " in 9160ea133fd7Smrg *[\ /]"$newobj "*) ;; 9161ea133fd7Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 9162ea133fd7Smrg esac 9163ea133fd7Smrg done 9164ea133fd7Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 916506f32fbeSmrg func_append oldobjs " $gentop/$newobj" 9166ea133fd7Smrg ;; 916706f32fbeSmrg *) func_append oldobjs " $obj" ;; 9168ea133fd7Smrg esac 9169a253d6aeSmrg done 9170a253d6aeSmrg fi 917157ee1794Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 917257ee1794Smrg tool_oldlib=$func_to_tool_file_result 9173ea133fd7Smrg eval cmds=\"$old_archive_cmds\" 9174a253d6aeSmrg 9175ea133fd7Smrg func_len " $cmds" 9176ea133fd7Smrg len=$func_len_result 9177ea133fd7Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9178ea133fd7Smrg cmds=$old_archive_cmds 917906f32fbeSmrg elif test -n "$archiver_list_spec"; then 918006f32fbeSmrg func_verbose "using command file archive linking..." 918106f32fbeSmrg for obj in $oldobjs 918206f32fbeSmrg do 918306f32fbeSmrg func_to_tool_file "$obj" 918406f32fbeSmrg $ECHO "$func_to_tool_file_result" 918506f32fbeSmrg done > $output_objdir/$libname.libcmd 918606f32fbeSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 918706f32fbeSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 918806f32fbeSmrg cmds=$old_archive_cmds 9189ea133fd7Smrg else 9190ea133fd7Smrg # the command line is too long to link in one step, link in parts 9191ea133fd7Smrg func_verbose "using piecewise archive linking..." 9192ea133fd7Smrg save_RANLIB=$RANLIB 9193ea133fd7Smrg RANLIB=: 9194ea133fd7Smrg objlist= 9195ea133fd7Smrg concat_cmds= 9196ea133fd7Smrg save_oldobjs=$oldobjs 9197ea133fd7Smrg oldobjs= 9198ea133fd7Smrg # Is there a better way of finding the last object in the list? 9199ea133fd7Smrg for obj in $save_oldobjs 9200ea133fd7Smrg do 9201ea133fd7Smrg last_oldobj=$obj 9202ea133fd7Smrg done 9203ea133fd7Smrg eval test_cmds=\"$old_archive_cmds\" 9204ea133fd7Smrg func_len " $test_cmds" 9205ea133fd7Smrg len0=$func_len_result 9206ea133fd7Smrg len=$len0 9207ea133fd7Smrg for obj in $save_oldobjs 9208ea133fd7Smrg do 9209ea133fd7Smrg func_len " $obj" 9210ea133fd7Smrg func_arith $len + $func_len_result 9211ea133fd7Smrg len=$func_arith_result 9212ea133fd7Smrg func_append objlist " $obj" 9213ea133fd7Smrg if test "$len" -lt "$max_cmd_len"; then 9214ea133fd7Smrg : 9215ea133fd7Smrg else 9216ea133fd7Smrg # the above command should be used before it gets too long 9217ea133fd7Smrg oldobjs=$objlist 9218ea133fd7Smrg if test "$obj" = "$last_oldobj" ; then 9219ea133fd7Smrg RANLIB=$save_RANLIB 9220ea133fd7Smrg fi 9221ea133fd7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9222ea133fd7Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 9223ea133fd7Smrg objlist= 9224ea133fd7Smrg len=$len0 9225ea133fd7Smrg fi 9226ea133fd7Smrg done 9227ea133fd7Smrg RANLIB=$save_RANLIB 9228ea133fd7Smrg oldobjs=$objlist 9229ea133fd7Smrg if test "X$oldobjs" = "X" ; then 9230ea133fd7Smrg eval cmds=\"\$concat_cmds\" 9231ea133fd7Smrg else 9232ea133fd7Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 9233ea133fd7Smrg fi 9234ea133fd7Smrg fi 9235ea133fd7Smrg fi 9236ea133fd7Smrg func_execute_cmds "$cmds" 'exit $?' 9237a253d6aeSmrg done 9238a253d6aeSmrg 9239ea133fd7Smrg test -n "$generated" && \ 9240ea133fd7Smrg func_show_eval "${RM}r$generated" 9241a253d6aeSmrg 9242ea133fd7Smrg # Now create the libtool archive. 9243ea133fd7Smrg case $output in 9244ea133fd7Smrg *.la) 9245ea133fd7Smrg old_library= 9246ea133fd7Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 9247ea133fd7Smrg func_verbose "creating $output" 9248a253d6aeSmrg 9249ea133fd7Smrg # Preserve any variables that may affect compiler behavior 9250ea133fd7Smrg for var in $variables_saved_for_relink; do 9251ea133fd7Smrg if eval test -z \"\${$var+set}\"; then 9252ea133fd7Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9253ea133fd7Smrg elif eval var_value=\$$var; test -z "$var_value"; then 9254ea133fd7Smrg relink_command="$var=; export $var; $relink_command" 9255a253d6aeSmrg else 9256ea133fd7Smrg func_quote_for_eval "$var_value" 9257ea133fd7Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9258a253d6aeSmrg fi 9259ea133fd7Smrg done 9260ea133fd7Smrg # Quote the link command for shipping. 9261ea133fd7Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 926225b89263Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9263ea133fd7Smrg if test "$hardcode_automatic" = yes ; then 9264ea133fd7Smrg relink_command= 9265ea133fd7Smrg fi 9266a253d6aeSmrg 9267ea133fd7Smrg # Only create the output if not a dry run. 9268ea133fd7Smrg $opt_dry_run || { 9269ea133fd7Smrg for installed in no yes; do 9270ea133fd7Smrg if test "$installed" = yes; then 9271ea133fd7Smrg if test -z "$install_libdir"; then 9272ea133fd7Smrg break 9273ea133fd7Smrg fi 9274ea133fd7Smrg output="$output_objdir/$outputname"i 9275ea133fd7Smrg # Replace all uninstalled libtool libraries with the installed ones 9276ea133fd7Smrg newdependency_libs= 9277ea133fd7Smrg for deplib in $dependency_libs; do 9278ea133fd7Smrg case $deplib in 9279ea133fd7Smrg *.la) 9280ea133fd7Smrg func_basename "$deplib" 9281ea133fd7Smrg name="$func_basename_result" 928257ee1794Smrg func_resolve_sysroot "$deplib" 928357ee1794Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 9284ea133fd7Smrg test -z "$libdir" && \ 9285ea133fd7Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 928606f32fbeSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 928706f32fbeSmrg ;; 928806f32fbeSmrg -L*) 928906f32fbeSmrg func_stripname -L '' "$deplib" 929006f32fbeSmrg func_replace_sysroot "$func_stripname_result" 929106f32fbeSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 929206f32fbeSmrg ;; 929306f32fbeSmrg -R*) 929406f32fbeSmrg func_stripname -R '' "$deplib" 929506f32fbeSmrg func_replace_sysroot "$func_stripname_result" 929606f32fbeSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 9297ea133fd7Smrg ;; 929806f32fbeSmrg *) func_append newdependency_libs " $deplib" ;; 9299ea133fd7Smrg esac 9300ea133fd7Smrg done 9301ea133fd7Smrg dependency_libs="$newdependency_libs" 9302ea133fd7Smrg newdlfiles= 9303ea133fd7Smrg 9304ea133fd7Smrg for lib in $dlfiles; do 9305ea133fd7Smrg case $lib in 9306ea133fd7Smrg *.la) 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 newdlfiles " ${lt_sysroot:+=}$libdir/$name" 9313ea133fd7Smrg ;; 931406f32fbeSmrg *) func_append newdlfiles " $lib" ;; 9315ea133fd7Smrg esac 9316ea133fd7Smrg done 9317ea133fd7Smrg dlfiles="$newdlfiles" 9318ea133fd7Smrg newdlprefiles= 9319ea133fd7Smrg for lib in $dlprefiles; do 9320ea133fd7Smrg case $lib in 9321ea133fd7Smrg *.la) 9322ea133fd7Smrg # Only pass preopened files to the pseudo-archive (for 9323ea133fd7Smrg # eventual linking with the app. that links it) if we 9324ea133fd7Smrg # didn't already link the preopened objects directly into 9325ea133fd7Smrg # the library: 9326ea133fd7Smrg func_basename "$lib" 9327ea133fd7Smrg name="$func_basename_result" 9328ea133fd7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9329ea133fd7Smrg test -z "$libdir" && \ 9330ea133fd7Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 933106f32fbeSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 9332ea133fd7Smrg ;; 9333ea133fd7Smrg esac 9334ea133fd7Smrg done 9335ea133fd7Smrg dlprefiles="$newdlprefiles" 9336ea133fd7Smrg else 9337ea133fd7Smrg newdlfiles= 9338ea133fd7Smrg for lib in $dlfiles; do 9339ea133fd7Smrg case $lib in 9340ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9341ea133fd7Smrg *) abs=`pwd`"/$lib" ;; 9342ea133fd7Smrg esac 934306f32fbeSmrg func_append newdlfiles " $abs" 9344ea133fd7Smrg done 9345ea133fd7Smrg dlfiles="$newdlfiles" 9346ea133fd7Smrg newdlprefiles= 9347ea133fd7Smrg for lib in $dlprefiles; do 9348ea133fd7Smrg case $lib in 9349ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9350ea133fd7Smrg *) abs=`pwd`"/$lib" ;; 9351ea133fd7Smrg esac 935206f32fbeSmrg func_append newdlprefiles " $abs" 9353ea133fd7Smrg done 9354ea133fd7Smrg dlprefiles="$newdlprefiles" 9355ea133fd7Smrg fi 9356ea133fd7Smrg $RM $output 9357ea133fd7Smrg # place dlname in correct position for cygwin 935825b89263Smrg # In fact, it would be nice if we could use this code for all target 935925b89263Smrg # systems that can't hard-code library paths into their executables 936025b89263Smrg # and that have no shared library path variable independent of PATH, 936125b89263Smrg # but it turns out we can't easily determine that from inspecting 936225b89263Smrg # libtool variables, so we have to hard-code the OSs to which it 936325b89263Smrg # applies here; at the moment, that means platforms that use the PE 936425b89263Smrg # object format with DLL files. See the long comment at the top of 936525b89263Smrg # tests/bindir.at for full details. 9366ea133fd7Smrg tdlname=$dlname 9367ea133fd7Smrg case $host,$output,$installed,$module,$dlname in 936825b89263Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 936925b89263Smrg # If a -bindir argument was supplied, place the dll there. 937025b89263Smrg if test "x$bindir" != x ; 937125b89263Smrg then 937225b89263Smrg func_relative_path "$install_libdir" "$bindir" 937325b89263Smrg tdlname=$func_relative_path_result$dlname 937425b89263Smrg else 937525b89263Smrg # Otherwise fall back on heuristic. 937625b89263Smrg tdlname=../bin/$dlname 937725b89263Smrg fi 937825b89263Smrg ;; 9379ea133fd7Smrg esac 9380ea133fd7Smrg $ECHO > $output "\ 9381ea133fd7Smrg# $outputname - a libtool library file 9382ea133fd7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 9383ea133fd7Smrg# 9384ea133fd7Smrg# Please DO NOT delete this file! 9385ea133fd7Smrg# It is necessary for linking the library. 9386a253d6aeSmrg 9387ea133fd7Smrg# The name that we can dlopen(3). 9388ea133fd7Smrgdlname='$tdlname' 9389a253d6aeSmrg 9390ea133fd7Smrg# Names of this library. 9391ea133fd7Smrglibrary_names='$library_names' 9392a253d6aeSmrg 9393ea133fd7Smrg# The name of the static archive. 9394ea133fd7Smrgold_library='$old_library' 9395a253d6aeSmrg 9396ea133fd7Smrg# Linker flags that can not go in dependency_libs. 9397ea133fd7Smrginherited_linker_flags='$new_inherited_linker_flags' 9398a253d6aeSmrg 9399ea133fd7Smrg# Libraries that this one depends upon. 9400ea133fd7Smrgdependency_libs='$dependency_libs' 9401a253d6aeSmrg 9402ea133fd7Smrg# Names of additional weak libraries provided by this library 9403ea133fd7Smrgweak_library_names='$weak_libs' 9404a253d6aeSmrg 9405ea133fd7Smrg# Version information for $libname. 9406ea133fd7Smrgcurrent=$current 9407ea133fd7Smrgage=$age 9408ea133fd7Smrgrevision=$revision 9409a253d6aeSmrg 9410ea133fd7Smrg# Is this an already installed library? 9411ea133fd7Smrginstalled=$installed 9412a253d6aeSmrg 9413ea133fd7Smrg# Should we warn about portability when linking against -modules? 9414ea133fd7Smrgshouldnotlink=$module 9415a253d6aeSmrg 9416ea133fd7Smrg# Files to dlopen/dlpreopen 9417ea133fd7Smrgdlopen='$dlfiles' 9418ea133fd7Smrgdlpreopen='$dlprefiles' 9419a253d6aeSmrg 9420ea133fd7Smrg# Directory that this library needs to be installed in: 9421ea133fd7Smrglibdir='$install_libdir'" 9422ea133fd7Smrg if test "$installed" = no && test "$need_relink" = yes; then 9423ea133fd7Smrg $ECHO >> $output "\ 9424ea133fd7Smrgrelink_command=\"$relink_command\"" 9425ea133fd7Smrg fi 9426ea133fd7Smrg done 9427ea133fd7Smrg } 9428a253d6aeSmrg 9429ea133fd7Smrg # Do a symbolic link so that the libtool archive can be found in 9430ea133fd7Smrg # LD_LIBRARY_PATH before the program is installed. 9431ea133fd7Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 9432ea133fd7Smrg ;; 9433ea133fd7Smrg esac 9434ea133fd7Smrg exit $EXIT_SUCCESS 9435ea133fd7Smrg} 9436a253d6aeSmrg 943706f32fbeSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 9438ea133fd7Smrg func_mode_link ${1+"$@"} 9439a253d6aeSmrg 9440a253d6aeSmrg 9441ea133fd7Smrg# func_mode_uninstall arg... 9442ea133fd7Smrgfunc_mode_uninstall () 9443ea133fd7Smrg{ 9444ea133fd7Smrg $opt_debug 9445ea133fd7Smrg RM="$nonopt" 9446a253d6aeSmrg files= 9447a253d6aeSmrg rmforce= 9448a253d6aeSmrg exit_status=0 9449a253d6aeSmrg 9450a253d6aeSmrg # This variable tells wrapper scripts just to set variables rather 9451a253d6aeSmrg # than running their programs. 9452a253d6aeSmrg libtool_install_magic="$magic" 9453a253d6aeSmrg 9454a253d6aeSmrg for arg 9455a253d6aeSmrg do 9456a253d6aeSmrg case $arg in 945706f32fbeSmrg -f) func_append RM " $arg"; rmforce=yes ;; 945806f32fbeSmrg -*) func_append RM " $arg" ;; 945906f32fbeSmrg *) func_append files " $arg" ;; 9460a253d6aeSmrg esac 9461a253d6aeSmrg done 9462a253d6aeSmrg 9463ea133fd7Smrg test -z "$RM" && \ 9464ea133fd7Smrg func_fatal_help "you must specify an RM program" 9465a253d6aeSmrg 9466a253d6aeSmrg rmdirs= 9467a253d6aeSmrg 9468a253d6aeSmrg for file in $files; do 9469ea133fd7Smrg func_dirname "$file" "" "." 9470ea133fd7Smrg dir="$func_dirname_result" 9471ea133fd7Smrg if test "X$dir" = X.; then 947206f32fbeSmrg odir="$objdir" 9473a253d6aeSmrg else 947406f32fbeSmrg odir="$dir/$objdir" 9475a253d6aeSmrg fi 9476ea133fd7Smrg func_basename "$file" 9477ea133fd7Smrg name="$func_basename_result" 947806f32fbeSmrg test "$opt_mode" = uninstall && odir="$dir" 9479a253d6aeSmrg 948006f32fbeSmrg # Remember odir for removal later, being careful to avoid duplicates 948106f32fbeSmrg if test "$opt_mode" = clean; then 9482a253d6aeSmrg case " $rmdirs " in 948306f32fbeSmrg *" $odir "*) ;; 948406f32fbeSmrg *) func_append rmdirs " $odir" ;; 9485a253d6aeSmrg esac 9486a253d6aeSmrg fi 9487a253d6aeSmrg 9488a253d6aeSmrg # Don't error if the file doesn't exist and rm -f was used. 9489ea133fd7Smrg if { test -L "$file"; } >/dev/null 2>&1 || 9490ea133fd7Smrg { test -h "$file"; } >/dev/null 2>&1 || 9491ea133fd7Smrg test -f "$file"; then 9492a253d6aeSmrg : 9493a253d6aeSmrg elif test -d "$file"; then 9494a253d6aeSmrg exit_status=1 9495a253d6aeSmrg continue 9496a253d6aeSmrg elif test "$rmforce" = yes; then 9497a253d6aeSmrg continue 9498a253d6aeSmrg fi 9499a253d6aeSmrg 9500a253d6aeSmrg rmfiles="$file" 9501a253d6aeSmrg 9502a253d6aeSmrg case $name in 9503a253d6aeSmrg *.la) 9504a253d6aeSmrg # Possibly a libtool archive, so verify it. 9505ea133fd7Smrg if func_lalib_p "$file"; then 9506ea133fd7Smrg func_source $dir/$name 9507a253d6aeSmrg 9508a253d6aeSmrg # Delete the libtool libraries and symlinks. 9509a253d6aeSmrg for n in $library_names; do 951006f32fbeSmrg func_append rmfiles " $odir/$n" 9511a253d6aeSmrg done 951206f32fbeSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9513a253d6aeSmrg 951406f32fbeSmrg case "$opt_mode" in 9515a253d6aeSmrg clean) 951606f32fbeSmrg case " $library_names " in 9517a253d6aeSmrg *" $dlname "*) ;; 951806f32fbeSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9519a253d6aeSmrg esac 952006f32fbeSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9521a253d6aeSmrg ;; 9522a253d6aeSmrg uninstall) 9523a253d6aeSmrg if test -n "$library_names"; then 9524a253d6aeSmrg # Do each command in the postuninstall commands. 9525ea133fd7Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9526a253d6aeSmrg fi 9527a253d6aeSmrg 9528a253d6aeSmrg if test -n "$old_library"; then 9529a253d6aeSmrg # Do each command in the old_postuninstall commands. 9530ea133fd7Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9531a253d6aeSmrg fi 9532a253d6aeSmrg # FIXME: should reinstall the best remaining shared library. 9533a253d6aeSmrg ;; 9534a253d6aeSmrg esac 9535a253d6aeSmrg fi 9536a253d6aeSmrg ;; 9537a253d6aeSmrg 9538a253d6aeSmrg *.lo) 9539a253d6aeSmrg # Possibly a libtool object, so verify it. 9540ea133fd7Smrg if func_lalib_p "$file"; then 9541a253d6aeSmrg 9542a253d6aeSmrg # Read the .lo file 9543ea133fd7Smrg func_source $dir/$name 9544a253d6aeSmrg 9545a253d6aeSmrg # Add PIC object to the list of files to remove. 9546ea133fd7Smrg if test -n "$pic_object" && 9547ea133fd7Smrg test "$pic_object" != none; then 954806f32fbeSmrg func_append rmfiles " $dir/$pic_object" 9549a253d6aeSmrg fi 9550a253d6aeSmrg 9551a253d6aeSmrg # Add non-PIC object to the list of files to remove. 9552ea133fd7Smrg if test -n "$non_pic_object" && 9553ea133fd7Smrg test "$non_pic_object" != none; then 955406f32fbeSmrg func_append rmfiles " $dir/$non_pic_object" 9555a253d6aeSmrg fi 9556a253d6aeSmrg fi 9557a253d6aeSmrg ;; 9558a253d6aeSmrg 9559a253d6aeSmrg *) 956006f32fbeSmrg if test "$opt_mode" = clean ; then 9561a253d6aeSmrg noexename=$name 9562a253d6aeSmrg case $file in 9563a253d6aeSmrg *.exe) 9564ea133fd7Smrg func_stripname '' '.exe' "$file" 9565ea133fd7Smrg file=$func_stripname_result 9566ea133fd7Smrg func_stripname '' '.exe' "$name" 9567ea133fd7Smrg noexename=$func_stripname_result 9568a253d6aeSmrg # $file with .exe has already been added to rmfiles, 9569a253d6aeSmrg # add $file without .exe 957006f32fbeSmrg func_append rmfiles " $file" 9571a253d6aeSmrg ;; 9572a253d6aeSmrg esac 9573a253d6aeSmrg # Do a test to see if this is a libtool program. 9574ea133fd7Smrg if func_ltwrapper_p "$file"; then 9575ea133fd7Smrg if func_ltwrapper_executable_p "$file"; then 9576ea133fd7Smrg func_ltwrapper_scriptname "$file" 9577ea133fd7Smrg relink_command= 9578ea133fd7Smrg func_source $func_ltwrapper_scriptname_result 957906f32fbeSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 9580ea133fd7Smrg else 9581ea133fd7Smrg relink_command= 9582ea133fd7Smrg func_source $dir/$noexename 9583ea133fd7Smrg fi 9584a253d6aeSmrg 9585a253d6aeSmrg # note $name still contains .exe if it was in $file originally 9586a253d6aeSmrg # as does the version of $file that was added into $rmfiles 958706f32fbeSmrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9588a253d6aeSmrg if test "$fast_install" = yes && test -n "$relink_command"; then 958906f32fbeSmrg func_append rmfiles " $odir/lt-$name" 9590a253d6aeSmrg fi 9591a253d6aeSmrg if test "X$noexename" != "X$name" ; then 959206f32fbeSmrg func_append rmfiles " $odir/lt-${noexename}.c" 9593a253d6aeSmrg fi 9594a253d6aeSmrg fi 9595a253d6aeSmrg fi 9596a253d6aeSmrg ;; 9597a253d6aeSmrg esac 9598ea133fd7Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 9599a253d6aeSmrg done 9600a253d6aeSmrg 9601a253d6aeSmrg # Try to remove the ${objdir}s in the directories where we deleted files 9602a253d6aeSmrg for dir in $rmdirs; do 9603a253d6aeSmrg if test -d "$dir"; then 9604ea133fd7Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 9605a253d6aeSmrg fi 9606a253d6aeSmrg done 9607a253d6aeSmrg 9608a253d6aeSmrg exit $exit_status 9609ea133fd7Smrg} 9610a253d6aeSmrg 961106f32fbeSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 9612ea133fd7Smrg func_mode_uninstall ${1+"$@"} 9613a253d6aeSmrg 961406f32fbeSmrgtest -z "$opt_mode" && { 9615ea133fd7Smrg help="$generic_help" 9616ea133fd7Smrg func_fatal_help "you must specify a MODE" 9617ea133fd7Smrg} 9618ea133fd7Smrg 9619ea133fd7Smrgtest -z "$exec_cmd" && \ 962006f32fbeSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 9621a253d6aeSmrg 9622a253d6aeSmrgif test -n "$exec_cmd"; then 9623ea133fd7Smrg eval exec "$exec_cmd" 9624a253d6aeSmrg exit $EXIT_FAILURE 9625a253d6aeSmrgfi 9626a253d6aeSmrg 9627ea133fd7Smrgexit $exit_status 9628a253d6aeSmrg 9629a253d6aeSmrg 9630a253d6aeSmrg# The TAGs below are defined such that we never get into a situation 9631a253d6aeSmrg# in which we disable both kinds of libraries. Given conflicting 9632a253d6aeSmrg# choices, we go for a static library, that is the most portable, 9633a253d6aeSmrg# since we can't tell whether shared libraries were disabled because 9634a253d6aeSmrg# the user asked for that or because the platform doesn't support 9635a253d6aeSmrg# them. This is particularly important on AIX, because we don't 9636a253d6aeSmrg# support having both static and shared libraries enabled at the same 9637a253d6aeSmrg# time on that platform, so we default to a shared-only configuration. 9638a253d6aeSmrg# If a disable-shared tag is given, we'll fallback to a static-only 9639a253d6aeSmrg# configuration. But we'll never go from static-only to shared-only. 9640a253d6aeSmrg 9641a253d6aeSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 9642ea133fd7Smrgbuild_libtool_libs=no 9643ea133fd7Smrgbuild_old_libs=yes 9644a253d6aeSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 9645a253d6aeSmrg 9646a253d6aeSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 9647ea133fd7Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9648a253d6aeSmrg# ### END LIBTOOL TAG CONFIG: disable-static 9649a253d6aeSmrg 9650a253d6aeSmrg# Local Variables: 9651a253d6aeSmrg# mode:shell-script 9652a253d6aeSmrg# sh-indentation:2 9653a253d6aeSmrg# End: 9654ea133fd7Smrg# vi:sw=2 9655ea133fd7Smrg 9656