ltmain.sh revision 47e89262
147e89262Smrg# Generated from ltmain.m4sh. 247e89262Smrg 347e89262Smrg# libtool (GNU libtool) 2.2.10 447e89262Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 547e89262Smrg 65bcb6992Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 747e89262Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 847e89262Smrg# This is free software; see the source for copying conditions. There is NO 947e89262Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1047e89262Smrg 1147e89262Smrg# GNU Libtool is free software; you can redistribute it and/or modify 12bd1da9d7Smrg# it under the terms of the GNU General Public License as published by 13bd1da9d7Smrg# the Free Software Foundation; either version 2 of the License, or 14bd1da9d7Smrg# (at your option) any later version. 15bd1da9d7Smrg# 1647e89262Smrg# As a special exception to the GNU General Public License, 1747e89262Smrg# if you distribute this file as part of a program or library that 1847e89262Smrg# is built using GNU Libtool, you may include this file under the 1947e89262Smrg# same distribution terms that you use for the rest of that program. 2047e89262Smrg# 2147e89262Smrg# GNU Libtool is distributed in the hope that it will be useful, but 22bd1da9d7Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 23bd1da9d7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24bd1da9d7Smrg# General Public License for more details. 25bd1da9d7Smrg# 26bd1da9d7Smrg# You should have received a copy of the GNU General Public License 2747e89262Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 2847e89262Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 2947e89262Smrg# or obtained by writing to the Free Software Foundation, Inc., 3047e89262Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 31bd1da9d7Smrg 3247e89262Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 3347e89262Smrg# 3447e89262Smrg# Provide generalized library-building support services. 3547e89262Smrg# 3647e89262Smrg# --config show all configuration variables 3747e89262Smrg# --debug enable verbose shell tracing 3847e89262Smrg# -n, --dry-run display commands without modifying any files 3947e89262Smrg# --features display basic configuration information and exit 4047e89262Smrg# --mode=MODE use operation mode MODE 4147e89262Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 4247e89262Smrg# --quiet, --silent don't print informational messages 4347e89262Smrg# --no-quiet, --no-silent 4447e89262Smrg# print informational messages (default) 4547e89262Smrg# --tag=TAG use configuration variables from tag TAG 4647e89262Smrg# -v, --verbose print more informational messages than default 4747e89262Smrg# --no-verbose don't print the extra informational messages 4847e89262Smrg# --version print version information 4947e89262Smrg# -h, --help, --help-all print short, long, or detailed help message 5047e89262Smrg# 5147e89262Smrg# MODE must be one of the following: 5247e89262Smrg# 5347e89262Smrg# clean remove files from the build directory 5447e89262Smrg# compile compile a source file into a libtool object 5547e89262Smrg# execute automatically set library path, then run a program 5647e89262Smrg# finish complete the installation of libtool libraries 5747e89262Smrg# install install libraries or executables 5847e89262Smrg# link create a library or an executable 5947e89262Smrg# uninstall remove libraries from an installed directory 6047e89262Smrg# 6147e89262Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 6247e89262Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 6347e89262Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 6447e89262Smrg# 6547e89262Smrg# When reporting a bug, please describe a test case to reproduce it and 6647e89262Smrg# include the following information: 6747e89262Smrg# 6847e89262Smrg# host-triplet: $host 6947e89262Smrg# shell: $SHELL 7047e89262Smrg# compiler: $LTCC 7147e89262Smrg# compiler flags: $LTCFLAGS 7247e89262Smrg# linker: $LD (gnu? $with_gnu_ld) 7347e89262Smrg# $progname: (GNU libtool) 2.2.10 7447e89262Smrg# automake: $automake_version 7547e89262Smrg# autoconf: $autoconf_version 7647e89262Smrg# 7747e89262Smrg# Report bugs to <bug-libtool@gnu.org>. 78bd1da9d7Smrg 7947e89262SmrgPROGRAM=libtool 80bd1da9d7SmrgPACKAGE=libtool 8147e89262SmrgVERSION=2.2.10 8247e89262SmrgTIMESTAMP="" 8347e89262Smrgpackage_revision=1.3175 845bcb6992Smrg 8547e89262Smrg# Be Bourne compatible 865bcb6992Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 875bcb6992Smrg emulate sh 885bcb6992Smrg NULLCMD=: 895bcb6992Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 905bcb6992Smrg # is contrary to our usage. Disable this feature. 915bcb6992Smrg alias -g '${1+"$@"}'='"$@"' 92bd1da9d7Smrg setopt NO_GLOB_SUBST 935bcb6992Smrgelse 945bcb6992Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 95bd1da9d7Smrgfi 965bcb6992SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 975bcb6992SmrgDUALCASE=1; export DUALCASE # for MKS sh 98bd1da9d7Smrg 9947e89262Smrg# A function that is used when there is no print builtin or printf. 10047e89262Smrgfunc_fallback_echo () 10147e89262Smrg{ 10247e89262Smrg eval 'cat <<_LTECHO_EOF 10347e89262Smrg$1 10447e89262Smrg_LTECHO_EOF' 10547e89262Smrg} 106bd1da9d7Smrg 10747e89262Smrg# NLS nuisances: We save the old values to restore during execute mode. 10847e89262Smrglt_user_locale= 10947e89262Smrglt_safe_locale= 1105bcb6992Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1115bcb6992Smrgdo 1125bcb6992Smrg eval "if test \"\${$lt_var+set}\" = set; then 11347e89262Smrg save_$lt_var=\$$lt_var 11447e89262Smrg $lt_var=C 1155bcb6992Smrg export $lt_var 11647e89262Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 11747e89262Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 1185bcb6992Smrg fi" 1195bcb6992Smrgdone 12047e89262SmrgLC_ALL=C 12147e89262SmrgLANGUAGE=C 12247e89262Smrgexport LANGUAGE LC_ALL 1235bcb6992Smrg 12447e89262Smrg$lt_unset CDPATH 12547e89262Smrg 12647e89262Smrg 12747e89262Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 12847e89262Smrg# is ksh but when the shell is invoked as "sh" and the current value of 12947e89262Smrg# the _XPG environment variable is not equal to 1 (one), the special 13047e89262Smrg# positional parameter $0, within a function call, is the name of the 13147e89262Smrg# function. 13247e89262Smrgprogpath="$0" 13347e89262Smrg 13447e89262Smrg 13547e89262Smrg 13647e89262Smrg: ${CP="cp -f"} 13747e89262Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 13847e89262Smrg: ${EGREP="grep -E"} 13947e89262Smrg: ${FGREP="grep -F"} 14047e89262Smrg: ${GREP="grep"} 14147e89262Smrg: ${LN_S="ln -s"} 14247e89262Smrg: ${MAKE="make"} 14347e89262Smrg: ${MKDIR="mkdir"} 14447e89262Smrg: ${MV="mv -f"} 14547e89262Smrg: ${RM="rm -f"} 14647e89262Smrg: ${SED="sed"} 14747e89262Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 14847e89262Smrg: ${Xsed="$SED -e 1s/^X//"} 14947e89262Smrg 15047e89262Smrg# Global variables: 15147e89262SmrgEXIT_SUCCESS=0 15247e89262SmrgEXIT_FAILURE=1 15347e89262SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 15447e89262SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 15547e89262Smrg 15647e89262Smrgexit_status=$EXIT_SUCCESS 157bd1da9d7Smrg 158bd1da9d7Smrg# Make sure IFS has a sensible default 159bd1da9d7Smrglt_nl=' 160bd1da9d7Smrg' 161bd1da9d7SmrgIFS=" $lt_nl" 162bd1da9d7Smrg 16347e89262Smrgdirname="s,/[^/]*$,," 16447e89262Smrgbasename="s,^.*/,," 16547e89262Smrg 16647e89262Smrg# func_dirname_and_basename file append nondir_replacement 16747e89262Smrg# perform func_basename and func_dirname in a single function 16847e89262Smrg# call: 16947e89262Smrg# dirname: Compute the dirname of FILE. If nonempty, 17047e89262Smrg# add APPEND to the result, otherwise set result 17147e89262Smrg# to NONDIR_REPLACEMENT. 17247e89262Smrg# value returned in "$func_dirname_result" 17347e89262Smrg# basename: Compute filename of FILE. 17447e89262Smrg# value retuned in "$func_basename_result" 17547e89262Smrg# Implementation must be kept synchronized with func_dirname 17647e89262Smrg# and func_basename. For efficiency, we do not delegate to 17747e89262Smrg# those functions but instead duplicate the functionality here. 17847e89262Smrgfunc_dirname_and_basename () 17947e89262Smrg{ 18047e89262Smrg # Extract subdirectory from the argument. 18147e89262Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 18247e89262Smrg if test "X$func_dirname_result" = "X${1}"; then 18347e89262Smrg func_dirname_result="${3}" 18447e89262Smrg else 18547e89262Smrg func_dirname_result="$func_dirname_result${2}" 18647e89262Smrg fi 18747e89262Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 18847e89262Smrg} 189bd1da9d7Smrg 19047e89262Smrg# Generated shell functions inserted here. 19147e89262Smrg 19247e89262Smrg# These SED scripts presuppose an absolute path with a trailing slash. 19347e89262Smrgpathcar='s,^/\([^/]*\).*$,\1,' 19447e89262Smrgpathcdr='s,^/[^/]*,,' 19547e89262Smrgremovedotparts=':dotsl 19647e89262Smrg s@/\./@/@g 19747e89262Smrg t dotsl 19847e89262Smrg s,/\.$,/,' 19947e89262Smrgcollapseslashes='s@/\{1,\}@/@g' 20047e89262Smrgfinalslash='s,/*$,/,' 20147e89262Smrg 20247e89262Smrg# func_normal_abspath PATH 20347e89262Smrg# Remove doubled-up and trailing slashes, "." path components, 20447e89262Smrg# and cancel out any ".." path components in PATH after making 20547e89262Smrg# it an absolute path. 20647e89262Smrg# value returned in "$func_normal_abspath_result" 20747e89262Smrgfunc_normal_abspath () 20847e89262Smrg{ 20947e89262Smrg # Start from root dir and reassemble the path. 21047e89262Smrg func_normal_abspath_result= 21147e89262Smrg func_normal_abspath_tpath=$1 21247e89262Smrg func_normal_abspath_altnamespace= 21347e89262Smrg case $func_normal_abspath_tpath in 21447e89262Smrg "") 21547e89262Smrg # Empty path, that just means $cwd. 21647e89262Smrg func_stripname '' '/' "`pwd`" 21747e89262Smrg func_normal_abspath_result=$func_stripname_result 21847e89262Smrg return 21947e89262Smrg ;; 22047e89262Smrg # The next three entries are used to spot a run of precisely 22147e89262Smrg # two leading slashes without using negated character classes; 22247e89262Smrg # we take advantage of case's first-match behaviour. 22347e89262Smrg ///*) 22447e89262Smrg # Unusual form of absolute path, do nothing. 22547e89262Smrg ;; 22647e89262Smrg //*) 22747e89262Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 22847e89262Smrg # and for example Cygwin uses it to access remote file shares 22947e89262Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 23047e89262Smrg func_normal_abspath_altnamespace=/ 23147e89262Smrg ;; 23247e89262Smrg /*) 23347e89262Smrg # Absolute path, do nothing. 23447e89262Smrg ;; 23547e89262Smrg *) 23647e89262Smrg # Relative path, prepend $cwd. 23747e89262Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 23847e89262Smrg ;; 23947e89262Smrg esac 24047e89262Smrg # Cancel out all the simple stuff to save iterations. We also want 24147e89262Smrg # the path to end with a slash for ease of parsing, so make sure 24247e89262Smrg # there is one (and only one) here. 24347e89262Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 24447e89262Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 24547e89262Smrg while :; do 24647e89262Smrg # Processed it all yet? 24747e89262Smrg if test "$func_normal_abspath_tpath" = / ; then 24847e89262Smrg # If we ascended to the root using ".." the result may be empty now. 24947e89262Smrg if test -z "$func_normal_abspath_result" ; then 25047e89262Smrg func_normal_abspath_result=/ 25147e89262Smrg fi 25247e89262Smrg break 25347e89262Smrg fi 25447e89262Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 25547e89262Smrg -e "$pathcar"` 25647e89262Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 25747e89262Smrg -e "$pathcdr"` 25847e89262Smrg # Figure out what to do with it 25947e89262Smrg case $func_normal_abspath_tcomponent in 26047e89262Smrg "") 26147e89262Smrg # Trailing empty path component, ignore it. 26247e89262Smrg ;; 26347e89262Smrg ..) 26447e89262Smrg # Parent dir; strip last assembled component from result. 26547e89262Smrg func_dirname "$func_normal_abspath_result" 26647e89262Smrg func_normal_abspath_result=$func_dirname_result 26747e89262Smrg ;; 26847e89262Smrg *) 26947e89262Smrg # Actual path component, append it. 27047e89262Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 27147e89262Smrg ;; 27247e89262Smrg esac 27347e89262Smrg done 27447e89262Smrg # Restore leading double-slash if one was found on entry. 27547e89262Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 27647e89262Smrg} 27747e89262Smrg 27847e89262Smrg# func_relative_path SRCDIR DSTDIR 27947e89262Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 28047e89262Smrg# slash if non-empty, suitable for immediately appending a filename 28147e89262Smrg# without needing to append a separator. 28247e89262Smrg# value returned in "$func_relative_path_result" 28347e89262Smrgfunc_relative_path () 28447e89262Smrg{ 28547e89262Smrg func_relative_path_result= 28647e89262Smrg func_normal_abspath "$1" 28747e89262Smrg func_relative_path_tlibdir=$func_normal_abspath_result 28847e89262Smrg func_normal_abspath "$2" 28947e89262Smrg func_relative_path_tbindir=$func_normal_abspath_result 29047e89262Smrg 29147e89262Smrg # Ascend the tree starting from libdir 29247e89262Smrg while :; do 29347e89262Smrg # check if we have found a prefix of bindir 29447e89262Smrg case $func_relative_path_tbindir in 29547e89262Smrg $func_relative_path_tlibdir) 29647e89262Smrg # found an exact match 29747e89262Smrg func_relative_path_tcancelled= 29847e89262Smrg break 29947e89262Smrg ;; 30047e89262Smrg $func_relative_path_tlibdir*) 30147e89262Smrg # found a matching prefix 30247e89262Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 30347e89262Smrg func_relative_path_tcancelled=$func_stripname_result 30447e89262Smrg if test -z "$func_relative_path_result"; then 30547e89262Smrg func_relative_path_result=. 30647e89262Smrg fi 30747e89262Smrg break 30847e89262Smrg ;; 30947e89262Smrg *) 31047e89262Smrg func_dirname $func_relative_path_tlibdir 31147e89262Smrg func_relative_path_tlibdir=${func_dirname_result} 31247e89262Smrg if test "x$func_relative_path_tlibdir" = x ; then 31347e89262Smrg # Have to descend all the way to the root! 31447e89262Smrg func_relative_path_result=../$func_relative_path_result 31547e89262Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 31647e89262Smrg break 31747e89262Smrg fi 31847e89262Smrg func_relative_path_result=../$func_relative_path_result 31947e89262Smrg ;; 32047e89262Smrg esac 32147e89262Smrg done 32247e89262Smrg 32347e89262Smrg # Now calculate path; take care to avoid doubling-up slashes. 32447e89262Smrg func_stripname '' '/' "$func_relative_path_result" 32547e89262Smrg func_relative_path_result=$func_stripname_result 32647e89262Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 32747e89262Smrg if test "x$func_stripname_result" != x ; then 32847e89262Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 32947e89262Smrg fi 33047e89262Smrg 33147e89262Smrg # Normalisation. If bindir is libdir, return empty string, 33247e89262Smrg # else relative path ending with a slash; either way, target 33347e89262Smrg # file name can be directly appended. 33447e89262Smrg if test ! -z "$func_relative_path_result"; then 33547e89262Smrg func_stripname './' '' "$func_relative_path_result/" 33647e89262Smrg func_relative_path_result=$func_stripname_result 33747e89262Smrg fi 33847e89262Smrg} 33947e89262Smrg 34047e89262Smrg# The name of this program: 34147e89262Smrgfunc_dirname_and_basename "$progpath" 34247e89262Smrgprogname=$func_basename_result 34347e89262Smrg 34447e89262Smrg# Make sure we have an absolute path for reexecution: 34547e89262Smrgcase $progpath in 34647e89262Smrg [\\/]*|[A-Za-z]:\\*) ;; 34747e89262Smrg *[\\/]*) 34847e89262Smrg progdir=$func_dirname_result 34947e89262Smrg progdir=`cd "$progdir" && pwd` 35047e89262Smrg progpath="$progdir/$progname" 35147e89262Smrg ;; 35247e89262Smrg *) 35347e89262Smrg save_IFS="$IFS" 35447e89262Smrg IFS=: 35547e89262Smrg for progdir in $PATH; do 35647e89262Smrg IFS="$save_IFS" 35747e89262Smrg test -x "$progdir/$progname" && break 35847e89262Smrg done 35947e89262Smrg IFS="$save_IFS" 36047e89262Smrg test -n "$progdir" || progdir=`pwd` 36147e89262Smrg progpath="$progdir/$progname" 36247e89262Smrg ;; 36347e89262Smrgesac 36447e89262Smrg 36547e89262Smrg# Sed substitution that helps us do robust quoting. It backslashifies 36647e89262Smrg# metacharacters that are still active within double-quoted strings. 36747e89262SmrgXsed="${SED}"' -e 1s/^X//' 36847e89262Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 36947e89262Smrg 37047e89262Smrg# Same as above, but do not quote variable references. 37147e89262Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 37247e89262Smrg 37347e89262Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 37447e89262Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 37547e89262Smrg# in input to double_quote_subst, that '$' was protected from expansion. 37647e89262Smrg# Since each input `\' is now two `\'s, look for any number of runs of 37747e89262Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 37847e89262Smrgbs='\\' 37947e89262Smrgbs2='\\\\' 38047e89262Smrgbs4='\\\\\\\\' 38147e89262Smrgdollar='\$' 38247e89262Smrgsed_double_backslash="\ 38347e89262Smrg s/$bs4/&\\ 38447e89262Smrg/g 38547e89262Smrg s/^$bs2$dollar/$bs&/ 38647e89262Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 38747e89262Smrg s/\n//g" 38847e89262Smrg 38947e89262Smrg# Standard options: 39047e89262Smrgopt_dry_run=false 39147e89262Smrgopt_help=false 39247e89262Smrgopt_quiet=false 39347e89262Smrgopt_verbose=false 39447e89262Smrgopt_warning=: 39547e89262Smrg 39647e89262Smrg# func_echo arg... 39747e89262Smrg# Echo program name prefixed message, along with the current mode 39847e89262Smrg# name if it has been set yet. 39947e89262Smrgfunc_echo () 40047e89262Smrg{ 40147e89262Smrg $ECHO "$progname${mode+: }$mode: $*" 40247e89262Smrg} 40347e89262Smrg 40447e89262Smrg# func_verbose arg... 40547e89262Smrg# Echo program name prefixed message in verbose mode only. 40647e89262Smrgfunc_verbose () 40747e89262Smrg{ 40847e89262Smrg $opt_verbose && func_echo ${1+"$@"} 40947e89262Smrg 41047e89262Smrg # A bug in bash halts the script if the last line of a function 41147e89262Smrg # fails when set -e is in force, so we need another command to 41247e89262Smrg # work around that: 41347e89262Smrg : 41447e89262Smrg} 41547e89262Smrg 41647e89262Smrg# func_echo_all arg... 41747e89262Smrg# Invoke $ECHO with all args, space-separated. 41847e89262Smrgfunc_echo_all () 41947e89262Smrg{ 42047e89262Smrg $ECHO "$*" 42147e89262Smrg} 42247e89262Smrg 42347e89262Smrg# func_error arg... 42447e89262Smrg# Echo program name prefixed message to standard error. 42547e89262Smrgfunc_error () 42647e89262Smrg{ 42747e89262Smrg $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 42847e89262Smrg} 42947e89262Smrg 43047e89262Smrg# func_warning arg... 43147e89262Smrg# Echo program name prefixed warning message to standard error. 43247e89262Smrgfunc_warning () 43347e89262Smrg{ 43447e89262Smrg $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 43547e89262Smrg 43647e89262Smrg # bash bug again: 43747e89262Smrg : 43847e89262Smrg} 43947e89262Smrg 44047e89262Smrg# func_fatal_error arg... 44147e89262Smrg# Echo program name prefixed message to standard error, and exit. 44247e89262Smrgfunc_fatal_error () 44347e89262Smrg{ 44447e89262Smrg func_error ${1+"$@"} 44547e89262Smrg exit $EXIT_FAILURE 44647e89262Smrg} 44747e89262Smrg 44847e89262Smrg# func_fatal_help arg... 44947e89262Smrg# Echo program name prefixed message to standard error, followed by 45047e89262Smrg# a help hint, and exit. 45147e89262Smrgfunc_fatal_help () 45247e89262Smrg{ 45347e89262Smrg func_error ${1+"$@"} 45447e89262Smrg func_fatal_error "$help" 45547e89262Smrg} 45647e89262Smrghelp="Try \`$progname --help' for more information." ## default 45747e89262Smrg 45847e89262Smrg 45947e89262Smrg# func_grep expression filename 46047e89262Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 46147e89262Smrgfunc_grep () 46247e89262Smrg{ 46347e89262Smrg $GREP "$1" "$2" >/dev/null 2>&1 46447e89262Smrg} 46547e89262Smrg 46647e89262Smrg 46747e89262Smrg# func_mkdir_p directory-path 46847e89262Smrg# Make sure the entire path to DIRECTORY-PATH is available. 46947e89262Smrgfunc_mkdir_p () 47047e89262Smrg{ 47147e89262Smrg my_directory_path="$1" 47247e89262Smrg my_dir_list= 47347e89262Smrg 47447e89262Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 47547e89262Smrg 47647e89262Smrg # Protect directory names starting with `-' 47747e89262Smrg case $my_directory_path in 47847e89262Smrg -*) my_directory_path="./$my_directory_path" ;; 47947e89262Smrg esac 48047e89262Smrg 48147e89262Smrg # While some portion of DIR does not yet exist... 48247e89262Smrg while test ! -d "$my_directory_path"; do 48347e89262Smrg # ...make a list in topmost first order. Use a colon delimited 48447e89262Smrg # list incase some portion of path contains whitespace. 48547e89262Smrg my_dir_list="$my_directory_path:$my_dir_list" 48647e89262Smrg 48747e89262Smrg # If the last portion added has no slash in it, the list is done 48847e89262Smrg case $my_directory_path in */*) ;; *) break ;; esac 48947e89262Smrg 49047e89262Smrg # ...otherwise throw away the child directory and loop 49147e89262Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 49247e89262Smrg done 49347e89262Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 49447e89262Smrg 49547e89262Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 49647e89262Smrg for my_dir in $my_dir_list; do 49747e89262Smrg IFS="$save_mkdir_p_IFS" 49847e89262Smrg # mkdir can fail with a `File exist' error if two processes 49947e89262Smrg # try to create one of the directories concurrently. Don't 50047e89262Smrg # stop in that case! 50147e89262Smrg $MKDIR "$my_dir" 2>/dev/null || : 50247e89262Smrg done 50347e89262Smrg IFS="$save_mkdir_p_IFS" 50447e89262Smrg 50547e89262Smrg # Bail out if we (or some other process) failed to create a directory. 50647e89262Smrg test -d "$my_directory_path" || \ 50747e89262Smrg func_fatal_error "Failed to create \`$1'" 50847e89262Smrg fi 50947e89262Smrg} 510bd1da9d7Smrg 511bd1da9d7Smrg 512bd1da9d7Smrg# func_mktempdir [string] 513bd1da9d7Smrg# Make a temporary directory that won't clash with other running 514bd1da9d7Smrg# libtool processes, and avoids race conditions if possible. If 515bd1da9d7Smrg# given, STRING is the basename for that directory. 516bd1da9d7Smrgfunc_mktempdir () 517bd1da9d7Smrg{ 518bd1da9d7Smrg my_template="${TMPDIR-/tmp}/${1-$progname}" 519bd1da9d7Smrg 52047e89262Smrg if test "$opt_dry_run" = ":"; then 521bd1da9d7Smrg # Return a directory name, but don't create it in dry-run mode 522bd1da9d7Smrg my_tmpdir="${my_template}-$$" 523bd1da9d7Smrg else 524bd1da9d7Smrg 525bd1da9d7Smrg # If mktemp works, use that first and foremost 526bd1da9d7Smrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 527bd1da9d7Smrg 528bd1da9d7Smrg if test ! -d "$my_tmpdir"; then 52947e89262Smrg # Failing that, at least try and use $RANDOM to avoid a race 53047e89262Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 531bd1da9d7Smrg 53247e89262Smrg save_mktempdir_umask=`umask` 53347e89262Smrg umask 0077 53447e89262Smrg $MKDIR "$my_tmpdir" 53547e89262Smrg umask $save_mktempdir_umask 536bd1da9d7Smrg fi 537bd1da9d7Smrg 538bd1da9d7Smrg # If we're not in dry-run mode, bomb out on failure 53947e89262Smrg test -d "$my_tmpdir" || \ 54047e89262Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 541bd1da9d7Smrg fi 542bd1da9d7Smrg 54347e89262Smrg $ECHO "$my_tmpdir" 544bd1da9d7Smrg} 545bd1da9d7Smrg 546bd1da9d7Smrg 54747e89262Smrg# func_quote_for_eval arg 54847e89262Smrg# Aesthetically quote ARG to be evaled later. 54947e89262Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 55047e89262Smrg# is double-quoted, suitable for a subsequent eval, whereas 55147e89262Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 55247e89262Smrg# which are still active within double quotes backslashified. 55347e89262Smrgfunc_quote_for_eval () 554bd1da9d7Smrg{ 55547e89262Smrg case $1 in 55647e89262Smrg *[\\\`\"\$]*) 55747e89262Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 55847e89262Smrg *) 55947e89262Smrg func_quote_for_eval_unquoted_result="$1" ;; 56047e89262Smrg esac 56147e89262Smrg 56247e89262Smrg case $func_quote_for_eval_unquoted_result in 56347e89262Smrg # Double-quote args containing shell metacharacters to delay 56447e89262Smrg # word splitting, command substitution and and variable 56547e89262Smrg # expansion for a subsequent eval. 56647e89262Smrg # Many Bourne shells cannot handle close brackets correctly 56747e89262Smrg # in scan sets, so we specify it separately. 56847e89262Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 56947e89262Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 57047e89262Smrg ;; 57147e89262Smrg *) 57247e89262Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 573bd1da9d7Smrg esac 574bd1da9d7Smrg} 575bd1da9d7Smrg 576bd1da9d7Smrg 57747e89262Smrg# func_quote_for_expand arg 57847e89262Smrg# Aesthetically quote ARG to be evaled later; same as above, 57947e89262Smrg# but do not quote variable references. 58047e89262Smrgfunc_quote_for_expand () 581bd1da9d7Smrg{ 58247e89262Smrg case $1 in 58347e89262Smrg *[\\\`\"]*) 58447e89262Smrg my_arg=`$ECHO "$1" | $SED \ 58547e89262Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 586bd1da9d7Smrg *) 58747e89262Smrg my_arg="$1" ;; 58847e89262Smrg esac 58947e89262Smrg 59047e89262Smrg case $my_arg in 59147e89262Smrg # Double-quote args containing shell metacharacters to delay 59247e89262Smrg # word splitting and command substitution for a subsequent eval. 59347e89262Smrg # Many Bourne shells cannot handle close brackets correctly 59447e89262Smrg # in scan sets, so we specify it separately. 59547e89262Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 59647e89262Smrg my_arg="\"$my_arg\"" 59747e89262Smrg ;; 59847e89262Smrg esac 59947e89262Smrg 60047e89262Smrg func_quote_for_expand_result="$my_arg" 601bd1da9d7Smrg} 602bd1da9d7Smrg 603bd1da9d7Smrg 60447e89262Smrg# func_show_eval cmd [fail_exp] 60547e89262Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 60647e89262Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 60747e89262Smrg# is given, then evaluate it. 60847e89262Smrgfunc_show_eval () 609bd1da9d7Smrg{ 61047e89262Smrg my_cmd="$1" 61147e89262Smrg my_fail_exp="${2-:}" 612bd1da9d7Smrg 61347e89262Smrg ${opt_silent-false} || { 61447e89262Smrg func_quote_for_expand "$my_cmd" 61547e89262Smrg eval "func_echo $func_quote_for_expand_result" 61647e89262Smrg } 61747e89262Smrg 61847e89262Smrg if ${opt_dry_run-false}; then :; else 61947e89262Smrg eval "$my_cmd" 62047e89262Smrg my_status=$? 62147e89262Smrg if test "$my_status" -eq 0; then :; else 62247e89262Smrg eval "(exit $my_status); $my_fail_exp" 62347e89262Smrg fi 624bd1da9d7Smrg fi 625bd1da9d7Smrg} 626bd1da9d7Smrg 62747e89262Smrg 62847e89262Smrg# func_show_eval_locale cmd [fail_exp] 62947e89262Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 63047e89262Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 63147e89262Smrg# is given, then evaluate it. Use the saved locale for evaluation. 63247e89262Smrgfunc_show_eval_locale () 633bd1da9d7Smrg{ 63447e89262Smrg my_cmd="$1" 63547e89262Smrg my_fail_exp="${2-:}" 636bd1da9d7Smrg 63747e89262Smrg ${opt_silent-false} || { 63847e89262Smrg func_quote_for_expand "$my_cmd" 63947e89262Smrg eval "func_echo $func_quote_for_expand_result" 64047e89262Smrg } 641bd1da9d7Smrg 64247e89262Smrg if ${opt_dry_run-false}; then :; else 64347e89262Smrg eval "$lt_user_locale 64447e89262Smrg $my_cmd" 64547e89262Smrg my_status=$? 64647e89262Smrg eval "$lt_safe_locale" 64747e89262Smrg if test "$my_status" -eq 0; then :; else 64847e89262Smrg eval "(exit $my_status); $my_fail_exp" 649bd1da9d7Smrg fi 65047e89262Smrg fi 651bd1da9d7Smrg} 652bd1da9d7Smrg 653bd1da9d7Smrg 65447e89262Smrg# func_version 65547e89262Smrg# Echo version message to standard output and exit. 65647e89262Smrgfunc_version () 65747e89262Smrg{ 65847e89262Smrg $SED -n '/(C)/!b go 65947e89262Smrg :more 66047e89262Smrg /\./!{ 66147e89262Smrg N 66247e89262Smrg s/\n# / / 66347e89262Smrg b more 66447e89262Smrg } 66547e89262Smrg :go 66647e89262Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 66747e89262Smrg s/^# // 66847e89262Smrg s/^# *$// 66947e89262Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 67047e89262Smrg p 67147e89262Smrg }' < "$progpath" 67247e89262Smrg exit $? 67347e89262Smrg} 674bd1da9d7Smrg 67547e89262Smrg# func_usage 67647e89262Smrg# Echo short help message to standard output and exit. 67747e89262Smrgfunc_usage () 67847e89262Smrg{ 67947e89262Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 68047e89262Smrg s/^# // 68147e89262Smrg s/^# *$// 68247e89262Smrg s/\$progname/'$progname'/ 68347e89262Smrg p 68447e89262Smrg }' < "$progpath" 68547e89262Smrg echo 68647e89262Smrg $ECHO "run \`$progname --help | more' for full usage" 68747e89262Smrg exit $? 68847e89262Smrg} 689bd1da9d7Smrg 69047e89262Smrg# func_help [NOEXIT] 69147e89262Smrg# Echo long help message to standard output and exit, 69247e89262Smrg# unless 'noexit' is passed as argument. 69347e89262Smrgfunc_help () 69447e89262Smrg{ 69547e89262Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 69647e89262Smrg s/^# // 69747e89262Smrg s/^# *$// 69847e89262Smrg s*\$progname*'$progname'* 69947e89262Smrg s*\$host*'"$host"'* 70047e89262Smrg s*\$SHELL*'"$SHELL"'* 70147e89262Smrg s*\$LTCC*'"$LTCC"'* 70247e89262Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 70347e89262Smrg s*\$LD*'"$LD"'* 70447e89262Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 70547e89262Smrg s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ 70647e89262Smrg s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ 70747e89262Smrg p 70847e89262Smrg }' < "$progpath" 70947e89262Smrg ret=$? 71047e89262Smrg if test -z "$1"; then 71147e89262Smrg exit $ret 71247e89262Smrg fi 71347e89262Smrg} 714bd1da9d7Smrg 71547e89262Smrg# func_missing_arg argname 71647e89262Smrg# Echo program name prefixed message to standard error and set global 71747e89262Smrg# exit_cmd. 71847e89262Smrgfunc_missing_arg () 71947e89262Smrg{ 72047e89262Smrg func_error "missing argument for $1." 72147e89262Smrg exit_cmd=exit 72247e89262Smrg} 723bd1da9d7Smrg 72447e89262Smrgexit_cmd=: 725bd1da9d7Smrg 726bd1da9d7Smrg 727bd1da9d7Smrg 7285bcb6992Smrg 729bd1da9d7Smrg 73047e89262Smrg 73147e89262Smrgmagic="%%%MAGIC variable%%%" 73247e89262Smrgmagic_exe="%%%MAGIC EXE variable%%%" 73347e89262Smrg 73447e89262Smrg# Global variables. 73547e89262Smrg# $mode is unset 73647e89262Smrgnonopt= 73747e89262Smrgexecute_dlfiles= 73847e89262Smrgpreserve_args= 73947e89262Smrglo2o="s/\\.lo\$/.${objext}/" 74047e89262Smrgo2lo="s/\\.${objext}\$/.lo/" 74147e89262Smrgextracted_archives= 74247e89262Smrgextracted_serial=0 74347e89262Smrg 74447e89262Smrgopt_dry_run=false 74547e89262Smrgopt_duplicate_deps=false 74647e89262Smrgopt_silent=false 74747e89262Smrgopt_debug=: 74847e89262Smrg 74947e89262Smrg# If this variable is set in any of the actions, the command in it 75047e89262Smrg# will be execed at the end. This prevents here-documents from being 75147e89262Smrg# left over by shells. 75247e89262Smrgexec_cmd= 75347e89262Smrg 75447e89262Smrg# func_fatal_configuration arg... 75547e89262Smrg# Echo program name prefixed message to standard error, followed by 75647e89262Smrg# a configuration failure hint, and exit. 75747e89262Smrgfunc_fatal_configuration () 75847e89262Smrg{ 75947e89262Smrg func_error ${1+"$@"} 76047e89262Smrg func_error "See the $PACKAGE documentation for more information." 76147e89262Smrg func_fatal_error "Fatal configuration error." 76247e89262Smrg} 76347e89262Smrg 76447e89262Smrg 76547e89262Smrg# func_config 76647e89262Smrg# Display the configuration for all the tags in this script. 76747e89262Smrgfunc_config () 76847e89262Smrg{ 76947e89262Smrg re_begincf='^# ### BEGIN LIBTOOL' 77047e89262Smrg re_endcf='^# ### END LIBTOOL' 77147e89262Smrg 77247e89262Smrg # Default configuration. 77347e89262Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 77447e89262Smrg 775bd1da9d7Smrg # Now print the configurations for the tags. 776bd1da9d7Smrg for tagname in $taglist; do 77747e89262Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 778bd1da9d7Smrg done 779bd1da9d7Smrg 78047e89262Smrg exit $? 78147e89262Smrg} 782bd1da9d7Smrg 78347e89262Smrg# func_features 78447e89262Smrg# Display the features supported by this script. 78547e89262Smrgfunc_features () 78647e89262Smrg{ 78747e89262Smrg echo "host: $host" 788bd1da9d7Smrg if test "$build_libtool_libs" = yes; then 78947e89262Smrg echo "enable shared libraries" 790bd1da9d7Smrg else 79147e89262Smrg echo "disable shared libraries" 792bd1da9d7Smrg fi 793bd1da9d7Smrg if test "$build_old_libs" = yes; then 79447e89262Smrg echo "enable static libraries" 795bd1da9d7Smrg else 79647e89262Smrg echo "disable static libraries" 797bd1da9d7Smrg fi 79847e89262Smrg 799bd1da9d7Smrg exit $? 80047e89262Smrg} 801bd1da9d7Smrg 80247e89262Smrg# func_enable_tag tagname 80347e89262Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 80447e89262Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 80547e89262Smrg# variable here. 80647e89262Smrgfunc_enable_tag () 80747e89262Smrg{ 80847e89262Smrg # Global variable: 80947e89262Smrg tagname="$1" 810bd1da9d7Smrg 81147e89262Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 81247e89262Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 81347e89262Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 814bd1da9d7Smrg 81547e89262Smrg # Validate tagname. 81647e89262Smrg case $tagname in 81747e89262Smrg *[!-_A-Za-z0-9,/]*) 81847e89262Smrg func_fatal_error "invalid tag name: $tagname" 81947e89262Smrg ;; 82047e89262Smrg esac 821bd1da9d7Smrg 82247e89262Smrg # Don't test for the "default" C tag, as we know it's 82347e89262Smrg # there but not specially marked. 82447e89262Smrg case $tagname in 82547e89262Smrg CC) ;; 82647e89262Smrg *) 82747e89262Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 82847e89262Smrg taglist="$taglist $tagname" 82947e89262Smrg 83047e89262Smrg # Evaluate the configuration. Be careful to quote the path 83147e89262Smrg # and the sed script, to avoid splitting on whitespace, but 83247e89262Smrg # also don't use non-portable quotes within backquotes within 83347e89262Smrg # quotes we have to do it in 2 steps: 83447e89262Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 83547e89262Smrg eval "$extractedcf" 83647e89262Smrg else 83747e89262Smrg func_error "ignoring unknown tag $tagname" 83847e89262Smrg fi 83947e89262Smrg ;; 84047e89262Smrg esac 84147e89262Smrg} 84247e89262Smrg 84347e89262Smrg# Parse options once, thoroughly. This comes as soon as possible in 84447e89262Smrg# the script to make things like `libtool --version' happen quickly. 84547e89262Smrg{ 846bd1da9d7Smrg 84747e89262Smrg # Shorthand for --mode=foo, only valid as the first argument 84847e89262Smrg case $1 in 84947e89262Smrg clean|clea|cle|cl) 85047e89262Smrg shift; set dummy --mode clean ${1+"$@"}; shift 851bd1da9d7Smrg ;; 85247e89262Smrg compile|compil|compi|comp|com|co|c) 85347e89262Smrg shift; set dummy --mode compile ${1+"$@"}; shift 854bd1da9d7Smrg ;; 85547e89262Smrg execute|execut|execu|exec|exe|ex|e) 85647e89262Smrg shift; set dummy --mode execute ${1+"$@"}; shift 857bd1da9d7Smrg ;; 85847e89262Smrg finish|finis|fini|fin|fi|f) 85947e89262Smrg shift; set dummy --mode finish ${1+"$@"}; shift 860bd1da9d7Smrg ;; 86147e89262Smrg install|instal|insta|inst|ins|in|i) 86247e89262Smrg shift; set dummy --mode install ${1+"$@"}; shift 86347e89262Smrg ;; 86447e89262Smrg link|lin|li|l) 86547e89262Smrg shift; set dummy --mode link ${1+"$@"}; shift 86647e89262Smrg ;; 86747e89262Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 86847e89262Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 869bd1da9d7Smrg ;; 870bd1da9d7Smrg esac 871bd1da9d7Smrg 87247e89262Smrg # Parse non-mode specific arguments: 87347e89262Smrg while test "$#" -gt 0; do 87447e89262Smrg opt="$1" 87547e89262Smrg shift 876bd1da9d7Smrg 87747e89262Smrg case $opt in 87847e89262Smrg --config) func_config ;; 879bd1da9d7Smrg 88047e89262Smrg --debug) preserve_args="$preserve_args $opt" 88147e89262Smrg func_echo "enabling shell trace mode" 88247e89262Smrg opt_debug='set -x' 88347e89262Smrg $opt_debug 88447e89262Smrg ;; 885bd1da9d7Smrg 88647e89262Smrg -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break 88747e89262Smrg execute_dlfiles="$execute_dlfiles $1" 88847e89262Smrg shift 88947e89262Smrg ;; 890bd1da9d7Smrg 89147e89262Smrg --dry-run | -n) opt_dry_run=: ;; 89247e89262Smrg --features) func_features ;; 89347e89262Smrg --finish) mode="finish" ;; 89447e89262Smrg 89547e89262Smrg --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break 89647e89262Smrg case $1 in 89747e89262Smrg # Valid mode arguments: 89847e89262Smrg clean) ;; 89947e89262Smrg compile) ;; 90047e89262Smrg execute) ;; 90147e89262Smrg finish) ;; 90247e89262Smrg install) ;; 90347e89262Smrg link) ;; 90447e89262Smrg relink) ;; 90547e89262Smrg uninstall) ;; 90647e89262Smrg 90747e89262Smrg # Catch anything else as an error 90847e89262Smrg *) func_error "invalid argument for $opt" 90947e89262Smrg exit_cmd=exit 91047e89262Smrg break 91147e89262Smrg ;; 91247e89262Smrg esac 91347e89262Smrg 91447e89262Smrg mode="$1" 91547e89262Smrg shift 91647e89262Smrg ;; 91747e89262Smrg 91847e89262Smrg --preserve-dup-deps) 91947e89262Smrg opt_duplicate_deps=: ;; 92047e89262Smrg 92147e89262Smrg --quiet|--silent) preserve_args="$preserve_args $opt" 92247e89262Smrg opt_silent=: 92347e89262Smrg opt_verbose=false 92447e89262Smrg ;; 92547e89262Smrg 92647e89262Smrg --no-quiet|--no-silent) 92747e89262Smrg preserve_args="$preserve_args $opt" 92847e89262Smrg opt_silent=false 92947e89262Smrg ;; 93047e89262Smrg 93147e89262Smrg --verbose| -v) preserve_args="$preserve_args $opt" 93247e89262Smrg opt_silent=false 93347e89262Smrg opt_verbose=: 93447e89262Smrg ;; 93547e89262Smrg 93647e89262Smrg --no-verbose) preserve_args="$preserve_args $opt" 93747e89262Smrg opt_verbose=false 93847e89262Smrg ;; 93947e89262Smrg 94047e89262Smrg --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break 94147e89262Smrg preserve_args="$preserve_args $opt $1" 94247e89262Smrg func_enable_tag "$1" # tagname is set here 94347e89262Smrg shift 94447e89262Smrg ;; 94547e89262Smrg 94647e89262Smrg # Separate optargs to long options: 94747e89262Smrg -dlopen=*|--mode=*|--tag=*) 94847e89262Smrg func_opt_split "$opt" 94947e89262Smrg set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} 95047e89262Smrg shift 95147e89262Smrg ;; 95247e89262Smrg 95347e89262Smrg -\?|-h) func_usage ;; 95447e89262Smrg --help) opt_help=: ;; 95547e89262Smrg --help-all) opt_help=': help-all' ;; 95647e89262Smrg --version) func_version ;; 95747e89262Smrg 95847e89262Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 95947e89262Smrg 96047e89262Smrg *) nonopt="$opt" 96147e89262Smrg break 96247e89262Smrg ;; 96347e89262Smrg esac 96447e89262Smrg done 96547e89262Smrg 96647e89262Smrg 96747e89262Smrg case $host in 96847e89262Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 96947e89262Smrg # don't eliminate duplications in $postdeps and $predeps 97047e89262Smrg opt_duplicate_compiler_generated_deps=: 971bd1da9d7Smrg ;; 972bd1da9d7Smrg *) 97347e89262Smrg opt_duplicate_compiler_generated_deps=$opt_duplicate_deps 97447e89262Smrg ;; 97547e89262Smrg esac 976bd1da9d7Smrg 97747e89262Smrg # Having warned about all mis-specified options, bail out if 97847e89262Smrg # anything was wrong. 97947e89262Smrg $exit_cmd $EXIT_FAILURE 98047e89262Smrg} 98147e89262Smrg 98247e89262Smrg# func_check_version_match 98347e89262Smrg# Ensure that we are using m4 macros, and libtool script from the same 98447e89262Smrg# release of libtool. 98547e89262Smrgfunc_check_version_match () 98647e89262Smrg{ 98747e89262Smrg if test "$package_revision" != "$macro_revision"; then 98847e89262Smrg if test "$VERSION" != "$macro_version"; then 98947e89262Smrg if test -z "$macro_version"; then 99047e89262Smrg cat >&2 <<_LT_EOF 99147e89262Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99247e89262Smrg$progname: definition of this LT_INIT comes from an older release. 99347e89262Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99447e89262Smrg$progname: and run autoconf again. 99547e89262Smrg_LT_EOF 99647e89262Smrg else 99747e89262Smrg cat >&2 <<_LT_EOF 99847e89262Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99947e89262Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 100047e89262Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 100147e89262Smrg$progname: and run autoconf again. 100247e89262Smrg_LT_EOF 1003bd1da9d7Smrg fi 100447e89262Smrg else 100547e89262Smrg cat >&2 <<_LT_EOF 100647e89262Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 100747e89262Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 100847e89262Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 100947e89262Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 101047e89262Smrg_LT_EOF 101147e89262Smrg fi 101247e89262Smrg 101347e89262Smrg exit $EXIT_MISMATCH 101447e89262Smrg fi 101547e89262Smrg} 101647e89262Smrg 101747e89262Smrg 101847e89262Smrg## ----------- ## 101947e89262Smrg## Main. ## 102047e89262Smrg## ----------- ## 102147e89262Smrg 102247e89262Smrg$opt_help || { 102347e89262Smrg # Sanity checks first: 102447e89262Smrg func_check_version_match 102547e89262Smrg 102647e89262Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 102747e89262Smrg func_fatal_configuration "not configured to build any kind of library" 1028bd1da9d7Smrg fi 1029bd1da9d7Smrg 103047e89262Smrg test -z "$mode" && func_fatal_error "error: you must specify a MODE." 103147e89262Smrg 103247e89262Smrg 103347e89262Smrg # Darwin sucks 103447e89262Smrg eval std_shrext=\"$shrext_cmds\" 103547e89262Smrg 103647e89262Smrg 1037bd1da9d7Smrg # Only execute mode is allowed to have -dlopen flags. 1038bd1da9d7Smrg if test -n "$execute_dlfiles" && test "$mode" != execute; then 103947e89262Smrg func_error "unrecognized option \`-dlopen'" 104047e89262Smrg $ECHO "$help" 1>&2 1041bd1da9d7Smrg exit $EXIT_FAILURE 1042bd1da9d7Smrg fi 1043bd1da9d7Smrg 1044bd1da9d7Smrg # Change the help message to a mode-specific one. 1045bd1da9d7Smrg generic_help="$help" 104647e89262Smrg help="Try \`$progname --help --mode=$mode' for more information." 104747e89262Smrg} 1048bd1da9d7Smrg 1049bd1da9d7Smrg 105047e89262Smrg# func_lalib_p file 105147e89262Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 105247e89262Smrg# This function is only a basic sanity check; it will hardly flush out 105347e89262Smrg# determined imposters. 105447e89262Smrgfunc_lalib_p () 105547e89262Smrg{ 105647e89262Smrg test -f "$1" && 105747e89262Smrg $SED -e 4q "$1" 2>/dev/null \ 105847e89262Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 105947e89262Smrg} 1060bd1da9d7Smrg 106147e89262Smrg# func_lalib_unsafe_p file 106247e89262Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 106347e89262Smrg# This function implements the same check as func_lalib_p without 106447e89262Smrg# resorting to external programs. To this end, it redirects stdin and 106547e89262Smrg# closes it afterwards, without saving the original file descriptor. 106647e89262Smrg# As a safety measure, use it only where a negative result would be 106747e89262Smrg# fatal anyway. Works if `file' does not exist. 106847e89262Smrgfunc_lalib_unsafe_p () 106947e89262Smrg{ 107047e89262Smrg lalib_p=no 107147e89262Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 107247e89262Smrg for lalib_p_l in 1 2 3 4 107347e89262Smrg do 107447e89262Smrg read lalib_p_line 107547e89262Smrg case "$lalib_p_line" in 107647e89262Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 107747e89262Smrg esac 107847e89262Smrg done 107947e89262Smrg exec 0<&5 5<&- 108047e89262Smrg fi 108147e89262Smrg test "$lalib_p" = yes 108247e89262Smrg} 1083bd1da9d7Smrg 108447e89262Smrg# func_ltwrapper_script_p file 108547e89262Smrg# True iff FILE is a libtool wrapper script 108647e89262Smrg# This function is only a basic sanity check; it will hardly flush out 108747e89262Smrg# determined imposters. 108847e89262Smrgfunc_ltwrapper_script_p () 108947e89262Smrg{ 109047e89262Smrg func_lalib_p "$1" 109147e89262Smrg} 1092bd1da9d7Smrg 109347e89262Smrg# func_ltwrapper_executable_p file 109447e89262Smrg# True iff FILE is a libtool wrapper executable 109547e89262Smrg# This function is only a basic sanity check; it will hardly flush out 109647e89262Smrg# determined imposters. 109747e89262Smrgfunc_ltwrapper_executable_p () 109847e89262Smrg{ 109947e89262Smrg func_ltwrapper_exec_suffix= 110047e89262Smrg case $1 in 110147e89262Smrg *.exe) ;; 110247e89262Smrg *) func_ltwrapper_exec_suffix=.exe ;; 110347e89262Smrg esac 110447e89262Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 110547e89262Smrg} 110647e89262Smrg 110747e89262Smrg# func_ltwrapper_scriptname file 110847e89262Smrg# Assumes file is an ltwrapper_executable 110947e89262Smrg# uses $file to determine the appropriate filename for a 111047e89262Smrg# temporary ltwrapper_script. 111147e89262Smrgfunc_ltwrapper_scriptname () 111247e89262Smrg{ 111347e89262Smrg func_ltwrapper_scriptname_result="" 111447e89262Smrg if func_ltwrapper_executable_p "$1"; then 111547e89262Smrg func_dirname_and_basename "$1" "" "." 111647e89262Smrg func_stripname '' '.exe' "$func_basename_result" 111747e89262Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 111847e89262Smrg fi 111947e89262Smrg} 112047e89262Smrg 112147e89262Smrg# func_ltwrapper_p file 112247e89262Smrg# True iff FILE is a libtool wrapper script or wrapper executable 112347e89262Smrg# This function is only a basic sanity check; it will hardly flush out 112447e89262Smrg# determined imposters. 112547e89262Smrgfunc_ltwrapper_p () 112647e89262Smrg{ 112747e89262Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 112847e89262Smrg} 112947e89262Smrg 113047e89262Smrg 113147e89262Smrg# func_execute_cmds commands fail_cmd 113247e89262Smrg# Execute tilde-delimited COMMANDS. 113347e89262Smrg# If FAIL_CMD is given, eval that upon failure. 113447e89262Smrg# FAIL_CMD may read-access the current command in variable CMD! 113547e89262Smrgfunc_execute_cmds () 113647e89262Smrg{ 113747e89262Smrg $opt_debug 113847e89262Smrg save_ifs=$IFS; IFS='~' 113947e89262Smrg for cmd in $1; do 114047e89262Smrg IFS=$save_ifs 114147e89262Smrg eval cmd=\"$cmd\" 114247e89262Smrg func_show_eval "$cmd" "${2-:}" 114347e89262Smrg done 114447e89262Smrg IFS=$save_ifs 114547e89262Smrg} 114647e89262Smrg 114747e89262Smrg 114847e89262Smrg# func_source file 114947e89262Smrg# Source FILE, adding directory component if necessary. 115047e89262Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 115147e89262Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 115247e89262Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 115347e89262Smrg# `FILE.' does not work on cygwin managed mounts. 115447e89262Smrgfunc_source () 115547e89262Smrg{ 115647e89262Smrg $opt_debug 115747e89262Smrg case $1 in 115847e89262Smrg */* | *\\*) . "$1" ;; 115947e89262Smrg *) . "./$1" ;; 116047e89262Smrg esac 116147e89262Smrg} 116247e89262Smrg 116347e89262Smrg 116447e89262Smrg# func_infer_tag arg 116547e89262Smrg# Infer tagged configuration to use if any are available and 116647e89262Smrg# if one wasn't chosen via the "--tag" command line option. 116747e89262Smrg# Only attempt this if the compiler in the base compile 116847e89262Smrg# command doesn't match the default compiler. 116947e89262Smrg# arg is usually of the form 'gcc ...' 117047e89262Smrgfunc_infer_tag () 117147e89262Smrg{ 117247e89262Smrg $opt_debug 117347e89262Smrg if test -n "$available_tags" && test -z "$tagname"; then 117447e89262Smrg CC_quoted= 117547e89262Smrg for arg in $CC; do 117647e89262Smrg func_quote_for_eval "$arg" 117747e89262Smrg CC_quoted="$CC_quoted $func_quote_for_eval_result" 117847e89262Smrg done 117947e89262Smrg CC_expanded=`func_echo_all $CC` 118047e89262Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 118147e89262Smrg case $@ in 118247e89262Smrg # Blanks in the command may have been stripped by the calling shell, 118347e89262Smrg # but not from the CC environment variable when configure was run. 118447e89262Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 118547e89262Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 118647e89262Smrg # Blanks at the start of $base_compile will cause this to fail 118747e89262Smrg # if we don't check for them as well. 118847e89262Smrg *) 118947e89262Smrg for z in $available_tags; do 119047e89262Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 119147e89262Smrg # Evaluate the configuration. 119247e89262Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 119347e89262Smrg CC_quoted= 119447e89262Smrg for arg in $CC; do 119547e89262Smrg # Double-quote args containing other shell metacharacters. 119647e89262Smrg func_quote_for_eval "$arg" 119747e89262Smrg CC_quoted="$CC_quoted $func_quote_for_eval_result" 119847e89262Smrg done 119947e89262Smrg CC_expanded=`func_echo_all $CC` 120047e89262Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 120147e89262Smrg case "$@ " in 120247e89262Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 120347e89262Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 120447e89262Smrg # The compiler in the base compile command matches 120547e89262Smrg # the one in the tagged configuration. 120647e89262Smrg # Assume this is the tagged configuration we want. 120747e89262Smrg tagname=$z 120847e89262Smrg break 120947e89262Smrg ;; 121047e89262Smrg esac 121147e89262Smrg fi 121247e89262Smrg done 121347e89262Smrg # If $tagname still isn't set, then no tagged configuration 121447e89262Smrg # was found and let the user know that the "--tag" command 121547e89262Smrg # line option must be used. 121647e89262Smrg if test -z "$tagname"; then 121747e89262Smrg func_echo "unable to infer tagged configuration" 121847e89262Smrg func_fatal_error "specify a tag with \`--tag'" 121947e89262Smrg# else 122047e89262Smrg# func_verbose "using $tagname tagged configuration" 122147e89262Smrg fi 122247e89262Smrg ;; 122347e89262Smrg esac 122447e89262Smrg fi 122547e89262Smrg} 122647e89262Smrg 122747e89262Smrg 122847e89262Smrg 122947e89262Smrg# func_write_libtool_object output_name pic_name nonpic_name 123047e89262Smrg# Create a libtool object file (analogous to a ".la" file), 123147e89262Smrg# but don't create it if we're doing a dry run. 123247e89262Smrgfunc_write_libtool_object () 123347e89262Smrg{ 123447e89262Smrg write_libobj=${1} 123547e89262Smrg if test "$build_libtool_libs" = yes; then 123647e89262Smrg write_lobj=\'${2}\' 123747e89262Smrg else 123847e89262Smrg write_lobj=none 123947e89262Smrg fi 124047e89262Smrg 124147e89262Smrg if test "$build_old_libs" = yes; then 124247e89262Smrg write_oldobj=\'${3}\' 124347e89262Smrg else 124447e89262Smrg write_oldobj=none 124547e89262Smrg fi 124647e89262Smrg 124747e89262Smrg $opt_dry_run || { 124847e89262Smrg cat >${write_libobj}T <<EOF 124947e89262Smrg# $write_libobj - a libtool object file 125047e89262Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 125147e89262Smrg# 125247e89262Smrg# Please DO NOT delete this file! 125347e89262Smrg# It is necessary for linking the library. 125447e89262Smrg 125547e89262Smrg# Name of the PIC object. 125647e89262Smrgpic_object=$write_lobj 125747e89262Smrg 125847e89262Smrg# Name of the non-PIC object 125947e89262Smrgnon_pic_object=$write_oldobj 126047e89262Smrg 126147e89262SmrgEOF 126247e89262Smrg $MV "${write_libobj}T" "${write_libobj}" 126347e89262Smrg } 126447e89262Smrg} 126547e89262Smrg 126647e89262Smrg# func_mode_compile arg... 126747e89262Smrgfunc_mode_compile () 126847e89262Smrg{ 126947e89262Smrg $opt_debug 127047e89262Smrg # Get the compilation command and the source file. 127147e89262Smrg base_compile= 127247e89262Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 127347e89262Smrg suppress_opt=yes 127447e89262Smrg suppress_output= 127547e89262Smrg arg_mode=normal 127647e89262Smrg libobj= 127747e89262Smrg later= 127847e89262Smrg pie_flag= 127947e89262Smrg 128047e89262Smrg for arg 128147e89262Smrg do 128247e89262Smrg case $arg_mode in 128347e89262Smrg arg ) 128447e89262Smrg # do not "continue". Instead, add this to base_compile 128547e89262Smrg lastarg="$arg" 128647e89262Smrg arg_mode=normal 128747e89262Smrg ;; 128847e89262Smrg 128947e89262Smrg target ) 129047e89262Smrg libobj="$arg" 129147e89262Smrg arg_mode=normal 129247e89262Smrg continue 129347e89262Smrg ;; 129447e89262Smrg 129547e89262Smrg normal ) 129647e89262Smrg # Accept any command-line options. 129747e89262Smrg case $arg in 129847e89262Smrg -o) 129947e89262Smrg test -n "$libobj" && \ 130047e89262Smrg func_fatal_error "you cannot specify \`-o' more than once" 130147e89262Smrg arg_mode=target 130247e89262Smrg continue 130347e89262Smrg ;; 130447e89262Smrg 130547e89262Smrg -pie | -fpie | -fPIE) 130647e89262Smrg pie_flag="$pie_flag $arg" 130747e89262Smrg continue 130847e89262Smrg ;; 130947e89262Smrg 131047e89262Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 131147e89262Smrg later="$later $arg" 131247e89262Smrg continue 131347e89262Smrg ;; 1314bd1da9d7Smrg 1315bd1da9d7Smrg -no-suppress) 1316bd1da9d7Smrg suppress_opt=no 1317bd1da9d7Smrg continue 1318bd1da9d7Smrg ;; 1319bd1da9d7Smrg 1320bd1da9d7Smrg -Xcompiler) 1321bd1da9d7Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 1322bd1da9d7Smrg continue # The current "srcfile" will either be retained or 1323bd1da9d7Smrg ;; # replaced later. I would guess that would be a bug. 1324bd1da9d7Smrg 1325bd1da9d7Smrg -Wc,*) 132647e89262Smrg func_stripname '-Wc,' '' "$arg" 132747e89262Smrg args=$func_stripname_result 1328bd1da9d7Smrg lastarg= 1329bd1da9d7Smrg save_ifs="$IFS"; IFS=',' 133047e89262Smrg for arg in $args; do 1331bd1da9d7Smrg IFS="$save_ifs" 133247e89262Smrg func_quote_for_eval "$arg" 133347e89262Smrg lastarg="$lastarg $func_quote_for_eval_result" 1334bd1da9d7Smrg done 1335bd1da9d7Smrg IFS="$save_ifs" 133647e89262Smrg func_stripname ' ' '' "$lastarg" 133747e89262Smrg lastarg=$func_stripname_result 1338bd1da9d7Smrg 1339bd1da9d7Smrg # Add the arguments to base_compile. 1340bd1da9d7Smrg base_compile="$base_compile $lastarg" 1341bd1da9d7Smrg continue 1342bd1da9d7Smrg ;; 1343bd1da9d7Smrg 134447e89262Smrg *) 1345bd1da9d7Smrg # Accept the current argument as the source file. 1346bd1da9d7Smrg # The previous "srcfile" becomes the current argument. 1347bd1da9d7Smrg # 1348bd1da9d7Smrg lastarg="$srcfile" 1349bd1da9d7Smrg srcfile="$arg" 1350bd1da9d7Smrg ;; 1351bd1da9d7Smrg esac # case $arg 1352bd1da9d7Smrg ;; 1353bd1da9d7Smrg esac # case $arg_mode 1354bd1da9d7Smrg 1355bd1da9d7Smrg # Aesthetically quote the previous argument. 135647e89262Smrg func_quote_for_eval "$lastarg" 135747e89262Smrg base_compile="$base_compile $func_quote_for_eval_result" 1358bd1da9d7Smrg done # for arg 1359bd1da9d7Smrg 1360bd1da9d7Smrg case $arg_mode in 1361bd1da9d7Smrg arg) 136247e89262Smrg func_fatal_error "you must specify an argument for -Xcompile" 1363bd1da9d7Smrg ;; 1364bd1da9d7Smrg target) 136547e89262Smrg func_fatal_error "you must specify a target with \`-o'" 1366bd1da9d7Smrg ;; 1367bd1da9d7Smrg *) 1368bd1da9d7Smrg # Get the name of the library object. 136947e89262Smrg test -z "$libobj" && { 137047e89262Smrg func_basename "$srcfile" 137147e89262Smrg libobj="$func_basename_result" 137247e89262Smrg } 1373bd1da9d7Smrg ;; 1374bd1da9d7Smrg esac 1375bd1da9d7Smrg 1376bd1da9d7Smrg # Recognize several different file suffixes. 1377bd1da9d7Smrg # If the user specifies -o file.o, it is replaced with file.lo 1378bd1da9d7Smrg case $libobj in 137947e89262Smrg *.[cCFSifmso] | \ 138047e89262Smrg *.ada | *.adb | *.ads | *.asm | \ 138147e89262Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 138247e89262Smrg *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) 138347e89262Smrg func_xform "$libobj" 138447e89262Smrg libobj=$func_xform_result 138547e89262Smrg ;; 1386bd1da9d7Smrg esac 1387bd1da9d7Smrg 1388bd1da9d7Smrg case $libobj in 138947e89262Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 1390bd1da9d7Smrg *) 139147e89262Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 1392bd1da9d7Smrg ;; 1393bd1da9d7Smrg esac 1394bd1da9d7Smrg 1395bd1da9d7Smrg func_infer_tag $base_compile 1396bd1da9d7Smrg 1397bd1da9d7Smrg for arg in $later; do 1398bd1da9d7Smrg case $arg in 139947e89262Smrg -shared) 140047e89262Smrg test "$build_libtool_libs" != yes && \ 140147e89262Smrg func_fatal_configuration "can not build a shared library" 140247e89262Smrg build_old_libs=no 140347e89262Smrg continue 140447e89262Smrg ;; 140547e89262Smrg 1406bd1da9d7Smrg -static) 140747e89262Smrg build_libtool_libs=no 1408bd1da9d7Smrg build_old_libs=yes 1409bd1da9d7Smrg continue 1410bd1da9d7Smrg ;; 1411bd1da9d7Smrg 1412bd1da9d7Smrg -prefer-pic) 1413bd1da9d7Smrg pic_mode=yes 1414bd1da9d7Smrg continue 1415bd1da9d7Smrg ;; 1416bd1da9d7Smrg 1417bd1da9d7Smrg -prefer-non-pic) 1418bd1da9d7Smrg pic_mode=no 1419bd1da9d7Smrg continue 1420bd1da9d7Smrg ;; 1421bd1da9d7Smrg esac 1422bd1da9d7Smrg done 1423bd1da9d7Smrg 142447e89262Smrg func_quote_for_eval "$libobj" 142547e89262Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 142647e89262Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 142747e89262Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 142847e89262Smrg func_dirname_and_basename "$obj" "/" "" 142947e89262Smrg objname="$func_basename_result" 143047e89262Smrg xdir="$func_dirname_result" 1431bd1da9d7Smrg lobj=${xdir}$objdir/$objname 1432bd1da9d7Smrg 143347e89262Smrg test -z "$base_compile" && \ 143447e89262Smrg func_fatal_help "you must specify a compilation command" 1435bd1da9d7Smrg 1436bd1da9d7Smrg # Delete any leftover library objects. 1437bd1da9d7Smrg if test "$build_old_libs" = yes; then 1438bd1da9d7Smrg removelist="$obj $lobj $libobj ${libobj}T" 1439bd1da9d7Smrg else 1440bd1da9d7Smrg removelist="$lobj $libobj ${libobj}T" 1441bd1da9d7Smrg fi 1442bd1da9d7Smrg 1443bd1da9d7Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 1444bd1da9d7Smrg case $host_os in 144547e89262Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 1446bd1da9d7Smrg pic_mode=default 1447bd1da9d7Smrg ;; 1448bd1da9d7Smrg esac 1449bd1da9d7Smrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 1450bd1da9d7Smrg # non-PIC code in shared libraries is not supported 1451bd1da9d7Smrg pic_mode=default 1452bd1da9d7Smrg fi 1453bd1da9d7Smrg 1454bd1da9d7Smrg # Calculate the filename of the output object if compiler does 1455bd1da9d7Smrg # not support -o with -c 1456bd1da9d7Smrg if test "$compiler_c_o" = no; then 145747e89262Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 1458bd1da9d7Smrg lockfile="$output_obj.lock" 1459bd1da9d7Smrg else 1460bd1da9d7Smrg output_obj= 1461bd1da9d7Smrg need_locks=no 1462bd1da9d7Smrg lockfile= 1463bd1da9d7Smrg fi 1464bd1da9d7Smrg 1465bd1da9d7Smrg # Lock this critical section if it is needed 1466bd1da9d7Smrg # We use this script file to make the link, it avoids creating a new file 1467bd1da9d7Smrg if test "$need_locks" = yes; then 146847e89262Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 146947e89262Smrg func_echo "Waiting for $lockfile to be removed" 1470bd1da9d7Smrg sleep 2 1471bd1da9d7Smrg done 1472bd1da9d7Smrg elif test "$need_locks" = warn; then 1473bd1da9d7Smrg if test -f "$lockfile"; then 147447e89262Smrg $ECHO "\ 1475bd1da9d7Smrg*** ERROR, $lockfile exists and contains: 1476bd1da9d7Smrg`cat $lockfile 2>/dev/null` 1477bd1da9d7Smrg 1478bd1da9d7SmrgThis indicates that another process is trying to use the same 1479bd1da9d7Smrgtemporary object file, and libtool could not work around it because 1480bd1da9d7Smrgyour compiler does not support \`-c' and \`-o' together. If you 1481bd1da9d7Smrgrepeat this compilation, it may succeed, by chance, but you had better 1482bd1da9d7Smrgavoid parallel builds (make -j) in this platform, or get a better 1483bd1da9d7Smrgcompiler." 1484bd1da9d7Smrg 148547e89262Smrg $opt_dry_run || $RM $removelist 1486bd1da9d7Smrg exit $EXIT_FAILURE 1487bd1da9d7Smrg fi 148847e89262Smrg removelist="$removelist $output_obj" 148947e89262Smrg $ECHO "$srcfile" > "$lockfile" 1490bd1da9d7Smrg fi 1491bd1da9d7Smrg 149247e89262Smrg $opt_dry_run || $RM $removelist 149347e89262Smrg removelist="$removelist $lockfile" 149447e89262Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 149547e89262Smrg 1496bd1da9d7Smrg if test -n "$fix_srcfile_path"; then 1497bd1da9d7Smrg eval srcfile=\"$fix_srcfile_path\" 1498bd1da9d7Smrg fi 149947e89262Smrg func_quote_for_eval "$srcfile" 150047e89262Smrg qsrcfile=$func_quote_for_eval_result 1501bd1da9d7Smrg 1502bd1da9d7Smrg # Only build a PIC object if we are building libtool libraries. 1503bd1da9d7Smrg if test "$build_libtool_libs" = yes; then 1504bd1da9d7Smrg # Without this assignment, base_compile gets emptied. 1505bd1da9d7Smrg fbsd_hideous_sh_bug=$base_compile 1506bd1da9d7Smrg 1507bd1da9d7Smrg if test "$pic_mode" != no; then 1508bd1da9d7Smrg command="$base_compile $qsrcfile $pic_flag" 1509bd1da9d7Smrg else 1510bd1da9d7Smrg # Don't build PIC code 1511bd1da9d7Smrg command="$base_compile $qsrcfile" 1512bd1da9d7Smrg fi 1513bd1da9d7Smrg 151447e89262Smrg func_mkdir_p "$xdir$objdir" 1515bd1da9d7Smrg 1516bd1da9d7Smrg if test -z "$output_obj"; then 1517bd1da9d7Smrg # Place PIC objects in $objdir 1518bd1da9d7Smrg command="$command -o $lobj" 1519bd1da9d7Smrg fi 1520bd1da9d7Smrg 152147e89262Smrg func_show_eval_locale "$command" \ 152247e89262Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 1523bd1da9d7Smrg 1524bd1da9d7Smrg if test "$need_locks" = warn && 1525bd1da9d7Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 152647e89262Smrg $ECHO "\ 1527bd1da9d7Smrg*** ERROR, $lockfile contains: 1528bd1da9d7Smrg`cat $lockfile 2>/dev/null` 1529bd1da9d7Smrg 1530bd1da9d7Smrgbut it should contain: 1531bd1da9d7Smrg$srcfile 1532bd1da9d7Smrg 1533bd1da9d7SmrgThis indicates that another process is trying to use the same 1534bd1da9d7Smrgtemporary object file, and libtool could not work around it because 1535bd1da9d7Smrgyour compiler does not support \`-c' and \`-o' together. If you 1536bd1da9d7Smrgrepeat this compilation, it may succeed, by chance, but you had better 1537bd1da9d7Smrgavoid parallel builds (make -j) in this platform, or get a better 1538bd1da9d7Smrgcompiler." 1539bd1da9d7Smrg 154047e89262Smrg $opt_dry_run || $RM $removelist 1541bd1da9d7Smrg exit $EXIT_FAILURE 1542bd1da9d7Smrg fi 1543bd1da9d7Smrg 1544bd1da9d7Smrg # Just move the object if needed, then go on to compile the next one 1545bd1da9d7Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 154647e89262Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 154747e89262Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 1548bd1da9d7Smrg fi 1549bd1da9d7Smrg 1550bd1da9d7Smrg # Allow error messages only from the first compilation. 1551bd1da9d7Smrg if test "$suppress_opt" = yes; then 155247e89262Smrg suppress_output=' >/dev/null 2>&1' 1553bd1da9d7Smrg fi 1554bd1da9d7Smrg fi 1555bd1da9d7Smrg 1556bd1da9d7Smrg # Only build a position-dependent object if we build old libraries. 1557bd1da9d7Smrg if test "$build_old_libs" = yes; then 1558bd1da9d7Smrg if test "$pic_mode" != yes; then 1559bd1da9d7Smrg # Don't build PIC code 156047e89262Smrg command="$base_compile $qsrcfile$pie_flag" 1561bd1da9d7Smrg else 1562bd1da9d7Smrg command="$base_compile $qsrcfile $pic_flag" 1563bd1da9d7Smrg fi 1564bd1da9d7Smrg if test "$compiler_c_o" = yes; then 1565bd1da9d7Smrg command="$command -o $obj" 1566bd1da9d7Smrg fi 1567bd1da9d7Smrg 1568bd1da9d7Smrg # Suppress compiler output if we already did a PIC compilation. 1569bd1da9d7Smrg command="$command$suppress_output" 157047e89262Smrg func_show_eval_locale "$command" \ 157147e89262Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1572bd1da9d7Smrg 1573bd1da9d7Smrg if test "$need_locks" = warn && 1574bd1da9d7Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 157547e89262Smrg $ECHO "\ 1576bd1da9d7Smrg*** ERROR, $lockfile contains: 1577bd1da9d7Smrg`cat $lockfile 2>/dev/null` 1578bd1da9d7Smrg 1579bd1da9d7Smrgbut it should contain: 1580bd1da9d7Smrg$srcfile 1581bd1da9d7Smrg 1582bd1da9d7SmrgThis indicates that another process is trying to use the same 1583bd1da9d7Smrgtemporary object file, and libtool could not work around it because 1584bd1da9d7Smrgyour compiler does not support \`-c' and \`-o' together. If you 1585bd1da9d7Smrgrepeat this compilation, it may succeed, by chance, but you had better 1586bd1da9d7Smrgavoid parallel builds (make -j) in this platform, or get a better 1587bd1da9d7Smrgcompiler." 1588bd1da9d7Smrg 158947e89262Smrg $opt_dry_run || $RM $removelist 1590bd1da9d7Smrg exit $EXIT_FAILURE 1591bd1da9d7Smrg fi 1592bd1da9d7Smrg 1593bd1da9d7Smrg # Just move the object if needed 1594bd1da9d7Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 159547e89262Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 159647e89262Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 1597bd1da9d7Smrg fi 1598bd1da9d7Smrg fi 1599bd1da9d7Smrg 160047e89262Smrg $opt_dry_run || { 160147e89262Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 1602bd1da9d7Smrg 160347e89262Smrg # Unlock the critical section if it was locked 160447e89262Smrg if test "$need_locks" != no; then 160547e89262Smrg removelist=$lockfile 160647e89262Smrg $RM "$lockfile" 160747e89262Smrg fi 160847e89262Smrg } 1609bd1da9d7Smrg 1610bd1da9d7Smrg exit $EXIT_SUCCESS 161147e89262Smrg} 1612bd1da9d7Smrg 161347e89262Smrg$opt_help || { 161447e89262Smrg test "$mode" = compile && func_mode_compile ${1+"$@"} 161547e89262Smrg} 1616bd1da9d7Smrg 161747e89262Smrgfunc_mode_help () 161847e89262Smrg{ 161947e89262Smrg # We need to display help for each of the modes. 162047e89262Smrg case $mode in 162147e89262Smrg "") 162247e89262Smrg # Generic help is extracted from the usage comments 162347e89262Smrg # at the start of this file. 162447e89262Smrg func_help 162547e89262Smrg ;; 1626bd1da9d7Smrg 162747e89262Smrg clean) 162847e89262Smrg $ECHO \ 162947e89262Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 1630bd1da9d7Smrg 163147e89262SmrgRemove files from the build directory. 1632bd1da9d7Smrg 163347e89262SmrgRM is the name of the program to use to delete files associated with each FILE 163447e89262Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 163547e89262Smrgto RM. 1636bd1da9d7Smrg 163747e89262SmrgIf FILE is a libtool library, object or program, all the files associated 163847e89262Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 163947e89262Smrg ;; 1640bd1da9d7Smrg 164147e89262Smrg compile) 164247e89262Smrg $ECHO \ 164347e89262Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 1644bd1da9d7Smrg 164547e89262SmrgCompile a source file into a libtool library object. 1646bd1da9d7Smrg 164747e89262SmrgThis mode accepts the following additional options: 1648bd1da9d7Smrg 164947e89262Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 165047e89262Smrg -no-suppress do not suppress compiler output for multiple passes 165147e89262Smrg -prefer-pic try to build PIC objects only 165247e89262Smrg -prefer-non-pic try to build non-PIC objects only 165347e89262Smrg -shared do not build a \`.o' file suitable for static linking 165447e89262Smrg -static only build a \`.o' file suitable for static linking 165547e89262Smrg -Wc,FLAG pass FLAG directly to the compiler 1656bd1da9d7Smrg 165747e89262SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 165847e89262Smrgfrom the given SOURCEFILE. 1659bd1da9d7Smrg 166047e89262SmrgThe output file name is determined by removing the directory component from 166147e89262SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 166247e89262Smrglibrary object suffix, \`.lo'." 166347e89262Smrg ;; 1664bd1da9d7Smrg 166547e89262Smrg execute) 166647e89262Smrg $ECHO \ 166747e89262Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 1668bd1da9d7Smrg 166947e89262SmrgAutomatically set library path, then run a program. 1670bd1da9d7Smrg 167147e89262SmrgThis mode accepts the following additional options: 1672bd1da9d7Smrg 167347e89262Smrg -dlopen FILE add the directory containing FILE to the library path 1674bd1da9d7Smrg 167547e89262SmrgThis mode sets the library path environment variable according to \`-dlopen' 167647e89262Smrgflags. 1677bd1da9d7Smrg 167847e89262SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 167947e89262Smrginto their corresponding uninstalled binary, and any of their required library 168047e89262Smrgdirectories are added to the library path. 1681bd1da9d7Smrg 168247e89262SmrgThen, COMMAND is executed, with ARGS as arguments." 168347e89262Smrg ;; 1684bd1da9d7Smrg 168547e89262Smrg finish) 168647e89262Smrg $ECHO \ 168747e89262Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 1688bd1da9d7Smrg 168947e89262SmrgComplete the installation of libtool libraries. 1690bd1da9d7Smrg 169147e89262SmrgEach LIBDIR is a directory that contains libtool libraries. 1692bd1da9d7Smrg 169347e89262SmrgThe commands that this mode executes may require superuser privileges. Use 169447e89262Smrgthe \`--dry-run' option if you just want to see what would be executed." 169547e89262Smrg ;; 1696bd1da9d7Smrg 169747e89262Smrg install) 169847e89262Smrg $ECHO \ 169947e89262Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 1700bd1da9d7Smrg 170147e89262SmrgInstall executables or libraries. 1702bd1da9d7Smrg 170347e89262SmrgINSTALL-COMMAND is the installation command. The first component should be 170447e89262Smrgeither the \`install' or \`cp' program. 1705bd1da9d7Smrg 170647e89262SmrgThe following components of INSTALL-COMMAND are treated specially: 1707bd1da9d7Smrg 170847e89262Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 1709bd1da9d7Smrg 171047e89262SmrgThe rest of the components are interpreted as arguments to that command (only 171147e89262SmrgBSD-compatible install options are recognized)." 171247e89262Smrg ;; 1713bd1da9d7Smrg 171447e89262Smrg link) 171547e89262Smrg $ECHO \ 171647e89262Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 1717bd1da9d7Smrg 171847e89262SmrgLink object files or libraries together to form another library, or to 171947e89262Smrgcreate an executable program. 1720bd1da9d7Smrg 172147e89262SmrgLINK-COMMAND is a command using the C compiler that you would use to create 172247e89262Smrga program from several object files. 1723bd1da9d7Smrg 172447e89262SmrgThe following components of LINK-COMMAND are treated specially: 1725bd1da9d7Smrg 172647e89262Smrg -all-static do not do any dynamic linking at all 172747e89262Smrg -avoid-version do not add a version suffix if possible 172847e89262Smrg -bindir BINDIR specify path to binaries directory (for systems where 172947e89262Smrg libraries must be found in the PATH setting at runtime) 173047e89262Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 173147e89262Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 173247e89262Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 173347e89262Smrg -export-symbols SYMFILE 173447e89262Smrg try to export only the symbols listed in SYMFILE 173547e89262Smrg -export-symbols-regex REGEX 173647e89262Smrg try to export only the symbols matching REGEX 173747e89262Smrg -LLIBDIR search LIBDIR for required installed libraries 173847e89262Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 173947e89262Smrg -module build a library that can dlopened 174047e89262Smrg -no-fast-install disable the fast-install mode 174147e89262Smrg -no-install link a not-installable executable 174247e89262Smrg -no-undefined declare that a library does not refer to external symbols 174347e89262Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 174447e89262Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 174547e89262Smrg -precious-files-regex REGEX 174647e89262Smrg don't remove output files matching REGEX 174747e89262Smrg -release RELEASE specify package release information 174847e89262Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 174947e89262Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 175047e89262Smrg -shared only do dynamic linking of libtool libraries 175147e89262Smrg -shrext SUFFIX override the standard shared library file extension 175247e89262Smrg -static do not do any dynamic linking of uninstalled libtool libraries 175347e89262Smrg -static-libtool-libs 175447e89262Smrg do not do any dynamic linking of libtool libraries 175547e89262Smrg -version-info CURRENT[:REVISION[:AGE]] 175647e89262Smrg specify library version info [each variable defaults to 0] 175747e89262Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 175847e89262Smrg -Wc,FLAG 175947e89262Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 176047e89262Smrg -Wl,FLAG 176147e89262Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 176247e89262Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 1763bd1da9d7Smrg 176447e89262SmrgAll other options (arguments beginning with \`-') are ignored. 1765bd1da9d7Smrg 176647e89262SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 176747e89262Smrgtreated as uninstalled libtool libraries, other files are standard or library 176847e89262Smrgobject files. 1769bd1da9d7Smrg 177047e89262SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 177147e89262Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 177247e89262Smrgrequired, except when creating a convenience library. 1773bd1da9d7Smrg 177447e89262SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 177547e89262Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 17765bcb6992Smrg 177747e89262SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 177847e89262Smrgis created, otherwise an executable program is created." 177947e89262Smrg ;; 1780bd1da9d7Smrg 178147e89262Smrg uninstall) 178247e89262Smrg $ECHO \ 178347e89262Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 1784bd1da9d7Smrg 178547e89262SmrgRemove libraries from an installation directory. 1786bd1da9d7Smrg 178747e89262SmrgRM is the name of the program to use to delete files associated with each FILE 178847e89262Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 178947e89262Smrgto RM. 1790bd1da9d7Smrg 179147e89262SmrgIf FILE is a libtool library, all the files associated with it are deleted. 179247e89262SmrgOtherwise, only FILE itself is deleted using RM." 179347e89262Smrg ;; 1794bd1da9d7Smrg 179547e89262Smrg *) 179647e89262Smrg func_fatal_help "invalid operation mode \`$mode'" 179747e89262Smrg ;; 179847e89262Smrg esac 1799bd1da9d7Smrg 180047e89262Smrg echo 180147e89262Smrg $ECHO "Try \`$progname --help' for more information about other modes." 180247e89262Smrg} 1803bd1da9d7Smrg 180447e89262Smrg# Now that we've collected a possible --mode arg, show help if necessary 180547e89262Smrgif $opt_help; then 180647e89262Smrg if test "$opt_help" = :; then 180747e89262Smrg func_mode_help 180847e89262Smrg else 180947e89262Smrg { 181047e89262Smrg func_help noexit 181147e89262Smrg for mode in compile link execute install finish uninstall clean; do 181247e89262Smrg func_mode_help 181347e89262Smrg done 181447e89262Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 181547e89262Smrg { 181647e89262Smrg func_help noexit 181747e89262Smrg for mode in compile link execute install finish uninstall clean; do 181847e89262Smrg echo 181947e89262Smrg func_mode_help 182047e89262Smrg done 182147e89262Smrg } | 182247e89262Smrg sed '1d 182347e89262Smrg /^When reporting/,/^Report/{ 182447e89262Smrg H 182547e89262Smrg d 182647e89262Smrg } 182747e89262Smrg $x 182847e89262Smrg /information about other modes/d 182947e89262Smrg /more detailed .*MODE/d 183047e89262Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 183147e89262Smrg fi 183247e89262Smrg exit $? 183347e89262Smrgfi 1834bd1da9d7Smrg 1835bd1da9d7Smrg 183647e89262Smrg# func_mode_execute arg... 183747e89262Smrgfunc_mode_execute () 183847e89262Smrg{ 183947e89262Smrg $opt_debug 184047e89262Smrg # The first argument is the command name. 184147e89262Smrg cmd="$nonopt" 184247e89262Smrg test -z "$cmd" && \ 184347e89262Smrg func_fatal_help "you must specify a COMMAND" 1844bd1da9d7Smrg 184547e89262Smrg # Handle -dlopen flags immediately. 184647e89262Smrg for file in $execute_dlfiles; do 184747e89262Smrg test -f "$file" \ 184847e89262Smrg || func_fatal_help "\`$file' is not a file" 1849bd1da9d7Smrg 185047e89262Smrg dir= 185147e89262Smrg case $file in 185247e89262Smrg *.la) 185347e89262Smrg # Check to see that this really is a libtool archive. 185447e89262Smrg func_lalib_unsafe_p "$file" \ 185547e89262Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 1856bd1da9d7Smrg 185747e89262Smrg # Read the libtool library. 185847e89262Smrg dlname= 185947e89262Smrg library_names= 186047e89262Smrg func_source "$file" 1861bd1da9d7Smrg 186247e89262Smrg # Skip this library if it cannot be dlopened. 186347e89262Smrg if test -z "$dlname"; then 186447e89262Smrg # Warn if it was a shared library. 186547e89262Smrg test -n "$library_names" && \ 186647e89262Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 186747e89262Smrg continue 186847e89262Smrg fi 1869bd1da9d7Smrg 187047e89262Smrg func_dirname "$file" "" "." 187147e89262Smrg dir="$func_dirname_result" 1872bd1da9d7Smrg 187347e89262Smrg if test -f "$dir/$objdir/$dlname"; then 187447e89262Smrg dir="$dir/$objdir" 187547e89262Smrg else 187647e89262Smrg if test ! -f "$dir/$dlname"; then 187747e89262Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 187847e89262Smrg fi 187947e89262Smrg fi 1880bd1da9d7Smrg ;; 1881bd1da9d7Smrg 188247e89262Smrg *.lo) 188347e89262Smrg # Just add the directory containing the .lo file. 188447e89262Smrg func_dirname "$file" "" "." 188547e89262Smrg dir="$func_dirname_result" 1886bd1da9d7Smrg ;; 188747e89262Smrg 188847e89262Smrg *) 188947e89262Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 1890bd1da9d7Smrg continue 1891bd1da9d7Smrg ;; 189247e89262Smrg esac 1893bd1da9d7Smrg 189447e89262Smrg # Get the absolute pathname. 189547e89262Smrg absdir=`cd "$dir" && pwd` 189647e89262Smrg test -n "$absdir" && dir="$absdir" 1897bd1da9d7Smrg 189847e89262Smrg # Now add the directory to shlibpath_var. 189947e89262Smrg if eval "test -z \"\$$shlibpath_var\""; then 190047e89262Smrg eval "$shlibpath_var=\"\$dir\"" 190147e89262Smrg else 190247e89262Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 190347e89262Smrg fi 190447e89262Smrg done 1905bd1da9d7Smrg 190647e89262Smrg # This variable tells wrapper scripts just to set shlibpath_var 190747e89262Smrg # rather than running their programs. 190847e89262Smrg libtool_execute_magic="$magic" 1909bd1da9d7Smrg 191047e89262Smrg # Check if any of the arguments is a wrapper script. 191147e89262Smrg args= 191247e89262Smrg for file 191347e89262Smrg do 191447e89262Smrg case $file in 191547e89262Smrg -* | *.la | *.lo ) ;; 191647e89262Smrg *) 191747e89262Smrg # Do a test to see if this is really a libtool program. 191847e89262Smrg if func_ltwrapper_script_p "$file"; then 191947e89262Smrg func_source "$file" 192047e89262Smrg # Transform arg to wrapped name. 192147e89262Smrg file="$progdir/$program" 192247e89262Smrg elif func_ltwrapper_executable_p "$file"; then 192347e89262Smrg func_ltwrapper_scriptname "$file" 192447e89262Smrg func_source "$func_ltwrapper_scriptname_result" 192547e89262Smrg # Transform arg to wrapped name. 192647e89262Smrg file="$progdir/$program" 192747e89262Smrg fi 1928bd1da9d7Smrg ;; 192947e89262Smrg esac 193047e89262Smrg # Quote arguments (to preserve shell metacharacters). 193147e89262Smrg func_quote_for_eval "$file" 193247e89262Smrg args="$args $func_quote_for_eval_result" 193347e89262Smrg done 1934bd1da9d7Smrg 193547e89262Smrg if test "X$opt_dry_run" = Xfalse; then 193647e89262Smrg if test -n "$shlibpath_var"; then 193747e89262Smrg # Export the shlibpath_var. 193847e89262Smrg eval "export $shlibpath_var" 193947e89262Smrg fi 1940bd1da9d7Smrg 194147e89262Smrg # Restore saved environment variables 194247e89262Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 194347e89262Smrg do 194447e89262Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 194547e89262Smrg $lt_var=\$save_$lt_var; export $lt_var 194647e89262Smrg else 194747e89262Smrg $lt_unset $lt_var 194847e89262Smrg fi" 194947e89262Smrg done 1950bd1da9d7Smrg 195147e89262Smrg # Now prepare to actually exec the command. 195247e89262Smrg exec_cmd="\$cmd$args" 195347e89262Smrg else 195447e89262Smrg # Display what would be done. 195547e89262Smrg if test -n "$shlibpath_var"; then 195647e89262Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 195747e89262Smrg echo "export $shlibpath_var" 195847e89262Smrg fi 195947e89262Smrg $ECHO "$cmd$args" 196047e89262Smrg exit $EXIT_SUCCESS 196147e89262Smrg fi 196247e89262Smrg} 1963bd1da9d7Smrg 196447e89262Smrgtest "$mode" = execute && func_mode_execute ${1+"$@"} 1965bd1da9d7Smrg 1966bd1da9d7Smrg 196747e89262Smrg# func_mode_finish arg... 196847e89262Smrgfunc_mode_finish () 196947e89262Smrg{ 197047e89262Smrg $opt_debug 197147e89262Smrg libdirs="$nonopt" 197247e89262Smrg admincmds= 1973bd1da9d7Smrg 197447e89262Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 197547e89262Smrg for dir 197647e89262Smrg do 197747e89262Smrg libdirs="$libdirs $dir" 197847e89262Smrg done 1979bd1da9d7Smrg 198047e89262Smrg for libdir in $libdirs; do 198147e89262Smrg if test -n "$finish_cmds"; then 198247e89262Smrg # Do each command in the finish commands. 198347e89262Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 198447e89262Smrg'"$cmd"'"' 198547e89262Smrg fi 198647e89262Smrg if test -n "$finish_eval"; then 198747e89262Smrg # Do the single finish_eval. 198847e89262Smrg eval cmds=\"$finish_eval\" 198947e89262Smrg $opt_dry_run || eval "$cmds" || admincmds="$admincmds 199047e89262Smrg $cmds" 199147e89262Smrg fi 199247e89262Smrg done 199347e89262Smrg fi 1994bd1da9d7Smrg 199547e89262Smrg # Exit here if they wanted silent mode. 199647e89262Smrg $opt_silent && exit $EXIT_SUCCESS 1997bd1da9d7Smrg 199847e89262Smrg echo "----------------------------------------------------------------------" 199947e89262Smrg echo "Libraries have been installed in:" 200047e89262Smrg for libdir in $libdirs; do 200147e89262Smrg $ECHO " $libdir" 200247e89262Smrg done 200347e89262Smrg echo 200447e89262Smrg echo "If you ever happen to want to link against installed libraries" 200547e89262Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 200647e89262Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 200747e89262Smrg echo "flag during linking and do at least one of the following:" 200847e89262Smrg if test -n "$shlibpath_var"; then 200947e89262Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 201047e89262Smrg echo " during execution" 201147e89262Smrg fi 201247e89262Smrg if test -n "$runpath_var"; then 201347e89262Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 201447e89262Smrg echo " during linking" 201547e89262Smrg fi 201647e89262Smrg if test -n "$hardcode_libdir_flag_spec"; then 201747e89262Smrg libdir=LIBDIR 201847e89262Smrg eval flag=\"$hardcode_libdir_flag_spec\" 2019bd1da9d7Smrg 202047e89262Smrg $ECHO " - use the \`$flag' linker flag" 202147e89262Smrg fi 202247e89262Smrg if test -n "$admincmds"; then 202347e89262Smrg $ECHO " - have your system administrator run these commands:$admincmds" 202447e89262Smrg fi 202547e89262Smrg if test -f /etc/ld.so.conf; then 202647e89262Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 202747e89262Smrg fi 202847e89262Smrg echo 2029bd1da9d7Smrg 203047e89262Smrg echo "See any operating system documentation about shared libraries for" 203147e89262Smrg case $host in 203247e89262Smrg solaris2.[6789]|solaris2.1[0-9]) 203347e89262Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 203447e89262Smrg echo "pages." 203547e89262Smrg ;; 203647e89262Smrg *) 203747e89262Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 203847e89262Smrg ;; 203947e89262Smrg esac 204047e89262Smrg echo "----------------------------------------------------------------------" 204147e89262Smrg exit $EXIT_SUCCESS 204247e89262Smrg} 2043bd1da9d7Smrg 204447e89262Smrgtest "$mode" = finish && func_mode_finish ${1+"$@"} 2045bd1da9d7Smrg 2046bd1da9d7Smrg 204747e89262Smrg# func_mode_install arg... 204847e89262Smrgfunc_mode_install () 204947e89262Smrg{ 205047e89262Smrg $opt_debug 205147e89262Smrg # There may be an optional sh(1) argument at the beginning of 205247e89262Smrg # install_prog (especially on Windows NT). 205347e89262Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 205447e89262Smrg # Allow the use of GNU shtool's install command. 205547e89262Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 205647e89262Smrg # Aesthetically quote it. 205747e89262Smrg func_quote_for_eval "$nonopt" 205847e89262Smrg install_prog="$func_quote_for_eval_result " 205947e89262Smrg arg=$1 206047e89262Smrg shift 206147e89262Smrg else 206247e89262Smrg install_prog= 206347e89262Smrg arg=$nonopt 206447e89262Smrg fi 2065bd1da9d7Smrg 206647e89262Smrg # The real first argument should be the name of the installation program. 206747e89262Smrg # Aesthetically quote it. 206847e89262Smrg func_quote_for_eval "$arg" 206947e89262Smrg install_prog="$install_prog$func_quote_for_eval_result" 207047e89262Smrg install_shared_prog=$install_prog 207147e89262Smrg case " $install_prog " in 207247e89262Smrg *[\\\ /]cp\ *) install_cp=: ;; 207347e89262Smrg *) install_cp=false ;; 207447e89262Smrg esac 2075bd1da9d7Smrg 207647e89262Smrg # We need to accept at least all the BSD install flags. 207747e89262Smrg dest= 207847e89262Smrg files= 207947e89262Smrg opts= 208047e89262Smrg prev= 208147e89262Smrg install_type= 208247e89262Smrg isdir=no 208347e89262Smrg stripme= 208447e89262Smrg no_mode=: 208547e89262Smrg for arg 208647e89262Smrg do 208747e89262Smrg arg2= 208847e89262Smrg if test -n "$dest"; then 208947e89262Smrg files="$files $dest" 209047e89262Smrg dest=$arg 2091bd1da9d7Smrg continue 209247e89262Smrg fi 2093bd1da9d7Smrg 209447e89262Smrg case $arg in 209547e89262Smrg -d) isdir=yes ;; 209647e89262Smrg -f) 209747e89262Smrg if $install_cp; then :; else 209847e89262Smrg prev=$arg 2099bd1da9d7Smrg fi 210047e89262Smrg ;; 210147e89262Smrg -g | -m | -o) 210247e89262Smrg prev=$arg 210347e89262Smrg ;; 210447e89262Smrg -s) 210547e89262Smrg stripme=" -s" 2106bd1da9d7Smrg continue 2107bd1da9d7Smrg ;; 210847e89262Smrg -*) 210947e89262Smrg ;; 2110bd1da9d7Smrg *) 211147e89262Smrg # If the previous option needed an argument, then skip it. 211247e89262Smrg if test -n "$prev"; then 211347e89262Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 211447e89262Smrg arg2=$install_override_mode 211547e89262Smrg no_mode=false 211647e89262Smrg fi 211747e89262Smrg prev= 211847e89262Smrg else 211947e89262Smrg dest=$arg 212047e89262Smrg continue 212147e89262Smrg fi 2122bd1da9d7Smrg ;; 212347e89262Smrg esac 2124bd1da9d7Smrg 212547e89262Smrg # Aesthetically quote the argument. 212647e89262Smrg func_quote_for_eval "$arg" 212747e89262Smrg install_prog="$install_prog $func_quote_for_eval_result" 212847e89262Smrg if test -n "$arg2"; then 212947e89262Smrg func_quote_for_eval "$arg2" 2130bd1da9d7Smrg fi 213147e89262Smrg install_shared_prog="$install_shared_prog $func_quote_for_eval_result" 213247e89262Smrg done 2133bd1da9d7Smrg 213447e89262Smrg test -z "$install_prog" && \ 213547e89262Smrg func_fatal_help "you must specify an install program" 2136bd1da9d7Smrg 213747e89262Smrg test -n "$prev" && \ 213847e89262Smrg func_fatal_help "the \`$prev' option requires an argument" 2139bd1da9d7Smrg 214047e89262Smrg if test -n "$install_override_mode" && $no_mode; then 214147e89262Smrg if $install_cp; then :; else 214247e89262Smrg func_quote_for_eval "$install_override_mode" 214347e89262Smrg install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result" 214447e89262Smrg fi 2145bd1da9d7Smrg fi 2146bd1da9d7Smrg 214747e89262Smrg if test -z "$files"; then 214847e89262Smrg if test -z "$dest"; then 214947e89262Smrg func_fatal_help "no file or destination specified" 215047e89262Smrg else 215147e89262Smrg func_fatal_help "you must specify a destination" 2152bd1da9d7Smrg fi 2153bd1da9d7Smrg fi 2154bd1da9d7Smrg 215547e89262Smrg # Strip any trailing slash from the destination. 215647e89262Smrg func_stripname '' '/' "$dest" 215747e89262Smrg dest=$func_stripname_result 2158bd1da9d7Smrg 215947e89262Smrg # Check to see that the destination is a directory. 216047e89262Smrg test -d "$dest" && isdir=yes 216147e89262Smrg if test "$isdir" = yes; then 216247e89262Smrg destdir="$dest" 216347e89262Smrg destname= 216447e89262Smrg else 216547e89262Smrg func_dirname_and_basename "$dest" "" "." 216647e89262Smrg destdir="$func_dirname_result" 216747e89262Smrg destname="$func_basename_result" 216847e89262Smrg 216947e89262Smrg # Not a directory, so check to see that there is only one file specified. 217047e89262Smrg set dummy $files; shift 217147e89262Smrg test "$#" -gt 1 && \ 217247e89262Smrg func_fatal_help "\`$dest' is not a directory" 217347e89262Smrg fi 217447e89262Smrg case $destdir in 217547e89262Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 2176bd1da9d7Smrg *) 217747e89262Smrg for file in $files; do 217847e89262Smrg case $file in 217947e89262Smrg *.lo) ;; 218047e89262Smrg *) 218147e89262Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 218247e89262Smrg ;; 218347e89262Smrg esac 218447e89262Smrg done 2185bd1da9d7Smrg ;; 2186bd1da9d7Smrg esac 2187bd1da9d7Smrg 218847e89262Smrg # This variable tells wrapper scripts just to set variables rather 218947e89262Smrg # than running their programs. 219047e89262Smrg libtool_install_magic="$magic" 2191bd1da9d7Smrg 219247e89262Smrg staticlibs= 219347e89262Smrg future_libdirs= 219447e89262Smrg current_libdirs= 219547e89262Smrg for file in $files; do 2196bd1da9d7Smrg 219747e89262Smrg # Do each installation. 219847e89262Smrg case $file in 219947e89262Smrg *.$libext) 220047e89262Smrg # Do the static libraries later. 220147e89262Smrg staticlibs="$staticlibs $file" 220247e89262Smrg ;; 220347e89262Smrg 220447e89262Smrg *.la) 220547e89262Smrg # Check to see that this really is a libtool archive. 220647e89262Smrg func_lalib_unsafe_p "$file" \ 220747e89262Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 220847e89262Smrg 220947e89262Smrg library_names= 221047e89262Smrg old_library= 221147e89262Smrg relink_command= 221247e89262Smrg func_source "$file" 221347e89262Smrg 221447e89262Smrg # Add the libdir to current_libdirs if it is the destination. 221547e89262Smrg if test "X$destdir" = "X$libdir"; then 221647e89262Smrg case "$current_libdirs " in 221747e89262Smrg *" $libdir "*) ;; 221847e89262Smrg *) current_libdirs="$current_libdirs $libdir" ;; 2219bd1da9d7Smrg esac 222047e89262Smrg else 222147e89262Smrg # Note the libdir as a future libdir. 222247e89262Smrg case "$future_libdirs " in 222347e89262Smrg *" $libdir "*) ;; 222447e89262Smrg *) future_libdirs="$future_libdirs $libdir" ;; 222547e89262Smrg esac 222647e89262Smrg fi 2227bd1da9d7Smrg 222847e89262Smrg func_dirname "$file" "/" "" 222947e89262Smrg dir="$func_dirname_result" 223047e89262Smrg dir="$dir$objdir" 223147e89262Smrg 223247e89262Smrg if test -n "$relink_command"; then 223347e89262Smrg # Determine the prefix the user has applied to our future dir. 223447e89262Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 223547e89262Smrg 223647e89262Smrg # Don't allow the user to place us outside of our expected 223747e89262Smrg # location b/c this prevents finding dependent libraries that 223847e89262Smrg # are installed to the same prefix. 223947e89262Smrg # At present, this check doesn't affect windows .dll's that 224047e89262Smrg # are installed into $libdir/../bin (currently, that works fine) 224147e89262Smrg # but it's something to keep an eye on. 224247e89262Smrg test "$inst_prefix_dir" = "$destdir" && \ 224347e89262Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 224447e89262Smrg 224547e89262Smrg if test -n "$inst_prefix_dir"; then 224647e89262Smrg # Stick the inst_prefix_dir data into the link command. 224747e89262Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 224847e89262Smrg else 224947e89262Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 225047e89262Smrg fi 225147e89262Smrg 225247e89262Smrg func_warning "relinking \`$file'" 225347e89262Smrg func_show_eval "$relink_command" \ 225447e89262Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 225547e89262Smrg fi 225647e89262Smrg 225747e89262Smrg # See the names of the shared library. 225847e89262Smrg set dummy $library_names; shift 225947e89262Smrg if test -n "$1"; then 226047e89262Smrg realname="$1" 226147e89262Smrg shift 226247e89262Smrg 226347e89262Smrg srcname="$realname" 226447e89262Smrg test -n "$relink_command" && srcname="$realname"T 226547e89262Smrg 226647e89262Smrg # Install the shared library and build the symlinks. 226747e89262Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 226847e89262Smrg 'exit $?' 226947e89262Smrg tstripme="$stripme" 227047e89262Smrg case $host_os in 227147e89262Smrg cygwin* | mingw* | pw32* | cegcc*) 227247e89262Smrg case $realname in 227347e89262Smrg *.dll.a) 227447e89262Smrg tstripme="" 227547e89262Smrg ;; 227647e89262Smrg esac 2277bd1da9d7Smrg ;; 2278bd1da9d7Smrg esac 227947e89262Smrg if test -n "$tstripme" && test -n "$striplib"; then 228047e89262Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 228147e89262Smrg fi 228247e89262Smrg 228347e89262Smrg if test "$#" -gt 0; then 228447e89262Smrg # Delete the old symlinks, and create new ones. 228547e89262Smrg # Try `ln -sf' first, because the `ln' binary might depend on 228647e89262Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 228747e89262Smrg # so we also need to try rm && ln -s. 228847e89262Smrg for linkname 228947e89262Smrg do 229047e89262Smrg test "$linkname" != "$realname" \ 229147e89262Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 229247e89262Smrg done 229347e89262Smrg fi 229447e89262Smrg 229547e89262Smrg # Do each command in the postinstall commands. 229647e89262Smrg lib="$destdir/$realname" 229747e89262Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 229847e89262Smrg fi 229947e89262Smrg 230047e89262Smrg # Install the pseudo-library for information purposes. 230147e89262Smrg func_basename "$file" 230247e89262Smrg name="$func_basename_result" 230347e89262Smrg instname="$dir/$name"i 230447e89262Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 230547e89262Smrg 230647e89262Smrg # Maybe install the static library, too. 230747e89262Smrg test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" 2308bd1da9d7Smrg ;; 230947e89262Smrg 231047e89262Smrg *.lo) 231147e89262Smrg # Install (i.e. copy) a libtool object. 231247e89262Smrg 231347e89262Smrg # Figure out destination file name, if it wasn't already specified. 231447e89262Smrg if test -n "$destname"; then 231547e89262Smrg destfile="$destdir/$destname" 231647e89262Smrg else 231747e89262Smrg func_basename "$file" 231847e89262Smrg destfile="$func_basename_result" 231947e89262Smrg destfile="$destdir/$destfile" 232047e89262Smrg fi 232147e89262Smrg 232247e89262Smrg # Deduce the name of the destination old-style object file. 232347e89262Smrg case $destfile in 232447e89262Smrg *.lo) 232547e89262Smrg func_lo2o "$destfile" 232647e89262Smrg staticdest=$func_lo2o_result 2327bd1da9d7Smrg ;; 232847e89262Smrg *.$objext) 232947e89262Smrg staticdest="$destfile" 233047e89262Smrg destfile= 2331bd1da9d7Smrg ;; 233247e89262Smrg *) 233347e89262Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 2334bd1da9d7Smrg ;; 233547e89262Smrg esac 233647e89262Smrg 233747e89262Smrg # Install the libtool object if requested. 233847e89262Smrg test -n "$destfile" && \ 233947e89262Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 234047e89262Smrg 234147e89262Smrg # Install the old object if enabled. 234247e89262Smrg if test "$build_old_libs" = yes; then 234347e89262Smrg # Deduce the name of the old-style object file. 234447e89262Smrg func_lo2o "$file" 234547e89262Smrg staticobj=$func_lo2o_result 234647e89262Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 2347bd1da9d7Smrg fi 234847e89262Smrg exit $EXIT_SUCCESS 234947e89262Smrg ;; 2350bd1da9d7Smrg 235147e89262Smrg *) 235247e89262Smrg # Figure out destination file name, if it wasn't already specified. 235347e89262Smrg if test -n "$destname"; then 235447e89262Smrg destfile="$destdir/$destname" 2355bd1da9d7Smrg else 235647e89262Smrg func_basename "$file" 235747e89262Smrg destfile="$func_basename_result" 235847e89262Smrg destfile="$destdir/$destfile" 2359bd1da9d7Smrg fi 2360bd1da9d7Smrg 236147e89262Smrg # If the file is missing, and there is a .exe on the end, strip it 236247e89262Smrg # because it is most likely a libtool script we actually want to 236347e89262Smrg # install 236447e89262Smrg stripped_ext="" 236547e89262Smrg case $file in 236647e89262Smrg *.exe) 236747e89262Smrg if test ! -f "$file"; then 236847e89262Smrg func_stripname '' '.exe' "$file" 236947e89262Smrg file=$func_stripname_result 237047e89262Smrg stripped_ext=".exe" 237147e89262Smrg fi 237247e89262Smrg ;; 237347e89262Smrg esac 2374bd1da9d7Smrg 237547e89262Smrg # Do a test to see if this is really a libtool program. 237647e89262Smrg case $host in 237747e89262Smrg *cygwin* | *mingw*) 237847e89262Smrg if func_ltwrapper_executable_p "$file"; then 237947e89262Smrg func_ltwrapper_scriptname "$file" 238047e89262Smrg wrapper=$func_ltwrapper_scriptname_result 238147e89262Smrg else 238247e89262Smrg func_stripname '' '.exe' "$file" 238347e89262Smrg wrapper=$func_stripname_result 238447e89262Smrg fi 238547e89262Smrg ;; 238647e89262Smrg *) 238747e89262Smrg wrapper=$file 238847e89262Smrg ;; 238947e89262Smrg esac 239047e89262Smrg if func_ltwrapper_script_p "$wrapper"; then 239147e89262Smrg notinst_deplibs= 239247e89262Smrg relink_command= 2393bd1da9d7Smrg 239447e89262Smrg func_source "$wrapper" 2395bd1da9d7Smrg 239647e89262Smrg # Check the variables that should have been set. 239747e89262Smrg test -z "$generated_by_libtool_version" && \ 239847e89262Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 2399bd1da9d7Smrg 240047e89262Smrg finalize=yes 240147e89262Smrg for lib in $notinst_deplibs; do 240247e89262Smrg # Check to see that each library is installed. 240347e89262Smrg libdir= 240447e89262Smrg if test -f "$lib"; then 240547e89262Smrg func_source "$lib" 2406bd1da9d7Smrg fi 240747e89262Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 240847e89262Smrg if test -n "$libdir" && test ! -f "$libfile"; then 240947e89262Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 241047e89262Smrg finalize=no 241147e89262Smrg fi 241247e89262Smrg done 2413bd1da9d7Smrg 241447e89262Smrg relink_command= 241547e89262Smrg func_source "$wrapper" 2416bd1da9d7Smrg 241747e89262Smrg outputname= 241847e89262Smrg if test "$fast_install" = no && test -n "$relink_command"; then 241947e89262Smrg $opt_dry_run || { 242047e89262Smrg if test "$finalize" = yes; then 242147e89262Smrg tmpdir=`func_mktempdir` 242247e89262Smrg func_basename "$file$stripped_ext" 242347e89262Smrg file="$func_basename_result" 242447e89262Smrg outputname="$tmpdir/$file" 242547e89262Smrg # Replace the output file specification. 242647e89262Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 242747e89262Smrg 242847e89262Smrg $opt_silent || { 242947e89262Smrg func_quote_for_expand "$relink_command" 243047e89262Smrg eval "func_echo $func_quote_for_expand_result" 243147e89262Smrg } 243247e89262Smrg if eval "$relink_command"; then : 243347e89262Smrg else 243447e89262Smrg func_error "error: relink \`$file' with the above command before installing it" 243547e89262Smrg $opt_dry_run || ${RM}r "$tmpdir" 243647e89262Smrg continue 243747e89262Smrg fi 243847e89262Smrg file="$outputname" 243947e89262Smrg else 244047e89262Smrg func_warning "cannot relink \`$file'" 244147e89262Smrg fi 244247e89262Smrg } 2443bd1da9d7Smrg else 244447e89262Smrg # Install the binary that we compiled earlier. 244547e89262Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 2446bd1da9d7Smrg fi 244747e89262Smrg fi 2448bd1da9d7Smrg 244947e89262Smrg # remove .exe since cygwin /usr/bin/install will append another 245047e89262Smrg # one anyway 245147e89262Smrg case $install_prog,$host in 245247e89262Smrg */usr/bin/install*,*cygwin*) 245347e89262Smrg case $file:$destfile in 245447e89262Smrg *.exe:*.exe) 245547e89262Smrg # this is ok 245647e89262Smrg ;; 245747e89262Smrg *.exe:*) 245847e89262Smrg destfile=$destfile.exe 245947e89262Smrg ;; 246047e89262Smrg *:*.exe) 246147e89262Smrg func_stripname '' '.exe' "$destfile" 246247e89262Smrg destfile=$func_stripname_result 246347e89262Smrg ;; 246447e89262Smrg esac 2465bd1da9d7Smrg ;; 2466bd1da9d7Smrg esac 246747e89262Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 246847e89262Smrg $opt_dry_run || if test -n "$outputname"; then 246947e89262Smrg ${RM}r "$tmpdir" 247047e89262Smrg fi 247147e89262Smrg ;; 247247e89262Smrg esac 247347e89262Smrg done 2474bd1da9d7Smrg 247547e89262Smrg for file in $staticlibs; do 247647e89262Smrg func_basename "$file" 247747e89262Smrg name="$func_basename_result" 247847e89262Smrg 247947e89262Smrg # Set up the ranlib parameters. 248047e89262Smrg oldlib="$destdir/$name" 248147e89262Smrg 248247e89262Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 248347e89262Smrg 248447e89262Smrg if test -n "$stripme" && test -n "$old_striplib"; then 248547e89262Smrg func_show_eval "$old_striplib $oldlib" 'exit $?' 248647e89262Smrg fi 248747e89262Smrg 248847e89262Smrg # Do each command in the postinstall commands. 248947e89262Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 249047e89262Smrg done 249147e89262Smrg 249247e89262Smrg test -n "$future_libdirs" && \ 249347e89262Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 249447e89262Smrg 249547e89262Smrg if test -n "$current_libdirs"; then 249647e89262Smrg # Maybe just do a dry run. 249747e89262Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 249847e89262Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 249947e89262Smrg else 250047e89262Smrg exit $EXIT_SUCCESS 250147e89262Smrg fi 250247e89262Smrg} 250347e89262Smrg 250447e89262Smrgtest "$mode" = install && func_mode_install ${1+"$@"} 250547e89262Smrg 250647e89262Smrg 250747e89262Smrg# func_generate_dlsyms outputname originator pic_p 250847e89262Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 250947e89262Smrg# a dlpreopen symbol table. 251047e89262Smrgfunc_generate_dlsyms () 251147e89262Smrg{ 251247e89262Smrg $opt_debug 251347e89262Smrg my_outputname="$1" 251447e89262Smrg my_originator="$2" 251547e89262Smrg my_pic_p="${3-no}" 251647e89262Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 251747e89262Smrg my_dlsyms= 251847e89262Smrg 251947e89262Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 252047e89262Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 252147e89262Smrg my_dlsyms="${my_outputname}S.c" 252247e89262Smrg else 252347e89262Smrg func_error "not configured to extract global symbols from dlpreopened files" 252447e89262Smrg fi 252547e89262Smrg fi 252647e89262Smrg 252747e89262Smrg if test -n "$my_dlsyms"; then 252847e89262Smrg case $my_dlsyms in 252947e89262Smrg "") ;; 253047e89262Smrg *.c) 253147e89262Smrg # Discover the nlist of each of the dlfiles. 253247e89262Smrg nlist="$output_objdir/${my_outputname}.nm" 253347e89262Smrg 253447e89262Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 253547e89262Smrg 253647e89262Smrg # Parse the name list into a source file. 253747e89262Smrg func_verbose "creating $output_objdir/$my_dlsyms" 253847e89262Smrg 253947e89262Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 254047e89262Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 254147e89262Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 254247e89262Smrg 254347e89262Smrg#ifdef __cplusplus 254447e89262Smrgextern \"C\" { 254547e89262Smrg#endif 254647e89262Smrg 254747e89262Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 254847e89262Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 254947e89262Smrg#endif 255047e89262Smrg 255147e89262Smrg/* External symbol declarations for the compiler. */\ 255247e89262Smrg" 255347e89262Smrg 255447e89262Smrg if test "$dlself" = yes; then 255547e89262Smrg func_verbose "generating symbol list for \`$output'" 255647e89262Smrg 255747e89262Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 255847e89262Smrg 255947e89262Smrg # Add our own program objects to the symbol list. 256047e89262Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 256147e89262Smrg for progfile in $progfiles; do 256247e89262Smrg func_verbose "extracting global C symbols from \`$progfile'" 256347e89262Smrg $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" 256447e89262Smrg done 256547e89262Smrg 256647e89262Smrg if test -n "$exclude_expsyms"; then 256747e89262Smrg $opt_dry_run || { 256847e89262Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 256947e89262Smrg eval '$MV "$nlist"T "$nlist"' 257047e89262Smrg } 2571bd1da9d7Smrg fi 257247e89262Smrg 257347e89262Smrg if test -n "$export_symbols_regex"; then 257447e89262Smrg $opt_dry_run || { 257547e89262Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 257647e89262Smrg eval '$MV "$nlist"T "$nlist"' 257747e89262Smrg } 257847e89262Smrg fi 257947e89262Smrg 258047e89262Smrg # Prepare the list of exported symbols 258147e89262Smrg if test -z "$export_symbols"; then 258247e89262Smrg export_symbols="$output_objdir/$outputname.exp" 258347e89262Smrg $opt_dry_run || { 258447e89262Smrg $RM $export_symbols 258547e89262Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 258647e89262Smrg case $host in 258747e89262Smrg *cygwin* | *mingw* | *cegcc* ) 258847e89262Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 258947e89262Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 259047e89262Smrg ;; 259147e89262Smrg esac 259247e89262Smrg } 2593bd1da9d7Smrg else 259447e89262Smrg $opt_dry_run || { 259547e89262Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 259647e89262Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 259747e89262Smrg eval '$MV "$nlist"T "$nlist"' 259847e89262Smrg case $host in 259947e89262Smrg *cygwin* | *mingw* | *cegcc* ) 260047e89262Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 260147e89262Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 260247e89262Smrg ;; 260347e89262Smrg esac 260447e89262Smrg } 2605bd1da9d7Smrg fi 260647e89262Smrg fi 2607bd1da9d7Smrg 260847e89262Smrg for dlprefile in $dlprefiles; do 260947e89262Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 261047e89262Smrg func_basename "$dlprefile" 261147e89262Smrg name="$func_basename_result" 261247e89262Smrg $opt_dry_run || { 261347e89262Smrg eval '$ECHO ": $name " >> "$nlist"' 261447e89262Smrg eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" 261547e89262Smrg } 261647e89262Smrg done 261747e89262Smrg 261847e89262Smrg $opt_dry_run || { 261947e89262Smrg # Make sure we have at least an empty file. 262047e89262Smrg test -f "$nlist" || : > "$nlist" 262147e89262Smrg 262247e89262Smrg if test -n "$exclude_expsyms"; then 262347e89262Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 262447e89262Smrg $MV "$nlist"T "$nlist" 2625bd1da9d7Smrg fi 262647e89262Smrg 262747e89262Smrg # Try sorting and uniquifying the output. 262847e89262Smrg if $GREP -v "^: " < "$nlist" | 262947e89262Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 263047e89262Smrg sort -k 3 263147e89262Smrg else 263247e89262Smrg sort +2 263347e89262Smrg fi | 263447e89262Smrg uniq > "$nlist"S; then 263547e89262Smrg : 2636bd1da9d7Smrg else 263747e89262Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 2638bd1da9d7Smrg fi 2639bd1da9d7Smrg 264047e89262Smrg if test -f "$nlist"S; then 264147e89262Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 2642bd1da9d7Smrg else 264347e89262Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 2644bd1da9d7Smrg fi 2645bd1da9d7Smrg 264647e89262Smrg echo >> "$output_objdir/$my_dlsyms" "\ 2647bd1da9d7Smrg 264847e89262Smrg/* The mapping between symbol names and symbols. */ 264947e89262Smrgtypedef struct { 265047e89262Smrg const char *name; 265147e89262Smrg void *address; 265247e89262Smrg} lt_dlsymlist; 265347e89262Smrg" 265447e89262Smrg case $host in 265547e89262Smrg *cygwin* | *mingw* | *cegcc* ) 265647e89262Smrg echo >> "$output_objdir/$my_dlsyms" "\ 265747e89262Smrg/* DATA imports from DLLs on WIN32 con't be const, because 265847e89262Smrg runtime relocations are performed -- see ld's documentation 265947e89262Smrg on pseudo-relocs. */" 266047e89262Smrg lt_dlsym_const= ;; 266147e89262Smrg *osf5*) 266247e89262Smrg echo >> "$output_objdir/$my_dlsyms" "\ 266347e89262Smrg/* This system does not cope well with relocations in const data */" 266447e89262Smrg lt_dlsym_const= ;; 266547e89262Smrg *) 266647e89262Smrg lt_dlsym_const=const ;; 266747e89262Smrg esac 2668bd1da9d7Smrg 266947e89262Smrg echo >> "$output_objdir/$my_dlsyms" "\ 267047e89262Smrgextern $lt_dlsym_const lt_dlsymlist 267147e89262Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 267247e89262Smrg$lt_dlsym_const lt_dlsymlist 267347e89262Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 267447e89262Smrg{\ 267547e89262Smrg { \"$my_originator\", (void *) 0 }," 2676bd1da9d7Smrg 267747e89262Smrg case $need_lib_prefix in 267847e89262Smrg no) 267947e89262Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 268047e89262Smrg ;; 268147e89262Smrg *) 268247e89262Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 268347e89262Smrg ;; 268447e89262Smrg esac 268547e89262Smrg echo >> "$output_objdir/$my_dlsyms" "\ 268647e89262Smrg {0, (void *) 0} 268747e89262Smrg}; 2688bd1da9d7Smrg 268947e89262Smrg/* This works around a problem in FreeBSD linker */ 269047e89262Smrg#ifdef FREEBSD_WORKAROUND 269147e89262Smrgstatic const void *lt_preloaded_setup() { 269247e89262Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 269347e89262Smrg} 269447e89262Smrg#endif 2695bd1da9d7Smrg 269647e89262Smrg#ifdef __cplusplus 269747e89262Smrg} 269847e89262Smrg#endif\ 269947e89262Smrg" 270047e89262Smrg } # !$opt_dry_run 2701bd1da9d7Smrg 270247e89262Smrg pic_flag_for_symtable= 270347e89262Smrg case "$compile_command " in 270447e89262Smrg *" -static "*) ;; 270547e89262Smrg *) 270647e89262Smrg case $host in 270747e89262Smrg # compiling the symbol table file with pic_flag works around 270847e89262Smrg # a FreeBSD bug that causes programs to crash when -lm is 270947e89262Smrg # linked before any other PIC object. But we must not use 271047e89262Smrg # pic_flag when linking with -static. The problem exists in 271147e89262Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 271247e89262Smrg *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 271347e89262Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 271447e89262Smrg *-*-hpux*) 271547e89262Smrg pic_flag_for_symtable=" $pic_flag" ;; 271647e89262Smrg *) 271747e89262Smrg if test "X$my_pic_p" != Xno; then 271847e89262Smrg pic_flag_for_symtable=" $pic_flag" 271947e89262Smrg fi 272047e89262Smrg ;; 272147e89262Smrg esac 272247e89262Smrg ;; 272347e89262Smrg esac 272447e89262Smrg symtab_cflags= 272547e89262Smrg for arg in $LTCFLAGS; do 272647e89262Smrg case $arg in 272747e89262Smrg -pie | -fpie | -fPIE) ;; 272847e89262Smrg *) symtab_cflags="$symtab_cflags $arg" ;; 272947e89262Smrg esac 273047e89262Smrg done 2731bd1da9d7Smrg 273247e89262Smrg # Now compile the dynamic symbol file. 273347e89262Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 2734bd1da9d7Smrg 273547e89262Smrg # Clean up the generated files. 273647e89262Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 2737bd1da9d7Smrg 273847e89262Smrg # Transform the symbol file into the correct name. 273947e89262Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 274047e89262Smrg case $host in 274147e89262Smrg *cygwin* | *mingw* | *cegcc* ) 274247e89262Smrg if test -f "$output_objdir/$my_outputname.def"; then 274347e89262Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 274447e89262Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 274547e89262Smrg else 274647e89262Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 274747e89262Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 274847e89262Smrg fi 274947e89262Smrg ;; 275047e89262Smrg *) 275147e89262Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 275247e89262Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 275347e89262Smrg ;; 275447e89262Smrg esac 275547e89262Smrg ;; 275647e89262Smrg *) 275747e89262Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 275847e89262Smrg ;; 275947e89262Smrg esac 276047e89262Smrg else 276147e89262Smrg # We keep going just in case the user didn't refer to 276247e89262Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 276347e89262Smrg # really was required. 2764bd1da9d7Smrg 276547e89262Smrg # Nullify the symbol file. 276647e89262Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 276747e89262Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 276847e89262Smrg fi 276947e89262Smrg} 2770bd1da9d7Smrg 277147e89262Smrg# func_win32_libid arg 277247e89262Smrg# return the library type of file 'arg' 277347e89262Smrg# 277447e89262Smrg# Need a lot of goo to handle *both* DLLs and import libs 277547e89262Smrg# Has to be a shell function in order to 'eat' the argument 277647e89262Smrg# that is supplied when $file_magic_command is called. 277747e89262Smrg# Despite the name, also deal with 64 bit binaries. 277847e89262Smrgfunc_win32_libid () 277947e89262Smrg{ 278047e89262Smrg $opt_debug 278147e89262Smrg win32_libid_type="unknown" 278247e89262Smrg win32_fileres=`file -L $1 2>/dev/null` 278347e89262Smrg case $win32_fileres in 278447e89262Smrg *ar\ archive\ import\ library*) # definitely import 278547e89262Smrg win32_libid_type="x86 archive import" 278647e89262Smrg ;; 278747e89262Smrg *ar\ archive*) # could be an import, or static 278847e89262Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 278947e89262Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 279047e89262Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 279147e89262Smrg win32_nmres=`eval $NM -f posix -A $1 | 279247e89262Smrg $SED -n -e ' 279347e89262Smrg 1,100{ 279447e89262Smrg / I /{ 279547e89262Smrg s,.*,import, 279647e89262Smrg p 279747e89262Smrg q 279847e89262Smrg } 279947e89262Smrg }'` 280047e89262Smrg case $win32_nmres in 280147e89262Smrg import*) win32_libid_type="x86 archive import";; 280247e89262Smrg *) win32_libid_type="x86 archive static";; 280347e89262Smrg esac 280447e89262Smrg fi 280547e89262Smrg ;; 280647e89262Smrg *DLL*) 280747e89262Smrg win32_libid_type="x86 DLL" 280847e89262Smrg ;; 280947e89262Smrg *executable*) # but shell scripts are "executable" too... 281047e89262Smrg case $win32_fileres in 281147e89262Smrg *MS\ Windows\ PE\ Intel*) 281247e89262Smrg win32_libid_type="x86 DLL" 281347e89262Smrg ;; 281447e89262Smrg esac 281547e89262Smrg ;; 281647e89262Smrg esac 281747e89262Smrg $ECHO "$win32_libid_type" 281847e89262Smrg} 2819bd1da9d7Smrg 2820bd1da9d7Smrg 2821bd1da9d7Smrg 282247e89262Smrg# func_extract_an_archive dir oldlib 282347e89262Smrgfunc_extract_an_archive () 282447e89262Smrg{ 282547e89262Smrg $opt_debug 282647e89262Smrg f_ex_an_ar_dir="$1"; shift 282747e89262Smrg f_ex_an_ar_oldlib="$1" 282847e89262Smrg if test "$lock_old_archive_extraction" = yes; then 282947e89262Smrg lockfile=$f_ex_an_ar_oldlib.lock 283047e89262Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 283147e89262Smrg func_echo "Waiting for $lockfile to be removed" 283247e89262Smrg sleep 2 283347e89262Smrg done 283447e89262Smrg fi 283547e89262Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 283647e89262Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 283747e89262Smrg if test "$lock_old_archive_extraction" = yes; then 283847e89262Smrg $opt_dry_run || rm -f "$lockfile" 283947e89262Smrg fi 284047e89262Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 284147e89262Smrg : 284247e89262Smrg else 284347e89262Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 284447e89262Smrg fi 284547e89262Smrg} 2846bd1da9d7Smrg 2847bd1da9d7Smrg 284847e89262Smrg# func_extract_archives gentop oldlib ... 284947e89262Smrgfunc_extract_archives () 285047e89262Smrg{ 285147e89262Smrg $opt_debug 285247e89262Smrg my_gentop="$1"; shift 285347e89262Smrg my_oldlibs=${1+"$@"} 285447e89262Smrg my_oldobjs="" 285547e89262Smrg my_xlib="" 285647e89262Smrg my_xabs="" 285747e89262Smrg my_xdir="" 2858bd1da9d7Smrg 285947e89262Smrg for my_xlib in $my_oldlibs; do 286047e89262Smrg # Extract the objects. 286147e89262Smrg case $my_xlib in 286247e89262Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 286347e89262Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 286447e89262Smrg esac 286547e89262Smrg func_basename "$my_xlib" 286647e89262Smrg my_xlib="$func_basename_result" 286747e89262Smrg my_xlib_u=$my_xlib 286847e89262Smrg while :; do 286947e89262Smrg case " $extracted_archives " in 287047e89262Smrg *" $my_xlib_u "*) 287147e89262Smrg func_arith $extracted_serial + 1 287247e89262Smrg extracted_serial=$func_arith_result 287347e89262Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 287447e89262Smrg *) break ;; 287547e89262Smrg esac 287647e89262Smrg done 287747e89262Smrg extracted_archives="$extracted_archives $my_xlib_u" 287847e89262Smrg my_xdir="$my_gentop/$my_xlib_u" 2879bd1da9d7Smrg 288047e89262Smrg func_mkdir_p "$my_xdir" 288147e89262Smrg 288247e89262Smrg case $host in 288347e89262Smrg *-darwin*) 288447e89262Smrg func_verbose "Extracting $my_xabs" 288547e89262Smrg # Do not bother doing anything if just a dry run 288647e89262Smrg $opt_dry_run || { 288747e89262Smrg darwin_orig_dir=`pwd` 288847e89262Smrg cd $my_xdir || exit $? 288947e89262Smrg darwin_archive=$my_xabs 289047e89262Smrg darwin_curdir=`pwd` 289147e89262Smrg darwin_base_archive=`basename "$darwin_archive"` 289247e89262Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 289347e89262Smrg if test -n "$darwin_arches"; then 289447e89262Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 289547e89262Smrg darwin_arch= 289647e89262Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 289747e89262Smrg for darwin_arch in $darwin_arches ; do 289847e89262Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 289947e89262Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 290047e89262Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 290147e89262Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 290247e89262Smrg cd "$darwin_curdir" 290347e89262Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 290447e89262Smrg done # $darwin_arches 290547e89262Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 290647e89262Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 290747e89262Smrg darwin_file= 290847e89262Smrg darwin_files= 290947e89262Smrg for darwin_file in $darwin_filelist; do 291047e89262Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 291147e89262Smrg $LIPO -create -output "$darwin_file" $darwin_files 291247e89262Smrg done # $darwin_filelist 291347e89262Smrg $RM -rf unfat-$$ 291447e89262Smrg cd "$darwin_orig_dir" 2915bd1da9d7Smrg else 291647e89262Smrg cd $darwin_orig_dir 291747e89262Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 291847e89262Smrg fi # $darwin_arches 291947e89262Smrg } # !$opt_dry_run 292047e89262Smrg ;; 292147e89262Smrg *) 292247e89262Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 292347e89262Smrg ;; 292447e89262Smrg esac 292547e89262Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 292647e89262Smrg done 2927bd1da9d7Smrg 292847e89262Smrg func_extract_archives_result="$my_oldobjs" 292947e89262Smrg} 2930bd1da9d7Smrg 2931bd1da9d7Smrg 293247e89262Smrg# func_emit_wrapper [arg=no] 293347e89262Smrg# 293447e89262Smrg# Emit a libtool wrapper script on stdout. 293547e89262Smrg# Don't directly open a file because we may want to 293647e89262Smrg# incorporate the script contents within a cygwin/mingw 293747e89262Smrg# wrapper executable. Must ONLY be called from within 293847e89262Smrg# func_mode_link because it depends on a number of variables 293947e89262Smrg# set therein. 294047e89262Smrg# 294147e89262Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 294247e89262Smrg# variable will take. If 'yes', then the emitted script 294347e89262Smrg# will assume that the directory in which it is stored is 294447e89262Smrg# the $objdir directory. This is a cygwin/mingw-specific 294547e89262Smrg# behavior. 294647e89262Smrgfunc_emit_wrapper () 294747e89262Smrg{ 294847e89262Smrg func_emit_wrapper_arg1=${1-no} 2949bd1da9d7Smrg 295047e89262Smrg $ECHO "\ 295147e89262Smrg#! $SHELL 2952bd1da9d7Smrg 295347e89262Smrg# $output - temporary wrapper script for $objdir/$outputname 295447e89262Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 295547e89262Smrg# 295647e89262Smrg# The $output program cannot be directly executed until all the libtool 295747e89262Smrg# libraries that it depends on are installed. 295847e89262Smrg# 295947e89262Smrg# This wrapper script should never be moved out of the build directory. 296047e89262Smrg# If it is, it will not operate correctly. 2961bd1da9d7Smrg 296247e89262Smrg# Sed substitution that helps us do robust quoting. It backslashifies 296347e89262Smrg# metacharacters that are still active within double-quoted strings. 296447e89262Smrgsed_quote_subst='$sed_quote_subst' 2965bd1da9d7Smrg 296647e89262Smrg# Be Bourne compatible 296747e89262Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 296847e89262Smrg emulate sh 296947e89262Smrg NULLCMD=: 297047e89262Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 297147e89262Smrg # is contrary to our usage. Disable this feature. 297247e89262Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 297347e89262Smrg setopt NO_GLOB_SUBST 297447e89262Smrgelse 297547e89262Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 297647e89262Smrgfi 297747e89262SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 297847e89262SmrgDUALCASE=1; export DUALCASE # for MKS sh 2979bd1da9d7Smrg 298047e89262Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 298147e89262Smrg# if CDPATH is set. 298247e89262Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 2983bd1da9d7Smrg 298447e89262Smrgrelink_command=\"$relink_command\" 2985bd1da9d7Smrg 298647e89262Smrg# This environment variable determines our operation mode. 298747e89262Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 298847e89262Smrg # install mode needs the following variables: 298947e89262Smrg generated_by_libtool_version='$macro_version' 299047e89262Smrg notinst_deplibs='$notinst_deplibs' 299147e89262Smrgelse 299247e89262Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 299347e89262Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 299447e89262Smrg file=\"\$0\"" 2995bd1da9d7Smrg 299647e89262Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 299747e89262Smrg $ECHO "\ 2998bd1da9d7Smrg 299947e89262Smrg# A function that is used when there is no print builtin or printf. 300047e89262Smrgfunc_fallback_echo () 300147e89262Smrg{ 300247e89262Smrg eval 'cat <<_LTECHO_EOF 300347e89262Smrg\$1 300447e89262Smrg_LTECHO_EOF' 300547e89262Smrg} 300647e89262Smrg ECHO=\"$qECHO\" 300747e89262Smrg fi 300847e89262Smrg 300947e89262Smrg# Very basic option parsing. These options are (a) specific to 301047e89262Smrg# the libtool wrapper, (b) are identical between the wrapper 301147e89262Smrg# /script/ and the wrapper /executable/ which is used only on 301247e89262Smrg# windows platforms, and (c) all begin with the string "--lt-" 301347e89262Smrg# (application programs are unlikely to have options which match 301447e89262Smrg# this pattern). 301547e89262Smrg# 301647e89262Smrg# There are only two supported options: --lt-debug and 301747e89262Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 301847e89262Smrg# 301947e89262Smrg# The first argument to this parsing function should be the 302047e89262Smrg# script's $0 value, followed by "$@". 302147e89262Smrglt_option_debug= 302247e89262Smrgfunc_parse_lt_options () 302347e89262Smrg{ 302447e89262Smrg lt_script_arg0=\$0 302547e89262Smrg shift 302647e89262Smrg for lt_opt 302747e89262Smrg do 302847e89262Smrg case \"\$lt_opt\" in 302947e89262Smrg --lt-debug) lt_option_debug=1 ;; 303047e89262Smrg --lt-dump-script) 303147e89262Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 303247e89262Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 303347e89262Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 303447e89262Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 303547e89262Smrg exit 0 303647e89262Smrg ;; 303747e89262Smrg --lt-*) 303847e89262Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 303947e89262Smrg exit 1 3040bd1da9d7Smrg ;; 304147e89262Smrg esac 304247e89262Smrg done 3043bd1da9d7Smrg 304447e89262Smrg # Print the debug banner immediately: 304547e89262Smrg if test -n \"\$lt_option_debug\"; then 304647e89262Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 304747e89262Smrg fi 304847e89262Smrg} 3049bd1da9d7Smrg 305047e89262Smrg# Used when --lt-debug. Prints its arguments to stdout 305147e89262Smrg# (redirection is the responsibility of the caller) 305247e89262Smrgfunc_lt_dump_args () 305347e89262Smrg{ 305447e89262Smrg lt_dump_args_N=1; 305547e89262Smrg for lt_arg 305647e89262Smrg do 305747e89262Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 305847e89262Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 305947e89262Smrg done 306047e89262Smrg} 3061bd1da9d7Smrg 306247e89262Smrg# Core function for launching the target application 306347e89262Smrgfunc_exec_program_core () 306447e89262Smrg{ 306547e89262Smrg" 306647e89262Smrg case $host in 306747e89262Smrg # Backslashes separate directories on plain windows 306847e89262Smrg *-*-mingw | *-*-os2* | *-cegcc*) 306947e89262Smrg $ECHO "\ 307047e89262Smrg if test -n \"\$lt_option_debug\"; then 307147e89262Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 307247e89262Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3073bd1da9d7Smrg fi 307447e89262Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 307547e89262Smrg" 307647e89262Smrg ;; 3077bd1da9d7Smrg 307847e89262Smrg *) 307947e89262Smrg $ECHO "\ 308047e89262Smrg if test -n \"\$lt_option_debug\"; then 308147e89262Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 308247e89262Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3083bd1da9d7Smrg fi 308447e89262Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 308547e89262Smrg" 308647e89262Smrg ;; 308747e89262Smrg esac 308847e89262Smrg $ECHO "\ 308947e89262Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 309047e89262Smrg exit 1 309147e89262Smrg} 3092bd1da9d7Smrg 309347e89262Smrg# A function to encapsulate launching the target application 309447e89262Smrg# Strips options in the --lt-* namespace from \$@ and 309547e89262Smrg# launches target application with the remaining arguments. 309647e89262Smrgfunc_exec_program () 309747e89262Smrg{ 309847e89262Smrg for lt_wr_arg 309947e89262Smrg do 310047e89262Smrg case \$lt_wr_arg in 310147e89262Smrg --lt-*) ;; 310247e89262Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 310347e89262Smrg esac 310447e89262Smrg shift 310547e89262Smrg done 310647e89262Smrg func_exec_program_core \${1+\"\$@\"} 310747e89262Smrg} 3108bd1da9d7Smrg 310947e89262Smrg # Parse options 311047e89262Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 3111bd1da9d7Smrg 311247e89262Smrg # Find the directory that this script lives in. 311347e89262Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 311447e89262Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 3115bd1da9d7Smrg 311647e89262Smrg # Follow symbolic links until we get to the real thisdir. 311747e89262Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 311847e89262Smrg while test -n \"\$file\"; do 311947e89262Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 3120bd1da9d7Smrg 312147e89262Smrg # If there was a directory component, then change thisdir. 312247e89262Smrg if test \"x\$destdir\" != \"x\$file\"; then 312347e89262Smrg case \"\$destdir\" in 312447e89262Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 312547e89262Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 312647e89262Smrg esac 312747e89262Smrg fi 3128bd1da9d7Smrg 312947e89262Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 313047e89262Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 313147e89262Smrg done 3132bd1da9d7Smrg 313347e89262Smrg # Usually 'no', except on cygwin/mingw when embedded into 313447e89262Smrg # the cwrapper. 313547e89262Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 313647e89262Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 313747e89262Smrg # special case for '.' 313847e89262Smrg if test \"\$thisdir\" = \".\"; then 313947e89262Smrg thisdir=\`pwd\` 314047e89262Smrg fi 314147e89262Smrg # remove .libs from thisdir 314247e89262Smrg case \"\$thisdir\" in 314347e89262Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 314447e89262Smrg $objdir ) thisdir=. ;; 314547e89262Smrg esac 314647e89262Smrg fi 3147bd1da9d7Smrg 314847e89262Smrg # Try to get the absolute directory name. 314947e89262Smrg absdir=\`cd \"\$thisdir\" && pwd\` 315047e89262Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 315147e89262Smrg" 3152bd1da9d7Smrg 315347e89262Smrg if test "$fast_install" = yes; then 315447e89262Smrg $ECHO "\ 315547e89262Smrg program=lt-'$outputname'$exeext 315647e89262Smrg progdir=\"\$thisdir/$objdir\" 3157bd1da9d7Smrg 315847e89262Smrg if test ! -f \"\$progdir/\$program\" || 315947e89262Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 316047e89262Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 3161bd1da9d7Smrg 316247e89262Smrg file=\"\$\$-\$program\" 3163bd1da9d7Smrg 316447e89262Smrg if test ! -d \"\$progdir\"; then 316547e89262Smrg $MKDIR \"\$progdir\" 316647e89262Smrg else 316747e89262Smrg $RM \"\$progdir/\$file\" 316847e89262Smrg fi" 3169bd1da9d7Smrg 317047e89262Smrg $ECHO "\ 3171bd1da9d7Smrg 317247e89262Smrg # relink executable if necessary 317347e89262Smrg if test -n \"\$relink_command\"; then 317447e89262Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 317547e89262Smrg else 317647e89262Smrg $ECHO \"\$relink_command_output\" >&2 317747e89262Smrg $RM \"\$progdir/\$file\" 317847e89262Smrg exit 1 317947e89262Smrg fi 318047e89262Smrg fi 3181bd1da9d7Smrg 318247e89262Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 318347e89262Smrg { $RM \"\$progdir/\$program\"; 318447e89262Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 318547e89262Smrg $RM \"\$progdir/\$file\" 318647e89262Smrg fi" 318747e89262Smrg else 318847e89262Smrg $ECHO "\ 318947e89262Smrg program='$outputname' 319047e89262Smrg progdir=\"\$thisdir/$objdir\" 319147e89262Smrg" 319247e89262Smrg fi 3193bd1da9d7Smrg 319447e89262Smrg $ECHO "\ 3195bd1da9d7Smrg 319647e89262Smrg if test -f \"\$progdir/\$program\"; then" 3197bd1da9d7Smrg 319847e89262Smrg # Export our shlibpath_var if we have one. 319947e89262Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 320047e89262Smrg $ECHO "\ 320147e89262Smrg # Add our own library path to $shlibpath_var 320247e89262Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 3203bd1da9d7Smrg 320447e89262Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 320547e89262Smrg # The second colon is a workaround for a bug in BeOS R4 sed 320647e89262Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 3207bd1da9d7Smrg 320847e89262Smrg export $shlibpath_var 320947e89262Smrg" 321047e89262Smrg fi 3211bd1da9d7Smrg 321247e89262Smrg # fixup the dll searchpath if we need to. 321347e89262Smrg if test -n "$dllsearchpath"; then 321447e89262Smrg $ECHO "\ 321547e89262Smrg # Add the dll search path components to the executable PATH 321647e89262Smrg PATH=$dllsearchpath:\$PATH 321747e89262Smrg" 321847e89262Smrg fi 3219bd1da9d7Smrg 322047e89262Smrg $ECHO "\ 322147e89262Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 322247e89262Smrg # Run the actual program with our arguments. 322347e89262Smrg func_exec_program \${1+\"\$@\"} 322447e89262Smrg fi 322547e89262Smrg else 322647e89262Smrg # The program doesn't exist. 322747e89262Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 322847e89262Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 322947e89262Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 323047e89262Smrg exit 1 323147e89262Smrg fi 323247e89262Smrgfi\ 323347e89262Smrg" 323447e89262Smrg} 3235bd1da9d7Smrg 3236bd1da9d7Smrg 323747e89262Smrg# func_to_host_path arg 323847e89262Smrg# 323947e89262Smrg# Convert paths to host format when used with build tools. 324047e89262Smrg# Intended for use with "native" mingw (where libtool itself 324147e89262Smrg# is running under the msys shell), or in the following cross- 324247e89262Smrg# build environments: 324347e89262Smrg# $build $host 324447e89262Smrg# mingw (msys) mingw [e.g. native] 324547e89262Smrg# cygwin mingw 324647e89262Smrg# *nix + wine mingw 324747e89262Smrg# where wine is equipped with the `winepath' executable. 324847e89262Smrg# In the native mingw case, the (msys) shell automatically 324947e89262Smrg# converts paths for any non-msys applications it launches, 325047e89262Smrg# but that facility isn't available from inside the cwrapper. 325147e89262Smrg# Similar accommodations are necessary for $host mingw and 325247e89262Smrg# $build cygwin. Calling this function does no harm for other 325347e89262Smrg# $host/$build combinations not listed above. 325447e89262Smrg# 325547e89262Smrg# ARG is the path (on $build) that should be converted to 325647e89262Smrg# the proper representation for $host. The result is stored 325747e89262Smrg# in $func_to_host_path_result. 325847e89262Smrgfunc_to_host_path () 325947e89262Smrg{ 326047e89262Smrg func_to_host_path_result="$1" 326147e89262Smrg if test -n "$1"; then 326247e89262Smrg case $host in 326347e89262Smrg *mingw* ) 326447e89262Smrg lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 326547e89262Smrg case $build in 326647e89262Smrg *mingw* ) # actually, msys 326747e89262Smrg # awkward: cmd appends spaces to result 326847e89262Smrg func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null | 326947e89262Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 327047e89262Smrg ;; 327147e89262Smrg *cygwin* ) 327247e89262Smrg func_to_host_path_result=`cygpath -w "$1" | 327347e89262Smrg $SED -e "$lt_sed_naive_backslashify"` 327447e89262Smrg ;; 327547e89262Smrg * ) 327647e89262Smrg # Unfortunately, winepath does not exit with a non-zero 327747e89262Smrg # error code, so we are forced to check the contents of 327847e89262Smrg # stdout. On the other hand, if the command is not 327947e89262Smrg # found, the shell will set an exit code of 127 and print 328047e89262Smrg # *an error message* to stdout. So we must check for both 328147e89262Smrg # error code of zero AND non-empty stdout, which explains 328247e89262Smrg # the odd construction: 328347e89262Smrg func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` 328447e89262Smrg if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then 328547e89262Smrg func_to_host_path_result=`$ECHO "$func_to_host_path_tmp1" | 328647e89262Smrg $SED -e "$lt_sed_naive_backslashify"` 328747e89262Smrg else 328847e89262Smrg # Allow warning below. 328947e89262Smrg func_to_host_path_result= 329047e89262Smrg fi 329147e89262Smrg ;; 329247e89262Smrg esac 329347e89262Smrg if test -z "$func_to_host_path_result" ; then 329447e89262Smrg func_error "Could not determine host path corresponding to" 329547e89262Smrg func_error " \`$1'" 329647e89262Smrg func_error "Continuing, but uninstalled executables may not work." 329747e89262Smrg # Fallback: 329847e89262Smrg func_to_host_path_result="$1" 329947e89262Smrg fi 330047e89262Smrg ;; 330147e89262Smrg esac 330247e89262Smrg fi 330347e89262Smrg} 330447e89262Smrg# end: func_to_host_path 3305bd1da9d7Smrg 330647e89262Smrg# func_to_host_pathlist arg 330747e89262Smrg# 330847e89262Smrg# Convert pathlists to host format when used with build tools. 330947e89262Smrg# See func_to_host_path(), above. This function supports the 331047e89262Smrg# following $build/$host combinations (but does no harm for 331147e89262Smrg# combinations not listed here): 331247e89262Smrg# $build $host 331347e89262Smrg# mingw (msys) mingw [e.g. native] 331447e89262Smrg# cygwin mingw 331547e89262Smrg# *nix + wine mingw 331647e89262Smrg# 331747e89262Smrg# Path separators are also converted from $build format to 331847e89262Smrg# $host format. If ARG begins or ends with a path separator 331947e89262Smrg# character, it is preserved (but converted to $host format) 332047e89262Smrg# on output. 332147e89262Smrg# 332247e89262Smrg# ARG is a pathlist (on $build) that should be converted to 332347e89262Smrg# the proper representation on $host. The result is stored 332447e89262Smrg# in $func_to_host_pathlist_result. 332547e89262Smrgfunc_to_host_pathlist () 332647e89262Smrg{ 332747e89262Smrg func_to_host_pathlist_result="$1" 332847e89262Smrg if test -n "$1"; then 332947e89262Smrg case $host in 333047e89262Smrg *mingw* ) 333147e89262Smrg lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 333247e89262Smrg # Remove leading and trailing path separator characters from 333347e89262Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 333447e89262Smrg # into '.;' and ';.', and winepath ignores them completely. 333547e89262Smrg func_stripname : : "$1" 333647e89262Smrg func_to_host_pathlist_tmp1=$func_stripname_result 333747e89262Smrg case $build in 333847e89262Smrg *mingw* ) # Actually, msys. 333947e89262Smrg # Awkward: cmd appends spaces to result. 334047e89262Smrg func_to_host_pathlist_result=` 334147e89262Smrg ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null | 334247e89262Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 334347e89262Smrg ;; 334447e89262Smrg *cygwin* ) 334547e89262Smrg func_to_host_pathlist_result=`cygpath -w -p "$func_to_host_pathlist_tmp1" | 334647e89262Smrg $SED -e "$lt_sed_naive_backslashify"` 334747e89262Smrg ;; 334847e89262Smrg * ) 334947e89262Smrg # unfortunately, winepath doesn't convert pathlists 335047e89262Smrg func_to_host_pathlist_result="" 335147e89262Smrg func_to_host_pathlist_oldIFS=$IFS 335247e89262Smrg IFS=: 335347e89262Smrg for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do 335447e89262Smrg IFS=$func_to_host_pathlist_oldIFS 335547e89262Smrg if test -n "$func_to_host_pathlist_f" ; then 335647e89262Smrg func_to_host_path "$func_to_host_pathlist_f" 335747e89262Smrg if test -n "$func_to_host_path_result" ; then 335847e89262Smrg if test -z "$func_to_host_pathlist_result" ; then 335947e89262Smrg func_to_host_pathlist_result="$func_to_host_path_result" 336047e89262Smrg else 336147e89262Smrg func_append func_to_host_pathlist_result ";$func_to_host_path_result" 336247e89262Smrg fi 336347e89262Smrg fi 336447e89262Smrg fi 336547e89262Smrg done 336647e89262Smrg IFS=$func_to_host_pathlist_oldIFS 336747e89262Smrg ;; 336847e89262Smrg esac 336947e89262Smrg if test -z "$func_to_host_pathlist_result"; then 337047e89262Smrg func_error "Could not determine the host path(s) corresponding to" 337147e89262Smrg func_error " \`$1'" 337247e89262Smrg func_error "Continuing, but uninstalled executables may not work." 337347e89262Smrg # Fallback. This may break if $1 contains DOS-style drive 337447e89262Smrg # specifications. The fix is not to complicate the expression 337547e89262Smrg # below, but for the user to provide a working wine installation 337647e89262Smrg # with winepath so that path translation in the cross-to-mingw 337747e89262Smrg # case works properly. 337847e89262Smrg lt_replace_pathsep_nix_to_dos="s|:|;|g" 337947e89262Smrg func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ 338047e89262Smrg $SED -e "$lt_replace_pathsep_nix_to_dos"` 338147e89262Smrg fi 338247e89262Smrg # Now, add the leading and trailing path separators back 338347e89262Smrg case "$1" in 338447e89262Smrg :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" 338547e89262Smrg ;; 338647e89262Smrg esac 338747e89262Smrg case "$1" in 338847e89262Smrg *: ) func_append func_to_host_pathlist_result ";" 338947e89262Smrg ;; 339047e89262Smrg esac 339147e89262Smrg ;; 339247e89262Smrg esac 339347e89262Smrg fi 339447e89262Smrg} 339547e89262Smrg# end: func_to_host_pathlist 3396bd1da9d7Smrg 339747e89262Smrg# func_emit_cwrapperexe_src 339847e89262Smrg# emit the source code for a wrapper executable on stdout 339947e89262Smrg# Must ONLY be called from within func_mode_link because 340047e89262Smrg# it depends on a number of variable set therein. 340147e89262Smrgfunc_emit_cwrapperexe_src () 340247e89262Smrg{ 340347e89262Smrg cat <<EOF 3404bd1da9d7Smrg 340547e89262Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 340647e89262Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3407bd1da9d7Smrg 340847e89262Smrg The $output program cannot be directly executed until all the libtool 340947e89262Smrg libraries that it depends on are installed. 3410bd1da9d7Smrg 341147e89262Smrg This wrapper executable should never be moved out of the build directory. 341247e89262Smrg If it is, it will not operate correctly. 341347e89262Smrg*/ 341447e89262SmrgEOF 341547e89262Smrg cat <<"EOF" 341647e89262Smrg#ifdef _MSC_VER 341747e89262Smrg# define _CRT_SECURE_NO_DEPRECATE 1 341847e89262Smrg#endif 341947e89262Smrg#include <stdio.h> 342047e89262Smrg#include <stdlib.h> 342147e89262Smrg#ifdef _MSC_VER 342247e89262Smrg# include <direct.h> 342347e89262Smrg# include <process.h> 342447e89262Smrg# include <io.h> 342547e89262Smrg#else 342647e89262Smrg# include <unistd.h> 342747e89262Smrg# include <stdint.h> 342847e89262Smrg# ifdef __CYGWIN__ 342947e89262Smrg# include <io.h> 343047e89262Smrg# endif 343147e89262Smrg#endif 343247e89262Smrg#include <malloc.h> 343347e89262Smrg#include <stdarg.h> 343447e89262Smrg#include <assert.h> 343547e89262Smrg#include <string.h> 343647e89262Smrg#include <ctype.h> 343747e89262Smrg#include <errno.h> 343847e89262Smrg#include <fcntl.h> 343947e89262Smrg#include <sys/stat.h> 3440bd1da9d7Smrg 344147e89262Smrg/* declarations of non-ANSI functions */ 344247e89262Smrg#if defined(__MINGW32__) 344347e89262Smrg# ifdef __STRICT_ANSI__ 344447e89262Smrgint _putenv (const char *); 344547e89262Smrg# endif 344647e89262Smrg#elif defined(__CYGWIN__) 344747e89262Smrg# ifdef __STRICT_ANSI__ 344847e89262Smrgchar *realpath (const char *, char *); 344947e89262Smrgint putenv (char *); 345047e89262Smrgint setenv (const char *, const char *, int); 345147e89262Smrg# endif 345247e89262Smrg/* #elif defined (other platforms) ... */ 345347e89262Smrg#endif 3454bd1da9d7Smrg 345547e89262Smrg/* portability defines, excluding path handling macros */ 345647e89262Smrg#if defined(_MSC_VER) 345747e89262Smrg# define setmode _setmode 345847e89262Smrg# define stat _stat 345947e89262Smrg# define chmod _chmod 346047e89262Smrg# define getcwd _getcwd 346147e89262Smrg# define putenv _putenv 346247e89262Smrg# define S_IXUSR _S_IEXEC 346347e89262Smrg# ifndef _INTPTR_T_DEFINED 346447e89262Smrg# define _INTPTR_T_DEFINED 346547e89262Smrg# define intptr_t int 346647e89262Smrg# endif 346747e89262Smrg#elif defined(__MINGW32__) 346847e89262Smrg# define setmode _setmode 346947e89262Smrg# define stat _stat 347047e89262Smrg# define chmod _chmod 347147e89262Smrg# define getcwd _getcwd 347247e89262Smrg# define putenv _putenv 347347e89262Smrg#elif defined(__CYGWIN__) 347447e89262Smrg# define HAVE_SETENV 347547e89262Smrg# define FOPEN_WB "wb" 347647e89262Smrg/* #elif defined (other platforms) ... */ 347747e89262Smrg#endif 3478bd1da9d7Smrg 347947e89262Smrg#if defined(PATH_MAX) 348047e89262Smrg# define LT_PATHMAX PATH_MAX 348147e89262Smrg#elif defined(MAXPATHLEN) 348247e89262Smrg# define LT_PATHMAX MAXPATHLEN 348347e89262Smrg#else 348447e89262Smrg# define LT_PATHMAX 1024 348547e89262Smrg#endif 3486bd1da9d7Smrg 348747e89262Smrg#ifndef S_IXOTH 348847e89262Smrg# define S_IXOTH 0 348947e89262Smrg#endif 349047e89262Smrg#ifndef S_IXGRP 349147e89262Smrg# define S_IXGRP 0 349247e89262Smrg#endif 3493bd1da9d7Smrg 349447e89262Smrg/* path handling portability macros */ 349547e89262Smrg#ifndef DIR_SEPARATOR 349647e89262Smrg# define DIR_SEPARATOR '/' 349747e89262Smrg# define PATH_SEPARATOR ':' 349847e89262Smrg#endif 3499bd1da9d7Smrg 350047e89262Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 350147e89262Smrg defined (__OS2__) 350247e89262Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 350347e89262Smrg# define FOPEN_WB "wb" 350447e89262Smrg# ifndef DIR_SEPARATOR_2 350547e89262Smrg# define DIR_SEPARATOR_2 '\\' 350647e89262Smrg# endif 350747e89262Smrg# ifndef PATH_SEPARATOR_2 350847e89262Smrg# define PATH_SEPARATOR_2 ';' 350947e89262Smrg# endif 351047e89262Smrg#endif 3511bd1da9d7Smrg 351247e89262Smrg#ifndef DIR_SEPARATOR_2 351347e89262Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 351447e89262Smrg#else /* DIR_SEPARATOR_2 */ 351547e89262Smrg# define IS_DIR_SEPARATOR(ch) \ 351647e89262Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 351747e89262Smrg#endif /* DIR_SEPARATOR_2 */ 3518bd1da9d7Smrg 351947e89262Smrg#ifndef PATH_SEPARATOR_2 352047e89262Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 352147e89262Smrg#else /* PATH_SEPARATOR_2 */ 352247e89262Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 352347e89262Smrg#endif /* PATH_SEPARATOR_2 */ 352447e89262Smrg 352547e89262Smrg#ifndef FOPEN_WB 352647e89262Smrg# define FOPEN_WB "w" 352747e89262Smrg#endif 352847e89262Smrg#ifndef _O_BINARY 352947e89262Smrg# define _O_BINARY 0 353047e89262Smrg#endif 353147e89262Smrg 353247e89262Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 353347e89262Smrg#define XFREE(stale) do { \ 353447e89262Smrg if (stale) { free ((void *) stale); stale = 0; } \ 353547e89262Smrg} while (0) 353647e89262Smrg 353747e89262Smrg#if defined(LT_DEBUGWRAPPER) 353847e89262Smrgstatic int lt_debug = 1; 353947e89262Smrg#else 354047e89262Smrgstatic int lt_debug = 0; 354147e89262Smrg#endif 354247e89262Smrg 354347e89262Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 354447e89262Smrg 354547e89262Smrgvoid *xmalloc (size_t num); 354647e89262Smrgchar *xstrdup (const char *string); 354747e89262Smrgconst char *base_name (const char *name); 354847e89262Smrgchar *find_executable (const char *wrapper); 354947e89262Smrgchar *chase_symlinks (const char *pathspec); 355047e89262Smrgint make_executable (const char *path); 355147e89262Smrgint check_executable (const char *path); 355247e89262Smrgchar *strendzap (char *str, const char *pat); 355347e89262Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 355447e89262Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 355547e89262Smrgstatic const char *nonnull (const char *s); 355647e89262Smrgstatic const char *nonempty (const char *s); 355747e89262Smrgvoid lt_setenv (const char *name, const char *value); 355847e89262Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 355947e89262Smrgvoid lt_update_exe_path (const char *name, const char *value); 356047e89262Smrgvoid lt_update_lib_path (const char *name, const char *value); 356147e89262Smrgchar **prepare_spawn (char **argv); 356247e89262Smrgvoid lt_dump_script (FILE *f); 356347e89262SmrgEOF 356447e89262Smrg 356547e89262Smrg cat <<EOF 356647e89262Smrgconst char * MAGIC_EXE = "$magic_exe"; 356747e89262Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 356847e89262SmrgEOF 356947e89262Smrg 357047e89262Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 357147e89262Smrg func_to_host_pathlist "$temp_rpath" 357247e89262Smrg cat <<EOF 357347e89262Smrgconst char * LIB_PATH_VALUE = "$func_to_host_pathlist_result"; 3574bd1da9d7SmrgEOF 3575bd1da9d7Smrg else 357647e89262Smrg cat <<"EOF" 357747e89262Smrgconst char * LIB_PATH_VALUE = ""; 357847e89262SmrgEOF 3579bd1da9d7Smrg fi 358047e89262Smrg 358147e89262Smrg if test -n "$dllsearchpath"; then 358247e89262Smrg func_to_host_pathlist "$dllsearchpath:" 358347e89262Smrg cat <<EOF 358447e89262Smrgconst char * EXE_PATH_VARNAME = "PATH"; 358547e89262Smrgconst char * EXE_PATH_VALUE = "$func_to_host_pathlist_result"; 358647e89262SmrgEOF 3587bd1da9d7Smrg else 358847e89262Smrg cat <<"EOF" 358947e89262Smrgconst char * EXE_PATH_VARNAME = ""; 359047e89262Smrgconst char * EXE_PATH_VALUE = ""; 359147e89262SmrgEOF 3592bd1da9d7Smrg fi 359347e89262Smrg 359447e89262Smrg if test "$fast_install" = yes; then 359547e89262Smrg cat <<EOF 359647e89262Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 359747e89262SmrgEOF 3598bd1da9d7Smrg else 359947e89262Smrg cat <<EOF 360047e89262Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 360147e89262SmrgEOF 3602bd1da9d7Smrg fi 3603bd1da9d7Smrg 3604bd1da9d7Smrg 360547e89262Smrg cat <<"EOF" 3606bd1da9d7Smrg 360747e89262Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 3608bd1da9d7Smrg 360947e89262Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 361047e89262Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 361147e89262Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 3612bd1da9d7Smrg 361347e89262Smrgint 361447e89262Smrgmain (int argc, char *argv[]) 361547e89262Smrg{ 361647e89262Smrg char **newargz; 361747e89262Smrg int newargc; 361847e89262Smrg char *tmp_pathspec; 361947e89262Smrg char *actual_cwrapper_path; 362047e89262Smrg char *actual_cwrapper_name; 362147e89262Smrg char *target_name; 362247e89262Smrg char *lt_argv_zero; 362347e89262Smrg intptr_t rval = 127; 3624bd1da9d7Smrg 362547e89262Smrg int i; 3626bd1da9d7Smrg 362747e89262Smrg program_name = (char *) xstrdup (base_name (argv[0])); 362847e89262Smrg newargz = XMALLOC (char *, argc + 1); 3629bd1da9d7Smrg 363047e89262Smrg /* very simple arg parsing; don't want to rely on getopt 363147e89262Smrg * also, copy all non cwrapper options to newargz, except 363247e89262Smrg * argz[0], which is handled differently 363347e89262Smrg */ 363447e89262Smrg newargc=0; 363547e89262Smrg for (i = 1; i < argc; i++) 363647e89262Smrg { 363747e89262Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 363847e89262Smrg { 363947e89262SmrgEOF 364047e89262Smrg case "$host" in 364147e89262Smrg *mingw* | *cygwin* ) 364247e89262Smrg # make stdout use "unix" line endings 364347e89262Smrg echo " setmode(1,_O_BINARY);" 364447e89262Smrg ;; 36455bcb6992Smrg esac 3646bd1da9d7Smrg 364747e89262Smrg cat <<"EOF" 364847e89262Smrg lt_dump_script (stdout); 364947e89262Smrg return 0; 365047e89262Smrg } 365147e89262Smrg if (strcmp (argv[i], debug_opt) == 0) 365247e89262Smrg { 365347e89262Smrg lt_debug = 1; 365447e89262Smrg continue; 365547e89262Smrg } 365647e89262Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 365747e89262Smrg { 365847e89262Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 365947e89262Smrg namespace, but it is not one of the ones we know about and 366047e89262Smrg have already dealt with, above (inluding dump-script), then 366147e89262Smrg report an error. Otherwise, targets might begin to believe 366247e89262Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 366347e89262Smrg namespace. The first time any user complains about this, we'll 366447e89262Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 366547e89262Smrg or a configure.ac-settable value. 366647e89262Smrg */ 366747e89262Smrg lt_fatal (__FILE__, __LINE__, 366847e89262Smrg "unrecognized %s option: '%s'", 366947e89262Smrg ltwrapper_option_prefix, argv[i]); 367047e89262Smrg } 367147e89262Smrg /* otherwise ... */ 367247e89262Smrg newargz[++newargc] = xstrdup (argv[i]); 367347e89262Smrg } 367447e89262Smrg newargz[++newargc] = NULL; 3675bd1da9d7Smrg 367647e89262SmrgEOF 367747e89262Smrg cat <<EOF 367847e89262Smrg /* The GNU banner must be the first non-error debug message */ 367947e89262Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 368047e89262SmrgEOF 368147e89262Smrg cat <<"EOF" 368247e89262Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 368347e89262Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 368447e89262Smrg 368547e89262Smrg tmp_pathspec = find_executable (argv[0]); 368647e89262Smrg if (tmp_pathspec == NULL) 368747e89262Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 368847e89262Smrg lt_debugprintf (__FILE__, __LINE__, 368947e89262Smrg "(main) found exe (before symlink chase) at: %s\n", 369047e89262Smrg tmp_pathspec); 369147e89262Smrg 369247e89262Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 369347e89262Smrg lt_debugprintf (__FILE__, __LINE__, 369447e89262Smrg "(main) found exe (after symlink chase) at: %s\n", 369547e89262Smrg actual_cwrapper_path); 369647e89262Smrg XFREE (tmp_pathspec); 369747e89262Smrg 369847e89262Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 369947e89262Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 370047e89262Smrg 370147e89262Smrg /* wrapper name transforms */ 370247e89262Smrg strendzap (actual_cwrapper_name, ".exe"); 370347e89262Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 370447e89262Smrg XFREE (actual_cwrapper_name); 370547e89262Smrg actual_cwrapper_name = tmp_pathspec; 370647e89262Smrg tmp_pathspec = 0; 370747e89262Smrg 370847e89262Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 370947e89262Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 371047e89262Smrg strendzap (target_name, ".exe"); 371147e89262Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 371247e89262Smrg XFREE (target_name); 371347e89262Smrg target_name = tmp_pathspec; 371447e89262Smrg tmp_pathspec = 0; 371547e89262Smrg 371647e89262Smrg lt_debugprintf (__FILE__, __LINE__, 371747e89262Smrg "(main) libtool target name: %s\n", 371847e89262Smrg target_name); 371947e89262SmrgEOF 3720bd1da9d7Smrg 372147e89262Smrg cat <<EOF 372247e89262Smrg newargz[0] = 372347e89262Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 372447e89262Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 372547e89262Smrg strcpy (newargz[0], actual_cwrapper_path); 372647e89262Smrg strcat (newargz[0], "$objdir"); 372747e89262Smrg strcat (newargz[0], "/"); 372847e89262SmrgEOF 3729bd1da9d7Smrg 373047e89262Smrg cat <<"EOF" 373147e89262Smrg /* stop here, and copy so we don't have to do this twice */ 373247e89262Smrg tmp_pathspec = xstrdup (newargz[0]); 3733bd1da9d7Smrg 373447e89262Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 373547e89262Smrg strcat (newargz[0], actual_cwrapper_name); 3736bd1da9d7Smrg 373747e89262Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 373847e89262Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 373947e89262Smrg XFREE (tmp_pathspec); 374047e89262Smrg tmp_pathspec = NULL; 374147e89262SmrgEOF 3742bd1da9d7Smrg 374347e89262Smrg case $host_os in 374447e89262Smrg mingw*) 374547e89262Smrg cat <<"EOF" 374647e89262Smrg { 374747e89262Smrg char* p; 374847e89262Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 374947e89262Smrg { 375047e89262Smrg *p = '/'; 375147e89262Smrg } 375247e89262Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 375347e89262Smrg { 375447e89262Smrg *p = '/'; 375547e89262Smrg } 375647e89262Smrg } 375747e89262SmrgEOF 375847e89262Smrg ;; 375947e89262Smrg esac 3760bd1da9d7Smrg 376147e89262Smrg cat <<"EOF" 376247e89262Smrg XFREE (target_name); 376347e89262Smrg XFREE (actual_cwrapper_path); 376447e89262Smrg XFREE (actual_cwrapper_name); 3765bd1da9d7Smrg 376647e89262Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 376747e89262Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 376847e89262Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 376947e89262Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 3770bd1da9d7Smrg 377147e89262Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 377247e89262Smrg nonnull (lt_argv_zero)); 377347e89262Smrg for (i = 0; i < newargc; i++) 377447e89262Smrg { 377547e89262Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 377647e89262Smrg i, nonnull (newargz[i])); 377747e89262Smrg } 3778bd1da9d7Smrg 377947e89262SmrgEOF 3780bd1da9d7Smrg 378147e89262Smrg case $host_os in 378247e89262Smrg mingw*) 378347e89262Smrg cat <<"EOF" 378447e89262Smrg /* execv doesn't actually work on mingw as expected on unix */ 378547e89262Smrg newargz = prepare_spawn (newargz); 378647e89262Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 378747e89262Smrg if (rval == -1) 378847e89262Smrg { 378947e89262Smrg /* failed to start process */ 379047e89262Smrg lt_debugprintf (__FILE__, __LINE__, 379147e89262Smrg "(main) failed to launch target \"%s\": %s\n", 379247e89262Smrg lt_argv_zero, nonnull (strerror (errno))); 379347e89262Smrg return 127; 379447e89262Smrg } 379547e89262Smrg return rval; 379647e89262SmrgEOF 379747e89262Smrg ;; 379847e89262Smrg *) 379947e89262Smrg cat <<"EOF" 380047e89262Smrg execv (lt_argv_zero, newargz); 380147e89262Smrg return rval; /* =127, but avoids unused variable warning */ 380247e89262SmrgEOF 380347e89262Smrg ;; 380447e89262Smrg esac 3805bd1da9d7Smrg 380647e89262Smrg cat <<"EOF" 380747e89262Smrg} 3808bd1da9d7Smrg 380947e89262Smrgvoid * 381047e89262Smrgxmalloc (size_t num) 381147e89262Smrg{ 381247e89262Smrg void *p = (void *) malloc (num); 381347e89262Smrg if (!p) 381447e89262Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 3815bd1da9d7Smrg 381647e89262Smrg return p; 381747e89262Smrg} 3818bd1da9d7Smrg 381947e89262Smrgchar * 382047e89262Smrgxstrdup (const char *string) 382147e89262Smrg{ 382247e89262Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 382347e89262Smrg string) : NULL; 382447e89262Smrg} 3825bd1da9d7Smrg 382647e89262Smrgconst char * 382747e89262Smrgbase_name (const char *name) 382847e89262Smrg{ 382947e89262Smrg const char *base; 3830bd1da9d7Smrg 383147e89262Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 383247e89262Smrg /* Skip over the disk name in MSDOS pathnames. */ 383347e89262Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 383447e89262Smrg name += 2; 383547e89262Smrg#endif 3836bd1da9d7Smrg 383747e89262Smrg for (base = name; *name; name++) 383847e89262Smrg if (IS_DIR_SEPARATOR (*name)) 383947e89262Smrg base = name + 1; 384047e89262Smrg return base; 384147e89262Smrg} 3842bd1da9d7Smrg 384347e89262Smrgint 384447e89262Smrgcheck_executable (const char *path) 384547e89262Smrg{ 384647e89262Smrg struct stat st; 3847bd1da9d7Smrg 384847e89262Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 384947e89262Smrg nonempty (path)); 385047e89262Smrg if ((!path) || (!*path)) 385147e89262Smrg return 0; 3852bd1da9d7Smrg 385347e89262Smrg if ((stat (path, &st) >= 0) 385447e89262Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 385547e89262Smrg return 1; 385647e89262Smrg else 385747e89262Smrg return 0; 385847e89262Smrg} 3859bd1da9d7Smrg 386047e89262Smrgint 386147e89262Smrgmake_executable (const char *path) 386247e89262Smrg{ 386347e89262Smrg int rval = 0; 386447e89262Smrg struct stat st; 3865bd1da9d7Smrg 386647e89262Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 386747e89262Smrg nonempty (path)); 386847e89262Smrg if ((!path) || (!*path)) 386947e89262Smrg return 0; 3870bd1da9d7Smrg 387147e89262Smrg if (stat (path, &st) >= 0) 387247e89262Smrg { 387347e89262Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 387447e89262Smrg } 387547e89262Smrg return rval; 387647e89262Smrg} 3877bd1da9d7Smrg 387847e89262Smrg/* Searches for the full path of the wrapper. Returns 387947e89262Smrg newly allocated full path name if found, NULL otherwise 388047e89262Smrg Does not chase symlinks, even on platforms that support them. 388147e89262Smrg*/ 388247e89262Smrgchar * 388347e89262Smrgfind_executable (const char *wrapper) 388447e89262Smrg{ 388547e89262Smrg int has_slash = 0; 388647e89262Smrg const char *p; 388747e89262Smrg const char *p_next; 388847e89262Smrg /* static buffer for getcwd */ 388947e89262Smrg char tmp[LT_PATHMAX + 1]; 389047e89262Smrg int tmp_len; 389147e89262Smrg char *concat_name; 3892bd1da9d7Smrg 389347e89262Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 389447e89262Smrg nonempty (wrapper)); 3895bd1da9d7Smrg 389647e89262Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 389747e89262Smrg return NULL; 3898bd1da9d7Smrg 389947e89262Smrg /* Absolute path? */ 390047e89262Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 390147e89262Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 390247e89262Smrg { 390347e89262Smrg concat_name = xstrdup (wrapper); 390447e89262Smrg if (check_executable (concat_name)) 390547e89262Smrg return concat_name; 390647e89262Smrg XFREE (concat_name); 390747e89262Smrg } 390847e89262Smrg else 390947e89262Smrg { 391047e89262Smrg#endif 391147e89262Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 391247e89262Smrg { 391347e89262Smrg concat_name = xstrdup (wrapper); 391447e89262Smrg if (check_executable (concat_name)) 391547e89262Smrg return concat_name; 391647e89262Smrg XFREE (concat_name); 391747e89262Smrg } 391847e89262Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 391947e89262Smrg } 392047e89262Smrg#endif 3921bd1da9d7Smrg 392247e89262Smrg for (p = wrapper; *p; p++) 392347e89262Smrg if (*p == '/') 392447e89262Smrg { 392547e89262Smrg has_slash = 1; 392647e89262Smrg break; 392747e89262Smrg } 392847e89262Smrg if (!has_slash) 392947e89262Smrg { 393047e89262Smrg /* no slashes; search PATH */ 393147e89262Smrg const char *path = getenv ("PATH"); 393247e89262Smrg if (path != NULL) 393347e89262Smrg { 393447e89262Smrg for (p = path; *p; p = p_next) 393547e89262Smrg { 393647e89262Smrg const char *q; 393747e89262Smrg size_t p_len; 393847e89262Smrg for (q = p; *q; q++) 393947e89262Smrg if (IS_PATH_SEPARATOR (*q)) 394047e89262Smrg break; 394147e89262Smrg p_len = q - p; 394247e89262Smrg p_next = (*q == '\0' ? q : q + 1); 394347e89262Smrg if (p_len == 0) 394447e89262Smrg { 394547e89262Smrg /* empty path: current directory */ 394647e89262Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 394747e89262Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 394847e89262Smrg nonnull (strerror (errno))); 394947e89262Smrg tmp_len = strlen (tmp); 395047e89262Smrg concat_name = 395147e89262Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 395247e89262Smrg memcpy (concat_name, tmp, tmp_len); 395347e89262Smrg concat_name[tmp_len] = '/'; 395447e89262Smrg strcpy (concat_name + tmp_len + 1, wrapper); 395547e89262Smrg } 395647e89262Smrg else 395747e89262Smrg { 395847e89262Smrg concat_name = 395947e89262Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 396047e89262Smrg memcpy (concat_name, p, p_len); 396147e89262Smrg concat_name[p_len] = '/'; 396247e89262Smrg strcpy (concat_name + p_len + 1, wrapper); 396347e89262Smrg } 396447e89262Smrg if (check_executable (concat_name)) 396547e89262Smrg return concat_name; 396647e89262Smrg XFREE (concat_name); 396747e89262Smrg } 396847e89262Smrg } 396947e89262Smrg /* not found in PATH; assume curdir */ 397047e89262Smrg } 397147e89262Smrg /* Relative path | not found in path: prepend cwd */ 397247e89262Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 397347e89262Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 397447e89262Smrg nonnull (strerror (errno))); 397547e89262Smrg tmp_len = strlen (tmp); 397647e89262Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 397747e89262Smrg memcpy (concat_name, tmp, tmp_len); 397847e89262Smrg concat_name[tmp_len] = '/'; 397947e89262Smrg strcpy (concat_name + tmp_len + 1, wrapper); 3980bd1da9d7Smrg 398147e89262Smrg if (check_executable (concat_name)) 398247e89262Smrg return concat_name; 398347e89262Smrg XFREE (concat_name); 398447e89262Smrg return NULL; 398547e89262Smrg} 3986bd1da9d7Smrg 398747e89262Smrgchar * 398847e89262Smrgchase_symlinks (const char *pathspec) 398947e89262Smrg{ 399047e89262Smrg#ifndef S_ISLNK 399147e89262Smrg return xstrdup (pathspec); 399247e89262Smrg#else 399347e89262Smrg char buf[LT_PATHMAX]; 399447e89262Smrg struct stat s; 399547e89262Smrg char *tmp_pathspec = xstrdup (pathspec); 399647e89262Smrg char *p; 399747e89262Smrg int has_symlinks = 0; 399847e89262Smrg while (strlen (tmp_pathspec) && !has_symlinks) 399947e89262Smrg { 400047e89262Smrg lt_debugprintf (__FILE__, __LINE__, 400147e89262Smrg "checking path component for symlinks: %s\n", 400247e89262Smrg tmp_pathspec); 400347e89262Smrg if (lstat (tmp_pathspec, &s) == 0) 400447e89262Smrg { 400547e89262Smrg if (S_ISLNK (s.st_mode) != 0) 400647e89262Smrg { 400747e89262Smrg has_symlinks = 1; 400847e89262Smrg break; 400947e89262Smrg } 4010bd1da9d7Smrg 401147e89262Smrg /* search backwards for last DIR_SEPARATOR */ 401247e89262Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 401347e89262Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 401447e89262Smrg p--; 401547e89262Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 401647e89262Smrg { 401747e89262Smrg /* no more DIR_SEPARATORS left */ 401847e89262Smrg break; 401947e89262Smrg } 402047e89262Smrg *p = '\0'; 402147e89262Smrg } 402247e89262Smrg else 402347e89262Smrg { 402447e89262Smrg lt_fatal (__FILE__, __LINE__, 402547e89262Smrg "error accessing file \"%s\": %s", 402647e89262Smrg tmp_pathspec, nonnull (strerror (errno))); 402747e89262Smrg } 402847e89262Smrg } 402947e89262Smrg XFREE (tmp_pathspec); 4030bd1da9d7Smrg 403147e89262Smrg if (!has_symlinks) 403247e89262Smrg { 403347e89262Smrg return xstrdup (pathspec); 403447e89262Smrg } 4035bd1da9d7Smrg 403647e89262Smrg tmp_pathspec = realpath (pathspec, buf); 403747e89262Smrg if (tmp_pathspec == 0) 403847e89262Smrg { 403947e89262Smrg lt_fatal (__FILE__, __LINE__, 404047e89262Smrg "could not follow symlinks for %s", pathspec); 404147e89262Smrg } 404247e89262Smrg return xstrdup (tmp_pathspec); 404347e89262Smrg#endif 404447e89262Smrg} 4045bd1da9d7Smrg 404647e89262Smrgchar * 404747e89262Smrgstrendzap (char *str, const char *pat) 404847e89262Smrg{ 404947e89262Smrg size_t len, patlen; 4050bd1da9d7Smrg 405147e89262Smrg assert (str != NULL); 405247e89262Smrg assert (pat != NULL); 4053bd1da9d7Smrg 405447e89262Smrg len = strlen (str); 405547e89262Smrg patlen = strlen (pat); 4056bd1da9d7Smrg 405747e89262Smrg if (patlen <= len) 405847e89262Smrg { 405947e89262Smrg str += len - patlen; 406047e89262Smrg if (strcmp (str, pat) == 0) 406147e89262Smrg *str = '\0'; 406247e89262Smrg } 406347e89262Smrg return str; 406447e89262Smrg} 4065bd1da9d7Smrg 406647e89262Smrgvoid 406747e89262Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 406847e89262Smrg{ 406947e89262Smrg va_list args; 407047e89262Smrg if (lt_debug) 407147e89262Smrg { 407247e89262Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 407347e89262Smrg va_start (args, fmt); 407447e89262Smrg (void) vfprintf (stderr, fmt, args); 407547e89262Smrg va_end (args); 407647e89262Smrg } 407747e89262Smrg} 4078bd1da9d7Smrg 407947e89262Smrgstatic void 408047e89262Smrglt_error_core (int exit_status, const char *file, 408147e89262Smrg int line, const char *mode, 408247e89262Smrg const char *message, va_list ap) 408347e89262Smrg{ 408447e89262Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 408547e89262Smrg vfprintf (stderr, message, ap); 408647e89262Smrg fprintf (stderr, ".\n"); 4087bd1da9d7Smrg 408847e89262Smrg if (exit_status >= 0) 408947e89262Smrg exit (exit_status); 409047e89262Smrg} 4091bd1da9d7Smrg 409247e89262Smrgvoid 409347e89262Smrglt_fatal (const char *file, int line, const char *message, ...) 409447e89262Smrg{ 409547e89262Smrg va_list ap; 409647e89262Smrg va_start (ap, message); 409747e89262Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 409847e89262Smrg va_end (ap); 409947e89262Smrg} 4100bd1da9d7Smrg 410147e89262Smrgstatic const char * 410247e89262Smrgnonnull (const char *s) 410347e89262Smrg{ 410447e89262Smrg return s ? s : "(null)"; 410547e89262Smrg} 4106bd1da9d7Smrg 410747e89262Smrgstatic const char * 410847e89262Smrgnonempty (const char *s) 410947e89262Smrg{ 411047e89262Smrg return (s && !*s) ? "(empty)" : nonnull (s); 411147e89262Smrg} 4112bd1da9d7Smrg 411347e89262Smrgvoid 411447e89262Smrglt_setenv (const char *name, const char *value) 411547e89262Smrg{ 411647e89262Smrg lt_debugprintf (__FILE__, __LINE__, 411747e89262Smrg "(lt_setenv) setting '%s' to '%s'\n", 411847e89262Smrg nonnull (name), nonnull (value)); 411947e89262Smrg { 412047e89262Smrg#ifdef HAVE_SETENV 412147e89262Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 412247e89262Smrg char *str = xstrdup (value); 412347e89262Smrg setenv (name, str, 1); 412447e89262Smrg#else 412547e89262Smrg int len = strlen (name) + 1 + strlen (value) + 1; 412647e89262Smrg char *str = XMALLOC (char, len); 412747e89262Smrg sprintf (str, "%s=%s", name, value); 412847e89262Smrg if (putenv (str) != EXIT_SUCCESS) 412947e89262Smrg { 413047e89262Smrg XFREE (str); 413147e89262Smrg } 413247e89262Smrg#endif 413347e89262Smrg } 413447e89262Smrg} 4135bd1da9d7Smrg 413647e89262Smrgchar * 413747e89262Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 413847e89262Smrg{ 413947e89262Smrg char *new_value; 414047e89262Smrg if (orig_value && *orig_value) 414147e89262Smrg { 414247e89262Smrg int orig_value_len = strlen (orig_value); 414347e89262Smrg int add_len = strlen (add); 414447e89262Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 414547e89262Smrg if (to_end) 414647e89262Smrg { 414747e89262Smrg strcpy (new_value, orig_value); 414847e89262Smrg strcpy (new_value + orig_value_len, add); 414947e89262Smrg } 415047e89262Smrg else 415147e89262Smrg { 415247e89262Smrg strcpy (new_value, add); 415347e89262Smrg strcpy (new_value + add_len, orig_value); 415447e89262Smrg } 415547e89262Smrg } 415647e89262Smrg else 415747e89262Smrg { 415847e89262Smrg new_value = xstrdup (add); 415947e89262Smrg } 416047e89262Smrg return new_value; 416147e89262Smrg} 4162bd1da9d7Smrg 416347e89262Smrgvoid 416447e89262Smrglt_update_exe_path (const char *name, const char *value) 416547e89262Smrg{ 416647e89262Smrg lt_debugprintf (__FILE__, __LINE__, 416747e89262Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 416847e89262Smrg nonnull (name), nonnull (value)); 4169bd1da9d7Smrg 417047e89262Smrg if (name && *name && value && *value) 417147e89262Smrg { 417247e89262Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 417347e89262Smrg /* some systems can't cope with a ':'-terminated path #' */ 417447e89262Smrg int len = strlen (new_value); 417547e89262Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 417647e89262Smrg { 417747e89262Smrg new_value[len-1] = '\0'; 417847e89262Smrg } 417947e89262Smrg lt_setenv (name, new_value); 418047e89262Smrg XFREE (new_value); 418147e89262Smrg } 418247e89262Smrg} 4183bd1da9d7Smrg 418447e89262Smrgvoid 418547e89262Smrglt_update_lib_path (const char *name, const char *value) 418647e89262Smrg{ 418747e89262Smrg lt_debugprintf (__FILE__, __LINE__, 418847e89262Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 418947e89262Smrg nonnull (name), nonnull (value)); 4190bd1da9d7Smrg 419147e89262Smrg if (name && *name && value && *value) 419247e89262Smrg { 419347e89262Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 419447e89262Smrg lt_setenv (name, new_value); 419547e89262Smrg XFREE (new_value); 419647e89262Smrg } 419747e89262Smrg} 4198bd1da9d7Smrg 419947e89262SmrgEOF 420047e89262Smrg case $host_os in 420147e89262Smrg mingw*) 420247e89262Smrg cat <<"EOF" 420347e89262Smrg 420447e89262Smrg/* Prepares an argument vector before calling spawn(). 420547e89262Smrg Note that spawn() does not by itself call the command interpreter 420647e89262Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 420747e89262Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 420847e89262Smrg GetVersionEx(&v); 420947e89262Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 421047e89262Smrg }) ? "cmd.exe" : "command.com"). 421147e89262Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 421247e89262Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 421347e89262Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 421447e89262Smrg special way: 421547e89262Smrg - Space and tab are interpreted as delimiters. They are not treated as 421647e89262Smrg delimiters if they are surrounded by double quotes: "...". 421747e89262Smrg - Unescaped double quotes are removed from the input. Their only effect is 421847e89262Smrg that within double quotes, space and tab are treated like normal 421947e89262Smrg characters. 422047e89262Smrg - Backslashes not followed by double quotes are not special. 422147e89262Smrg - But 2*n+1 backslashes followed by a double quote become 422247e89262Smrg n backslashes followed by a double quote (n >= 0): 422347e89262Smrg \" -> " 422447e89262Smrg \\\" -> \" 422547e89262Smrg \\\\\" -> \\" 422647e89262Smrg */ 422747e89262Smrg#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" 422847e89262Smrg#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" 422947e89262Smrgchar ** 423047e89262Smrgprepare_spawn (char **argv) 423147e89262Smrg{ 423247e89262Smrg size_t argc; 423347e89262Smrg char **new_argv; 423447e89262Smrg size_t i; 4235bd1da9d7Smrg 423647e89262Smrg /* Count number of arguments. */ 423747e89262Smrg for (argc = 0; argv[argc] != NULL; argc++) 423847e89262Smrg ; 4239bd1da9d7Smrg 424047e89262Smrg /* Allocate new argument vector. */ 424147e89262Smrg new_argv = XMALLOC (char *, argc + 1); 4242bd1da9d7Smrg 424347e89262Smrg /* Put quoted arguments into the new argument vector. */ 424447e89262Smrg for (i = 0; i < argc; i++) 424547e89262Smrg { 424647e89262Smrg const char *string = argv[i]; 424747e89262Smrg 424847e89262Smrg if (string[0] == '\0') 424947e89262Smrg new_argv[i] = xstrdup ("\"\""); 425047e89262Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 425147e89262Smrg { 425247e89262Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 425347e89262Smrg size_t length; 425447e89262Smrg unsigned int backslashes; 425547e89262Smrg const char *s; 425647e89262Smrg char *quoted_string; 425747e89262Smrg char *p; 425847e89262Smrg 425947e89262Smrg length = 0; 426047e89262Smrg backslashes = 0; 426147e89262Smrg if (quote_around) 426247e89262Smrg length++; 426347e89262Smrg for (s = string; *s != '\0'; s++) 426447e89262Smrg { 426547e89262Smrg char c = *s; 426647e89262Smrg if (c == '"') 426747e89262Smrg length += backslashes + 1; 426847e89262Smrg length++; 426947e89262Smrg if (c == '\\') 427047e89262Smrg backslashes++; 427147e89262Smrg else 427247e89262Smrg backslashes = 0; 427347e89262Smrg } 427447e89262Smrg if (quote_around) 427547e89262Smrg length += backslashes + 1; 427647e89262Smrg 427747e89262Smrg quoted_string = XMALLOC (char, length + 1); 427847e89262Smrg 427947e89262Smrg p = quoted_string; 428047e89262Smrg backslashes = 0; 428147e89262Smrg if (quote_around) 428247e89262Smrg *p++ = '"'; 428347e89262Smrg for (s = string; *s != '\0'; s++) 428447e89262Smrg { 428547e89262Smrg char c = *s; 428647e89262Smrg if (c == '"') 428747e89262Smrg { 428847e89262Smrg unsigned int j; 428947e89262Smrg for (j = backslashes + 1; j > 0; j--) 429047e89262Smrg *p++ = '\\'; 429147e89262Smrg } 429247e89262Smrg *p++ = c; 429347e89262Smrg if (c == '\\') 429447e89262Smrg backslashes++; 429547e89262Smrg else 429647e89262Smrg backslashes = 0; 429747e89262Smrg } 429847e89262Smrg if (quote_around) 429947e89262Smrg { 430047e89262Smrg unsigned int j; 430147e89262Smrg for (j = backslashes; j > 0; j--) 430247e89262Smrg *p++ = '\\'; 430347e89262Smrg *p++ = '"'; 430447e89262Smrg } 430547e89262Smrg *p = '\0'; 4306bd1da9d7Smrg 430747e89262Smrg new_argv[i] = quoted_string; 430847e89262Smrg } 430947e89262Smrg else 431047e89262Smrg new_argv[i] = (char *) string; 431147e89262Smrg } 431247e89262Smrg new_argv[argc] = NULL; 4313bd1da9d7Smrg 431447e89262Smrg return new_argv; 431547e89262Smrg} 431647e89262SmrgEOF 4317bd1da9d7Smrg ;; 431847e89262Smrg esac 4319bd1da9d7Smrg 432047e89262Smrg cat <<"EOF" 432147e89262Smrgvoid lt_dump_script (FILE* f) 432247e89262Smrg{ 432347e89262SmrgEOF 432447e89262Smrg func_emit_wrapper yes | 432547e89262Smrg $SED -e 's/\([\\"]\)/\\\1/g' \ 432647e89262Smrg -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' 4327bd1da9d7Smrg 432847e89262Smrg cat <<"EOF" 432947e89262Smrg} 433047e89262SmrgEOF 433147e89262Smrg} 433247e89262Smrg# end: func_emit_cwrapperexe_src 4333bd1da9d7Smrg 433447e89262Smrg# func_win32_import_lib_p ARG 433547e89262Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 433647e89262Smrgfunc_win32_import_lib_p () 433747e89262Smrg{ 433847e89262Smrg $opt_debug 433947e89262Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 434047e89262Smrg *import*) : ;; 434147e89262Smrg *) false ;; 434247e89262Smrg esac 434347e89262Smrg} 4344bd1da9d7Smrg 434547e89262Smrg# func_mode_link arg... 434647e89262Smrgfunc_mode_link () 434747e89262Smrg{ 434847e89262Smrg $opt_debug 434947e89262Smrg case $host in 435047e89262Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 435147e89262Smrg # It is impossible to link a dll without this setting, and 435247e89262Smrg # we shouldn't force the makefile maintainer to figure out 435347e89262Smrg # which system we are compiling for in order to pass an extra 435447e89262Smrg # flag for every libtool invocation. 435547e89262Smrg # allow_undefined=no 4356bd1da9d7Smrg 435747e89262Smrg # FIXME: Unfortunately, there are problems with the above when trying 435847e89262Smrg # to make a dll which has undefined symbols, in which case not 435947e89262Smrg # even a static library is built. For now, we need to specify 436047e89262Smrg # -no-undefined on the libtool link line when we can be certain 436147e89262Smrg # that all symbols are satisfied, otherwise we get a static library. 436247e89262Smrg allow_undefined=yes 436347e89262Smrg ;; 436447e89262Smrg *) 436547e89262Smrg allow_undefined=yes 436647e89262Smrg ;; 436747e89262Smrg esac 436847e89262Smrg libtool_args=$nonopt 436947e89262Smrg base_compile="$nonopt $@" 437047e89262Smrg compile_command=$nonopt 437147e89262Smrg finalize_command=$nonopt 4372bd1da9d7Smrg 437347e89262Smrg compile_rpath= 437447e89262Smrg finalize_rpath= 437547e89262Smrg compile_shlibpath= 437647e89262Smrg finalize_shlibpath= 437747e89262Smrg convenience= 437847e89262Smrg old_convenience= 437947e89262Smrg deplibs= 438047e89262Smrg old_deplibs= 438147e89262Smrg compiler_flags= 438247e89262Smrg linker_flags= 438347e89262Smrg dllsearchpath= 438447e89262Smrg lib_search_path=`pwd` 438547e89262Smrg inst_prefix_dir= 438647e89262Smrg new_inherited_linker_flags= 4387bd1da9d7Smrg 438847e89262Smrg avoid_version=no 438947e89262Smrg bindir= 439047e89262Smrg dlfiles= 439147e89262Smrg dlprefiles= 439247e89262Smrg dlself=no 439347e89262Smrg export_dynamic=no 439447e89262Smrg export_symbols= 439547e89262Smrg export_symbols_regex= 439647e89262Smrg generated= 439747e89262Smrg libobjs= 439847e89262Smrg ltlibs= 439947e89262Smrg module=no 440047e89262Smrg no_install=no 440147e89262Smrg objs= 440247e89262Smrg non_pic_objects= 440347e89262Smrg precious_files_regex= 440447e89262Smrg prefer_static_libs=no 440547e89262Smrg preload=no 440647e89262Smrg prev= 440747e89262Smrg prevarg= 440847e89262Smrg release= 440947e89262Smrg rpath= 441047e89262Smrg xrpath= 441147e89262Smrg perm_rpath= 441247e89262Smrg temp_rpath= 441347e89262Smrg thread_safe=no 441447e89262Smrg vinfo= 441547e89262Smrg vinfo_number=no 441647e89262Smrg weak_libs= 441747e89262Smrg single_module="${wl}-single_module" 441847e89262Smrg func_infer_tag $base_compile 4419bd1da9d7Smrg 442047e89262Smrg # We need to know -static, to get the right output filenames. 442147e89262Smrg for arg 442247e89262Smrg do 442347e89262Smrg case $arg in 442447e89262Smrg -shared) 442547e89262Smrg test "$build_libtool_libs" != yes && \ 442647e89262Smrg func_fatal_configuration "can not build a shared library" 442747e89262Smrg build_old_libs=no 442847e89262Smrg break 442947e89262Smrg ;; 443047e89262Smrg -all-static | -static | -static-libtool-libs) 443147e89262Smrg case $arg in 443247e89262Smrg -all-static) 443347e89262Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 443447e89262Smrg func_warning "complete static linking is impossible in this configuration" 443547e89262Smrg fi 443647e89262Smrg if test -n "$link_static_flag"; then 443747e89262Smrg dlopen_self=$dlopen_self_static 443847e89262Smrg fi 443947e89262Smrg prefer_static_libs=yes 444047e89262Smrg ;; 444147e89262Smrg -static) 444247e89262Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 444347e89262Smrg dlopen_self=$dlopen_self_static 444447e89262Smrg fi 444547e89262Smrg prefer_static_libs=built 444647e89262Smrg ;; 444747e89262Smrg -static-libtool-libs) 444847e89262Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 444947e89262Smrg dlopen_self=$dlopen_self_static 445047e89262Smrg fi 445147e89262Smrg prefer_static_libs=yes 445247e89262Smrg ;; 445347e89262Smrg esac 445447e89262Smrg build_libtool_libs=no 445547e89262Smrg build_old_libs=yes 445647e89262Smrg break 445747e89262Smrg ;; 445847e89262Smrg esac 445947e89262Smrg done 4460bd1da9d7Smrg 446147e89262Smrg # See if our shared archives depend on static archives. 446247e89262Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 4463bd1da9d7Smrg 446447e89262Smrg # Go through the arguments, transforming them on the way. 446547e89262Smrg while test "$#" -gt 0; do 446647e89262Smrg arg="$1" 446747e89262Smrg shift 446847e89262Smrg func_quote_for_eval "$arg" 446947e89262Smrg qarg=$func_quote_for_eval_unquoted_result 447047e89262Smrg func_append libtool_args " $func_quote_for_eval_result" 4471bd1da9d7Smrg 447247e89262Smrg # If the previous option needs an argument, assign it. 447347e89262Smrg if test -n "$prev"; then 447447e89262Smrg case $prev in 447547e89262Smrg output) 447647e89262Smrg func_append compile_command " @OUTPUT@" 447747e89262Smrg func_append finalize_command " @OUTPUT@" 447847e89262Smrg ;; 447947e89262Smrg esac 4480bd1da9d7Smrg 448147e89262Smrg case $prev in 448247e89262Smrg bindir) 448347e89262Smrg bindir="$arg" 448447e89262Smrg prev= 448547e89262Smrg continue 448647e89262Smrg ;; 448747e89262Smrg dlfiles|dlprefiles) 448847e89262Smrg if test "$preload" = no; then 448947e89262Smrg # Add the symbol object into the linking commands. 449047e89262Smrg func_append compile_command " @SYMFILE@" 449147e89262Smrg func_append finalize_command " @SYMFILE@" 449247e89262Smrg preload=yes 4493bd1da9d7Smrg fi 449447e89262Smrg case $arg in 449547e89262Smrg *.la | *.lo) ;; # We handle these cases below. 449647e89262Smrg force) 449747e89262Smrg if test "$dlself" = no; then 449847e89262Smrg dlself=needless 449947e89262Smrg export_dynamic=yes 4500bd1da9d7Smrg fi 450147e89262Smrg prev= 450247e89262Smrg continue 450347e89262Smrg ;; 450447e89262Smrg self) 450547e89262Smrg if test "$prev" = dlprefiles; then 450647e89262Smrg dlself=yes 450747e89262Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 450847e89262Smrg dlself=yes 4509bd1da9d7Smrg else 451047e89262Smrg dlself=needless 451147e89262Smrg export_dynamic=yes 4512bd1da9d7Smrg fi 451347e89262Smrg prev= 451447e89262Smrg continue 451547e89262Smrg ;; 451647e89262Smrg *) 451747e89262Smrg if test "$prev" = dlfiles; then 451847e89262Smrg dlfiles="$dlfiles $arg" 4519bd1da9d7Smrg else 452047e89262Smrg dlprefiles="$dlprefiles $arg" 4521bd1da9d7Smrg fi 452247e89262Smrg prev= 452347e89262Smrg continue 452447e89262Smrg ;; 452547e89262Smrg esac 452647e89262Smrg ;; 452747e89262Smrg expsyms) 452847e89262Smrg export_symbols="$arg" 452947e89262Smrg test -f "$arg" \ 453047e89262Smrg || func_fatal_error "symbol file \`$arg' does not exist" 453147e89262Smrg prev= 453247e89262Smrg continue 453347e89262Smrg ;; 453447e89262Smrg expsyms_regex) 453547e89262Smrg export_symbols_regex="$arg" 453647e89262Smrg prev= 453747e89262Smrg continue 453847e89262Smrg ;; 453947e89262Smrg framework) 4540bd1da9d7Smrg case $host in 454147e89262Smrg *-*-darwin*) 454247e89262Smrg case "$deplibs " in 454347e89262Smrg *" $qarg.ltframework "*) ;; 454447e89262Smrg *) deplibs="$deplibs $qarg.ltframework" # this is fixed later 454547e89262Smrg ;; 454647e89262Smrg esac 454747e89262Smrg ;; 4548bd1da9d7Smrg esac 454947e89262Smrg prev= 455047e89262Smrg continue 4551bd1da9d7Smrg ;; 455247e89262Smrg inst_prefix) 455347e89262Smrg inst_prefix_dir="$arg" 455447e89262Smrg prev= 455547e89262Smrg continue 4556bd1da9d7Smrg ;; 455747e89262Smrg objectlist) 455847e89262Smrg if test -f "$arg"; then 455947e89262Smrg save_arg=$arg 456047e89262Smrg moreargs= 456147e89262Smrg for fil in `cat "$save_arg"` 456247e89262Smrg do 456347e89262Smrg# moreargs="$moreargs $fil" 456447e89262Smrg arg=$fil 456547e89262Smrg # A libtool-controlled object. 4566bd1da9d7Smrg 456747e89262Smrg # Check to see that this really is a libtool object. 456847e89262Smrg if func_lalib_unsafe_p "$arg"; then 456947e89262Smrg pic_object= 457047e89262Smrg non_pic_object= 4571bd1da9d7Smrg 457247e89262Smrg # Read the .lo file 457347e89262Smrg func_source "$arg" 4574bd1da9d7Smrg 457547e89262Smrg if test -z "$pic_object" || 457647e89262Smrg test -z "$non_pic_object" || 457747e89262Smrg test "$pic_object" = none && 457847e89262Smrg test "$non_pic_object" = none; then 457947e89262Smrg func_fatal_error "cannot find name of object for \`$arg'" 458047e89262Smrg fi 4581bd1da9d7Smrg 458247e89262Smrg # Extract subdirectory from the argument. 458347e89262Smrg func_dirname "$arg" "/" "" 458447e89262Smrg xdir="$func_dirname_result" 4585bd1da9d7Smrg 458647e89262Smrg if test "$pic_object" != none; then 458747e89262Smrg # Prepend the subdirectory the object is found in. 458847e89262Smrg pic_object="$xdir$pic_object" 4589bd1da9d7Smrg 459047e89262Smrg if test "$prev" = dlfiles; then 459147e89262Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 459247e89262Smrg dlfiles="$dlfiles $pic_object" 459347e89262Smrg prev= 459447e89262Smrg continue 459547e89262Smrg else 459647e89262Smrg # If libtool objects are unsupported, then we need to preload. 459747e89262Smrg prev=dlprefiles 459847e89262Smrg fi 459947e89262Smrg fi 4600bd1da9d7Smrg 460147e89262Smrg # CHECK ME: I think I busted this. -Ossama 460247e89262Smrg if test "$prev" = dlprefiles; then 460347e89262Smrg # Preload the old-style object. 460447e89262Smrg dlprefiles="$dlprefiles $pic_object" 460547e89262Smrg prev= 460647e89262Smrg fi 4607bd1da9d7Smrg 460847e89262Smrg # A PIC object. 460947e89262Smrg func_append libobjs " $pic_object" 461047e89262Smrg arg="$pic_object" 461147e89262Smrg fi 4612bd1da9d7Smrg 461347e89262Smrg # Non-PIC object. 461447e89262Smrg if test "$non_pic_object" != none; then 461547e89262Smrg # Prepend the subdirectory the object is found in. 461647e89262Smrg non_pic_object="$xdir$non_pic_object" 4617bd1da9d7Smrg 461847e89262Smrg # A standard non-PIC object 461947e89262Smrg func_append non_pic_objects " $non_pic_object" 462047e89262Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 462147e89262Smrg arg="$non_pic_object" 462247e89262Smrg fi 462347e89262Smrg else 462447e89262Smrg # If the PIC object exists, use it instead. 462547e89262Smrg # $xdir was prepended to $pic_object above. 462647e89262Smrg non_pic_object="$pic_object" 462747e89262Smrg func_append non_pic_objects " $non_pic_object" 462847e89262Smrg fi 462947e89262Smrg else 463047e89262Smrg # Only an error if not doing a dry-run. 463147e89262Smrg if $opt_dry_run; then 463247e89262Smrg # Extract subdirectory from the argument. 463347e89262Smrg func_dirname "$arg" "/" "" 463447e89262Smrg xdir="$func_dirname_result" 463547e89262Smrg 463647e89262Smrg func_lo2o "$arg" 463747e89262Smrg pic_object=$xdir$objdir/$func_lo2o_result 463847e89262Smrg non_pic_object=$xdir$func_lo2o_result 463947e89262Smrg func_append libobjs " $pic_object" 464047e89262Smrg func_append non_pic_objects " $non_pic_object" 464147e89262Smrg else 464247e89262Smrg func_fatal_error "\`$arg' is not a valid libtool object" 464347e89262Smrg fi 464447e89262Smrg fi 464547e89262Smrg done 4646bd1da9d7Smrg else 464747e89262Smrg func_fatal_error "link input file \`$arg' does not exist" 4648bd1da9d7Smrg fi 464947e89262Smrg arg=$save_arg 465047e89262Smrg prev= 465147e89262Smrg continue 465247e89262Smrg ;; 465347e89262Smrg precious_regex) 465447e89262Smrg precious_files_regex="$arg" 465547e89262Smrg prev= 465647e89262Smrg continue 465747e89262Smrg ;; 465847e89262Smrg release) 465947e89262Smrg release="-$arg" 466047e89262Smrg prev= 466147e89262Smrg continue 466247e89262Smrg ;; 466347e89262Smrg rpath | xrpath) 466447e89262Smrg # We need an absolute path. 466547e89262Smrg case $arg in 466647e89262Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 466747e89262Smrg *) 466847e89262Smrg func_fatal_error "only absolute run-paths are allowed" 466947e89262Smrg ;; 467047e89262Smrg esac 467147e89262Smrg if test "$prev" = rpath; then 467247e89262Smrg case "$rpath " in 467347e89262Smrg *" $arg "*) ;; 467447e89262Smrg *) rpath="$rpath $arg" ;; 467547e89262Smrg esac 4676bd1da9d7Smrg else 467747e89262Smrg case "$xrpath " in 467847e89262Smrg *" $arg "*) ;; 467947e89262Smrg *) xrpath="$xrpath $arg" ;; 468047e89262Smrg esac 4681bd1da9d7Smrg fi 468247e89262Smrg prev= 468347e89262Smrg continue 468447e89262Smrg ;; 468547e89262Smrg shrext) 468647e89262Smrg shrext_cmds="$arg" 468747e89262Smrg prev= 468847e89262Smrg continue 468947e89262Smrg ;; 469047e89262Smrg weak) 469147e89262Smrg weak_libs="$weak_libs $arg" 469247e89262Smrg prev= 469347e89262Smrg continue 469447e89262Smrg ;; 469547e89262Smrg xcclinker) 469647e89262Smrg linker_flags="$linker_flags $qarg" 469747e89262Smrg compiler_flags="$compiler_flags $qarg" 469847e89262Smrg prev= 469947e89262Smrg func_append compile_command " $qarg" 470047e89262Smrg func_append finalize_command " $qarg" 470147e89262Smrg continue 470247e89262Smrg ;; 470347e89262Smrg xcompiler) 470447e89262Smrg compiler_flags="$compiler_flags $qarg" 470547e89262Smrg prev= 470647e89262Smrg func_append compile_command " $qarg" 470747e89262Smrg func_append finalize_command " $qarg" 470847e89262Smrg continue 470947e89262Smrg ;; 471047e89262Smrg xlinker) 471147e89262Smrg linker_flags="$linker_flags $qarg" 471247e89262Smrg compiler_flags="$compiler_flags $wl$qarg" 471347e89262Smrg prev= 471447e89262Smrg func_append compile_command " $wl$qarg" 471547e89262Smrg func_append finalize_command " $wl$qarg" 471647e89262Smrg continue 471747e89262Smrg ;; 471847e89262Smrg *) 471947e89262Smrg eval "$prev=\"\$arg\"" 472047e89262Smrg prev= 472147e89262Smrg continue 472247e89262Smrg ;; 4723bd1da9d7Smrg esac 472447e89262Smrg fi # test -n "$prev" 4725bd1da9d7Smrg 472647e89262Smrg prevarg="$arg" 4727bd1da9d7Smrg 472847e89262Smrg case $arg in 472947e89262Smrg -all-static) 473047e89262Smrg if test -n "$link_static_flag"; then 473147e89262Smrg # See comment for -static flag below, for more details. 473247e89262Smrg func_append compile_command " $link_static_flag" 473347e89262Smrg func_append finalize_command " $link_static_flag" 473447e89262Smrg fi 473547e89262Smrg continue 473647e89262Smrg ;; 4737bd1da9d7Smrg 473847e89262Smrg -allow-undefined) 473947e89262Smrg # FIXME: remove this flag sometime in the future. 474047e89262Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 474147e89262Smrg ;; 4742bd1da9d7Smrg 474347e89262Smrg -avoid-version) 474447e89262Smrg avoid_version=yes 474547e89262Smrg continue 474647e89262Smrg ;; 4747bd1da9d7Smrg 474847e89262Smrg -bindir) 474947e89262Smrg prev=bindir 475047e89262Smrg continue 475147e89262Smrg ;; 4752bd1da9d7Smrg 475347e89262Smrg -dlopen) 475447e89262Smrg prev=dlfiles 475547e89262Smrg continue 475647e89262Smrg ;; 4757bd1da9d7Smrg 475847e89262Smrg -dlpreopen) 475947e89262Smrg prev=dlprefiles 476047e89262Smrg continue 476147e89262Smrg ;; 4762bd1da9d7Smrg 476347e89262Smrg -export-dynamic) 476447e89262Smrg export_dynamic=yes 476547e89262Smrg continue 476647e89262Smrg ;; 4767bd1da9d7Smrg 476847e89262Smrg -export-symbols | -export-symbols-regex) 476947e89262Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 477047e89262Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 477147e89262Smrg fi 477247e89262Smrg if test "X$arg" = "X-export-symbols"; then 477347e89262Smrg prev=expsyms 477447e89262Smrg else 477547e89262Smrg prev=expsyms_regex 477647e89262Smrg fi 477747e89262Smrg continue 477847e89262Smrg ;; 4779bd1da9d7Smrg 478047e89262Smrg -framework) 478147e89262Smrg prev=framework 478247e89262Smrg continue 478347e89262Smrg ;; 4784bd1da9d7Smrg 478547e89262Smrg -inst-prefix-dir) 478647e89262Smrg prev=inst_prefix 478747e89262Smrg continue 478847e89262Smrg ;; 4789bd1da9d7Smrg 479047e89262Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 479147e89262Smrg # so, if we see these flags be careful not to treat them like -L 479247e89262Smrg -L[A-Z][A-Z]*:*) 479347e89262Smrg case $with_gcc/$host in 479447e89262Smrg no/*-*-irix* | /*-*-irix*) 479547e89262Smrg func_append compile_command " $arg" 479647e89262Smrg func_append finalize_command " $arg" 479747e89262Smrg ;; 479847e89262Smrg esac 479947e89262Smrg continue 480047e89262Smrg ;; 4801bd1da9d7Smrg 480247e89262Smrg -L*) 480347e89262Smrg func_stripname '-L' '' "$arg" 480447e89262Smrg dir=$func_stripname_result 480547e89262Smrg if test -z "$dir"; then 480647e89262Smrg if test "$#" -gt 0; then 480747e89262Smrg func_fatal_error "require no space between \`-L' and \`$1'" 480847e89262Smrg else 480947e89262Smrg func_fatal_error "need path for \`-L' option" 481047e89262Smrg fi 481147e89262Smrg fi 481247e89262Smrg # We need an absolute path. 481347e89262Smrg case $dir in 481447e89262Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 481547e89262Smrg *) 481647e89262Smrg absdir=`cd "$dir" && pwd` 481747e89262Smrg test -z "$absdir" && \ 481847e89262Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 481947e89262Smrg dir="$absdir" 482047e89262Smrg ;; 482147e89262Smrg esac 482247e89262Smrg case "$deplibs " in 482347e89262Smrg *" -L$dir "*) ;; 482447e89262Smrg *) 482547e89262Smrg deplibs="$deplibs -L$dir" 482647e89262Smrg lib_search_path="$lib_search_path $dir" 482747e89262Smrg ;; 482847e89262Smrg esac 482947e89262Smrg case $host in 483047e89262Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 483147e89262Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 483247e89262Smrg case :$dllsearchpath: in 483347e89262Smrg *":$dir:"*) ;; 483447e89262Smrg ::) dllsearchpath=$dir;; 483547e89262Smrg *) dllsearchpath="$dllsearchpath:$dir";; 483647e89262Smrg esac 483747e89262Smrg case :$dllsearchpath: in 483847e89262Smrg *":$testbindir:"*) ;; 483947e89262Smrg ::) dllsearchpath=$testbindir;; 484047e89262Smrg *) dllsearchpath="$dllsearchpath:$testbindir";; 484147e89262Smrg esac 484247e89262Smrg ;; 484347e89262Smrg esac 484447e89262Smrg continue 484547e89262Smrg ;; 4846bd1da9d7Smrg 484747e89262Smrg -l*) 484847e89262Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 484947e89262Smrg case $host in 485047e89262Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 485147e89262Smrg # These systems don't actually have a C or math library (as such) 485247e89262Smrg continue 485347e89262Smrg ;; 485447e89262Smrg *-*-os2*) 485547e89262Smrg # These systems don't actually have a C library (as such) 485647e89262Smrg test "X$arg" = "X-lc" && continue 485747e89262Smrg ;; 485847e89262Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 485947e89262Smrg # Do not include libc due to us having libc/libc_r. 486047e89262Smrg test "X$arg" = "X-lc" && continue 486147e89262Smrg ;; 486247e89262Smrg *-*-rhapsody* | *-*-darwin1.[012]) 486347e89262Smrg # Rhapsody C and math libraries are in the System framework 486447e89262Smrg deplibs="$deplibs System.ltframework" 486547e89262Smrg continue 486647e89262Smrg ;; 486747e89262Smrg *-*-sco3.2v5* | *-*-sco5v6*) 486847e89262Smrg # Causes problems with __ctype 486947e89262Smrg test "X$arg" = "X-lc" && continue 487047e89262Smrg ;; 487147e89262Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 487247e89262Smrg # Compiler inserts libc in the correct place for threads to work 487347e89262Smrg test "X$arg" = "X-lc" && continue 487447e89262Smrg ;; 487547e89262Smrg esac 487647e89262Smrg elif test "X$arg" = "X-lc_r"; then 487747e89262Smrg case $host in 487847e89262Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 487947e89262Smrg # Do not include libc_r directly, use -pthread flag. 488047e89262Smrg continue 488147e89262Smrg ;; 488247e89262Smrg esac 488347e89262Smrg fi 488447e89262Smrg deplibs="$deplibs $arg" 488547e89262Smrg continue 488647e89262Smrg ;; 4887bd1da9d7Smrg 488847e89262Smrg -module) 488947e89262Smrg module=yes 489047e89262Smrg continue 489147e89262Smrg ;; 4892bd1da9d7Smrg 489347e89262Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 489447e89262Smrg # classes, name mangling, and exception handling. 489547e89262Smrg # Darwin uses the -arch flag to determine output architecture. 489647e89262Smrg -model|-arch|-isysroot) 489747e89262Smrg compiler_flags="$compiler_flags $arg" 489847e89262Smrg func_append compile_command " $arg" 489947e89262Smrg func_append finalize_command " $arg" 490047e89262Smrg prev=xcompiler 490147e89262Smrg continue 490247e89262Smrg ;; 4903bd1da9d7Smrg 490447e89262Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 490547e89262Smrg compiler_flags="$compiler_flags $arg" 490647e89262Smrg func_append compile_command " $arg" 490747e89262Smrg func_append finalize_command " $arg" 490847e89262Smrg case "$new_inherited_linker_flags " in 490947e89262Smrg *" $arg "*) ;; 491047e89262Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; 491147e89262Smrg esac 491247e89262Smrg continue 491347e89262Smrg ;; 4914bd1da9d7Smrg 491547e89262Smrg -multi_module) 491647e89262Smrg single_module="${wl}-multi_module" 491747e89262Smrg continue 491847e89262Smrg ;; 4919bd1da9d7Smrg 492047e89262Smrg -no-fast-install) 492147e89262Smrg fast_install=no 492247e89262Smrg continue 492347e89262Smrg ;; 4924bd1da9d7Smrg 492547e89262Smrg -no-install) 492647e89262Smrg case $host in 492747e89262Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 492847e89262Smrg # The PATH hackery in wrapper scripts is required on Windows 492947e89262Smrg # and Darwin in order for the loader to find any dlls it needs. 493047e89262Smrg func_warning "\`-no-install' is ignored for $host" 493147e89262Smrg func_warning "assuming \`-no-fast-install' instead" 493247e89262Smrg fast_install=no 493347e89262Smrg ;; 493447e89262Smrg *) no_install=yes ;; 493547e89262Smrg esac 493647e89262Smrg continue 493747e89262Smrg ;; 4938bd1da9d7Smrg 493947e89262Smrg -no-undefined) 494047e89262Smrg allow_undefined=no 494147e89262Smrg continue 494247e89262Smrg ;; 4943bd1da9d7Smrg 494447e89262Smrg -objectlist) 494547e89262Smrg prev=objectlist 494647e89262Smrg continue 494747e89262Smrg ;; 4948bd1da9d7Smrg 494947e89262Smrg -o) prev=output ;; 4950bd1da9d7Smrg 495147e89262Smrg -precious-files-regex) 495247e89262Smrg prev=precious_regex 495347e89262Smrg continue 495447e89262Smrg ;; 4955bd1da9d7Smrg 495647e89262Smrg -release) 495747e89262Smrg prev=release 495847e89262Smrg continue 495947e89262Smrg ;; 4960bd1da9d7Smrg 496147e89262Smrg -rpath) 496247e89262Smrg prev=rpath 496347e89262Smrg continue 496447e89262Smrg ;; 4965bd1da9d7Smrg 496647e89262Smrg -R) 496747e89262Smrg prev=xrpath 496847e89262Smrg continue 496947e89262Smrg ;; 4970bd1da9d7Smrg 497147e89262Smrg -R*) 497247e89262Smrg func_stripname '-R' '' "$arg" 497347e89262Smrg dir=$func_stripname_result 497447e89262Smrg # We need an absolute path. 497547e89262Smrg case $dir in 497647e89262Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 497747e89262Smrg *) 497847e89262Smrg func_fatal_error "only absolute run-paths are allowed" 497947e89262Smrg ;; 498047e89262Smrg esac 498147e89262Smrg case "$xrpath " in 498247e89262Smrg *" $dir "*) ;; 498347e89262Smrg *) xrpath="$xrpath $dir" ;; 498447e89262Smrg esac 498547e89262Smrg continue 498647e89262Smrg ;; 4987bd1da9d7Smrg 498847e89262Smrg -shared) 498947e89262Smrg # The effects of -shared are defined in a previous loop. 499047e89262Smrg continue 499147e89262Smrg ;; 4992bd1da9d7Smrg 499347e89262Smrg -shrext) 499447e89262Smrg prev=shrext 499547e89262Smrg continue 499647e89262Smrg ;; 4997bd1da9d7Smrg 499847e89262Smrg -static | -static-libtool-libs) 499947e89262Smrg # The effects of -static are defined in a previous loop. 500047e89262Smrg # We used to do the same as -all-static on platforms that 500147e89262Smrg # didn't have a PIC flag, but the assumption that the effects 500247e89262Smrg # would be equivalent was wrong. It would break on at least 500347e89262Smrg # Digital Unix and AIX. 500447e89262Smrg continue 500547e89262Smrg ;; 5006bd1da9d7Smrg 500747e89262Smrg -thread-safe) 500847e89262Smrg thread_safe=yes 500947e89262Smrg continue 501047e89262Smrg ;; 5011bd1da9d7Smrg 501247e89262Smrg -version-info) 501347e89262Smrg prev=vinfo 501447e89262Smrg continue 501547e89262Smrg ;; 5016bd1da9d7Smrg 501747e89262Smrg -version-number) 501847e89262Smrg prev=vinfo 501947e89262Smrg vinfo_number=yes 502047e89262Smrg continue 502147e89262Smrg ;; 5022bd1da9d7Smrg 502347e89262Smrg -weak) 502447e89262Smrg prev=weak 502547e89262Smrg continue 502647e89262Smrg ;; 5027bd1da9d7Smrg 502847e89262Smrg -Wc,*) 502947e89262Smrg func_stripname '-Wc,' '' "$arg" 503047e89262Smrg args=$func_stripname_result 503147e89262Smrg arg= 503247e89262Smrg save_ifs="$IFS"; IFS=',' 503347e89262Smrg for flag in $args; do 503447e89262Smrg IFS="$save_ifs" 503547e89262Smrg func_quote_for_eval "$flag" 503647e89262Smrg arg="$arg $func_quote_for_eval_result" 503747e89262Smrg compiler_flags="$compiler_flags $func_quote_for_eval_result" 503847e89262Smrg done 503947e89262Smrg IFS="$save_ifs" 504047e89262Smrg func_stripname ' ' '' "$arg" 504147e89262Smrg arg=$func_stripname_result 504247e89262Smrg ;; 5043bd1da9d7Smrg 504447e89262Smrg -Wl,*) 504547e89262Smrg func_stripname '-Wl,' '' "$arg" 504647e89262Smrg args=$func_stripname_result 504747e89262Smrg arg= 504847e89262Smrg save_ifs="$IFS"; IFS=',' 504947e89262Smrg for flag in $args; do 505047e89262Smrg IFS="$save_ifs" 505147e89262Smrg func_quote_for_eval "$flag" 505247e89262Smrg arg="$arg $wl$func_quote_for_eval_result" 505347e89262Smrg compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" 505447e89262Smrg linker_flags="$linker_flags $func_quote_for_eval_result" 505547e89262Smrg done 505647e89262Smrg IFS="$save_ifs" 505747e89262Smrg func_stripname ' ' '' "$arg" 505847e89262Smrg arg=$func_stripname_result 505947e89262Smrg ;; 5060bd1da9d7Smrg 506147e89262Smrg -Xcompiler) 506247e89262Smrg prev=xcompiler 506347e89262Smrg continue 506447e89262Smrg ;; 5065bd1da9d7Smrg 506647e89262Smrg -Xlinker) 506747e89262Smrg prev=xlinker 506847e89262Smrg continue 506947e89262Smrg ;; 5070bd1da9d7Smrg 507147e89262Smrg -XCClinker) 507247e89262Smrg prev=xcclinker 507347e89262Smrg continue 507447e89262Smrg ;; 5075bd1da9d7Smrg 507647e89262Smrg # -msg_* for osf cc 507747e89262Smrg -msg_*) 507847e89262Smrg func_quote_for_eval "$arg" 507947e89262Smrg arg="$func_quote_for_eval_result" 508047e89262Smrg ;; 5081bd1da9d7Smrg 508247e89262Smrg # Flags to be passed through unchanged, with rationale: 508347e89262Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 508447e89262Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 508547e89262Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 508647e89262Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 508747e89262Smrg # -q* compiler args for the IBM compiler 508847e89262Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 508947e89262Smrg # -F/path path to uninstalled frameworks, gcc on darwin 509047e89262Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 509147e89262Smrg # @file GCC response files 509247e89262Smrg # -tp=* Portland pgcc target processor selection 509347e89262Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 509447e89262Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*) 509547e89262Smrg func_quote_for_eval "$arg" 509647e89262Smrg arg="$func_quote_for_eval_result" 509747e89262Smrg func_append compile_command " $arg" 509847e89262Smrg func_append finalize_command " $arg" 509947e89262Smrg compiler_flags="$compiler_flags $arg" 510047e89262Smrg continue 510147e89262Smrg ;; 5102bd1da9d7Smrg 510347e89262Smrg # Some other compiler flag. 510447e89262Smrg -* | +*) 510547e89262Smrg func_quote_for_eval "$arg" 510647e89262Smrg arg="$func_quote_for_eval_result" 510747e89262Smrg ;; 5108bd1da9d7Smrg 510947e89262Smrg *.$objext) 511047e89262Smrg # A standard object. 511147e89262Smrg objs="$objs $arg" 511247e89262Smrg ;; 5113bd1da9d7Smrg 511447e89262Smrg *.lo) 511547e89262Smrg # A libtool-controlled object. 5116bd1da9d7Smrg 511747e89262Smrg # Check to see that this really is a libtool object. 511847e89262Smrg if func_lalib_unsafe_p "$arg"; then 511947e89262Smrg pic_object= 512047e89262Smrg non_pic_object= 5121bd1da9d7Smrg 512247e89262Smrg # Read the .lo file 512347e89262Smrg func_source "$arg" 5124bd1da9d7Smrg 512547e89262Smrg if test -z "$pic_object" || 512647e89262Smrg test -z "$non_pic_object" || 512747e89262Smrg test "$pic_object" = none && 512847e89262Smrg test "$non_pic_object" = none; then 512947e89262Smrg func_fatal_error "cannot find name of object for \`$arg'" 513047e89262Smrg fi 51315bcb6992Smrg 513247e89262Smrg # Extract subdirectory from the argument. 513347e89262Smrg func_dirname "$arg" "/" "" 513447e89262Smrg xdir="$func_dirname_result" 5135bd1da9d7Smrg 513647e89262Smrg if test "$pic_object" != none; then 513747e89262Smrg # Prepend the subdirectory the object is found in. 513847e89262Smrg pic_object="$xdir$pic_object" 5139bd1da9d7Smrg 514047e89262Smrg if test "$prev" = dlfiles; then 514147e89262Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 514247e89262Smrg dlfiles="$dlfiles $pic_object" 514347e89262Smrg prev= 514447e89262Smrg continue 514547e89262Smrg else 514647e89262Smrg # If libtool objects are unsupported, then we need to preload. 514747e89262Smrg prev=dlprefiles 514847e89262Smrg fi 514947e89262Smrg fi 515047e89262Smrg 515147e89262Smrg # CHECK ME: I think I busted this. -Ossama 515247e89262Smrg if test "$prev" = dlprefiles; then 515347e89262Smrg # Preload the old-style object. 515447e89262Smrg dlprefiles="$dlprefiles $pic_object" 515547e89262Smrg prev= 515647e89262Smrg fi 515747e89262Smrg 515847e89262Smrg # A PIC object. 515947e89262Smrg func_append libobjs " $pic_object" 516047e89262Smrg arg="$pic_object" 516147e89262Smrg fi 516247e89262Smrg 516347e89262Smrg # Non-PIC object. 516447e89262Smrg if test "$non_pic_object" != none; then 516547e89262Smrg # Prepend the subdirectory the object is found in. 516647e89262Smrg non_pic_object="$xdir$non_pic_object" 516747e89262Smrg 516847e89262Smrg # A standard non-PIC object 516947e89262Smrg func_append non_pic_objects " $non_pic_object" 517047e89262Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 517147e89262Smrg arg="$non_pic_object" 517247e89262Smrg fi 517347e89262Smrg else 517447e89262Smrg # If the PIC object exists, use it instead. 517547e89262Smrg # $xdir was prepended to $pic_object above. 517647e89262Smrg non_pic_object="$pic_object" 517747e89262Smrg func_append non_pic_objects " $non_pic_object" 517847e89262Smrg fi 517947e89262Smrg else 518047e89262Smrg # Only an error if not doing a dry-run. 518147e89262Smrg if $opt_dry_run; then 518247e89262Smrg # Extract subdirectory from the argument. 518347e89262Smrg func_dirname "$arg" "/" "" 518447e89262Smrg xdir="$func_dirname_result" 518547e89262Smrg 518647e89262Smrg func_lo2o "$arg" 518747e89262Smrg pic_object=$xdir$objdir/$func_lo2o_result 518847e89262Smrg non_pic_object=$xdir$func_lo2o_result 518947e89262Smrg func_append libobjs " $pic_object" 519047e89262Smrg func_append non_pic_objects " $non_pic_object" 519147e89262Smrg else 519247e89262Smrg func_fatal_error "\`$arg' is not a valid libtool object" 519347e89262Smrg fi 519447e89262Smrg fi 519547e89262Smrg ;; 519647e89262Smrg 519747e89262Smrg *.$libext) 519847e89262Smrg # An archive. 519947e89262Smrg deplibs="$deplibs $arg" 520047e89262Smrg old_deplibs="$old_deplibs $arg" 520147e89262Smrg continue 520247e89262Smrg ;; 520347e89262Smrg 520447e89262Smrg *.la) 520547e89262Smrg # A libtool-controlled library. 520647e89262Smrg 520747e89262Smrg if test "$prev" = dlfiles; then 520847e89262Smrg # This library was specified with -dlopen. 520947e89262Smrg dlfiles="$dlfiles $arg" 521047e89262Smrg prev= 521147e89262Smrg elif test "$prev" = dlprefiles; then 521247e89262Smrg # The library was specified with -dlpreopen. 521347e89262Smrg dlprefiles="$dlprefiles $arg" 521447e89262Smrg prev= 521547e89262Smrg else 521647e89262Smrg deplibs="$deplibs $arg" 521747e89262Smrg fi 521847e89262Smrg continue 521947e89262Smrg ;; 522047e89262Smrg 522147e89262Smrg # Some other compiler argument. 522247e89262Smrg *) 522347e89262Smrg # Unknown arguments in both finalize_command and compile_command need 522447e89262Smrg # to be aesthetically quoted because they are evaled later. 522547e89262Smrg func_quote_for_eval "$arg" 522647e89262Smrg arg="$func_quote_for_eval_result" 522747e89262Smrg ;; 522847e89262Smrg esac # arg 522947e89262Smrg 523047e89262Smrg # Now actually substitute the argument into the commands. 523147e89262Smrg if test -n "$arg"; then 523247e89262Smrg func_append compile_command " $arg" 523347e89262Smrg func_append finalize_command " $arg" 523447e89262Smrg fi 523547e89262Smrg done # argument parsing loop 523647e89262Smrg 523747e89262Smrg test -n "$prev" && \ 523847e89262Smrg func_fatal_help "the \`$prevarg' option requires an argument" 523947e89262Smrg 524047e89262Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 524147e89262Smrg eval arg=\"$export_dynamic_flag_spec\" 524247e89262Smrg func_append compile_command " $arg" 524347e89262Smrg func_append finalize_command " $arg" 524447e89262Smrg fi 524547e89262Smrg 524647e89262Smrg oldlibs= 524747e89262Smrg # calculate the name of the file, without its directory 524847e89262Smrg func_basename "$output" 524947e89262Smrg outputname="$func_basename_result" 525047e89262Smrg libobjs_save="$libobjs" 525147e89262Smrg 525247e89262Smrg if test -n "$shlibpath_var"; then 525347e89262Smrg # get the directories listed in $shlibpath_var 525447e89262Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 5255bd1da9d7Smrg else 525647e89262Smrg shlib_search_path= 5257bd1da9d7Smrg fi 525847e89262Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 525947e89262Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 5260bd1da9d7Smrg 526147e89262Smrg func_dirname "$output" "/" "" 526247e89262Smrg output_objdir="$func_dirname_result$objdir" 526347e89262Smrg # Create the object directory. 526447e89262Smrg func_mkdir_p "$output_objdir" 5265bd1da9d7Smrg 526647e89262Smrg # Determine the type of output 526747e89262Smrg case $output in 526847e89262Smrg "") 526947e89262Smrg func_fatal_help "you must specify an output file" 527047e89262Smrg ;; 527147e89262Smrg *.$libext) linkmode=oldlib ;; 527247e89262Smrg *.lo | *.$objext) linkmode=obj ;; 527347e89262Smrg *.la) linkmode=lib ;; 527447e89262Smrg *) linkmode=prog ;; # Anything else should be a program. 527547e89262Smrg esac 527647e89262Smrg 527747e89262Smrg specialdeplibs= 527847e89262Smrg 527947e89262Smrg libs= 528047e89262Smrg # Find all interdependent deplibs by searching for libraries 528147e89262Smrg # that are linked more than once (e.g. -la -lb -la) 528247e89262Smrg for deplib in $deplibs; do 528347e89262Smrg if $opt_duplicate_deps ; then 528447e89262Smrg case "$libs " in 528547e89262Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 528647e89262Smrg esac 528747e89262Smrg fi 528847e89262Smrg libs="$libs $deplib" 528947e89262Smrg done 529047e89262Smrg 529147e89262Smrg if test "$linkmode" = lib; then 529247e89262Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 529347e89262Smrg 529447e89262Smrg # Compute libraries that are listed more than once in $predeps 529547e89262Smrg # $postdeps and mark them as special (i.e., whose duplicates are 529647e89262Smrg # not to be eliminated). 529747e89262Smrg pre_post_deps= 529847e89262Smrg if $opt_duplicate_compiler_generated_deps; then 529947e89262Smrg for pre_post_dep in $predeps $postdeps; do 530047e89262Smrg case "$pre_post_deps " in 530147e89262Smrg *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; 530247e89262Smrg esac 530347e89262Smrg pre_post_deps="$pre_post_deps $pre_post_dep" 530447e89262Smrg done 530547e89262Smrg fi 530647e89262Smrg pre_post_deps= 530747e89262Smrg fi 530847e89262Smrg 530947e89262Smrg deplibs= 531047e89262Smrg newdependency_libs= 531147e89262Smrg newlib_search_path= 531247e89262Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 531347e89262Smrg notinst_deplibs= # not-installed libtool libraries 531447e89262Smrg notinst_path= # paths that contain not-installed libtool libraries 531547e89262Smrg 531647e89262Smrg case $linkmode in 531747e89262Smrg lib) 531847e89262Smrg passes="conv dlpreopen link" 531947e89262Smrg for file in $dlfiles $dlprefiles; do 532047e89262Smrg case $file in 532147e89262Smrg *.la) ;; 532247e89262Smrg *) 532347e89262Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 532447e89262Smrg ;; 532547e89262Smrg esac 532647e89262Smrg done 532747e89262Smrg ;; 532847e89262Smrg prog) 532947e89262Smrg compile_deplibs= 533047e89262Smrg finalize_deplibs= 533147e89262Smrg alldeplibs=no 533247e89262Smrg newdlfiles= 533347e89262Smrg newdlprefiles= 533447e89262Smrg passes="conv scan dlopen dlpreopen link" 533547e89262Smrg ;; 533647e89262Smrg *) passes="conv" 533747e89262Smrg ;; 533847e89262Smrg esac 533947e89262Smrg 534047e89262Smrg for pass in $passes; do 534147e89262Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 534247e89262Smrg # so that -L comes before libs that need it for instance... 534347e89262Smrg if test "$linkmode,$pass" = "lib,link"; then 534447e89262Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 534547e89262Smrg ## order, and fix it there properly 534647e89262Smrg tmp_deplibs= 534747e89262Smrg for deplib in $deplibs; do 534847e89262Smrg tmp_deplibs="$deplib $tmp_deplibs" 534947e89262Smrg done 535047e89262Smrg deplibs="$tmp_deplibs" 535147e89262Smrg fi 535247e89262Smrg 535347e89262Smrg if test "$linkmode,$pass" = "lib,link" || 535447e89262Smrg test "$linkmode,$pass" = "prog,scan"; then 535547e89262Smrg libs="$deplibs" 535647e89262Smrg deplibs= 535747e89262Smrg fi 535847e89262Smrg if test "$linkmode" = prog; then 535947e89262Smrg case $pass in 536047e89262Smrg dlopen) libs="$dlfiles" ;; 536147e89262Smrg dlpreopen) libs="$dlprefiles" ;; 536247e89262Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 536347e89262Smrg esac 536447e89262Smrg fi 536547e89262Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 536647e89262Smrg # Collect and forward deplibs of preopened libtool libs 536747e89262Smrg for lib in $dlprefiles; do 536847e89262Smrg # Ignore non-libtool-libs 536947e89262Smrg dependency_libs= 537047e89262Smrg case $lib in 537147e89262Smrg *.la) func_source "$lib" ;; 537247e89262Smrg esac 537347e89262Smrg 537447e89262Smrg # Collect preopened libtool deplibs, except any this library 537547e89262Smrg # has declared as weak libs 537647e89262Smrg for deplib in $dependency_libs; do 537747e89262Smrg func_basename "$deplib" 537847e89262Smrg deplib_base=$func_basename_result 537947e89262Smrg case " $weak_libs " in 538047e89262Smrg *" $deplib_base "*) ;; 538147e89262Smrg *) deplibs="$deplibs $deplib" ;; 538247e89262Smrg esac 538347e89262Smrg done 538447e89262Smrg done 538547e89262Smrg libs="$dlprefiles" 538647e89262Smrg fi 538747e89262Smrg if test "$pass" = dlopen; then 538847e89262Smrg # Collect dlpreopened libraries 538947e89262Smrg save_deplibs="$deplibs" 539047e89262Smrg deplibs= 539147e89262Smrg fi 539247e89262Smrg 539347e89262Smrg for deplib in $libs; do 539447e89262Smrg lib= 539547e89262Smrg found=no 539647e89262Smrg case $deplib in 539747e89262Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 539847e89262Smrg if test "$linkmode,$pass" = "prog,link"; then 539947e89262Smrg compile_deplibs="$deplib $compile_deplibs" 540047e89262Smrg finalize_deplibs="$deplib $finalize_deplibs" 540147e89262Smrg else 540247e89262Smrg compiler_flags="$compiler_flags $deplib" 540347e89262Smrg if test "$linkmode" = lib ; then 540447e89262Smrg case "$new_inherited_linker_flags " in 540547e89262Smrg *" $deplib "*) ;; 540647e89262Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; 540747e89262Smrg esac 540847e89262Smrg fi 540947e89262Smrg fi 541047e89262Smrg continue 541147e89262Smrg ;; 541247e89262Smrg -l*) 541347e89262Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 541447e89262Smrg func_warning "\`-l' is ignored for archives/objects" 541547e89262Smrg continue 541647e89262Smrg fi 541747e89262Smrg func_stripname '-l' '' "$deplib" 541847e89262Smrg name=$func_stripname_result 541947e89262Smrg if test "$linkmode" = lib; then 542047e89262Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 542147e89262Smrg else 542247e89262Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 542347e89262Smrg fi 542447e89262Smrg for searchdir in $searchdirs; do 542547e89262Smrg for search_ext in .la $std_shrext .so .a; do 542647e89262Smrg # Search the libtool library 542747e89262Smrg lib="$searchdir/lib${name}${search_ext}" 542847e89262Smrg if test -f "$lib"; then 542947e89262Smrg if test "$search_ext" = ".la"; then 543047e89262Smrg found=yes 543147e89262Smrg else 543247e89262Smrg found=no 543347e89262Smrg fi 543447e89262Smrg break 2 543547e89262Smrg fi 543647e89262Smrg done 543747e89262Smrg done 543847e89262Smrg if test "$found" != yes; then 543947e89262Smrg # deplib doesn't seem to be a libtool library 544047e89262Smrg if test "$linkmode,$pass" = "prog,link"; then 544147e89262Smrg compile_deplibs="$deplib $compile_deplibs" 544247e89262Smrg finalize_deplibs="$deplib $finalize_deplibs" 544347e89262Smrg else 544447e89262Smrg deplibs="$deplib $deplibs" 544547e89262Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 544647e89262Smrg fi 544747e89262Smrg continue 544847e89262Smrg else # deplib is a libtool library 544947e89262Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 545047e89262Smrg # We need to do some special things here, and not later. 545147e89262Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 545247e89262Smrg case " $predeps $postdeps " in 545347e89262Smrg *" $deplib "*) 545447e89262Smrg if func_lalib_p "$lib"; then 545547e89262Smrg library_names= 545647e89262Smrg old_library= 545747e89262Smrg func_source "$lib" 545847e89262Smrg for l in $old_library $library_names; do 545947e89262Smrg ll="$l" 546047e89262Smrg done 546147e89262Smrg if test "X$ll" = "X$old_library" ; then # only static version available 546247e89262Smrg found=no 546347e89262Smrg func_dirname "$lib" "" "." 546447e89262Smrg ladir="$func_dirname_result" 546547e89262Smrg lib=$ladir/$old_library 546647e89262Smrg if test "$linkmode,$pass" = "prog,link"; then 546747e89262Smrg compile_deplibs="$deplib $compile_deplibs" 546847e89262Smrg finalize_deplibs="$deplib $finalize_deplibs" 546947e89262Smrg else 547047e89262Smrg deplibs="$deplib $deplibs" 547147e89262Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 547247e89262Smrg fi 547347e89262Smrg continue 547447e89262Smrg fi 547547e89262Smrg fi 547647e89262Smrg ;; 547747e89262Smrg *) ;; 547847e89262Smrg esac 547947e89262Smrg fi 548047e89262Smrg fi 548147e89262Smrg ;; # -l 548247e89262Smrg *.ltframework) 548347e89262Smrg if test "$linkmode,$pass" = "prog,link"; then 548447e89262Smrg compile_deplibs="$deplib $compile_deplibs" 548547e89262Smrg finalize_deplibs="$deplib $finalize_deplibs" 548647e89262Smrg else 548747e89262Smrg deplibs="$deplib $deplibs" 548847e89262Smrg if test "$linkmode" = lib ; then 548947e89262Smrg case "$new_inherited_linker_flags " in 549047e89262Smrg *" $deplib "*) ;; 549147e89262Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; 549247e89262Smrg esac 549347e89262Smrg fi 549447e89262Smrg fi 549547e89262Smrg continue 549647e89262Smrg ;; 549747e89262Smrg -L*) 549847e89262Smrg case $linkmode in 549947e89262Smrg lib) 550047e89262Smrg deplibs="$deplib $deplibs" 550147e89262Smrg test "$pass" = conv && continue 550247e89262Smrg newdependency_libs="$deplib $newdependency_libs" 550347e89262Smrg func_stripname '-L' '' "$deplib" 550447e89262Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 550547e89262Smrg ;; 550647e89262Smrg prog) 550747e89262Smrg if test "$pass" = conv; then 550847e89262Smrg deplibs="$deplib $deplibs" 550947e89262Smrg continue 551047e89262Smrg fi 551147e89262Smrg if test "$pass" = scan; then 551247e89262Smrg deplibs="$deplib $deplibs" 551347e89262Smrg else 551447e89262Smrg compile_deplibs="$deplib $compile_deplibs" 551547e89262Smrg finalize_deplibs="$deplib $finalize_deplibs" 551647e89262Smrg fi 551747e89262Smrg func_stripname '-L' '' "$deplib" 551847e89262Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 551947e89262Smrg ;; 552047e89262Smrg *) 552147e89262Smrg func_warning "\`-L' is ignored for archives/objects" 552247e89262Smrg ;; 552347e89262Smrg esac # linkmode 552447e89262Smrg continue 552547e89262Smrg ;; # -L 552647e89262Smrg -R*) 552747e89262Smrg if test "$pass" = link; then 552847e89262Smrg func_stripname '-R' '' "$deplib" 552947e89262Smrg dir=$func_stripname_result 553047e89262Smrg # Make sure the xrpath contains only unique directories. 553147e89262Smrg case "$xrpath " in 553247e89262Smrg *" $dir "*) ;; 553347e89262Smrg *) xrpath="$xrpath $dir" ;; 553447e89262Smrg esac 553547e89262Smrg fi 553647e89262Smrg deplibs="$deplib $deplibs" 553747e89262Smrg continue 553847e89262Smrg ;; 553947e89262Smrg *.la) lib="$deplib" ;; 554047e89262Smrg *.$libext) 554147e89262Smrg if test "$pass" = conv; then 554247e89262Smrg deplibs="$deplib $deplibs" 554347e89262Smrg continue 554447e89262Smrg fi 554547e89262Smrg case $linkmode in 554647e89262Smrg lib) 554747e89262Smrg # Linking convenience modules into shared libraries is allowed, 554847e89262Smrg # but linking other static libraries is non-portable. 554947e89262Smrg case " $dlpreconveniencelibs " in 555047e89262Smrg *" $deplib "*) ;; 555147e89262Smrg *) 555247e89262Smrg valid_a_lib=no 555347e89262Smrg case $deplibs_check_method in 555447e89262Smrg match_pattern*) 555547e89262Smrg set dummy $deplibs_check_method; shift 555647e89262Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 555747e89262Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 555847e89262Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 555947e89262Smrg valid_a_lib=yes 556047e89262Smrg fi 556147e89262Smrg ;; 556247e89262Smrg pass_all) 556347e89262Smrg valid_a_lib=yes 556447e89262Smrg ;; 556547e89262Smrg esac 556647e89262Smrg if test "$valid_a_lib" != yes; then 556747e89262Smrg echo 556847e89262Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 556947e89262Smrg echo "*** I have the capability to make that library automatically link in when" 557047e89262Smrg echo "*** you link to this library. But I can only do this if you have a" 557147e89262Smrg echo "*** shared version of the library, which you do not appear to have" 557247e89262Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 557347e89262Smrg echo "*** that it is just a static archive that I should not use here." 557447e89262Smrg else 557547e89262Smrg echo 557647e89262Smrg $ECHO "*** Warning: Linking the shared library $output against the" 557747e89262Smrg $ECHO "*** static library $deplib is not portable!" 557847e89262Smrg deplibs="$deplib $deplibs" 557947e89262Smrg fi 558047e89262Smrg ;; 558147e89262Smrg esac 558247e89262Smrg continue 558347e89262Smrg ;; 558447e89262Smrg prog) 558547e89262Smrg if test "$pass" != link; then 558647e89262Smrg deplibs="$deplib $deplibs" 558747e89262Smrg else 558847e89262Smrg compile_deplibs="$deplib $compile_deplibs" 558947e89262Smrg finalize_deplibs="$deplib $finalize_deplibs" 559047e89262Smrg fi 559147e89262Smrg continue 559247e89262Smrg ;; 559347e89262Smrg esac # linkmode 559447e89262Smrg ;; # *.$libext 559547e89262Smrg *.lo | *.$objext) 559647e89262Smrg if test "$pass" = conv; then 559747e89262Smrg deplibs="$deplib $deplibs" 559847e89262Smrg elif test "$linkmode" = prog; then 559947e89262Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 560047e89262Smrg # If there is no dlopen support or we're linking statically, 560147e89262Smrg # we need to preload. 560247e89262Smrg newdlprefiles="$newdlprefiles $deplib" 560347e89262Smrg compile_deplibs="$deplib $compile_deplibs" 560447e89262Smrg finalize_deplibs="$deplib $finalize_deplibs" 560547e89262Smrg else 560647e89262Smrg newdlfiles="$newdlfiles $deplib" 560747e89262Smrg fi 560847e89262Smrg fi 560947e89262Smrg continue 561047e89262Smrg ;; 561147e89262Smrg %DEPLIBS%) 561247e89262Smrg alldeplibs=yes 561347e89262Smrg continue 561447e89262Smrg ;; 561547e89262Smrg esac # case $deplib 561647e89262Smrg 561747e89262Smrg if test "$found" = yes || test -f "$lib"; then : 561847e89262Smrg else 561947e89262Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 562047e89262Smrg fi 562147e89262Smrg 562247e89262Smrg # Check to see that this really is a libtool archive. 562347e89262Smrg func_lalib_unsafe_p "$lib" \ 562447e89262Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 562547e89262Smrg 562647e89262Smrg func_dirname "$lib" "" "." 562747e89262Smrg ladir="$func_dirname_result" 562847e89262Smrg 562947e89262Smrg dlname= 563047e89262Smrg dlopen= 563147e89262Smrg dlpreopen= 563247e89262Smrg libdir= 563347e89262Smrg library_names= 563447e89262Smrg old_library= 563547e89262Smrg inherited_linker_flags= 563647e89262Smrg # If the library was installed with an old release of libtool, 563747e89262Smrg # it will not redefine variables installed, or shouldnotlink 563847e89262Smrg installed=yes 563947e89262Smrg shouldnotlink=no 564047e89262Smrg avoidtemprpath= 564147e89262Smrg 564247e89262Smrg 564347e89262Smrg # Read the .la file 564447e89262Smrg func_source "$lib" 564547e89262Smrg 564647e89262Smrg # Convert "-framework foo" to "foo.ltframework" 564747e89262Smrg if test -n "$inherited_linker_flags"; then 564847e89262Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 564947e89262Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 565047e89262Smrg case " $new_inherited_linker_flags " in 565147e89262Smrg *" $tmp_inherited_linker_flag "*) ;; 565247e89262Smrg *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; 565347e89262Smrg esac 565447e89262Smrg done 565547e89262Smrg fi 565647e89262Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 565747e89262Smrg if test "$linkmode,$pass" = "lib,link" || 565847e89262Smrg test "$linkmode,$pass" = "prog,scan" || 565947e89262Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 566047e89262Smrg test -n "$dlopen" && dlfiles="$dlfiles $dlopen" 566147e89262Smrg test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" 566247e89262Smrg fi 566347e89262Smrg 566447e89262Smrg if test "$pass" = conv; then 566547e89262Smrg # Only check for convenience libraries 566647e89262Smrg deplibs="$lib $deplibs" 566747e89262Smrg if test -z "$libdir"; then 566847e89262Smrg if test -z "$old_library"; then 566947e89262Smrg func_fatal_error "cannot find name of link library for \`$lib'" 567047e89262Smrg fi 567147e89262Smrg # It is a libtool convenience library, so add in its objects. 567247e89262Smrg convenience="$convenience $ladir/$objdir/$old_library" 567347e89262Smrg old_convenience="$old_convenience $ladir/$objdir/$old_library" 567447e89262Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 567547e89262Smrg func_fatal_error "\`$lib' is not a convenience library" 567647e89262Smrg fi 567747e89262Smrg tmp_libs= 567847e89262Smrg for deplib in $dependency_libs; do 567947e89262Smrg deplibs="$deplib $deplibs" 568047e89262Smrg if $opt_duplicate_deps ; then 568147e89262Smrg case "$tmp_libs " in 568247e89262Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 568347e89262Smrg esac 568447e89262Smrg fi 568547e89262Smrg tmp_libs="$tmp_libs $deplib" 568647e89262Smrg done 568747e89262Smrg continue 568847e89262Smrg fi # $pass = conv 568947e89262Smrg 569047e89262Smrg 569147e89262Smrg # Get the name of the library we link against. 569247e89262Smrg linklib= 569347e89262Smrg for l in $old_library $library_names; do 569447e89262Smrg linklib="$l" 569547e89262Smrg done 569647e89262Smrg if test -z "$linklib"; then 569747e89262Smrg func_fatal_error "cannot find name of link library for \`$lib'" 569847e89262Smrg fi 569947e89262Smrg 570047e89262Smrg # This library was specified with -dlopen. 570147e89262Smrg if test "$pass" = dlopen; then 570247e89262Smrg if test -z "$libdir"; then 570347e89262Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 570447e89262Smrg fi 570547e89262Smrg if test -z "$dlname" || 570647e89262Smrg test "$dlopen_support" != yes || 570747e89262Smrg test "$build_libtool_libs" = no; then 570847e89262Smrg # If there is no dlname, no dlopen support or we're linking 570947e89262Smrg # statically, we need to preload. We also need to preload any 571047e89262Smrg # dependent libraries so libltdl's deplib preloader doesn't 571147e89262Smrg # bomb out in the load deplibs phase. 571247e89262Smrg dlprefiles="$dlprefiles $lib $dependency_libs" 571347e89262Smrg else 571447e89262Smrg newdlfiles="$newdlfiles $lib" 571547e89262Smrg fi 571647e89262Smrg continue 571747e89262Smrg fi # $pass = dlopen 571847e89262Smrg 571947e89262Smrg # We need an absolute path. 572047e89262Smrg case $ladir in 572147e89262Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 572247e89262Smrg *) 572347e89262Smrg abs_ladir=`cd "$ladir" && pwd` 572447e89262Smrg if test -z "$abs_ladir"; then 572547e89262Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 572647e89262Smrg func_warning "passing it literally to the linker, although it might fail" 572747e89262Smrg abs_ladir="$ladir" 572847e89262Smrg fi 572947e89262Smrg ;; 573047e89262Smrg esac 573147e89262Smrg func_basename "$lib" 573247e89262Smrg laname="$func_basename_result" 573347e89262Smrg 573447e89262Smrg # Find the relevant object directory and library name. 573547e89262Smrg if test "X$installed" = Xyes; then 573647e89262Smrg if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 573747e89262Smrg func_warning "library \`$lib' was moved." 573847e89262Smrg dir="$ladir" 573947e89262Smrg absdir="$abs_ladir" 574047e89262Smrg libdir="$abs_ladir" 574147e89262Smrg else 574247e89262Smrg dir="$libdir" 574347e89262Smrg absdir="$libdir" 574447e89262Smrg fi 574547e89262Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 574647e89262Smrg else 574747e89262Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 574847e89262Smrg dir="$ladir" 574947e89262Smrg absdir="$abs_ladir" 575047e89262Smrg # Remove this search path later 575147e89262Smrg notinst_path="$notinst_path $abs_ladir" 575247e89262Smrg else 575347e89262Smrg dir="$ladir/$objdir" 575447e89262Smrg absdir="$abs_ladir/$objdir" 575547e89262Smrg # Remove this search path later 575647e89262Smrg notinst_path="$notinst_path $abs_ladir" 575747e89262Smrg fi 575847e89262Smrg fi # $installed = yes 575947e89262Smrg func_stripname 'lib' '.la' "$laname" 576047e89262Smrg name=$func_stripname_result 576147e89262Smrg 576247e89262Smrg # This library was specified with -dlpreopen. 576347e89262Smrg if test "$pass" = dlpreopen; then 576447e89262Smrg if test -z "$libdir" && test "$linkmode" = prog; then 576547e89262Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 576647e89262Smrg fi 576747e89262Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 576847e89262Smrg # are required to link). 576947e89262Smrg if test -n "$old_library"; then 577047e89262Smrg newdlprefiles="$newdlprefiles $dir/$old_library" 577147e89262Smrg # Keep a list of preopened convenience libraries to check 577247e89262Smrg # that they are being used correctly in the link pass. 577347e89262Smrg test -z "$libdir" && \ 577447e89262Smrg dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" 577547e89262Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 577647e89262Smrg elif test -n "$dlname"; then 577747e89262Smrg newdlprefiles="$newdlprefiles $dir/$dlname" 577847e89262Smrg else 577947e89262Smrg newdlprefiles="$newdlprefiles $dir/$linklib" 578047e89262Smrg fi 578147e89262Smrg fi # $pass = dlpreopen 578247e89262Smrg 578347e89262Smrg if test -z "$libdir"; then 578447e89262Smrg # Link the convenience library 578547e89262Smrg if test "$linkmode" = lib; then 578647e89262Smrg deplibs="$dir/$old_library $deplibs" 578747e89262Smrg elif test "$linkmode,$pass" = "prog,link"; then 578847e89262Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 578947e89262Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 579047e89262Smrg else 579147e89262Smrg deplibs="$lib $deplibs" # used for prog,scan pass 579247e89262Smrg fi 579347e89262Smrg continue 579447e89262Smrg fi 579547e89262Smrg 579647e89262Smrg 579747e89262Smrg if test "$linkmode" = prog && test "$pass" != link; then 579847e89262Smrg newlib_search_path="$newlib_search_path $ladir" 579947e89262Smrg deplibs="$lib $deplibs" 580047e89262Smrg 580147e89262Smrg linkalldeplibs=no 580247e89262Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 580347e89262Smrg test "$build_libtool_libs" = no; then 580447e89262Smrg linkalldeplibs=yes 580547e89262Smrg fi 580647e89262Smrg 580747e89262Smrg tmp_libs= 580847e89262Smrg for deplib in $dependency_libs; do 580947e89262Smrg case $deplib in 581047e89262Smrg -L*) func_stripname '-L' '' "$deplib" 581147e89262Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 581247e89262Smrg ;; 581347e89262Smrg esac 581447e89262Smrg # Need to link against all dependency_libs? 581547e89262Smrg if test "$linkalldeplibs" = yes; then 581647e89262Smrg deplibs="$deplib $deplibs" 581747e89262Smrg else 581847e89262Smrg # Need to hardcode shared library paths 581947e89262Smrg # or/and link against static libraries 582047e89262Smrg newdependency_libs="$deplib $newdependency_libs" 582147e89262Smrg fi 582247e89262Smrg if $opt_duplicate_deps ; then 582347e89262Smrg case "$tmp_libs " in 582447e89262Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 582547e89262Smrg esac 582647e89262Smrg fi 582747e89262Smrg tmp_libs="$tmp_libs $deplib" 582847e89262Smrg done # for deplib 582947e89262Smrg continue 583047e89262Smrg fi # $linkmode = prog... 583147e89262Smrg 583247e89262Smrg if test "$linkmode,$pass" = "prog,link"; then 583347e89262Smrg if test -n "$library_names" && 583447e89262Smrg { { test "$prefer_static_libs" = no || 583547e89262Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 583647e89262Smrg test -z "$old_library"; }; then 583747e89262Smrg # We need to hardcode the library path 583847e89262Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 583947e89262Smrg # Make sure the rpath contains only unique directories. 584047e89262Smrg case "$temp_rpath:" in 584147e89262Smrg *"$absdir:"*) ;; 584247e89262Smrg *) temp_rpath="$temp_rpath$absdir:" ;; 584347e89262Smrg esac 584447e89262Smrg fi 584547e89262Smrg 584647e89262Smrg # Hardcode the library path. 584747e89262Smrg # Skip directories that are in the system default run-time 584847e89262Smrg # search path. 584947e89262Smrg case " $sys_lib_dlsearch_path " in 585047e89262Smrg *" $absdir "*) ;; 585147e89262Smrg *) 585247e89262Smrg case "$compile_rpath " in 585347e89262Smrg *" $absdir "*) ;; 585447e89262Smrg *) compile_rpath="$compile_rpath $absdir" 585547e89262Smrg esac 585647e89262Smrg ;; 585747e89262Smrg esac 585847e89262Smrg case " $sys_lib_dlsearch_path " in 585947e89262Smrg *" $libdir "*) ;; 586047e89262Smrg *) 586147e89262Smrg case "$finalize_rpath " in 586247e89262Smrg *" $libdir "*) ;; 586347e89262Smrg *) finalize_rpath="$finalize_rpath $libdir" 586447e89262Smrg esac 586547e89262Smrg ;; 586647e89262Smrg esac 586747e89262Smrg fi # $linkmode,$pass = prog,link... 586847e89262Smrg 586947e89262Smrg if test "$alldeplibs" = yes && 587047e89262Smrg { test "$deplibs_check_method" = pass_all || 587147e89262Smrg { test "$build_libtool_libs" = yes && 587247e89262Smrg test -n "$library_names"; }; }; then 587347e89262Smrg # We only need to search for static libraries 587447e89262Smrg continue 587547e89262Smrg fi 587647e89262Smrg fi 587747e89262Smrg 587847e89262Smrg link_static=no # Whether the deplib will be linked statically 587947e89262Smrg use_static_libs=$prefer_static_libs 588047e89262Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 588147e89262Smrg use_static_libs=no 588247e89262Smrg fi 588347e89262Smrg if test -n "$library_names" && 588447e89262Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 588547e89262Smrg case $host in 588647e89262Smrg *cygwin* | *mingw* | *cegcc*) 588747e89262Smrg # No point in relinking DLLs because paths are not encoded 588847e89262Smrg notinst_deplibs="$notinst_deplibs $lib" 588947e89262Smrg need_relink=no 589047e89262Smrg ;; 589147e89262Smrg *) 589247e89262Smrg if test "$installed" = no; then 589347e89262Smrg notinst_deplibs="$notinst_deplibs $lib" 589447e89262Smrg need_relink=yes 589547e89262Smrg fi 589647e89262Smrg ;; 589747e89262Smrg esac 589847e89262Smrg # This is a shared library 589947e89262Smrg 590047e89262Smrg # Warn about portability, can't link against -module's on some 590147e89262Smrg # systems (darwin). Don't bleat about dlopened modules though! 590247e89262Smrg dlopenmodule="" 590347e89262Smrg for dlpremoduletest in $dlprefiles; do 590447e89262Smrg if test "X$dlpremoduletest" = "X$lib"; then 590547e89262Smrg dlopenmodule="$dlpremoduletest" 590647e89262Smrg break 590747e89262Smrg fi 590847e89262Smrg done 590947e89262Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 591047e89262Smrg echo 591147e89262Smrg if test "$linkmode" = prog; then 591247e89262Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 591347e89262Smrg else 591447e89262Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 591547e89262Smrg fi 591647e89262Smrg $ECHO "*** $linklib is not portable!" 591747e89262Smrg fi 591847e89262Smrg if test "$linkmode" = lib && 591947e89262Smrg test "$hardcode_into_libs" = yes; then 592047e89262Smrg # Hardcode the library path. 592147e89262Smrg # Skip directories that are in the system default run-time 592247e89262Smrg # search path. 592347e89262Smrg case " $sys_lib_dlsearch_path " in 592447e89262Smrg *" $absdir "*) ;; 592547e89262Smrg *) 592647e89262Smrg case "$compile_rpath " in 592747e89262Smrg *" $absdir "*) ;; 592847e89262Smrg *) compile_rpath="$compile_rpath $absdir" 592947e89262Smrg esac 593047e89262Smrg ;; 593147e89262Smrg esac 593247e89262Smrg case " $sys_lib_dlsearch_path " in 593347e89262Smrg *" $libdir "*) ;; 593447e89262Smrg *) 593547e89262Smrg case "$finalize_rpath " in 593647e89262Smrg *" $libdir "*) ;; 593747e89262Smrg *) finalize_rpath="$finalize_rpath $libdir" 593847e89262Smrg esac 593947e89262Smrg ;; 594047e89262Smrg esac 594147e89262Smrg fi 594247e89262Smrg 594347e89262Smrg if test -n "$old_archive_from_expsyms_cmds"; then 594447e89262Smrg # figure out the soname 594547e89262Smrg set dummy $library_names 594647e89262Smrg shift 594747e89262Smrg realname="$1" 594847e89262Smrg shift 594947e89262Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 595047e89262Smrg # use dlname if we got it. it's perfectly good, no? 595147e89262Smrg if test -n "$dlname"; then 595247e89262Smrg soname="$dlname" 595347e89262Smrg elif test -n "$soname_spec"; then 595447e89262Smrg # bleh windows 595547e89262Smrg case $host in 595647e89262Smrg *cygwin* | mingw* | *cegcc*) 595747e89262Smrg func_arith $current - $age 595847e89262Smrg major=$func_arith_result 595947e89262Smrg versuffix="-$major" 596047e89262Smrg ;; 596147e89262Smrg esac 596247e89262Smrg eval soname=\"$soname_spec\" 596347e89262Smrg else 596447e89262Smrg soname="$realname" 596547e89262Smrg fi 596647e89262Smrg 596747e89262Smrg # Make a new name for the extract_expsyms_cmds to use 596847e89262Smrg soroot="$soname" 596947e89262Smrg func_basename "$soroot" 597047e89262Smrg soname="$func_basename_result" 597147e89262Smrg func_stripname 'lib' '.dll' "$soname" 597247e89262Smrg newlib=libimp-$func_stripname_result.a 597347e89262Smrg 597447e89262Smrg # If the library has no export list, then create one now 597547e89262Smrg if test -f "$output_objdir/$soname-def"; then : 597647e89262Smrg else 597747e89262Smrg func_verbose "extracting exported symbol list from \`$soname'" 597847e89262Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 597947e89262Smrg fi 598047e89262Smrg 598147e89262Smrg # Create $newlib 598247e89262Smrg if test -f "$output_objdir/$newlib"; then :; else 598347e89262Smrg func_verbose "generating import library for \`$soname'" 598447e89262Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 598547e89262Smrg fi 598647e89262Smrg # make sure the library variables are pointing to the new library 598747e89262Smrg dir=$output_objdir 598847e89262Smrg linklib=$newlib 598947e89262Smrg fi # test -n "$old_archive_from_expsyms_cmds" 599047e89262Smrg 599147e89262Smrg if test "$linkmode" = prog || test "$mode" != relink; then 599247e89262Smrg add_shlibpath= 599347e89262Smrg add_dir= 599447e89262Smrg add= 599547e89262Smrg lib_linked=yes 599647e89262Smrg case $hardcode_action in 599747e89262Smrg immediate | unsupported) 599847e89262Smrg if test "$hardcode_direct" = no; then 599947e89262Smrg add="$dir/$linklib" 600047e89262Smrg case $host in 600147e89262Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 600247e89262Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 600347e89262Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 600447e89262Smrg *-*-unixware7*) add_dir="-L$dir" ;; 600547e89262Smrg *-*-darwin* ) 600647e89262Smrg # if the lib is a (non-dlopened) module then we can not 600747e89262Smrg # link against it, someone is ignoring the earlier warnings 600847e89262Smrg if /usr/bin/file -L $add 2> /dev/null | 600947e89262Smrg $GREP ": [^:]* bundle" >/dev/null ; then 601047e89262Smrg if test "X$dlopenmodule" != "X$lib"; then 601147e89262Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 601247e89262Smrg if test -z "$old_library" ; then 601347e89262Smrg echo 601447e89262Smrg echo "*** And there doesn't seem to be a static archive available" 601547e89262Smrg echo "*** The link will probably fail, sorry" 601647e89262Smrg else 601747e89262Smrg add="$dir/$old_library" 601847e89262Smrg fi 601947e89262Smrg elif test -n "$old_library"; then 602047e89262Smrg add="$dir/$old_library" 602147e89262Smrg fi 602247e89262Smrg fi 602347e89262Smrg esac 602447e89262Smrg elif test "$hardcode_minus_L" = no; then 602547e89262Smrg case $host in 602647e89262Smrg *-*-sunos*) add_shlibpath="$dir" ;; 602747e89262Smrg esac 602847e89262Smrg add_dir="-L$dir" 602947e89262Smrg add="-l$name" 603047e89262Smrg elif test "$hardcode_shlibpath_var" = no; then 603147e89262Smrg add_shlibpath="$dir" 603247e89262Smrg add="-l$name" 603347e89262Smrg else 603447e89262Smrg lib_linked=no 603547e89262Smrg fi 603647e89262Smrg ;; 603747e89262Smrg relink) 603847e89262Smrg if test "$hardcode_direct" = yes && 603947e89262Smrg test "$hardcode_direct_absolute" = no; then 604047e89262Smrg add="$dir/$linklib" 604147e89262Smrg elif test "$hardcode_minus_L" = yes; then 604247e89262Smrg add_dir="-L$dir" 604347e89262Smrg # Try looking first in the location we're being installed to. 604447e89262Smrg if test -n "$inst_prefix_dir"; then 604547e89262Smrg case $libdir in 604647e89262Smrg [\\/]*) 604747e89262Smrg add_dir="$add_dir -L$inst_prefix_dir$libdir" 604847e89262Smrg ;; 604947e89262Smrg esac 605047e89262Smrg fi 605147e89262Smrg add="-l$name" 605247e89262Smrg elif test "$hardcode_shlibpath_var" = yes; then 605347e89262Smrg add_shlibpath="$dir" 605447e89262Smrg add="-l$name" 605547e89262Smrg else 605647e89262Smrg lib_linked=no 605747e89262Smrg fi 605847e89262Smrg ;; 605947e89262Smrg *) lib_linked=no ;; 606047e89262Smrg esac 606147e89262Smrg 606247e89262Smrg if test "$lib_linked" != yes; then 606347e89262Smrg func_fatal_configuration "unsupported hardcode properties" 606447e89262Smrg fi 606547e89262Smrg 606647e89262Smrg if test -n "$add_shlibpath"; then 606747e89262Smrg case :$compile_shlibpath: in 606847e89262Smrg *":$add_shlibpath:"*) ;; 606947e89262Smrg *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; 607047e89262Smrg esac 607147e89262Smrg fi 607247e89262Smrg if test "$linkmode" = prog; then 607347e89262Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 607447e89262Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 607547e89262Smrg else 607647e89262Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 607747e89262Smrg test -n "$add" && deplibs="$add $deplibs" 607847e89262Smrg if test "$hardcode_direct" != yes && 607947e89262Smrg test "$hardcode_minus_L" != yes && 608047e89262Smrg test "$hardcode_shlibpath_var" = yes; then 608147e89262Smrg case :$finalize_shlibpath: in 608247e89262Smrg *":$libdir:"*) ;; 608347e89262Smrg *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; 608447e89262Smrg esac 608547e89262Smrg fi 608647e89262Smrg fi 608747e89262Smrg fi 608847e89262Smrg 608947e89262Smrg if test "$linkmode" = prog || test "$mode" = relink; then 609047e89262Smrg add_shlibpath= 609147e89262Smrg add_dir= 609247e89262Smrg add= 609347e89262Smrg # Finalize command for both is simple: just hardcode it. 609447e89262Smrg if test "$hardcode_direct" = yes && 609547e89262Smrg test "$hardcode_direct_absolute" = no; then 609647e89262Smrg add="$libdir/$linklib" 609747e89262Smrg elif test "$hardcode_minus_L" = yes; then 609847e89262Smrg add_dir="-L$libdir" 609947e89262Smrg add="-l$name" 610047e89262Smrg elif test "$hardcode_shlibpath_var" = yes; then 610147e89262Smrg case :$finalize_shlibpath: in 610247e89262Smrg *":$libdir:"*) ;; 610347e89262Smrg *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; 610447e89262Smrg esac 610547e89262Smrg add="-l$name" 610647e89262Smrg elif test "$hardcode_automatic" = yes; then 610747e89262Smrg if test -n "$inst_prefix_dir" && 610847e89262Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 610947e89262Smrg add="$inst_prefix_dir$libdir/$linklib" 611047e89262Smrg else 611147e89262Smrg add="$libdir/$linklib" 611247e89262Smrg fi 611347e89262Smrg else 611447e89262Smrg # We cannot seem to hardcode it, guess we'll fake it. 611547e89262Smrg add_dir="-L$libdir" 611647e89262Smrg # Try looking first in the location we're being installed to. 611747e89262Smrg if test -n "$inst_prefix_dir"; then 611847e89262Smrg case $libdir in 611947e89262Smrg [\\/]*) 612047e89262Smrg add_dir="$add_dir -L$inst_prefix_dir$libdir" 612147e89262Smrg ;; 612247e89262Smrg esac 612347e89262Smrg fi 612447e89262Smrg add="-l$name" 612547e89262Smrg fi 612647e89262Smrg 612747e89262Smrg if test "$linkmode" = prog; then 612847e89262Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 612947e89262Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 613047e89262Smrg else 613147e89262Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 613247e89262Smrg test -n "$add" && deplibs="$add $deplibs" 613347e89262Smrg fi 613447e89262Smrg fi 613547e89262Smrg elif test "$linkmode" = prog; then 613647e89262Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 613747e89262Smrg # is not unsupported. This is valid on all known static and 613847e89262Smrg # shared platforms. 613947e89262Smrg if test "$hardcode_direct" != unsupported; then 614047e89262Smrg test -n "$old_library" && linklib="$old_library" 614147e89262Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 614247e89262Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 614347e89262Smrg else 614447e89262Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 614547e89262Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 614647e89262Smrg fi 614747e89262Smrg elif test "$build_libtool_libs" = yes; then 614847e89262Smrg # Not a shared library 614947e89262Smrg if test "$deplibs_check_method" != pass_all; then 615047e89262Smrg # We're trying link a shared library against a static one 615147e89262Smrg # but the system doesn't support it. 615247e89262Smrg 615347e89262Smrg # Just print a warning and add the library to dependency_libs so 615447e89262Smrg # that the program can be linked against the static library. 615547e89262Smrg echo 615647e89262Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 615747e89262Smrg echo "*** I have the capability to make that library automatically link in when" 615847e89262Smrg echo "*** you link to this library. But I can only do this if you have a" 615947e89262Smrg echo "*** shared version of the library, which you do not appear to have." 616047e89262Smrg if test "$module" = yes; then 616147e89262Smrg echo "*** But as you try to build a module library, libtool will still create " 616247e89262Smrg echo "*** a static module, that should work as long as the dlopening application" 616347e89262Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 616447e89262Smrg if test -z "$global_symbol_pipe"; then 616547e89262Smrg echo 616647e89262Smrg echo "*** However, this would only work if libtool was able to extract symbol" 616747e89262Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 616847e89262Smrg echo "*** not find such a program. So, this module is probably useless." 616947e89262Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 617047e89262Smrg fi 617147e89262Smrg if test "$build_old_libs" = no; then 617247e89262Smrg build_libtool_libs=module 617347e89262Smrg build_old_libs=yes 617447e89262Smrg else 617547e89262Smrg build_libtool_libs=no 617647e89262Smrg fi 617747e89262Smrg fi 617847e89262Smrg else 617947e89262Smrg deplibs="$dir/$old_library $deplibs" 618047e89262Smrg link_static=yes 618147e89262Smrg fi 618247e89262Smrg fi # link shared/static library? 618347e89262Smrg 618447e89262Smrg if test "$linkmode" = lib; then 618547e89262Smrg if test -n "$dependency_libs" && 618647e89262Smrg { test "$hardcode_into_libs" != yes || 618747e89262Smrg test "$build_old_libs" = yes || 618847e89262Smrg test "$link_static" = yes; }; then 618947e89262Smrg # Extract -R from dependency_libs 619047e89262Smrg temp_deplibs= 619147e89262Smrg for libdir in $dependency_libs; do 619247e89262Smrg case $libdir in 619347e89262Smrg -R*) func_stripname '-R' '' "$libdir" 619447e89262Smrg temp_xrpath=$func_stripname_result 619547e89262Smrg case " $xrpath " in 619647e89262Smrg *" $temp_xrpath "*) ;; 619747e89262Smrg *) xrpath="$xrpath $temp_xrpath";; 619847e89262Smrg esac;; 619947e89262Smrg *) temp_deplibs="$temp_deplibs $libdir";; 620047e89262Smrg esac 620147e89262Smrg done 620247e89262Smrg dependency_libs="$temp_deplibs" 620347e89262Smrg fi 620447e89262Smrg 620547e89262Smrg newlib_search_path="$newlib_search_path $absdir" 620647e89262Smrg # Link against this library 620747e89262Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 620847e89262Smrg # ... and its dependency_libs 620947e89262Smrg tmp_libs= 621047e89262Smrg for deplib in $dependency_libs; do 621147e89262Smrg newdependency_libs="$deplib $newdependency_libs" 621247e89262Smrg if $opt_duplicate_deps ; then 621347e89262Smrg case "$tmp_libs " in 621447e89262Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 621547e89262Smrg esac 621647e89262Smrg fi 621747e89262Smrg tmp_libs="$tmp_libs $deplib" 621847e89262Smrg done 621947e89262Smrg 622047e89262Smrg if test "$link_all_deplibs" != no; then 622147e89262Smrg # Add the search paths of all dependency libraries 622247e89262Smrg for deplib in $dependency_libs; do 622347e89262Smrg path= 622447e89262Smrg case $deplib in 622547e89262Smrg -L*) path="$deplib" ;; 622647e89262Smrg *.la) 622747e89262Smrg func_dirname "$deplib" "" "." 622847e89262Smrg dir="$func_dirname_result" 622947e89262Smrg # We need an absolute path. 623047e89262Smrg case $dir in 623147e89262Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 623247e89262Smrg *) 623347e89262Smrg absdir=`cd "$dir" && pwd` 623447e89262Smrg if test -z "$absdir"; then 623547e89262Smrg func_warning "cannot determine absolute directory name of \`$dir'" 623647e89262Smrg absdir="$dir" 623747e89262Smrg fi 623847e89262Smrg ;; 623947e89262Smrg esac 624047e89262Smrg if $GREP "^installed=no" $deplib > /dev/null; then 624147e89262Smrg case $host in 624247e89262Smrg *-*-darwin*) 624347e89262Smrg depdepl= 624447e89262Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 624547e89262Smrg if test -n "$deplibrary_names" ; then 624647e89262Smrg for tmp in $deplibrary_names ; do 624747e89262Smrg depdepl=$tmp 624847e89262Smrg done 624947e89262Smrg if test -f "$absdir/$objdir/$depdepl" ; then 625047e89262Smrg depdepl="$absdir/$objdir/$depdepl" 625147e89262Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 625247e89262Smrg if test -z "$darwin_install_name"; then 625347e89262Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 625447e89262Smrg fi 625547e89262Smrg compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 625647e89262Smrg linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" 625747e89262Smrg path= 625847e89262Smrg fi 625947e89262Smrg fi 626047e89262Smrg ;; 626147e89262Smrg *) 626247e89262Smrg path="-L$absdir/$objdir" 626347e89262Smrg ;; 626447e89262Smrg esac 626547e89262Smrg else 626647e89262Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 626747e89262Smrg test -z "$libdir" && \ 626847e89262Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 626947e89262Smrg test "$absdir" != "$libdir" && \ 627047e89262Smrg func_warning "\`$deplib' seems to be moved" 627147e89262Smrg 627247e89262Smrg path="-L$absdir" 627347e89262Smrg fi 627447e89262Smrg ;; 627547e89262Smrg esac 627647e89262Smrg case " $deplibs " in 627747e89262Smrg *" $path "*) ;; 627847e89262Smrg *) deplibs="$path $deplibs" ;; 627947e89262Smrg esac 628047e89262Smrg done 628147e89262Smrg fi # link_all_deplibs != no 628247e89262Smrg fi # linkmode = lib 628347e89262Smrg done # for deplib in $libs 628447e89262Smrg if test "$pass" = link; then 628547e89262Smrg if test "$linkmode" = "prog"; then 628647e89262Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 628747e89262Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 628847e89262Smrg else 628947e89262Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 629047e89262Smrg fi 629147e89262Smrg fi 629247e89262Smrg dependency_libs="$newdependency_libs" 629347e89262Smrg if test "$pass" = dlpreopen; then 629447e89262Smrg # Link the dlpreopened libraries before other libraries 629547e89262Smrg for deplib in $save_deplibs; do 629647e89262Smrg deplibs="$deplib $deplibs" 629747e89262Smrg done 629847e89262Smrg fi 629947e89262Smrg if test "$pass" != dlopen; then 630047e89262Smrg if test "$pass" != conv; then 630147e89262Smrg # Make sure lib_search_path contains only unique directories. 630247e89262Smrg lib_search_path= 630347e89262Smrg for dir in $newlib_search_path; do 630447e89262Smrg case "$lib_search_path " in 630547e89262Smrg *" $dir "*) ;; 630647e89262Smrg *) lib_search_path="$lib_search_path $dir" ;; 630747e89262Smrg esac 630847e89262Smrg done 630947e89262Smrg newlib_search_path= 631047e89262Smrg fi 631147e89262Smrg 631247e89262Smrg if test "$linkmode,$pass" != "prog,link"; then 631347e89262Smrg vars="deplibs" 631447e89262Smrg else 631547e89262Smrg vars="compile_deplibs finalize_deplibs" 631647e89262Smrg fi 631747e89262Smrg for var in $vars dependency_libs; do 631847e89262Smrg # Add libraries to $var in reverse order 631947e89262Smrg eval tmp_libs=\"\$$var\" 632047e89262Smrg new_libs= 632147e89262Smrg for deplib in $tmp_libs; do 632247e89262Smrg # FIXME: Pedantically, this is the right thing to do, so 632347e89262Smrg # that some nasty dependency loop isn't accidentally 632447e89262Smrg # broken: 632547e89262Smrg #new_libs="$deplib $new_libs" 632647e89262Smrg # Pragmatically, this seems to cause very few problems in 632747e89262Smrg # practice: 632847e89262Smrg case $deplib in 632947e89262Smrg -L*) new_libs="$deplib $new_libs" ;; 633047e89262Smrg -R*) ;; 633147e89262Smrg *) 633247e89262Smrg # And here is the reason: when a library appears more 633347e89262Smrg # than once as an explicit dependence of a library, or 633447e89262Smrg # is implicitly linked in more than once by the 633547e89262Smrg # compiler, it is considered special, and multiple 633647e89262Smrg # occurrences thereof are not removed. Compare this 633747e89262Smrg # with having the same library being listed as a 633847e89262Smrg # dependency of multiple other libraries: in this case, 633947e89262Smrg # we know (pedantically, we assume) the library does not 634047e89262Smrg # need to be listed more than once, so we keep only the 634147e89262Smrg # last copy. This is not always right, but it is rare 634247e89262Smrg # enough that we require users that really mean to play 634347e89262Smrg # such unportable linking tricks to link the library 634447e89262Smrg # using -Wl,-lname, so that libtool does not consider it 634547e89262Smrg # for duplicate removal. 634647e89262Smrg case " $specialdeplibs " in 634747e89262Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 634847e89262Smrg *) 634947e89262Smrg case " $new_libs " in 635047e89262Smrg *" $deplib "*) ;; 635147e89262Smrg *) new_libs="$deplib $new_libs" ;; 635247e89262Smrg esac 635347e89262Smrg ;; 635447e89262Smrg esac 635547e89262Smrg ;; 635647e89262Smrg esac 635747e89262Smrg done 635847e89262Smrg tmp_libs= 635947e89262Smrg for deplib in $new_libs; do 636047e89262Smrg case $deplib in 636147e89262Smrg -L*) 636247e89262Smrg case " $tmp_libs " in 636347e89262Smrg *" $deplib "*) ;; 636447e89262Smrg *) tmp_libs="$tmp_libs $deplib" ;; 636547e89262Smrg esac 636647e89262Smrg ;; 636747e89262Smrg *) tmp_libs="$tmp_libs $deplib" ;; 636847e89262Smrg esac 636947e89262Smrg done 637047e89262Smrg eval $var=\"$tmp_libs\" 637147e89262Smrg done # for var 637247e89262Smrg fi 637347e89262Smrg # Last step: remove runtime libs from dependency_libs 637447e89262Smrg # (they stay in deplibs) 637547e89262Smrg tmp_libs= 637647e89262Smrg for i in $dependency_libs ; do 637747e89262Smrg case " $predeps $postdeps $compiler_lib_search_path " in 637847e89262Smrg *" $i "*) 637947e89262Smrg i="" 638047e89262Smrg ;; 638147e89262Smrg esac 638247e89262Smrg if test -n "$i" ; then 638347e89262Smrg tmp_libs="$tmp_libs $i" 638447e89262Smrg fi 638547e89262Smrg done 638647e89262Smrg dependency_libs=$tmp_libs 638747e89262Smrg done # for pass 638847e89262Smrg if test "$linkmode" = prog; then 638947e89262Smrg dlfiles="$newdlfiles" 639047e89262Smrg fi 639147e89262Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 639247e89262Smrg dlprefiles="$newdlprefiles" 639347e89262Smrg fi 639447e89262Smrg 639547e89262Smrg case $linkmode in 639647e89262Smrg oldlib) 639747e89262Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 639847e89262Smrg func_warning "\`-dlopen' is ignored for archives" 639947e89262Smrg fi 640047e89262Smrg 640147e89262Smrg case " $deplibs" in 640247e89262Smrg *\ -l* | *\ -L*) 640347e89262Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 640447e89262Smrg esac 640547e89262Smrg 640647e89262Smrg test -n "$rpath" && \ 640747e89262Smrg func_warning "\`-rpath' is ignored for archives" 640847e89262Smrg 640947e89262Smrg test -n "$xrpath" && \ 641047e89262Smrg func_warning "\`-R' is ignored for archives" 641147e89262Smrg 641247e89262Smrg test -n "$vinfo" && \ 641347e89262Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 641447e89262Smrg 641547e89262Smrg test -n "$release" && \ 641647e89262Smrg func_warning "\`-release' is ignored for archives" 641747e89262Smrg 641847e89262Smrg test -n "$export_symbols$export_symbols_regex" && \ 641947e89262Smrg func_warning "\`-export-symbols' is ignored for archives" 642047e89262Smrg 642147e89262Smrg # Now set the variables for building old libraries. 642247e89262Smrg build_libtool_libs=no 642347e89262Smrg oldlibs="$output" 642447e89262Smrg objs="$objs$old_deplibs" 642547e89262Smrg ;; 642647e89262Smrg 642747e89262Smrg lib) 642847e89262Smrg # Make sure we only generate libraries of the form `libNAME.la'. 642947e89262Smrg case $outputname in 643047e89262Smrg lib*) 643147e89262Smrg func_stripname 'lib' '.la' "$outputname" 643247e89262Smrg name=$func_stripname_result 643347e89262Smrg eval shared_ext=\"$shrext_cmds\" 643447e89262Smrg eval libname=\"$libname_spec\" 643547e89262Smrg ;; 643647e89262Smrg *) 643747e89262Smrg test "$module" = no && \ 643847e89262Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 643947e89262Smrg 644047e89262Smrg if test "$need_lib_prefix" != no; then 644147e89262Smrg # Add the "lib" prefix for modules if required 644247e89262Smrg func_stripname '' '.la' "$outputname" 644347e89262Smrg name=$func_stripname_result 644447e89262Smrg eval shared_ext=\"$shrext_cmds\" 644547e89262Smrg eval libname=\"$libname_spec\" 644647e89262Smrg else 644747e89262Smrg func_stripname '' '.la' "$outputname" 644847e89262Smrg libname=$func_stripname_result 644947e89262Smrg fi 645047e89262Smrg ;; 645147e89262Smrg esac 645247e89262Smrg 645347e89262Smrg if test -n "$objs"; then 645447e89262Smrg if test "$deplibs_check_method" != pass_all; then 645547e89262Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 645647e89262Smrg else 645747e89262Smrg echo 645847e89262Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 645947e89262Smrg $ECHO "*** objects $objs is not portable!" 646047e89262Smrg libobjs="$libobjs $objs" 646147e89262Smrg fi 646247e89262Smrg fi 646347e89262Smrg 646447e89262Smrg test "$dlself" != no && \ 646547e89262Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 646647e89262Smrg 646747e89262Smrg set dummy $rpath 646847e89262Smrg shift 646947e89262Smrg test "$#" -gt 1 && \ 647047e89262Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 647147e89262Smrg 647247e89262Smrg install_libdir="$1" 647347e89262Smrg 647447e89262Smrg oldlibs= 647547e89262Smrg if test -z "$rpath"; then 647647e89262Smrg if test "$build_libtool_libs" = yes; then 647747e89262Smrg # Building a libtool convenience library. 647847e89262Smrg # Some compilers have problems with a `.al' extension so 647947e89262Smrg # convenience libraries should have the same extension an 648047e89262Smrg # archive normally would. 648147e89262Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 648247e89262Smrg build_libtool_libs=convenience 648347e89262Smrg build_old_libs=yes 648447e89262Smrg fi 648547e89262Smrg 648647e89262Smrg test -n "$vinfo" && \ 648747e89262Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 648847e89262Smrg 648947e89262Smrg test -n "$release" && \ 649047e89262Smrg func_warning "\`-release' is ignored for convenience libraries" 649147e89262Smrg else 649247e89262Smrg 649347e89262Smrg # Parse the version information argument. 649447e89262Smrg save_ifs="$IFS"; IFS=':' 649547e89262Smrg set dummy $vinfo 0 0 0 649647e89262Smrg shift 649747e89262Smrg IFS="$save_ifs" 649847e89262Smrg 649947e89262Smrg test -n "$7" && \ 650047e89262Smrg func_fatal_help "too many parameters to \`-version-info'" 650147e89262Smrg 650247e89262Smrg # convert absolute version numbers to libtool ages 650347e89262Smrg # this retains compatibility with .la files and attempts 650447e89262Smrg # to make the code below a bit more comprehensible 650547e89262Smrg 650647e89262Smrg case $vinfo_number in 650747e89262Smrg yes) 650847e89262Smrg number_major="$1" 650947e89262Smrg number_minor="$2" 651047e89262Smrg number_revision="$3" 651147e89262Smrg # 651247e89262Smrg # There are really only two kinds -- those that 651347e89262Smrg # use the current revision as the major version 651447e89262Smrg # and those that subtract age and use age as 651547e89262Smrg # a minor version. But, then there is irix 651647e89262Smrg # which has an extra 1 added just for fun 651747e89262Smrg # 651847e89262Smrg case $version_type in 651947e89262Smrg darwin|linux|osf|windows|none) 652047e89262Smrg func_arith $number_major + $number_minor 652147e89262Smrg current=$func_arith_result 652247e89262Smrg age="$number_minor" 652347e89262Smrg revision="$number_revision" 652447e89262Smrg ;; 652547e89262Smrg freebsd-aout|freebsd-elf|qnx|sunos) 652647e89262Smrg current="$number_major" 652747e89262Smrg revision="$number_minor" 652847e89262Smrg age="0" 652947e89262Smrg ;; 653047e89262Smrg irix|nonstopux) 653147e89262Smrg func_arith $number_major + $number_minor 653247e89262Smrg current=$func_arith_result 653347e89262Smrg age="$number_minor" 653447e89262Smrg revision="$number_minor" 653547e89262Smrg lt_irix_increment=no 653647e89262Smrg ;; 653747e89262Smrg esac 653847e89262Smrg ;; 653947e89262Smrg no) 654047e89262Smrg current="$1" 654147e89262Smrg revision="$2" 654247e89262Smrg age="$3" 654347e89262Smrg ;; 654447e89262Smrg esac 654547e89262Smrg 654647e89262Smrg # Check that each of the things are valid numbers. 654747e89262Smrg case $current in 654847e89262Smrg 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]) ;; 654947e89262Smrg *) 655047e89262Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 655147e89262Smrg func_fatal_error "\`$vinfo' is not valid version information" 655247e89262Smrg ;; 655347e89262Smrg esac 655447e89262Smrg 655547e89262Smrg case $revision in 655647e89262Smrg 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]) ;; 655747e89262Smrg *) 655847e89262Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 655947e89262Smrg func_fatal_error "\`$vinfo' is not valid version information" 656047e89262Smrg ;; 656147e89262Smrg esac 656247e89262Smrg 656347e89262Smrg case $age in 656447e89262Smrg 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]) ;; 656547e89262Smrg *) 656647e89262Smrg func_error "AGE \`$age' must be a nonnegative integer" 656747e89262Smrg func_fatal_error "\`$vinfo' is not valid version information" 656847e89262Smrg ;; 656947e89262Smrg esac 657047e89262Smrg 657147e89262Smrg if test "$age" -gt "$current"; then 657247e89262Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 657347e89262Smrg func_fatal_error "\`$vinfo' is not valid version information" 657447e89262Smrg fi 657547e89262Smrg 657647e89262Smrg # Calculate the version variables. 657747e89262Smrg major= 657847e89262Smrg versuffix= 657947e89262Smrg verstring= 658047e89262Smrg case $version_type in 658147e89262Smrg none) ;; 658247e89262Smrg 658347e89262Smrg darwin) 658447e89262Smrg # Like Linux, but with the current version available in 658547e89262Smrg # verstring for coding it into the library header 658647e89262Smrg func_arith $current - $age 658747e89262Smrg major=.$func_arith_result 658847e89262Smrg versuffix="$major.$age.$revision" 658947e89262Smrg # Darwin ld doesn't like 0 for these options... 659047e89262Smrg func_arith $current + 1 659147e89262Smrg minor_current=$func_arith_result 659247e89262Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 659347e89262Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 659447e89262Smrg ;; 659547e89262Smrg 659647e89262Smrg freebsd-aout) 659747e89262Smrg major=".$current" 659847e89262Smrg versuffix=".$current.$revision"; 659947e89262Smrg ;; 660047e89262Smrg 660147e89262Smrg freebsd-elf) 660247e89262Smrg major=".$current" 660347e89262Smrg versuffix=".$current" 660447e89262Smrg ;; 660547e89262Smrg 660647e89262Smrg irix | nonstopux) 660747e89262Smrg if test "X$lt_irix_increment" = "Xno"; then 660847e89262Smrg func_arith $current - $age 660947e89262Smrg else 661047e89262Smrg func_arith $current - $age + 1 661147e89262Smrg fi 661247e89262Smrg major=$func_arith_result 661347e89262Smrg 661447e89262Smrg case $version_type in 661547e89262Smrg nonstopux) verstring_prefix=nonstopux ;; 661647e89262Smrg *) verstring_prefix=sgi ;; 661747e89262Smrg esac 661847e89262Smrg verstring="$verstring_prefix$major.$revision" 661947e89262Smrg 662047e89262Smrg # Add in all the interfaces that we are compatible with. 662147e89262Smrg loop=$revision 662247e89262Smrg while test "$loop" -ne 0; do 662347e89262Smrg func_arith $revision - $loop 662447e89262Smrg iface=$func_arith_result 662547e89262Smrg func_arith $loop - 1 662647e89262Smrg loop=$func_arith_result 662747e89262Smrg verstring="$verstring_prefix$major.$iface:$verstring" 662847e89262Smrg done 662947e89262Smrg 663047e89262Smrg # Before this point, $major must not contain `.'. 663147e89262Smrg major=.$major 663247e89262Smrg versuffix="$major.$revision" 663347e89262Smrg ;; 663447e89262Smrg 663547e89262Smrg linux) 663647e89262Smrg func_arith $current - $age 663747e89262Smrg major=.$func_arith_result 663847e89262Smrg versuffix="$major.$age.$revision" 663947e89262Smrg ;; 664047e89262Smrg 664147e89262Smrg osf) 664247e89262Smrg func_arith $current - $age 664347e89262Smrg major=.$func_arith_result 664447e89262Smrg versuffix=".$current.$age.$revision" 664547e89262Smrg verstring="$current.$age.$revision" 664647e89262Smrg 664747e89262Smrg # Add in all the interfaces that we are compatible with. 664847e89262Smrg loop=$age 664947e89262Smrg while test "$loop" -ne 0; do 665047e89262Smrg func_arith $current - $loop 665147e89262Smrg iface=$func_arith_result 665247e89262Smrg func_arith $loop - 1 665347e89262Smrg loop=$func_arith_result 665447e89262Smrg verstring="$verstring:${iface}.0" 665547e89262Smrg done 665647e89262Smrg 665747e89262Smrg # Make executables depend on our current version. 665847e89262Smrg verstring="$verstring:${current}.0" 665947e89262Smrg ;; 666047e89262Smrg 666147e89262Smrg qnx) 666247e89262Smrg major=".$current" 666347e89262Smrg versuffix=".$current" 666447e89262Smrg ;; 666547e89262Smrg 666647e89262Smrg sunos) 666747e89262Smrg major=".$current" 666847e89262Smrg versuffix=".$current.$revision" 666947e89262Smrg ;; 667047e89262Smrg 667147e89262Smrg windows) 667247e89262Smrg # Use '-' rather than '.', since we only want one 667347e89262Smrg # extension on DOS 8.3 filesystems. 667447e89262Smrg func_arith $current - $age 667547e89262Smrg major=$func_arith_result 667647e89262Smrg versuffix="-$major" 667747e89262Smrg ;; 667847e89262Smrg 667947e89262Smrg *) 668047e89262Smrg func_fatal_configuration "unknown library version type \`$version_type'" 668147e89262Smrg ;; 668247e89262Smrg esac 668347e89262Smrg 668447e89262Smrg # Clear the version info if we defaulted, and they specified a release. 668547e89262Smrg if test -z "$vinfo" && test -n "$release"; then 668647e89262Smrg major= 668747e89262Smrg case $version_type in 668847e89262Smrg darwin) 668947e89262Smrg # we can't check for "0.0" in archive_cmds due to quoting 669047e89262Smrg # problems, so we reset it completely 669147e89262Smrg verstring= 669247e89262Smrg ;; 669347e89262Smrg *) 669447e89262Smrg verstring="0.0" 669547e89262Smrg ;; 669647e89262Smrg esac 669747e89262Smrg if test "$need_version" = no; then 669847e89262Smrg versuffix= 669947e89262Smrg else 670047e89262Smrg versuffix=".0.0" 670147e89262Smrg fi 670247e89262Smrg fi 670347e89262Smrg 670447e89262Smrg # Remove version info from name if versioning should be avoided 670547e89262Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 670647e89262Smrg major= 670747e89262Smrg versuffix= 670847e89262Smrg verstring="" 670947e89262Smrg fi 671047e89262Smrg 671147e89262Smrg # Check to see if the archive will have undefined symbols. 671247e89262Smrg if test "$allow_undefined" = yes; then 671347e89262Smrg if test "$allow_undefined_flag" = unsupported; then 671447e89262Smrg func_warning "undefined symbols not allowed in $host shared libraries" 671547e89262Smrg build_libtool_libs=no 671647e89262Smrg build_old_libs=yes 671747e89262Smrg fi 671847e89262Smrg else 671947e89262Smrg # Don't allow undefined symbols. 672047e89262Smrg allow_undefined_flag="$no_undefined_flag" 672147e89262Smrg fi 672247e89262Smrg 672347e89262Smrg fi 672447e89262Smrg 672547e89262Smrg func_generate_dlsyms "$libname" "$libname" "yes" 672647e89262Smrg libobjs="$libobjs $symfileobj" 672747e89262Smrg test "X$libobjs" = "X " && libobjs= 672847e89262Smrg 672947e89262Smrg if test "$mode" != relink; then 673047e89262Smrg # Remove our outputs, but don't remove object files since they 673147e89262Smrg # may have been created when compiling PIC objects. 673247e89262Smrg removelist= 673347e89262Smrg tempremovelist=`$ECHO "$output_objdir/*"` 673447e89262Smrg for p in $tempremovelist; do 673547e89262Smrg case $p in 673647e89262Smrg *.$objext | *.gcno) 673747e89262Smrg ;; 673847e89262Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 673947e89262Smrg if test "X$precious_files_regex" != "X"; then 674047e89262Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 674147e89262Smrg then 674247e89262Smrg continue 674347e89262Smrg fi 674447e89262Smrg fi 674547e89262Smrg removelist="$removelist $p" 674647e89262Smrg ;; 674747e89262Smrg *) ;; 674847e89262Smrg esac 674947e89262Smrg done 675047e89262Smrg test -n "$removelist" && \ 675147e89262Smrg func_show_eval "${RM}r \$removelist" 675247e89262Smrg fi 675347e89262Smrg 675447e89262Smrg # Now set the variables for building old libraries. 675547e89262Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 675647e89262Smrg oldlibs="$oldlibs $output_objdir/$libname.$libext" 675747e89262Smrg 675847e89262Smrg # Transform .lo files to .o files. 675947e89262Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 676047e89262Smrg fi 676147e89262Smrg 676247e89262Smrg # Eliminate all temporary directories. 676347e89262Smrg #for path in $notinst_path; do 676447e89262Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 676547e89262Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 676647e89262Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 676747e89262Smrg #done 676847e89262Smrg 676947e89262Smrg if test -n "$xrpath"; then 677047e89262Smrg # If the user specified any rpath flags, then add them. 677147e89262Smrg temp_xrpath= 677247e89262Smrg for libdir in $xrpath; do 677347e89262Smrg temp_xrpath="$temp_xrpath -R$libdir" 677447e89262Smrg case "$finalize_rpath " in 677547e89262Smrg *" $libdir "*) ;; 677647e89262Smrg *) finalize_rpath="$finalize_rpath $libdir" ;; 677747e89262Smrg esac 677847e89262Smrg done 677947e89262Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 678047e89262Smrg dependency_libs="$temp_xrpath $dependency_libs" 678147e89262Smrg fi 678247e89262Smrg fi 678347e89262Smrg 678447e89262Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 678547e89262Smrg old_dlfiles="$dlfiles" 678647e89262Smrg dlfiles= 678747e89262Smrg for lib in $old_dlfiles; do 678847e89262Smrg case " $dlprefiles $dlfiles " in 678947e89262Smrg *" $lib "*) ;; 679047e89262Smrg *) dlfiles="$dlfiles $lib" ;; 679147e89262Smrg esac 679247e89262Smrg done 679347e89262Smrg 679447e89262Smrg # Make sure dlprefiles contains only unique files 679547e89262Smrg old_dlprefiles="$dlprefiles" 679647e89262Smrg dlprefiles= 679747e89262Smrg for lib in $old_dlprefiles; do 679847e89262Smrg case "$dlprefiles " in 679947e89262Smrg *" $lib "*) ;; 680047e89262Smrg *) dlprefiles="$dlprefiles $lib" ;; 680147e89262Smrg esac 680247e89262Smrg done 680347e89262Smrg 680447e89262Smrg if test "$build_libtool_libs" = yes; then 680547e89262Smrg if test -n "$rpath"; then 680647e89262Smrg case $host in 680747e89262Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 680847e89262Smrg # these systems don't actually have a c library (as such)! 680947e89262Smrg ;; 681047e89262Smrg *-*-rhapsody* | *-*-darwin1.[012]) 681147e89262Smrg # Rhapsody C library is in the System framework 681247e89262Smrg deplibs="$deplibs System.ltframework" 681347e89262Smrg ;; 681447e89262Smrg *-*-netbsd*) 681547e89262Smrg # Don't link with libc until the a.out ld.so is fixed. 681647e89262Smrg ;; 681747e89262Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 681847e89262Smrg # Do not include libc due to us having libc/libc_r. 681947e89262Smrg ;; 682047e89262Smrg *-*-sco3.2v5* | *-*-sco5v6*) 682147e89262Smrg # Causes problems with __ctype 682247e89262Smrg ;; 682347e89262Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 682447e89262Smrg # Compiler inserts libc in the correct place for threads to work 682547e89262Smrg ;; 682647e89262Smrg *) 682747e89262Smrg # Add libc to deplibs on all other systems if necessary. 682847e89262Smrg if test "$build_libtool_need_lc" = "yes"; then 682947e89262Smrg deplibs="$deplibs -lc" 683047e89262Smrg fi 683147e89262Smrg ;; 683247e89262Smrg esac 683347e89262Smrg fi 683447e89262Smrg 683547e89262Smrg # Transform deplibs into only deplibs that can be linked in shared. 683647e89262Smrg name_save=$name 683747e89262Smrg libname_save=$libname 683847e89262Smrg release_save=$release 683947e89262Smrg versuffix_save=$versuffix 684047e89262Smrg major_save=$major 684147e89262Smrg # I'm not sure if I'm treating the release correctly. I think 684247e89262Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 684347e89262Smrg # add it in twice. Is that correct? 684447e89262Smrg release="" 684547e89262Smrg versuffix="" 684647e89262Smrg major="" 684747e89262Smrg newdeplibs= 684847e89262Smrg droppeddeps=no 684947e89262Smrg case $deplibs_check_method in 685047e89262Smrg pass_all) 685147e89262Smrg # Don't check for shared/static. Everything works. 685247e89262Smrg # This might be a little naive. We might want to check 685347e89262Smrg # whether the library exists or not. But this is on 685447e89262Smrg # osf3 & osf4 and I'm not really sure... Just 685547e89262Smrg # implementing what was already the behavior. 685647e89262Smrg newdeplibs=$deplibs 685747e89262Smrg ;; 685847e89262Smrg test_compile) 685947e89262Smrg # This code stresses the "libraries are programs" paradigm to its 686047e89262Smrg # limits. Maybe even breaks it. We compile a program, linking it 686147e89262Smrg # against the deplibs as a proxy for the library. Then we can check 686247e89262Smrg # whether they linked in statically or dynamically with ldd. 686347e89262Smrg $opt_dry_run || $RM conftest.c 686447e89262Smrg cat > conftest.c <<EOF 686547e89262Smrg int main() { return 0; } 686647e89262SmrgEOF 686747e89262Smrg $opt_dry_run || $RM conftest 686847e89262Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 686947e89262Smrg ldd_output=`ldd conftest` 687047e89262Smrg for i in $deplibs; do 687147e89262Smrg case $i in 687247e89262Smrg -l*) 687347e89262Smrg func_stripname -l '' "$i" 687447e89262Smrg name=$func_stripname_result 687547e89262Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 687647e89262Smrg case " $predeps $postdeps " in 687747e89262Smrg *" $i "*) 687847e89262Smrg newdeplibs="$newdeplibs $i" 687947e89262Smrg i="" 688047e89262Smrg ;; 688147e89262Smrg esac 688247e89262Smrg fi 688347e89262Smrg if test -n "$i" ; then 688447e89262Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 688547e89262Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 688647e89262Smrg set dummy $deplib_matches; shift 688747e89262Smrg deplib_match=$1 688847e89262Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 688947e89262Smrg newdeplibs="$newdeplibs $i" 689047e89262Smrg else 689147e89262Smrg droppeddeps=yes 689247e89262Smrg echo 689347e89262Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 689447e89262Smrg echo "*** I have the capability to make that library automatically link in when" 689547e89262Smrg echo "*** you link to this library. But I can only do this if you have a" 689647e89262Smrg echo "*** shared version of the library, which I believe you do not have" 689747e89262Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 689847e89262Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 689947e89262Smrg fi 690047e89262Smrg fi 690147e89262Smrg ;; 690247e89262Smrg *) 690347e89262Smrg newdeplibs="$newdeplibs $i" 690447e89262Smrg ;; 690547e89262Smrg esac 690647e89262Smrg done 690747e89262Smrg else 690847e89262Smrg # Error occurred in the first compile. Let's try to salvage 690947e89262Smrg # the situation: Compile a separate program for each library. 691047e89262Smrg for i in $deplibs; do 691147e89262Smrg case $i in 691247e89262Smrg -l*) 691347e89262Smrg func_stripname -l '' "$i" 691447e89262Smrg name=$func_stripname_result 691547e89262Smrg $opt_dry_run || $RM conftest 691647e89262Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 691747e89262Smrg ldd_output=`ldd conftest` 691847e89262Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 691947e89262Smrg case " $predeps $postdeps " in 692047e89262Smrg *" $i "*) 692147e89262Smrg newdeplibs="$newdeplibs $i" 692247e89262Smrg i="" 692347e89262Smrg ;; 692447e89262Smrg esac 692547e89262Smrg fi 692647e89262Smrg if test -n "$i" ; then 692747e89262Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 692847e89262Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 692947e89262Smrg set dummy $deplib_matches; shift 693047e89262Smrg deplib_match=$1 693147e89262Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 693247e89262Smrg newdeplibs="$newdeplibs $i" 693347e89262Smrg else 693447e89262Smrg droppeddeps=yes 693547e89262Smrg echo 693647e89262Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 693747e89262Smrg echo "*** I have the capability to make that library automatically link in when" 693847e89262Smrg echo "*** you link to this library. But I can only do this if you have a" 693947e89262Smrg echo "*** shared version of the library, which you do not appear to have" 694047e89262Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 694147e89262Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 694247e89262Smrg fi 694347e89262Smrg fi 694447e89262Smrg else 694547e89262Smrg droppeddeps=yes 694647e89262Smrg echo 694747e89262Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 694847e89262Smrg echo "*** make it link in! You will probably need to install it or some" 694947e89262Smrg echo "*** library that it depends on before this library will be fully" 695047e89262Smrg echo "*** functional. Installing it before continuing would be even better." 695147e89262Smrg fi 695247e89262Smrg ;; 695347e89262Smrg *) 695447e89262Smrg newdeplibs="$newdeplibs $i" 695547e89262Smrg ;; 695647e89262Smrg esac 695747e89262Smrg done 695847e89262Smrg fi 695947e89262Smrg ;; 696047e89262Smrg file_magic*) 696147e89262Smrg set dummy $deplibs_check_method; shift 696247e89262Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 696347e89262Smrg for a_deplib in $deplibs; do 696447e89262Smrg case $a_deplib in 696547e89262Smrg -l*) 696647e89262Smrg func_stripname -l '' "$a_deplib" 696747e89262Smrg name=$func_stripname_result 696847e89262Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 696947e89262Smrg case " $predeps $postdeps " in 697047e89262Smrg *" $a_deplib "*) 697147e89262Smrg newdeplibs="$newdeplibs $a_deplib" 697247e89262Smrg a_deplib="" 697347e89262Smrg ;; 697447e89262Smrg esac 697547e89262Smrg fi 697647e89262Smrg if test -n "$a_deplib" ; then 697747e89262Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 697847e89262Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 697947e89262Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 698047e89262Smrg for potent_lib in $potential_libs; do 698147e89262Smrg # Follow soft links. 698247e89262Smrg if ls -lLd "$potent_lib" 2>/dev/null | 698347e89262Smrg $GREP " -> " >/dev/null; then 698447e89262Smrg continue 698547e89262Smrg fi 698647e89262Smrg # The statement above tries to avoid entering an 698747e89262Smrg # endless loop below, in case of cyclic links. 698847e89262Smrg # We might still enter an endless loop, since a link 698947e89262Smrg # loop can be closed while we follow links, 699047e89262Smrg # but so what? 699147e89262Smrg potlib="$potent_lib" 699247e89262Smrg while test -h "$potlib" 2>/dev/null; do 699347e89262Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 699447e89262Smrg case $potliblink in 699547e89262Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 699647e89262Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 699747e89262Smrg esac 699847e89262Smrg done 699947e89262Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 700047e89262Smrg $SED -e 10q | 700147e89262Smrg $EGREP "$file_magic_regex" > /dev/null; then 700247e89262Smrg newdeplibs="$newdeplibs $a_deplib" 700347e89262Smrg a_deplib="" 700447e89262Smrg break 2 700547e89262Smrg fi 700647e89262Smrg done 700747e89262Smrg done 700847e89262Smrg fi 700947e89262Smrg if test -n "$a_deplib" ; then 701047e89262Smrg droppeddeps=yes 701147e89262Smrg echo 701247e89262Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 701347e89262Smrg echo "*** I have the capability to make that library automatically link in when" 701447e89262Smrg echo "*** you link to this library. But I can only do this if you have a" 701547e89262Smrg echo "*** shared version of the library, which you do not appear to have" 701647e89262Smrg echo "*** because I did check the linker path looking for a file starting" 701747e89262Smrg if test -z "$potlib" ; then 701847e89262Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 701947e89262Smrg else 702047e89262Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 702147e89262Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 702247e89262Smrg fi 702347e89262Smrg fi 702447e89262Smrg ;; 702547e89262Smrg *) 702647e89262Smrg # Add a -L argument. 702747e89262Smrg newdeplibs="$newdeplibs $a_deplib" 702847e89262Smrg ;; 702947e89262Smrg esac 703047e89262Smrg done # Gone through all deplibs. 703147e89262Smrg ;; 703247e89262Smrg match_pattern*) 703347e89262Smrg set dummy $deplibs_check_method; shift 703447e89262Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 703547e89262Smrg for a_deplib in $deplibs; do 703647e89262Smrg case $a_deplib in 703747e89262Smrg -l*) 703847e89262Smrg func_stripname -l '' "$a_deplib" 703947e89262Smrg name=$func_stripname_result 704047e89262Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 704147e89262Smrg case " $predeps $postdeps " in 704247e89262Smrg *" $a_deplib "*) 704347e89262Smrg newdeplibs="$newdeplibs $a_deplib" 704447e89262Smrg a_deplib="" 704547e89262Smrg ;; 704647e89262Smrg esac 704747e89262Smrg fi 704847e89262Smrg if test -n "$a_deplib" ; then 704947e89262Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 705047e89262Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 705147e89262Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 705247e89262Smrg for potent_lib in $potential_libs; do 705347e89262Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 705447e89262Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 705547e89262Smrg $EGREP "$match_pattern_regex" > /dev/null; then 705647e89262Smrg newdeplibs="$newdeplibs $a_deplib" 705747e89262Smrg a_deplib="" 705847e89262Smrg break 2 705947e89262Smrg fi 706047e89262Smrg done 706147e89262Smrg done 706247e89262Smrg fi 706347e89262Smrg if test -n "$a_deplib" ; then 706447e89262Smrg droppeddeps=yes 706547e89262Smrg echo 706647e89262Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 706747e89262Smrg echo "*** I have the capability to make that library automatically link in when" 706847e89262Smrg echo "*** you link to this library. But I can only do this if you have a" 706947e89262Smrg echo "*** shared version of the library, which you do not appear to have" 707047e89262Smrg echo "*** because I did check the linker path looking for a file starting" 707147e89262Smrg if test -z "$potlib" ; then 707247e89262Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 707347e89262Smrg else 707447e89262Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 707547e89262Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 707647e89262Smrg fi 707747e89262Smrg fi 707847e89262Smrg ;; 707947e89262Smrg *) 708047e89262Smrg # Add a -L argument. 708147e89262Smrg newdeplibs="$newdeplibs $a_deplib" 708247e89262Smrg ;; 708347e89262Smrg esac 708447e89262Smrg done # Gone through all deplibs. 708547e89262Smrg ;; 708647e89262Smrg none | unknown | *) 708747e89262Smrg newdeplibs="" 708847e89262Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 708947e89262Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 709047e89262Smrg for i in $predeps $postdeps ; do 709147e89262Smrg # can't use Xsed below, because $i might contain '/' 709247e89262Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 709347e89262Smrg done 709447e89262Smrg fi 709547e89262Smrg case $tmp_deplibs in 709647e89262Smrg *[!\ \ ]*) 709747e89262Smrg echo 709847e89262Smrg if test "X$deplibs_check_method" = "Xnone"; then 709947e89262Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 710047e89262Smrg else 710147e89262Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 710247e89262Smrg fi 710347e89262Smrg echo "*** All declared inter-library dependencies are being dropped." 710447e89262Smrg droppeddeps=yes 710547e89262Smrg ;; 710647e89262Smrg esac 710747e89262Smrg ;; 710847e89262Smrg esac 710947e89262Smrg versuffix=$versuffix_save 711047e89262Smrg major=$major_save 711147e89262Smrg release=$release_save 711247e89262Smrg libname=$libname_save 711347e89262Smrg name=$name_save 711447e89262Smrg 711547e89262Smrg case $host in 711647e89262Smrg *-*-rhapsody* | *-*-darwin1.[012]) 711747e89262Smrg # On Rhapsody replace the C library with the System framework 711847e89262Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 711947e89262Smrg ;; 712047e89262Smrg esac 712147e89262Smrg 712247e89262Smrg if test "$droppeddeps" = yes; then 712347e89262Smrg if test "$module" = yes; then 712447e89262Smrg echo 712547e89262Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 712647e89262Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 712747e89262Smrg echo "*** a static module, that should work as long as the dlopening" 712847e89262Smrg echo "*** application is linked with the -dlopen flag." 712947e89262Smrg if test -z "$global_symbol_pipe"; then 713047e89262Smrg echo 713147e89262Smrg echo "*** However, this would only work if libtool was able to extract symbol" 713247e89262Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 713347e89262Smrg echo "*** not find such a program. So, this module is probably useless." 713447e89262Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 713547e89262Smrg fi 713647e89262Smrg if test "$build_old_libs" = no; then 713747e89262Smrg oldlibs="$output_objdir/$libname.$libext" 713847e89262Smrg build_libtool_libs=module 713947e89262Smrg build_old_libs=yes 714047e89262Smrg else 714147e89262Smrg build_libtool_libs=no 714247e89262Smrg fi 714347e89262Smrg else 714447e89262Smrg echo "*** The inter-library dependencies that have been dropped here will be" 714547e89262Smrg echo "*** automatically added whenever a program is linked with this library" 714647e89262Smrg echo "*** or is declared to -dlopen it." 714747e89262Smrg 714847e89262Smrg if test "$allow_undefined" = no; then 714947e89262Smrg echo 715047e89262Smrg echo "*** Since this library must not contain undefined symbols," 715147e89262Smrg echo "*** because either the platform does not support them or" 715247e89262Smrg echo "*** it was explicitly requested with -no-undefined," 715347e89262Smrg echo "*** libtool will only create a static version of it." 715447e89262Smrg if test "$build_old_libs" = no; then 715547e89262Smrg oldlibs="$output_objdir/$libname.$libext" 715647e89262Smrg build_libtool_libs=module 715747e89262Smrg build_old_libs=yes 715847e89262Smrg else 715947e89262Smrg build_libtool_libs=no 716047e89262Smrg fi 716147e89262Smrg fi 716247e89262Smrg fi 716347e89262Smrg fi 716447e89262Smrg # Done checking deplibs! 716547e89262Smrg deplibs=$newdeplibs 716647e89262Smrg fi 716747e89262Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 716847e89262Smrg case $host in 716947e89262Smrg *-*-darwin*) 717047e89262Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 717147e89262Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 717247e89262Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 717347e89262Smrg ;; 717447e89262Smrg esac 717547e89262Smrg 717647e89262Smrg # move library search paths that coincide with paths to not yet 717747e89262Smrg # installed libraries to the beginning of the library search list 717847e89262Smrg new_libs= 717947e89262Smrg for path in $notinst_path; do 718047e89262Smrg case " $new_libs " in 718147e89262Smrg *" -L$path/$objdir "*) ;; 718247e89262Smrg *) 718347e89262Smrg case " $deplibs " in 718447e89262Smrg *" -L$path/$objdir "*) 718547e89262Smrg new_libs="$new_libs -L$path/$objdir" ;; 718647e89262Smrg esac 718747e89262Smrg ;; 718847e89262Smrg esac 718947e89262Smrg done 719047e89262Smrg for deplib in $deplibs; do 719147e89262Smrg case $deplib in 719247e89262Smrg -L*) 719347e89262Smrg case " $new_libs " in 719447e89262Smrg *" $deplib "*) ;; 719547e89262Smrg *) new_libs="$new_libs $deplib" ;; 719647e89262Smrg esac 719747e89262Smrg ;; 719847e89262Smrg *) new_libs="$new_libs $deplib" ;; 719947e89262Smrg esac 720047e89262Smrg done 720147e89262Smrg deplibs="$new_libs" 720247e89262Smrg 720347e89262Smrg # All the library-specific variables (install_libdir is set above). 720447e89262Smrg library_names= 720547e89262Smrg old_library= 720647e89262Smrg dlname= 720747e89262Smrg 720847e89262Smrg # Test again, we may have decided not to build it any more 720947e89262Smrg if test "$build_libtool_libs" = yes; then 721047e89262Smrg if test "$hardcode_into_libs" = yes; then 721147e89262Smrg # Hardcode the library paths 721247e89262Smrg hardcode_libdirs= 721347e89262Smrg dep_rpath= 721447e89262Smrg rpath="$finalize_rpath" 721547e89262Smrg test "$mode" != relink && rpath="$compile_rpath$rpath" 721647e89262Smrg for libdir in $rpath; do 721747e89262Smrg if test -n "$hardcode_libdir_flag_spec"; then 721847e89262Smrg if test -n "$hardcode_libdir_separator"; then 721947e89262Smrg if test -z "$hardcode_libdirs"; then 722047e89262Smrg hardcode_libdirs="$libdir" 722147e89262Smrg else 722247e89262Smrg # Just accumulate the unique libdirs. 722347e89262Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 722447e89262Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 722547e89262Smrg ;; 722647e89262Smrg *) 722747e89262Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 722847e89262Smrg ;; 722947e89262Smrg esac 723047e89262Smrg fi 723147e89262Smrg else 723247e89262Smrg eval flag=\"$hardcode_libdir_flag_spec\" 723347e89262Smrg dep_rpath="$dep_rpath $flag" 723447e89262Smrg fi 723547e89262Smrg elif test -n "$runpath_var"; then 723647e89262Smrg case "$perm_rpath " in 723747e89262Smrg *" $libdir "*) ;; 723847e89262Smrg *) perm_rpath="$perm_rpath $libdir" ;; 723947e89262Smrg esac 724047e89262Smrg fi 724147e89262Smrg done 724247e89262Smrg # Substitute the hardcoded libdirs into the rpath. 724347e89262Smrg if test -n "$hardcode_libdir_separator" && 724447e89262Smrg test -n "$hardcode_libdirs"; then 724547e89262Smrg libdir="$hardcode_libdirs" 724647e89262Smrg if test -n "$hardcode_libdir_flag_spec_ld"; then 724747e89262Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 724847e89262Smrg else 724947e89262Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec\" 725047e89262Smrg fi 725147e89262Smrg fi 725247e89262Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 725347e89262Smrg # We should set the runpath_var. 725447e89262Smrg rpath= 725547e89262Smrg for dir in $perm_rpath; do 725647e89262Smrg rpath="$rpath$dir:" 725747e89262Smrg done 725847e89262Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 725947e89262Smrg fi 726047e89262Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 726147e89262Smrg fi 7262bd1da9d7Smrg 726347e89262Smrg shlibpath="$finalize_shlibpath" 726447e89262Smrg test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 726547e89262Smrg if test -n "$shlibpath"; then 726647e89262Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 726747e89262Smrg fi 7268bd1da9d7Smrg 726947e89262Smrg # Get the real and link names of the library. 727047e89262Smrg eval shared_ext=\"$shrext_cmds\" 727147e89262Smrg eval library_names=\"$library_names_spec\" 727247e89262Smrg set dummy $library_names 727347e89262Smrg shift 727447e89262Smrg realname="$1" 727547e89262Smrg shift 7276bd1da9d7Smrg 727747e89262Smrg if test -n "$soname_spec"; then 727847e89262Smrg eval soname=\"$soname_spec\" 727947e89262Smrg else 728047e89262Smrg soname="$realname" 728147e89262Smrg fi 728247e89262Smrg if test -z "$dlname"; then 728347e89262Smrg dlname=$soname 728447e89262Smrg fi 7285bd1da9d7Smrg 728647e89262Smrg lib="$output_objdir/$realname" 728747e89262Smrg linknames= 728847e89262Smrg for link 728947e89262Smrg do 729047e89262Smrg linknames="$linknames $link" 729147e89262Smrg done 7292bd1da9d7Smrg 729347e89262Smrg # Use standard objects if they are pic 729447e89262Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 729547e89262Smrg test "X$libobjs" = "X " && libobjs= 7296bd1da9d7Smrg 729747e89262Smrg delfiles= 729847e89262Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 729947e89262Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 730047e89262Smrg export_symbols="$output_objdir/$libname.uexp" 730147e89262Smrg delfiles="$delfiles $export_symbols" 730247e89262Smrg fi 7303bd1da9d7Smrg 730447e89262Smrg orig_export_symbols= 730547e89262Smrg case $host_os in 730647e89262Smrg cygwin* | mingw* | cegcc*) 730747e89262Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 730847e89262Smrg # exporting using user supplied symfile 730947e89262Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 731047e89262Smrg # and it's NOT already a .def file. Must figure out 731147e89262Smrg # which of the given symbols are data symbols and tag 731247e89262Smrg # them as such. So, trigger use of export_symbols_cmds. 731347e89262Smrg # export_symbols gets reassigned inside the "prepare 731447e89262Smrg # the list of exported symbols" if statement, so the 731547e89262Smrg # include_expsyms logic still works. 731647e89262Smrg orig_export_symbols="$export_symbols" 731747e89262Smrg export_symbols= 731847e89262Smrg always_export_symbols=yes 731947e89262Smrg fi 732047e89262Smrg fi 732147e89262Smrg ;; 732247e89262Smrg esac 7323bd1da9d7Smrg 732447e89262Smrg # Prepare the list of exported symbols 732547e89262Smrg if test -z "$export_symbols"; then 732647e89262Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 732747e89262Smrg func_verbose "generating symbol list for \`$libname.la'" 732847e89262Smrg export_symbols="$output_objdir/$libname.exp" 732947e89262Smrg $opt_dry_run || $RM $export_symbols 733047e89262Smrg cmds=$export_symbols_cmds 733147e89262Smrg save_ifs="$IFS"; IFS='~' 733247e89262Smrg for cmd in $cmds; do 733347e89262Smrg IFS="$save_ifs" 733447e89262Smrg eval cmd=\"$cmd\" 733547e89262Smrg func_len " $cmd" 733647e89262Smrg len=$func_len_result 733747e89262Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 733847e89262Smrg func_show_eval "$cmd" 'exit $?' 733947e89262Smrg skipped_export=false 734047e89262Smrg else 734147e89262Smrg # The command line is too long to execute in one step. 734247e89262Smrg func_verbose "using reloadable object file for export list..." 734347e89262Smrg skipped_export=: 734447e89262Smrg # Break out early, otherwise skipped_export may be 734547e89262Smrg # set to false by a later but shorter cmd. 734647e89262Smrg break 734747e89262Smrg fi 734847e89262Smrg done 734947e89262Smrg IFS="$save_ifs" 735047e89262Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 735147e89262Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 735247e89262Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 735347e89262Smrg fi 735447e89262Smrg fi 735547e89262Smrg fi 7356bd1da9d7Smrg 735747e89262Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 735847e89262Smrg tmp_export_symbols="$export_symbols" 735947e89262Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 736047e89262Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 736147e89262Smrg fi 7362bd1da9d7Smrg 736347e89262Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 736447e89262Smrg # The given exports_symbols file has to be filtered, so filter it. 736547e89262Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 736647e89262Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 736747e89262Smrg # 's' commands which not all seds can handle. GNU sed should be fine 736847e89262Smrg # though. Also, the filter scales superlinearly with the number of 736947e89262Smrg # global variables. join(1) would be nice here, but unfortunately 737047e89262Smrg # isn't a blessed tool. 737147e89262Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 737247e89262Smrg delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" 737347e89262Smrg export_symbols=$output_objdir/$libname.def 737447e89262Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 7375bd1da9d7Smrg fi 7376bd1da9d7Smrg 737747e89262Smrg tmp_deplibs= 737847e89262Smrg for test_deplib in $deplibs; do 737947e89262Smrg case " $convenience " in 738047e89262Smrg *" $test_deplib "*) ;; 738147e89262Smrg *) 738247e89262Smrg tmp_deplibs="$tmp_deplibs $test_deplib" 738347e89262Smrg ;; 738447e89262Smrg esac 738547e89262Smrg done 738647e89262Smrg deplibs="$tmp_deplibs" 7387bd1da9d7Smrg 738847e89262Smrg if test -n "$convenience"; then 738947e89262Smrg if test -n "$whole_archive_flag_spec" && 739047e89262Smrg test "$compiler_needs_object" = yes && 739147e89262Smrg test -z "$libobjs"; then 739247e89262Smrg # extract the archives, so we have objects to list. 739347e89262Smrg # TODO: could optimize this to just extract one archive. 739447e89262Smrg whole_archive_flag_spec= 739547e89262Smrg fi 739647e89262Smrg if test -n "$whole_archive_flag_spec"; then 739747e89262Smrg save_libobjs=$libobjs 739847e89262Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 739947e89262Smrg test "X$libobjs" = "X " && libobjs= 740047e89262Smrg else 740147e89262Smrg gentop="$output_objdir/${outputname}x" 740247e89262Smrg generated="$generated $gentop" 7403bd1da9d7Smrg 740447e89262Smrg func_extract_archives $gentop $convenience 740547e89262Smrg libobjs="$libobjs $func_extract_archives_result" 740647e89262Smrg test "X$libobjs" = "X " && libobjs= 740747e89262Smrg fi 740847e89262Smrg fi 7409bd1da9d7Smrg 741047e89262Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 741147e89262Smrg eval flag=\"$thread_safe_flag_spec\" 741247e89262Smrg linker_flags="$linker_flags $flag" 741347e89262Smrg fi 7414bd1da9d7Smrg 741547e89262Smrg # Make a backup of the uninstalled library when relinking 741647e89262Smrg if test "$mode" = relink; then 741747e89262Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 7418bd1da9d7Smrg fi 7419bd1da9d7Smrg 742047e89262Smrg # Do each of the archive commands. 742147e89262Smrg if test "$module" = yes && test -n "$module_cmds" ; then 742247e89262Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 742347e89262Smrg eval test_cmds=\"$module_expsym_cmds\" 742447e89262Smrg cmds=$module_expsym_cmds 742547e89262Smrg else 742647e89262Smrg eval test_cmds=\"$module_cmds\" 742747e89262Smrg cmds=$module_cmds 742847e89262Smrg fi 742947e89262Smrg else 743047e89262Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 743147e89262Smrg eval test_cmds=\"$archive_expsym_cmds\" 743247e89262Smrg cmds=$archive_expsym_cmds 743347e89262Smrg else 743447e89262Smrg eval test_cmds=\"$archive_cmds\" 743547e89262Smrg cmds=$archive_cmds 743647e89262Smrg fi 7437bd1da9d7Smrg fi 7438bd1da9d7Smrg 743947e89262Smrg if test "X$skipped_export" != "X:" && 744047e89262Smrg func_len " $test_cmds" && 744147e89262Smrg len=$func_len_result && 744247e89262Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 744347e89262Smrg : 744447e89262Smrg else 744547e89262Smrg # The command line is too long to link in one step, link piecewise 744647e89262Smrg # or, if using GNU ld and skipped_export is not :, use a linker 744747e89262Smrg # script. 7448bd1da9d7Smrg 744947e89262Smrg # Save the value of $output and $libobjs because we want to 745047e89262Smrg # use them later. If we have whole_archive_flag_spec, we 745147e89262Smrg # want to use save_libobjs as it was before 745247e89262Smrg # whole_archive_flag_spec was expanded, because we can't 745347e89262Smrg # assume the linker understands whole_archive_flag_spec. 745447e89262Smrg # This may have to be revisited, in case too many 745547e89262Smrg # convenience libraries get linked in and end up exceeding 745647e89262Smrg # the spec. 745747e89262Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 745847e89262Smrg save_libobjs=$libobjs 745947e89262Smrg fi 746047e89262Smrg save_output=$output 746147e89262Smrg func_basename "$output" 746247e89262Smrg output_la=$func_basename_result 7463bd1da9d7Smrg 746447e89262Smrg # Clear the reloadable object creation command queue and 746547e89262Smrg # initialize k to one. 746647e89262Smrg test_cmds= 746747e89262Smrg concat_cmds= 746847e89262Smrg objlist= 746947e89262Smrg last_robj= 747047e89262Smrg k=1 7471bd1da9d7Smrg 747247e89262Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 747347e89262Smrg output=${output_objdir}/${output_la}.lnkscript 747447e89262Smrg func_verbose "creating GNU ld script: $output" 747547e89262Smrg echo 'INPUT (' > $output 747647e89262Smrg for obj in $save_libobjs 747747e89262Smrg do 747847e89262Smrg $ECHO "$obj" >> $output 747947e89262Smrg done 748047e89262Smrg echo ')' >> $output 748147e89262Smrg delfiles="$delfiles $output" 748247e89262Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 748347e89262Smrg output=${output_objdir}/${output_la}.lnk 748447e89262Smrg func_verbose "creating linker input file list: $output" 748547e89262Smrg : > $output 748647e89262Smrg set x $save_libobjs 748747e89262Smrg shift 748847e89262Smrg firstobj= 748947e89262Smrg if test "$compiler_needs_object" = yes; then 749047e89262Smrg firstobj="$1 " 749147e89262Smrg shift 749247e89262Smrg fi 749347e89262Smrg for obj 749447e89262Smrg do 749547e89262Smrg $ECHO "$obj" >> $output 749647e89262Smrg done 749747e89262Smrg delfiles="$delfiles $output" 749847e89262Smrg output=$firstobj\"$file_list_spec$output\" 749947e89262Smrg else 750047e89262Smrg if test -n "$save_libobjs"; then 750147e89262Smrg func_verbose "creating reloadable object files..." 750247e89262Smrg output=$output_objdir/$output_la-${k}.$objext 750347e89262Smrg eval test_cmds=\"$reload_cmds\" 750447e89262Smrg func_len " $test_cmds" 750547e89262Smrg len0=$func_len_result 750647e89262Smrg len=$len0 750747e89262Smrg 750847e89262Smrg # Loop over the list of objects to be linked. 750947e89262Smrg for obj in $save_libobjs 751047e89262Smrg do 751147e89262Smrg func_len " $obj" 751247e89262Smrg func_arith $len + $func_len_result 751347e89262Smrg len=$func_arith_result 751447e89262Smrg if test "X$objlist" = X || 751547e89262Smrg test "$len" -lt "$max_cmd_len"; then 751647e89262Smrg func_append objlist " $obj" 751747e89262Smrg else 751847e89262Smrg # The command $test_cmds is almost too long, add a 751947e89262Smrg # command to the queue. 752047e89262Smrg if test "$k" -eq 1 ; then 752147e89262Smrg # The first file doesn't have a previous command to add. 752247e89262Smrg reload_objs=$objlist 752347e89262Smrg eval concat_cmds=\"$reload_cmds\" 752447e89262Smrg else 752547e89262Smrg # All subsequent reloadable object files will link in 752647e89262Smrg # the last one created. 752747e89262Smrg reload_objs="$objlist $last_robj" 752847e89262Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 752947e89262Smrg fi 753047e89262Smrg last_robj=$output_objdir/$output_la-${k}.$objext 753147e89262Smrg func_arith $k + 1 753247e89262Smrg k=$func_arith_result 753347e89262Smrg output=$output_objdir/$output_la-${k}.$objext 753447e89262Smrg objlist=" $obj" 753547e89262Smrg func_len " $last_robj" 753647e89262Smrg func_arith $len0 + $func_len_result 753747e89262Smrg len=$func_arith_result 753847e89262Smrg fi 753947e89262Smrg done 754047e89262Smrg # Handle the remaining objects by creating one last 754147e89262Smrg # reloadable object file. All subsequent reloadable object 754247e89262Smrg # files will link in the last one created. 754347e89262Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 754447e89262Smrg reload_objs="$objlist $last_robj" 754547e89262Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 754647e89262Smrg if test -n "$last_robj"; then 754747e89262Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 754847e89262Smrg fi 754947e89262Smrg delfiles="$delfiles $output" 755047e89262Smrg 755147e89262Smrg else 755247e89262Smrg output= 755347e89262Smrg fi 7554bd1da9d7Smrg 755547e89262Smrg if ${skipped_export-false}; then 755647e89262Smrg func_verbose "generating symbol list for \`$libname.la'" 755747e89262Smrg export_symbols="$output_objdir/$libname.exp" 755847e89262Smrg $opt_dry_run || $RM $export_symbols 755947e89262Smrg libobjs=$output 756047e89262Smrg # Append the command to create the export file. 756147e89262Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 756247e89262Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 756347e89262Smrg if test -n "$last_robj"; then 756447e89262Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 756547e89262Smrg fi 756647e89262Smrg fi 7567bd1da9d7Smrg 756847e89262Smrg test -n "$save_libobjs" && 756947e89262Smrg func_verbose "creating a temporary reloadable object file: $output" 7570bd1da9d7Smrg 757147e89262Smrg # Loop through the commands generated above and execute them. 757247e89262Smrg save_ifs="$IFS"; IFS='~' 757347e89262Smrg for cmd in $concat_cmds; do 757447e89262Smrg IFS="$save_ifs" 757547e89262Smrg $opt_silent || { 757647e89262Smrg func_quote_for_expand "$cmd" 757747e89262Smrg eval "func_echo $func_quote_for_expand_result" 757847e89262Smrg } 757947e89262Smrg $opt_dry_run || eval "$cmd" || { 758047e89262Smrg lt_exit=$? 758147e89262Smrg 758247e89262Smrg # Restore the uninstalled library and exit 758347e89262Smrg if test "$mode" = relink; then 758447e89262Smrg ( cd "$output_objdir" && \ 758547e89262Smrg $RM "${realname}T" && \ 758647e89262Smrg $MV "${realname}U" "$realname" ) 758747e89262Smrg fi 7588bd1da9d7Smrg 758947e89262Smrg exit $lt_exit 759047e89262Smrg } 759147e89262Smrg done 759247e89262Smrg IFS="$save_ifs" 7593bd1da9d7Smrg 759447e89262Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 759547e89262Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 759647e89262Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 7597bd1da9d7Smrg fi 7598bd1da9d7Smrg fi 7599bd1da9d7Smrg 760047e89262Smrg if ${skipped_export-false}; then 760147e89262Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 760247e89262Smrg tmp_export_symbols="$export_symbols" 760347e89262Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 760447e89262Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 760547e89262Smrg fi 7606bd1da9d7Smrg 760747e89262Smrg if test -n "$orig_export_symbols"; then 760847e89262Smrg # The given exports_symbols file has to be filtered, so filter it. 760947e89262Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 761047e89262Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 761147e89262Smrg # 's' commands which not all seds can handle. GNU sed should be fine 761247e89262Smrg # though. Also, the filter scales superlinearly with the number of 761347e89262Smrg # global variables. join(1) would be nice here, but unfortunately 761447e89262Smrg # isn't a blessed tool. 761547e89262Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 761647e89262Smrg delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" 761747e89262Smrg export_symbols=$output_objdir/$libname.def 761847e89262Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 761947e89262Smrg fi 762047e89262Smrg fi 7621bd1da9d7Smrg 762247e89262Smrg libobjs=$output 762347e89262Smrg # Restore the value of output. 762447e89262Smrg output=$save_output 7625bd1da9d7Smrg 762647e89262Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 762747e89262Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 762847e89262Smrg test "X$libobjs" = "X " && libobjs= 762947e89262Smrg fi 763047e89262Smrg # Expand the library linking commands again to reset the 763147e89262Smrg # value of $libobjs for piecewise linking. 763247e89262Smrg 763347e89262Smrg # Do each of the archive commands. 763447e89262Smrg if test "$module" = yes && test -n "$module_cmds" ; then 763547e89262Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 763647e89262Smrg cmds=$module_expsym_cmds 7637bd1da9d7Smrg else 763847e89262Smrg cmds=$module_cmds 7639bd1da9d7Smrg fi 7640bd1da9d7Smrg else 764147e89262Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 764247e89262Smrg cmds=$archive_expsym_cmds 764347e89262Smrg else 764447e89262Smrg cmds=$archive_cmds 764547e89262Smrg fi 7646bd1da9d7Smrg fi 7647bd1da9d7Smrg fi 7648bd1da9d7Smrg 764947e89262Smrg if test -n "$delfiles"; then 765047e89262Smrg # Append the command to remove temporary files to $cmds. 765147e89262Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 765247e89262Smrg fi 7653bd1da9d7Smrg 765447e89262Smrg # Add any objects from preloaded convenience libraries 765547e89262Smrg if test -n "$dlprefiles"; then 765647e89262Smrg gentop="$output_objdir/${outputname}x" 765747e89262Smrg generated="$generated $gentop" 7658bd1da9d7Smrg 765947e89262Smrg func_extract_archives $gentop $dlprefiles 766047e89262Smrg libobjs="$libobjs $func_extract_archives_result" 766147e89262Smrg test "X$libobjs" = "X " && libobjs= 7662bd1da9d7Smrg fi 7663bd1da9d7Smrg 766447e89262Smrg save_ifs="$IFS"; IFS='~' 766547e89262Smrg for cmd in $cmds; do 766647e89262Smrg IFS="$save_ifs" 766747e89262Smrg eval cmd=\"$cmd\" 766847e89262Smrg $opt_silent || { 766947e89262Smrg func_quote_for_expand "$cmd" 767047e89262Smrg eval "func_echo $func_quote_for_expand_result" 767147e89262Smrg } 767247e89262Smrg $opt_dry_run || eval "$cmd" || { 767347e89262Smrg lt_exit=$? 7674bd1da9d7Smrg 767547e89262Smrg # Restore the uninstalled library and exit 767647e89262Smrg if test "$mode" = relink; then 767747e89262Smrg ( cd "$output_objdir" && \ 767847e89262Smrg $RM "${realname}T" && \ 767947e89262Smrg $MV "${realname}U" "$realname" ) 7680bd1da9d7Smrg fi 7681bd1da9d7Smrg 768247e89262Smrg exit $lt_exit 768347e89262Smrg } 768447e89262Smrg done 768547e89262Smrg IFS="$save_ifs" 7686bd1da9d7Smrg 768747e89262Smrg # Restore the uninstalled library and exit 768847e89262Smrg if test "$mode" = relink; then 768947e89262Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 7690bd1da9d7Smrg 769147e89262Smrg if test -n "$convenience"; then 769247e89262Smrg if test -z "$whole_archive_flag_spec"; then 769347e89262Smrg func_show_eval '${RM}r "$gentop"' 769447e89262Smrg fi 769547e89262Smrg fi 7696bd1da9d7Smrg 769747e89262Smrg exit $EXIT_SUCCESS 769847e89262Smrg fi 7699bd1da9d7Smrg 770047e89262Smrg # Create links to the real library. 770147e89262Smrg for linkname in $linknames; do 770247e89262Smrg if test "$realname" != "$linkname"; then 770347e89262Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 770447e89262Smrg fi 770547e89262Smrg done 7706bd1da9d7Smrg 770747e89262Smrg # If -module or -export-dynamic was specified, set the dlname. 770847e89262Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 770947e89262Smrg # On all known operating systems, these are identical. 771047e89262Smrg dlname="$soname" 771147e89262Smrg fi 771247e89262Smrg fi 771347e89262Smrg ;; 7714bd1da9d7Smrg 771547e89262Smrg obj) 771647e89262Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 771747e89262Smrg func_warning "\`-dlopen' is ignored for objects" 771847e89262Smrg fi 7719bd1da9d7Smrg 772047e89262Smrg case " $deplibs" in 772147e89262Smrg *\ -l* | *\ -L*) 772247e89262Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 772347e89262Smrg esac 7724bd1da9d7Smrg 772547e89262Smrg test -n "$rpath" && \ 772647e89262Smrg func_warning "\`-rpath' is ignored for objects" 7727bd1da9d7Smrg 772847e89262Smrg test -n "$xrpath" && \ 772947e89262Smrg func_warning "\`-R' is ignored for objects" 773047e89262Smrg 773147e89262Smrg test -n "$vinfo" && \ 773247e89262Smrg func_warning "\`-version-info' is ignored for objects" 7733bd1da9d7Smrg 773447e89262Smrg test -n "$release" && \ 773547e89262Smrg func_warning "\`-release' is ignored for objects" 7736bd1da9d7Smrg 773747e89262Smrg case $output in 773847e89262Smrg *.lo) 773947e89262Smrg test -n "$objs$old_deplibs" && \ 774047e89262Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 774147e89262Smrg 774247e89262Smrg libobj=$output 774347e89262Smrg func_lo2o "$libobj" 774447e89262Smrg obj=$func_lo2o_result 774547e89262Smrg ;; 774647e89262Smrg *) 774747e89262Smrg libobj= 774847e89262Smrg obj="$output" 7749bd1da9d7Smrg ;; 7750bd1da9d7Smrg esac 7751bd1da9d7Smrg 775247e89262Smrg # Delete the old objects. 775347e89262Smrg $opt_dry_run || $RM $obj $libobj 7754bd1da9d7Smrg 775547e89262Smrg # Objects from convenience libraries. This assumes 775647e89262Smrg # single-version convenience libraries. Whenever we create 775747e89262Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 775847e89262Smrg # the extraction. 775947e89262Smrg reload_conv_objs= 776047e89262Smrg gentop= 776147e89262Smrg # reload_cmds runs $LD directly, so let us get rid of 776247e89262Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 776347e89262Smrg # turning comma into space.. 776447e89262Smrg wl= 7765bd1da9d7Smrg 776647e89262Smrg if test -n "$convenience"; then 776747e89262Smrg if test -n "$whole_archive_flag_spec"; then 776847e89262Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 776947e89262Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 7770bd1da9d7Smrg else 777147e89262Smrg gentop="$output_objdir/${obj}x" 777247e89262Smrg generated="$generated $gentop" 777347e89262Smrg 777447e89262Smrg func_extract_archives $gentop $convenience 777547e89262Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 7776bd1da9d7Smrg fi 777747e89262Smrg fi 7778bd1da9d7Smrg 777947e89262Smrg # Create the old-style object. 778047e89262Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 7781bd1da9d7Smrg 778247e89262Smrg output="$obj" 778347e89262Smrg func_execute_cmds "$reload_cmds" 'exit $?' 7784bd1da9d7Smrg 778547e89262Smrg # Exit if we aren't doing a library object file. 778647e89262Smrg if test -z "$libobj"; then 778747e89262Smrg if test -n "$gentop"; then 778847e89262Smrg func_show_eval '${RM}r "$gentop"' 778947e89262Smrg fi 7790bd1da9d7Smrg 779147e89262Smrg exit $EXIT_SUCCESS 7792bd1da9d7Smrg fi 7793bd1da9d7Smrg 779447e89262Smrg if test "$build_libtool_libs" != yes; then 779547e89262Smrg if test -n "$gentop"; then 779647e89262Smrg func_show_eval '${RM}r "$gentop"' 779747e89262Smrg fi 7798bd1da9d7Smrg 779947e89262Smrg # Create an invalid libtool object if no PIC, so that we don't 780047e89262Smrg # accidentally link it into a program. 780147e89262Smrg # $show "echo timestamp > $libobj" 780247e89262Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 780347e89262Smrg exit $EXIT_SUCCESS 780447e89262Smrg fi 7805bd1da9d7Smrg 780647e89262Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 780747e89262Smrg # Only do commands if we really have different PIC objects. 780847e89262Smrg reload_objs="$libobjs $reload_conv_objs" 780947e89262Smrg output="$libobj" 781047e89262Smrg func_execute_cmds "$reload_cmds" 'exit $?' 7811bd1da9d7Smrg fi 781247e89262Smrg 781347e89262Smrg if test -n "$gentop"; then 781447e89262Smrg func_show_eval '${RM}r "$gentop"' 781547e89262Smrg fi 781647e89262Smrg 781747e89262Smrg exit $EXIT_SUCCESS 7818bd1da9d7Smrg ;; 7819bd1da9d7Smrg 782047e89262Smrg prog) 782147e89262Smrg case $host in 782247e89262Smrg *cygwin*) func_stripname '' '.exe' "$output" 782347e89262Smrg output=$func_stripname_result.exe;; 782447e89262Smrg esac 782547e89262Smrg test -n "$vinfo" && \ 782647e89262Smrg func_warning "\`-version-info' is ignored for programs" 7827bd1da9d7Smrg 782847e89262Smrg test -n "$release" && \ 782947e89262Smrg func_warning "\`-release' is ignored for programs" 7830bd1da9d7Smrg 783147e89262Smrg test "$preload" = yes \ 783247e89262Smrg && test "$dlopen_support" = unknown \ 783347e89262Smrg && test "$dlopen_self" = unknown \ 783447e89262Smrg && test "$dlopen_self_static" = unknown && \ 783547e89262Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 783647e89262Smrg 783747e89262Smrg case $host in 783847e89262Smrg *-*-rhapsody* | *-*-darwin1.[012]) 783947e89262Smrg # On Rhapsody replace the C library is the System framework 784047e89262Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 784147e89262Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 7842bd1da9d7Smrg ;; 784347e89262Smrg esac 7844bd1da9d7Smrg 784547e89262Smrg case $host in 784647e89262Smrg *-*-darwin*) 784747e89262Smrg # Don't allow lazy linking, it breaks C++ global constructors 784847e89262Smrg # But is supposedly fixed on 10.4 or later (yay!). 784947e89262Smrg if test "$tagname" = CXX ; then 785047e89262Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 785147e89262Smrg 10.[0123]) 785247e89262Smrg compile_command="$compile_command ${wl}-bind_at_load" 785347e89262Smrg finalize_command="$finalize_command ${wl}-bind_at_load" 785447e89262Smrg ;; 785547e89262Smrg esac 7856bd1da9d7Smrg fi 785747e89262Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 785847e89262Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 785947e89262Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 786047e89262Smrg ;; 786147e89262Smrg esac 7862bd1da9d7Smrg 7863bd1da9d7Smrg 786447e89262Smrg # move library search paths that coincide with paths to not yet 786547e89262Smrg # installed libraries to the beginning of the library search list 786647e89262Smrg new_libs= 786747e89262Smrg for path in $notinst_path; do 786847e89262Smrg case " $new_libs " in 786947e89262Smrg *" -L$path/$objdir "*) ;; 787047e89262Smrg *) 787147e89262Smrg case " $compile_deplibs " in 787247e89262Smrg *" -L$path/$objdir "*) 787347e89262Smrg new_libs="$new_libs -L$path/$objdir" ;; 7874bd1da9d7Smrg esac 787547e89262Smrg ;; 787647e89262Smrg esac 787747e89262Smrg done 787847e89262Smrg for deplib in $compile_deplibs; do 787947e89262Smrg case $deplib in 788047e89262Smrg -L*) 788147e89262Smrg case " $new_libs " in 788247e89262Smrg *" $deplib "*) ;; 788347e89262Smrg *) new_libs="$new_libs $deplib" ;; 7884bd1da9d7Smrg esac 788547e89262Smrg ;; 788647e89262Smrg *) new_libs="$new_libs $deplib" ;; 788747e89262Smrg esac 788847e89262Smrg done 788947e89262Smrg compile_deplibs="$new_libs" 7890bd1da9d7Smrg 7891bd1da9d7Smrg 789247e89262Smrg compile_command="$compile_command $compile_deplibs" 789347e89262Smrg finalize_command="$finalize_command $finalize_deplibs" 7894bd1da9d7Smrg 789547e89262Smrg if test -n "$rpath$xrpath"; then 789647e89262Smrg # If the user specified any rpath flags, then add them. 789747e89262Smrg for libdir in $rpath $xrpath; do 789847e89262Smrg # This is the magic to use -rpath. 789947e89262Smrg case "$finalize_rpath " in 790047e89262Smrg *" $libdir "*) ;; 790147e89262Smrg *) finalize_rpath="$finalize_rpath $libdir" ;; 790247e89262Smrg esac 790347e89262Smrg done 790447e89262Smrg fi 7905bd1da9d7Smrg 790647e89262Smrg # Now hardcode the library paths 790747e89262Smrg rpath= 790847e89262Smrg hardcode_libdirs= 790947e89262Smrg for libdir in $compile_rpath $finalize_rpath; do 791047e89262Smrg if test -n "$hardcode_libdir_flag_spec"; then 791147e89262Smrg if test -n "$hardcode_libdir_separator"; then 791247e89262Smrg if test -z "$hardcode_libdirs"; then 791347e89262Smrg hardcode_libdirs="$libdir" 791447e89262Smrg else 791547e89262Smrg # Just accumulate the unique libdirs. 791647e89262Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 791747e89262Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 791847e89262Smrg ;; 791947e89262Smrg *) 792047e89262Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 792147e89262Smrg ;; 792247e89262Smrg esac 792347e89262Smrg fi 7924bd1da9d7Smrg else 792547e89262Smrg eval flag=\"$hardcode_libdir_flag_spec\" 792647e89262Smrg rpath="$rpath $flag" 7927bd1da9d7Smrg fi 792847e89262Smrg elif test -n "$runpath_var"; then 792947e89262Smrg case "$perm_rpath " in 793047e89262Smrg *" $libdir "*) ;; 793147e89262Smrg *) perm_rpath="$perm_rpath $libdir" ;; 793247e89262Smrg esac 793347e89262Smrg fi 793447e89262Smrg case $host in 793547e89262Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 793647e89262Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 793747e89262Smrg case :$dllsearchpath: in 793847e89262Smrg *":$libdir:"*) ;; 793947e89262Smrg ::) dllsearchpath=$libdir;; 794047e89262Smrg *) dllsearchpath="$dllsearchpath:$libdir";; 794147e89262Smrg esac 794247e89262Smrg case :$dllsearchpath: in 794347e89262Smrg *":$testbindir:"*) ;; 794447e89262Smrg ::) dllsearchpath=$testbindir;; 794547e89262Smrg *) dllsearchpath="$dllsearchpath:$testbindir";; 794647e89262Smrg esac 794747e89262Smrg ;; 794847e89262Smrg esac 794947e89262Smrg done 795047e89262Smrg # Substitute the hardcoded libdirs into the rpath. 795147e89262Smrg if test -n "$hardcode_libdir_separator" && 795247e89262Smrg test -n "$hardcode_libdirs"; then 795347e89262Smrg libdir="$hardcode_libdirs" 795447e89262Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 795547e89262Smrg fi 795647e89262Smrg compile_rpath="$rpath" 7957bd1da9d7Smrg 795847e89262Smrg rpath= 795947e89262Smrg hardcode_libdirs= 796047e89262Smrg for libdir in $finalize_rpath; do 796147e89262Smrg if test -n "$hardcode_libdir_flag_spec"; then 796247e89262Smrg if test -n "$hardcode_libdir_separator"; then 796347e89262Smrg if test -z "$hardcode_libdirs"; then 796447e89262Smrg hardcode_libdirs="$libdir" 796547e89262Smrg else 796647e89262Smrg # Just accumulate the unique libdirs. 796747e89262Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 796847e89262Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 796947e89262Smrg ;; 797047e89262Smrg *) 797147e89262Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 797247e89262Smrg ;; 797347e89262Smrg esac 797447e89262Smrg fi 7975bd1da9d7Smrg else 797647e89262Smrg eval flag=\"$hardcode_libdir_flag_spec\" 797747e89262Smrg rpath="$rpath $flag" 7978bd1da9d7Smrg fi 797947e89262Smrg elif test -n "$runpath_var"; then 798047e89262Smrg case "$finalize_perm_rpath " in 798147e89262Smrg *" $libdir "*) ;; 798247e89262Smrg *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; 798347e89262Smrg esac 7984bd1da9d7Smrg fi 798547e89262Smrg done 798647e89262Smrg # Substitute the hardcoded libdirs into the rpath. 798747e89262Smrg if test -n "$hardcode_libdir_separator" && 798847e89262Smrg test -n "$hardcode_libdirs"; then 798947e89262Smrg libdir="$hardcode_libdirs" 799047e89262Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 799147e89262Smrg fi 799247e89262Smrg finalize_rpath="$rpath" 7993bd1da9d7Smrg 799447e89262Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 799547e89262Smrg # Transform all the library objects into standard objects. 799647e89262Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 799747e89262Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 799847e89262Smrg fi 7999bd1da9d7Smrg 800047e89262Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8001bd1da9d7Smrg 800247e89262Smrg # template prelinking step 800347e89262Smrg if test -n "$prelink_cmds"; then 800447e89262Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 800547e89262Smrg fi 8006bd1da9d7Smrg 800747e89262Smrg wrappers_required=yes 800847e89262Smrg case $host in 800947e89262Smrg *cegcc* | *mingw32ce*) 801047e89262Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 801147e89262Smrg wrappers_required=no 801247e89262Smrg ;; 801347e89262Smrg *cygwin* | *mingw* ) 801447e89262Smrg if test "$build_libtool_libs" != yes; then 801547e89262Smrg wrappers_required=no 801647e89262Smrg fi 801747e89262Smrg ;; 801847e89262Smrg *) 801947e89262Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 802047e89262Smrg wrappers_required=no 802147e89262Smrg fi 802247e89262Smrg ;; 802347e89262Smrg esac 802447e89262Smrg if test "$wrappers_required" = no; then 802547e89262Smrg # Replace the output file specification. 802647e89262Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 802747e89262Smrg link_command="$compile_command$compile_rpath" 8028bd1da9d7Smrg 802947e89262Smrg # We have no uninstalled library dependencies, so finalize right now. 803047e89262Smrg exit_status=0 803147e89262Smrg func_show_eval "$link_command" 'exit_status=$?' 8032bd1da9d7Smrg 803347e89262Smrg # Delete the generated files. 803447e89262Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 803547e89262Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8036bd1da9d7Smrg fi 8037bd1da9d7Smrg 803847e89262Smrg exit $exit_status 803947e89262Smrg fi 8040bd1da9d7Smrg 804147e89262Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 804247e89262Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 804347e89262Smrg fi 804447e89262Smrg if test -n "$finalize_shlibpath"; then 804547e89262Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 804647e89262Smrg fi 8047bd1da9d7Smrg 804847e89262Smrg compile_var= 804947e89262Smrg finalize_var= 805047e89262Smrg if test -n "$runpath_var"; then 805147e89262Smrg if test -n "$perm_rpath"; then 805247e89262Smrg # We should set the runpath_var. 805347e89262Smrg rpath= 805447e89262Smrg for dir in $perm_rpath; do 805547e89262Smrg rpath="$rpath$dir:" 805647e89262Smrg done 805747e89262Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8058bd1da9d7Smrg fi 805947e89262Smrg if test -n "$finalize_perm_rpath"; then 806047e89262Smrg # We should set the runpath_var. 806147e89262Smrg rpath= 806247e89262Smrg for dir in $finalize_perm_rpath; do 806347e89262Smrg rpath="$rpath$dir:" 806447e89262Smrg done 806547e89262Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8066bd1da9d7Smrg fi 806747e89262Smrg fi 8068bd1da9d7Smrg 806947e89262Smrg if test "$no_install" = yes; then 807047e89262Smrg # We don't need to create a wrapper script. 807147e89262Smrg link_command="$compile_var$compile_command$compile_rpath" 807247e89262Smrg # Replace the output file specification. 807347e89262Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 807447e89262Smrg # Delete the old output file. 807547e89262Smrg $opt_dry_run || $RM $output 807647e89262Smrg # Link the executable and exit 807747e89262Smrg func_show_eval "$link_command" 'exit $?' 8078bd1da9d7Smrg exit $EXIT_SUCCESS 807947e89262Smrg fi 8080bd1da9d7Smrg 808147e89262Smrg if test "$hardcode_action" = relink; then 808247e89262Smrg # Fast installation is not supported 808347e89262Smrg link_command="$compile_var$compile_command$compile_rpath" 808447e89262Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 808547e89262Smrg 808647e89262Smrg func_warning "this platform does not like uninstalled shared libraries" 808747e89262Smrg func_warning "\`$output' will be relinked during installation" 808847e89262Smrg else 808947e89262Smrg if test "$fast_install" != no; then 809047e89262Smrg link_command="$finalize_var$compile_command$finalize_rpath" 809147e89262Smrg if test "$fast_install" = yes; then 809247e89262Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 809347e89262Smrg else 809447e89262Smrg # fast_install is set to needless 809547e89262Smrg relink_command= 809647e89262Smrg fi 8097bd1da9d7Smrg else 809847e89262Smrg link_command="$compile_var$compile_command$compile_rpath" 809947e89262Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8100bd1da9d7Smrg fi 810147e89262Smrg fi 8102bd1da9d7Smrg 810347e89262Smrg # Replace the output file specification. 810447e89262Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8105bd1da9d7Smrg 810647e89262Smrg # Delete the old output files. 810747e89262Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8108bd1da9d7Smrg 810947e89262Smrg func_show_eval "$link_command" 'exit $?' 8110bd1da9d7Smrg 811147e89262Smrg # Now create the wrapper script. 811247e89262Smrg func_verbose "creating $output" 8113bd1da9d7Smrg 811447e89262Smrg # Quote the relink command for shipping. 811547e89262Smrg if test -n "$relink_command"; then 811647e89262Smrg # Preserve any variables that may affect compiler behavior 811747e89262Smrg for var in $variables_saved_for_relink; do 811847e89262Smrg if eval test -z \"\${$var+set}\"; then 811947e89262Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 812047e89262Smrg elif eval var_value=\$$var; test -z "$var_value"; then 812147e89262Smrg relink_command="$var=; export $var; $relink_command" 8122bd1da9d7Smrg else 812347e89262Smrg func_quote_for_eval "$var_value" 812447e89262Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 8125bd1da9d7Smrg fi 812647e89262Smrg done 812747e89262Smrg relink_command="(cd `pwd`; $relink_command)" 812847e89262Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 812947e89262Smrg fi 8130bd1da9d7Smrg 813147e89262Smrg # Only actually do things if not in dry run mode. 813247e89262Smrg $opt_dry_run || { 813347e89262Smrg # win32 will think the script is a binary if it has 813447e89262Smrg # a .exe suffix, so we strip it off here. 813547e89262Smrg case $output in 813647e89262Smrg *.exe) func_stripname '' '.exe' "$output" 813747e89262Smrg output=$func_stripname_result ;; 813847e89262Smrg esac 813947e89262Smrg # test for cygwin because mv fails w/o .exe extensions 814047e89262Smrg case $host in 814147e89262Smrg *cygwin*) 814247e89262Smrg exeext=.exe 814347e89262Smrg func_stripname '' '.exe' "$outputname" 814447e89262Smrg outputname=$func_stripname_result ;; 814547e89262Smrg *) exeext= ;; 8146bd1da9d7Smrg esac 814747e89262Smrg case $host in 814847e89262Smrg *cygwin* | *mingw* ) 814947e89262Smrg func_dirname_and_basename "$output" "" "." 815047e89262Smrg output_name=$func_basename_result 815147e89262Smrg output_path=$func_dirname_result 815247e89262Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 815347e89262Smrg cwrapper="$output_path/$output_name.exe" 815447e89262Smrg $RM $cwrappersource $cwrapper 815547e89262Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 815647e89262Smrg 815747e89262Smrg func_emit_cwrapperexe_src > $cwrappersource 815847e89262Smrg 815947e89262Smrg # The wrapper executable is built using the $host compiler, 816047e89262Smrg # because it contains $host paths and files. If cross- 816147e89262Smrg # compiling, it, like the target executable, must be 816247e89262Smrg # executed on the $host or under an emulation environment. 816347e89262Smrg $opt_dry_run || { 816447e89262Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 816547e89262Smrg $STRIP $cwrapper 816647e89262Smrg } 8167bd1da9d7Smrg 816847e89262Smrg # Now, create the wrapper script for func_source use: 816947e89262Smrg func_ltwrapper_scriptname $cwrapper 817047e89262Smrg $RM $func_ltwrapper_scriptname_result 817147e89262Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 817247e89262Smrg $opt_dry_run || { 817347e89262Smrg # note: this script will not be executed, so do not chmod. 817447e89262Smrg if test "x$build" = "x$host" ; then 817547e89262Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 817647e89262Smrg else 817747e89262Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 817847e89262Smrg fi 817947e89262Smrg } 818047e89262Smrg ;; 818147e89262Smrg * ) 818247e89262Smrg $RM $output 818347e89262Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 8184bd1da9d7Smrg 818547e89262Smrg func_emit_wrapper no > $output 818647e89262Smrg chmod +x $output 818747e89262Smrg ;; 818847e89262Smrg esac 818947e89262Smrg } 819047e89262Smrg exit $EXIT_SUCCESS 819147e89262Smrg ;; 819247e89262Smrg esac 8193bd1da9d7Smrg 819447e89262Smrg # See if we need to build an old-fashioned archive. 819547e89262Smrg for oldlib in $oldlibs; do 8196bd1da9d7Smrg 819747e89262Smrg if test "$build_libtool_libs" = convenience; then 819847e89262Smrg oldobjs="$libobjs_save $symfileobj" 819947e89262Smrg addlibs="$convenience" 820047e89262Smrg build_libtool_libs=no 820147e89262Smrg else 820247e89262Smrg if test "$build_libtool_libs" = module; then 820347e89262Smrg oldobjs="$libobjs_save" 820447e89262Smrg build_libtool_libs=no 820547e89262Smrg else 820647e89262Smrg oldobjs="$old_deplibs $non_pic_objects" 820747e89262Smrg if test "$preload" = yes && test -f "$symfileobj"; then 820847e89262Smrg oldobjs="$oldobjs $symfileobj" 820947e89262Smrg fi 821047e89262Smrg fi 821147e89262Smrg addlibs="$old_convenience" 8212bd1da9d7Smrg fi 8213bd1da9d7Smrg 821447e89262Smrg if test -n "$addlibs"; then 821547e89262Smrg gentop="$output_objdir/${outputname}x" 821647e89262Smrg generated="$generated $gentop" 8217bd1da9d7Smrg 821847e89262Smrg func_extract_archives $gentop $addlibs 821947e89262Smrg oldobjs="$oldobjs $func_extract_archives_result" 822047e89262Smrg fi 8221bd1da9d7Smrg 822247e89262Smrg # Do each command in the archive commands. 822347e89262Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 822447e89262Smrg cmds=$old_archive_from_new_cmds 822547e89262Smrg else 8226bd1da9d7Smrg 822747e89262Smrg # Add any objects from preloaded convenience libraries 822847e89262Smrg if test -n "$dlprefiles"; then 822947e89262Smrg gentop="$output_objdir/${outputname}x" 823047e89262Smrg generated="$generated $gentop" 8231bd1da9d7Smrg 823247e89262Smrg func_extract_archives $gentop $dlprefiles 823347e89262Smrg oldobjs="$oldobjs $func_extract_archives_result" 823447e89262Smrg fi 8235bd1da9d7Smrg 823647e89262Smrg # POSIX demands no paths to be encoded in archives. We have 823747e89262Smrg # to avoid creating archives with duplicate basenames if we 823847e89262Smrg # might have to extract them afterwards, e.g., when creating a 823947e89262Smrg # static archive out of a convenience library, or when linking 824047e89262Smrg # the entirety of a libtool archive into another (currently 824147e89262Smrg # not supported by libtool). 824247e89262Smrg if (for obj in $oldobjs 824347e89262Smrg do 824447e89262Smrg func_basename "$obj" 824547e89262Smrg $ECHO "$func_basename_result" 824647e89262Smrg done | sort | sort -uc >/dev/null 2>&1); then 824747e89262Smrg : 824847e89262Smrg else 824947e89262Smrg echo "copying selected object files to avoid basename conflicts..." 825047e89262Smrg gentop="$output_objdir/${outputname}x" 825147e89262Smrg generated="$generated $gentop" 825247e89262Smrg func_mkdir_p "$gentop" 825347e89262Smrg save_oldobjs=$oldobjs 825447e89262Smrg oldobjs= 825547e89262Smrg counter=1 825647e89262Smrg for obj in $save_oldobjs 825747e89262Smrg do 825847e89262Smrg func_basename "$obj" 825947e89262Smrg objbase="$func_basename_result" 826047e89262Smrg case " $oldobjs " in 826147e89262Smrg " ") oldobjs=$obj ;; 826247e89262Smrg *[\ /]"$objbase "*) 826347e89262Smrg while :; do 826447e89262Smrg # Make sure we don't pick an alternate name that also 826547e89262Smrg # overlaps. 826647e89262Smrg newobj=lt$counter-$objbase 826747e89262Smrg func_arith $counter + 1 826847e89262Smrg counter=$func_arith_result 826947e89262Smrg case " $oldobjs " in 827047e89262Smrg *[\ /]"$newobj "*) ;; 827147e89262Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 827247e89262Smrg esac 827347e89262Smrg done 827447e89262Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 827547e89262Smrg oldobjs="$oldobjs $gentop/$newobj" 827647e89262Smrg ;; 827747e89262Smrg *) oldobjs="$oldobjs $obj" ;; 827847e89262Smrg esac 8279bd1da9d7Smrg done 8280bd1da9d7Smrg fi 828147e89262Smrg eval cmds=\"$old_archive_cmds\" 8282bd1da9d7Smrg 828347e89262Smrg func_len " $cmds" 828447e89262Smrg len=$func_len_result 828547e89262Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 828647e89262Smrg cmds=$old_archive_cmds 828747e89262Smrg else 828847e89262Smrg # the command line is too long to link in one step, link in parts 828947e89262Smrg func_verbose "using piecewise archive linking..." 829047e89262Smrg save_RANLIB=$RANLIB 829147e89262Smrg RANLIB=: 829247e89262Smrg objlist= 829347e89262Smrg concat_cmds= 829447e89262Smrg save_oldobjs=$oldobjs 829547e89262Smrg oldobjs= 829647e89262Smrg # Is there a better way of finding the last object in the list? 829747e89262Smrg for obj in $save_oldobjs 829847e89262Smrg do 829947e89262Smrg last_oldobj=$obj 830047e89262Smrg done 830147e89262Smrg eval test_cmds=\"$old_archive_cmds\" 830247e89262Smrg func_len " $test_cmds" 830347e89262Smrg len0=$func_len_result 830447e89262Smrg len=$len0 830547e89262Smrg for obj in $save_oldobjs 830647e89262Smrg do 830747e89262Smrg func_len " $obj" 830847e89262Smrg func_arith $len + $func_len_result 830947e89262Smrg len=$func_arith_result 831047e89262Smrg func_append objlist " $obj" 831147e89262Smrg if test "$len" -lt "$max_cmd_len"; then 831247e89262Smrg : 831347e89262Smrg else 831447e89262Smrg # the above command should be used before it gets too long 831547e89262Smrg oldobjs=$objlist 831647e89262Smrg if test "$obj" = "$last_oldobj" ; then 831747e89262Smrg RANLIB=$save_RANLIB 831847e89262Smrg fi 831947e89262Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 832047e89262Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 832147e89262Smrg objlist= 832247e89262Smrg len=$len0 832347e89262Smrg fi 832447e89262Smrg done 832547e89262Smrg RANLIB=$save_RANLIB 832647e89262Smrg oldobjs=$objlist 832747e89262Smrg if test "X$oldobjs" = "X" ; then 832847e89262Smrg eval cmds=\"\$concat_cmds\" 832947e89262Smrg else 833047e89262Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 833147e89262Smrg fi 833247e89262Smrg fi 833347e89262Smrg fi 833447e89262Smrg func_execute_cmds "$cmds" 'exit $?' 8335bd1da9d7Smrg done 8336bd1da9d7Smrg 833747e89262Smrg test -n "$generated" && \ 833847e89262Smrg func_show_eval "${RM}r$generated" 8339bd1da9d7Smrg 834047e89262Smrg # Now create the libtool archive. 834147e89262Smrg case $output in 834247e89262Smrg *.la) 834347e89262Smrg old_library= 834447e89262Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 834547e89262Smrg func_verbose "creating $output" 8346bd1da9d7Smrg 834747e89262Smrg # Preserve any variables that may affect compiler behavior 834847e89262Smrg for var in $variables_saved_for_relink; do 834947e89262Smrg if eval test -z \"\${$var+set}\"; then 835047e89262Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 835147e89262Smrg elif eval var_value=\$$var; test -z "$var_value"; then 835247e89262Smrg relink_command="$var=; export $var; $relink_command" 8353bd1da9d7Smrg else 835447e89262Smrg func_quote_for_eval "$var_value" 835547e89262Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 8356bd1da9d7Smrg fi 835747e89262Smrg done 835847e89262Smrg # Quote the link command for shipping. 835947e89262Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 836047e89262Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 836147e89262Smrg if test "$hardcode_automatic" = yes ; then 836247e89262Smrg relink_command= 836347e89262Smrg fi 8364bd1da9d7Smrg 836547e89262Smrg # Only create the output if not a dry run. 836647e89262Smrg $opt_dry_run || { 836747e89262Smrg for installed in no yes; do 836847e89262Smrg if test "$installed" = yes; then 836947e89262Smrg if test -z "$install_libdir"; then 837047e89262Smrg break 837147e89262Smrg fi 837247e89262Smrg output="$output_objdir/$outputname"i 837347e89262Smrg # Replace all uninstalled libtool libraries with the installed ones 837447e89262Smrg newdependency_libs= 837547e89262Smrg for deplib in $dependency_libs; do 837647e89262Smrg case $deplib in 837747e89262Smrg *.la) 837847e89262Smrg func_basename "$deplib" 837947e89262Smrg name="$func_basename_result" 838047e89262Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 838147e89262Smrg test -z "$libdir" && \ 838247e89262Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 838347e89262Smrg newdependency_libs="$newdependency_libs $libdir/$name" 838447e89262Smrg ;; 838547e89262Smrg *) newdependency_libs="$newdependency_libs $deplib" ;; 838647e89262Smrg esac 838747e89262Smrg done 838847e89262Smrg dependency_libs="$newdependency_libs" 838947e89262Smrg newdlfiles= 839047e89262Smrg 839147e89262Smrg for lib in $dlfiles; do 839247e89262Smrg case $lib in 839347e89262Smrg *.la) 839447e89262Smrg func_basename "$lib" 839547e89262Smrg name="$func_basename_result" 839647e89262Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 839747e89262Smrg test -z "$libdir" && \ 839847e89262Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 839947e89262Smrg newdlfiles="$newdlfiles $libdir/$name" 840047e89262Smrg ;; 840147e89262Smrg *) newdlfiles="$newdlfiles $lib" ;; 840247e89262Smrg esac 840347e89262Smrg done 840447e89262Smrg dlfiles="$newdlfiles" 840547e89262Smrg newdlprefiles= 840647e89262Smrg for lib in $dlprefiles; do 840747e89262Smrg case $lib in 840847e89262Smrg *.la) 840947e89262Smrg # Only pass preopened files to the pseudo-archive (for 841047e89262Smrg # eventual linking with the app. that links it) if we 841147e89262Smrg # didn't already link the preopened objects directly into 841247e89262Smrg # the library: 841347e89262Smrg func_basename "$lib" 841447e89262Smrg name="$func_basename_result" 841547e89262Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 841647e89262Smrg test -z "$libdir" && \ 841747e89262Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 841847e89262Smrg newdlprefiles="$newdlprefiles $libdir/$name" 841947e89262Smrg ;; 842047e89262Smrg esac 842147e89262Smrg done 842247e89262Smrg dlprefiles="$newdlprefiles" 842347e89262Smrg else 842447e89262Smrg newdlfiles= 842547e89262Smrg for lib in $dlfiles; do 842647e89262Smrg case $lib in 842747e89262Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 842847e89262Smrg *) abs=`pwd`"/$lib" ;; 842947e89262Smrg esac 843047e89262Smrg newdlfiles="$newdlfiles $abs" 843147e89262Smrg done 843247e89262Smrg dlfiles="$newdlfiles" 843347e89262Smrg newdlprefiles= 843447e89262Smrg for lib in $dlprefiles; do 843547e89262Smrg case $lib in 843647e89262Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 843747e89262Smrg *) abs=`pwd`"/$lib" ;; 843847e89262Smrg esac 843947e89262Smrg newdlprefiles="$newdlprefiles $abs" 844047e89262Smrg done 844147e89262Smrg dlprefiles="$newdlprefiles" 844247e89262Smrg fi 844347e89262Smrg $RM $output 844447e89262Smrg # place dlname in correct position for cygwin 844547e89262Smrg # In fact, it would be nice if we could use this code for all target 844647e89262Smrg # systems that can't hard-code library paths into their executables 844747e89262Smrg # and that have no shared library path variable independent of PATH, 844847e89262Smrg # but it turns out we can't easily determine that from inspecting 844947e89262Smrg # libtool variables, so we have to hard-code the OSs to which it 845047e89262Smrg # applies here; at the moment, that means platforms that use the PE 845147e89262Smrg # object format with DLL files. See the long comment at the top of 845247e89262Smrg # tests/bindir.at for full details. 845347e89262Smrg tdlname=$dlname 845447e89262Smrg case $host,$output,$installed,$module,$dlname in 845547e89262Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 845647e89262Smrg # If a -bindir argument was supplied, place the dll there. 845747e89262Smrg if test "x$bindir" != x ; 845847e89262Smrg then 845947e89262Smrg func_relative_path "$install_libdir" "$bindir" 846047e89262Smrg tdlname=$func_relative_path_result$dlname 846147e89262Smrg else 846247e89262Smrg # Otherwise fall back on heuristic. 846347e89262Smrg tdlname=../bin/$dlname 846447e89262Smrg fi 846547e89262Smrg ;; 846647e89262Smrg esac 846747e89262Smrg $ECHO > $output "\ 846847e89262Smrg# $outputname - a libtool library file 846947e89262Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 847047e89262Smrg# 847147e89262Smrg# Please DO NOT delete this file! 847247e89262Smrg# It is necessary for linking the library. 8473bd1da9d7Smrg 847447e89262Smrg# The name that we can dlopen(3). 847547e89262Smrgdlname='$tdlname' 8476bd1da9d7Smrg 847747e89262Smrg# Names of this library. 847847e89262Smrglibrary_names='$library_names' 8479bd1da9d7Smrg 848047e89262Smrg# The name of the static archive. 848147e89262Smrgold_library='$old_library' 8482bd1da9d7Smrg 848347e89262Smrg# Linker flags that can not go in dependency_libs. 848447e89262Smrginherited_linker_flags='$new_inherited_linker_flags' 8485bd1da9d7Smrg 848647e89262Smrg# Libraries that this one depends upon. 848747e89262Smrgdependency_libs='$dependency_libs' 8488bd1da9d7Smrg 848947e89262Smrg# Names of additional weak libraries provided by this library 849047e89262Smrgweak_library_names='$weak_libs' 8491bd1da9d7Smrg 849247e89262Smrg# Version information for $libname. 849347e89262Smrgcurrent=$current 849447e89262Smrgage=$age 849547e89262Smrgrevision=$revision 8496bd1da9d7Smrg 849747e89262Smrg# Is this an already installed library? 849847e89262Smrginstalled=$installed 8499bd1da9d7Smrg 850047e89262Smrg# Should we warn about portability when linking against -modules? 850147e89262Smrgshouldnotlink=$module 8502bd1da9d7Smrg 850347e89262Smrg# Files to dlopen/dlpreopen 850447e89262Smrgdlopen='$dlfiles' 850547e89262Smrgdlpreopen='$dlprefiles' 8506bd1da9d7Smrg 850747e89262Smrg# Directory that this library needs to be installed in: 850847e89262Smrglibdir='$install_libdir'" 850947e89262Smrg if test "$installed" = no && test "$need_relink" = yes; then 851047e89262Smrg $ECHO >> $output "\ 851147e89262Smrgrelink_command=\"$relink_command\"" 851247e89262Smrg fi 851347e89262Smrg done 851447e89262Smrg } 8515bd1da9d7Smrg 851647e89262Smrg # Do a symbolic link so that the libtool archive can be found in 851747e89262Smrg # LD_LIBRARY_PATH before the program is installed. 851847e89262Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 851947e89262Smrg ;; 852047e89262Smrg esac 852147e89262Smrg exit $EXIT_SUCCESS 852247e89262Smrg} 8523bd1da9d7Smrg 852447e89262Smrg{ test "$mode" = link || test "$mode" = relink; } && 852547e89262Smrg func_mode_link ${1+"$@"} 8526bd1da9d7Smrg 8527bd1da9d7Smrg 852847e89262Smrg# func_mode_uninstall arg... 852947e89262Smrgfunc_mode_uninstall () 853047e89262Smrg{ 853147e89262Smrg $opt_debug 853247e89262Smrg RM="$nonopt" 8533bd1da9d7Smrg files= 8534bd1da9d7Smrg rmforce= 8535bd1da9d7Smrg exit_status=0 8536bd1da9d7Smrg 8537bd1da9d7Smrg # This variable tells wrapper scripts just to set variables rather 8538bd1da9d7Smrg # than running their programs. 8539bd1da9d7Smrg libtool_install_magic="$magic" 8540bd1da9d7Smrg 8541bd1da9d7Smrg for arg 8542bd1da9d7Smrg do 8543bd1da9d7Smrg case $arg in 854447e89262Smrg -f) RM="$RM $arg"; rmforce=yes ;; 854547e89262Smrg -*) RM="$RM $arg" ;; 8546bd1da9d7Smrg *) files="$files $arg" ;; 8547bd1da9d7Smrg esac 8548bd1da9d7Smrg done 8549bd1da9d7Smrg 855047e89262Smrg test -z "$RM" && \ 855147e89262Smrg func_fatal_help "you must specify an RM program" 8552bd1da9d7Smrg 8553bd1da9d7Smrg rmdirs= 8554bd1da9d7Smrg 8555bd1da9d7Smrg origobjdir="$objdir" 8556bd1da9d7Smrg for file in $files; do 855747e89262Smrg func_dirname "$file" "" "." 855847e89262Smrg dir="$func_dirname_result" 855947e89262Smrg if test "X$dir" = X.; then 8560bd1da9d7Smrg objdir="$origobjdir" 8561bd1da9d7Smrg else 8562bd1da9d7Smrg objdir="$dir/$origobjdir" 8563bd1da9d7Smrg fi 856447e89262Smrg func_basename "$file" 856547e89262Smrg name="$func_basename_result" 8566bd1da9d7Smrg test "$mode" = uninstall && objdir="$dir" 8567bd1da9d7Smrg 8568bd1da9d7Smrg # Remember objdir for removal later, being careful to avoid duplicates 8569bd1da9d7Smrg if test "$mode" = clean; then 8570bd1da9d7Smrg case " $rmdirs " in 8571bd1da9d7Smrg *" $objdir "*) ;; 8572bd1da9d7Smrg *) rmdirs="$rmdirs $objdir" ;; 8573bd1da9d7Smrg esac 8574bd1da9d7Smrg fi 8575bd1da9d7Smrg 8576bd1da9d7Smrg # Don't error if the file doesn't exist and rm -f was used. 857747e89262Smrg if { test -L "$file"; } >/dev/null 2>&1 || 857847e89262Smrg { test -h "$file"; } >/dev/null 2>&1 || 857947e89262Smrg test -f "$file"; then 8580bd1da9d7Smrg : 8581bd1da9d7Smrg elif test -d "$file"; then 8582bd1da9d7Smrg exit_status=1 8583bd1da9d7Smrg continue 8584bd1da9d7Smrg elif test "$rmforce" = yes; then 8585bd1da9d7Smrg continue 8586bd1da9d7Smrg fi 8587bd1da9d7Smrg 8588bd1da9d7Smrg rmfiles="$file" 8589bd1da9d7Smrg 8590bd1da9d7Smrg case $name in 8591bd1da9d7Smrg *.la) 8592bd1da9d7Smrg # Possibly a libtool archive, so verify it. 859347e89262Smrg if func_lalib_p "$file"; then 859447e89262Smrg func_source $dir/$name 8595bd1da9d7Smrg 8596bd1da9d7Smrg # Delete the libtool libraries and symlinks. 8597bd1da9d7Smrg for n in $library_names; do 8598bd1da9d7Smrg rmfiles="$rmfiles $objdir/$n" 8599bd1da9d7Smrg done 8600bd1da9d7Smrg test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" 8601bd1da9d7Smrg 8602bd1da9d7Smrg case "$mode" in 8603bd1da9d7Smrg clean) 8604bd1da9d7Smrg case " $library_names " in 8605bd1da9d7Smrg # " " in the beginning catches empty $dlname 8606bd1da9d7Smrg *" $dlname "*) ;; 8607bd1da9d7Smrg *) rmfiles="$rmfiles $objdir/$dlname" ;; 8608bd1da9d7Smrg esac 860947e89262Smrg test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" 8610bd1da9d7Smrg ;; 8611bd1da9d7Smrg uninstall) 8612bd1da9d7Smrg if test -n "$library_names"; then 8613bd1da9d7Smrg # Do each command in the postuninstall commands. 861447e89262Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 8615bd1da9d7Smrg fi 8616bd1da9d7Smrg 8617bd1da9d7Smrg if test -n "$old_library"; then 8618bd1da9d7Smrg # Do each command in the old_postuninstall commands. 861947e89262Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 8620bd1da9d7Smrg fi 8621bd1da9d7Smrg # FIXME: should reinstall the best remaining shared library. 8622bd1da9d7Smrg ;; 8623bd1da9d7Smrg esac 8624bd1da9d7Smrg fi 8625bd1da9d7Smrg ;; 8626bd1da9d7Smrg 8627bd1da9d7Smrg *.lo) 8628bd1da9d7Smrg # Possibly a libtool object, so verify it. 862947e89262Smrg if func_lalib_p "$file"; then 8630bd1da9d7Smrg 8631bd1da9d7Smrg # Read the .lo file 863247e89262Smrg func_source $dir/$name 8633bd1da9d7Smrg 8634bd1da9d7Smrg # Add PIC object to the list of files to remove. 863547e89262Smrg if test -n "$pic_object" && 863647e89262Smrg test "$pic_object" != none; then 8637bd1da9d7Smrg rmfiles="$rmfiles $dir/$pic_object" 8638bd1da9d7Smrg fi 8639bd1da9d7Smrg 8640bd1da9d7Smrg # Add non-PIC object to the list of files to remove. 864147e89262Smrg if test -n "$non_pic_object" && 864247e89262Smrg test "$non_pic_object" != none; then 8643bd1da9d7Smrg rmfiles="$rmfiles $dir/$non_pic_object" 8644bd1da9d7Smrg fi 8645bd1da9d7Smrg fi 8646bd1da9d7Smrg ;; 8647bd1da9d7Smrg 8648bd1da9d7Smrg *) 8649bd1da9d7Smrg if test "$mode" = clean ; then 8650bd1da9d7Smrg noexename=$name 8651bd1da9d7Smrg case $file in 8652bd1da9d7Smrg *.exe) 865347e89262Smrg func_stripname '' '.exe' "$file" 865447e89262Smrg file=$func_stripname_result 865547e89262Smrg func_stripname '' '.exe' "$name" 865647e89262Smrg noexename=$func_stripname_result 8657bd1da9d7Smrg # $file with .exe has already been added to rmfiles, 8658bd1da9d7Smrg # add $file without .exe 8659bd1da9d7Smrg rmfiles="$rmfiles $file" 8660bd1da9d7Smrg ;; 8661bd1da9d7Smrg esac 8662bd1da9d7Smrg # Do a test to see if this is a libtool program. 866347e89262Smrg if func_ltwrapper_p "$file"; then 866447e89262Smrg if func_ltwrapper_executable_p "$file"; then 866547e89262Smrg func_ltwrapper_scriptname "$file" 866647e89262Smrg relink_command= 866747e89262Smrg func_source $func_ltwrapper_scriptname_result 866847e89262Smrg rmfiles="$rmfiles $func_ltwrapper_scriptname_result" 866947e89262Smrg else 867047e89262Smrg relink_command= 867147e89262Smrg func_source $dir/$noexename 867247e89262Smrg fi 8673bd1da9d7Smrg 8674bd1da9d7Smrg # note $name still contains .exe if it was in $file originally 8675bd1da9d7Smrg # as does the version of $file that was added into $rmfiles 8676bd1da9d7Smrg rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" 8677bd1da9d7Smrg if test "$fast_install" = yes && test -n "$relink_command"; then 8678bd1da9d7Smrg rmfiles="$rmfiles $objdir/lt-$name" 8679bd1da9d7Smrg fi 8680bd1da9d7Smrg if test "X$noexename" != "X$name" ; then 8681bd1da9d7Smrg rmfiles="$rmfiles $objdir/lt-${noexename}.c" 8682bd1da9d7Smrg fi 8683bd1da9d7Smrg fi 8684bd1da9d7Smrg fi 8685bd1da9d7Smrg ;; 8686bd1da9d7Smrg esac 868747e89262Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 8688bd1da9d7Smrg done 8689bd1da9d7Smrg objdir="$origobjdir" 8690bd1da9d7Smrg 8691bd1da9d7Smrg # Try to remove the ${objdir}s in the directories where we deleted files 8692bd1da9d7Smrg for dir in $rmdirs; do 8693bd1da9d7Smrg if test -d "$dir"; then 869447e89262Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 8695bd1da9d7Smrg fi 8696bd1da9d7Smrg done 8697bd1da9d7Smrg 8698bd1da9d7Smrg exit $exit_status 869947e89262Smrg} 8700bd1da9d7Smrg 870147e89262Smrg{ test "$mode" = uninstall || test "$mode" = clean; } && 870247e89262Smrg func_mode_uninstall ${1+"$@"} 8703bd1da9d7Smrg 870447e89262Smrgtest -z "$mode" && { 870547e89262Smrg help="$generic_help" 870647e89262Smrg func_fatal_help "you must specify a MODE" 870747e89262Smrg} 870847e89262Smrg 870947e89262Smrgtest -z "$exec_cmd" && \ 871047e89262Smrg func_fatal_help "invalid operation mode \`$mode'" 8711bd1da9d7Smrg 8712bd1da9d7Smrgif test -n "$exec_cmd"; then 871347e89262Smrg eval exec "$exec_cmd" 8714bd1da9d7Smrg exit $EXIT_FAILURE 8715bd1da9d7Smrgfi 8716bd1da9d7Smrg 871747e89262Smrgexit $exit_status 8718bd1da9d7Smrg 8719bd1da9d7Smrg 8720bd1da9d7Smrg# The TAGs below are defined such that we never get into a situation 8721bd1da9d7Smrg# in which we disable both kinds of libraries. Given conflicting 8722bd1da9d7Smrg# choices, we go for a static library, that is the most portable, 8723bd1da9d7Smrg# since we can't tell whether shared libraries were disabled because 8724bd1da9d7Smrg# the user asked for that or because the platform doesn't support 8725bd1da9d7Smrg# them. This is particularly important on AIX, because we don't 8726bd1da9d7Smrg# support having both static and shared libraries enabled at the same 8727bd1da9d7Smrg# time on that platform, so we default to a shared-only configuration. 8728bd1da9d7Smrg# If a disable-shared tag is given, we'll fallback to a static-only 8729bd1da9d7Smrg# configuration. But we'll never go from static-only to shared-only. 8730bd1da9d7Smrg 8731bd1da9d7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 873247e89262Smrgbuild_libtool_libs=no 873347e89262Smrgbuild_old_libs=yes 8734bd1da9d7Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 8735bd1da9d7Smrg 8736bd1da9d7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 873747e89262Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 8738bd1da9d7Smrg# ### END LIBTOOL TAG CONFIG: disable-static 8739bd1da9d7Smrg 8740bd1da9d7Smrg# Local Variables: 8741bd1da9d7Smrg# mode:shell-script 8742bd1da9d7Smrg# sh-indentation:2 8743bd1da9d7Smrg# End: 874447e89262Smrg# vi:sw=2 874547e89262Smrg 8746