ltmain.sh revision 25b89263
1ea133fd7Smrg# Generated from ltmain.m4sh. 2ea133fd7Smrg 325b89263Smrg# libtool (GNU libtool) 2.2.10 4ea133fd7Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 5ea133fd7Smrg 625b89263Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 725b89263Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 8ea133fd7Smrg# This is free software; see the source for copying conditions. There is NO 9ea133fd7Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10ea133fd7Smrg 11ea133fd7Smrg# GNU Libtool is free software; you can redistribute it and/or modify 12a253d6aeSmrg# it under the terms of the GNU General Public License as published by 13a253d6aeSmrg# the Free Software Foundation; either version 2 of the License, or 14a253d6aeSmrg# (at your option) any later version. 15a253d6aeSmrg# 16ea133fd7Smrg# As a special exception to the GNU General Public License, 17ea133fd7Smrg# if you distribute this file as part of a program or library that 18ea133fd7Smrg# is built using GNU Libtool, you may include this file under the 19ea133fd7Smrg# same distribution terms that you use for the rest of that program. 20ea133fd7Smrg# 21ea133fd7Smrg# GNU Libtool is distributed in the hope that it will be useful, but 22a253d6aeSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 23a253d6aeSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24a253d6aeSmrg# General Public License for more details. 25a253d6aeSmrg# 26a253d6aeSmrg# You should have received a copy of the GNU General Public License 27ea133fd7Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 28ea133fd7Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 29ea133fd7Smrg# or obtained by writing to the Free Software Foundation, Inc., 30ea133fd7Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 31ea133fd7Smrg 32ea133fd7Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 33ea133fd7Smrg# 34ea133fd7Smrg# Provide generalized library-building support services. 35a253d6aeSmrg# 3625b89263Smrg# --config show all configuration variables 3725b89263Smrg# --debug enable verbose shell tracing 3825b89263Smrg# -n, --dry-run display commands without modifying any files 3925b89263Smrg# --features display basic configuration information and exit 4025b89263Smrg# --mode=MODE use operation mode MODE 4125b89263Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 4225b89263Smrg# --quiet, --silent don't print informational messages 4325b89263Smrg# --no-quiet, --no-silent 4425b89263Smrg# print informational messages (default) 4525b89263Smrg# --tag=TAG use configuration variables from tag TAG 4625b89263Smrg# -v, --verbose print more informational messages than default 4725b89263Smrg# --no-verbose don't print the extra informational messages 4825b89263Smrg# --version print version information 4925b89263Smrg# -h, --help, --help-all print short, long, or detailed help message 50ea133fd7Smrg# 51ea133fd7Smrg# MODE must be one of the following: 52ea133fd7Smrg# 5325b89263Smrg# clean remove files from the build directory 5425b89263Smrg# compile compile a source file into a libtool object 5525b89263Smrg# execute automatically set library path, then run a program 5625b89263Smrg# finish complete the installation of libtool libraries 5725b89263Smrg# install install libraries or executables 5825b89263Smrg# link create a library or an executable 5925b89263Smrg# uninstall remove libraries from an installed directory 60ea133fd7Smrg# 6125b89263Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 6225b89263Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 63ea133fd7Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 64ea133fd7Smrg# 65ea133fd7Smrg# When reporting a bug, please describe a test case to reproduce it and 66ea133fd7Smrg# include the following information: 67ea133fd7Smrg# 6825b89263Smrg# host-triplet: $host 6925b89263Smrg# shell: $SHELL 7025b89263Smrg# compiler: $LTCC 7125b89263Smrg# compiler flags: $LTCFLAGS 7225b89263Smrg# linker: $LD (gnu? $with_gnu_ld) 7325b89263Smrg# $progname: (GNU libtool) 2.2.10 7425b89263Smrg# automake: $automake_version 7525b89263Smrg# autoconf: $autoconf_version 76ea133fd7Smrg# 77ea133fd7Smrg# Report bugs to <bug-libtool@gnu.org>. 78ea133fd7Smrg 7925b89263SmrgPROGRAM=libtool 80ea133fd7SmrgPACKAGE=libtool 8125b89263SmrgVERSION=2.2.10 82ea133fd7SmrgTIMESTAMP="" 8325b89263Smrgpackage_revision=1.3175 84ea133fd7Smrg 85ea133fd7Smrg# Be Bourne compatible 86ea133fd7Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 87ea133fd7Smrg emulate sh 88ea133fd7Smrg NULLCMD=: 89ea133fd7Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 90ea133fd7Smrg # is contrary to our usage. Disable this feature. 91ea133fd7Smrg alias -g '${1+"$@"}'='"$@"' 92ea133fd7Smrg setopt NO_GLOB_SUBST 93ea133fd7Smrgelse 94ea133fd7Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 95ea133fd7Smrgfi 96ea133fd7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 97ea133fd7SmrgDUALCASE=1; export DUALCASE # for MKS sh 98ea133fd7Smrg 9925b89263Smrg# A function that is used when there is no print builtin or printf. 10025b89263Smrgfunc_fallback_echo () 10125b89263Smrg{ 10225b89263Smrg eval 'cat <<_LTECHO_EOF 10325b89263Smrg$1 10425b89263Smrg_LTECHO_EOF' 10525b89263Smrg} 10625b89263Smrg 107ea133fd7Smrg# NLS nuisances: We save the old values to restore during execute mode. 108ea133fd7Smrglt_user_locale= 109ea133fd7Smrglt_safe_locale= 110ea133fd7Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 111ea133fd7Smrgdo 112ea133fd7Smrg eval "if test \"\${$lt_var+set}\" = set; then 113ea133fd7Smrg save_$lt_var=\$$lt_var 114ea133fd7Smrg $lt_var=C 115ea133fd7Smrg export $lt_var 116ea133fd7Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 117ea133fd7Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 118ea133fd7Smrg fi" 119ea133fd7Smrgdone 12025b89263SmrgLC_ALL=C 12125b89263SmrgLANGUAGE=C 12225b89263Smrgexport LANGUAGE LC_ALL 123ea133fd7Smrg 124ea133fd7Smrg$lt_unset CDPATH 125ea133fd7Smrg 126ea133fd7Smrg 12725b89263Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 12825b89263Smrg# is ksh but when the shell is invoked as "sh" and the current value of 12925b89263Smrg# the _XPG environment variable is not equal to 1 (one), the special 13025b89263Smrg# positional parameter $0, within a function call, is the name of the 13125b89263Smrg# function. 13225b89263Smrgprogpath="$0" 133ea133fd7Smrg 134ea133fd7Smrg 135ea133fd7Smrg 136ea133fd7Smrg: ${CP="cp -f"} 13725b89263Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 13825b89263Smrg: ${EGREP="grep -E"} 13925b89263Smrg: ${FGREP="grep -F"} 14025b89263Smrg: ${GREP="grep"} 141ea133fd7Smrg: ${LN_S="ln -s"} 142ea133fd7Smrg: ${MAKE="make"} 143ea133fd7Smrg: ${MKDIR="mkdir"} 144ea133fd7Smrg: ${MV="mv -f"} 145ea133fd7Smrg: ${RM="rm -f"} 14625b89263Smrg: ${SED="sed"} 147ea133fd7Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 148ea133fd7Smrg: ${Xsed="$SED -e 1s/^X//"} 149a253d6aeSmrg 150ea133fd7Smrg# Global variables: 151ea133fd7SmrgEXIT_SUCCESS=0 152ea133fd7SmrgEXIT_FAILURE=1 153ea133fd7SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 154ea133fd7SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 155ea133fd7Smrg 156ea133fd7Smrgexit_status=$EXIT_SUCCESS 157ea133fd7Smrg 158ea133fd7Smrg# Make sure IFS has a sensible default 159ea133fd7Smrglt_nl=' 160ea133fd7Smrg' 161ea133fd7SmrgIFS=" $lt_nl" 162ea133fd7Smrg 163ea133fd7Smrgdirname="s,/[^/]*$,," 164ea133fd7Smrgbasename="s,^.*/,," 165ea133fd7Smrg 166ea133fd7Smrg# func_dirname_and_basename file append nondir_replacement 167ea133fd7Smrg# perform func_basename and func_dirname in a single function 168ea133fd7Smrg# call: 169ea133fd7Smrg# dirname: Compute the dirname of FILE. If nonempty, 170ea133fd7Smrg# add APPEND to the result, otherwise set result 171ea133fd7Smrg# to NONDIR_REPLACEMENT. 172ea133fd7Smrg# value returned in "$func_dirname_result" 173ea133fd7Smrg# basename: Compute filename of FILE. 174ea133fd7Smrg# value retuned in "$func_basename_result" 175ea133fd7Smrg# Implementation must be kept synchronized with func_dirname 176ea133fd7Smrg# and func_basename. For efficiency, we do not delegate to 177ea133fd7Smrg# those functions but instead duplicate the functionality here. 178ea133fd7Smrgfunc_dirname_and_basename () 179ea133fd7Smrg{ 180ea133fd7Smrg # Extract subdirectory from the argument. 18125b89263Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 182ea133fd7Smrg if test "X$func_dirname_result" = "X${1}"; then 183ea133fd7Smrg func_dirname_result="${3}" 184ea133fd7Smrg else 185ea133fd7Smrg func_dirname_result="$func_dirname_result${2}" 186ea133fd7Smrg fi 18725b89263Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 188ea133fd7Smrg} 189ea133fd7Smrg 190ea133fd7Smrg# Generated shell functions inserted here. 191a253d6aeSmrg 19225b89263Smrg# These SED scripts presuppose an absolute path with a trailing slash. 19325b89263Smrgpathcar='s,^/\([^/]*\).*$,\1,' 19425b89263Smrgpathcdr='s,^/[^/]*,,' 19525b89263Smrgremovedotparts=':dotsl 19625b89263Smrg s@/\./@/@g 19725b89263Smrg t dotsl 19825b89263Smrg s,/\.$,/,' 19925b89263Smrgcollapseslashes='s@/\{1,\}@/@g' 20025b89263Smrgfinalslash='s,/*$,/,' 20125b89263Smrg 20225b89263Smrg# func_normal_abspath PATH 20325b89263Smrg# Remove doubled-up and trailing slashes, "." path components, 20425b89263Smrg# and cancel out any ".." path components in PATH after making 20525b89263Smrg# it an absolute path. 20625b89263Smrg# value returned in "$func_normal_abspath_result" 20725b89263Smrgfunc_normal_abspath () 20825b89263Smrg{ 20925b89263Smrg # Start from root dir and reassemble the path. 21025b89263Smrg func_normal_abspath_result= 21125b89263Smrg func_normal_abspath_tpath=$1 21225b89263Smrg func_normal_abspath_altnamespace= 21325b89263Smrg case $func_normal_abspath_tpath in 21425b89263Smrg "") 21525b89263Smrg # Empty path, that just means $cwd. 21625b89263Smrg func_stripname '' '/' "`pwd`" 21725b89263Smrg func_normal_abspath_result=$func_stripname_result 21825b89263Smrg return 21925b89263Smrg ;; 22025b89263Smrg # The next three entries are used to spot a run of precisely 22125b89263Smrg # two leading slashes without using negated character classes; 22225b89263Smrg # we take advantage of case's first-match behaviour. 22325b89263Smrg ///*) 22425b89263Smrg # Unusual form of absolute path, do nothing. 22525b89263Smrg ;; 22625b89263Smrg //*) 22725b89263Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 22825b89263Smrg # and for example Cygwin uses it to access remote file shares 22925b89263Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 23025b89263Smrg func_normal_abspath_altnamespace=/ 23125b89263Smrg ;; 23225b89263Smrg /*) 23325b89263Smrg # Absolute path, do nothing. 23425b89263Smrg ;; 23525b89263Smrg *) 23625b89263Smrg # Relative path, prepend $cwd. 23725b89263Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 23825b89263Smrg ;; 23925b89263Smrg esac 24025b89263Smrg # Cancel out all the simple stuff to save iterations. We also want 24125b89263Smrg # the path to end with a slash for ease of parsing, so make sure 24225b89263Smrg # there is one (and only one) here. 24325b89263Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 24425b89263Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 24525b89263Smrg while :; do 24625b89263Smrg # Processed it all yet? 24725b89263Smrg if test "$func_normal_abspath_tpath" = / ; then 24825b89263Smrg # If we ascended to the root using ".." the result may be empty now. 24925b89263Smrg if test -z "$func_normal_abspath_result" ; then 25025b89263Smrg func_normal_abspath_result=/ 25125b89263Smrg fi 25225b89263Smrg break 25325b89263Smrg fi 25425b89263Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 25525b89263Smrg -e "$pathcar"` 25625b89263Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 25725b89263Smrg -e "$pathcdr"` 25825b89263Smrg # Figure out what to do with it 25925b89263Smrg case $func_normal_abspath_tcomponent in 26025b89263Smrg "") 26125b89263Smrg # Trailing empty path component, ignore it. 26225b89263Smrg ;; 26325b89263Smrg ..) 26425b89263Smrg # Parent dir; strip last assembled component from result. 26525b89263Smrg func_dirname "$func_normal_abspath_result" 26625b89263Smrg func_normal_abspath_result=$func_dirname_result 26725b89263Smrg ;; 26825b89263Smrg *) 26925b89263Smrg # Actual path component, append it. 27025b89263Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 27125b89263Smrg ;; 27225b89263Smrg esac 27325b89263Smrg done 27425b89263Smrg # Restore leading double-slash if one was found on entry. 27525b89263Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 27625b89263Smrg} 27725b89263Smrg 27825b89263Smrg# func_relative_path SRCDIR DSTDIR 27925b89263Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 28025b89263Smrg# slash if non-empty, suitable for immediately appending a filename 28125b89263Smrg# without needing to append a separator. 28225b89263Smrg# value returned in "$func_relative_path_result" 28325b89263Smrgfunc_relative_path () 28425b89263Smrg{ 28525b89263Smrg func_relative_path_result= 28625b89263Smrg func_normal_abspath "$1" 28725b89263Smrg func_relative_path_tlibdir=$func_normal_abspath_result 28825b89263Smrg func_normal_abspath "$2" 28925b89263Smrg func_relative_path_tbindir=$func_normal_abspath_result 29025b89263Smrg 29125b89263Smrg # Ascend the tree starting from libdir 29225b89263Smrg while :; do 29325b89263Smrg # check if we have found a prefix of bindir 29425b89263Smrg case $func_relative_path_tbindir in 29525b89263Smrg $func_relative_path_tlibdir) 29625b89263Smrg # found an exact match 29725b89263Smrg func_relative_path_tcancelled= 29825b89263Smrg break 29925b89263Smrg ;; 30025b89263Smrg $func_relative_path_tlibdir*) 30125b89263Smrg # found a matching prefix 30225b89263Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 30325b89263Smrg func_relative_path_tcancelled=$func_stripname_result 30425b89263Smrg if test -z "$func_relative_path_result"; then 30525b89263Smrg func_relative_path_result=. 30625b89263Smrg fi 30725b89263Smrg break 30825b89263Smrg ;; 30925b89263Smrg *) 31025b89263Smrg func_dirname $func_relative_path_tlibdir 31125b89263Smrg func_relative_path_tlibdir=${func_dirname_result} 31225b89263Smrg if test "x$func_relative_path_tlibdir" = x ; then 31325b89263Smrg # Have to descend all the way to the root! 31425b89263Smrg func_relative_path_result=../$func_relative_path_result 31525b89263Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 31625b89263Smrg break 31725b89263Smrg fi 31825b89263Smrg func_relative_path_result=../$func_relative_path_result 31925b89263Smrg ;; 32025b89263Smrg esac 32125b89263Smrg done 32225b89263Smrg 32325b89263Smrg # Now calculate path; take care to avoid doubling-up slashes. 32425b89263Smrg func_stripname '' '/' "$func_relative_path_result" 32525b89263Smrg func_relative_path_result=$func_stripname_result 32625b89263Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 32725b89263Smrg if test "x$func_stripname_result" != x ; then 32825b89263Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 32925b89263Smrg fi 33025b89263Smrg 33125b89263Smrg # Normalisation. If bindir is libdir, return empty string, 33225b89263Smrg # else relative path ending with a slash; either way, target 33325b89263Smrg # file name can be directly appended. 33425b89263Smrg if test ! -z "$func_relative_path_result"; then 33525b89263Smrg func_stripname './' '' "$func_relative_path_result/" 33625b89263Smrg func_relative_path_result=$func_stripname_result 33725b89263Smrg fi 33825b89263Smrg} 339a253d6aeSmrg 340a253d6aeSmrg# The name of this program: 341ea133fd7Smrgfunc_dirname_and_basename "$progpath" 342ea133fd7Smrgprogname=$func_basename_result 343a253d6aeSmrg 344ea133fd7Smrg# Make sure we have an absolute path for reexecution: 345ea133fd7Smrgcase $progpath in 346ea133fd7Smrg [\\/]*|[A-Za-z]:\\*) ;; 347ea133fd7Smrg *[\\/]*) 348ea133fd7Smrg progdir=$func_dirname_result 349ea133fd7Smrg progdir=`cd "$progdir" && pwd` 350ea133fd7Smrg progpath="$progdir/$progname" 351ea133fd7Smrg ;; 352ea133fd7Smrg *) 353ea133fd7Smrg save_IFS="$IFS" 354ea133fd7Smrg IFS=: 355ea133fd7Smrg for progdir in $PATH; do 356ea133fd7Smrg IFS="$save_IFS" 357ea133fd7Smrg test -x "$progdir/$progname" && break 358ea133fd7Smrg done 359ea133fd7Smrg IFS="$save_IFS" 360ea133fd7Smrg test -n "$progdir" || progdir=`pwd` 361ea133fd7Smrg progpath="$progdir/$progname" 362ea133fd7Smrg ;; 363ea133fd7Smrgesac 364a253d6aeSmrg 365ea133fd7Smrg# Sed substitution that helps us do robust quoting. It backslashifies 366ea133fd7Smrg# metacharacters that are still active within double-quoted strings. 367ea133fd7SmrgXsed="${SED}"' -e 1s/^X//' 368ea133fd7Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 369ea133fd7Smrg 370ea133fd7Smrg# Same as above, but do not quote variable references. 371ea133fd7Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 372ea133fd7Smrg 373ea133fd7Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 374ea133fd7Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 375ea133fd7Smrg# in input to double_quote_subst, that '$' was protected from expansion. 376ea133fd7Smrg# Since each input `\' is now two `\'s, look for any number of runs of 377ea133fd7Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 378ea133fd7Smrgbs='\\' 379ea133fd7Smrgbs2='\\\\' 380ea133fd7Smrgbs4='\\\\\\\\' 381ea133fd7Smrgdollar='\$' 382ea133fd7Smrgsed_double_backslash="\ 383ea133fd7Smrg s/$bs4/&\\ 384ea133fd7Smrg/g 385ea133fd7Smrg s/^$bs2$dollar/$bs&/ 386ea133fd7Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 387ea133fd7Smrg s/\n//g" 388ea133fd7Smrg 389ea133fd7Smrg# Standard options: 390ea133fd7Smrgopt_dry_run=false 391ea133fd7Smrgopt_help=false 392ea133fd7Smrgopt_quiet=false 393ea133fd7Smrgopt_verbose=false 394ea133fd7Smrgopt_warning=: 395ea133fd7Smrg 396ea133fd7Smrg# func_echo arg... 397ea133fd7Smrg# Echo program name prefixed message, along with the current mode 398ea133fd7Smrg# name if it has been set yet. 399ea133fd7Smrgfunc_echo () 400ea133fd7Smrg{ 401ea133fd7Smrg $ECHO "$progname${mode+: }$mode: $*" 402ea133fd7Smrg} 403a253d6aeSmrg 404ea133fd7Smrg# func_verbose arg... 405ea133fd7Smrg# Echo program name prefixed message in verbose mode only. 406ea133fd7Smrgfunc_verbose () 407ea133fd7Smrg{ 408ea133fd7Smrg $opt_verbose && func_echo ${1+"$@"} 409a253d6aeSmrg 410ea133fd7Smrg # A bug in bash halts the script if the last line of a function 411ea133fd7Smrg # fails when set -e is in force, so we need another command to 412ea133fd7Smrg # work around that: 413ea133fd7Smrg : 414ea133fd7Smrg} 415a253d6aeSmrg 41625b89263Smrg# func_echo_all arg... 41725b89263Smrg# Invoke $ECHO with all args, space-separated. 41825b89263Smrgfunc_echo_all () 41925b89263Smrg{ 42025b89263Smrg $ECHO "$*" 42125b89263Smrg} 42225b89263Smrg 423ea133fd7Smrg# func_error arg... 424ea133fd7Smrg# Echo program name prefixed message to standard error. 425ea133fd7Smrgfunc_error () 426ea133fd7Smrg{ 427ea133fd7Smrg $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 428ea133fd7Smrg} 429a253d6aeSmrg 430ea133fd7Smrg# func_warning arg... 431ea133fd7Smrg# Echo program name prefixed warning message to standard error. 432ea133fd7Smrgfunc_warning () 433ea133fd7Smrg{ 434ea133fd7Smrg $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 435a253d6aeSmrg 436ea133fd7Smrg # bash bug again: 437ea133fd7Smrg : 438ea133fd7Smrg} 439a253d6aeSmrg 440ea133fd7Smrg# func_fatal_error arg... 441ea133fd7Smrg# Echo program name prefixed message to standard error, and exit. 442ea133fd7Smrgfunc_fatal_error () 443ea133fd7Smrg{ 444ea133fd7Smrg func_error ${1+"$@"} 445ea133fd7Smrg exit $EXIT_FAILURE 446ea133fd7Smrg} 447a253d6aeSmrg 448ea133fd7Smrg# func_fatal_help arg... 449ea133fd7Smrg# Echo program name prefixed message to standard error, followed by 450ea133fd7Smrg# a help hint, and exit. 451ea133fd7Smrgfunc_fatal_help () 452ea133fd7Smrg{ 453ea133fd7Smrg func_error ${1+"$@"} 454ea133fd7Smrg func_fatal_error "$help" 455ea133fd7Smrg} 456ea133fd7Smrghelp="Try \`$progname --help' for more information." ## default 457a253d6aeSmrg 458a253d6aeSmrg 459ea133fd7Smrg# func_grep expression filename 460ea133fd7Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 461ea133fd7Smrgfunc_grep () 462ea133fd7Smrg{ 463ea133fd7Smrg $GREP "$1" "$2" >/dev/null 2>&1 464ea133fd7Smrg} 465ea133fd7Smrg 466ea133fd7Smrg 467ea133fd7Smrg# func_mkdir_p directory-path 468ea133fd7Smrg# Make sure the entire path to DIRECTORY-PATH is available. 469ea133fd7Smrgfunc_mkdir_p () 470ea133fd7Smrg{ 471ea133fd7Smrg my_directory_path="$1" 472ea133fd7Smrg my_dir_list= 473ea133fd7Smrg 474ea133fd7Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 475ea133fd7Smrg 476ea133fd7Smrg # Protect directory names starting with `-' 477ea133fd7Smrg case $my_directory_path in 478ea133fd7Smrg -*) my_directory_path="./$my_directory_path" ;; 479ea133fd7Smrg esac 480ea133fd7Smrg 481ea133fd7Smrg # While some portion of DIR does not yet exist... 482ea133fd7Smrg while test ! -d "$my_directory_path"; do 483ea133fd7Smrg # ...make a list in topmost first order. Use a colon delimited 484ea133fd7Smrg # list incase some portion of path contains whitespace. 485ea133fd7Smrg my_dir_list="$my_directory_path:$my_dir_list" 486ea133fd7Smrg 487ea133fd7Smrg # If the last portion added has no slash in it, the list is done 488ea133fd7Smrg case $my_directory_path in */*) ;; *) break ;; esac 489ea133fd7Smrg 490ea133fd7Smrg # ...otherwise throw away the child directory and loop 49125b89263Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 492ea133fd7Smrg done 49325b89263Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 494ea133fd7Smrg 495ea133fd7Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 496ea133fd7Smrg for my_dir in $my_dir_list; do 497ea133fd7Smrg IFS="$save_mkdir_p_IFS" 498ea133fd7Smrg # mkdir can fail with a `File exist' error if two processes 499ea133fd7Smrg # try to create one of the directories concurrently. Don't 500ea133fd7Smrg # stop in that case! 501ea133fd7Smrg $MKDIR "$my_dir" 2>/dev/null || : 502ea133fd7Smrg done 503ea133fd7Smrg IFS="$save_mkdir_p_IFS" 504ea133fd7Smrg 505ea133fd7Smrg # Bail out if we (or some other process) failed to create a directory. 506ea133fd7Smrg test -d "$my_directory_path" || \ 507ea133fd7Smrg func_fatal_error "Failed to create \`$1'" 508ea133fd7Smrg fi 509ea133fd7Smrg} 510a253d6aeSmrg 511a253d6aeSmrg 512a253d6aeSmrg# func_mktempdir [string] 513a253d6aeSmrg# Make a temporary directory that won't clash with other running 514a253d6aeSmrg# libtool processes, and avoids race conditions if possible. If 515a253d6aeSmrg# given, STRING is the basename for that directory. 516a253d6aeSmrgfunc_mktempdir () 517a253d6aeSmrg{ 518a253d6aeSmrg my_template="${TMPDIR-/tmp}/${1-$progname}" 519a253d6aeSmrg 520ea133fd7Smrg if test "$opt_dry_run" = ":"; then 521a253d6aeSmrg # Return a directory name, but don't create it in dry-run mode 522a253d6aeSmrg my_tmpdir="${my_template}-$$" 523a253d6aeSmrg else 524a253d6aeSmrg 525a253d6aeSmrg # If mktemp works, use that first and foremost 526a253d6aeSmrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 527a253d6aeSmrg 528a253d6aeSmrg if test ! -d "$my_tmpdir"; then 529ea133fd7Smrg # Failing that, at least try and use $RANDOM to avoid a race 530ea133fd7Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 531a253d6aeSmrg 532ea133fd7Smrg save_mktempdir_umask=`umask` 533ea133fd7Smrg umask 0077 534ea133fd7Smrg $MKDIR "$my_tmpdir" 535ea133fd7Smrg umask $save_mktempdir_umask 536a253d6aeSmrg fi 537a253d6aeSmrg 538a253d6aeSmrg # If we're not in dry-run mode, bomb out on failure 539ea133fd7Smrg test -d "$my_tmpdir" || \ 540ea133fd7Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 541a253d6aeSmrg fi 542a253d6aeSmrg 54325b89263Smrg $ECHO "$my_tmpdir" 544a253d6aeSmrg} 545a253d6aeSmrg 546a253d6aeSmrg 547ea133fd7Smrg# func_quote_for_eval arg 548ea133fd7Smrg# Aesthetically quote ARG to be evaled later. 549ea133fd7Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 550ea133fd7Smrg# is double-quoted, suitable for a subsequent eval, whereas 551ea133fd7Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 552ea133fd7Smrg# which are still active within double quotes backslashified. 553ea133fd7Smrgfunc_quote_for_eval () 554a253d6aeSmrg{ 555ea133fd7Smrg case $1 in 556ea133fd7Smrg *[\\\`\"\$]*) 55725b89263Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 558ea133fd7Smrg *) 559ea133fd7Smrg func_quote_for_eval_unquoted_result="$1" ;; 560ea133fd7Smrg esac 561ea133fd7Smrg 562ea133fd7Smrg case $func_quote_for_eval_unquoted_result in 563ea133fd7Smrg # Double-quote args containing shell metacharacters to delay 564ea133fd7Smrg # word splitting, command substitution and and variable 565ea133fd7Smrg # expansion for a subsequent eval. 566ea133fd7Smrg # Many Bourne shells cannot handle close brackets correctly 567ea133fd7Smrg # in scan sets, so we specify it separately. 568ea133fd7Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 569ea133fd7Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 570ea133fd7Smrg ;; 571ea133fd7Smrg *) 572ea133fd7Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 573a253d6aeSmrg esac 574a253d6aeSmrg} 575a253d6aeSmrg 576a253d6aeSmrg 577ea133fd7Smrg# func_quote_for_expand arg 578ea133fd7Smrg# Aesthetically quote ARG to be evaled later; same as above, 579ea133fd7Smrg# but do not quote variable references. 580ea133fd7Smrgfunc_quote_for_expand () 581a253d6aeSmrg{ 582ea133fd7Smrg case $1 in 583ea133fd7Smrg *[\\\`\"]*) 58425b89263Smrg my_arg=`$ECHO "$1" | $SED \ 585ea133fd7Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 586a253d6aeSmrg *) 587ea133fd7Smrg my_arg="$1" ;; 588ea133fd7Smrg esac 589ea133fd7Smrg 590ea133fd7Smrg case $my_arg in 591ea133fd7Smrg # Double-quote args containing shell metacharacters to delay 592ea133fd7Smrg # word splitting and command substitution for a subsequent eval. 593ea133fd7Smrg # Many Bourne shells cannot handle close brackets correctly 594ea133fd7Smrg # in scan sets, so we specify it separately. 595ea133fd7Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 596ea133fd7Smrg my_arg="\"$my_arg\"" 597ea133fd7Smrg ;; 598ea133fd7Smrg esac 599ea133fd7Smrg 600ea133fd7Smrg func_quote_for_expand_result="$my_arg" 601a253d6aeSmrg} 602a253d6aeSmrg 603a253d6aeSmrg 604ea133fd7Smrg# func_show_eval cmd [fail_exp] 605ea133fd7Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 606ea133fd7Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 607ea133fd7Smrg# is given, then evaluate it. 608ea133fd7Smrgfunc_show_eval () 609a253d6aeSmrg{ 610ea133fd7Smrg my_cmd="$1" 611ea133fd7Smrg my_fail_exp="${2-:}" 612a253d6aeSmrg 613ea133fd7Smrg ${opt_silent-false} || { 614ea133fd7Smrg func_quote_for_expand "$my_cmd" 615ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 616ea133fd7Smrg } 617ea133fd7Smrg 618ea133fd7Smrg if ${opt_dry_run-false}; then :; else 619ea133fd7Smrg eval "$my_cmd" 620ea133fd7Smrg my_status=$? 621ea133fd7Smrg if test "$my_status" -eq 0; then :; else 622ea133fd7Smrg eval "(exit $my_status); $my_fail_exp" 623ea133fd7Smrg fi 624a253d6aeSmrg fi 625a253d6aeSmrg} 626a253d6aeSmrg 627ea133fd7Smrg 628ea133fd7Smrg# func_show_eval_locale cmd [fail_exp] 629ea133fd7Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 630ea133fd7Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 631ea133fd7Smrg# is given, then evaluate it. Use the saved locale for evaluation. 632ea133fd7Smrgfunc_show_eval_locale () 633a253d6aeSmrg{ 634ea133fd7Smrg my_cmd="$1" 635ea133fd7Smrg my_fail_exp="${2-:}" 636a253d6aeSmrg 637ea133fd7Smrg ${opt_silent-false} || { 638ea133fd7Smrg func_quote_for_expand "$my_cmd" 639ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 640ea133fd7Smrg } 641ea133fd7Smrg 642ea133fd7Smrg if ${opt_dry_run-false}; then :; else 643ea133fd7Smrg eval "$lt_user_locale 644ea133fd7Smrg $my_cmd" 645ea133fd7Smrg my_status=$? 646ea133fd7Smrg eval "$lt_safe_locale" 647ea133fd7Smrg if test "$my_status" -eq 0; then :; else 648ea133fd7Smrg eval "(exit $my_status); $my_fail_exp" 649a253d6aeSmrg fi 650ea133fd7Smrg fi 651a253d6aeSmrg} 652a253d6aeSmrg 653a253d6aeSmrg 654ea133fd7Smrg# func_version 655ea133fd7Smrg# Echo version message to standard output and exit. 656ea133fd7Smrgfunc_version () 657ea133fd7Smrg{ 65825b89263Smrg $SED -n '/(C)/!b go 65925b89263Smrg :more 66025b89263Smrg /\./!{ 66125b89263Smrg N 66225b89263Smrg s/\n# / / 66325b89263Smrg b more 66425b89263Smrg } 66525b89263Smrg :go 66625b89263Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 667ea133fd7Smrg s/^# // 668ea133fd7Smrg s/^# *$// 669ea133fd7Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 670ea133fd7Smrg p 671ea133fd7Smrg }' < "$progpath" 672ea133fd7Smrg exit $? 673ea133fd7Smrg} 674ea133fd7Smrg 675ea133fd7Smrg# func_usage 676ea133fd7Smrg# Echo short help message to standard output and exit. 677ea133fd7Smrgfunc_usage () 678ea133fd7Smrg{ 67925b89263Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 680ea133fd7Smrg s/^# // 681ea133fd7Smrg s/^# *$// 682ea133fd7Smrg s/\$progname/'$progname'/ 683ea133fd7Smrg p 684ea133fd7Smrg }' < "$progpath" 68525b89263Smrg echo 686ea133fd7Smrg $ECHO "run \`$progname --help | more' for full usage" 687ea133fd7Smrg exit $? 688ea133fd7Smrg} 689ea133fd7Smrg 69025b89263Smrg# func_help [NOEXIT] 69125b89263Smrg# Echo long help message to standard output and exit, 69225b89263Smrg# unless 'noexit' is passed as argument. 693ea133fd7Smrgfunc_help () 694ea133fd7Smrg{ 695ea133fd7Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 696ea133fd7Smrg s/^# // 697ea133fd7Smrg s/^# *$// 698ea133fd7Smrg s*\$progname*'$progname'* 699ea133fd7Smrg s*\$host*'"$host"'* 700ea133fd7Smrg s*\$SHELL*'"$SHELL"'* 701ea133fd7Smrg s*\$LTCC*'"$LTCC"'* 702ea133fd7Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 703ea133fd7Smrg s*\$LD*'"$LD"'* 704ea133fd7Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 705ea133fd7Smrg s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ 706ea133fd7Smrg s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ 707ea133fd7Smrg p 708ea133fd7Smrg }' < "$progpath" 70925b89263Smrg ret=$? 71025b89263Smrg if test -z "$1"; then 71125b89263Smrg exit $ret 71225b89263Smrg fi 713ea133fd7Smrg} 714ea133fd7Smrg 715ea133fd7Smrg# func_missing_arg argname 716ea133fd7Smrg# Echo program name prefixed message to standard error and set global 717ea133fd7Smrg# exit_cmd. 718ea133fd7Smrgfunc_missing_arg () 719ea133fd7Smrg{ 72025b89263Smrg func_error "missing argument for $1." 721ea133fd7Smrg exit_cmd=exit 722ea133fd7Smrg} 723ea133fd7Smrg 724ea133fd7Smrgexit_cmd=: 725ea133fd7Smrg 726ea133fd7Smrg 727ea133fd7Smrg 728ea133fd7Smrg 729ea133fd7Smrg 730a253d6aeSmrg 731ea133fd7Smrgmagic="%%%MAGIC variable%%%" 732ea133fd7Smrgmagic_exe="%%%MAGIC EXE variable%%%" 733a253d6aeSmrg 734ea133fd7Smrg# Global variables. 735ea133fd7Smrg# $mode is unset 736ea133fd7Smrgnonopt= 737ea133fd7Smrgexecute_dlfiles= 738ea133fd7Smrgpreserve_args= 739ea133fd7Smrglo2o="s/\\.lo\$/.${objext}/" 740ea133fd7Smrgo2lo="s/\\.${objext}\$/.lo/" 741ea133fd7Smrgextracted_archives= 742ea133fd7Smrgextracted_serial=0 743a253d6aeSmrg 744ea133fd7Smrgopt_dry_run=false 745ea133fd7Smrgopt_duplicate_deps=false 746ea133fd7Smrgopt_silent=false 747ea133fd7Smrgopt_debug=: 748a253d6aeSmrg 749ea133fd7Smrg# If this variable is set in any of the actions, the command in it 750ea133fd7Smrg# will be execed at the end. This prevents here-documents from being 751ea133fd7Smrg# left over by shells. 752ea133fd7Smrgexec_cmd= 753a253d6aeSmrg 754ea133fd7Smrg# func_fatal_configuration arg... 755ea133fd7Smrg# Echo program name prefixed message to standard error, followed by 756ea133fd7Smrg# a configuration failure hint, and exit. 757ea133fd7Smrgfunc_fatal_configuration () 758ea133fd7Smrg{ 759ea133fd7Smrg func_error ${1+"$@"} 760ea133fd7Smrg func_error "See the $PACKAGE documentation for more information." 761ea133fd7Smrg func_fatal_error "Fatal configuration error." 762ea133fd7Smrg} 763ea133fd7Smrg 764ea133fd7Smrg 765ea133fd7Smrg# func_config 766ea133fd7Smrg# Display the configuration for all the tags in this script. 767ea133fd7Smrgfunc_config () 768ea133fd7Smrg{ 769ea133fd7Smrg re_begincf='^# ### BEGIN LIBTOOL' 770ea133fd7Smrg re_endcf='^# ### END LIBTOOL' 771ea133fd7Smrg 772ea133fd7Smrg # Default configuration. 773ea133fd7Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 774a253d6aeSmrg 775a253d6aeSmrg # Now print the configurations for the tags. 776a253d6aeSmrg for tagname in $taglist; do 777ea133fd7Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 778a253d6aeSmrg done 779a253d6aeSmrg 780ea133fd7Smrg exit $? 781ea133fd7Smrg} 782a253d6aeSmrg 783ea133fd7Smrg# func_features 784ea133fd7Smrg# Display the features supported by this script. 785ea133fd7Smrgfunc_features () 786ea133fd7Smrg{ 78725b89263Smrg echo "host: $host" 788a253d6aeSmrg if test "$build_libtool_libs" = yes; then 78925b89263Smrg echo "enable shared libraries" 790a253d6aeSmrg else 79125b89263Smrg echo "disable shared libraries" 792a253d6aeSmrg fi 793a253d6aeSmrg if test "$build_old_libs" = yes; then 79425b89263Smrg echo "enable static libraries" 795a253d6aeSmrg else 79625b89263Smrg echo "disable static libraries" 797a253d6aeSmrg fi 798ea133fd7Smrg 799a253d6aeSmrg exit $? 800ea133fd7Smrg} 801ea133fd7Smrg 802ea133fd7Smrg# func_enable_tag tagname 803ea133fd7Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 804ea133fd7Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 805ea133fd7Smrg# variable here. 806ea133fd7Smrgfunc_enable_tag () 807ea133fd7Smrg{ 808ea133fd7Smrg # Global variable: 809ea133fd7Smrg tagname="$1" 810a253d6aeSmrg 811ea133fd7Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 812ea133fd7Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 813ea133fd7Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 814a253d6aeSmrg 815ea133fd7Smrg # Validate tagname. 816ea133fd7Smrg case $tagname in 817ea133fd7Smrg *[!-_A-Za-z0-9,/]*) 818ea133fd7Smrg func_fatal_error "invalid tag name: $tagname" 819ea133fd7Smrg ;; 820ea133fd7Smrg esac 821a253d6aeSmrg 822ea133fd7Smrg # Don't test for the "default" C tag, as we know it's 823ea133fd7Smrg # there but not specially marked. 824ea133fd7Smrg case $tagname in 825ea133fd7Smrg CC) ;; 826ea133fd7Smrg *) 827ea133fd7Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 828ea133fd7Smrg taglist="$taglist $tagname" 829ea133fd7Smrg 830ea133fd7Smrg # Evaluate the configuration. Be careful to quote the path 831ea133fd7Smrg # and the sed script, to avoid splitting on whitespace, but 832ea133fd7Smrg # also don't use non-portable quotes within backquotes within 833ea133fd7Smrg # quotes we have to do it in 2 steps: 834ea133fd7Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 835ea133fd7Smrg eval "$extractedcf" 836ea133fd7Smrg else 837ea133fd7Smrg func_error "ignoring unknown tag $tagname" 838ea133fd7Smrg fi 839ea133fd7Smrg ;; 840ea133fd7Smrg esac 841ea133fd7Smrg} 842a253d6aeSmrg 843ea133fd7Smrg# Parse options once, thoroughly. This comes as soon as possible in 844ea133fd7Smrg# the script to make things like `libtool --version' happen quickly. 845ea133fd7Smrg{ 846a253d6aeSmrg 847ea133fd7Smrg # Shorthand for --mode=foo, only valid as the first argument 848ea133fd7Smrg case $1 in 849ea133fd7Smrg clean|clea|cle|cl) 850ea133fd7Smrg shift; set dummy --mode clean ${1+"$@"}; shift 851a253d6aeSmrg ;; 852ea133fd7Smrg compile|compil|compi|comp|com|co|c) 853ea133fd7Smrg shift; set dummy --mode compile ${1+"$@"}; shift 854a253d6aeSmrg ;; 855ea133fd7Smrg execute|execut|execu|exec|exe|ex|e) 856ea133fd7Smrg shift; set dummy --mode execute ${1+"$@"}; shift 857a253d6aeSmrg ;; 858ea133fd7Smrg finish|finis|fini|fin|fi|f) 859ea133fd7Smrg shift; set dummy --mode finish ${1+"$@"}; shift 860a253d6aeSmrg ;; 861ea133fd7Smrg install|instal|insta|inst|ins|in|i) 862ea133fd7Smrg shift; set dummy --mode install ${1+"$@"}; shift 863ea133fd7Smrg ;; 864ea133fd7Smrg link|lin|li|l) 865ea133fd7Smrg shift; set dummy --mode link ${1+"$@"}; shift 866ea133fd7Smrg ;; 867ea133fd7Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 868ea133fd7Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 869a253d6aeSmrg ;; 870a253d6aeSmrg esac 871a253d6aeSmrg 872ea133fd7Smrg # Parse non-mode specific arguments: 873ea133fd7Smrg while test "$#" -gt 0; do 874ea133fd7Smrg opt="$1" 875ea133fd7Smrg shift 876a253d6aeSmrg 877ea133fd7Smrg case $opt in 878ea133fd7Smrg --config) func_config ;; 879a253d6aeSmrg 880ea133fd7Smrg --debug) preserve_args="$preserve_args $opt" 881ea133fd7Smrg func_echo "enabling shell trace mode" 882ea133fd7Smrg opt_debug='set -x' 883ea133fd7Smrg $opt_debug 884ea133fd7Smrg ;; 885a253d6aeSmrg 886ea133fd7Smrg -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break 887ea133fd7Smrg execute_dlfiles="$execute_dlfiles $1" 888ea133fd7Smrg shift 889ea133fd7Smrg ;; 890a253d6aeSmrg 891ea133fd7Smrg --dry-run | -n) opt_dry_run=: ;; 892ea133fd7Smrg --features) func_features ;; 893ea133fd7Smrg --finish) mode="finish" ;; 894ea133fd7Smrg 895ea133fd7Smrg --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break 896ea133fd7Smrg case $1 in 897ea133fd7Smrg # Valid mode arguments: 898ea133fd7Smrg clean) ;; 899ea133fd7Smrg compile) ;; 900ea133fd7Smrg execute) ;; 901ea133fd7Smrg finish) ;; 902ea133fd7Smrg install) ;; 903ea133fd7Smrg link) ;; 904ea133fd7Smrg relink) ;; 905ea133fd7Smrg uninstall) ;; 906ea133fd7Smrg 907ea133fd7Smrg # Catch anything else as an error 908ea133fd7Smrg *) func_error "invalid argument for $opt" 909ea133fd7Smrg exit_cmd=exit 910ea133fd7Smrg break 911ea133fd7Smrg ;; 912ea133fd7Smrg esac 913ea133fd7Smrg 914ea133fd7Smrg mode="$1" 915ea133fd7Smrg shift 916ea133fd7Smrg ;; 917ea133fd7Smrg 918ea133fd7Smrg --preserve-dup-deps) 919ea133fd7Smrg opt_duplicate_deps=: ;; 920ea133fd7Smrg 921ea133fd7Smrg --quiet|--silent) preserve_args="$preserve_args $opt" 922ea133fd7Smrg opt_silent=: 92325b89263Smrg opt_verbose=false 92425b89263Smrg ;; 92525b89263Smrg 92625b89263Smrg --no-quiet|--no-silent) 92725b89263Smrg preserve_args="$preserve_args $opt" 92825b89263Smrg opt_silent=false 929ea133fd7Smrg ;; 930ea133fd7Smrg 931ea133fd7Smrg --verbose| -v) preserve_args="$preserve_args $opt" 932ea133fd7Smrg opt_silent=false 93325b89263Smrg opt_verbose=: 93425b89263Smrg ;; 93525b89263Smrg 93625b89263Smrg --no-verbose) preserve_args="$preserve_args $opt" 93725b89263Smrg opt_verbose=false 938ea133fd7Smrg ;; 939ea133fd7Smrg 940ea133fd7Smrg --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break 941ea133fd7Smrg preserve_args="$preserve_args $opt $1" 942ea133fd7Smrg func_enable_tag "$1" # tagname is set here 943ea133fd7Smrg shift 944ea133fd7Smrg ;; 945ea133fd7Smrg 946ea133fd7Smrg # Separate optargs to long options: 947ea133fd7Smrg -dlopen=*|--mode=*|--tag=*) 948ea133fd7Smrg func_opt_split "$opt" 949ea133fd7Smrg set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} 950ea133fd7Smrg shift 951ea133fd7Smrg ;; 952ea133fd7Smrg 953ea133fd7Smrg -\?|-h) func_usage ;; 954ea133fd7Smrg --help) opt_help=: ;; 95525b89263Smrg --help-all) opt_help=': help-all' ;; 956ea133fd7Smrg --version) func_version ;; 957ea133fd7Smrg 958ea133fd7Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 959ea133fd7Smrg 960ea133fd7Smrg *) nonopt="$opt" 961ea133fd7Smrg break 962ea133fd7Smrg ;; 963ea133fd7Smrg esac 964ea133fd7Smrg done 965ea133fd7Smrg 966ea133fd7Smrg 967ea133fd7Smrg case $host in 968ea133fd7Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 969ea133fd7Smrg # don't eliminate duplications in $postdeps and $predeps 970ea133fd7Smrg opt_duplicate_compiler_generated_deps=: 971a253d6aeSmrg ;; 972a253d6aeSmrg *) 973ea133fd7Smrg opt_duplicate_compiler_generated_deps=$opt_duplicate_deps 974ea133fd7Smrg ;; 975ea133fd7Smrg esac 976a253d6aeSmrg 977ea133fd7Smrg # Having warned about all mis-specified options, bail out if 978ea133fd7Smrg # anything was wrong. 979ea133fd7Smrg $exit_cmd $EXIT_FAILURE 980ea133fd7Smrg} 981ea133fd7Smrg 982ea133fd7Smrg# func_check_version_match 983ea133fd7Smrg# Ensure that we are using m4 macros, and libtool script from the same 984ea133fd7Smrg# release of libtool. 985ea133fd7Smrgfunc_check_version_match () 986ea133fd7Smrg{ 987ea133fd7Smrg if test "$package_revision" != "$macro_revision"; then 988ea133fd7Smrg if test "$VERSION" != "$macro_version"; then 989ea133fd7Smrg if test -z "$macro_version"; then 990ea133fd7Smrg cat >&2 <<_LT_EOF 991ea133fd7Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 992ea133fd7Smrg$progname: definition of this LT_INIT comes from an older release. 993ea133fd7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 994ea133fd7Smrg$progname: and run autoconf again. 995ea133fd7Smrg_LT_EOF 996ea133fd7Smrg else 997ea133fd7Smrg cat >&2 <<_LT_EOF 998ea133fd7Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 999ea133fd7Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 1000ea133fd7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 1001ea133fd7Smrg$progname: and run autoconf again. 1002ea133fd7Smrg_LT_EOF 1003a253d6aeSmrg fi 1004ea133fd7Smrg else 1005ea133fd7Smrg cat >&2 <<_LT_EOF 1006ea133fd7Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 1007ea133fd7Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 1008ea133fd7Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 1009ea133fd7Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 1010ea133fd7Smrg_LT_EOF 1011ea133fd7Smrg fi 1012ea133fd7Smrg 1013ea133fd7Smrg exit $EXIT_MISMATCH 1014ea133fd7Smrg fi 1015ea133fd7Smrg} 1016ea133fd7Smrg 1017ea133fd7Smrg 1018ea133fd7Smrg## ----------- ## 1019ea133fd7Smrg## Main. ## 1020ea133fd7Smrg## ----------- ## 1021ea133fd7Smrg 1022ea133fd7Smrg$opt_help || { 1023ea133fd7Smrg # Sanity checks first: 1024ea133fd7Smrg func_check_version_match 1025ea133fd7Smrg 1026ea133fd7Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 1027ea133fd7Smrg func_fatal_configuration "not configured to build any kind of library" 1028a253d6aeSmrg fi 1029a253d6aeSmrg 1030ea133fd7Smrg test -z "$mode" && func_fatal_error "error: you must specify a MODE." 1031ea133fd7Smrg 1032ea133fd7Smrg 1033ea133fd7Smrg # Darwin sucks 1034ea133fd7Smrg eval std_shrext=\"$shrext_cmds\" 1035ea133fd7Smrg 1036ea133fd7Smrg 1037a253d6aeSmrg # Only execute mode is allowed to have -dlopen flags. 1038a253d6aeSmrg if test -n "$execute_dlfiles" && test "$mode" != execute; then 1039ea133fd7Smrg func_error "unrecognized option \`-dlopen'" 1040ea133fd7Smrg $ECHO "$help" 1>&2 1041a253d6aeSmrg exit $EXIT_FAILURE 1042a253d6aeSmrg fi 1043a253d6aeSmrg 1044a253d6aeSmrg # Change the help message to a mode-specific one. 1045a253d6aeSmrg generic_help="$help" 1046ea133fd7Smrg help="Try \`$progname --help --mode=$mode' for more information." 1047ea133fd7Smrg} 1048a253d6aeSmrg 1049a253d6aeSmrg 1050ea133fd7Smrg# func_lalib_p file 1051ea133fd7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1052ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out 1053ea133fd7Smrg# determined imposters. 1054ea133fd7Smrgfunc_lalib_p () 1055ea133fd7Smrg{ 1056ea133fd7Smrg test -f "$1" && 1057ea133fd7Smrg $SED -e 4q "$1" 2>/dev/null \ 1058ea133fd7Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 1059ea133fd7Smrg} 1060a253d6aeSmrg 1061ea133fd7Smrg# func_lalib_unsafe_p file 1062ea133fd7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1063ea133fd7Smrg# This function implements the same check as func_lalib_p without 1064ea133fd7Smrg# resorting to external programs. To this end, it redirects stdin and 1065ea133fd7Smrg# closes it afterwards, without saving the original file descriptor. 1066ea133fd7Smrg# As a safety measure, use it only where a negative result would be 1067ea133fd7Smrg# fatal anyway. Works if `file' does not exist. 1068ea133fd7Smrgfunc_lalib_unsafe_p () 1069ea133fd7Smrg{ 1070ea133fd7Smrg lalib_p=no 1071ea133fd7Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 1072ea133fd7Smrg for lalib_p_l in 1 2 3 4 1073ea133fd7Smrg do 1074ea133fd7Smrg read lalib_p_line 1075ea133fd7Smrg case "$lalib_p_line" in 1076ea133fd7Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 1077ea133fd7Smrg esac 1078ea133fd7Smrg done 1079ea133fd7Smrg exec 0<&5 5<&- 1080ea133fd7Smrg fi 1081ea133fd7Smrg test "$lalib_p" = yes 1082ea133fd7Smrg} 1083a253d6aeSmrg 1084ea133fd7Smrg# func_ltwrapper_script_p file 1085ea133fd7Smrg# True iff FILE is a libtool wrapper script 1086ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out 1087ea133fd7Smrg# determined imposters. 1088ea133fd7Smrgfunc_ltwrapper_script_p () 1089ea133fd7Smrg{ 1090ea133fd7Smrg func_lalib_p "$1" 1091ea133fd7Smrg} 1092a253d6aeSmrg 1093ea133fd7Smrg# func_ltwrapper_executable_p file 1094ea133fd7Smrg# True iff FILE is a libtool wrapper executable 1095ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out 1096ea133fd7Smrg# determined imposters. 1097ea133fd7Smrgfunc_ltwrapper_executable_p () 1098ea133fd7Smrg{ 1099ea133fd7Smrg func_ltwrapper_exec_suffix= 1100ea133fd7Smrg case $1 in 1101ea133fd7Smrg *.exe) ;; 1102ea133fd7Smrg *) func_ltwrapper_exec_suffix=.exe ;; 1103ea133fd7Smrg esac 1104ea133fd7Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 1105ea133fd7Smrg} 1106a253d6aeSmrg 1107ea133fd7Smrg# func_ltwrapper_scriptname file 1108ea133fd7Smrg# Assumes file is an ltwrapper_executable 1109ea133fd7Smrg# uses $file to determine the appropriate filename for a 1110ea133fd7Smrg# temporary ltwrapper_script. 1111ea133fd7Smrgfunc_ltwrapper_scriptname () 1112ea133fd7Smrg{ 1113ea133fd7Smrg func_ltwrapper_scriptname_result="" 1114ea133fd7Smrg if func_ltwrapper_executable_p "$1"; then 1115ea133fd7Smrg func_dirname_and_basename "$1" "" "." 1116ea133fd7Smrg func_stripname '' '.exe' "$func_basename_result" 1117ea133fd7Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 1118ea133fd7Smrg fi 1119ea133fd7Smrg} 1120a253d6aeSmrg 1121ea133fd7Smrg# func_ltwrapper_p file 1122ea133fd7Smrg# True iff FILE is a libtool wrapper script or wrapper executable 1123ea133fd7Smrg# This function is only a basic sanity check; it will hardly flush out 1124ea133fd7Smrg# determined imposters. 1125ea133fd7Smrgfunc_ltwrapper_p () 1126ea133fd7Smrg{ 1127ea133fd7Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 1128ea133fd7Smrg} 1129a253d6aeSmrg 1130a253d6aeSmrg 1131ea133fd7Smrg# func_execute_cmds commands fail_cmd 1132ea133fd7Smrg# Execute tilde-delimited COMMANDS. 1133ea133fd7Smrg# If FAIL_CMD is given, eval that upon failure. 1134ea133fd7Smrg# FAIL_CMD may read-access the current command in variable CMD! 1135ea133fd7Smrgfunc_execute_cmds () 1136ea133fd7Smrg{ 1137ea133fd7Smrg $opt_debug 1138ea133fd7Smrg save_ifs=$IFS; IFS='~' 1139ea133fd7Smrg for cmd in $1; do 1140ea133fd7Smrg IFS=$save_ifs 1141ea133fd7Smrg eval cmd=\"$cmd\" 1142ea133fd7Smrg func_show_eval "$cmd" "${2-:}" 1143ea133fd7Smrg done 1144ea133fd7Smrg IFS=$save_ifs 1145ea133fd7Smrg} 1146ea133fd7Smrg 1147ea133fd7Smrg 1148ea133fd7Smrg# func_source file 1149ea133fd7Smrg# Source FILE, adding directory component if necessary. 1150ea133fd7Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 1151ea133fd7Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 1152ea133fd7Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 1153ea133fd7Smrg# `FILE.' does not work on cygwin managed mounts. 1154ea133fd7Smrgfunc_source () 1155ea133fd7Smrg{ 1156ea133fd7Smrg $opt_debug 1157ea133fd7Smrg case $1 in 1158ea133fd7Smrg */* | *\\*) . "$1" ;; 1159ea133fd7Smrg *) . "./$1" ;; 1160ea133fd7Smrg esac 1161ea133fd7Smrg} 1162ea133fd7Smrg 1163ea133fd7Smrg 1164ea133fd7Smrg# func_infer_tag arg 1165ea133fd7Smrg# Infer tagged configuration to use if any are available and 1166ea133fd7Smrg# if one wasn't chosen via the "--tag" command line option. 1167ea133fd7Smrg# Only attempt this if the compiler in the base compile 1168ea133fd7Smrg# command doesn't match the default compiler. 1169ea133fd7Smrg# arg is usually of the form 'gcc ...' 1170ea133fd7Smrgfunc_infer_tag () 1171ea133fd7Smrg{ 1172ea133fd7Smrg $opt_debug 1173ea133fd7Smrg if test -n "$available_tags" && test -z "$tagname"; then 1174ea133fd7Smrg CC_quoted= 1175ea133fd7Smrg for arg in $CC; do 1176ea133fd7Smrg func_quote_for_eval "$arg" 1177ea133fd7Smrg CC_quoted="$CC_quoted $func_quote_for_eval_result" 1178ea133fd7Smrg done 117925b89263Smrg CC_expanded=`func_echo_all $CC` 118025b89263Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1181ea133fd7Smrg case $@ in 1182ea133fd7Smrg # Blanks in the command may have been stripped by the calling shell, 1183ea133fd7Smrg # but not from the CC environment variable when configure was run. 118425b89263Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 118525b89263Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 1186ea133fd7Smrg # Blanks at the start of $base_compile will cause this to fail 1187ea133fd7Smrg # if we don't check for them as well. 1188ea133fd7Smrg *) 1189ea133fd7Smrg for z in $available_tags; do 1190ea133fd7Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 1191ea133fd7Smrg # Evaluate the configuration. 1192ea133fd7Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 1193ea133fd7Smrg CC_quoted= 1194ea133fd7Smrg for arg in $CC; do 1195ea133fd7Smrg # Double-quote args containing other shell metacharacters. 1196ea133fd7Smrg func_quote_for_eval "$arg" 1197ea133fd7Smrg CC_quoted="$CC_quoted $func_quote_for_eval_result" 1198ea133fd7Smrg done 119925b89263Smrg CC_expanded=`func_echo_all $CC` 120025b89263Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1201ea133fd7Smrg case "$@ " in 120225b89263Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 120325b89263Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 1204ea133fd7Smrg # The compiler in the base compile command matches 1205ea133fd7Smrg # the one in the tagged configuration. 1206ea133fd7Smrg # Assume this is the tagged configuration we want. 1207ea133fd7Smrg tagname=$z 1208ea133fd7Smrg break 1209ea133fd7Smrg ;; 1210a253d6aeSmrg esac 1211ea133fd7Smrg fi 1212ea133fd7Smrg done 1213ea133fd7Smrg # If $tagname still isn't set, then no tagged configuration 1214ea133fd7Smrg # was found and let the user know that the "--tag" command 1215ea133fd7Smrg # line option must be used. 1216ea133fd7Smrg if test -z "$tagname"; then 1217ea133fd7Smrg func_echo "unable to infer tagged configuration" 1218ea133fd7Smrg func_fatal_error "specify a tag with \`--tag'" 1219ea133fd7Smrg# else 1220ea133fd7Smrg# func_verbose "using $tagname tagged configuration" 1221ea133fd7Smrg fi 1222ea133fd7Smrg ;; 1223ea133fd7Smrg esac 1224ea133fd7Smrg fi 1225ea133fd7Smrg} 1226ea133fd7Smrg 1227ea133fd7Smrg 1228ea133fd7Smrg 1229ea133fd7Smrg# func_write_libtool_object output_name pic_name nonpic_name 1230ea133fd7Smrg# Create a libtool object file (analogous to a ".la" file), 1231ea133fd7Smrg# but don't create it if we're doing a dry run. 1232ea133fd7Smrgfunc_write_libtool_object () 1233ea133fd7Smrg{ 1234ea133fd7Smrg write_libobj=${1} 1235ea133fd7Smrg if test "$build_libtool_libs" = yes; then 1236ea133fd7Smrg write_lobj=\'${2}\' 1237ea133fd7Smrg else 1238ea133fd7Smrg write_lobj=none 1239ea133fd7Smrg fi 1240ea133fd7Smrg 1241ea133fd7Smrg if test "$build_old_libs" = yes; then 1242ea133fd7Smrg write_oldobj=\'${3}\' 1243ea133fd7Smrg else 1244ea133fd7Smrg write_oldobj=none 1245ea133fd7Smrg fi 1246ea133fd7Smrg 1247ea133fd7Smrg $opt_dry_run || { 1248ea133fd7Smrg cat >${write_libobj}T <<EOF 1249ea133fd7Smrg# $write_libobj - a libtool object file 1250ea133fd7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1251ea133fd7Smrg# 1252ea133fd7Smrg# Please DO NOT delete this file! 1253ea133fd7Smrg# It is necessary for linking the library. 1254ea133fd7Smrg 1255ea133fd7Smrg# Name of the PIC object. 1256ea133fd7Smrgpic_object=$write_lobj 1257ea133fd7Smrg 1258ea133fd7Smrg# Name of the non-PIC object 1259ea133fd7Smrgnon_pic_object=$write_oldobj 1260ea133fd7Smrg 1261ea133fd7SmrgEOF 1262ea133fd7Smrg $MV "${write_libobj}T" "${write_libobj}" 1263ea133fd7Smrg } 1264ea133fd7Smrg} 1265ea133fd7Smrg 1266ea133fd7Smrg# func_mode_compile arg... 1267ea133fd7Smrgfunc_mode_compile () 1268ea133fd7Smrg{ 1269ea133fd7Smrg $opt_debug 1270ea133fd7Smrg # Get the compilation command and the source file. 1271ea133fd7Smrg base_compile= 1272ea133fd7Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 1273ea133fd7Smrg suppress_opt=yes 1274ea133fd7Smrg suppress_output= 1275ea133fd7Smrg arg_mode=normal 1276ea133fd7Smrg libobj= 1277ea133fd7Smrg later= 1278ea133fd7Smrg pie_flag= 1279ea133fd7Smrg 1280ea133fd7Smrg for arg 1281ea133fd7Smrg do 1282ea133fd7Smrg case $arg_mode in 1283ea133fd7Smrg arg ) 1284ea133fd7Smrg # do not "continue". Instead, add this to base_compile 1285ea133fd7Smrg lastarg="$arg" 1286ea133fd7Smrg arg_mode=normal 1287ea133fd7Smrg ;; 1288ea133fd7Smrg 1289ea133fd7Smrg target ) 1290ea133fd7Smrg libobj="$arg" 1291ea133fd7Smrg arg_mode=normal 1292ea133fd7Smrg continue 1293ea133fd7Smrg ;; 1294ea133fd7Smrg 1295ea133fd7Smrg normal ) 1296ea133fd7Smrg # Accept any command-line options. 1297ea133fd7Smrg case $arg in 1298ea133fd7Smrg -o) 1299ea133fd7Smrg test -n "$libobj" && \ 1300ea133fd7Smrg func_fatal_error "you cannot specify \`-o' more than once" 1301ea133fd7Smrg arg_mode=target 1302ea133fd7Smrg continue 1303ea133fd7Smrg ;; 1304ea133fd7Smrg 1305ea133fd7Smrg -pie | -fpie | -fPIE) 1306ea133fd7Smrg pie_flag="$pie_flag $arg" 1307ea133fd7Smrg continue 1308ea133fd7Smrg ;; 1309ea133fd7Smrg 1310ea133fd7Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 1311ea133fd7Smrg later="$later $arg" 1312ea133fd7Smrg continue 1313ea133fd7Smrg ;; 1314ea133fd7Smrg 1315ea133fd7Smrg -no-suppress) 1316ea133fd7Smrg suppress_opt=no 1317ea133fd7Smrg continue 1318ea133fd7Smrg ;; 1319ea133fd7Smrg 1320ea133fd7Smrg -Xcompiler) 1321ea133fd7Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 1322ea133fd7Smrg continue # The current "srcfile" will either be retained or 1323ea133fd7Smrg ;; # replaced later. I would guess that would be a bug. 1324ea133fd7Smrg 1325ea133fd7Smrg -Wc,*) 1326ea133fd7Smrg func_stripname '-Wc,' '' "$arg" 1327ea133fd7Smrg args=$func_stripname_result 1328ea133fd7Smrg lastarg= 1329ea133fd7Smrg save_ifs="$IFS"; IFS=',' 1330ea133fd7Smrg for arg in $args; do 1331ea133fd7Smrg IFS="$save_ifs" 1332ea133fd7Smrg func_quote_for_eval "$arg" 1333ea133fd7Smrg lastarg="$lastarg $func_quote_for_eval_result" 1334a253d6aeSmrg done 1335a253d6aeSmrg IFS="$save_ifs" 1336ea133fd7Smrg func_stripname ' ' '' "$lastarg" 1337ea133fd7Smrg lastarg=$func_stripname_result 1338a253d6aeSmrg 1339a253d6aeSmrg # Add the arguments to base_compile. 1340a253d6aeSmrg base_compile="$base_compile $lastarg" 1341a253d6aeSmrg continue 1342a253d6aeSmrg ;; 1343a253d6aeSmrg 1344ea133fd7Smrg *) 1345a253d6aeSmrg # Accept the current argument as the source file. 1346a253d6aeSmrg # The previous "srcfile" becomes the current argument. 1347a253d6aeSmrg # 1348a253d6aeSmrg lastarg="$srcfile" 1349a253d6aeSmrg srcfile="$arg" 1350a253d6aeSmrg ;; 1351a253d6aeSmrg esac # case $arg 1352a253d6aeSmrg ;; 1353a253d6aeSmrg esac # case $arg_mode 1354a253d6aeSmrg 1355a253d6aeSmrg # Aesthetically quote the previous argument. 1356ea133fd7Smrg func_quote_for_eval "$lastarg" 1357ea133fd7Smrg base_compile="$base_compile $func_quote_for_eval_result" 1358a253d6aeSmrg done # for arg 1359a253d6aeSmrg 1360a253d6aeSmrg case $arg_mode in 1361a253d6aeSmrg arg) 1362ea133fd7Smrg func_fatal_error "you must specify an argument for -Xcompile" 1363a253d6aeSmrg ;; 1364a253d6aeSmrg target) 1365ea133fd7Smrg func_fatal_error "you must specify a target with \`-o'" 1366a253d6aeSmrg ;; 1367a253d6aeSmrg *) 1368a253d6aeSmrg # Get the name of the library object. 1369ea133fd7Smrg test -z "$libobj" && { 1370ea133fd7Smrg func_basename "$srcfile" 1371ea133fd7Smrg libobj="$func_basename_result" 1372ea133fd7Smrg } 1373a253d6aeSmrg ;; 1374a253d6aeSmrg esac 1375a253d6aeSmrg 1376a253d6aeSmrg # Recognize several different file suffixes. 1377a253d6aeSmrg # If the user specifies -o file.o, it is replaced with file.lo 1378a253d6aeSmrg case $libobj in 1379ea133fd7Smrg *.[cCFSifmso] | \ 1380ea133fd7Smrg *.ada | *.adb | *.ads | *.asm | \ 1381ea133fd7Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 138225b89263Smrg *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) 1383ea133fd7Smrg func_xform "$libobj" 1384ea133fd7Smrg libobj=$func_xform_result 1385ea133fd7Smrg ;; 1386a253d6aeSmrg esac 1387a253d6aeSmrg 1388a253d6aeSmrg case $libobj in 1389ea133fd7Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 1390a253d6aeSmrg *) 1391ea133fd7Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 1392a253d6aeSmrg ;; 1393a253d6aeSmrg esac 1394a253d6aeSmrg 1395a253d6aeSmrg func_infer_tag $base_compile 1396a253d6aeSmrg 1397a253d6aeSmrg for arg in $later; do 1398a253d6aeSmrg case $arg in 1399ea133fd7Smrg -shared) 1400ea133fd7Smrg test "$build_libtool_libs" != yes && \ 1401ea133fd7Smrg func_fatal_configuration "can not build a shared library" 1402ea133fd7Smrg build_old_libs=no 1403ea133fd7Smrg continue 1404ea133fd7Smrg ;; 1405ea133fd7Smrg 1406a253d6aeSmrg -static) 1407ea133fd7Smrg build_libtool_libs=no 1408a253d6aeSmrg build_old_libs=yes 1409a253d6aeSmrg continue 1410a253d6aeSmrg ;; 1411a253d6aeSmrg 1412a253d6aeSmrg -prefer-pic) 1413a253d6aeSmrg pic_mode=yes 1414a253d6aeSmrg continue 1415a253d6aeSmrg ;; 1416a253d6aeSmrg 1417a253d6aeSmrg -prefer-non-pic) 1418a253d6aeSmrg pic_mode=no 1419a253d6aeSmrg continue 1420a253d6aeSmrg ;; 1421a253d6aeSmrg esac 1422a253d6aeSmrg done 1423a253d6aeSmrg 1424ea133fd7Smrg func_quote_for_eval "$libobj" 1425ea133fd7Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 1426ea133fd7Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 1427ea133fd7Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 1428ea133fd7Smrg func_dirname_and_basename "$obj" "/" "" 1429ea133fd7Smrg objname="$func_basename_result" 1430ea133fd7Smrg xdir="$func_dirname_result" 1431a253d6aeSmrg lobj=${xdir}$objdir/$objname 1432a253d6aeSmrg 1433ea133fd7Smrg test -z "$base_compile" && \ 1434ea133fd7Smrg func_fatal_help "you must specify a compilation command" 1435a253d6aeSmrg 1436a253d6aeSmrg # Delete any leftover library objects. 1437a253d6aeSmrg if test "$build_old_libs" = yes; then 1438a253d6aeSmrg removelist="$obj $lobj $libobj ${libobj}T" 1439a253d6aeSmrg else 1440a253d6aeSmrg removelist="$lobj $libobj ${libobj}T" 1441a253d6aeSmrg fi 1442a253d6aeSmrg 1443a253d6aeSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 1444a253d6aeSmrg case $host_os in 1445ea133fd7Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 1446a253d6aeSmrg pic_mode=default 1447a253d6aeSmrg ;; 1448a253d6aeSmrg esac 1449a253d6aeSmrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 1450a253d6aeSmrg # non-PIC code in shared libraries is not supported 1451a253d6aeSmrg pic_mode=default 1452a253d6aeSmrg fi 1453a253d6aeSmrg 1454a253d6aeSmrg # Calculate the filename of the output object if compiler does 1455a253d6aeSmrg # not support -o with -c 1456a253d6aeSmrg if test "$compiler_c_o" = no; then 145725b89263Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 1458a253d6aeSmrg lockfile="$output_obj.lock" 1459a253d6aeSmrg else 1460a253d6aeSmrg output_obj= 1461a253d6aeSmrg need_locks=no 1462a253d6aeSmrg lockfile= 1463a253d6aeSmrg fi 1464a253d6aeSmrg 1465a253d6aeSmrg # Lock this critical section if it is needed 1466a253d6aeSmrg # We use this script file to make the link, it avoids creating a new file 1467a253d6aeSmrg if test "$need_locks" = yes; then 1468ea133fd7Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 1469ea133fd7Smrg func_echo "Waiting for $lockfile to be removed" 1470a253d6aeSmrg sleep 2 1471a253d6aeSmrg done 1472a253d6aeSmrg elif test "$need_locks" = warn; then 1473a253d6aeSmrg if test -f "$lockfile"; then 1474ea133fd7Smrg $ECHO "\ 1475a253d6aeSmrg*** ERROR, $lockfile exists and contains: 1476a253d6aeSmrg`cat $lockfile 2>/dev/null` 1477a253d6aeSmrg 1478a253d6aeSmrgThis indicates that another process is trying to use the same 1479a253d6aeSmrgtemporary object file, and libtool could not work around it because 1480a253d6aeSmrgyour compiler does not support \`-c' and \`-o' together. If you 1481a253d6aeSmrgrepeat this compilation, it may succeed, by chance, but you had better 1482a253d6aeSmrgavoid parallel builds (make -j) in this platform, or get a better 1483a253d6aeSmrgcompiler." 1484a253d6aeSmrg 1485ea133fd7Smrg $opt_dry_run || $RM $removelist 1486a253d6aeSmrg exit $EXIT_FAILURE 1487a253d6aeSmrg fi 1488ea133fd7Smrg removelist="$removelist $output_obj" 1489ea133fd7Smrg $ECHO "$srcfile" > "$lockfile" 1490a253d6aeSmrg fi 1491a253d6aeSmrg 1492ea133fd7Smrg $opt_dry_run || $RM $removelist 1493ea133fd7Smrg removelist="$removelist $lockfile" 1494ea133fd7Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 1495ea133fd7Smrg 1496a253d6aeSmrg if test -n "$fix_srcfile_path"; then 1497a253d6aeSmrg eval srcfile=\"$fix_srcfile_path\" 1498a253d6aeSmrg fi 1499ea133fd7Smrg func_quote_for_eval "$srcfile" 1500ea133fd7Smrg qsrcfile=$func_quote_for_eval_result 1501a253d6aeSmrg 1502a253d6aeSmrg # Only build a PIC object if we are building libtool libraries. 1503a253d6aeSmrg if test "$build_libtool_libs" = yes; then 1504a253d6aeSmrg # Without this assignment, base_compile gets emptied. 1505a253d6aeSmrg fbsd_hideous_sh_bug=$base_compile 1506a253d6aeSmrg 1507a253d6aeSmrg if test "$pic_mode" != no; then 1508a253d6aeSmrg command="$base_compile $qsrcfile $pic_flag" 1509a253d6aeSmrg else 1510a253d6aeSmrg # Don't build PIC code 1511a253d6aeSmrg command="$base_compile $qsrcfile" 1512a253d6aeSmrg fi 1513a253d6aeSmrg 1514ea133fd7Smrg func_mkdir_p "$xdir$objdir" 1515a253d6aeSmrg 1516a253d6aeSmrg if test -z "$output_obj"; then 1517a253d6aeSmrg # Place PIC objects in $objdir 1518a253d6aeSmrg command="$command -o $lobj" 1519a253d6aeSmrg fi 1520a253d6aeSmrg 1521ea133fd7Smrg func_show_eval_locale "$command" \ 1522ea133fd7Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 1523a253d6aeSmrg 1524a253d6aeSmrg if test "$need_locks" = warn && 1525a253d6aeSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 1526ea133fd7Smrg $ECHO "\ 1527a253d6aeSmrg*** ERROR, $lockfile contains: 1528a253d6aeSmrg`cat $lockfile 2>/dev/null` 1529a253d6aeSmrg 1530a253d6aeSmrgbut it should contain: 1531a253d6aeSmrg$srcfile 1532a253d6aeSmrg 1533a253d6aeSmrgThis indicates that another process is trying to use the same 1534a253d6aeSmrgtemporary object file, and libtool could not work around it because 1535a253d6aeSmrgyour compiler does not support \`-c' and \`-o' together. If you 1536a253d6aeSmrgrepeat this compilation, it may succeed, by chance, but you had better 1537a253d6aeSmrgavoid parallel builds (make -j) in this platform, or get a better 1538a253d6aeSmrgcompiler." 1539a253d6aeSmrg 1540ea133fd7Smrg $opt_dry_run || $RM $removelist 1541a253d6aeSmrg exit $EXIT_FAILURE 1542a253d6aeSmrg fi 1543a253d6aeSmrg 1544a253d6aeSmrg # Just move the object if needed, then go on to compile the next one 1545a253d6aeSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 1546ea133fd7Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 1547ea133fd7Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 1548a253d6aeSmrg fi 1549a253d6aeSmrg 1550a253d6aeSmrg # Allow error messages only from the first compilation. 1551a253d6aeSmrg if test "$suppress_opt" = yes; then 1552ea133fd7Smrg suppress_output=' >/dev/null 2>&1' 1553a253d6aeSmrg fi 1554a253d6aeSmrg fi 1555a253d6aeSmrg 1556a253d6aeSmrg # Only build a position-dependent object if we build old libraries. 1557a253d6aeSmrg if test "$build_old_libs" = yes; then 1558a253d6aeSmrg if test "$pic_mode" != yes; then 1559a253d6aeSmrg # Don't build PIC code 1560ea133fd7Smrg command="$base_compile $qsrcfile$pie_flag" 1561a253d6aeSmrg else 1562a253d6aeSmrg command="$base_compile $qsrcfile $pic_flag" 1563a253d6aeSmrg fi 1564a253d6aeSmrg if test "$compiler_c_o" = yes; then 1565a253d6aeSmrg command="$command -o $obj" 1566a253d6aeSmrg fi 1567a253d6aeSmrg 1568a253d6aeSmrg # Suppress compiler output if we already did a PIC compilation. 1569a253d6aeSmrg command="$command$suppress_output" 1570ea133fd7Smrg func_show_eval_locale "$command" \ 1571ea133fd7Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1572a253d6aeSmrg 1573a253d6aeSmrg if test "$need_locks" = warn && 1574a253d6aeSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 1575ea133fd7Smrg $ECHO "\ 1576a253d6aeSmrg*** ERROR, $lockfile contains: 1577a253d6aeSmrg`cat $lockfile 2>/dev/null` 1578a253d6aeSmrg 1579a253d6aeSmrgbut it should contain: 1580a253d6aeSmrg$srcfile 1581a253d6aeSmrg 1582a253d6aeSmrgThis indicates that another process is trying to use the same 1583a253d6aeSmrgtemporary object file, and libtool could not work around it because 1584a253d6aeSmrgyour compiler does not support \`-c' and \`-o' together. If you 1585a253d6aeSmrgrepeat this compilation, it may succeed, by chance, but you had better 1586a253d6aeSmrgavoid parallel builds (make -j) in this platform, or get a better 1587a253d6aeSmrgcompiler." 1588a253d6aeSmrg 1589ea133fd7Smrg $opt_dry_run || $RM $removelist 1590a253d6aeSmrg exit $EXIT_FAILURE 1591a253d6aeSmrg fi 1592a253d6aeSmrg 1593a253d6aeSmrg # Just move the object if needed 1594a253d6aeSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 1595ea133fd7Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 1596ea133fd7Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 1597a253d6aeSmrg fi 1598a253d6aeSmrg fi 1599a253d6aeSmrg 1600ea133fd7Smrg $opt_dry_run || { 1601ea133fd7Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 1602a253d6aeSmrg 1603ea133fd7Smrg # Unlock the critical section if it was locked 1604ea133fd7Smrg if test "$need_locks" != no; then 1605ea133fd7Smrg removelist=$lockfile 1606ea133fd7Smrg $RM "$lockfile" 1607ea133fd7Smrg fi 1608ea133fd7Smrg } 1609a253d6aeSmrg 1610a253d6aeSmrg exit $EXIT_SUCCESS 1611ea133fd7Smrg} 1612a253d6aeSmrg 1613ea133fd7Smrg$opt_help || { 161425b89263Smrg test "$mode" = compile && func_mode_compile ${1+"$@"} 1615ea133fd7Smrg} 1616a253d6aeSmrg 1617ea133fd7Smrgfunc_mode_help () 1618ea133fd7Smrg{ 1619ea133fd7Smrg # We need to display help for each of the modes. 1620ea133fd7Smrg case $mode in 1621ea133fd7Smrg "") 1622ea133fd7Smrg # Generic help is extracted from the usage comments 1623ea133fd7Smrg # at the start of this file. 1624ea133fd7Smrg func_help 1625ea133fd7Smrg ;; 1626a253d6aeSmrg 1627ea133fd7Smrg clean) 1628ea133fd7Smrg $ECHO \ 1629ea133fd7Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 1630a253d6aeSmrg 1631ea133fd7SmrgRemove files from the build directory. 1632a253d6aeSmrg 1633ea133fd7SmrgRM is the name of the program to use to delete files associated with each FILE 1634ea133fd7Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 1635ea133fd7Smrgto RM. 1636a253d6aeSmrg 1637ea133fd7SmrgIf FILE is a libtool library, object or program, all the files associated 1638ea133fd7Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 1639ea133fd7Smrg ;; 1640a253d6aeSmrg 1641ea133fd7Smrg compile) 1642ea133fd7Smrg $ECHO \ 1643ea133fd7Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 1644a253d6aeSmrg 1645ea133fd7SmrgCompile a source file into a libtool library object. 1646a253d6aeSmrg 1647ea133fd7SmrgThis mode accepts the following additional options: 1648a253d6aeSmrg 1649ea133fd7Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 1650ea133fd7Smrg -no-suppress do not suppress compiler output for multiple passes 165125b89263Smrg -prefer-pic try to build PIC objects only 165225b89263Smrg -prefer-non-pic try to build non-PIC objects only 1653ea133fd7Smrg -shared do not build a \`.o' file suitable for static linking 1654ea133fd7Smrg -static only build a \`.o' file suitable for static linking 165525b89263Smrg -Wc,FLAG pass FLAG directly to the compiler 1656a253d6aeSmrg 1657ea133fd7SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 1658ea133fd7Smrgfrom the given SOURCEFILE. 1659a253d6aeSmrg 1660ea133fd7SmrgThe output file name is determined by removing the directory component from 1661ea133fd7SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 1662ea133fd7Smrglibrary object suffix, \`.lo'." 1663ea133fd7Smrg ;; 1664a253d6aeSmrg 1665ea133fd7Smrg execute) 1666ea133fd7Smrg $ECHO \ 1667ea133fd7Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 1668a253d6aeSmrg 1669ea133fd7SmrgAutomatically set library path, then run a program. 1670a253d6aeSmrg 1671ea133fd7SmrgThis mode accepts the following additional options: 1672a253d6aeSmrg 1673ea133fd7Smrg -dlopen FILE add the directory containing FILE to the library path 1674a253d6aeSmrg 1675ea133fd7SmrgThis mode sets the library path environment variable according to \`-dlopen' 1676ea133fd7Smrgflags. 1677a253d6aeSmrg 1678ea133fd7SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 1679ea133fd7Smrginto their corresponding uninstalled binary, and any of their required library 1680ea133fd7Smrgdirectories are added to the library path. 1681a253d6aeSmrg 1682ea133fd7SmrgThen, COMMAND is executed, with ARGS as arguments." 1683ea133fd7Smrg ;; 1684a253d6aeSmrg 1685ea133fd7Smrg finish) 1686ea133fd7Smrg $ECHO \ 1687ea133fd7Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 1688a253d6aeSmrg 1689ea133fd7SmrgComplete the installation of libtool libraries. 1690a253d6aeSmrg 1691ea133fd7SmrgEach LIBDIR is a directory that contains libtool libraries. 1692a253d6aeSmrg 1693ea133fd7SmrgThe commands that this mode executes may require superuser privileges. Use 1694ea133fd7Smrgthe \`--dry-run' option if you just want to see what would be executed." 1695ea133fd7Smrg ;; 1696a253d6aeSmrg 1697ea133fd7Smrg install) 1698ea133fd7Smrg $ECHO \ 1699ea133fd7Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 1700a253d6aeSmrg 1701ea133fd7SmrgInstall executables or libraries. 1702a253d6aeSmrg 1703ea133fd7SmrgINSTALL-COMMAND is the installation command. The first component should be 1704ea133fd7Smrgeither the \`install' or \`cp' program. 1705a253d6aeSmrg 1706ea133fd7SmrgThe following components of INSTALL-COMMAND are treated specially: 1707a253d6aeSmrg 170825b89263Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 1709a253d6aeSmrg 1710ea133fd7SmrgThe rest of the components are interpreted as arguments to that command (only 1711ea133fd7SmrgBSD-compatible install options are recognized)." 1712ea133fd7Smrg ;; 1713a253d6aeSmrg 1714ea133fd7Smrg link) 1715ea133fd7Smrg $ECHO \ 1716ea133fd7Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 1717a253d6aeSmrg 1718ea133fd7SmrgLink object files or libraries together to form another library, or to 1719ea133fd7Smrgcreate an executable program. 1720a253d6aeSmrg 1721ea133fd7SmrgLINK-COMMAND is a command using the C compiler that you would use to create 1722ea133fd7Smrga program from several object files. 1723a253d6aeSmrg 1724ea133fd7SmrgThe following components of LINK-COMMAND are treated specially: 1725a253d6aeSmrg 1726ea133fd7Smrg -all-static do not do any dynamic linking at all 1727ea133fd7Smrg -avoid-version do not add a version suffix if possible 172825b89263Smrg -bindir BINDIR specify path to binaries directory (for systems where 172925b89263Smrg libraries must be found in the PATH setting at runtime) 1730ea133fd7Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 1731ea133fd7Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 1732ea133fd7Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 1733ea133fd7Smrg -export-symbols SYMFILE 1734ea133fd7Smrg try to export only the symbols listed in SYMFILE 1735ea133fd7Smrg -export-symbols-regex REGEX 1736ea133fd7Smrg try to export only the symbols matching REGEX 1737ea133fd7Smrg -LLIBDIR search LIBDIR for required installed libraries 1738ea133fd7Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 1739ea133fd7Smrg -module build a library that can dlopened 1740ea133fd7Smrg -no-fast-install disable the fast-install mode 1741ea133fd7Smrg -no-install link a not-installable executable 1742ea133fd7Smrg -no-undefined declare that a library does not refer to external symbols 1743ea133fd7Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 1744ea133fd7Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 1745ea133fd7Smrg -precious-files-regex REGEX 1746ea133fd7Smrg don't remove output files matching REGEX 1747ea133fd7Smrg -release RELEASE specify package release information 1748ea133fd7Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 1749ea133fd7Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 1750ea133fd7Smrg -shared only do dynamic linking of libtool libraries 1751ea133fd7Smrg -shrext SUFFIX override the standard shared library file extension 1752ea133fd7Smrg -static do not do any dynamic linking of uninstalled libtool libraries 1753ea133fd7Smrg -static-libtool-libs 1754ea133fd7Smrg do not do any dynamic linking of libtool libraries 1755ea133fd7Smrg -version-info CURRENT[:REVISION[:AGE]] 1756ea133fd7Smrg specify library version info [each variable defaults to 0] 1757ea133fd7Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 175825b89263Smrg -Wc,FLAG 175925b89263Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 176025b89263Smrg -Wl,FLAG 176125b89263Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 176225b89263Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 1763a253d6aeSmrg 1764ea133fd7SmrgAll other options (arguments beginning with \`-') are ignored. 1765a253d6aeSmrg 1766ea133fd7SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 1767ea133fd7Smrgtreated as uninstalled libtool libraries, other files are standard or library 1768ea133fd7Smrgobject files. 1769a253d6aeSmrg 1770ea133fd7SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 1771ea133fd7Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 1772ea133fd7Smrgrequired, except when creating a convenience library. 1773a253d6aeSmrg 1774ea133fd7SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 1775ea133fd7Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 1776a253d6aeSmrg 1777ea133fd7SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 1778ea133fd7Smrgis created, otherwise an executable program is created." 1779a253d6aeSmrg ;; 1780a253d6aeSmrg 1781ea133fd7Smrg uninstall) 1782ea133fd7Smrg $ECHO \ 1783ea133fd7Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 1784a253d6aeSmrg 1785ea133fd7SmrgRemove libraries from an installation directory. 1786a253d6aeSmrg 1787ea133fd7SmrgRM is the name of the program to use to delete files associated with each FILE 1788ea133fd7Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 1789ea133fd7Smrgto RM. 1790a253d6aeSmrg 1791ea133fd7SmrgIf FILE is a libtool library, all the files associated with it are deleted. 1792ea133fd7SmrgOtherwise, only FILE itself is deleted using RM." 1793ea133fd7Smrg ;; 1794a253d6aeSmrg 1795ea133fd7Smrg *) 1796ea133fd7Smrg func_fatal_help "invalid operation mode \`$mode'" 1797ea133fd7Smrg ;; 1798ea133fd7Smrg esac 1799a253d6aeSmrg 180025b89263Smrg echo 1801ea133fd7Smrg $ECHO "Try \`$progname --help' for more information about other modes." 1802ea133fd7Smrg} 1803a253d6aeSmrg 180425b89263Smrg# Now that we've collected a possible --mode arg, show help if necessary 180525b89263Smrgif $opt_help; then 180625b89263Smrg if test "$opt_help" = :; then 180725b89263Smrg func_mode_help 180825b89263Smrg else 180925b89263Smrg { 181025b89263Smrg func_help noexit 181125b89263Smrg for mode in compile link execute install finish uninstall clean; do 181225b89263Smrg func_mode_help 181325b89263Smrg done 181425b89263Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 181525b89263Smrg { 181625b89263Smrg func_help noexit 181725b89263Smrg for mode in compile link execute install finish uninstall clean; do 181825b89263Smrg echo 181925b89263Smrg func_mode_help 182025b89263Smrg done 182125b89263Smrg } | 182225b89263Smrg sed '1d 182325b89263Smrg /^When reporting/,/^Report/{ 182425b89263Smrg H 182525b89263Smrg d 182625b89263Smrg } 182725b89263Smrg $x 182825b89263Smrg /information about other modes/d 182925b89263Smrg /more detailed .*MODE/d 183025b89263Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 183125b89263Smrg fi 183225b89263Smrg exit $? 183325b89263Smrgfi 1834a253d6aeSmrg 1835a253d6aeSmrg 1836ea133fd7Smrg# func_mode_execute arg... 1837ea133fd7Smrgfunc_mode_execute () 1838ea133fd7Smrg{ 1839ea133fd7Smrg $opt_debug 1840ea133fd7Smrg # The first argument is the command name. 1841ea133fd7Smrg cmd="$nonopt" 1842ea133fd7Smrg test -z "$cmd" && \ 1843ea133fd7Smrg func_fatal_help "you must specify a COMMAND" 1844a253d6aeSmrg 1845ea133fd7Smrg # Handle -dlopen flags immediately. 1846ea133fd7Smrg for file in $execute_dlfiles; do 1847ea133fd7Smrg test -f "$file" \ 1848ea133fd7Smrg || func_fatal_help "\`$file' is not a file" 1849a253d6aeSmrg 1850ea133fd7Smrg dir= 1851ea133fd7Smrg case $file in 1852ea133fd7Smrg *.la) 1853ea133fd7Smrg # Check to see that this really is a libtool archive. 1854ea133fd7Smrg func_lalib_unsafe_p "$file" \ 1855ea133fd7Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 1856a253d6aeSmrg 1857ea133fd7Smrg # Read the libtool library. 1858ea133fd7Smrg dlname= 1859ea133fd7Smrg library_names= 1860ea133fd7Smrg func_source "$file" 1861a253d6aeSmrg 1862ea133fd7Smrg # Skip this library if it cannot be dlopened. 1863ea133fd7Smrg if test -z "$dlname"; then 1864ea133fd7Smrg # Warn if it was a shared library. 1865ea133fd7Smrg test -n "$library_names" && \ 1866ea133fd7Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 1867ea133fd7Smrg continue 1868ea133fd7Smrg fi 1869a253d6aeSmrg 1870ea133fd7Smrg func_dirname "$file" "" "." 1871ea133fd7Smrg dir="$func_dirname_result" 1872a253d6aeSmrg 1873ea133fd7Smrg if test -f "$dir/$objdir/$dlname"; then 1874ea133fd7Smrg dir="$dir/$objdir" 1875ea133fd7Smrg else 1876ea133fd7Smrg if test ! -f "$dir/$dlname"; then 1877ea133fd7Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1878ea133fd7Smrg fi 1879ea133fd7Smrg fi 1880a253d6aeSmrg ;; 1881a253d6aeSmrg 1882ea133fd7Smrg *.lo) 1883ea133fd7Smrg # Just add the directory containing the .lo file. 1884ea133fd7Smrg func_dirname "$file" "" "." 1885ea133fd7Smrg dir="$func_dirname_result" 1886a253d6aeSmrg ;; 1887a253d6aeSmrg 1888ea133fd7Smrg *) 1889ea133fd7Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 1890a253d6aeSmrg continue 1891a253d6aeSmrg ;; 1892ea133fd7Smrg esac 1893a253d6aeSmrg 1894ea133fd7Smrg # Get the absolute pathname. 1895ea133fd7Smrg absdir=`cd "$dir" && pwd` 1896ea133fd7Smrg test -n "$absdir" && dir="$absdir" 1897a253d6aeSmrg 1898ea133fd7Smrg # Now add the directory to shlibpath_var. 1899ea133fd7Smrg if eval "test -z \"\$$shlibpath_var\""; then 1900ea133fd7Smrg eval "$shlibpath_var=\"\$dir\"" 1901ea133fd7Smrg else 1902ea133fd7Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 1903ea133fd7Smrg fi 1904ea133fd7Smrg done 1905a253d6aeSmrg 1906ea133fd7Smrg # This variable tells wrapper scripts just to set shlibpath_var 1907ea133fd7Smrg # rather than running their programs. 1908ea133fd7Smrg libtool_execute_magic="$magic" 1909a253d6aeSmrg 1910ea133fd7Smrg # Check if any of the arguments is a wrapper script. 1911ea133fd7Smrg args= 1912ea133fd7Smrg for file 1913ea133fd7Smrg do 1914ea133fd7Smrg case $file in 191525b89263Smrg -* | *.la | *.lo ) ;; 1916ea133fd7Smrg *) 1917ea133fd7Smrg # Do a test to see if this is really a libtool program. 1918ea133fd7Smrg if func_ltwrapper_script_p "$file"; then 1919ea133fd7Smrg func_source "$file" 1920ea133fd7Smrg # Transform arg to wrapped name. 1921ea133fd7Smrg file="$progdir/$program" 1922ea133fd7Smrg elif func_ltwrapper_executable_p "$file"; then 1923ea133fd7Smrg func_ltwrapper_scriptname "$file" 1924ea133fd7Smrg func_source "$func_ltwrapper_scriptname_result" 1925ea133fd7Smrg # Transform arg to wrapped name. 1926ea133fd7Smrg file="$progdir/$program" 1927ea133fd7Smrg fi 1928ea133fd7Smrg ;; 1929ea133fd7Smrg esac 1930ea133fd7Smrg # Quote arguments (to preserve shell metacharacters). 1931ea133fd7Smrg func_quote_for_eval "$file" 1932ea133fd7Smrg args="$args $func_quote_for_eval_result" 1933ea133fd7Smrg done 1934a253d6aeSmrg 1935ea133fd7Smrg if test "X$opt_dry_run" = Xfalse; then 1936ea133fd7Smrg if test -n "$shlibpath_var"; then 1937ea133fd7Smrg # Export the shlibpath_var. 1938ea133fd7Smrg eval "export $shlibpath_var" 1939ea133fd7Smrg fi 1940a253d6aeSmrg 1941ea133fd7Smrg # Restore saved environment variables 1942ea133fd7Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1943ea133fd7Smrg do 1944ea133fd7Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 1945ea133fd7Smrg $lt_var=\$save_$lt_var; export $lt_var 1946ea133fd7Smrg else 1947ea133fd7Smrg $lt_unset $lt_var 1948ea133fd7Smrg fi" 1949ea133fd7Smrg done 1950a253d6aeSmrg 1951ea133fd7Smrg # Now prepare to actually exec the command. 1952ea133fd7Smrg exec_cmd="\$cmd$args" 1953ea133fd7Smrg else 1954ea133fd7Smrg # Display what would be done. 1955ea133fd7Smrg if test -n "$shlibpath_var"; then 1956ea133fd7Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 195725b89263Smrg echo "export $shlibpath_var" 1958ea133fd7Smrg fi 1959ea133fd7Smrg $ECHO "$cmd$args" 1960ea133fd7Smrg exit $EXIT_SUCCESS 1961ea133fd7Smrg fi 1962ea133fd7Smrg} 1963a253d6aeSmrg 1964ea133fd7Smrgtest "$mode" = execute && func_mode_execute ${1+"$@"} 1965a253d6aeSmrg 1966a253d6aeSmrg 1967ea133fd7Smrg# func_mode_finish arg... 1968ea133fd7Smrgfunc_mode_finish () 1969ea133fd7Smrg{ 1970ea133fd7Smrg $opt_debug 1971ea133fd7Smrg libdirs="$nonopt" 1972ea133fd7Smrg admincmds= 1973a253d6aeSmrg 1974ea133fd7Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 1975ea133fd7Smrg for dir 1976ea133fd7Smrg do 1977ea133fd7Smrg libdirs="$libdirs $dir" 1978ea133fd7Smrg done 1979a253d6aeSmrg 1980ea133fd7Smrg for libdir in $libdirs; do 1981ea133fd7Smrg if test -n "$finish_cmds"; then 1982ea133fd7Smrg # Do each command in the finish commands. 1983ea133fd7Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 1984ea133fd7Smrg'"$cmd"'"' 1985ea133fd7Smrg fi 1986ea133fd7Smrg if test -n "$finish_eval"; then 1987ea133fd7Smrg # Do the single finish_eval. 1988ea133fd7Smrg eval cmds=\"$finish_eval\" 1989ea133fd7Smrg $opt_dry_run || eval "$cmds" || admincmds="$admincmds 1990ea133fd7Smrg $cmds" 1991ea133fd7Smrg fi 1992ea133fd7Smrg done 1993ea133fd7Smrg fi 1994a253d6aeSmrg 1995ea133fd7Smrg # Exit here if they wanted silent mode. 1996ea133fd7Smrg $opt_silent && exit $EXIT_SUCCESS 1997a253d6aeSmrg 199825b89263Smrg echo "----------------------------------------------------------------------" 199925b89263Smrg echo "Libraries have been installed in:" 2000ea133fd7Smrg for libdir in $libdirs; do 2001ea133fd7Smrg $ECHO " $libdir" 2002ea133fd7Smrg done 200325b89263Smrg echo 200425b89263Smrg echo "If you ever happen to want to link against installed libraries" 200525b89263Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 200625b89263Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 200725b89263Smrg echo "flag during linking and do at least one of the following:" 2008ea133fd7Smrg if test -n "$shlibpath_var"; then 200925b89263Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 201025b89263Smrg echo " during execution" 2011ea133fd7Smrg fi 2012ea133fd7Smrg if test -n "$runpath_var"; then 201325b89263Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 201425b89263Smrg echo " during linking" 2015ea133fd7Smrg fi 2016ea133fd7Smrg if test -n "$hardcode_libdir_flag_spec"; then 2017ea133fd7Smrg libdir=LIBDIR 2018ea133fd7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 2019a253d6aeSmrg 2020ea133fd7Smrg $ECHO " - use the \`$flag' linker flag" 2021ea133fd7Smrg fi 2022ea133fd7Smrg if test -n "$admincmds"; then 2023ea133fd7Smrg $ECHO " - have your system administrator run these commands:$admincmds" 2024ea133fd7Smrg fi 2025ea133fd7Smrg if test -f /etc/ld.so.conf; then 202625b89263Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 2027ea133fd7Smrg fi 202825b89263Smrg echo 2029a253d6aeSmrg 203025b89263Smrg echo "See any operating system documentation about shared libraries for" 2031ea133fd7Smrg case $host in 2032ea133fd7Smrg solaris2.[6789]|solaris2.1[0-9]) 203325b89263Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 203425b89263Smrg echo "pages." 2035a253d6aeSmrg ;; 2036ea133fd7Smrg *) 203725b89263Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 2038ea133fd7Smrg ;; 2039ea133fd7Smrg esac 204025b89263Smrg echo "----------------------------------------------------------------------" 2041ea133fd7Smrg exit $EXIT_SUCCESS 2042ea133fd7Smrg} 2043a253d6aeSmrg 2044ea133fd7Smrgtest "$mode" = finish && func_mode_finish ${1+"$@"} 2045a253d6aeSmrg 2046a253d6aeSmrg 2047ea133fd7Smrg# func_mode_install arg... 2048ea133fd7Smrgfunc_mode_install () 2049ea133fd7Smrg{ 2050ea133fd7Smrg $opt_debug 2051ea133fd7Smrg # There may be an optional sh(1) argument at the beginning of 2052ea133fd7Smrg # install_prog (especially on Windows NT). 2053ea133fd7Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 2054ea133fd7Smrg # Allow the use of GNU shtool's install command. 205525b89263Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 2056ea133fd7Smrg # Aesthetically quote it. 2057ea133fd7Smrg func_quote_for_eval "$nonopt" 2058ea133fd7Smrg install_prog="$func_quote_for_eval_result " 2059ea133fd7Smrg arg=$1 2060ea133fd7Smrg shift 2061ea133fd7Smrg else 2062ea133fd7Smrg install_prog= 2063ea133fd7Smrg arg=$nonopt 2064ea133fd7Smrg fi 2065a253d6aeSmrg 2066ea133fd7Smrg # The real first argument should be the name of the installation program. 2067ea133fd7Smrg # Aesthetically quote it. 2068ea133fd7Smrg func_quote_for_eval "$arg" 2069ea133fd7Smrg install_prog="$install_prog$func_quote_for_eval_result" 207025b89263Smrg install_shared_prog=$install_prog 207125b89263Smrg case " $install_prog " in 207225b89263Smrg *[\\\ /]cp\ *) install_cp=: ;; 207325b89263Smrg *) install_cp=false ;; 207425b89263Smrg esac 2075ea133fd7Smrg 2076ea133fd7Smrg # We need to accept at least all the BSD install flags. 2077ea133fd7Smrg dest= 2078ea133fd7Smrg files= 2079ea133fd7Smrg opts= 2080ea133fd7Smrg prev= 2081ea133fd7Smrg install_type= 2082ea133fd7Smrg isdir=no 2083ea133fd7Smrg stripme= 208425b89263Smrg no_mode=: 2085ea133fd7Smrg for arg 2086ea133fd7Smrg do 208725b89263Smrg arg2= 2088ea133fd7Smrg if test -n "$dest"; then 2089ea133fd7Smrg files="$files $dest" 2090ea133fd7Smrg dest=$arg 2091ea133fd7Smrg continue 2092a253d6aeSmrg fi 2093a253d6aeSmrg 2094ea133fd7Smrg case $arg in 2095ea133fd7Smrg -d) isdir=yes ;; 2096ea133fd7Smrg -f) 209725b89263Smrg if $install_cp; then :; else 209825b89263Smrg prev=$arg 209925b89263Smrg fi 2100ea133fd7Smrg ;; 2101ea133fd7Smrg -g | -m | -o) 2102ea133fd7Smrg prev=$arg 2103ea133fd7Smrg ;; 2104ea133fd7Smrg -s) 2105ea133fd7Smrg stripme=" -s" 2106ea133fd7Smrg continue 2107ea133fd7Smrg ;; 2108ea133fd7Smrg -*) 2109ea133fd7Smrg ;; 2110ea133fd7Smrg *) 2111ea133fd7Smrg # If the previous option needed an argument, then skip it. 2112ea133fd7Smrg if test -n "$prev"; then 211325b89263Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 211425b89263Smrg arg2=$install_override_mode 211525b89263Smrg no_mode=false 211625b89263Smrg fi 2117ea133fd7Smrg prev= 2118ea133fd7Smrg else 2119ea133fd7Smrg dest=$arg 2120ea133fd7Smrg continue 2121ea133fd7Smrg fi 2122ea133fd7Smrg ;; 2123ea133fd7Smrg esac 2124a253d6aeSmrg 2125ea133fd7Smrg # Aesthetically quote the argument. 2126ea133fd7Smrg func_quote_for_eval "$arg" 2127ea133fd7Smrg install_prog="$install_prog $func_quote_for_eval_result" 212825b89263Smrg if test -n "$arg2"; then 212925b89263Smrg func_quote_for_eval "$arg2" 213025b89263Smrg fi 213125b89263Smrg install_shared_prog="$install_shared_prog $func_quote_for_eval_result" 2132ea133fd7Smrg done 2133a253d6aeSmrg 2134ea133fd7Smrg test -z "$install_prog" && \ 2135ea133fd7Smrg func_fatal_help "you must specify an install program" 2136a253d6aeSmrg 2137ea133fd7Smrg test -n "$prev" && \ 2138ea133fd7Smrg func_fatal_help "the \`$prev' option requires an argument" 2139a253d6aeSmrg 214025b89263Smrg if test -n "$install_override_mode" && $no_mode; then 214125b89263Smrg if $install_cp; then :; else 214225b89263Smrg func_quote_for_eval "$install_override_mode" 214325b89263Smrg install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result" 214425b89263Smrg fi 214525b89263Smrg fi 214625b89263Smrg 2147ea133fd7Smrg if test -z "$files"; then 2148ea133fd7Smrg if test -z "$dest"; then 2149ea133fd7Smrg func_fatal_help "no file or destination specified" 2150ea133fd7Smrg else 2151ea133fd7Smrg func_fatal_help "you must specify a destination" 2152a253d6aeSmrg fi 2153a253d6aeSmrg fi 2154a253d6aeSmrg 2155ea133fd7Smrg # Strip any trailing slash from the destination. 2156ea133fd7Smrg func_stripname '' '/' "$dest" 2157ea133fd7Smrg dest=$func_stripname_result 2158a253d6aeSmrg 2159ea133fd7Smrg # Check to see that the destination is a directory. 2160ea133fd7Smrg test -d "$dest" && isdir=yes 2161ea133fd7Smrg if test "$isdir" = yes; then 2162ea133fd7Smrg destdir="$dest" 2163ea133fd7Smrg destname= 2164ea133fd7Smrg else 2165ea133fd7Smrg func_dirname_and_basename "$dest" "" "." 2166ea133fd7Smrg destdir="$func_dirname_result" 2167ea133fd7Smrg destname="$func_basename_result" 2168ea133fd7Smrg 2169ea133fd7Smrg # Not a directory, so check to see that there is only one file specified. 2170ea133fd7Smrg set dummy $files; shift 2171ea133fd7Smrg test "$#" -gt 1 && \ 2172ea133fd7Smrg func_fatal_help "\`$dest' is not a directory" 2173ea133fd7Smrg fi 2174ea133fd7Smrg case $destdir in 2175ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 2176a253d6aeSmrg *) 2177ea133fd7Smrg for file in $files; do 2178ea133fd7Smrg case $file in 2179ea133fd7Smrg *.lo) ;; 2180ea133fd7Smrg *) 2181ea133fd7Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 2182ea133fd7Smrg ;; 2183ea133fd7Smrg esac 2184ea133fd7Smrg done 2185a253d6aeSmrg ;; 2186a253d6aeSmrg esac 2187a253d6aeSmrg 2188ea133fd7Smrg # This variable tells wrapper scripts just to set variables rather 2189ea133fd7Smrg # than running their programs. 2190ea133fd7Smrg libtool_install_magic="$magic" 2191a253d6aeSmrg 2192ea133fd7Smrg staticlibs= 2193ea133fd7Smrg future_libdirs= 2194ea133fd7Smrg current_libdirs= 2195ea133fd7Smrg for file in $files; do 2196a253d6aeSmrg 2197ea133fd7Smrg # Do each installation. 2198ea133fd7Smrg case $file in 2199ea133fd7Smrg *.$libext) 2200ea133fd7Smrg # Do the static libraries later. 2201ea133fd7Smrg staticlibs="$staticlibs $file" 2202ea133fd7Smrg ;; 2203ea133fd7Smrg 2204ea133fd7Smrg *.la) 2205ea133fd7Smrg # Check to see that this really is a libtool archive. 2206ea133fd7Smrg func_lalib_unsafe_p "$file" \ 2207ea133fd7Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 2208ea133fd7Smrg 2209ea133fd7Smrg library_names= 2210ea133fd7Smrg old_library= 2211ea133fd7Smrg relink_command= 2212ea133fd7Smrg func_source "$file" 2213ea133fd7Smrg 2214ea133fd7Smrg # Add the libdir to current_libdirs if it is the destination. 2215ea133fd7Smrg if test "X$destdir" = "X$libdir"; then 2216ea133fd7Smrg case "$current_libdirs " in 2217ea133fd7Smrg *" $libdir "*) ;; 2218ea133fd7Smrg *) current_libdirs="$current_libdirs $libdir" ;; 2219a253d6aeSmrg esac 2220ea133fd7Smrg else 2221ea133fd7Smrg # Note the libdir as a future libdir. 2222ea133fd7Smrg case "$future_libdirs " in 2223ea133fd7Smrg *" $libdir "*) ;; 2224ea133fd7Smrg *) future_libdirs="$future_libdirs $libdir" ;; 2225ea133fd7Smrg esac 2226ea133fd7Smrg fi 2227a253d6aeSmrg 2228ea133fd7Smrg func_dirname "$file" "/" "" 2229ea133fd7Smrg dir="$func_dirname_result" 2230ea133fd7Smrg dir="$dir$objdir" 2231ea133fd7Smrg 2232ea133fd7Smrg if test -n "$relink_command"; then 2233ea133fd7Smrg # Determine the prefix the user has applied to our future dir. 223425b89263Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2235ea133fd7Smrg 2236ea133fd7Smrg # Don't allow the user to place us outside of our expected 2237ea133fd7Smrg # location b/c this prevents finding dependent libraries that 2238ea133fd7Smrg # are installed to the same prefix. 2239ea133fd7Smrg # At present, this check doesn't affect windows .dll's that 2240ea133fd7Smrg # are installed into $libdir/../bin (currently, that works fine) 2241ea133fd7Smrg # but it's something to keep an eye on. 2242ea133fd7Smrg test "$inst_prefix_dir" = "$destdir" && \ 2243ea133fd7Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 2244ea133fd7Smrg 2245ea133fd7Smrg if test -n "$inst_prefix_dir"; then 2246ea133fd7Smrg # Stick the inst_prefix_dir data into the link command. 224725b89263Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2248ea133fd7Smrg else 224925b89263Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2250ea133fd7Smrg fi 2251ea133fd7Smrg 2252ea133fd7Smrg func_warning "relinking \`$file'" 2253ea133fd7Smrg func_show_eval "$relink_command" \ 2254ea133fd7Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 2255ea133fd7Smrg fi 2256ea133fd7Smrg 2257ea133fd7Smrg # See the names of the shared library. 2258ea133fd7Smrg set dummy $library_names; shift 2259ea133fd7Smrg if test -n "$1"; then 2260ea133fd7Smrg realname="$1" 2261ea133fd7Smrg shift 2262ea133fd7Smrg 2263ea133fd7Smrg srcname="$realname" 2264ea133fd7Smrg test -n "$relink_command" && srcname="$realname"T 2265ea133fd7Smrg 2266ea133fd7Smrg # Install the shared library and build the symlinks. 226725b89263Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 2268ea133fd7Smrg 'exit $?' 2269ea133fd7Smrg tstripme="$stripme" 2270ea133fd7Smrg case $host_os in 2271ea133fd7Smrg cygwin* | mingw* | pw32* | cegcc*) 2272ea133fd7Smrg case $realname in 2273ea133fd7Smrg *.dll.a) 2274ea133fd7Smrg tstripme="" 2275ea133fd7Smrg ;; 2276ea133fd7Smrg esac 2277a253d6aeSmrg ;; 2278a253d6aeSmrg esac 2279ea133fd7Smrg if test -n "$tstripme" && test -n "$striplib"; then 2280ea133fd7Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 2281a253d6aeSmrg fi 2282ea133fd7Smrg 2283ea133fd7Smrg if test "$#" -gt 0; then 2284ea133fd7Smrg # Delete the old symlinks, and create new ones. 2285ea133fd7Smrg # Try `ln -sf' first, because the `ln' binary might depend on 2286ea133fd7Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 2287ea133fd7Smrg # so we also need to try rm && ln -s. 2288ea133fd7Smrg for linkname 2289ea133fd7Smrg do 2290ea133fd7Smrg test "$linkname" != "$realname" \ 2291ea133fd7Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 2292a253d6aeSmrg done 2293a253d6aeSmrg fi 2294a253d6aeSmrg 2295ea133fd7Smrg # Do each command in the postinstall commands. 2296ea133fd7Smrg lib="$destdir/$realname" 2297ea133fd7Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 2298a253d6aeSmrg fi 2299a253d6aeSmrg 2300ea133fd7Smrg # Install the pseudo-library for information purposes. 2301ea133fd7Smrg func_basename "$file" 2302ea133fd7Smrg name="$func_basename_result" 2303ea133fd7Smrg instname="$dir/$name"i 2304ea133fd7Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 2305a253d6aeSmrg 2306ea133fd7Smrg # Maybe install the static library, too. 2307ea133fd7Smrg test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" 2308ea133fd7Smrg ;; 2309a253d6aeSmrg 2310ea133fd7Smrg *.lo) 2311ea133fd7Smrg # Install (i.e. copy) a libtool object. 2312a253d6aeSmrg 2313ea133fd7Smrg # Figure out destination file name, if it wasn't already specified. 2314ea133fd7Smrg if test -n "$destname"; then 2315ea133fd7Smrg destfile="$destdir/$destname" 2316ea133fd7Smrg else 2317ea133fd7Smrg func_basename "$file" 2318ea133fd7Smrg destfile="$func_basename_result" 2319ea133fd7Smrg destfile="$destdir/$destfile" 2320ea133fd7Smrg fi 2321ea133fd7Smrg 2322ea133fd7Smrg # Deduce the name of the destination old-style object file. 2323ea133fd7Smrg case $destfile in 2324ea133fd7Smrg *.lo) 2325ea133fd7Smrg func_lo2o "$destfile" 2326ea133fd7Smrg staticdest=$func_lo2o_result 2327ea133fd7Smrg ;; 2328ea133fd7Smrg *.$objext) 2329ea133fd7Smrg staticdest="$destfile" 2330ea133fd7Smrg destfile= 2331ea133fd7Smrg ;; 2332ea133fd7Smrg *) 2333ea133fd7Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 2334ea133fd7Smrg ;; 2335a253d6aeSmrg esac 2336a253d6aeSmrg 2337ea133fd7Smrg # Install the libtool object if requested. 2338ea133fd7Smrg test -n "$destfile" && \ 2339ea133fd7Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 2340ea133fd7Smrg 2341ea133fd7Smrg # Install the old object if enabled. 2342ea133fd7Smrg if test "$build_old_libs" = yes; then 2343ea133fd7Smrg # Deduce the name of the old-style object file. 2344ea133fd7Smrg func_lo2o "$file" 2345ea133fd7Smrg staticobj=$func_lo2o_result 2346ea133fd7Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 2347a253d6aeSmrg fi 2348ea133fd7Smrg exit $EXIT_SUCCESS 2349ea133fd7Smrg ;; 2350a253d6aeSmrg 2351ea133fd7Smrg *) 2352ea133fd7Smrg # Figure out destination file name, if it wasn't already specified. 2353ea133fd7Smrg if test -n "$destname"; then 2354ea133fd7Smrg destfile="$destdir/$destname" 2355ea133fd7Smrg else 2356ea133fd7Smrg func_basename "$file" 2357ea133fd7Smrg destfile="$func_basename_result" 2358ea133fd7Smrg destfile="$destdir/$destfile" 2359ea133fd7Smrg fi 2360ea133fd7Smrg 2361ea133fd7Smrg # If the file is missing, and there is a .exe on the end, strip it 2362ea133fd7Smrg # because it is most likely a libtool script we actually want to 2363ea133fd7Smrg # install 2364ea133fd7Smrg stripped_ext="" 2365ea133fd7Smrg case $file in 2366ea133fd7Smrg *.exe) 2367ea133fd7Smrg if test ! -f "$file"; then 2368ea133fd7Smrg func_stripname '' '.exe' "$file" 2369ea133fd7Smrg file=$func_stripname_result 2370ea133fd7Smrg stripped_ext=".exe" 2371a253d6aeSmrg fi 2372ea133fd7Smrg ;; 2373ea133fd7Smrg esac 2374a253d6aeSmrg 2375ea133fd7Smrg # Do a test to see if this is really a libtool program. 2376ea133fd7Smrg case $host in 2377ea133fd7Smrg *cygwin* | *mingw*) 2378ea133fd7Smrg if func_ltwrapper_executable_p "$file"; then 2379ea133fd7Smrg func_ltwrapper_scriptname "$file" 2380ea133fd7Smrg wrapper=$func_ltwrapper_scriptname_result 2381ea133fd7Smrg else 2382ea133fd7Smrg func_stripname '' '.exe' "$file" 2383ea133fd7Smrg wrapper=$func_stripname_result 2384ea133fd7Smrg fi 2385ea133fd7Smrg ;; 2386ea133fd7Smrg *) 2387ea133fd7Smrg wrapper=$file 2388ea133fd7Smrg ;; 2389ea133fd7Smrg esac 2390ea133fd7Smrg if func_ltwrapper_script_p "$wrapper"; then 2391ea133fd7Smrg notinst_deplibs= 2392ea133fd7Smrg relink_command= 2393a253d6aeSmrg 2394ea133fd7Smrg func_source "$wrapper" 2395a253d6aeSmrg 2396ea133fd7Smrg # Check the variables that should have been set. 2397ea133fd7Smrg test -z "$generated_by_libtool_version" && \ 2398ea133fd7Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 2399ea133fd7Smrg 2400ea133fd7Smrg finalize=yes 2401ea133fd7Smrg for lib in $notinst_deplibs; do 2402ea133fd7Smrg # Check to see that each library is installed. 2403ea133fd7Smrg libdir= 2404ea133fd7Smrg if test -f "$lib"; then 2405ea133fd7Smrg func_source "$lib" 2406ea133fd7Smrg fi 240725b89263Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 2408ea133fd7Smrg if test -n "$libdir" && test ! -f "$libfile"; then 2409ea133fd7Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 2410ea133fd7Smrg finalize=no 2411ea133fd7Smrg fi 2412ea133fd7Smrg done 2413ea133fd7Smrg 2414ea133fd7Smrg relink_command= 2415ea133fd7Smrg func_source "$wrapper" 2416ea133fd7Smrg 2417ea133fd7Smrg outputname= 2418ea133fd7Smrg if test "$fast_install" = no && test -n "$relink_command"; then 2419ea133fd7Smrg $opt_dry_run || { 2420ea133fd7Smrg if test "$finalize" = yes; then 2421ea133fd7Smrg tmpdir=`func_mktempdir` 2422ea133fd7Smrg func_basename "$file$stripped_ext" 2423ea133fd7Smrg file="$func_basename_result" 2424ea133fd7Smrg outputname="$tmpdir/$file" 2425ea133fd7Smrg # Replace the output file specification. 242625b89263Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 2427ea133fd7Smrg 2428ea133fd7Smrg $opt_silent || { 2429ea133fd7Smrg func_quote_for_expand "$relink_command" 2430ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 2431ea133fd7Smrg } 2432ea133fd7Smrg if eval "$relink_command"; then : 2433ea133fd7Smrg else 2434ea133fd7Smrg func_error "error: relink \`$file' with the above command before installing it" 2435ea133fd7Smrg $opt_dry_run || ${RM}r "$tmpdir" 2436ea133fd7Smrg continue 2437ea133fd7Smrg fi 2438ea133fd7Smrg file="$outputname" 2439ea133fd7Smrg else 2440ea133fd7Smrg func_warning "cannot relink \`$file'" 2441ea133fd7Smrg fi 2442ea133fd7Smrg } 2443a253d6aeSmrg else 2444ea133fd7Smrg # Install the binary that we compiled earlier. 244525b89263Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 2446a253d6aeSmrg fi 2447ea133fd7Smrg fi 2448a253d6aeSmrg 2449ea133fd7Smrg # remove .exe since cygwin /usr/bin/install will append another 2450ea133fd7Smrg # one anyway 2451ea133fd7Smrg case $install_prog,$host in 2452ea133fd7Smrg */usr/bin/install*,*cygwin*) 2453ea133fd7Smrg case $file:$destfile in 2454ea133fd7Smrg *.exe:*.exe) 2455ea133fd7Smrg # this is ok 2456ea133fd7Smrg ;; 2457ea133fd7Smrg *.exe:*) 2458ea133fd7Smrg destfile=$destfile.exe 2459ea133fd7Smrg ;; 2460ea133fd7Smrg *:*.exe) 2461ea133fd7Smrg func_stripname '' '.exe' "$destfile" 2462ea133fd7Smrg destfile=$func_stripname_result 2463ea133fd7Smrg ;; 2464ea133fd7Smrg esac 2465a253d6aeSmrg ;; 2466a253d6aeSmrg esac 2467ea133fd7Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 2468ea133fd7Smrg $opt_dry_run || if test -n "$outputname"; then 2469ea133fd7Smrg ${RM}r "$tmpdir" 2470ea133fd7Smrg fi 2471ea133fd7Smrg ;; 2472ea133fd7Smrg esac 2473ea133fd7Smrg done 2474a253d6aeSmrg 2475ea133fd7Smrg for file in $staticlibs; do 2476ea133fd7Smrg func_basename "$file" 2477ea133fd7Smrg name="$func_basename_result" 2478a253d6aeSmrg 2479ea133fd7Smrg # Set up the ranlib parameters. 2480ea133fd7Smrg oldlib="$destdir/$name" 2481a253d6aeSmrg 2482ea133fd7Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 2483a253d6aeSmrg 2484ea133fd7Smrg if test -n "$stripme" && test -n "$old_striplib"; then 2485ea133fd7Smrg func_show_eval "$old_striplib $oldlib" 'exit $?' 2486ea133fd7Smrg fi 2487a253d6aeSmrg 2488ea133fd7Smrg # Do each command in the postinstall commands. 2489ea133fd7Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 2490ea133fd7Smrg done 2491a253d6aeSmrg 2492ea133fd7Smrg test -n "$future_libdirs" && \ 2493ea133fd7Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 2494a253d6aeSmrg 2495ea133fd7Smrg if test -n "$current_libdirs"; then 2496ea133fd7Smrg # Maybe just do a dry run. 2497ea133fd7Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 2498ea133fd7Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 2499ea133fd7Smrg else 2500ea133fd7Smrg exit $EXIT_SUCCESS 2501ea133fd7Smrg fi 2502ea133fd7Smrg} 2503a253d6aeSmrg 2504ea133fd7Smrgtest "$mode" = install && func_mode_install ${1+"$@"} 2505a253d6aeSmrg 2506a253d6aeSmrg 2507ea133fd7Smrg# func_generate_dlsyms outputname originator pic_p 2508ea133fd7Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 2509ea133fd7Smrg# a dlpreopen symbol table. 2510ea133fd7Smrgfunc_generate_dlsyms () 2511ea133fd7Smrg{ 2512ea133fd7Smrg $opt_debug 2513ea133fd7Smrg my_outputname="$1" 2514ea133fd7Smrg my_originator="$2" 2515ea133fd7Smrg my_pic_p="${3-no}" 2516ea133fd7Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 2517ea133fd7Smrg my_dlsyms= 2518ea133fd7Smrg 2519ea133fd7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 2520ea133fd7Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 2521ea133fd7Smrg my_dlsyms="${my_outputname}S.c" 2522ea133fd7Smrg else 2523ea133fd7Smrg func_error "not configured to extract global symbols from dlpreopened files" 2524ea133fd7Smrg fi 2525ea133fd7Smrg fi 2526a253d6aeSmrg 2527ea133fd7Smrg if test -n "$my_dlsyms"; then 2528ea133fd7Smrg case $my_dlsyms in 2529ea133fd7Smrg "") ;; 2530ea133fd7Smrg *.c) 2531ea133fd7Smrg # Discover the nlist of each of the dlfiles. 2532ea133fd7Smrg nlist="$output_objdir/${my_outputname}.nm" 2533ea133fd7Smrg 2534ea133fd7Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 2535ea133fd7Smrg 2536ea133fd7Smrg # Parse the name list into a source file. 2537ea133fd7Smrg func_verbose "creating $output_objdir/$my_dlsyms" 2538ea133fd7Smrg 2539ea133fd7Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 2540ea133fd7Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 2541ea133fd7Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 2542ea133fd7Smrg 2543ea133fd7Smrg#ifdef __cplusplus 2544ea133fd7Smrgextern \"C\" { 2545ea133fd7Smrg#endif 2546ea133fd7Smrg 254725b89263Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 254825b89263Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 254925b89263Smrg#endif 255025b89263Smrg 2551ea133fd7Smrg/* External symbol declarations for the compiler. */\ 2552ea133fd7Smrg" 2553ea133fd7Smrg 2554ea133fd7Smrg if test "$dlself" = yes; then 2555ea133fd7Smrg func_verbose "generating symbol list for \`$output'" 2556ea133fd7Smrg 2557ea133fd7Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 2558ea133fd7Smrg 2559ea133fd7Smrg # Add our own program objects to the symbol list. 256025b89263Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 2561ea133fd7Smrg for progfile in $progfiles; do 2562ea133fd7Smrg func_verbose "extracting global C symbols from \`$progfile'" 2563ea133fd7Smrg $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" 2564ea133fd7Smrg done 2565ea133fd7Smrg 2566ea133fd7Smrg if test -n "$exclude_expsyms"; then 2567ea133fd7Smrg $opt_dry_run || { 2568ea133fd7Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 2569ea133fd7Smrg eval '$MV "$nlist"T "$nlist"' 2570ea133fd7Smrg } 2571a253d6aeSmrg fi 2572a253d6aeSmrg 2573ea133fd7Smrg if test -n "$export_symbols_regex"; then 2574ea133fd7Smrg $opt_dry_run || { 2575ea133fd7Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 2576ea133fd7Smrg eval '$MV "$nlist"T "$nlist"' 2577ea133fd7Smrg } 2578a253d6aeSmrg fi 2579ea133fd7Smrg 2580ea133fd7Smrg # Prepare the list of exported symbols 2581ea133fd7Smrg if test -z "$export_symbols"; then 2582ea133fd7Smrg export_symbols="$output_objdir/$outputname.exp" 2583ea133fd7Smrg $opt_dry_run || { 2584ea133fd7Smrg $RM $export_symbols 2585ea133fd7Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 2586ea133fd7Smrg case $host in 2587ea133fd7Smrg *cygwin* | *mingw* | *cegcc* ) 2588ea133fd7Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 2589ea133fd7Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 2590ea133fd7Smrg ;; 2591a253d6aeSmrg esac 2592ea133fd7Smrg } 2593ea133fd7Smrg else 2594ea133fd7Smrg $opt_dry_run || { 2595ea133fd7Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 2596ea133fd7Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 2597ea133fd7Smrg eval '$MV "$nlist"T "$nlist"' 2598ea133fd7Smrg case $host in 259925b89263Smrg *cygwin* | *mingw* | *cegcc* ) 2600ea133fd7Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 2601ea133fd7Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 2602ea133fd7Smrg ;; 2603a253d6aeSmrg esac 2604ea133fd7Smrg } 2605a253d6aeSmrg fi 2606ea133fd7Smrg fi 2607a253d6aeSmrg 2608ea133fd7Smrg for dlprefile in $dlprefiles; do 2609ea133fd7Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 2610ea133fd7Smrg func_basename "$dlprefile" 2611ea133fd7Smrg name="$func_basename_result" 2612ea133fd7Smrg $opt_dry_run || { 2613ea133fd7Smrg eval '$ECHO ": $name " >> "$nlist"' 2614ea133fd7Smrg eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" 2615ea133fd7Smrg } 2616ea133fd7Smrg done 2617a253d6aeSmrg 2618ea133fd7Smrg $opt_dry_run || { 2619ea133fd7Smrg # Make sure we have at least an empty file. 2620ea133fd7Smrg test -f "$nlist" || : > "$nlist" 2621a253d6aeSmrg 2622ea133fd7Smrg if test -n "$exclude_expsyms"; then 2623ea133fd7Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 2624ea133fd7Smrg $MV "$nlist"T "$nlist" 2625a253d6aeSmrg fi 2626a253d6aeSmrg 2627ea133fd7Smrg # Try sorting and uniquifying the output. 2628ea133fd7Smrg if $GREP -v "^: " < "$nlist" | 2629ea133fd7Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 2630ea133fd7Smrg sort -k 3 2631a253d6aeSmrg else 2632ea133fd7Smrg sort +2 2633ea133fd7Smrg fi | 2634ea133fd7Smrg uniq > "$nlist"S; then 2635ea133fd7Smrg : 2636a253d6aeSmrg else 2637ea133fd7Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 2638a253d6aeSmrg fi 2639a253d6aeSmrg 2640ea133fd7Smrg if test -f "$nlist"S; then 2641ea133fd7Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 2642a253d6aeSmrg else 264325b89263Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 2644a253d6aeSmrg fi 2645a253d6aeSmrg 264625b89263Smrg echo >> "$output_objdir/$my_dlsyms" "\ 2647a253d6aeSmrg 2648ea133fd7Smrg/* The mapping between symbol names and symbols. */ 2649ea133fd7Smrgtypedef struct { 2650ea133fd7Smrg const char *name; 2651ea133fd7Smrg void *address; 2652ea133fd7Smrg} lt_dlsymlist; 2653ea133fd7Smrg" 2654ea133fd7Smrg case $host in 2655ea133fd7Smrg *cygwin* | *mingw* | *cegcc* ) 265625b89263Smrg echo >> "$output_objdir/$my_dlsyms" "\ 2657ea133fd7Smrg/* DATA imports from DLLs on WIN32 con't be const, because 2658ea133fd7Smrg runtime relocations are performed -- see ld's documentation 2659ea133fd7Smrg on pseudo-relocs. */" 2660ea133fd7Smrg lt_dlsym_const= ;; 2661ea133fd7Smrg *osf5*) 2662ea133fd7Smrg echo >> "$output_objdir/$my_dlsyms" "\ 2663ea133fd7Smrg/* This system does not cope well with relocations in const data */" 2664ea133fd7Smrg lt_dlsym_const= ;; 2665ea133fd7Smrg *) 2666ea133fd7Smrg lt_dlsym_const=const ;; 2667ea133fd7Smrg esac 2668ea133fd7Smrg 266925b89263Smrg echo >> "$output_objdir/$my_dlsyms" "\ 2670ea133fd7Smrgextern $lt_dlsym_const lt_dlsymlist 2671ea133fd7Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 2672ea133fd7Smrg$lt_dlsym_const lt_dlsymlist 2673ea133fd7Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 2674ea133fd7Smrg{\ 2675ea133fd7Smrg { \"$my_originator\", (void *) 0 }," 2676ea133fd7Smrg 2677ea133fd7Smrg case $need_lib_prefix in 2678ea133fd7Smrg no) 2679ea133fd7Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 2680ea133fd7Smrg ;; 2681ea133fd7Smrg *) 2682ea133fd7Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 2683ea133fd7Smrg ;; 2684ea133fd7Smrg esac 268525b89263Smrg echo >> "$output_objdir/$my_dlsyms" "\ 2686ea133fd7Smrg {0, (void *) 0} 2687ea133fd7Smrg}; 2688ea133fd7Smrg 2689ea133fd7Smrg/* This works around a problem in FreeBSD linker */ 2690ea133fd7Smrg#ifdef FREEBSD_WORKAROUND 2691ea133fd7Smrgstatic const void *lt_preloaded_setup() { 2692ea133fd7Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 2693ea133fd7Smrg} 2694ea133fd7Smrg#endif 2695ea133fd7Smrg 2696ea133fd7Smrg#ifdef __cplusplus 2697ea133fd7Smrg} 2698ea133fd7Smrg#endif\ 2699ea133fd7Smrg" 2700ea133fd7Smrg } # !$opt_dry_run 2701ea133fd7Smrg 2702ea133fd7Smrg pic_flag_for_symtable= 2703ea133fd7Smrg case "$compile_command " in 2704ea133fd7Smrg *" -static "*) ;; 2705ea133fd7Smrg *) 2706ea133fd7Smrg case $host in 2707ea133fd7Smrg # compiling the symbol table file with pic_flag works around 2708ea133fd7Smrg # a FreeBSD bug that causes programs to crash when -lm is 2709ea133fd7Smrg # linked before any other PIC object. But we must not use 2710ea133fd7Smrg # pic_flag when linking with -static. The problem exists in 2711ea133fd7Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 2712ea133fd7Smrg *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 2713ea133fd7Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 2714ea133fd7Smrg *-*-hpux*) 2715ea133fd7Smrg pic_flag_for_symtable=" $pic_flag" ;; 2716ea133fd7Smrg *) 2717ea133fd7Smrg if test "X$my_pic_p" != Xno; then 2718ea133fd7Smrg pic_flag_for_symtable=" $pic_flag" 2719a253d6aeSmrg fi 2720ea133fd7Smrg ;; 2721ea133fd7Smrg esac 2722ea133fd7Smrg ;; 2723ea133fd7Smrg esac 2724ea133fd7Smrg symtab_cflags= 2725ea133fd7Smrg for arg in $LTCFLAGS; do 2726ea133fd7Smrg case $arg in 2727ea133fd7Smrg -pie | -fpie | -fPIE) ;; 2728ea133fd7Smrg *) symtab_cflags="$symtab_cflags $arg" ;; 2729ea133fd7Smrg esac 2730ea133fd7Smrg done 2731a253d6aeSmrg 2732ea133fd7Smrg # Now compile the dynamic symbol file. 2733ea133fd7Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 2734a253d6aeSmrg 2735ea133fd7Smrg # Clean up the generated files. 2736ea133fd7Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 2737ea133fd7Smrg 2738ea133fd7Smrg # Transform the symbol file into the correct name. 2739ea133fd7Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 2740ea133fd7Smrg case $host in 2741ea133fd7Smrg *cygwin* | *mingw* | *cegcc* ) 2742ea133fd7Smrg if test -f "$output_objdir/$my_outputname.def"; then 274325b89263Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 274425b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 2745ea133fd7Smrg else 274625b89263Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 274725b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 2748ea133fd7Smrg fi 2749ea133fd7Smrg ;; 2750ea133fd7Smrg *) 275125b89263Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 275225b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 2753a253d6aeSmrg ;; 2754a253d6aeSmrg esac 2755ea133fd7Smrg ;; 2756ea133fd7Smrg *) 2757ea133fd7Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 2758ea133fd7Smrg ;; 2759ea133fd7Smrg esac 2760ea133fd7Smrg else 2761ea133fd7Smrg # We keep going just in case the user didn't refer to 2762ea133fd7Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 2763ea133fd7Smrg # really was required. 2764ea133fd7Smrg 2765ea133fd7Smrg # Nullify the symbol file. 276625b89263Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 276725b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 2768a253d6aeSmrg fi 2769ea133fd7Smrg} 2770a253d6aeSmrg 2771ea133fd7Smrg# func_win32_libid arg 2772ea133fd7Smrg# return the library type of file 'arg' 2773ea133fd7Smrg# 2774ea133fd7Smrg# Need a lot of goo to handle *both* DLLs and import libs 2775ea133fd7Smrg# Has to be a shell function in order to 'eat' the argument 2776ea133fd7Smrg# that is supplied when $file_magic_command is called. 277725b89263Smrg# Despite the name, also deal with 64 bit binaries. 2778ea133fd7Smrgfunc_win32_libid () 2779ea133fd7Smrg{ 2780ea133fd7Smrg $opt_debug 2781ea133fd7Smrg win32_libid_type="unknown" 2782ea133fd7Smrg win32_fileres=`file -L $1 2>/dev/null` 2783ea133fd7Smrg case $win32_fileres in 2784ea133fd7Smrg *ar\ archive\ import\ library*) # definitely import 2785ea133fd7Smrg win32_libid_type="x86 archive import" 2786ea133fd7Smrg ;; 2787ea133fd7Smrg *ar\ archive*) # could be an import, or static 278825b89263Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 2789ea133fd7Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 279025b89263Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 2791ea133fd7Smrg win32_nmres=`eval $NM -f posix -A $1 | 2792ea133fd7Smrg $SED -n -e ' 2793ea133fd7Smrg 1,100{ 2794ea133fd7Smrg / I /{ 2795ea133fd7Smrg s,.*,import, 2796ea133fd7Smrg p 2797ea133fd7Smrg q 2798ea133fd7Smrg } 2799ea133fd7Smrg }'` 2800ea133fd7Smrg case $win32_nmres in 2801ea133fd7Smrg import*) win32_libid_type="x86 archive import";; 2802ea133fd7Smrg *) win32_libid_type="x86 archive static";; 2803ea133fd7Smrg esac 2804ea133fd7Smrg fi 2805ea133fd7Smrg ;; 2806ea133fd7Smrg *DLL*) 2807ea133fd7Smrg win32_libid_type="x86 DLL" 2808ea133fd7Smrg ;; 2809ea133fd7Smrg *executable*) # but shell scripts are "executable" too... 2810ea133fd7Smrg case $win32_fileres in 2811ea133fd7Smrg *MS\ Windows\ PE\ Intel*) 2812ea133fd7Smrg win32_libid_type="x86 DLL" 2813ea133fd7Smrg ;; 2814ea133fd7Smrg esac 2815ea133fd7Smrg ;; 2816ea133fd7Smrg esac 2817ea133fd7Smrg $ECHO "$win32_libid_type" 2818ea133fd7Smrg} 2819a253d6aeSmrg 2820a253d6aeSmrg 2821a253d6aeSmrg 2822ea133fd7Smrg# func_extract_an_archive dir oldlib 2823ea133fd7Smrgfunc_extract_an_archive () 2824ea133fd7Smrg{ 2825ea133fd7Smrg $opt_debug 2826ea133fd7Smrg f_ex_an_ar_dir="$1"; shift 2827ea133fd7Smrg f_ex_an_ar_oldlib="$1" 282825b89263Smrg if test "$lock_old_archive_extraction" = yes; then 282925b89263Smrg lockfile=$f_ex_an_ar_oldlib.lock 283025b89263Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 283125b89263Smrg func_echo "Waiting for $lockfile to be removed" 283225b89263Smrg sleep 2 283325b89263Smrg done 283425b89263Smrg fi 283525b89263Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 283625b89263Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 283725b89263Smrg if test "$lock_old_archive_extraction" = yes; then 283825b89263Smrg $opt_dry_run || rm -f "$lockfile" 283925b89263Smrg fi 2840ea133fd7Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 2841ea133fd7Smrg : 2842ea133fd7Smrg else 2843ea133fd7Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 2844ea133fd7Smrg fi 2845ea133fd7Smrg} 2846a253d6aeSmrg 2847a253d6aeSmrg 2848ea133fd7Smrg# func_extract_archives gentop oldlib ... 2849ea133fd7Smrgfunc_extract_archives () 2850ea133fd7Smrg{ 2851ea133fd7Smrg $opt_debug 2852ea133fd7Smrg my_gentop="$1"; shift 2853ea133fd7Smrg my_oldlibs=${1+"$@"} 2854ea133fd7Smrg my_oldobjs="" 2855ea133fd7Smrg my_xlib="" 2856ea133fd7Smrg my_xabs="" 2857ea133fd7Smrg my_xdir="" 2858a253d6aeSmrg 2859ea133fd7Smrg for my_xlib in $my_oldlibs; do 2860ea133fd7Smrg # Extract the objects. 2861ea133fd7Smrg case $my_xlib in 2862ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 2863ea133fd7Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 2864ea133fd7Smrg esac 2865ea133fd7Smrg func_basename "$my_xlib" 2866ea133fd7Smrg my_xlib="$func_basename_result" 2867ea133fd7Smrg my_xlib_u=$my_xlib 2868ea133fd7Smrg while :; do 2869ea133fd7Smrg case " $extracted_archives " in 2870ea133fd7Smrg *" $my_xlib_u "*) 2871ea133fd7Smrg func_arith $extracted_serial + 1 2872ea133fd7Smrg extracted_serial=$func_arith_result 2873ea133fd7Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 2874ea133fd7Smrg *) break ;; 2875ea133fd7Smrg esac 2876ea133fd7Smrg done 2877ea133fd7Smrg extracted_archives="$extracted_archives $my_xlib_u" 2878ea133fd7Smrg my_xdir="$my_gentop/$my_xlib_u" 2879a253d6aeSmrg 2880ea133fd7Smrg func_mkdir_p "$my_xdir" 2881a253d6aeSmrg 2882ea133fd7Smrg case $host in 2883ea133fd7Smrg *-darwin*) 2884ea133fd7Smrg func_verbose "Extracting $my_xabs" 2885ea133fd7Smrg # Do not bother doing anything if just a dry run 2886ea133fd7Smrg $opt_dry_run || { 2887ea133fd7Smrg darwin_orig_dir=`pwd` 2888ea133fd7Smrg cd $my_xdir || exit $? 2889ea133fd7Smrg darwin_archive=$my_xabs 2890ea133fd7Smrg darwin_curdir=`pwd` 2891ea133fd7Smrg darwin_base_archive=`basename "$darwin_archive"` 2892ea133fd7Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 2893ea133fd7Smrg if test -n "$darwin_arches"; then 2894ea133fd7Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 2895ea133fd7Smrg darwin_arch= 2896ea133fd7Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 2897ea133fd7Smrg for darwin_arch in $darwin_arches ; do 2898ea133fd7Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 2899ea133fd7Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 2900ea133fd7Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 2901ea133fd7Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 2902ea133fd7Smrg cd "$darwin_curdir" 2903ea133fd7Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 2904ea133fd7Smrg done # $darwin_arches 2905ea133fd7Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 2906ea133fd7Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 2907ea133fd7Smrg darwin_file= 2908ea133fd7Smrg darwin_files= 2909ea133fd7Smrg for darwin_file in $darwin_filelist; do 291025b89263Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 2911ea133fd7Smrg $LIPO -create -output "$darwin_file" $darwin_files 2912ea133fd7Smrg done # $darwin_filelist 2913ea133fd7Smrg $RM -rf unfat-$$ 2914ea133fd7Smrg cd "$darwin_orig_dir" 2915ea133fd7Smrg else 2916ea133fd7Smrg cd $darwin_orig_dir 2917ea133fd7Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 2918ea133fd7Smrg fi # $darwin_arches 2919ea133fd7Smrg } # !$opt_dry_run 2920ea133fd7Smrg ;; 2921ea133fd7Smrg *) 2922ea133fd7Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 2923ea133fd7Smrg ;; 2924a253d6aeSmrg esac 292525b89263Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 2926ea133fd7Smrg done 2927a253d6aeSmrg 2928ea133fd7Smrg func_extract_archives_result="$my_oldobjs" 2929ea133fd7Smrg} 2930a253d6aeSmrg 2931a253d6aeSmrg 293225b89263Smrg# func_emit_wrapper [arg=no] 293325b89263Smrg# 293425b89263Smrg# Emit a libtool wrapper script on stdout. 293525b89263Smrg# Don't directly open a file because we may want to 293625b89263Smrg# incorporate the script contents within a cygwin/mingw 293725b89263Smrg# wrapper executable. Must ONLY be called from within 293825b89263Smrg# func_mode_link because it depends on a number of variables 293925b89263Smrg# set therein. 2940ea133fd7Smrg# 294125b89263Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 294225b89263Smrg# variable will take. If 'yes', then the emitted script 294325b89263Smrg# will assume that the directory in which it is stored is 294425b89263Smrg# the $objdir directory. This is a cygwin/mingw-specific 294525b89263Smrg# behavior. 294625b89263Smrgfunc_emit_wrapper () 2947ea133fd7Smrg{ 294825b89263Smrg func_emit_wrapper_arg1=${1-no} 2949a253d6aeSmrg 2950ea133fd7Smrg $ECHO "\ 2951ea133fd7Smrg#! $SHELL 2952a253d6aeSmrg 2953ea133fd7Smrg# $output - temporary wrapper script for $objdir/$outputname 2954ea133fd7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 2955ea133fd7Smrg# 2956ea133fd7Smrg# The $output program cannot be directly executed until all the libtool 2957ea133fd7Smrg# libraries that it depends on are installed. 2958ea133fd7Smrg# 2959ea133fd7Smrg# This wrapper script should never be moved out of the build directory. 2960ea133fd7Smrg# If it is, it will not operate correctly. 2961a253d6aeSmrg 2962ea133fd7Smrg# Sed substitution that helps us do robust quoting. It backslashifies 2963ea133fd7Smrg# metacharacters that are still active within double-quoted strings. 2964ea133fd7Smrgsed_quote_subst='$sed_quote_subst' 2965a253d6aeSmrg 2966ea133fd7Smrg# Be Bourne compatible 2967ea133fd7Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 2968ea133fd7Smrg emulate sh 2969ea133fd7Smrg NULLCMD=: 2970ea133fd7Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 2971ea133fd7Smrg # is contrary to our usage. Disable this feature. 2972ea133fd7Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 2973ea133fd7Smrg setopt NO_GLOB_SUBST 2974ea133fd7Smrgelse 2975ea133fd7Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 2976ea133fd7Smrgfi 2977ea133fd7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 2978ea133fd7SmrgDUALCASE=1; export DUALCASE # for MKS sh 2979a253d6aeSmrg 2980ea133fd7Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 2981ea133fd7Smrg# if CDPATH is set. 2982ea133fd7Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 2983a253d6aeSmrg 2984ea133fd7Smrgrelink_command=\"$relink_command\" 2985a253d6aeSmrg 2986ea133fd7Smrg# This environment variable determines our operation mode. 2987ea133fd7Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 2988ea133fd7Smrg # install mode needs the following variables: 2989ea133fd7Smrg generated_by_libtool_version='$macro_version' 2990ea133fd7Smrg notinst_deplibs='$notinst_deplibs' 2991ea133fd7Smrgelse 2992ea133fd7Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 2993ea133fd7Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 299425b89263Smrg file=\"\$0\"" 299525b89263Smrg 299625b89263Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 299725b89263Smrg $ECHO "\ 299825b89263Smrg 299925b89263Smrg# A function that is used when there is no print builtin or printf. 300025b89263Smrgfunc_fallback_echo () 300125b89263Smrg{ 300225b89263Smrg eval 'cat <<_LTECHO_EOF 300325b89263Smrg\$1 300425b89263Smrg_LTECHO_EOF' 300525b89263Smrg} 300625b89263Smrg ECHO=\"$qECHO\" 300725b89263Smrg fi 300825b89263Smrg 300925b89263Smrg# Very basic option parsing. These options are (a) specific to 301025b89263Smrg# the libtool wrapper, (b) are identical between the wrapper 301125b89263Smrg# /script/ and the wrapper /executable/ which is used only on 301225b89263Smrg# windows platforms, and (c) all begin with the string "--lt-" 301325b89263Smrg# (application programs are unlikely to have options which match 301425b89263Smrg# this pattern). 301525b89263Smrg# 301625b89263Smrg# There are only two supported options: --lt-debug and 301725b89263Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 301825b89263Smrg# 301925b89263Smrg# The first argument to this parsing function should be the 302025b89263Smrg# script's $0 value, followed by "$@". 302125b89263Smrglt_option_debug= 302225b89263Smrgfunc_parse_lt_options () 302325b89263Smrg{ 302425b89263Smrg lt_script_arg0=\$0 302525b89263Smrg shift 302625b89263Smrg for lt_opt 302725b89263Smrg do 302825b89263Smrg case \"\$lt_opt\" in 302925b89263Smrg --lt-debug) lt_option_debug=1 ;; 303025b89263Smrg --lt-dump-script) 303125b89263Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 303225b89263Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 303325b89263Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 303425b89263Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 303525b89263Smrg exit 0 303625b89263Smrg ;; 303725b89263Smrg --lt-*) 303825b89263Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 303925b89263Smrg exit 1 304025b89263Smrg ;; 304125b89263Smrg esac 304225b89263Smrg done 304325b89263Smrg 304425b89263Smrg # Print the debug banner immediately: 304525b89263Smrg if test -n \"\$lt_option_debug\"; then 304625b89263Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 304725b89263Smrg fi 304825b89263Smrg} 304925b89263Smrg 305025b89263Smrg# Used when --lt-debug. Prints its arguments to stdout 305125b89263Smrg# (redirection is the responsibility of the caller) 305225b89263Smrgfunc_lt_dump_args () 305325b89263Smrg{ 305425b89263Smrg lt_dump_args_N=1; 305525b89263Smrg for lt_arg 305625b89263Smrg do 305725b89263Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 305825b89263Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 305925b89263Smrg done 306025b89263Smrg} 306125b89263Smrg 306225b89263Smrg# Core function for launching the target application 306325b89263Smrgfunc_exec_program_core () 306425b89263Smrg{ 3065ea133fd7Smrg" 306625b89263Smrg case $host in 306725b89263Smrg # Backslashes separate directories on plain windows 306825b89263Smrg *-*-mingw | *-*-os2* | *-cegcc*) 306925b89263Smrg $ECHO "\ 307025b89263Smrg if test -n \"\$lt_option_debug\"; then 307125b89263Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 307225b89263Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 307325b89263Smrg fi 307425b89263Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 307525b89263Smrg" 307625b89263Smrg ;; 307725b89263Smrg 307825b89263Smrg *) 307925b89263Smrg $ECHO "\ 308025b89263Smrg if test -n \"\$lt_option_debug\"; then 308125b89263Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 308225b89263Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 308325b89263Smrg fi 308425b89263Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 308525b89263Smrg" 308625b89263Smrg ;; 308725b89263Smrg esac 308825b89263Smrg $ECHO "\ 308925b89263Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 309025b89263Smrg exit 1 309125b89263Smrg} 309225b89263Smrg 309325b89263Smrg# A function to encapsulate launching the target application 309425b89263Smrg# Strips options in the --lt-* namespace from \$@ and 309525b89263Smrg# launches target application with the remaining arguments. 309625b89263Smrgfunc_exec_program () 309725b89263Smrg{ 309825b89263Smrg for lt_wr_arg 309925b89263Smrg do 310025b89263Smrg case \$lt_wr_arg in 310125b89263Smrg --lt-*) ;; 310225b89263Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 310325b89263Smrg esac 310425b89263Smrg shift 310525b89263Smrg done 310625b89263Smrg func_exec_program_core \${1+\"\$@\"} 310725b89263Smrg} 310825b89263Smrg 310925b89263Smrg # Parse options 311025b89263Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 3111a253d6aeSmrg 3112ea133fd7Smrg # Find the directory that this script lives in. 311325b89263Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 3114ea133fd7Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 3115a253d6aeSmrg 3116ea133fd7Smrg # Follow symbolic links until we get to the real thisdir. 311725b89263Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 3118ea133fd7Smrg while test -n \"\$file\"; do 311925b89263Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 3120a253d6aeSmrg 3121ea133fd7Smrg # If there was a directory component, then change thisdir. 3122ea133fd7Smrg if test \"x\$destdir\" != \"x\$file\"; then 3123ea133fd7Smrg case \"\$destdir\" in 3124ea133fd7Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 3125ea133fd7Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 3126ea133fd7Smrg esac 3127ea133fd7Smrg fi 3128a253d6aeSmrg 312925b89263Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 313025b89263Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 3131ea133fd7Smrg done 3132a253d6aeSmrg 3133ea133fd7Smrg # Usually 'no', except on cygwin/mingw when embedded into 3134ea133fd7Smrg # the cwrapper. 313525b89263Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 3136ea133fd7Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 3137ea133fd7Smrg # special case for '.' 3138ea133fd7Smrg if test \"\$thisdir\" = \".\"; then 3139ea133fd7Smrg thisdir=\`pwd\` 3140ea133fd7Smrg fi 3141ea133fd7Smrg # remove .libs from thisdir 3142ea133fd7Smrg case \"\$thisdir\" in 314325b89263Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 3144ea133fd7Smrg $objdir ) thisdir=. ;; 3145ea133fd7Smrg esac 3146ea133fd7Smrg fi 3147a253d6aeSmrg 3148ea133fd7Smrg # Try to get the absolute directory name. 3149ea133fd7Smrg absdir=\`cd \"\$thisdir\" && pwd\` 3150ea133fd7Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 3151ea133fd7Smrg" 3152a253d6aeSmrg 3153ea133fd7Smrg if test "$fast_install" = yes; then 3154ea133fd7Smrg $ECHO "\ 3155ea133fd7Smrg program=lt-'$outputname'$exeext 3156ea133fd7Smrg progdir=\"\$thisdir/$objdir\" 3157a253d6aeSmrg 3158ea133fd7Smrg if test ! -f \"\$progdir/\$program\" || 3159ea133fd7Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 3160ea133fd7Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 3161a253d6aeSmrg 3162ea133fd7Smrg file=\"\$\$-\$program\" 3163a253d6aeSmrg 3164ea133fd7Smrg if test ! -d \"\$progdir\"; then 3165ea133fd7Smrg $MKDIR \"\$progdir\" 3166ea133fd7Smrg else 3167ea133fd7Smrg $RM \"\$progdir/\$file\" 3168ea133fd7Smrg fi" 3169a253d6aeSmrg 3170ea133fd7Smrg $ECHO "\ 3171a253d6aeSmrg 3172ea133fd7Smrg # relink executable if necessary 3173ea133fd7Smrg if test -n \"\$relink_command\"; then 3174ea133fd7Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 3175ea133fd7Smrg else 3176ea133fd7Smrg $ECHO \"\$relink_command_output\" >&2 3177ea133fd7Smrg $RM \"\$progdir/\$file\" 3178ea133fd7Smrg exit 1 3179ea133fd7Smrg fi 3180ea133fd7Smrg fi 3181a253d6aeSmrg 3182ea133fd7Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 3183ea133fd7Smrg { $RM \"\$progdir/\$program\"; 3184ea133fd7Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 3185ea133fd7Smrg $RM \"\$progdir/\$file\" 3186ea133fd7Smrg fi" 3187ea133fd7Smrg else 3188ea133fd7Smrg $ECHO "\ 3189ea133fd7Smrg program='$outputname' 3190ea133fd7Smrg progdir=\"\$thisdir/$objdir\" 3191ea133fd7Smrg" 3192ea133fd7Smrg fi 3193a253d6aeSmrg 3194ea133fd7Smrg $ECHO "\ 3195a253d6aeSmrg 3196ea133fd7Smrg if test -f \"\$progdir/\$program\"; then" 3197a253d6aeSmrg 3198ea133fd7Smrg # Export our shlibpath_var if we have one. 3199ea133fd7Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 3200ea133fd7Smrg $ECHO "\ 3201ea133fd7Smrg # Add our own library path to $shlibpath_var 3202ea133fd7Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 3203a253d6aeSmrg 3204ea133fd7Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 3205ea133fd7Smrg # The second colon is a workaround for a bug in BeOS R4 sed 320625b89263Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 3207a253d6aeSmrg 3208ea133fd7Smrg export $shlibpath_var 3209ea133fd7Smrg" 3210a253d6aeSmrg fi 3211a253d6aeSmrg 3212ea133fd7Smrg # fixup the dll searchpath if we need to. 3213ea133fd7Smrg if test -n "$dllsearchpath"; then 3214ea133fd7Smrg $ECHO "\ 3215ea133fd7Smrg # Add the dll search path components to the executable PATH 3216ea133fd7Smrg PATH=$dllsearchpath:\$PATH 3217ea133fd7Smrg" 3218a253d6aeSmrg fi 3219a253d6aeSmrg 3220ea133fd7Smrg $ECHO "\ 3221ea133fd7Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 3222ea133fd7Smrg # Run the actual program with our arguments. 322325b89263Smrg func_exec_program \${1+\"\$@\"} 3224ea133fd7Smrg fi 3225ea133fd7Smrg else 3226ea133fd7Smrg # The program doesn't exist. 3227ea133fd7Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 3228ea133fd7Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 322925b89263Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 3230ea133fd7Smrg exit 1 3231ea133fd7Smrg fi 3232ea133fd7Smrgfi\ 3233ea133fd7Smrg" 3234ea133fd7Smrg} 3235a253d6aeSmrg 3236a253d6aeSmrg 3237ea133fd7Smrg# func_to_host_path arg 3238ea133fd7Smrg# 3239ea133fd7Smrg# Convert paths to host format when used with build tools. 3240ea133fd7Smrg# Intended for use with "native" mingw (where libtool itself 3241ea133fd7Smrg# is running under the msys shell), or in the following cross- 3242ea133fd7Smrg# build environments: 3243ea133fd7Smrg# $build $host 3244ea133fd7Smrg# mingw (msys) mingw [e.g. native] 3245ea133fd7Smrg# cygwin mingw 3246ea133fd7Smrg# *nix + wine mingw 3247ea133fd7Smrg# where wine is equipped with the `winepath' executable. 3248ea133fd7Smrg# In the native mingw case, the (msys) shell automatically 3249ea133fd7Smrg# converts paths for any non-msys applications it launches, 3250ea133fd7Smrg# but that facility isn't available from inside the cwrapper. 3251ea133fd7Smrg# Similar accommodations are necessary for $host mingw and 3252ea133fd7Smrg# $build cygwin. Calling this function does no harm for other 3253ea133fd7Smrg# $host/$build combinations not listed above. 3254ea133fd7Smrg# 3255ea133fd7Smrg# ARG is the path (on $build) that should be converted to 3256ea133fd7Smrg# the proper representation for $host. The result is stored 3257ea133fd7Smrg# in $func_to_host_path_result. 3258ea133fd7Smrgfunc_to_host_path () 3259ea133fd7Smrg{ 3260ea133fd7Smrg func_to_host_path_result="$1" 326125b89263Smrg if test -n "$1"; then 3262ea133fd7Smrg case $host in 3263ea133fd7Smrg *mingw* ) 3264ea133fd7Smrg lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3265ea133fd7Smrg case $build in 3266ea133fd7Smrg *mingw* ) # actually, msys 3267ea133fd7Smrg # awkward: cmd appends spaces to result 326825b89263Smrg func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null | 326925b89263Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 3270ea133fd7Smrg ;; 3271ea133fd7Smrg *cygwin* ) 327225b89263Smrg func_to_host_path_result=`cygpath -w "$1" | 327325b89263Smrg $SED -e "$lt_sed_naive_backslashify"` 3274ea133fd7Smrg ;; 3275ea133fd7Smrg * ) 3276ea133fd7Smrg # Unfortunately, winepath does not exit with a non-zero 3277ea133fd7Smrg # error code, so we are forced to check the contents of 3278ea133fd7Smrg # stdout. On the other hand, if the command is not 3279ea133fd7Smrg # found, the shell will set an exit code of 127 and print 3280ea133fd7Smrg # *an error message* to stdout. So we must check for both 3281ea133fd7Smrg # error code of zero AND non-empty stdout, which explains 3282ea133fd7Smrg # the odd construction: 3283ea133fd7Smrg func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` 3284ea133fd7Smrg if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then 328525b89263Smrg func_to_host_path_result=`$ECHO "$func_to_host_path_tmp1" | 3286ea133fd7Smrg $SED -e "$lt_sed_naive_backslashify"` 3287ea133fd7Smrg else 3288ea133fd7Smrg # Allow warning below. 328925b89263Smrg func_to_host_path_result= 3290ea133fd7Smrg fi 3291ea133fd7Smrg ;; 3292ea133fd7Smrg esac 3293ea133fd7Smrg if test -z "$func_to_host_path_result" ; then 3294ea133fd7Smrg func_error "Could not determine host path corresponding to" 329525b89263Smrg func_error " \`$1'" 3296ea133fd7Smrg func_error "Continuing, but uninstalled executables may not work." 3297ea133fd7Smrg # Fallback: 3298ea133fd7Smrg func_to_host_path_result="$1" 3299ea133fd7Smrg fi 3300ea133fd7Smrg ;; 3301ea133fd7Smrg esac 3302ea133fd7Smrg fi 3303ea133fd7Smrg} 3304ea133fd7Smrg# end: func_to_host_path 3305a253d6aeSmrg 3306ea133fd7Smrg# func_to_host_pathlist arg 3307ea133fd7Smrg# 3308ea133fd7Smrg# Convert pathlists to host format when used with build tools. 3309ea133fd7Smrg# See func_to_host_path(), above. This function supports the 3310ea133fd7Smrg# following $build/$host combinations (but does no harm for 3311ea133fd7Smrg# combinations not listed here): 3312ea133fd7Smrg# $build $host 3313ea133fd7Smrg# mingw (msys) mingw [e.g. native] 3314ea133fd7Smrg# cygwin mingw 3315ea133fd7Smrg# *nix + wine mingw 3316ea133fd7Smrg# 3317ea133fd7Smrg# Path separators are also converted from $build format to 3318ea133fd7Smrg# $host format. If ARG begins or ends with a path separator 3319ea133fd7Smrg# character, it is preserved (but converted to $host format) 3320ea133fd7Smrg# on output. 3321ea133fd7Smrg# 3322ea133fd7Smrg# ARG is a pathlist (on $build) that should be converted to 3323ea133fd7Smrg# the proper representation on $host. The result is stored 3324ea133fd7Smrg# in $func_to_host_pathlist_result. 3325ea133fd7Smrgfunc_to_host_pathlist () 3326ea133fd7Smrg{ 3327ea133fd7Smrg func_to_host_pathlist_result="$1" 332825b89263Smrg if test -n "$1"; then 3329ea133fd7Smrg case $host in 3330ea133fd7Smrg *mingw* ) 3331ea133fd7Smrg lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 3332ea133fd7Smrg # Remove leading and trailing path separator characters from 3333ea133fd7Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 3334ea133fd7Smrg # into '.;' and ';.', and winepath ignores them completely. 333525b89263Smrg func_stripname : : "$1" 333625b89263Smrg func_to_host_pathlist_tmp1=$func_stripname_result 3337ea133fd7Smrg case $build in 3338ea133fd7Smrg *mingw* ) # Actually, msys. 3339ea133fd7Smrg # Awkward: cmd appends spaces to result. 334025b89263Smrg func_to_host_pathlist_result=` 334125b89263Smrg ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null | 334225b89263Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 3343ea133fd7Smrg ;; 3344ea133fd7Smrg *cygwin* ) 334525b89263Smrg func_to_host_pathlist_result=`cygpath -w -p "$func_to_host_pathlist_tmp1" | 3346ea133fd7Smrg $SED -e "$lt_sed_naive_backslashify"` 3347ea133fd7Smrg ;; 3348ea133fd7Smrg * ) 3349ea133fd7Smrg # unfortunately, winepath doesn't convert pathlists 3350ea133fd7Smrg func_to_host_pathlist_result="" 3351ea133fd7Smrg func_to_host_pathlist_oldIFS=$IFS 3352ea133fd7Smrg IFS=: 3353ea133fd7Smrg for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do 3354ea133fd7Smrg IFS=$func_to_host_pathlist_oldIFS 3355ea133fd7Smrg if test -n "$func_to_host_pathlist_f" ; then 3356ea133fd7Smrg func_to_host_path "$func_to_host_pathlist_f" 3357ea133fd7Smrg if test -n "$func_to_host_path_result" ; then 3358ea133fd7Smrg if test -z "$func_to_host_pathlist_result" ; then 3359ea133fd7Smrg func_to_host_pathlist_result="$func_to_host_path_result" 3360ea133fd7Smrg else 336125b89263Smrg func_append func_to_host_pathlist_result ";$func_to_host_path_result" 3362ea133fd7Smrg fi 3363ea133fd7Smrg fi 3364ea133fd7Smrg fi 3365ea133fd7Smrg done 3366ea133fd7Smrg IFS=$func_to_host_pathlist_oldIFS 3367ea133fd7Smrg ;; 3368ea133fd7Smrg esac 336925b89263Smrg if test -z "$func_to_host_pathlist_result"; then 3370ea133fd7Smrg func_error "Could not determine the host path(s) corresponding to" 337125b89263Smrg func_error " \`$1'" 3372ea133fd7Smrg func_error "Continuing, but uninstalled executables may not work." 3373ea133fd7Smrg # Fallback. This may break if $1 contains DOS-style drive 3374ea133fd7Smrg # specifications. The fix is not to complicate the expression 3375ea133fd7Smrg # below, but for the user to provide a working wine installation 3376ea133fd7Smrg # with winepath so that path translation in the cross-to-mingw 3377ea133fd7Smrg # case works properly. 3378ea133fd7Smrg lt_replace_pathsep_nix_to_dos="s|:|;|g" 3379ea133fd7Smrg func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ 3380ea133fd7Smrg $SED -e "$lt_replace_pathsep_nix_to_dos"` 3381ea133fd7Smrg fi 3382ea133fd7Smrg # Now, add the leading and trailing path separators back 3383ea133fd7Smrg case "$1" in 3384ea133fd7Smrg :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" 3385ea133fd7Smrg ;; 3386ea133fd7Smrg esac 3387ea133fd7Smrg case "$1" in 338825b89263Smrg *: ) func_append func_to_host_pathlist_result ";" 3389ea133fd7Smrg ;; 3390ea133fd7Smrg esac 3391ea133fd7Smrg ;; 3392ea133fd7Smrg esac 3393ea133fd7Smrg fi 3394ea133fd7Smrg} 3395ea133fd7Smrg# end: func_to_host_pathlist 3396a253d6aeSmrg 3397ea133fd7Smrg# func_emit_cwrapperexe_src 3398ea133fd7Smrg# emit the source code for a wrapper executable on stdout 3399ea133fd7Smrg# Must ONLY be called from within func_mode_link because 3400ea133fd7Smrg# it depends on a number of variable set therein. 3401ea133fd7Smrgfunc_emit_cwrapperexe_src () 3402ea133fd7Smrg{ 3403ea133fd7Smrg cat <<EOF 3404a253d6aeSmrg 3405ea133fd7Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 3406ea133fd7Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3407a253d6aeSmrg 3408ea133fd7Smrg The $output program cannot be directly executed until all the libtool 3409ea133fd7Smrg libraries that it depends on are installed. 3410a253d6aeSmrg 3411ea133fd7Smrg This wrapper executable should never be moved out of the build directory. 3412ea133fd7Smrg If it is, it will not operate correctly. 3413ea133fd7Smrg*/ 3414ea133fd7SmrgEOF 3415ea133fd7Smrg cat <<"EOF" 341625b89263Smrg#ifdef _MSC_VER 341725b89263Smrg# define _CRT_SECURE_NO_DEPRECATE 1 341825b89263Smrg#endif 3419ea133fd7Smrg#include <stdio.h> 3420ea133fd7Smrg#include <stdlib.h> 3421ea133fd7Smrg#ifdef _MSC_VER 3422ea133fd7Smrg# include <direct.h> 3423ea133fd7Smrg# include <process.h> 3424ea133fd7Smrg# include <io.h> 3425ea133fd7Smrg#else 3426ea133fd7Smrg# include <unistd.h> 3427ea133fd7Smrg# include <stdint.h> 3428ea133fd7Smrg# ifdef __CYGWIN__ 3429ea133fd7Smrg# include <io.h> 3430ea133fd7Smrg# endif 3431ea133fd7Smrg#endif 3432ea133fd7Smrg#include <malloc.h> 3433ea133fd7Smrg#include <stdarg.h> 3434ea133fd7Smrg#include <assert.h> 3435ea133fd7Smrg#include <string.h> 3436ea133fd7Smrg#include <ctype.h> 3437ea133fd7Smrg#include <errno.h> 3438ea133fd7Smrg#include <fcntl.h> 3439ea133fd7Smrg#include <sys/stat.h> 3440ea133fd7Smrg 344125b89263Smrg/* declarations of non-ANSI functions */ 344225b89263Smrg#if defined(__MINGW32__) 344325b89263Smrg# ifdef __STRICT_ANSI__ 344425b89263Smrgint _putenv (const char *); 344525b89263Smrg# endif 344625b89263Smrg#elif defined(__CYGWIN__) 344725b89263Smrg# ifdef __STRICT_ANSI__ 344825b89263Smrgchar *realpath (const char *, char *); 344925b89263Smrgint putenv (char *); 345025b89263Smrgint setenv (const char *, const char *, int); 345125b89263Smrg# endif 345225b89263Smrg/* #elif defined (other platforms) ... */ 345325b89263Smrg#endif 345425b89263Smrg 345525b89263Smrg/* portability defines, excluding path handling macros */ 345625b89263Smrg#if defined(_MSC_VER) 345725b89263Smrg# define setmode _setmode 345825b89263Smrg# define stat _stat 345925b89263Smrg# define chmod _chmod 346025b89263Smrg# define getcwd _getcwd 346125b89263Smrg# define putenv _putenv 346225b89263Smrg# define S_IXUSR _S_IEXEC 346325b89263Smrg# ifndef _INTPTR_T_DEFINED 346425b89263Smrg# define _INTPTR_T_DEFINED 346525b89263Smrg# define intptr_t int 346625b89263Smrg# endif 346725b89263Smrg#elif defined(__MINGW32__) 346825b89263Smrg# define setmode _setmode 346925b89263Smrg# define stat _stat 347025b89263Smrg# define chmod _chmod 347125b89263Smrg# define getcwd _getcwd 347225b89263Smrg# define putenv _putenv 347325b89263Smrg#elif defined(__CYGWIN__) 347425b89263Smrg# define HAVE_SETENV 347525b89263Smrg# define FOPEN_WB "wb" 347625b89263Smrg/* #elif defined (other platforms) ... */ 347725b89263Smrg#endif 347825b89263Smrg 3479ea133fd7Smrg#if defined(PATH_MAX) 3480ea133fd7Smrg# define LT_PATHMAX PATH_MAX 3481ea133fd7Smrg#elif defined(MAXPATHLEN) 3482ea133fd7Smrg# define LT_PATHMAX MAXPATHLEN 3483ea133fd7Smrg#else 3484ea133fd7Smrg# define LT_PATHMAX 1024 3485ea133fd7Smrg#endif 3486ea133fd7Smrg 3487ea133fd7Smrg#ifndef S_IXOTH 3488ea133fd7Smrg# define S_IXOTH 0 3489ea133fd7Smrg#endif 3490ea133fd7Smrg#ifndef S_IXGRP 3491ea133fd7Smrg# define S_IXGRP 0 3492ea133fd7Smrg#endif 3493ea133fd7Smrg 349425b89263Smrg/* path handling portability macros */ 3495ea133fd7Smrg#ifndef DIR_SEPARATOR 3496ea133fd7Smrg# define DIR_SEPARATOR '/' 3497ea133fd7Smrg# define PATH_SEPARATOR ':' 3498ea133fd7Smrg#endif 3499ea133fd7Smrg 3500ea133fd7Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 3501ea133fd7Smrg defined (__OS2__) 3502ea133fd7Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 3503ea133fd7Smrg# define FOPEN_WB "wb" 3504ea133fd7Smrg# ifndef DIR_SEPARATOR_2 3505ea133fd7Smrg# define DIR_SEPARATOR_2 '\\' 3506ea133fd7Smrg# endif 3507ea133fd7Smrg# ifndef PATH_SEPARATOR_2 3508ea133fd7Smrg# define PATH_SEPARATOR_2 ';' 3509ea133fd7Smrg# endif 3510ea133fd7Smrg#endif 3511ea133fd7Smrg 3512ea133fd7Smrg#ifndef DIR_SEPARATOR_2 3513ea133fd7Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 3514ea133fd7Smrg#else /* DIR_SEPARATOR_2 */ 3515ea133fd7Smrg# define IS_DIR_SEPARATOR(ch) \ 3516ea133fd7Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 3517ea133fd7Smrg#endif /* DIR_SEPARATOR_2 */ 3518ea133fd7Smrg 3519ea133fd7Smrg#ifndef PATH_SEPARATOR_2 3520ea133fd7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 3521ea133fd7Smrg#else /* PATH_SEPARATOR_2 */ 3522ea133fd7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 3523ea133fd7Smrg#endif /* PATH_SEPARATOR_2 */ 3524ea133fd7Smrg 3525ea133fd7Smrg#ifndef FOPEN_WB 3526ea133fd7Smrg# define FOPEN_WB "w" 3527ea133fd7Smrg#endif 3528ea133fd7Smrg#ifndef _O_BINARY 3529ea133fd7Smrg# define _O_BINARY 0 3530ea133fd7Smrg#endif 3531ea133fd7Smrg 3532ea133fd7Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 3533ea133fd7Smrg#define XFREE(stale) do { \ 3534ea133fd7Smrg if (stale) { free ((void *) stale); stale = 0; } \ 3535ea133fd7Smrg} while (0) 3536ea133fd7Smrg 353725b89263Smrg#if defined(LT_DEBUGWRAPPER) 353825b89263Smrgstatic int lt_debug = 1; 3539ea133fd7Smrg#else 354025b89263Smrgstatic int lt_debug = 0; 3541ea133fd7Smrg#endif 3542ea133fd7Smrg 354325b89263Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 3544ea133fd7Smrg 3545ea133fd7Smrgvoid *xmalloc (size_t num); 3546ea133fd7Smrgchar *xstrdup (const char *string); 3547ea133fd7Smrgconst char *base_name (const char *name); 3548ea133fd7Smrgchar *find_executable (const char *wrapper); 3549ea133fd7Smrgchar *chase_symlinks (const char *pathspec); 3550ea133fd7Smrgint make_executable (const char *path); 3551ea133fd7Smrgint check_executable (const char *path); 3552ea133fd7Smrgchar *strendzap (char *str, const char *pat); 355325b89263Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 355425b89263Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 355525b89263Smrgstatic const char *nonnull (const char *s); 355625b89263Smrgstatic const char *nonempty (const char *s); 3557ea133fd7Smrgvoid lt_setenv (const char *name, const char *value); 3558ea133fd7Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 3559ea133fd7Smrgvoid lt_update_exe_path (const char *name, const char *value); 3560ea133fd7Smrgvoid lt_update_lib_path (const char *name, const char *value); 356125b89263Smrgchar **prepare_spawn (char **argv); 356225b89263Smrgvoid lt_dump_script (FILE *f); 3563ea133fd7SmrgEOF 3564ea133fd7Smrg 3565ea133fd7Smrg cat <<EOF 3566ea133fd7Smrgconst char * MAGIC_EXE = "$magic_exe"; 3567ea133fd7Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 3568ea133fd7SmrgEOF 3569ea133fd7Smrg 3570ea133fd7Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 3571ea133fd7Smrg func_to_host_pathlist "$temp_rpath" 3572ea133fd7Smrg cat <<EOF 3573ea133fd7Smrgconst char * LIB_PATH_VALUE = "$func_to_host_pathlist_result"; 3574a253d6aeSmrgEOF 3575a253d6aeSmrg else 3576ea133fd7Smrg cat <<"EOF" 3577ea133fd7Smrgconst char * LIB_PATH_VALUE = ""; 3578ea133fd7SmrgEOF 3579a253d6aeSmrg fi 3580ea133fd7Smrg 3581ea133fd7Smrg if test -n "$dllsearchpath"; then 3582ea133fd7Smrg func_to_host_pathlist "$dllsearchpath:" 3583ea133fd7Smrg cat <<EOF 3584ea133fd7Smrgconst char * EXE_PATH_VARNAME = "PATH"; 3585ea133fd7Smrgconst char * EXE_PATH_VALUE = "$func_to_host_pathlist_result"; 3586ea133fd7SmrgEOF 3587a253d6aeSmrg else 3588ea133fd7Smrg cat <<"EOF" 3589ea133fd7Smrgconst char * EXE_PATH_VARNAME = ""; 3590ea133fd7Smrgconst char * EXE_PATH_VALUE = ""; 3591ea133fd7SmrgEOF 3592a253d6aeSmrg fi 3593ea133fd7Smrg 3594ea133fd7Smrg if test "$fast_install" = yes; then 3595ea133fd7Smrg cat <<EOF 3596ea133fd7Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 3597ea133fd7SmrgEOF 3598a253d6aeSmrg else 3599ea133fd7Smrg cat <<EOF 3600ea133fd7Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 3601ea133fd7SmrgEOF 3602a253d6aeSmrg fi 3603a253d6aeSmrg 3604a253d6aeSmrg 3605ea133fd7Smrg cat <<"EOF" 3606a253d6aeSmrg 3607ea133fd7Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 3608a253d6aeSmrg 3609ea133fd7Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 3610ea133fd7Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 361125b89263Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 3612a253d6aeSmrg 3613ea133fd7Smrgint 3614ea133fd7Smrgmain (int argc, char *argv[]) 3615ea133fd7Smrg{ 3616ea133fd7Smrg char **newargz; 3617ea133fd7Smrg int newargc; 3618ea133fd7Smrg char *tmp_pathspec; 3619ea133fd7Smrg char *actual_cwrapper_path; 3620ea133fd7Smrg char *actual_cwrapper_name; 3621ea133fd7Smrg char *target_name; 3622ea133fd7Smrg char *lt_argv_zero; 3623ea133fd7Smrg intptr_t rval = 127; 3624a253d6aeSmrg 3625ea133fd7Smrg int i; 3626a253d6aeSmrg 3627ea133fd7Smrg program_name = (char *) xstrdup (base_name (argv[0])); 362825b89263Smrg newargz = XMALLOC (char *, argc + 1); 3629a253d6aeSmrg 363025b89263Smrg /* very simple arg parsing; don't want to rely on getopt 363125b89263Smrg * also, copy all non cwrapper options to newargz, except 363225b89263Smrg * argz[0], which is handled differently 363325b89263Smrg */ 363425b89263Smrg newargc=0; 3635ea133fd7Smrg for (i = 1; i < argc; i++) 3636ea133fd7Smrg { 3637ea133fd7Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 3638ea133fd7Smrg { 3639ea133fd7SmrgEOF 3640ea133fd7Smrg case "$host" in 3641ea133fd7Smrg *mingw* | *cygwin* ) 3642ea133fd7Smrg # make stdout use "unix" line endings 3643ea133fd7Smrg echo " setmode(1,_O_BINARY);" 3644ea133fd7Smrg ;; 3645ea133fd7Smrg esac 3646a253d6aeSmrg 3647ea133fd7Smrg cat <<"EOF" 364825b89263Smrg lt_dump_script (stdout); 3649ea133fd7Smrg return 0; 3650ea133fd7Smrg } 365125b89263Smrg if (strcmp (argv[i], debug_opt) == 0) 365225b89263Smrg { 365325b89263Smrg lt_debug = 1; 365425b89263Smrg continue; 365525b89263Smrg } 365625b89263Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 365725b89263Smrg { 365825b89263Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 365925b89263Smrg namespace, but it is not one of the ones we know about and 366025b89263Smrg have already dealt with, above (inluding dump-script), then 366125b89263Smrg report an error. Otherwise, targets might begin to believe 366225b89263Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 366325b89263Smrg namespace. The first time any user complains about this, we'll 366425b89263Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 366525b89263Smrg or a configure.ac-settable value. 366625b89263Smrg */ 366725b89263Smrg lt_fatal (__FILE__, __LINE__, 366825b89263Smrg "unrecognized %s option: '%s'", 366925b89263Smrg ltwrapper_option_prefix, argv[i]); 367025b89263Smrg } 367125b89263Smrg /* otherwise ... */ 367225b89263Smrg newargz[++newargc] = xstrdup (argv[i]); 3673ea133fd7Smrg } 367425b89263Smrg newargz[++newargc] = NULL; 367525b89263Smrg 367625b89263SmrgEOF 367725b89263Smrg cat <<EOF 367825b89263Smrg /* The GNU banner must be the first non-error debug message */ 367925b89263Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 368025b89263SmrgEOF 368125b89263Smrg cat <<"EOF" 368225b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 368325b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 3684a253d6aeSmrg 3685ea133fd7Smrg tmp_pathspec = find_executable (argv[0]); 3686ea133fd7Smrg if (tmp_pathspec == NULL) 368725b89263Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 368825b89263Smrg lt_debugprintf (__FILE__, __LINE__, 368925b89263Smrg "(main) found exe (before symlink chase) at: %s\n", 369025b89263Smrg tmp_pathspec); 3691ea133fd7Smrg 3692ea133fd7Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 369325b89263Smrg lt_debugprintf (__FILE__, __LINE__, 369425b89263Smrg "(main) found exe (after symlink chase) at: %s\n", 369525b89263Smrg actual_cwrapper_path); 3696ea133fd7Smrg XFREE (tmp_pathspec); 3697ea133fd7Smrg 369825b89263Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 3699ea133fd7Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 3700ea133fd7Smrg 3701ea133fd7Smrg /* wrapper name transforms */ 3702ea133fd7Smrg strendzap (actual_cwrapper_name, ".exe"); 3703ea133fd7Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 3704ea133fd7Smrg XFREE (actual_cwrapper_name); 3705ea133fd7Smrg actual_cwrapper_name = tmp_pathspec; 3706ea133fd7Smrg tmp_pathspec = 0; 3707ea133fd7Smrg 3708ea133fd7Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 3709ea133fd7Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 3710ea133fd7Smrg strendzap (target_name, ".exe"); 3711ea133fd7Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 3712ea133fd7Smrg XFREE (target_name); 3713ea133fd7Smrg target_name = tmp_pathspec; 3714ea133fd7Smrg tmp_pathspec = 0; 3715ea133fd7Smrg 371625b89263Smrg lt_debugprintf (__FILE__, __LINE__, 371725b89263Smrg "(main) libtool target name: %s\n", 371825b89263Smrg target_name); 3719ea133fd7SmrgEOF 3720a253d6aeSmrg 3721ea133fd7Smrg cat <<EOF 3722ea133fd7Smrg newargz[0] = 3723ea133fd7Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 3724ea133fd7Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 3725ea133fd7Smrg strcpy (newargz[0], actual_cwrapper_path); 3726ea133fd7Smrg strcat (newargz[0], "$objdir"); 3727ea133fd7Smrg strcat (newargz[0], "/"); 3728ea133fd7SmrgEOF 3729a253d6aeSmrg 3730ea133fd7Smrg cat <<"EOF" 3731ea133fd7Smrg /* stop here, and copy so we don't have to do this twice */ 3732ea133fd7Smrg tmp_pathspec = xstrdup (newargz[0]); 3733a253d6aeSmrg 3734ea133fd7Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 3735ea133fd7Smrg strcat (newargz[0], actual_cwrapper_name); 3736a253d6aeSmrg 3737ea133fd7Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 3738ea133fd7Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 3739ea133fd7Smrg XFREE (tmp_pathspec); 3740ea133fd7Smrg tmp_pathspec = NULL; 3741ea133fd7SmrgEOF 3742a253d6aeSmrg 3743ea133fd7Smrg case $host_os in 3744ea133fd7Smrg mingw*) 3745ea133fd7Smrg cat <<"EOF" 3746ea133fd7Smrg { 3747ea133fd7Smrg char* p; 3748ea133fd7Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 3749ea133fd7Smrg { 3750ea133fd7Smrg *p = '/'; 3751ea133fd7Smrg } 3752ea133fd7Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 3753ea133fd7Smrg { 3754ea133fd7Smrg *p = '/'; 3755ea133fd7Smrg } 3756ea133fd7Smrg } 3757ea133fd7SmrgEOF 3758ea133fd7Smrg ;; 3759ea133fd7Smrg esac 3760a253d6aeSmrg 3761ea133fd7Smrg cat <<"EOF" 3762ea133fd7Smrg XFREE (target_name); 3763ea133fd7Smrg XFREE (actual_cwrapper_path); 3764ea133fd7Smrg XFREE (actual_cwrapper_name); 3765a253d6aeSmrg 3766ea133fd7Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 3767ea133fd7Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 3768ea133fd7Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 3769ea133fd7Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 3770a253d6aeSmrg 377125b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 377225b89263Smrg nonnull (lt_argv_zero)); 3773ea133fd7Smrg for (i = 0; i < newargc; i++) 3774ea133fd7Smrg { 377525b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 377625b89263Smrg i, nonnull (newargz[i])); 3777ea133fd7Smrg } 3778a253d6aeSmrg 3779ea133fd7SmrgEOF 3780a253d6aeSmrg 3781ea133fd7Smrg case $host_os in 3782ea133fd7Smrg mingw*) 3783ea133fd7Smrg cat <<"EOF" 3784ea133fd7Smrg /* execv doesn't actually work on mingw as expected on unix */ 378525b89263Smrg newargz = prepare_spawn (newargz); 3786ea133fd7Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 3787ea133fd7Smrg if (rval == -1) 3788ea133fd7Smrg { 3789ea133fd7Smrg /* failed to start process */ 379025b89263Smrg lt_debugprintf (__FILE__, __LINE__, 379125b89263Smrg "(main) failed to launch target \"%s\": %s\n", 379225b89263Smrg lt_argv_zero, nonnull (strerror (errno))); 3793ea133fd7Smrg return 127; 3794ea133fd7Smrg } 3795ea133fd7Smrg return rval; 3796ea133fd7SmrgEOF 3797ea133fd7Smrg ;; 3798ea133fd7Smrg *) 3799ea133fd7Smrg cat <<"EOF" 3800ea133fd7Smrg execv (lt_argv_zero, newargz); 3801ea133fd7Smrg return rval; /* =127, but avoids unused variable warning */ 3802ea133fd7SmrgEOF 3803ea133fd7Smrg ;; 3804ea133fd7Smrg esac 3805a253d6aeSmrg 3806ea133fd7Smrg cat <<"EOF" 3807ea133fd7Smrg} 3808a253d6aeSmrg 3809ea133fd7Smrgvoid * 3810ea133fd7Smrgxmalloc (size_t num) 3811ea133fd7Smrg{ 3812ea133fd7Smrg void *p = (void *) malloc (num); 3813ea133fd7Smrg if (!p) 381425b89263Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 3815a253d6aeSmrg 3816ea133fd7Smrg return p; 3817ea133fd7Smrg} 3818a253d6aeSmrg 3819ea133fd7Smrgchar * 3820ea133fd7Smrgxstrdup (const char *string) 3821ea133fd7Smrg{ 3822ea133fd7Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 3823ea133fd7Smrg string) : NULL; 3824ea133fd7Smrg} 3825a253d6aeSmrg 3826ea133fd7Smrgconst char * 3827ea133fd7Smrgbase_name (const char *name) 3828ea133fd7Smrg{ 3829ea133fd7Smrg const char *base; 3830a253d6aeSmrg 3831ea133fd7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 3832ea133fd7Smrg /* Skip over the disk name in MSDOS pathnames. */ 3833ea133fd7Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 3834ea133fd7Smrg name += 2; 3835ea133fd7Smrg#endif 3836a253d6aeSmrg 3837ea133fd7Smrg for (base = name; *name; name++) 3838ea133fd7Smrg if (IS_DIR_SEPARATOR (*name)) 3839ea133fd7Smrg base = name + 1; 3840ea133fd7Smrg return base; 3841ea133fd7Smrg} 3842a253d6aeSmrg 3843ea133fd7Smrgint 3844ea133fd7Smrgcheck_executable (const char *path) 3845ea133fd7Smrg{ 3846ea133fd7Smrg struct stat st; 3847a253d6aeSmrg 384825b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 384925b89263Smrg nonempty (path)); 3850ea133fd7Smrg if ((!path) || (!*path)) 3851ea133fd7Smrg return 0; 3852a253d6aeSmrg 3853ea133fd7Smrg if ((stat (path, &st) >= 0) 3854ea133fd7Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 3855ea133fd7Smrg return 1; 3856ea133fd7Smrg else 3857ea133fd7Smrg return 0; 3858ea133fd7Smrg} 3859a253d6aeSmrg 3860ea133fd7Smrgint 3861ea133fd7Smrgmake_executable (const char *path) 3862ea133fd7Smrg{ 3863ea133fd7Smrg int rval = 0; 3864ea133fd7Smrg struct stat st; 3865a253d6aeSmrg 386625b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 386725b89263Smrg nonempty (path)); 3868ea133fd7Smrg if ((!path) || (!*path)) 3869ea133fd7Smrg return 0; 3870a253d6aeSmrg 3871ea133fd7Smrg if (stat (path, &st) >= 0) 3872ea133fd7Smrg { 3873ea133fd7Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 3874ea133fd7Smrg } 3875ea133fd7Smrg return rval; 3876ea133fd7Smrg} 3877a253d6aeSmrg 3878ea133fd7Smrg/* Searches for the full path of the wrapper. Returns 3879ea133fd7Smrg newly allocated full path name if found, NULL otherwise 3880ea133fd7Smrg Does not chase symlinks, even on platforms that support them. 3881ea133fd7Smrg*/ 3882ea133fd7Smrgchar * 3883ea133fd7Smrgfind_executable (const char *wrapper) 3884ea133fd7Smrg{ 3885ea133fd7Smrg int has_slash = 0; 3886ea133fd7Smrg const char *p; 3887ea133fd7Smrg const char *p_next; 3888ea133fd7Smrg /* static buffer for getcwd */ 3889ea133fd7Smrg char tmp[LT_PATHMAX + 1]; 3890ea133fd7Smrg int tmp_len; 3891ea133fd7Smrg char *concat_name; 3892a253d6aeSmrg 389325b89263Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 389425b89263Smrg nonempty (wrapper)); 3895a253d6aeSmrg 3896ea133fd7Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 3897ea133fd7Smrg return NULL; 3898a253d6aeSmrg 3899ea133fd7Smrg /* Absolute path? */ 3900ea133fd7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 3901ea133fd7Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 3902ea133fd7Smrg { 3903ea133fd7Smrg concat_name = xstrdup (wrapper); 3904ea133fd7Smrg if (check_executable (concat_name)) 3905ea133fd7Smrg return concat_name; 3906ea133fd7Smrg XFREE (concat_name); 3907ea133fd7Smrg } 3908ea133fd7Smrg else 3909ea133fd7Smrg { 3910ea133fd7Smrg#endif 3911ea133fd7Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 3912ea133fd7Smrg { 3913ea133fd7Smrg concat_name = xstrdup (wrapper); 3914ea133fd7Smrg if (check_executable (concat_name)) 3915ea133fd7Smrg return concat_name; 3916ea133fd7Smrg XFREE (concat_name); 3917ea133fd7Smrg } 3918ea133fd7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 3919ea133fd7Smrg } 3920ea133fd7Smrg#endif 3921a253d6aeSmrg 3922ea133fd7Smrg for (p = wrapper; *p; p++) 3923ea133fd7Smrg if (*p == '/') 3924ea133fd7Smrg { 3925ea133fd7Smrg has_slash = 1; 3926ea133fd7Smrg break; 3927ea133fd7Smrg } 3928ea133fd7Smrg if (!has_slash) 3929ea133fd7Smrg { 3930ea133fd7Smrg /* no slashes; search PATH */ 3931ea133fd7Smrg const char *path = getenv ("PATH"); 3932ea133fd7Smrg if (path != NULL) 3933ea133fd7Smrg { 3934ea133fd7Smrg for (p = path; *p; p = p_next) 3935ea133fd7Smrg { 3936ea133fd7Smrg const char *q; 3937ea133fd7Smrg size_t p_len; 3938ea133fd7Smrg for (q = p; *q; q++) 3939ea133fd7Smrg if (IS_PATH_SEPARATOR (*q)) 3940ea133fd7Smrg break; 3941ea133fd7Smrg p_len = q - p; 3942ea133fd7Smrg p_next = (*q == '\0' ? q : q + 1); 3943ea133fd7Smrg if (p_len == 0) 3944ea133fd7Smrg { 3945ea133fd7Smrg /* empty path: current directory */ 3946ea133fd7Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 394725b89263Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 394825b89263Smrg nonnull (strerror (errno))); 3949ea133fd7Smrg tmp_len = strlen (tmp); 3950ea133fd7Smrg concat_name = 3951ea133fd7Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 3952ea133fd7Smrg memcpy (concat_name, tmp, tmp_len); 3953ea133fd7Smrg concat_name[tmp_len] = '/'; 3954ea133fd7Smrg strcpy (concat_name + tmp_len + 1, wrapper); 3955ea133fd7Smrg } 3956ea133fd7Smrg else 3957ea133fd7Smrg { 3958ea133fd7Smrg concat_name = 3959ea133fd7Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 3960ea133fd7Smrg memcpy (concat_name, p, p_len); 3961ea133fd7Smrg concat_name[p_len] = '/'; 3962ea133fd7Smrg strcpy (concat_name + p_len + 1, wrapper); 3963ea133fd7Smrg } 3964ea133fd7Smrg if (check_executable (concat_name)) 3965ea133fd7Smrg return concat_name; 3966ea133fd7Smrg XFREE (concat_name); 3967ea133fd7Smrg } 3968ea133fd7Smrg } 3969ea133fd7Smrg /* not found in PATH; assume curdir */ 3970ea133fd7Smrg } 3971ea133fd7Smrg /* Relative path | not found in path: prepend cwd */ 3972ea133fd7Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 397325b89263Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 397425b89263Smrg nonnull (strerror (errno))); 3975ea133fd7Smrg tmp_len = strlen (tmp); 3976ea133fd7Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 3977ea133fd7Smrg memcpy (concat_name, tmp, tmp_len); 3978ea133fd7Smrg concat_name[tmp_len] = '/'; 3979ea133fd7Smrg strcpy (concat_name + tmp_len + 1, wrapper); 3980a253d6aeSmrg 3981ea133fd7Smrg if (check_executable (concat_name)) 3982ea133fd7Smrg return concat_name; 3983ea133fd7Smrg XFREE (concat_name); 3984ea133fd7Smrg return NULL; 3985ea133fd7Smrg} 3986a253d6aeSmrg 3987ea133fd7Smrgchar * 3988ea133fd7Smrgchase_symlinks (const char *pathspec) 3989ea133fd7Smrg{ 3990ea133fd7Smrg#ifndef S_ISLNK 3991ea133fd7Smrg return xstrdup (pathspec); 3992ea133fd7Smrg#else 3993ea133fd7Smrg char buf[LT_PATHMAX]; 3994ea133fd7Smrg struct stat s; 3995ea133fd7Smrg char *tmp_pathspec = xstrdup (pathspec); 3996ea133fd7Smrg char *p; 3997ea133fd7Smrg int has_symlinks = 0; 3998ea133fd7Smrg while (strlen (tmp_pathspec) && !has_symlinks) 3999ea133fd7Smrg { 400025b89263Smrg lt_debugprintf (__FILE__, __LINE__, 400125b89263Smrg "checking path component for symlinks: %s\n", 400225b89263Smrg tmp_pathspec); 4003ea133fd7Smrg if (lstat (tmp_pathspec, &s) == 0) 4004ea133fd7Smrg { 4005ea133fd7Smrg if (S_ISLNK (s.st_mode) != 0) 4006ea133fd7Smrg { 4007ea133fd7Smrg has_symlinks = 1; 4008ea133fd7Smrg break; 4009ea133fd7Smrg } 4010a253d6aeSmrg 4011ea133fd7Smrg /* search backwards for last DIR_SEPARATOR */ 4012ea133fd7Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 4013ea133fd7Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4014ea133fd7Smrg p--; 4015ea133fd7Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4016ea133fd7Smrg { 4017ea133fd7Smrg /* no more DIR_SEPARATORS left */ 4018ea133fd7Smrg break; 4019ea133fd7Smrg } 4020ea133fd7Smrg *p = '\0'; 4021ea133fd7Smrg } 4022ea133fd7Smrg else 4023ea133fd7Smrg { 402425b89263Smrg lt_fatal (__FILE__, __LINE__, 402525b89263Smrg "error accessing file \"%s\": %s", 402625b89263Smrg tmp_pathspec, nonnull (strerror (errno))); 4027ea133fd7Smrg } 4028ea133fd7Smrg } 4029ea133fd7Smrg XFREE (tmp_pathspec); 4030a253d6aeSmrg 4031ea133fd7Smrg if (!has_symlinks) 4032ea133fd7Smrg { 4033ea133fd7Smrg return xstrdup (pathspec); 4034ea133fd7Smrg } 4035a253d6aeSmrg 4036ea133fd7Smrg tmp_pathspec = realpath (pathspec, buf); 4037ea133fd7Smrg if (tmp_pathspec == 0) 4038ea133fd7Smrg { 403925b89263Smrg lt_fatal (__FILE__, __LINE__, 404025b89263Smrg "could not follow symlinks for %s", pathspec); 4041ea133fd7Smrg } 4042ea133fd7Smrg return xstrdup (tmp_pathspec); 4043ea133fd7Smrg#endif 4044ea133fd7Smrg} 4045a253d6aeSmrg 4046ea133fd7Smrgchar * 4047ea133fd7Smrgstrendzap (char *str, const char *pat) 4048ea133fd7Smrg{ 4049ea133fd7Smrg size_t len, patlen; 4050a253d6aeSmrg 4051ea133fd7Smrg assert (str != NULL); 4052ea133fd7Smrg assert (pat != NULL); 4053a253d6aeSmrg 4054ea133fd7Smrg len = strlen (str); 4055ea133fd7Smrg patlen = strlen (pat); 4056a253d6aeSmrg 4057ea133fd7Smrg if (patlen <= len) 4058ea133fd7Smrg { 4059ea133fd7Smrg str += len - patlen; 4060ea133fd7Smrg if (strcmp (str, pat) == 0) 4061ea133fd7Smrg *str = '\0'; 4062ea133fd7Smrg } 4063ea133fd7Smrg return str; 4064ea133fd7Smrg} 4065a253d6aeSmrg 406625b89263Smrgvoid 406725b89263Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 406825b89263Smrg{ 406925b89263Smrg va_list args; 407025b89263Smrg if (lt_debug) 407125b89263Smrg { 407225b89263Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 407325b89263Smrg va_start (args, fmt); 407425b89263Smrg (void) vfprintf (stderr, fmt, args); 407525b89263Smrg va_end (args); 407625b89263Smrg } 407725b89263Smrg} 407825b89263Smrg 4079ea133fd7Smrgstatic void 408025b89263Smrglt_error_core (int exit_status, const char *file, 408125b89263Smrg int line, const char *mode, 4082ea133fd7Smrg const char *message, va_list ap) 4083ea133fd7Smrg{ 408425b89263Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 4085ea133fd7Smrg vfprintf (stderr, message, ap); 4086ea133fd7Smrg fprintf (stderr, ".\n"); 4087a253d6aeSmrg 4088ea133fd7Smrg if (exit_status >= 0) 4089ea133fd7Smrg exit (exit_status); 4090ea133fd7Smrg} 4091a253d6aeSmrg 4092ea133fd7Smrgvoid 409325b89263Smrglt_fatal (const char *file, int line, const char *message, ...) 4094ea133fd7Smrg{ 4095ea133fd7Smrg va_list ap; 4096ea133fd7Smrg va_start (ap, message); 409725b89263Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 4098ea133fd7Smrg va_end (ap); 4099ea133fd7Smrg} 4100a253d6aeSmrg 410125b89263Smrgstatic const char * 410225b89263Smrgnonnull (const char *s) 410325b89263Smrg{ 410425b89263Smrg return s ? s : "(null)"; 410525b89263Smrg} 410625b89263Smrg 410725b89263Smrgstatic const char * 410825b89263Smrgnonempty (const char *s) 410925b89263Smrg{ 411025b89263Smrg return (s && !*s) ? "(empty)" : nonnull (s); 411125b89263Smrg} 411225b89263Smrg 4113ea133fd7Smrgvoid 4114ea133fd7Smrglt_setenv (const char *name, const char *value) 4115ea133fd7Smrg{ 411625b89263Smrg lt_debugprintf (__FILE__, __LINE__, 411725b89263Smrg "(lt_setenv) setting '%s' to '%s'\n", 411825b89263Smrg nonnull (name), nonnull (value)); 4119ea133fd7Smrg { 4120ea133fd7Smrg#ifdef HAVE_SETENV 4121ea133fd7Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 4122ea133fd7Smrg char *str = xstrdup (value); 4123ea133fd7Smrg setenv (name, str, 1); 4124ea133fd7Smrg#else 4125ea133fd7Smrg int len = strlen (name) + 1 + strlen (value) + 1; 4126ea133fd7Smrg char *str = XMALLOC (char, len); 4127ea133fd7Smrg sprintf (str, "%s=%s", name, value); 4128ea133fd7Smrg if (putenv (str) != EXIT_SUCCESS) 4129ea133fd7Smrg { 4130ea133fd7Smrg XFREE (str); 4131ea133fd7Smrg } 4132ea133fd7Smrg#endif 4133ea133fd7Smrg } 4134ea133fd7Smrg} 4135a253d6aeSmrg 4136ea133fd7Smrgchar * 4137ea133fd7Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 4138ea133fd7Smrg{ 4139ea133fd7Smrg char *new_value; 4140ea133fd7Smrg if (orig_value && *orig_value) 4141ea133fd7Smrg { 4142ea133fd7Smrg int orig_value_len = strlen (orig_value); 4143ea133fd7Smrg int add_len = strlen (add); 4144ea133fd7Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 4145ea133fd7Smrg if (to_end) 4146ea133fd7Smrg { 4147ea133fd7Smrg strcpy (new_value, orig_value); 4148ea133fd7Smrg strcpy (new_value + orig_value_len, add); 4149ea133fd7Smrg } 4150ea133fd7Smrg else 4151ea133fd7Smrg { 4152ea133fd7Smrg strcpy (new_value, add); 4153ea133fd7Smrg strcpy (new_value + add_len, orig_value); 4154ea133fd7Smrg } 4155ea133fd7Smrg } 4156ea133fd7Smrg else 4157ea133fd7Smrg { 4158ea133fd7Smrg new_value = xstrdup (add); 4159ea133fd7Smrg } 4160ea133fd7Smrg return new_value; 4161ea133fd7Smrg} 4162a253d6aeSmrg 4163ea133fd7Smrgvoid 4164ea133fd7Smrglt_update_exe_path (const char *name, const char *value) 4165ea133fd7Smrg{ 416625b89263Smrg lt_debugprintf (__FILE__, __LINE__, 416725b89263Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 416825b89263Smrg nonnull (name), nonnull (value)); 4169a253d6aeSmrg 4170ea133fd7Smrg if (name && *name && value && *value) 4171ea133fd7Smrg { 4172ea133fd7Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4173ea133fd7Smrg /* some systems can't cope with a ':'-terminated path #' */ 4174ea133fd7Smrg int len = strlen (new_value); 4175ea133fd7Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 4176ea133fd7Smrg { 4177ea133fd7Smrg new_value[len-1] = '\0'; 4178ea133fd7Smrg } 4179ea133fd7Smrg lt_setenv (name, new_value); 4180ea133fd7Smrg XFREE (new_value); 4181ea133fd7Smrg } 4182ea133fd7Smrg} 4183a253d6aeSmrg 4184ea133fd7Smrgvoid 4185ea133fd7Smrglt_update_lib_path (const char *name, const char *value) 4186ea133fd7Smrg{ 418725b89263Smrg lt_debugprintf (__FILE__, __LINE__, 418825b89263Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 418925b89263Smrg nonnull (name), nonnull (value)); 4190a253d6aeSmrg 4191ea133fd7Smrg if (name && *name && value && *value) 4192ea133fd7Smrg { 4193ea133fd7Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4194ea133fd7Smrg lt_setenv (name, new_value); 4195ea133fd7Smrg XFREE (new_value); 4196ea133fd7Smrg } 4197ea133fd7Smrg} 4198a253d6aeSmrg 419925b89263SmrgEOF 420025b89263Smrg case $host_os in 420125b89263Smrg mingw*) 420225b89263Smrg cat <<"EOF" 420325b89263Smrg 420425b89263Smrg/* Prepares an argument vector before calling spawn(). 420525b89263Smrg Note that spawn() does not by itself call the command interpreter 420625b89263Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 420725b89263Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 420825b89263Smrg GetVersionEx(&v); 420925b89263Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 421025b89263Smrg }) ? "cmd.exe" : "command.com"). 421125b89263Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 421225b89263Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 421325b89263Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 421425b89263Smrg special way: 421525b89263Smrg - Space and tab are interpreted as delimiters. They are not treated as 421625b89263Smrg delimiters if they are surrounded by double quotes: "...". 421725b89263Smrg - Unescaped double quotes are removed from the input. Their only effect is 421825b89263Smrg that within double quotes, space and tab are treated like normal 421925b89263Smrg characters. 422025b89263Smrg - Backslashes not followed by double quotes are not special. 422125b89263Smrg - But 2*n+1 backslashes followed by a double quote become 422225b89263Smrg n backslashes followed by a double quote (n >= 0): 422325b89263Smrg \" -> " 422425b89263Smrg \\\" -> \" 422525b89263Smrg \\\\\" -> \\" 422625b89263Smrg */ 422725b89263Smrg#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" 422825b89263Smrg#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" 422925b89263Smrgchar ** 423025b89263Smrgprepare_spawn (char **argv) 423125b89263Smrg{ 423225b89263Smrg size_t argc; 423325b89263Smrg char **new_argv; 423425b89263Smrg size_t i; 423525b89263Smrg 423625b89263Smrg /* Count number of arguments. */ 423725b89263Smrg for (argc = 0; argv[argc] != NULL; argc++) 423825b89263Smrg ; 423925b89263Smrg 424025b89263Smrg /* Allocate new argument vector. */ 424125b89263Smrg new_argv = XMALLOC (char *, argc + 1); 424225b89263Smrg 424325b89263Smrg /* Put quoted arguments into the new argument vector. */ 424425b89263Smrg for (i = 0; i < argc; i++) 424525b89263Smrg { 424625b89263Smrg const char *string = argv[i]; 424725b89263Smrg 424825b89263Smrg if (string[0] == '\0') 424925b89263Smrg new_argv[i] = xstrdup ("\"\""); 425025b89263Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 425125b89263Smrg { 425225b89263Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 425325b89263Smrg size_t length; 425425b89263Smrg unsigned int backslashes; 425525b89263Smrg const char *s; 425625b89263Smrg char *quoted_string; 425725b89263Smrg char *p; 425825b89263Smrg 425925b89263Smrg length = 0; 426025b89263Smrg backslashes = 0; 426125b89263Smrg if (quote_around) 426225b89263Smrg length++; 426325b89263Smrg for (s = string; *s != '\0'; s++) 426425b89263Smrg { 426525b89263Smrg char c = *s; 426625b89263Smrg if (c == '"') 426725b89263Smrg length += backslashes + 1; 426825b89263Smrg length++; 426925b89263Smrg if (c == '\\') 427025b89263Smrg backslashes++; 427125b89263Smrg else 427225b89263Smrg backslashes = 0; 427325b89263Smrg } 427425b89263Smrg if (quote_around) 427525b89263Smrg length += backslashes + 1; 427625b89263Smrg 427725b89263Smrg quoted_string = XMALLOC (char, length + 1); 427825b89263Smrg 427925b89263Smrg p = quoted_string; 428025b89263Smrg backslashes = 0; 428125b89263Smrg if (quote_around) 428225b89263Smrg *p++ = '"'; 428325b89263Smrg for (s = string; *s != '\0'; s++) 428425b89263Smrg { 428525b89263Smrg char c = *s; 428625b89263Smrg if (c == '"') 428725b89263Smrg { 428825b89263Smrg unsigned int j; 428925b89263Smrg for (j = backslashes + 1; j > 0; j--) 429025b89263Smrg *p++ = '\\'; 429125b89263Smrg } 429225b89263Smrg *p++ = c; 429325b89263Smrg if (c == '\\') 429425b89263Smrg backslashes++; 429525b89263Smrg else 429625b89263Smrg backslashes = 0; 429725b89263Smrg } 429825b89263Smrg if (quote_around) 429925b89263Smrg { 430025b89263Smrg unsigned int j; 430125b89263Smrg for (j = backslashes; j > 0; j--) 430225b89263Smrg *p++ = '\\'; 430325b89263Smrg *p++ = '"'; 430425b89263Smrg } 430525b89263Smrg *p = '\0'; 430625b89263Smrg 430725b89263Smrg new_argv[i] = quoted_string; 430825b89263Smrg } 430925b89263Smrg else 431025b89263Smrg new_argv[i] = (char *) string; 431125b89263Smrg } 431225b89263Smrg new_argv[argc] = NULL; 431325b89263Smrg 431425b89263Smrg return new_argv; 431525b89263Smrg} 431625b89263SmrgEOF 431725b89263Smrg ;; 431825b89263Smrg esac 431925b89263Smrg 432025b89263Smrg cat <<"EOF" 432125b89263Smrgvoid lt_dump_script (FILE* f) 432225b89263Smrg{ 432325b89263SmrgEOF 432425b89263Smrg func_emit_wrapper yes | 432525b89263Smrg $SED -e 's/\([\\"]\)/\\\1/g' \ 432625b89263Smrg -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' 4327a253d6aeSmrg 432825b89263Smrg cat <<"EOF" 432925b89263Smrg} 4330ea133fd7SmrgEOF 4331ea133fd7Smrg} 4332ea133fd7Smrg# end: func_emit_cwrapperexe_src 4333a253d6aeSmrg 433425b89263Smrg# func_win32_import_lib_p ARG 433525b89263Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 433625b89263Smrgfunc_win32_import_lib_p () 433725b89263Smrg{ 433825b89263Smrg $opt_debug 433925b89263Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 434025b89263Smrg *import*) : ;; 434125b89263Smrg *) false ;; 434225b89263Smrg esac 434325b89263Smrg} 434425b89263Smrg 4345ea133fd7Smrg# func_mode_link arg... 4346ea133fd7Smrgfunc_mode_link () 4347ea133fd7Smrg{ 4348ea133fd7Smrg $opt_debug 4349ea133fd7Smrg case $host in 4350ea133fd7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 4351ea133fd7Smrg # It is impossible to link a dll without this setting, and 4352ea133fd7Smrg # we shouldn't force the makefile maintainer to figure out 4353ea133fd7Smrg # which system we are compiling for in order to pass an extra 4354ea133fd7Smrg # flag for every libtool invocation. 4355ea133fd7Smrg # allow_undefined=no 4356a253d6aeSmrg 4357ea133fd7Smrg # FIXME: Unfortunately, there are problems with the above when trying 4358ea133fd7Smrg # to make a dll which has undefined symbols, in which case not 4359ea133fd7Smrg # even a static library is built. For now, we need to specify 4360ea133fd7Smrg # -no-undefined on the libtool link line when we can be certain 4361ea133fd7Smrg # that all symbols are satisfied, otherwise we get a static library. 4362ea133fd7Smrg allow_undefined=yes 4363ea133fd7Smrg ;; 4364ea133fd7Smrg *) 4365ea133fd7Smrg allow_undefined=yes 4366ea133fd7Smrg ;; 4367ea133fd7Smrg esac 4368ea133fd7Smrg libtool_args=$nonopt 4369ea133fd7Smrg base_compile="$nonopt $@" 4370ea133fd7Smrg compile_command=$nonopt 4371ea133fd7Smrg finalize_command=$nonopt 4372a253d6aeSmrg 4373ea133fd7Smrg compile_rpath= 4374ea133fd7Smrg finalize_rpath= 4375ea133fd7Smrg compile_shlibpath= 4376ea133fd7Smrg finalize_shlibpath= 4377ea133fd7Smrg convenience= 4378ea133fd7Smrg old_convenience= 4379ea133fd7Smrg deplibs= 4380ea133fd7Smrg old_deplibs= 4381ea133fd7Smrg compiler_flags= 4382ea133fd7Smrg linker_flags= 4383ea133fd7Smrg dllsearchpath= 4384ea133fd7Smrg lib_search_path=`pwd` 4385ea133fd7Smrg inst_prefix_dir= 4386ea133fd7Smrg new_inherited_linker_flags= 4387a253d6aeSmrg 4388ea133fd7Smrg avoid_version=no 438925b89263Smrg bindir= 4390ea133fd7Smrg dlfiles= 4391ea133fd7Smrg dlprefiles= 4392ea133fd7Smrg dlself=no 4393ea133fd7Smrg export_dynamic=no 4394ea133fd7Smrg export_symbols= 4395ea133fd7Smrg export_symbols_regex= 4396ea133fd7Smrg generated= 4397ea133fd7Smrg libobjs= 4398ea133fd7Smrg ltlibs= 4399ea133fd7Smrg module=no 4400ea133fd7Smrg no_install=no 4401ea133fd7Smrg objs= 4402ea133fd7Smrg non_pic_objects= 4403ea133fd7Smrg precious_files_regex= 4404ea133fd7Smrg prefer_static_libs=no 4405ea133fd7Smrg preload=no 4406ea133fd7Smrg prev= 4407ea133fd7Smrg prevarg= 4408ea133fd7Smrg release= 4409ea133fd7Smrg rpath= 4410ea133fd7Smrg xrpath= 4411ea133fd7Smrg perm_rpath= 4412ea133fd7Smrg temp_rpath= 4413ea133fd7Smrg thread_safe=no 4414ea133fd7Smrg vinfo= 4415ea133fd7Smrg vinfo_number=no 4416ea133fd7Smrg weak_libs= 4417ea133fd7Smrg single_module="${wl}-single_module" 4418ea133fd7Smrg func_infer_tag $base_compile 4419a253d6aeSmrg 4420ea133fd7Smrg # We need to know -static, to get the right output filenames. 4421ea133fd7Smrg for arg 4422ea133fd7Smrg do 4423ea133fd7Smrg case $arg in 4424ea133fd7Smrg -shared) 4425ea133fd7Smrg test "$build_libtool_libs" != yes && \ 4426ea133fd7Smrg func_fatal_configuration "can not build a shared library" 4427ea133fd7Smrg build_old_libs=no 4428ea133fd7Smrg break 4429ea133fd7Smrg ;; 4430ea133fd7Smrg -all-static | -static | -static-libtool-libs) 4431ea133fd7Smrg case $arg in 4432ea133fd7Smrg -all-static) 4433ea133fd7Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 4434ea133fd7Smrg func_warning "complete static linking is impossible in this configuration" 4435a253d6aeSmrg fi 4436ea133fd7Smrg if test -n "$link_static_flag"; then 4437ea133fd7Smrg dlopen_self=$dlopen_self_static 4438a253d6aeSmrg fi 4439ea133fd7Smrg prefer_static_libs=yes 4440a253d6aeSmrg ;; 4441ea133fd7Smrg -static) 4442ea133fd7Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 4443ea133fd7Smrg dlopen_self=$dlopen_self_static 4444ea133fd7Smrg fi 4445ea133fd7Smrg prefer_static_libs=built 4446ea133fd7Smrg ;; 4447ea133fd7Smrg -static-libtool-libs) 4448ea133fd7Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 4449ea133fd7Smrg dlopen_self=$dlopen_self_static 4450ea133fd7Smrg fi 4451ea133fd7Smrg prefer_static_libs=yes 4452a253d6aeSmrg ;; 4453a253d6aeSmrg esac 4454ea133fd7Smrg build_libtool_libs=no 4455ea133fd7Smrg build_old_libs=yes 4456ea133fd7Smrg break 4457ea133fd7Smrg ;; 4458ea133fd7Smrg esac 4459ea133fd7Smrg done 4460a253d6aeSmrg 4461ea133fd7Smrg # See if our shared archives depend on static archives. 4462ea133fd7Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 4463a253d6aeSmrg 4464ea133fd7Smrg # Go through the arguments, transforming them on the way. 4465ea133fd7Smrg while test "$#" -gt 0; do 4466ea133fd7Smrg arg="$1" 4467ea133fd7Smrg shift 4468ea133fd7Smrg func_quote_for_eval "$arg" 4469ea133fd7Smrg qarg=$func_quote_for_eval_unquoted_result 4470ea133fd7Smrg func_append libtool_args " $func_quote_for_eval_result" 4471a253d6aeSmrg 4472ea133fd7Smrg # If the previous option needs an argument, assign it. 4473ea133fd7Smrg if test -n "$prev"; then 4474ea133fd7Smrg case $prev in 4475ea133fd7Smrg output) 4476ea133fd7Smrg func_append compile_command " @OUTPUT@" 4477ea133fd7Smrg func_append finalize_command " @OUTPUT@" 4478ea133fd7Smrg ;; 4479ea133fd7Smrg esac 4480a253d6aeSmrg 4481ea133fd7Smrg case $prev in 448225b89263Smrg bindir) 448325b89263Smrg bindir="$arg" 448425b89263Smrg prev= 448525b89263Smrg continue 448625b89263Smrg ;; 4487ea133fd7Smrg dlfiles|dlprefiles) 4488ea133fd7Smrg if test "$preload" = no; then 4489ea133fd7Smrg # Add the symbol object into the linking commands. 4490ea133fd7Smrg func_append compile_command " @SYMFILE@" 4491ea133fd7Smrg func_append finalize_command " @SYMFILE@" 4492ea133fd7Smrg preload=yes 4493ea133fd7Smrg fi 4494ea133fd7Smrg case $arg in 4495ea133fd7Smrg *.la | *.lo) ;; # We handle these cases below. 4496ea133fd7Smrg force) 4497ea133fd7Smrg if test "$dlself" = no; then 4498ea133fd7Smrg dlself=needless 4499ea133fd7Smrg export_dynamic=yes 4500ea133fd7Smrg fi 4501ea133fd7Smrg prev= 4502ea133fd7Smrg continue 4503ea133fd7Smrg ;; 4504ea133fd7Smrg self) 4505ea133fd7Smrg if test "$prev" = dlprefiles; then 4506ea133fd7Smrg dlself=yes 4507ea133fd7Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 4508ea133fd7Smrg dlself=yes 4509ea133fd7Smrg else 4510ea133fd7Smrg dlself=needless 4511ea133fd7Smrg export_dynamic=yes 4512ea133fd7Smrg fi 4513ea133fd7Smrg prev= 4514ea133fd7Smrg continue 4515a253d6aeSmrg ;; 4516a253d6aeSmrg *) 4517ea133fd7Smrg if test "$prev" = dlfiles; then 4518ea133fd7Smrg dlfiles="$dlfiles $arg" 4519ea133fd7Smrg else 4520ea133fd7Smrg dlprefiles="$dlprefiles $arg" 4521ea133fd7Smrg fi 4522ea133fd7Smrg prev= 4523ea133fd7Smrg continue 4524a253d6aeSmrg ;; 4525a253d6aeSmrg esac 4526ea133fd7Smrg ;; 4527ea133fd7Smrg expsyms) 4528ea133fd7Smrg export_symbols="$arg" 4529ea133fd7Smrg test -f "$arg" \ 4530ea133fd7Smrg || func_fatal_error "symbol file \`$arg' does not exist" 4531ea133fd7Smrg prev= 4532ea133fd7Smrg continue 4533ea133fd7Smrg ;; 4534ea133fd7Smrg expsyms_regex) 4535ea133fd7Smrg export_symbols_regex="$arg" 4536ea133fd7Smrg prev= 4537ea133fd7Smrg continue 4538ea133fd7Smrg ;; 4539ea133fd7Smrg framework) 4540ea133fd7Smrg case $host in 4541ea133fd7Smrg *-*-darwin*) 4542ea133fd7Smrg case "$deplibs " in 4543ea133fd7Smrg *" $qarg.ltframework "*) ;; 4544ea133fd7Smrg *) deplibs="$deplibs $qarg.ltframework" # this is fixed later 4545ea133fd7Smrg ;; 4546ea133fd7Smrg esac 4547ea133fd7Smrg ;; 4548ea133fd7Smrg esac 4549ea133fd7Smrg prev= 4550ea133fd7Smrg continue 4551ea133fd7Smrg ;; 4552ea133fd7Smrg inst_prefix) 4553ea133fd7Smrg inst_prefix_dir="$arg" 4554ea133fd7Smrg prev= 4555ea133fd7Smrg continue 4556ea133fd7Smrg ;; 4557ea133fd7Smrg objectlist) 4558ea133fd7Smrg if test -f "$arg"; then 4559ea133fd7Smrg save_arg=$arg 4560ea133fd7Smrg moreargs= 4561ea133fd7Smrg for fil in `cat "$save_arg"` 4562ea133fd7Smrg do 4563ea133fd7Smrg# moreargs="$moreargs $fil" 4564ea133fd7Smrg arg=$fil 4565ea133fd7Smrg # A libtool-controlled object. 4566a253d6aeSmrg 4567ea133fd7Smrg # Check to see that this really is a libtool object. 4568ea133fd7Smrg if func_lalib_unsafe_p "$arg"; then 4569ea133fd7Smrg pic_object= 4570ea133fd7Smrg non_pic_object= 4571a253d6aeSmrg 4572ea133fd7Smrg # Read the .lo file 4573ea133fd7Smrg func_source "$arg" 4574a253d6aeSmrg 4575ea133fd7Smrg if test -z "$pic_object" || 4576ea133fd7Smrg test -z "$non_pic_object" || 4577ea133fd7Smrg test "$pic_object" = none && 4578ea133fd7Smrg test "$non_pic_object" = none; then 4579ea133fd7Smrg func_fatal_error "cannot find name of object for \`$arg'" 4580ea133fd7Smrg fi 4581a253d6aeSmrg 4582ea133fd7Smrg # Extract subdirectory from the argument. 4583ea133fd7Smrg func_dirname "$arg" "/" "" 4584ea133fd7Smrg xdir="$func_dirname_result" 4585a253d6aeSmrg 4586ea133fd7Smrg if test "$pic_object" != none; then 4587ea133fd7Smrg # Prepend the subdirectory the object is found in. 4588ea133fd7Smrg pic_object="$xdir$pic_object" 4589a253d6aeSmrg 4590ea133fd7Smrg if test "$prev" = dlfiles; then 4591ea133fd7Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 4592ea133fd7Smrg dlfiles="$dlfiles $pic_object" 4593ea133fd7Smrg prev= 4594ea133fd7Smrg continue 4595ea133fd7Smrg else 4596ea133fd7Smrg # If libtool objects are unsupported, then we need to preload. 4597ea133fd7Smrg prev=dlprefiles 4598ea133fd7Smrg fi 4599ea133fd7Smrg fi 4600a253d6aeSmrg 4601ea133fd7Smrg # CHECK ME: I think I busted this. -Ossama 4602ea133fd7Smrg if test "$prev" = dlprefiles; then 4603ea133fd7Smrg # Preload the old-style object. 4604ea133fd7Smrg dlprefiles="$dlprefiles $pic_object" 4605ea133fd7Smrg prev= 4606ea133fd7Smrg fi 4607a253d6aeSmrg 4608ea133fd7Smrg # A PIC object. 4609ea133fd7Smrg func_append libobjs " $pic_object" 4610ea133fd7Smrg arg="$pic_object" 4611ea133fd7Smrg fi 4612a253d6aeSmrg 4613ea133fd7Smrg # Non-PIC object. 4614ea133fd7Smrg if test "$non_pic_object" != none; then 4615ea133fd7Smrg # Prepend the subdirectory the object is found in. 4616ea133fd7Smrg non_pic_object="$xdir$non_pic_object" 4617a253d6aeSmrg 4618ea133fd7Smrg # A standard non-PIC object 4619ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 4620ea133fd7Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 4621ea133fd7Smrg arg="$non_pic_object" 4622ea133fd7Smrg fi 4623ea133fd7Smrg else 4624ea133fd7Smrg # If the PIC object exists, use it instead. 4625ea133fd7Smrg # $xdir was prepended to $pic_object above. 4626ea133fd7Smrg non_pic_object="$pic_object" 4627ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 4628ea133fd7Smrg fi 4629ea133fd7Smrg else 4630ea133fd7Smrg # Only an error if not doing a dry-run. 4631ea133fd7Smrg if $opt_dry_run; then 4632ea133fd7Smrg # Extract subdirectory from the argument. 4633ea133fd7Smrg func_dirname "$arg" "/" "" 4634ea133fd7Smrg xdir="$func_dirname_result" 4635ea133fd7Smrg 4636ea133fd7Smrg func_lo2o "$arg" 4637ea133fd7Smrg pic_object=$xdir$objdir/$func_lo2o_result 4638ea133fd7Smrg non_pic_object=$xdir$func_lo2o_result 4639ea133fd7Smrg func_append libobjs " $pic_object" 4640ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 4641ea133fd7Smrg else 4642ea133fd7Smrg func_fatal_error "\`$arg' is not a valid libtool object" 4643ea133fd7Smrg fi 4644ea133fd7Smrg fi 4645ea133fd7Smrg done 4646ea133fd7Smrg else 4647ea133fd7Smrg func_fatal_error "link input file \`$arg' does not exist" 4648ea133fd7Smrg fi 4649ea133fd7Smrg arg=$save_arg 4650ea133fd7Smrg prev= 4651ea133fd7Smrg continue 4652ea133fd7Smrg ;; 4653ea133fd7Smrg precious_regex) 4654ea133fd7Smrg precious_files_regex="$arg" 4655ea133fd7Smrg prev= 4656ea133fd7Smrg continue 4657ea133fd7Smrg ;; 4658ea133fd7Smrg release) 4659ea133fd7Smrg release="-$arg" 4660ea133fd7Smrg prev= 4661ea133fd7Smrg continue 4662ea133fd7Smrg ;; 4663ea133fd7Smrg rpath | xrpath) 4664ea133fd7Smrg # We need an absolute path. 4665ea133fd7Smrg case $arg in 4666ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4667ea133fd7Smrg *) 4668ea133fd7Smrg func_fatal_error "only absolute run-paths are allowed" 4669ea133fd7Smrg ;; 4670ea133fd7Smrg esac 4671ea133fd7Smrg if test "$prev" = rpath; then 4672ea133fd7Smrg case "$rpath " in 4673ea133fd7Smrg *" $arg "*) ;; 4674ea133fd7Smrg *) rpath="$rpath $arg" ;; 4675ea133fd7Smrg esac 4676ea133fd7Smrg else 4677ea133fd7Smrg case "$xrpath " in 4678ea133fd7Smrg *" $arg "*) ;; 4679ea133fd7Smrg *) xrpath="$xrpath $arg" ;; 4680ea133fd7Smrg esac 4681ea133fd7Smrg fi 4682ea133fd7Smrg prev= 4683ea133fd7Smrg continue 4684ea133fd7Smrg ;; 4685ea133fd7Smrg shrext) 4686ea133fd7Smrg shrext_cmds="$arg" 4687ea133fd7Smrg prev= 4688ea133fd7Smrg continue 4689ea133fd7Smrg ;; 4690ea133fd7Smrg weak) 4691ea133fd7Smrg weak_libs="$weak_libs $arg" 4692ea133fd7Smrg prev= 4693ea133fd7Smrg continue 4694ea133fd7Smrg ;; 4695ea133fd7Smrg xcclinker) 4696ea133fd7Smrg linker_flags="$linker_flags $qarg" 4697ea133fd7Smrg compiler_flags="$compiler_flags $qarg" 4698ea133fd7Smrg prev= 4699ea133fd7Smrg func_append compile_command " $qarg" 4700ea133fd7Smrg func_append finalize_command " $qarg" 4701ea133fd7Smrg continue 4702ea133fd7Smrg ;; 4703ea133fd7Smrg xcompiler) 4704ea133fd7Smrg compiler_flags="$compiler_flags $qarg" 4705ea133fd7Smrg prev= 4706ea133fd7Smrg func_append compile_command " $qarg" 4707ea133fd7Smrg func_append finalize_command " $qarg" 4708ea133fd7Smrg continue 4709ea133fd7Smrg ;; 4710ea133fd7Smrg xlinker) 4711ea133fd7Smrg linker_flags="$linker_flags $qarg" 4712ea133fd7Smrg compiler_flags="$compiler_flags $wl$qarg" 4713ea133fd7Smrg prev= 4714ea133fd7Smrg func_append compile_command " $wl$qarg" 4715ea133fd7Smrg func_append finalize_command " $wl$qarg" 4716ea133fd7Smrg continue 4717ea133fd7Smrg ;; 4718ea133fd7Smrg *) 4719ea133fd7Smrg eval "$prev=\"\$arg\"" 4720ea133fd7Smrg prev= 4721ea133fd7Smrg continue 4722ea133fd7Smrg ;; 4723a253d6aeSmrg esac 4724ea133fd7Smrg fi # test -n "$prev" 4725a253d6aeSmrg 4726ea133fd7Smrg prevarg="$arg" 4727a253d6aeSmrg 4728ea133fd7Smrg case $arg in 4729ea133fd7Smrg -all-static) 4730ea133fd7Smrg if test -n "$link_static_flag"; then 4731ea133fd7Smrg # See comment for -static flag below, for more details. 4732ea133fd7Smrg func_append compile_command " $link_static_flag" 4733ea133fd7Smrg func_append finalize_command " $link_static_flag" 4734ea133fd7Smrg fi 4735ea133fd7Smrg continue 4736ea133fd7Smrg ;; 4737a253d6aeSmrg 4738ea133fd7Smrg -allow-undefined) 4739ea133fd7Smrg # FIXME: remove this flag sometime in the future. 4740ea133fd7Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 4741ea133fd7Smrg ;; 4742a253d6aeSmrg 4743ea133fd7Smrg -avoid-version) 4744ea133fd7Smrg avoid_version=yes 4745ea133fd7Smrg continue 4746ea133fd7Smrg ;; 4747a253d6aeSmrg 474825b89263Smrg -bindir) 474925b89263Smrg prev=bindir 475025b89263Smrg continue 475125b89263Smrg ;; 475225b89263Smrg 4753ea133fd7Smrg -dlopen) 4754ea133fd7Smrg prev=dlfiles 4755ea133fd7Smrg continue 4756ea133fd7Smrg ;; 4757a253d6aeSmrg 4758ea133fd7Smrg -dlpreopen) 4759ea133fd7Smrg prev=dlprefiles 4760ea133fd7Smrg continue 4761ea133fd7Smrg ;; 4762a253d6aeSmrg 4763ea133fd7Smrg -export-dynamic) 4764ea133fd7Smrg export_dynamic=yes 4765ea133fd7Smrg continue 4766ea133fd7Smrg ;; 4767a253d6aeSmrg 4768ea133fd7Smrg -export-symbols | -export-symbols-regex) 4769ea133fd7Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 4770ea133fd7Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 4771ea133fd7Smrg fi 4772ea133fd7Smrg if test "X$arg" = "X-export-symbols"; then 4773ea133fd7Smrg prev=expsyms 4774ea133fd7Smrg else 4775ea133fd7Smrg prev=expsyms_regex 4776ea133fd7Smrg fi 4777ea133fd7Smrg continue 4778ea133fd7Smrg ;; 4779a253d6aeSmrg 4780ea133fd7Smrg -framework) 4781ea133fd7Smrg prev=framework 4782ea133fd7Smrg continue 4783ea133fd7Smrg ;; 4784a253d6aeSmrg 4785ea133fd7Smrg -inst-prefix-dir) 4786ea133fd7Smrg prev=inst_prefix 4787ea133fd7Smrg continue 4788ea133fd7Smrg ;; 4789a253d6aeSmrg 4790ea133fd7Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 4791ea133fd7Smrg # so, if we see these flags be careful not to treat them like -L 4792ea133fd7Smrg -L[A-Z][A-Z]*:*) 4793ea133fd7Smrg case $with_gcc/$host in 4794ea133fd7Smrg no/*-*-irix* | /*-*-irix*) 4795ea133fd7Smrg func_append compile_command " $arg" 4796ea133fd7Smrg func_append finalize_command " $arg" 4797ea133fd7Smrg ;; 4798ea133fd7Smrg esac 4799ea133fd7Smrg continue 4800ea133fd7Smrg ;; 4801a253d6aeSmrg 4802ea133fd7Smrg -L*) 4803ea133fd7Smrg func_stripname '-L' '' "$arg" 4804ea133fd7Smrg dir=$func_stripname_result 4805ea133fd7Smrg if test -z "$dir"; then 4806ea133fd7Smrg if test "$#" -gt 0; then 4807ea133fd7Smrg func_fatal_error "require no space between \`-L' and \`$1'" 4808ea133fd7Smrg else 4809ea133fd7Smrg func_fatal_error "need path for \`-L' option" 4810ea133fd7Smrg fi 4811ea133fd7Smrg fi 4812ea133fd7Smrg # We need an absolute path. 4813ea133fd7Smrg case $dir in 4814ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4815ea133fd7Smrg *) 4816ea133fd7Smrg absdir=`cd "$dir" && pwd` 4817ea133fd7Smrg test -z "$absdir" && \ 4818ea133fd7Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 4819ea133fd7Smrg dir="$absdir" 4820ea133fd7Smrg ;; 4821ea133fd7Smrg esac 4822ea133fd7Smrg case "$deplibs " in 4823ea133fd7Smrg *" -L$dir "*) ;; 4824ea133fd7Smrg *) 4825ea133fd7Smrg deplibs="$deplibs -L$dir" 4826ea133fd7Smrg lib_search_path="$lib_search_path $dir" 4827ea133fd7Smrg ;; 4828ea133fd7Smrg esac 4829ea133fd7Smrg case $host in 4830ea133fd7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 483125b89263Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 4832ea133fd7Smrg case :$dllsearchpath: in 4833ea133fd7Smrg *":$dir:"*) ;; 4834ea133fd7Smrg ::) dllsearchpath=$dir;; 4835ea133fd7Smrg *) dllsearchpath="$dllsearchpath:$dir";; 4836ea133fd7Smrg esac 4837ea133fd7Smrg case :$dllsearchpath: in 4838ea133fd7Smrg *":$testbindir:"*) ;; 4839ea133fd7Smrg ::) dllsearchpath=$testbindir;; 4840ea133fd7Smrg *) dllsearchpath="$dllsearchpath:$testbindir";; 4841ea133fd7Smrg esac 4842ea133fd7Smrg ;; 4843ea133fd7Smrg esac 4844ea133fd7Smrg continue 4845ea133fd7Smrg ;; 4846a253d6aeSmrg 4847ea133fd7Smrg -l*) 4848ea133fd7Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 4849ea133fd7Smrg case $host in 485025b89263Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 4851ea133fd7Smrg # These systems don't actually have a C or math library (as such) 4852ea133fd7Smrg continue 4853ea133fd7Smrg ;; 4854ea133fd7Smrg *-*-os2*) 4855ea133fd7Smrg # These systems don't actually have a C library (as such) 4856ea133fd7Smrg test "X$arg" = "X-lc" && continue 4857ea133fd7Smrg ;; 4858ea133fd7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 4859ea133fd7Smrg # Do not include libc due to us having libc/libc_r. 4860ea133fd7Smrg test "X$arg" = "X-lc" && continue 4861ea133fd7Smrg ;; 4862ea133fd7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 4863ea133fd7Smrg # Rhapsody C and math libraries are in the System framework 4864ea133fd7Smrg deplibs="$deplibs System.ltframework" 4865ea133fd7Smrg continue 4866ea133fd7Smrg ;; 4867ea133fd7Smrg *-*-sco3.2v5* | *-*-sco5v6*) 4868ea133fd7Smrg # Causes problems with __ctype 4869ea133fd7Smrg test "X$arg" = "X-lc" && continue 4870ea133fd7Smrg ;; 4871ea133fd7Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 4872ea133fd7Smrg # Compiler inserts libc in the correct place for threads to work 4873ea133fd7Smrg test "X$arg" = "X-lc" && continue 4874ea133fd7Smrg ;; 4875ea133fd7Smrg esac 4876ea133fd7Smrg elif test "X$arg" = "X-lc_r"; then 4877ea133fd7Smrg case $host in 4878ea133fd7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 4879ea133fd7Smrg # Do not include libc_r directly, use -pthread flag. 4880ea133fd7Smrg continue 4881ea133fd7Smrg ;; 4882ea133fd7Smrg esac 4883ea133fd7Smrg fi 4884ea133fd7Smrg deplibs="$deplibs $arg" 4885ea133fd7Smrg continue 4886ea133fd7Smrg ;; 4887a253d6aeSmrg 4888ea133fd7Smrg -module) 4889ea133fd7Smrg module=yes 4890ea133fd7Smrg continue 4891ea133fd7Smrg ;; 4892a253d6aeSmrg 4893ea133fd7Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 4894ea133fd7Smrg # classes, name mangling, and exception handling. 4895ea133fd7Smrg # Darwin uses the -arch flag to determine output architecture. 4896ea133fd7Smrg -model|-arch|-isysroot) 4897ea133fd7Smrg compiler_flags="$compiler_flags $arg" 4898ea133fd7Smrg func_append compile_command " $arg" 4899ea133fd7Smrg func_append finalize_command " $arg" 4900ea133fd7Smrg prev=xcompiler 4901ea133fd7Smrg continue 4902ea133fd7Smrg ;; 4903a253d6aeSmrg 4904ea133fd7Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 4905ea133fd7Smrg compiler_flags="$compiler_flags $arg" 4906ea133fd7Smrg func_append compile_command " $arg" 4907ea133fd7Smrg func_append finalize_command " $arg" 4908ea133fd7Smrg case "$new_inherited_linker_flags " in 4909ea133fd7Smrg *" $arg "*) ;; 4910ea133fd7Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; 4911ea133fd7Smrg esac 4912ea133fd7Smrg continue 4913ea133fd7Smrg ;; 4914a253d6aeSmrg 4915ea133fd7Smrg -multi_module) 4916ea133fd7Smrg single_module="${wl}-multi_module" 4917ea133fd7Smrg continue 4918ea133fd7Smrg ;; 4919a253d6aeSmrg 4920ea133fd7Smrg -no-fast-install) 4921ea133fd7Smrg fast_install=no 4922ea133fd7Smrg continue 4923ea133fd7Smrg ;; 4924a253d6aeSmrg 4925ea133fd7Smrg -no-install) 4926ea133fd7Smrg case $host in 4927ea133fd7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 4928ea133fd7Smrg # The PATH hackery in wrapper scripts is required on Windows 4929ea133fd7Smrg # and Darwin in order for the loader to find any dlls it needs. 4930ea133fd7Smrg func_warning "\`-no-install' is ignored for $host" 4931ea133fd7Smrg func_warning "assuming \`-no-fast-install' instead" 4932ea133fd7Smrg fast_install=no 4933ea133fd7Smrg ;; 4934ea133fd7Smrg *) no_install=yes ;; 4935ea133fd7Smrg esac 4936ea133fd7Smrg continue 4937ea133fd7Smrg ;; 4938a253d6aeSmrg 4939ea133fd7Smrg -no-undefined) 4940ea133fd7Smrg allow_undefined=no 4941ea133fd7Smrg continue 4942ea133fd7Smrg ;; 4943a253d6aeSmrg 4944ea133fd7Smrg -objectlist) 4945ea133fd7Smrg prev=objectlist 4946ea133fd7Smrg continue 4947ea133fd7Smrg ;; 4948a253d6aeSmrg 4949ea133fd7Smrg -o) prev=output ;; 4950a253d6aeSmrg 4951ea133fd7Smrg -precious-files-regex) 4952ea133fd7Smrg prev=precious_regex 4953ea133fd7Smrg continue 4954ea133fd7Smrg ;; 4955a253d6aeSmrg 4956ea133fd7Smrg -release) 4957ea133fd7Smrg prev=release 4958ea133fd7Smrg continue 4959ea133fd7Smrg ;; 4960a253d6aeSmrg 4961ea133fd7Smrg -rpath) 4962ea133fd7Smrg prev=rpath 4963ea133fd7Smrg continue 4964ea133fd7Smrg ;; 4965a253d6aeSmrg 4966ea133fd7Smrg -R) 4967ea133fd7Smrg prev=xrpath 4968ea133fd7Smrg continue 4969ea133fd7Smrg ;; 4970a253d6aeSmrg 4971ea133fd7Smrg -R*) 4972ea133fd7Smrg func_stripname '-R' '' "$arg" 4973ea133fd7Smrg dir=$func_stripname_result 4974ea133fd7Smrg # We need an absolute path. 4975ea133fd7Smrg case $dir in 4976ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4977ea133fd7Smrg *) 4978ea133fd7Smrg func_fatal_error "only absolute run-paths are allowed" 4979ea133fd7Smrg ;; 4980ea133fd7Smrg esac 4981ea133fd7Smrg case "$xrpath " in 4982ea133fd7Smrg *" $dir "*) ;; 4983ea133fd7Smrg *) xrpath="$xrpath $dir" ;; 4984ea133fd7Smrg esac 4985ea133fd7Smrg continue 4986ea133fd7Smrg ;; 4987a253d6aeSmrg 4988ea133fd7Smrg -shared) 4989ea133fd7Smrg # The effects of -shared are defined in a previous loop. 4990ea133fd7Smrg continue 4991ea133fd7Smrg ;; 4992a253d6aeSmrg 4993ea133fd7Smrg -shrext) 4994ea133fd7Smrg prev=shrext 4995ea133fd7Smrg continue 4996ea133fd7Smrg ;; 4997a253d6aeSmrg 4998ea133fd7Smrg -static | -static-libtool-libs) 4999ea133fd7Smrg # The effects of -static are defined in a previous loop. 5000ea133fd7Smrg # We used to do the same as -all-static on platforms that 5001ea133fd7Smrg # didn't have a PIC flag, but the assumption that the effects 5002ea133fd7Smrg # would be equivalent was wrong. It would break on at least 5003ea133fd7Smrg # Digital Unix and AIX. 5004ea133fd7Smrg continue 5005ea133fd7Smrg ;; 5006a253d6aeSmrg 5007ea133fd7Smrg -thread-safe) 5008ea133fd7Smrg thread_safe=yes 5009ea133fd7Smrg continue 5010ea133fd7Smrg ;; 5011a253d6aeSmrg 5012ea133fd7Smrg -version-info) 5013ea133fd7Smrg prev=vinfo 5014ea133fd7Smrg continue 5015ea133fd7Smrg ;; 5016a253d6aeSmrg 5017ea133fd7Smrg -version-number) 5018ea133fd7Smrg prev=vinfo 5019ea133fd7Smrg vinfo_number=yes 5020ea133fd7Smrg continue 5021ea133fd7Smrg ;; 5022a253d6aeSmrg 5023ea133fd7Smrg -weak) 5024ea133fd7Smrg prev=weak 5025ea133fd7Smrg continue 5026ea133fd7Smrg ;; 5027a253d6aeSmrg 5028ea133fd7Smrg -Wc,*) 5029ea133fd7Smrg func_stripname '-Wc,' '' "$arg" 5030ea133fd7Smrg args=$func_stripname_result 5031ea133fd7Smrg arg= 5032ea133fd7Smrg save_ifs="$IFS"; IFS=',' 5033ea133fd7Smrg for flag in $args; do 5034ea133fd7Smrg IFS="$save_ifs" 5035ea133fd7Smrg func_quote_for_eval "$flag" 503625b89263Smrg arg="$arg $func_quote_for_eval_result" 5037ea133fd7Smrg compiler_flags="$compiler_flags $func_quote_for_eval_result" 5038ea133fd7Smrg done 5039ea133fd7Smrg IFS="$save_ifs" 5040ea133fd7Smrg func_stripname ' ' '' "$arg" 5041ea133fd7Smrg arg=$func_stripname_result 5042ea133fd7Smrg ;; 5043a253d6aeSmrg 5044ea133fd7Smrg -Wl,*) 5045ea133fd7Smrg func_stripname '-Wl,' '' "$arg" 5046ea133fd7Smrg args=$func_stripname_result 5047ea133fd7Smrg arg= 5048ea133fd7Smrg save_ifs="$IFS"; IFS=',' 5049ea133fd7Smrg for flag in $args; do 5050ea133fd7Smrg IFS="$save_ifs" 5051ea133fd7Smrg func_quote_for_eval "$flag" 5052ea133fd7Smrg arg="$arg $wl$func_quote_for_eval_result" 5053ea133fd7Smrg compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" 5054ea133fd7Smrg linker_flags="$linker_flags $func_quote_for_eval_result" 5055ea133fd7Smrg done 5056ea133fd7Smrg IFS="$save_ifs" 5057ea133fd7Smrg func_stripname ' ' '' "$arg" 5058ea133fd7Smrg arg=$func_stripname_result 5059ea133fd7Smrg ;; 5060a253d6aeSmrg 5061ea133fd7Smrg -Xcompiler) 5062ea133fd7Smrg prev=xcompiler 5063ea133fd7Smrg continue 5064ea133fd7Smrg ;; 5065a253d6aeSmrg 5066ea133fd7Smrg -Xlinker) 5067ea133fd7Smrg prev=xlinker 5068ea133fd7Smrg continue 5069ea133fd7Smrg ;; 5070a253d6aeSmrg 5071ea133fd7Smrg -XCClinker) 5072ea133fd7Smrg prev=xcclinker 5073ea133fd7Smrg continue 5074ea133fd7Smrg ;; 5075a253d6aeSmrg 5076ea133fd7Smrg # -msg_* for osf cc 5077ea133fd7Smrg -msg_*) 5078ea133fd7Smrg func_quote_for_eval "$arg" 5079ea133fd7Smrg arg="$func_quote_for_eval_result" 5080ea133fd7Smrg ;; 5081a253d6aeSmrg 508225b89263Smrg # Flags to be passed through unchanged, with rationale: 508325b89263Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 508425b89263Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 508525b89263Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 508625b89263Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 508725b89263Smrg # -q* compiler args for the IBM compiler 508825b89263Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 508925b89263Smrg # -F/path path to uninstalled frameworks, gcc on darwin 509025b89263Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 509125b89263Smrg # @file GCC response files 509225b89263Smrg # -tp=* Portland pgcc target processor selection 5093ea133fd7Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 509425b89263Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*) 5095ea133fd7Smrg func_quote_for_eval "$arg" 5096ea133fd7Smrg arg="$func_quote_for_eval_result" 5097ea133fd7Smrg func_append compile_command " $arg" 5098ea133fd7Smrg func_append finalize_command " $arg" 5099ea133fd7Smrg compiler_flags="$compiler_flags $arg" 5100ea133fd7Smrg continue 5101ea133fd7Smrg ;; 5102a253d6aeSmrg 5103ea133fd7Smrg # Some other compiler flag. 5104ea133fd7Smrg -* | +*) 5105ea133fd7Smrg func_quote_for_eval "$arg" 5106ea133fd7Smrg arg="$func_quote_for_eval_result" 5107ea133fd7Smrg ;; 5108a253d6aeSmrg 5109ea133fd7Smrg *.$objext) 5110ea133fd7Smrg # A standard object. 5111ea133fd7Smrg objs="$objs $arg" 5112ea133fd7Smrg ;; 5113ea133fd7Smrg 5114ea133fd7Smrg *.lo) 5115ea133fd7Smrg # A libtool-controlled object. 5116ea133fd7Smrg 5117ea133fd7Smrg # Check to see that this really is a libtool object. 5118ea133fd7Smrg if func_lalib_unsafe_p "$arg"; then 5119ea133fd7Smrg pic_object= 5120ea133fd7Smrg non_pic_object= 5121ea133fd7Smrg 5122ea133fd7Smrg # Read the .lo file 5123ea133fd7Smrg func_source "$arg" 5124ea133fd7Smrg 5125ea133fd7Smrg if test -z "$pic_object" || 5126ea133fd7Smrg test -z "$non_pic_object" || 5127ea133fd7Smrg test "$pic_object" = none && 5128ea133fd7Smrg test "$non_pic_object" = none; then 5129ea133fd7Smrg func_fatal_error "cannot find name of object for \`$arg'" 5130ea133fd7Smrg fi 5131ea133fd7Smrg 5132ea133fd7Smrg # Extract subdirectory from the argument. 5133ea133fd7Smrg func_dirname "$arg" "/" "" 5134ea133fd7Smrg xdir="$func_dirname_result" 5135ea133fd7Smrg 5136ea133fd7Smrg if test "$pic_object" != none; then 5137ea133fd7Smrg # Prepend the subdirectory the object is found in. 5138ea133fd7Smrg pic_object="$xdir$pic_object" 5139ea133fd7Smrg 5140ea133fd7Smrg if test "$prev" = dlfiles; then 5141ea133fd7Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5142ea133fd7Smrg dlfiles="$dlfiles $pic_object" 5143ea133fd7Smrg prev= 5144ea133fd7Smrg continue 5145ea133fd7Smrg else 5146ea133fd7Smrg # If libtool objects are unsupported, then we need to preload. 5147ea133fd7Smrg prev=dlprefiles 5148ea133fd7Smrg fi 5149ea133fd7Smrg fi 5150ea133fd7Smrg 5151ea133fd7Smrg # CHECK ME: I think I busted this. -Ossama 5152ea133fd7Smrg if test "$prev" = dlprefiles; then 5153ea133fd7Smrg # Preload the old-style object. 5154ea133fd7Smrg dlprefiles="$dlprefiles $pic_object" 5155ea133fd7Smrg prev= 5156ea133fd7Smrg fi 5157ea133fd7Smrg 5158ea133fd7Smrg # A PIC object. 5159ea133fd7Smrg func_append libobjs " $pic_object" 5160ea133fd7Smrg arg="$pic_object" 5161ea133fd7Smrg fi 5162ea133fd7Smrg 5163ea133fd7Smrg # Non-PIC object. 5164ea133fd7Smrg if test "$non_pic_object" != none; then 5165ea133fd7Smrg # Prepend the subdirectory the object is found in. 5166ea133fd7Smrg non_pic_object="$xdir$non_pic_object" 5167ea133fd7Smrg 5168ea133fd7Smrg # A standard non-PIC object 5169ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5170ea133fd7Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5171ea133fd7Smrg arg="$non_pic_object" 5172ea133fd7Smrg fi 5173ea133fd7Smrg else 5174ea133fd7Smrg # If the PIC object exists, use it instead. 5175ea133fd7Smrg # $xdir was prepended to $pic_object above. 5176ea133fd7Smrg non_pic_object="$pic_object" 5177ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5178ea133fd7Smrg fi 5179ea133fd7Smrg else 5180ea133fd7Smrg # Only an error if not doing a dry-run. 5181ea133fd7Smrg if $opt_dry_run; then 5182ea133fd7Smrg # Extract subdirectory from the argument. 5183ea133fd7Smrg func_dirname "$arg" "/" "" 5184ea133fd7Smrg xdir="$func_dirname_result" 5185ea133fd7Smrg 5186ea133fd7Smrg func_lo2o "$arg" 5187ea133fd7Smrg pic_object=$xdir$objdir/$func_lo2o_result 5188ea133fd7Smrg non_pic_object=$xdir$func_lo2o_result 5189ea133fd7Smrg func_append libobjs " $pic_object" 5190ea133fd7Smrg func_append non_pic_objects " $non_pic_object" 5191ea133fd7Smrg else 5192ea133fd7Smrg func_fatal_error "\`$arg' is not a valid libtool object" 5193ea133fd7Smrg fi 5194ea133fd7Smrg fi 5195ea133fd7Smrg ;; 5196ea133fd7Smrg 5197ea133fd7Smrg *.$libext) 5198ea133fd7Smrg # An archive. 5199ea133fd7Smrg deplibs="$deplibs $arg" 5200ea133fd7Smrg old_deplibs="$old_deplibs $arg" 5201ea133fd7Smrg continue 5202ea133fd7Smrg ;; 5203ea133fd7Smrg 5204ea133fd7Smrg *.la) 5205ea133fd7Smrg # A libtool-controlled library. 5206ea133fd7Smrg 5207ea133fd7Smrg if test "$prev" = dlfiles; then 5208ea133fd7Smrg # This library was specified with -dlopen. 5209ea133fd7Smrg dlfiles="$dlfiles $arg" 5210ea133fd7Smrg prev= 5211ea133fd7Smrg elif test "$prev" = dlprefiles; then 5212ea133fd7Smrg # The library was specified with -dlpreopen. 5213ea133fd7Smrg dlprefiles="$dlprefiles $arg" 5214ea133fd7Smrg prev= 5215ea133fd7Smrg else 5216ea133fd7Smrg deplibs="$deplibs $arg" 5217ea133fd7Smrg fi 5218ea133fd7Smrg continue 5219ea133fd7Smrg ;; 5220ea133fd7Smrg 5221ea133fd7Smrg # Some other compiler argument. 5222ea133fd7Smrg *) 5223ea133fd7Smrg # Unknown arguments in both finalize_command and compile_command need 5224ea133fd7Smrg # to be aesthetically quoted because they are evaled later. 5225ea133fd7Smrg func_quote_for_eval "$arg" 5226ea133fd7Smrg arg="$func_quote_for_eval_result" 5227ea133fd7Smrg ;; 5228ea133fd7Smrg esac # arg 5229ea133fd7Smrg 5230ea133fd7Smrg # Now actually substitute the argument into the commands. 5231ea133fd7Smrg if test -n "$arg"; then 5232ea133fd7Smrg func_append compile_command " $arg" 5233ea133fd7Smrg func_append finalize_command " $arg" 5234ea133fd7Smrg fi 5235ea133fd7Smrg done # argument parsing loop 5236ea133fd7Smrg 5237ea133fd7Smrg test -n "$prev" && \ 5238ea133fd7Smrg func_fatal_help "the \`$prevarg' option requires an argument" 5239ea133fd7Smrg 5240ea133fd7Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 5241ea133fd7Smrg eval arg=\"$export_dynamic_flag_spec\" 5242ea133fd7Smrg func_append compile_command " $arg" 5243ea133fd7Smrg func_append finalize_command " $arg" 5244ea133fd7Smrg fi 5245ea133fd7Smrg 5246ea133fd7Smrg oldlibs= 5247ea133fd7Smrg # calculate the name of the file, without its directory 5248ea133fd7Smrg func_basename "$output" 5249ea133fd7Smrg outputname="$func_basename_result" 5250ea133fd7Smrg libobjs_save="$libobjs" 5251ea133fd7Smrg 5252ea133fd7Smrg if test -n "$shlibpath_var"; then 5253ea133fd7Smrg # get the directories listed in $shlibpath_var 525425b89263Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 5255a253d6aeSmrg else 5256ea133fd7Smrg shlib_search_path= 5257a253d6aeSmrg fi 5258ea133fd7Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 5259ea133fd7Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 5260a253d6aeSmrg 5261ea133fd7Smrg func_dirname "$output" "/" "" 5262ea133fd7Smrg output_objdir="$func_dirname_result$objdir" 5263ea133fd7Smrg # Create the object directory. 5264ea133fd7Smrg func_mkdir_p "$output_objdir" 5265a253d6aeSmrg 5266ea133fd7Smrg # Determine the type of output 5267ea133fd7Smrg case $output in 5268ea133fd7Smrg "") 5269ea133fd7Smrg func_fatal_help "you must specify an output file" 5270ea133fd7Smrg ;; 5271ea133fd7Smrg *.$libext) linkmode=oldlib ;; 5272ea133fd7Smrg *.lo | *.$objext) linkmode=obj ;; 5273ea133fd7Smrg *.la) linkmode=lib ;; 5274ea133fd7Smrg *) linkmode=prog ;; # Anything else should be a program. 5275ea133fd7Smrg esac 5276ea133fd7Smrg 5277ea133fd7Smrg specialdeplibs= 5278ea133fd7Smrg 5279ea133fd7Smrg libs= 5280ea133fd7Smrg # Find all interdependent deplibs by searching for libraries 5281ea133fd7Smrg # that are linked more than once (e.g. -la -lb -la) 5282ea133fd7Smrg for deplib in $deplibs; do 5283ea133fd7Smrg if $opt_duplicate_deps ; then 5284ea133fd7Smrg case "$libs " in 5285ea133fd7Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 5286ea133fd7Smrg esac 5287ea133fd7Smrg fi 5288ea133fd7Smrg libs="$libs $deplib" 5289ea133fd7Smrg done 5290ea133fd7Smrg 5291ea133fd7Smrg if test "$linkmode" = lib; then 5292ea133fd7Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 5293ea133fd7Smrg 5294ea133fd7Smrg # Compute libraries that are listed more than once in $predeps 5295ea133fd7Smrg # $postdeps and mark them as special (i.e., whose duplicates are 5296ea133fd7Smrg # not to be eliminated). 5297ea133fd7Smrg pre_post_deps= 5298ea133fd7Smrg if $opt_duplicate_compiler_generated_deps; then 5299ea133fd7Smrg for pre_post_dep in $predeps $postdeps; do 5300ea133fd7Smrg case "$pre_post_deps " in 5301ea133fd7Smrg *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; 5302ea133fd7Smrg esac 5303ea133fd7Smrg pre_post_deps="$pre_post_deps $pre_post_dep" 5304ea133fd7Smrg done 5305ea133fd7Smrg fi 5306ea133fd7Smrg pre_post_deps= 5307ea133fd7Smrg fi 5308ea133fd7Smrg 5309ea133fd7Smrg deplibs= 5310ea133fd7Smrg newdependency_libs= 5311ea133fd7Smrg newlib_search_path= 5312ea133fd7Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 5313ea133fd7Smrg notinst_deplibs= # not-installed libtool libraries 5314ea133fd7Smrg notinst_path= # paths that contain not-installed libtool libraries 5315ea133fd7Smrg 5316ea133fd7Smrg case $linkmode in 5317ea133fd7Smrg lib) 5318ea133fd7Smrg passes="conv dlpreopen link" 5319ea133fd7Smrg for file in $dlfiles $dlprefiles; do 5320ea133fd7Smrg case $file in 5321ea133fd7Smrg *.la) ;; 5322ea133fd7Smrg *) 5323ea133fd7Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 5324ea133fd7Smrg ;; 5325ea133fd7Smrg esac 5326ea133fd7Smrg done 5327ea133fd7Smrg ;; 5328ea133fd7Smrg prog) 5329ea133fd7Smrg compile_deplibs= 5330ea133fd7Smrg finalize_deplibs= 5331ea133fd7Smrg alldeplibs=no 5332ea133fd7Smrg newdlfiles= 5333ea133fd7Smrg newdlprefiles= 5334ea133fd7Smrg passes="conv scan dlopen dlpreopen link" 5335ea133fd7Smrg ;; 5336ea133fd7Smrg *) passes="conv" 5337ea133fd7Smrg ;; 5338ea133fd7Smrg esac 5339ea133fd7Smrg 5340ea133fd7Smrg for pass in $passes; do 5341ea133fd7Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 5342ea133fd7Smrg # so that -L comes before libs that need it for instance... 5343ea133fd7Smrg if test "$linkmode,$pass" = "lib,link"; then 5344ea133fd7Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 5345ea133fd7Smrg ## order, and fix it there properly 5346ea133fd7Smrg tmp_deplibs= 5347ea133fd7Smrg for deplib in $deplibs; do 5348ea133fd7Smrg tmp_deplibs="$deplib $tmp_deplibs" 5349ea133fd7Smrg done 5350ea133fd7Smrg deplibs="$tmp_deplibs" 5351ea133fd7Smrg fi 5352ea133fd7Smrg 5353ea133fd7Smrg if test "$linkmode,$pass" = "lib,link" || 5354ea133fd7Smrg test "$linkmode,$pass" = "prog,scan"; then 5355ea133fd7Smrg libs="$deplibs" 5356ea133fd7Smrg deplibs= 5357ea133fd7Smrg fi 5358ea133fd7Smrg if test "$linkmode" = prog; then 5359ea133fd7Smrg case $pass in 5360ea133fd7Smrg dlopen) libs="$dlfiles" ;; 5361ea133fd7Smrg dlpreopen) libs="$dlprefiles" ;; 5362ea133fd7Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 5363ea133fd7Smrg esac 5364ea133fd7Smrg fi 5365ea133fd7Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 5366ea133fd7Smrg # Collect and forward deplibs of preopened libtool libs 5367ea133fd7Smrg for lib in $dlprefiles; do 5368ea133fd7Smrg # Ignore non-libtool-libs 5369ea133fd7Smrg dependency_libs= 5370ea133fd7Smrg case $lib in 5371ea133fd7Smrg *.la) func_source "$lib" ;; 5372ea133fd7Smrg esac 5373ea133fd7Smrg 5374ea133fd7Smrg # Collect preopened libtool deplibs, except any this library 5375ea133fd7Smrg # has declared as weak libs 5376ea133fd7Smrg for deplib in $dependency_libs; do 537725b89263Smrg func_basename "$deplib" 537825b89263Smrg deplib_base=$func_basename_result 5379ea133fd7Smrg case " $weak_libs " in 5380ea133fd7Smrg *" $deplib_base "*) ;; 5381ea133fd7Smrg *) deplibs="$deplibs $deplib" ;; 5382ea133fd7Smrg esac 5383ea133fd7Smrg done 5384ea133fd7Smrg done 5385ea133fd7Smrg libs="$dlprefiles" 5386ea133fd7Smrg fi 5387ea133fd7Smrg if test "$pass" = dlopen; then 5388ea133fd7Smrg # Collect dlpreopened libraries 5389ea133fd7Smrg save_deplibs="$deplibs" 5390ea133fd7Smrg deplibs= 5391ea133fd7Smrg fi 5392ea133fd7Smrg 5393ea133fd7Smrg for deplib in $libs; do 5394ea133fd7Smrg lib= 5395ea133fd7Smrg found=no 5396ea133fd7Smrg case $deplib in 5397ea133fd7Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 5398ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 5399ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 5400ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 5401ea133fd7Smrg else 5402ea133fd7Smrg compiler_flags="$compiler_flags $deplib" 5403ea133fd7Smrg if test "$linkmode" = lib ; then 5404ea133fd7Smrg case "$new_inherited_linker_flags " in 5405ea133fd7Smrg *" $deplib "*) ;; 5406ea133fd7Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; 5407ea133fd7Smrg esac 5408ea133fd7Smrg fi 5409ea133fd7Smrg fi 5410ea133fd7Smrg continue 5411ea133fd7Smrg ;; 5412ea133fd7Smrg -l*) 5413ea133fd7Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 5414ea133fd7Smrg func_warning "\`-l' is ignored for archives/objects" 5415ea133fd7Smrg continue 5416ea133fd7Smrg fi 5417ea133fd7Smrg func_stripname '-l' '' "$deplib" 5418ea133fd7Smrg name=$func_stripname_result 5419ea133fd7Smrg if test "$linkmode" = lib; then 5420ea133fd7Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 5421ea133fd7Smrg else 5422ea133fd7Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 5423ea133fd7Smrg fi 5424ea133fd7Smrg for searchdir in $searchdirs; do 5425ea133fd7Smrg for search_ext in .la $std_shrext .so .a; do 5426ea133fd7Smrg # Search the libtool library 5427ea133fd7Smrg lib="$searchdir/lib${name}${search_ext}" 5428ea133fd7Smrg if test -f "$lib"; then 5429ea133fd7Smrg if test "$search_ext" = ".la"; then 5430ea133fd7Smrg found=yes 5431ea133fd7Smrg else 5432ea133fd7Smrg found=no 5433ea133fd7Smrg fi 5434ea133fd7Smrg break 2 5435ea133fd7Smrg fi 5436ea133fd7Smrg done 5437ea133fd7Smrg done 5438ea133fd7Smrg if test "$found" != yes; then 5439ea133fd7Smrg # deplib doesn't seem to be a libtool library 5440ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 5441ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 5442ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 5443ea133fd7Smrg else 5444ea133fd7Smrg deplibs="$deplib $deplibs" 5445ea133fd7Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 5446ea133fd7Smrg fi 5447ea133fd7Smrg continue 5448ea133fd7Smrg else # deplib is a libtool library 5449ea133fd7Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 5450ea133fd7Smrg # We need to do some special things here, and not later. 5451ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 5452ea133fd7Smrg case " $predeps $postdeps " in 5453ea133fd7Smrg *" $deplib "*) 5454ea133fd7Smrg if func_lalib_p "$lib"; then 5455ea133fd7Smrg library_names= 5456ea133fd7Smrg old_library= 5457ea133fd7Smrg func_source "$lib" 5458ea133fd7Smrg for l in $old_library $library_names; do 5459ea133fd7Smrg ll="$l" 5460ea133fd7Smrg done 5461ea133fd7Smrg if test "X$ll" = "X$old_library" ; then # only static version available 5462ea133fd7Smrg found=no 5463ea133fd7Smrg func_dirname "$lib" "" "." 5464ea133fd7Smrg ladir="$func_dirname_result" 5465ea133fd7Smrg lib=$ladir/$old_library 5466ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 5467ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 5468ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 5469ea133fd7Smrg else 5470ea133fd7Smrg deplibs="$deplib $deplibs" 5471ea133fd7Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 5472ea133fd7Smrg fi 5473ea133fd7Smrg continue 5474ea133fd7Smrg fi 5475ea133fd7Smrg fi 5476ea133fd7Smrg ;; 5477ea133fd7Smrg *) ;; 5478ea133fd7Smrg esac 5479ea133fd7Smrg fi 5480ea133fd7Smrg fi 5481ea133fd7Smrg ;; # -l 5482ea133fd7Smrg *.ltframework) 5483ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 5484ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 5485ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 5486ea133fd7Smrg else 5487ea133fd7Smrg deplibs="$deplib $deplibs" 5488ea133fd7Smrg if test "$linkmode" = lib ; then 5489ea133fd7Smrg case "$new_inherited_linker_flags " in 5490ea133fd7Smrg *" $deplib "*) ;; 5491ea133fd7Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; 5492ea133fd7Smrg esac 5493ea133fd7Smrg fi 5494ea133fd7Smrg fi 5495ea133fd7Smrg continue 5496ea133fd7Smrg ;; 5497ea133fd7Smrg -L*) 5498ea133fd7Smrg case $linkmode in 5499ea133fd7Smrg lib) 5500ea133fd7Smrg deplibs="$deplib $deplibs" 5501ea133fd7Smrg test "$pass" = conv && continue 5502ea133fd7Smrg newdependency_libs="$deplib $newdependency_libs" 5503ea133fd7Smrg func_stripname '-L' '' "$deplib" 5504ea133fd7Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 5505ea133fd7Smrg ;; 5506ea133fd7Smrg prog) 5507ea133fd7Smrg if test "$pass" = conv; then 5508ea133fd7Smrg deplibs="$deplib $deplibs" 5509ea133fd7Smrg continue 5510ea133fd7Smrg fi 5511ea133fd7Smrg if test "$pass" = scan; then 5512ea133fd7Smrg deplibs="$deplib $deplibs" 5513ea133fd7Smrg else 5514ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 5515ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 5516ea133fd7Smrg fi 5517ea133fd7Smrg func_stripname '-L' '' "$deplib" 5518ea133fd7Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 5519ea133fd7Smrg ;; 5520ea133fd7Smrg *) 5521ea133fd7Smrg func_warning "\`-L' is ignored for archives/objects" 5522ea133fd7Smrg ;; 5523ea133fd7Smrg esac # linkmode 5524ea133fd7Smrg continue 5525ea133fd7Smrg ;; # -L 5526ea133fd7Smrg -R*) 5527ea133fd7Smrg if test "$pass" = link; then 5528ea133fd7Smrg func_stripname '-R' '' "$deplib" 5529ea133fd7Smrg dir=$func_stripname_result 5530ea133fd7Smrg # Make sure the xrpath contains only unique directories. 5531ea133fd7Smrg case "$xrpath " in 5532ea133fd7Smrg *" $dir "*) ;; 5533ea133fd7Smrg *) xrpath="$xrpath $dir" ;; 5534ea133fd7Smrg esac 5535ea133fd7Smrg fi 5536ea133fd7Smrg deplibs="$deplib $deplibs" 5537ea133fd7Smrg continue 5538ea133fd7Smrg ;; 5539ea133fd7Smrg *.la) lib="$deplib" ;; 5540ea133fd7Smrg *.$libext) 5541ea133fd7Smrg if test "$pass" = conv; then 5542ea133fd7Smrg deplibs="$deplib $deplibs" 5543ea133fd7Smrg continue 5544ea133fd7Smrg fi 5545ea133fd7Smrg case $linkmode in 5546ea133fd7Smrg lib) 5547ea133fd7Smrg # Linking convenience modules into shared libraries is allowed, 5548ea133fd7Smrg # but linking other static libraries is non-portable. 5549ea133fd7Smrg case " $dlpreconveniencelibs " in 5550ea133fd7Smrg *" $deplib "*) ;; 5551ea133fd7Smrg *) 5552ea133fd7Smrg valid_a_lib=no 5553ea133fd7Smrg case $deplibs_check_method in 5554ea133fd7Smrg match_pattern*) 5555ea133fd7Smrg set dummy $deplibs_check_method; shift 5556ea133fd7Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 555725b89263Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 5558ea133fd7Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 5559ea133fd7Smrg valid_a_lib=yes 5560ea133fd7Smrg fi 5561ea133fd7Smrg ;; 5562ea133fd7Smrg pass_all) 5563ea133fd7Smrg valid_a_lib=yes 5564ea133fd7Smrg ;; 5565ea133fd7Smrg esac 5566ea133fd7Smrg if test "$valid_a_lib" != yes; then 556725b89263Smrg echo 5568ea133fd7Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 556925b89263Smrg echo "*** I have the capability to make that library automatically link in when" 557025b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 557125b89263Smrg echo "*** shared version of the library, which you do not appear to have" 557225b89263Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 557325b89263Smrg echo "*** that it is just a static archive that I should not use here." 5574ea133fd7Smrg else 557525b89263Smrg echo 5576ea133fd7Smrg $ECHO "*** Warning: Linking the shared library $output against the" 5577ea133fd7Smrg $ECHO "*** static library $deplib is not portable!" 5578ea133fd7Smrg deplibs="$deplib $deplibs" 5579ea133fd7Smrg fi 5580ea133fd7Smrg ;; 5581ea133fd7Smrg esac 5582ea133fd7Smrg continue 5583ea133fd7Smrg ;; 5584ea133fd7Smrg prog) 5585ea133fd7Smrg if test "$pass" != link; then 5586ea133fd7Smrg deplibs="$deplib $deplibs" 5587ea133fd7Smrg else 5588ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 5589ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 5590ea133fd7Smrg fi 5591ea133fd7Smrg continue 5592ea133fd7Smrg ;; 5593ea133fd7Smrg esac # linkmode 5594ea133fd7Smrg ;; # *.$libext 5595ea133fd7Smrg *.lo | *.$objext) 5596ea133fd7Smrg if test "$pass" = conv; then 5597ea133fd7Smrg deplibs="$deplib $deplibs" 5598ea133fd7Smrg elif test "$linkmode" = prog; then 5599ea133fd7Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 5600ea133fd7Smrg # If there is no dlopen support or we're linking statically, 5601ea133fd7Smrg # we need to preload. 5602ea133fd7Smrg newdlprefiles="$newdlprefiles $deplib" 5603ea133fd7Smrg compile_deplibs="$deplib $compile_deplibs" 5604ea133fd7Smrg finalize_deplibs="$deplib $finalize_deplibs" 5605ea133fd7Smrg else 5606ea133fd7Smrg newdlfiles="$newdlfiles $deplib" 5607ea133fd7Smrg fi 5608ea133fd7Smrg fi 5609ea133fd7Smrg continue 5610ea133fd7Smrg ;; 5611ea133fd7Smrg %DEPLIBS%) 5612ea133fd7Smrg alldeplibs=yes 5613ea133fd7Smrg continue 5614ea133fd7Smrg ;; 5615ea133fd7Smrg esac # case $deplib 5616ea133fd7Smrg 5617ea133fd7Smrg if test "$found" = yes || test -f "$lib"; then : 5618ea133fd7Smrg else 5619ea133fd7Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 5620ea133fd7Smrg fi 5621ea133fd7Smrg 5622ea133fd7Smrg # Check to see that this really is a libtool archive. 5623ea133fd7Smrg func_lalib_unsafe_p "$lib" \ 5624ea133fd7Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 5625ea133fd7Smrg 5626ea133fd7Smrg func_dirname "$lib" "" "." 5627ea133fd7Smrg ladir="$func_dirname_result" 5628ea133fd7Smrg 5629ea133fd7Smrg dlname= 5630ea133fd7Smrg dlopen= 5631ea133fd7Smrg dlpreopen= 5632ea133fd7Smrg libdir= 5633ea133fd7Smrg library_names= 5634ea133fd7Smrg old_library= 5635ea133fd7Smrg inherited_linker_flags= 5636ea133fd7Smrg # If the library was installed with an old release of libtool, 5637ea133fd7Smrg # it will not redefine variables installed, or shouldnotlink 5638ea133fd7Smrg installed=yes 5639ea133fd7Smrg shouldnotlink=no 5640ea133fd7Smrg avoidtemprpath= 5641ea133fd7Smrg 5642ea133fd7Smrg 5643ea133fd7Smrg # Read the .la file 5644ea133fd7Smrg func_source "$lib" 5645ea133fd7Smrg 5646ea133fd7Smrg # Convert "-framework foo" to "foo.ltframework" 5647ea133fd7Smrg if test -n "$inherited_linker_flags"; then 564825b89263Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 5649ea133fd7Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 5650ea133fd7Smrg case " $new_inherited_linker_flags " in 5651ea133fd7Smrg *" $tmp_inherited_linker_flag "*) ;; 5652ea133fd7Smrg *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; 5653ea133fd7Smrg esac 5654ea133fd7Smrg done 5655ea133fd7Smrg fi 565625b89263Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 5657ea133fd7Smrg if test "$linkmode,$pass" = "lib,link" || 5658ea133fd7Smrg test "$linkmode,$pass" = "prog,scan" || 5659ea133fd7Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 5660ea133fd7Smrg test -n "$dlopen" && dlfiles="$dlfiles $dlopen" 5661ea133fd7Smrg test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" 5662ea133fd7Smrg fi 5663ea133fd7Smrg 5664ea133fd7Smrg if test "$pass" = conv; then 5665ea133fd7Smrg # Only check for convenience libraries 5666ea133fd7Smrg deplibs="$lib $deplibs" 5667ea133fd7Smrg if test -z "$libdir"; then 5668ea133fd7Smrg if test -z "$old_library"; then 5669ea133fd7Smrg func_fatal_error "cannot find name of link library for \`$lib'" 5670ea133fd7Smrg fi 5671ea133fd7Smrg # It is a libtool convenience library, so add in its objects. 5672ea133fd7Smrg convenience="$convenience $ladir/$objdir/$old_library" 5673ea133fd7Smrg old_convenience="$old_convenience $ladir/$objdir/$old_library" 5674ea133fd7Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 5675ea133fd7Smrg func_fatal_error "\`$lib' is not a convenience library" 5676ea133fd7Smrg fi 5677ea133fd7Smrg tmp_libs= 5678ea133fd7Smrg for deplib in $dependency_libs; do 5679ea133fd7Smrg deplibs="$deplib $deplibs" 5680ea133fd7Smrg if $opt_duplicate_deps ; then 5681ea133fd7Smrg case "$tmp_libs " in 5682ea133fd7Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 5683ea133fd7Smrg esac 5684ea133fd7Smrg fi 5685ea133fd7Smrg tmp_libs="$tmp_libs $deplib" 5686ea133fd7Smrg done 5687ea133fd7Smrg continue 5688ea133fd7Smrg fi # $pass = conv 5689ea133fd7Smrg 5690ea133fd7Smrg 5691ea133fd7Smrg # Get the name of the library we link against. 5692ea133fd7Smrg linklib= 5693ea133fd7Smrg for l in $old_library $library_names; do 5694ea133fd7Smrg linklib="$l" 5695ea133fd7Smrg done 5696ea133fd7Smrg if test -z "$linklib"; then 5697ea133fd7Smrg func_fatal_error "cannot find name of link library for \`$lib'" 5698ea133fd7Smrg fi 5699ea133fd7Smrg 5700ea133fd7Smrg # This library was specified with -dlopen. 5701ea133fd7Smrg if test "$pass" = dlopen; then 5702ea133fd7Smrg if test -z "$libdir"; then 5703ea133fd7Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 5704ea133fd7Smrg fi 5705ea133fd7Smrg if test -z "$dlname" || 5706ea133fd7Smrg test "$dlopen_support" != yes || 5707ea133fd7Smrg test "$build_libtool_libs" = no; then 5708ea133fd7Smrg # If there is no dlname, no dlopen support or we're linking 5709ea133fd7Smrg # statically, we need to preload. We also need to preload any 5710ea133fd7Smrg # dependent libraries so libltdl's deplib preloader doesn't 5711ea133fd7Smrg # bomb out in the load deplibs phase. 5712ea133fd7Smrg dlprefiles="$dlprefiles $lib $dependency_libs" 5713ea133fd7Smrg else 5714ea133fd7Smrg newdlfiles="$newdlfiles $lib" 5715ea133fd7Smrg fi 5716ea133fd7Smrg continue 5717ea133fd7Smrg fi # $pass = dlopen 5718ea133fd7Smrg 5719ea133fd7Smrg # We need an absolute path. 5720ea133fd7Smrg case $ladir in 5721ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 5722ea133fd7Smrg *) 5723ea133fd7Smrg abs_ladir=`cd "$ladir" && pwd` 5724ea133fd7Smrg if test -z "$abs_ladir"; then 5725ea133fd7Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 5726ea133fd7Smrg func_warning "passing it literally to the linker, although it might fail" 5727ea133fd7Smrg abs_ladir="$ladir" 5728ea133fd7Smrg fi 5729ea133fd7Smrg ;; 5730ea133fd7Smrg esac 5731ea133fd7Smrg func_basename "$lib" 5732ea133fd7Smrg laname="$func_basename_result" 5733ea133fd7Smrg 5734ea133fd7Smrg # Find the relevant object directory and library name. 5735ea133fd7Smrg if test "X$installed" = Xyes; then 5736ea133fd7Smrg if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 5737ea133fd7Smrg func_warning "library \`$lib' was moved." 5738ea133fd7Smrg dir="$ladir" 5739ea133fd7Smrg absdir="$abs_ladir" 5740ea133fd7Smrg libdir="$abs_ladir" 5741ea133fd7Smrg else 5742ea133fd7Smrg dir="$libdir" 5743ea133fd7Smrg absdir="$libdir" 5744ea133fd7Smrg fi 5745ea133fd7Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 5746ea133fd7Smrg else 5747ea133fd7Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 5748ea133fd7Smrg dir="$ladir" 5749ea133fd7Smrg absdir="$abs_ladir" 5750ea133fd7Smrg # Remove this search path later 5751ea133fd7Smrg notinst_path="$notinst_path $abs_ladir" 5752ea133fd7Smrg else 5753ea133fd7Smrg dir="$ladir/$objdir" 5754ea133fd7Smrg absdir="$abs_ladir/$objdir" 5755ea133fd7Smrg # Remove this search path later 5756ea133fd7Smrg notinst_path="$notinst_path $abs_ladir" 5757ea133fd7Smrg fi 5758ea133fd7Smrg fi # $installed = yes 5759ea133fd7Smrg func_stripname 'lib' '.la' "$laname" 5760ea133fd7Smrg name=$func_stripname_result 5761ea133fd7Smrg 5762ea133fd7Smrg # This library was specified with -dlpreopen. 5763ea133fd7Smrg if test "$pass" = dlpreopen; then 5764ea133fd7Smrg if test -z "$libdir" && test "$linkmode" = prog; then 5765ea133fd7Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 5766ea133fd7Smrg fi 5767ea133fd7Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 5768ea133fd7Smrg # are required to link). 5769ea133fd7Smrg if test -n "$old_library"; then 5770ea133fd7Smrg newdlprefiles="$newdlprefiles $dir/$old_library" 5771ea133fd7Smrg # Keep a list of preopened convenience libraries to check 5772ea133fd7Smrg # that they are being used correctly in the link pass. 5773ea133fd7Smrg test -z "$libdir" && \ 5774ea133fd7Smrg dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" 5775ea133fd7Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 5776ea133fd7Smrg elif test -n "$dlname"; then 5777ea133fd7Smrg newdlprefiles="$newdlprefiles $dir/$dlname" 5778ea133fd7Smrg else 5779ea133fd7Smrg newdlprefiles="$newdlprefiles $dir/$linklib" 5780ea133fd7Smrg fi 5781ea133fd7Smrg fi # $pass = dlpreopen 5782ea133fd7Smrg 5783ea133fd7Smrg if test -z "$libdir"; then 5784ea133fd7Smrg # Link the convenience library 5785ea133fd7Smrg if test "$linkmode" = lib; then 5786ea133fd7Smrg deplibs="$dir/$old_library $deplibs" 5787ea133fd7Smrg elif test "$linkmode,$pass" = "prog,link"; then 5788ea133fd7Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 5789ea133fd7Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 5790ea133fd7Smrg else 5791ea133fd7Smrg deplibs="$lib $deplibs" # used for prog,scan pass 5792ea133fd7Smrg fi 5793ea133fd7Smrg continue 5794ea133fd7Smrg fi 5795ea133fd7Smrg 5796ea133fd7Smrg 5797ea133fd7Smrg if test "$linkmode" = prog && test "$pass" != link; then 5798ea133fd7Smrg newlib_search_path="$newlib_search_path $ladir" 5799ea133fd7Smrg deplibs="$lib $deplibs" 5800ea133fd7Smrg 5801ea133fd7Smrg linkalldeplibs=no 5802ea133fd7Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 5803ea133fd7Smrg test "$build_libtool_libs" = no; then 5804ea133fd7Smrg linkalldeplibs=yes 5805ea133fd7Smrg fi 5806ea133fd7Smrg 5807ea133fd7Smrg tmp_libs= 5808ea133fd7Smrg for deplib in $dependency_libs; do 5809ea133fd7Smrg case $deplib in 5810ea133fd7Smrg -L*) func_stripname '-L' '' "$deplib" 5811ea133fd7Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 5812ea133fd7Smrg ;; 5813ea133fd7Smrg esac 5814ea133fd7Smrg # Need to link against all dependency_libs? 5815ea133fd7Smrg if test "$linkalldeplibs" = yes; then 5816ea133fd7Smrg deplibs="$deplib $deplibs" 5817ea133fd7Smrg else 5818ea133fd7Smrg # Need to hardcode shared library paths 5819ea133fd7Smrg # or/and link against static libraries 5820ea133fd7Smrg newdependency_libs="$deplib $newdependency_libs" 5821ea133fd7Smrg fi 5822ea133fd7Smrg if $opt_duplicate_deps ; then 5823ea133fd7Smrg case "$tmp_libs " in 5824ea133fd7Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 5825ea133fd7Smrg esac 5826ea133fd7Smrg fi 5827ea133fd7Smrg tmp_libs="$tmp_libs $deplib" 5828ea133fd7Smrg done # for deplib 5829ea133fd7Smrg continue 5830ea133fd7Smrg fi # $linkmode = prog... 5831ea133fd7Smrg 5832ea133fd7Smrg if test "$linkmode,$pass" = "prog,link"; then 5833ea133fd7Smrg if test -n "$library_names" && 5834ea133fd7Smrg { { test "$prefer_static_libs" = no || 5835ea133fd7Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 5836ea133fd7Smrg test -z "$old_library"; }; then 5837ea133fd7Smrg # We need to hardcode the library path 5838ea133fd7Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 5839ea133fd7Smrg # Make sure the rpath contains only unique directories. 5840ea133fd7Smrg case "$temp_rpath:" in 5841ea133fd7Smrg *"$absdir:"*) ;; 5842ea133fd7Smrg *) temp_rpath="$temp_rpath$absdir:" ;; 5843ea133fd7Smrg esac 5844ea133fd7Smrg fi 5845ea133fd7Smrg 5846ea133fd7Smrg # Hardcode the library path. 5847ea133fd7Smrg # Skip directories that are in the system default run-time 5848ea133fd7Smrg # search path. 5849ea133fd7Smrg case " $sys_lib_dlsearch_path " in 5850ea133fd7Smrg *" $absdir "*) ;; 5851ea133fd7Smrg *) 5852ea133fd7Smrg case "$compile_rpath " in 5853ea133fd7Smrg *" $absdir "*) ;; 5854ea133fd7Smrg *) compile_rpath="$compile_rpath $absdir" 5855ea133fd7Smrg esac 5856ea133fd7Smrg ;; 5857ea133fd7Smrg esac 5858ea133fd7Smrg case " $sys_lib_dlsearch_path " in 5859ea133fd7Smrg *" $libdir "*) ;; 5860ea133fd7Smrg *) 5861ea133fd7Smrg case "$finalize_rpath " in 5862ea133fd7Smrg *" $libdir "*) ;; 5863ea133fd7Smrg *) finalize_rpath="$finalize_rpath $libdir" 5864ea133fd7Smrg esac 5865ea133fd7Smrg ;; 5866ea133fd7Smrg esac 5867ea133fd7Smrg fi # $linkmode,$pass = prog,link... 5868ea133fd7Smrg 5869ea133fd7Smrg if test "$alldeplibs" = yes && 5870ea133fd7Smrg { test "$deplibs_check_method" = pass_all || 5871ea133fd7Smrg { test "$build_libtool_libs" = yes && 5872ea133fd7Smrg test -n "$library_names"; }; }; then 5873ea133fd7Smrg # We only need to search for static libraries 5874ea133fd7Smrg continue 5875ea133fd7Smrg fi 5876ea133fd7Smrg fi 5877ea133fd7Smrg 5878ea133fd7Smrg link_static=no # Whether the deplib will be linked statically 5879ea133fd7Smrg use_static_libs=$prefer_static_libs 5880ea133fd7Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 5881ea133fd7Smrg use_static_libs=no 5882ea133fd7Smrg fi 5883ea133fd7Smrg if test -n "$library_names" && 5884ea133fd7Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 5885ea133fd7Smrg case $host in 5886ea133fd7Smrg *cygwin* | *mingw* | *cegcc*) 5887ea133fd7Smrg # No point in relinking DLLs because paths are not encoded 5888ea133fd7Smrg notinst_deplibs="$notinst_deplibs $lib" 5889ea133fd7Smrg need_relink=no 5890ea133fd7Smrg ;; 5891ea133fd7Smrg *) 5892ea133fd7Smrg if test "$installed" = no; then 5893ea133fd7Smrg notinst_deplibs="$notinst_deplibs $lib" 5894ea133fd7Smrg need_relink=yes 5895ea133fd7Smrg fi 5896ea133fd7Smrg ;; 5897ea133fd7Smrg esac 5898ea133fd7Smrg # This is a shared library 5899ea133fd7Smrg 5900ea133fd7Smrg # Warn about portability, can't link against -module's on some 5901ea133fd7Smrg # systems (darwin). Don't bleat about dlopened modules though! 5902ea133fd7Smrg dlopenmodule="" 5903ea133fd7Smrg for dlpremoduletest in $dlprefiles; do 5904ea133fd7Smrg if test "X$dlpremoduletest" = "X$lib"; then 5905ea133fd7Smrg dlopenmodule="$dlpremoduletest" 5906ea133fd7Smrg break 5907ea133fd7Smrg fi 5908ea133fd7Smrg done 5909ea133fd7Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 591025b89263Smrg echo 5911ea133fd7Smrg if test "$linkmode" = prog; then 5912ea133fd7Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 5913ea133fd7Smrg else 5914ea133fd7Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 5915ea133fd7Smrg fi 5916ea133fd7Smrg $ECHO "*** $linklib is not portable!" 5917ea133fd7Smrg fi 5918ea133fd7Smrg if test "$linkmode" = lib && 5919ea133fd7Smrg test "$hardcode_into_libs" = yes; then 5920ea133fd7Smrg # Hardcode the library path. 5921ea133fd7Smrg # Skip directories that are in the system default run-time 5922ea133fd7Smrg # search path. 5923ea133fd7Smrg case " $sys_lib_dlsearch_path " in 5924ea133fd7Smrg *" $absdir "*) ;; 5925ea133fd7Smrg *) 5926ea133fd7Smrg case "$compile_rpath " in 5927ea133fd7Smrg *" $absdir "*) ;; 5928ea133fd7Smrg *) compile_rpath="$compile_rpath $absdir" 5929ea133fd7Smrg esac 5930ea133fd7Smrg ;; 5931ea133fd7Smrg esac 5932ea133fd7Smrg case " $sys_lib_dlsearch_path " in 5933ea133fd7Smrg *" $libdir "*) ;; 5934ea133fd7Smrg *) 5935ea133fd7Smrg case "$finalize_rpath " in 5936ea133fd7Smrg *" $libdir "*) ;; 5937ea133fd7Smrg *) finalize_rpath="$finalize_rpath $libdir" 5938ea133fd7Smrg esac 5939ea133fd7Smrg ;; 5940ea133fd7Smrg esac 5941ea133fd7Smrg fi 5942ea133fd7Smrg 5943ea133fd7Smrg if test -n "$old_archive_from_expsyms_cmds"; then 5944ea133fd7Smrg # figure out the soname 5945ea133fd7Smrg set dummy $library_names 5946ea133fd7Smrg shift 5947ea133fd7Smrg realname="$1" 5948ea133fd7Smrg shift 5949ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 5950ea133fd7Smrg # use dlname if we got it. it's perfectly good, no? 5951ea133fd7Smrg if test -n "$dlname"; then 5952ea133fd7Smrg soname="$dlname" 5953ea133fd7Smrg elif test -n "$soname_spec"; then 5954ea133fd7Smrg # bleh windows 5955ea133fd7Smrg case $host in 5956ea133fd7Smrg *cygwin* | mingw* | *cegcc*) 5957ea133fd7Smrg func_arith $current - $age 5958ea133fd7Smrg major=$func_arith_result 5959ea133fd7Smrg versuffix="-$major" 5960ea133fd7Smrg ;; 5961ea133fd7Smrg esac 5962ea133fd7Smrg eval soname=\"$soname_spec\" 5963ea133fd7Smrg else 5964ea133fd7Smrg soname="$realname" 5965ea133fd7Smrg fi 5966ea133fd7Smrg 5967ea133fd7Smrg # Make a new name for the extract_expsyms_cmds to use 5968ea133fd7Smrg soroot="$soname" 5969ea133fd7Smrg func_basename "$soroot" 5970ea133fd7Smrg soname="$func_basename_result" 5971ea133fd7Smrg func_stripname 'lib' '.dll' "$soname" 5972ea133fd7Smrg newlib=libimp-$func_stripname_result.a 5973ea133fd7Smrg 5974ea133fd7Smrg # If the library has no export list, then create one now 5975ea133fd7Smrg if test -f "$output_objdir/$soname-def"; then : 5976ea133fd7Smrg else 5977ea133fd7Smrg func_verbose "extracting exported symbol list from \`$soname'" 5978ea133fd7Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 5979ea133fd7Smrg fi 5980ea133fd7Smrg 5981ea133fd7Smrg # Create $newlib 5982ea133fd7Smrg if test -f "$output_objdir/$newlib"; then :; else 5983ea133fd7Smrg func_verbose "generating import library for \`$soname'" 5984ea133fd7Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 5985ea133fd7Smrg fi 5986ea133fd7Smrg # make sure the library variables are pointing to the new library 5987ea133fd7Smrg dir=$output_objdir 5988ea133fd7Smrg linklib=$newlib 5989ea133fd7Smrg fi # test -n "$old_archive_from_expsyms_cmds" 5990ea133fd7Smrg 5991ea133fd7Smrg if test "$linkmode" = prog || test "$mode" != relink; then 5992ea133fd7Smrg add_shlibpath= 5993ea133fd7Smrg add_dir= 5994ea133fd7Smrg add= 5995ea133fd7Smrg lib_linked=yes 5996ea133fd7Smrg case $hardcode_action in 5997ea133fd7Smrg immediate | unsupported) 5998ea133fd7Smrg if test "$hardcode_direct" = no; then 5999ea133fd7Smrg add="$dir/$linklib" 6000ea133fd7Smrg case $host in 6001ea133fd7Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6002ea133fd7Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 6003ea133fd7Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6004ea133fd7Smrg *-*-unixware7*) add_dir="-L$dir" ;; 6005ea133fd7Smrg *-*-darwin* ) 6006ea133fd7Smrg # if the lib is a (non-dlopened) module then we can not 6007ea133fd7Smrg # link against it, someone is ignoring the earlier warnings 6008ea133fd7Smrg if /usr/bin/file -L $add 2> /dev/null | 6009ea133fd7Smrg $GREP ": [^:]* bundle" >/dev/null ; then 6010ea133fd7Smrg if test "X$dlopenmodule" != "X$lib"; then 6011ea133fd7Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6012ea133fd7Smrg if test -z "$old_library" ; then 601325b89263Smrg echo 601425b89263Smrg echo "*** And there doesn't seem to be a static archive available" 601525b89263Smrg echo "*** The link will probably fail, sorry" 6016ea133fd7Smrg else 6017ea133fd7Smrg add="$dir/$old_library" 6018ea133fd7Smrg fi 6019ea133fd7Smrg elif test -n "$old_library"; then 6020ea133fd7Smrg add="$dir/$old_library" 6021ea133fd7Smrg fi 6022ea133fd7Smrg fi 6023ea133fd7Smrg esac 6024ea133fd7Smrg elif test "$hardcode_minus_L" = no; then 6025ea133fd7Smrg case $host in 6026ea133fd7Smrg *-*-sunos*) add_shlibpath="$dir" ;; 6027ea133fd7Smrg esac 6028ea133fd7Smrg add_dir="-L$dir" 6029ea133fd7Smrg add="-l$name" 6030ea133fd7Smrg elif test "$hardcode_shlibpath_var" = no; then 6031ea133fd7Smrg add_shlibpath="$dir" 6032ea133fd7Smrg add="-l$name" 6033ea133fd7Smrg else 6034ea133fd7Smrg lib_linked=no 6035ea133fd7Smrg fi 6036ea133fd7Smrg ;; 6037ea133fd7Smrg relink) 6038ea133fd7Smrg if test "$hardcode_direct" = yes && 6039ea133fd7Smrg test "$hardcode_direct_absolute" = no; then 6040ea133fd7Smrg add="$dir/$linklib" 6041ea133fd7Smrg elif test "$hardcode_minus_L" = yes; then 6042ea133fd7Smrg add_dir="-L$dir" 6043ea133fd7Smrg # Try looking first in the location we're being installed to. 6044ea133fd7Smrg if test -n "$inst_prefix_dir"; then 6045ea133fd7Smrg case $libdir in 6046ea133fd7Smrg [\\/]*) 6047ea133fd7Smrg add_dir="$add_dir -L$inst_prefix_dir$libdir" 6048ea133fd7Smrg ;; 6049ea133fd7Smrg esac 6050ea133fd7Smrg fi 6051ea133fd7Smrg add="-l$name" 6052ea133fd7Smrg elif test "$hardcode_shlibpath_var" = yes; then 6053ea133fd7Smrg add_shlibpath="$dir" 6054ea133fd7Smrg add="-l$name" 6055ea133fd7Smrg else 6056ea133fd7Smrg lib_linked=no 6057ea133fd7Smrg fi 6058ea133fd7Smrg ;; 6059ea133fd7Smrg *) lib_linked=no ;; 6060ea133fd7Smrg esac 6061ea133fd7Smrg 6062ea133fd7Smrg if test "$lib_linked" != yes; then 6063ea133fd7Smrg func_fatal_configuration "unsupported hardcode properties" 6064ea133fd7Smrg fi 6065ea133fd7Smrg 6066ea133fd7Smrg if test -n "$add_shlibpath"; then 6067ea133fd7Smrg case :$compile_shlibpath: in 6068ea133fd7Smrg *":$add_shlibpath:"*) ;; 6069ea133fd7Smrg *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; 6070ea133fd7Smrg esac 6071ea133fd7Smrg fi 6072ea133fd7Smrg if test "$linkmode" = prog; then 6073ea133fd7Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 6074ea133fd7Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 6075ea133fd7Smrg else 6076ea133fd7Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6077ea133fd7Smrg test -n "$add" && deplibs="$add $deplibs" 6078ea133fd7Smrg if test "$hardcode_direct" != yes && 6079ea133fd7Smrg test "$hardcode_minus_L" != yes && 6080ea133fd7Smrg test "$hardcode_shlibpath_var" = yes; then 6081ea133fd7Smrg case :$finalize_shlibpath: in 6082ea133fd7Smrg *":$libdir:"*) ;; 6083ea133fd7Smrg *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; 6084ea133fd7Smrg esac 6085ea133fd7Smrg fi 6086ea133fd7Smrg fi 6087ea133fd7Smrg fi 6088ea133fd7Smrg 6089ea133fd7Smrg if test "$linkmode" = prog || test "$mode" = relink; then 6090ea133fd7Smrg add_shlibpath= 6091ea133fd7Smrg add_dir= 6092ea133fd7Smrg add= 6093ea133fd7Smrg # Finalize command for both is simple: just hardcode it. 6094ea133fd7Smrg if test "$hardcode_direct" = yes && 6095ea133fd7Smrg test "$hardcode_direct_absolute" = no; then 6096ea133fd7Smrg add="$libdir/$linklib" 6097ea133fd7Smrg elif test "$hardcode_minus_L" = yes; then 6098ea133fd7Smrg add_dir="-L$libdir" 6099ea133fd7Smrg add="-l$name" 6100ea133fd7Smrg elif test "$hardcode_shlibpath_var" = yes; then 6101ea133fd7Smrg case :$finalize_shlibpath: in 6102ea133fd7Smrg *":$libdir:"*) ;; 6103ea133fd7Smrg *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; 6104ea133fd7Smrg esac 6105ea133fd7Smrg add="-l$name" 6106ea133fd7Smrg elif test "$hardcode_automatic" = yes; then 6107ea133fd7Smrg if test -n "$inst_prefix_dir" && 6108ea133fd7Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 6109ea133fd7Smrg add="$inst_prefix_dir$libdir/$linklib" 6110ea133fd7Smrg else 6111ea133fd7Smrg add="$libdir/$linklib" 6112ea133fd7Smrg fi 6113ea133fd7Smrg else 6114ea133fd7Smrg # We cannot seem to hardcode it, guess we'll fake it. 6115ea133fd7Smrg add_dir="-L$libdir" 6116ea133fd7Smrg # Try looking first in the location we're being installed to. 6117ea133fd7Smrg if test -n "$inst_prefix_dir"; then 6118ea133fd7Smrg case $libdir in 6119ea133fd7Smrg [\\/]*) 6120ea133fd7Smrg add_dir="$add_dir -L$inst_prefix_dir$libdir" 6121ea133fd7Smrg ;; 6122ea133fd7Smrg esac 6123ea133fd7Smrg fi 6124ea133fd7Smrg add="-l$name" 6125ea133fd7Smrg fi 6126ea133fd7Smrg 6127ea133fd7Smrg if test "$linkmode" = prog; then 6128ea133fd7Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 6129ea133fd7Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 6130ea133fd7Smrg else 6131ea133fd7Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6132ea133fd7Smrg test -n "$add" && deplibs="$add $deplibs" 6133ea133fd7Smrg fi 6134ea133fd7Smrg fi 6135ea133fd7Smrg elif test "$linkmode" = prog; then 6136ea133fd7Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 6137ea133fd7Smrg # is not unsupported. This is valid on all known static and 6138ea133fd7Smrg # shared platforms. 6139ea133fd7Smrg if test "$hardcode_direct" != unsupported; then 6140ea133fd7Smrg test -n "$old_library" && linklib="$old_library" 6141ea133fd7Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 6142ea133fd7Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 6143ea133fd7Smrg else 6144ea133fd7Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 6145ea133fd7Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 6146ea133fd7Smrg fi 6147ea133fd7Smrg elif test "$build_libtool_libs" = yes; then 6148ea133fd7Smrg # Not a shared library 6149ea133fd7Smrg if test "$deplibs_check_method" != pass_all; then 6150ea133fd7Smrg # We're trying link a shared library against a static one 6151ea133fd7Smrg # but the system doesn't support it. 6152ea133fd7Smrg 6153ea133fd7Smrg # Just print a warning and add the library to dependency_libs so 6154ea133fd7Smrg # that the program can be linked against the static library. 615525b89263Smrg echo 6156ea133fd7Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 615725b89263Smrg echo "*** I have the capability to make that library automatically link in when" 615825b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 615925b89263Smrg echo "*** shared version of the library, which you do not appear to have." 6160ea133fd7Smrg if test "$module" = yes; then 616125b89263Smrg echo "*** But as you try to build a module library, libtool will still create " 616225b89263Smrg echo "*** a static module, that should work as long as the dlopening application" 616325b89263Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 6164ea133fd7Smrg if test -z "$global_symbol_pipe"; then 616525b89263Smrg echo 616625b89263Smrg echo "*** However, this would only work if libtool was able to extract symbol" 616725b89263Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 616825b89263Smrg echo "*** not find such a program. So, this module is probably useless." 616925b89263Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 6170ea133fd7Smrg fi 6171ea133fd7Smrg if test "$build_old_libs" = no; then 6172ea133fd7Smrg build_libtool_libs=module 6173ea133fd7Smrg build_old_libs=yes 6174ea133fd7Smrg else 6175ea133fd7Smrg build_libtool_libs=no 6176ea133fd7Smrg fi 6177ea133fd7Smrg fi 6178ea133fd7Smrg else 6179ea133fd7Smrg deplibs="$dir/$old_library $deplibs" 6180ea133fd7Smrg link_static=yes 6181ea133fd7Smrg fi 6182ea133fd7Smrg fi # link shared/static library? 6183ea133fd7Smrg 6184ea133fd7Smrg if test "$linkmode" = lib; then 6185ea133fd7Smrg if test -n "$dependency_libs" && 6186ea133fd7Smrg { test "$hardcode_into_libs" != yes || 6187ea133fd7Smrg test "$build_old_libs" = yes || 6188ea133fd7Smrg test "$link_static" = yes; }; then 6189ea133fd7Smrg # Extract -R from dependency_libs 6190ea133fd7Smrg temp_deplibs= 6191ea133fd7Smrg for libdir in $dependency_libs; do 6192ea133fd7Smrg case $libdir in 6193ea133fd7Smrg -R*) func_stripname '-R' '' "$libdir" 6194ea133fd7Smrg temp_xrpath=$func_stripname_result 6195ea133fd7Smrg case " $xrpath " in 6196ea133fd7Smrg *" $temp_xrpath "*) ;; 6197ea133fd7Smrg *) xrpath="$xrpath $temp_xrpath";; 6198ea133fd7Smrg esac;; 6199ea133fd7Smrg *) temp_deplibs="$temp_deplibs $libdir";; 6200ea133fd7Smrg esac 6201ea133fd7Smrg done 6202ea133fd7Smrg dependency_libs="$temp_deplibs" 6203ea133fd7Smrg fi 6204ea133fd7Smrg 6205ea133fd7Smrg newlib_search_path="$newlib_search_path $absdir" 6206ea133fd7Smrg # Link against this library 6207ea133fd7Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 6208ea133fd7Smrg # ... and its dependency_libs 6209ea133fd7Smrg tmp_libs= 6210ea133fd7Smrg for deplib in $dependency_libs; do 6211ea133fd7Smrg newdependency_libs="$deplib $newdependency_libs" 6212ea133fd7Smrg if $opt_duplicate_deps ; then 6213ea133fd7Smrg case "$tmp_libs " in 6214ea133fd7Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 6215ea133fd7Smrg esac 6216ea133fd7Smrg fi 6217ea133fd7Smrg tmp_libs="$tmp_libs $deplib" 6218ea133fd7Smrg done 6219ea133fd7Smrg 6220ea133fd7Smrg if test "$link_all_deplibs" != no; then 6221ea133fd7Smrg # Add the search paths of all dependency libraries 6222ea133fd7Smrg for deplib in $dependency_libs; do 622325b89263Smrg path= 6224ea133fd7Smrg case $deplib in 6225ea133fd7Smrg -L*) path="$deplib" ;; 6226ea133fd7Smrg *.la) 6227ea133fd7Smrg func_dirname "$deplib" "" "." 6228ea133fd7Smrg dir="$func_dirname_result" 6229ea133fd7Smrg # We need an absolute path. 6230ea133fd7Smrg case $dir in 6231ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 6232ea133fd7Smrg *) 6233ea133fd7Smrg absdir=`cd "$dir" && pwd` 6234ea133fd7Smrg if test -z "$absdir"; then 6235ea133fd7Smrg func_warning "cannot determine absolute directory name of \`$dir'" 6236ea133fd7Smrg absdir="$dir" 6237ea133fd7Smrg fi 6238ea133fd7Smrg ;; 6239ea133fd7Smrg esac 6240ea133fd7Smrg if $GREP "^installed=no" $deplib > /dev/null; then 6241ea133fd7Smrg case $host in 6242ea133fd7Smrg *-*-darwin*) 6243ea133fd7Smrg depdepl= 6244ea133fd7Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 6245ea133fd7Smrg if test -n "$deplibrary_names" ; then 6246ea133fd7Smrg for tmp in $deplibrary_names ; do 6247ea133fd7Smrg depdepl=$tmp 6248ea133fd7Smrg done 6249ea133fd7Smrg if test -f "$absdir/$objdir/$depdepl" ; then 6250ea133fd7Smrg depdepl="$absdir/$objdir/$depdepl" 6251ea133fd7Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 6252ea133fd7Smrg if test -z "$darwin_install_name"; then 6253ea133fd7Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 6254ea133fd7Smrg fi 6255ea133fd7Smrg compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 6256ea133fd7Smrg linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" 6257ea133fd7Smrg path= 6258ea133fd7Smrg fi 6259ea133fd7Smrg fi 6260ea133fd7Smrg ;; 6261ea133fd7Smrg *) 6262ea133fd7Smrg path="-L$absdir/$objdir" 6263ea133fd7Smrg ;; 6264ea133fd7Smrg esac 6265ea133fd7Smrg else 6266ea133fd7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 6267ea133fd7Smrg test -z "$libdir" && \ 6268ea133fd7Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 6269ea133fd7Smrg test "$absdir" != "$libdir" && \ 6270ea133fd7Smrg func_warning "\`$deplib' seems to be moved" 6271ea133fd7Smrg 6272ea133fd7Smrg path="-L$absdir" 6273ea133fd7Smrg fi 6274ea133fd7Smrg ;; 6275ea133fd7Smrg esac 6276ea133fd7Smrg case " $deplibs " in 6277ea133fd7Smrg *" $path "*) ;; 6278ea133fd7Smrg *) deplibs="$path $deplibs" ;; 6279ea133fd7Smrg esac 6280ea133fd7Smrg done 6281ea133fd7Smrg fi # link_all_deplibs != no 6282ea133fd7Smrg fi # linkmode = lib 6283ea133fd7Smrg done # for deplib in $libs 6284ea133fd7Smrg if test "$pass" = link; then 6285ea133fd7Smrg if test "$linkmode" = "prog"; then 6286ea133fd7Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 6287ea133fd7Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 6288ea133fd7Smrg else 628925b89263Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 6290ea133fd7Smrg fi 6291ea133fd7Smrg fi 6292ea133fd7Smrg dependency_libs="$newdependency_libs" 6293ea133fd7Smrg if test "$pass" = dlpreopen; then 6294ea133fd7Smrg # Link the dlpreopened libraries before other libraries 6295ea133fd7Smrg for deplib in $save_deplibs; do 6296ea133fd7Smrg deplibs="$deplib $deplibs" 6297ea133fd7Smrg done 6298ea133fd7Smrg fi 6299ea133fd7Smrg if test "$pass" != dlopen; then 6300ea133fd7Smrg if test "$pass" != conv; then 6301ea133fd7Smrg # Make sure lib_search_path contains only unique directories. 6302ea133fd7Smrg lib_search_path= 6303ea133fd7Smrg for dir in $newlib_search_path; do 6304ea133fd7Smrg case "$lib_search_path " in 6305ea133fd7Smrg *" $dir "*) ;; 6306ea133fd7Smrg *) lib_search_path="$lib_search_path $dir" ;; 6307ea133fd7Smrg esac 6308ea133fd7Smrg done 6309ea133fd7Smrg newlib_search_path= 6310ea133fd7Smrg fi 6311ea133fd7Smrg 6312ea133fd7Smrg if test "$linkmode,$pass" != "prog,link"; then 6313ea133fd7Smrg vars="deplibs" 6314ea133fd7Smrg else 6315ea133fd7Smrg vars="compile_deplibs finalize_deplibs" 6316ea133fd7Smrg fi 6317ea133fd7Smrg for var in $vars dependency_libs; do 6318ea133fd7Smrg # Add libraries to $var in reverse order 6319ea133fd7Smrg eval tmp_libs=\"\$$var\" 6320ea133fd7Smrg new_libs= 6321ea133fd7Smrg for deplib in $tmp_libs; do 6322ea133fd7Smrg # FIXME: Pedantically, this is the right thing to do, so 6323ea133fd7Smrg # that some nasty dependency loop isn't accidentally 6324ea133fd7Smrg # broken: 6325ea133fd7Smrg #new_libs="$deplib $new_libs" 6326ea133fd7Smrg # Pragmatically, this seems to cause very few problems in 6327ea133fd7Smrg # practice: 6328ea133fd7Smrg case $deplib in 6329ea133fd7Smrg -L*) new_libs="$deplib $new_libs" ;; 6330ea133fd7Smrg -R*) ;; 6331ea133fd7Smrg *) 6332ea133fd7Smrg # And here is the reason: when a library appears more 6333ea133fd7Smrg # than once as an explicit dependence of a library, or 6334ea133fd7Smrg # is implicitly linked in more than once by the 6335ea133fd7Smrg # compiler, it is considered special, and multiple 6336ea133fd7Smrg # occurrences thereof are not removed. Compare this 6337ea133fd7Smrg # with having the same library being listed as a 6338ea133fd7Smrg # dependency of multiple other libraries: in this case, 6339ea133fd7Smrg # we know (pedantically, we assume) the library does not 6340ea133fd7Smrg # need to be listed more than once, so we keep only the 6341ea133fd7Smrg # last copy. This is not always right, but it is rare 6342ea133fd7Smrg # enough that we require users that really mean to play 6343ea133fd7Smrg # such unportable linking tricks to link the library 6344ea133fd7Smrg # using -Wl,-lname, so that libtool does not consider it 6345ea133fd7Smrg # for duplicate removal. 6346ea133fd7Smrg case " $specialdeplibs " in 6347ea133fd7Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 6348ea133fd7Smrg *) 6349ea133fd7Smrg case " $new_libs " in 6350ea133fd7Smrg *" $deplib "*) ;; 6351ea133fd7Smrg *) new_libs="$deplib $new_libs" ;; 6352ea133fd7Smrg esac 6353ea133fd7Smrg ;; 6354ea133fd7Smrg esac 6355ea133fd7Smrg ;; 6356ea133fd7Smrg esac 6357ea133fd7Smrg done 6358ea133fd7Smrg tmp_libs= 6359ea133fd7Smrg for deplib in $new_libs; do 6360ea133fd7Smrg case $deplib in 6361ea133fd7Smrg -L*) 6362ea133fd7Smrg case " $tmp_libs " in 6363ea133fd7Smrg *" $deplib "*) ;; 6364ea133fd7Smrg *) tmp_libs="$tmp_libs $deplib" ;; 6365ea133fd7Smrg esac 6366ea133fd7Smrg ;; 6367ea133fd7Smrg *) tmp_libs="$tmp_libs $deplib" ;; 6368ea133fd7Smrg esac 6369ea133fd7Smrg done 6370ea133fd7Smrg eval $var=\"$tmp_libs\" 6371ea133fd7Smrg done # for var 6372ea133fd7Smrg fi 6373ea133fd7Smrg # Last step: remove runtime libs from dependency_libs 6374ea133fd7Smrg # (they stay in deplibs) 6375ea133fd7Smrg tmp_libs= 6376ea133fd7Smrg for i in $dependency_libs ; do 6377ea133fd7Smrg case " $predeps $postdeps $compiler_lib_search_path " in 6378ea133fd7Smrg *" $i "*) 6379ea133fd7Smrg i="" 6380ea133fd7Smrg ;; 6381ea133fd7Smrg esac 6382ea133fd7Smrg if test -n "$i" ; then 6383ea133fd7Smrg tmp_libs="$tmp_libs $i" 6384ea133fd7Smrg fi 6385ea133fd7Smrg done 6386ea133fd7Smrg dependency_libs=$tmp_libs 6387ea133fd7Smrg done # for pass 6388ea133fd7Smrg if test "$linkmode" = prog; then 6389ea133fd7Smrg dlfiles="$newdlfiles" 6390ea133fd7Smrg fi 6391ea133fd7Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 6392ea133fd7Smrg dlprefiles="$newdlprefiles" 6393ea133fd7Smrg fi 6394ea133fd7Smrg 6395ea133fd7Smrg case $linkmode in 6396ea133fd7Smrg oldlib) 6397ea133fd7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 6398ea133fd7Smrg func_warning "\`-dlopen' is ignored for archives" 6399ea133fd7Smrg fi 6400ea133fd7Smrg 6401ea133fd7Smrg case " $deplibs" in 6402ea133fd7Smrg *\ -l* | *\ -L*) 6403ea133fd7Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 6404ea133fd7Smrg esac 6405ea133fd7Smrg 6406ea133fd7Smrg test -n "$rpath" && \ 6407ea133fd7Smrg func_warning "\`-rpath' is ignored for archives" 6408ea133fd7Smrg 6409ea133fd7Smrg test -n "$xrpath" && \ 6410ea133fd7Smrg func_warning "\`-R' is ignored for archives" 6411ea133fd7Smrg 6412ea133fd7Smrg test -n "$vinfo" && \ 6413ea133fd7Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 6414ea133fd7Smrg 6415ea133fd7Smrg test -n "$release" && \ 6416ea133fd7Smrg func_warning "\`-release' is ignored for archives" 6417ea133fd7Smrg 6418ea133fd7Smrg test -n "$export_symbols$export_symbols_regex" && \ 6419ea133fd7Smrg func_warning "\`-export-symbols' is ignored for archives" 6420ea133fd7Smrg 6421ea133fd7Smrg # Now set the variables for building old libraries. 6422ea133fd7Smrg build_libtool_libs=no 6423ea133fd7Smrg oldlibs="$output" 6424ea133fd7Smrg objs="$objs$old_deplibs" 6425ea133fd7Smrg ;; 6426ea133fd7Smrg 6427ea133fd7Smrg lib) 6428ea133fd7Smrg # Make sure we only generate libraries of the form `libNAME.la'. 6429ea133fd7Smrg case $outputname in 6430ea133fd7Smrg lib*) 6431ea133fd7Smrg func_stripname 'lib' '.la' "$outputname" 6432ea133fd7Smrg name=$func_stripname_result 6433ea133fd7Smrg eval shared_ext=\"$shrext_cmds\" 6434ea133fd7Smrg eval libname=\"$libname_spec\" 6435ea133fd7Smrg ;; 6436ea133fd7Smrg *) 6437ea133fd7Smrg test "$module" = no && \ 6438ea133fd7Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 6439ea133fd7Smrg 6440ea133fd7Smrg if test "$need_lib_prefix" != no; then 6441ea133fd7Smrg # Add the "lib" prefix for modules if required 6442ea133fd7Smrg func_stripname '' '.la' "$outputname" 6443ea133fd7Smrg name=$func_stripname_result 6444ea133fd7Smrg eval shared_ext=\"$shrext_cmds\" 6445ea133fd7Smrg eval libname=\"$libname_spec\" 6446ea133fd7Smrg else 6447ea133fd7Smrg func_stripname '' '.la' "$outputname" 6448ea133fd7Smrg libname=$func_stripname_result 6449ea133fd7Smrg fi 6450ea133fd7Smrg ;; 6451ea133fd7Smrg esac 6452ea133fd7Smrg 6453ea133fd7Smrg if test -n "$objs"; then 6454ea133fd7Smrg if test "$deplibs_check_method" != pass_all; then 6455ea133fd7Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 6456ea133fd7Smrg else 645725b89263Smrg echo 6458ea133fd7Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 6459ea133fd7Smrg $ECHO "*** objects $objs is not portable!" 6460ea133fd7Smrg libobjs="$libobjs $objs" 6461ea133fd7Smrg fi 6462ea133fd7Smrg fi 6463ea133fd7Smrg 6464ea133fd7Smrg test "$dlself" != no && \ 6465ea133fd7Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 6466ea133fd7Smrg 6467ea133fd7Smrg set dummy $rpath 6468ea133fd7Smrg shift 6469ea133fd7Smrg test "$#" -gt 1 && \ 6470ea133fd7Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 6471ea133fd7Smrg 6472ea133fd7Smrg install_libdir="$1" 6473ea133fd7Smrg 6474ea133fd7Smrg oldlibs= 6475ea133fd7Smrg if test -z "$rpath"; then 6476ea133fd7Smrg if test "$build_libtool_libs" = yes; then 6477ea133fd7Smrg # Building a libtool convenience library. 6478ea133fd7Smrg # Some compilers have problems with a `.al' extension so 6479ea133fd7Smrg # convenience libraries should have the same extension an 6480ea133fd7Smrg # archive normally would. 6481ea133fd7Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 6482ea133fd7Smrg build_libtool_libs=convenience 6483ea133fd7Smrg build_old_libs=yes 6484ea133fd7Smrg fi 6485ea133fd7Smrg 6486ea133fd7Smrg test -n "$vinfo" && \ 6487ea133fd7Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 6488ea133fd7Smrg 6489ea133fd7Smrg test -n "$release" && \ 6490ea133fd7Smrg func_warning "\`-release' is ignored for convenience libraries" 6491ea133fd7Smrg else 6492ea133fd7Smrg 6493ea133fd7Smrg # Parse the version information argument. 6494ea133fd7Smrg save_ifs="$IFS"; IFS=':' 6495ea133fd7Smrg set dummy $vinfo 0 0 0 6496ea133fd7Smrg shift 6497ea133fd7Smrg IFS="$save_ifs" 6498ea133fd7Smrg 6499ea133fd7Smrg test -n "$7" && \ 6500ea133fd7Smrg func_fatal_help "too many parameters to \`-version-info'" 6501ea133fd7Smrg 6502ea133fd7Smrg # convert absolute version numbers to libtool ages 6503ea133fd7Smrg # this retains compatibility with .la files and attempts 6504ea133fd7Smrg # to make the code below a bit more comprehensible 6505ea133fd7Smrg 6506ea133fd7Smrg case $vinfo_number in 6507ea133fd7Smrg yes) 6508ea133fd7Smrg number_major="$1" 6509ea133fd7Smrg number_minor="$2" 6510ea133fd7Smrg number_revision="$3" 6511ea133fd7Smrg # 6512ea133fd7Smrg # There are really only two kinds -- those that 6513ea133fd7Smrg # use the current revision as the major version 6514ea133fd7Smrg # and those that subtract age and use age as 6515ea133fd7Smrg # a minor version. But, then there is irix 6516ea133fd7Smrg # which has an extra 1 added just for fun 6517ea133fd7Smrg # 6518ea133fd7Smrg case $version_type in 6519ea133fd7Smrg darwin|linux|osf|windows|none) 6520ea133fd7Smrg func_arith $number_major + $number_minor 6521ea133fd7Smrg current=$func_arith_result 6522ea133fd7Smrg age="$number_minor" 6523ea133fd7Smrg revision="$number_revision" 6524ea133fd7Smrg ;; 652525b89263Smrg freebsd-aout|freebsd-elf|qnx|sunos) 6526ea133fd7Smrg current="$number_major" 6527ea133fd7Smrg revision="$number_minor" 6528ea133fd7Smrg age="0" 6529ea133fd7Smrg ;; 6530ea133fd7Smrg irix|nonstopux) 6531ea133fd7Smrg func_arith $number_major + $number_minor 6532ea133fd7Smrg current=$func_arith_result 6533ea133fd7Smrg age="$number_minor" 6534ea133fd7Smrg revision="$number_minor" 6535ea133fd7Smrg lt_irix_increment=no 6536ea133fd7Smrg ;; 6537ea133fd7Smrg esac 6538ea133fd7Smrg ;; 6539ea133fd7Smrg no) 6540ea133fd7Smrg current="$1" 6541ea133fd7Smrg revision="$2" 6542ea133fd7Smrg age="$3" 6543ea133fd7Smrg ;; 6544ea133fd7Smrg esac 6545ea133fd7Smrg 6546ea133fd7Smrg # Check that each of the things are valid numbers. 6547ea133fd7Smrg case $current in 6548ea133fd7Smrg 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]) ;; 6549ea133fd7Smrg *) 6550ea133fd7Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 6551ea133fd7Smrg func_fatal_error "\`$vinfo' is not valid version information" 6552ea133fd7Smrg ;; 6553ea133fd7Smrg esac 6554ea133fd7Smrg 6555ea133fd7Smrg case $revision in 6556ea133fd7Smrg 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]) ;; 6557ea133fd7Smrg *) 6558ea133fd7Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 6559ea133fd7Smrg func_fatal_error "\`$vinfo' is not valid version information" 6560ea133fd7Smrg ;; 6561ea133fd7Smrg esac 6562ea133fd7Smrg 6563ea133fd7Smrg case $age in 6564ea133fd7Smrg 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]) ;; 6565ea133fd7Smrg *) 6566ea133fd7Smrg func_error "AGE \`$age' must be a nonnegative integer" 6567ea133fd7Smrg func_fatal_error "\`$vinfo' is not valid version information" 6568ea133fd7Smrg ;; 6569ea133fd7Smrg esac 6570ea133fd7Smrg 6571ea133fd7Smrg if test "$age" -gt "$current"; then 6572ea133fd7Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 6573ea133fd7Smrg func_fatal_error "\`$vinfo' is not valid version information" 6574ea133fd7Smrg fi 6575ea133fd7Smrg 6576ea133fd7Smrg # Calculate the version variables. 6577ea133fd7Smrg major= 6578ea133fd7Smrg versuffix= 6579ea133fd7Smrg verstring= 6580ea133fd7Smrg case $version_type in 6581ea133fd7Smrg none) ;; 6582ea133fd7Smrg 6583ea133fd7Smrg darwin) 6584ea133fd7Smrg # Like Linux, but with the current version available in 6585ea133fd7Smrg # verstring for coding it into the library header 6586ea133fd7Smrg func_arith $current - $age 6587ea133fd7Smrg major=.$func_arith_result 6588ea133fd7Smrg versuffix="$major.$age.$revision" 6589ea133fd7Smrg # Darwin ld doesn't like 0 for these options... 6590ea133fd7Smrg func_arith $current + 1 6591ea133fd7Smrg minor_current=$func_arith_result 6592ea133fd7Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 6593ea133fd7Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 6594ea133fd7Smrg ;; 6595ea133fd7Smrg 6596ea133fd7Smrg freebsd-aout) 6597ea133fd7Smrg major=".$current" 6598ea133fd7Smrg versuffix=".$current.$revision"; 6599ea133fd7Smrg ;; 6600ea133fd7Smrg 6601ea133fd7Smrg freebsd-elf) 6602ea133fd7Smrg major=".$current" 6603ea133fd7Smrg versuffix=".$current" 6604ea133fd7Smrg ;; 6605ea133fd7Smrg 6606ea133fd7Smrg irix | nonstopux) 6607ea133fd7Smrg if test "X$lt_irix_increment" = "Xno"; then 6608ea133fd7Smrg func_arith $current - $age 6609ea133fd7Smrg else 6610ea133fd7Smrg func_arith $current - $age + 1 6611ea133fd7Smrg fi 6612ea133fd7Smrg major=$func_arith_result 6613ea133fd7Smrg 6614ea133fd7Smrg case $version_type in 6615ea133fd7Smrg nonstopux) verstring_prefix=nonstopux ;; 6616ea133fd7Smrg *) verstring_prefix=sgi ;; 6617ea133fd7Smrg esac 6618ea133fd7Smrg verstring="$verstring_prefix$major.$revision" 6619ea133fd7Smrg 6620ea133fd7Smrg # Add in all the interfaces that we are compatible with. 6621ea133fd7Smrg loop=$revision 6622ea133fd7Smrg while test "$loop" -ne 0; do 6623ea133fd7Smrg func_arith $revision - $loop 6624ea133fd7Smrg iface=$func_arith_result 6625ea133fd7Smrg func_arith $loop - 1 6626ea133fd7Smrg loop=$func_arith_result 6627ea133fd7Smrg verstring="$verstring_prefix$major.$iface:$verstring" 6628ea133fd7Smrg done 6629ea133fd7Smrg 6630ea133fd7Smrg # Before this point, $major must not contain `.'. 6631ea133fd7Smrg major=.$major 6632ea133fd7Smrg versuffix="$major.$revision" 6633ea133fd7Smrg ;; 6634ea133fd7Smrg 6635ea133fd7Smrg linux) 6636ea133fd7Smrg func_arith $current - $age 6637ea133fd7Smrg major=.$func_arith_result 6638ea133fd7Smrg versuffix="$major.$age.$revision" 6639ea133fd7Smrg ;; 6640ea133fd7Smrg 6641ea133fd7Smrg osf) 6642ea133fd7Smrg func_arith $current - $age 6643ea133fd7Smrg major=.$func_arith_result 6644ea133fd7Smrg versuffix=".$current.$age.$revision" 6645ea133fd7Smrg verstring="$current.$age.$revision" 6646ea133fd7Smrg 6647ea133fd7Smrg # Add in all the interfaces that we are compatible with. 6648ea133fd7Smrg loop=$age 6649ea133fd7Smrg while test "$loop" -ne 0; do 6650ea133fd7Smrg func_arith $current - $loop 6651ea133fd7Smrg iface=$func_arith_result 6652ea133fd7Smrg func_arith $loop - 1 6653ea133fd7Smrg loop=$func_arith_result 6654ea133fd7Smrg verstring="$verstring:${iface}.0" 6655ea133fd7Smrg done 6656ea133fd7Smrg 6657ea133fd7Smrg # Make executables depend on our current version. 6658ea133fd7Smrg verstring="$verstring:${current}.0" 6659ea133fd7Smrg ;; 6660ea133fd7Smrg 6661ea133fd7Smrg qnx) 6662ea133fd7Smrg major=".$current" 6663ea133fd7Smrg versuffix=".$current" 6664ea133fd7Smrg ;; 6665ea133fd7Smrg 6666ea133fd7Smrg sunos) 6667ea133fd7Smrg major=".$current" 6668ea133fd7Smrg versuffix=".$current.$revision" 6669ea133fd7Smrg ;; 6670ea133fd7Smrg 6671ea133fd7Smrg windows) 6672ea133fd7Smrg # Use '-' rather than '.', since we only want one 6673ea133fd7Smrg # extension on DOS 8.3 filesystems. 6674ea133fd7Smrg func_arith $current - $age 6675ea133fd7Smrg major=$func_arith_result 6676ea133fd7Smrg versuffix="-$major" 6677ea133fd7Smrg ;; 6678ea133fd7Smrg 6679ea133fd7Smrg *) 6680ea133fd7Smrg func_fatal_configuration "unknown library version type \`$version_type'" 6681ea133fd7Smrg ;; 6682ea133fd7Smrg esac 6683ea133fd7Smrg 6684ea133fd7Smrg # Clear the version info if we defaulted, and they specified a release. 6685ea133fd7Smrg if test -z "$vinfo" && test -n "$release"; then 6686ea133fd7Smrg major= 6687ea133fd7Smrg case $version_type in 6688ea133fd7Smrg darwin) 6689ea133fd7Smrg # we can't check for "0.0" in archive_cmds due to quoting 6690ea133fd7Smrg # problems, so we reset it completely 6691ea133fd7Smrg verstring= 6692ea133fd7Smrg ;; 6693ea133fd7Smrg *) 6694ea133fd7Smrg verstring="0.0" 6695ea133fd7Smrg ;; 6696ea133fd7Smrg esac 6697ea133fd7Smrg if test "$need_version" = no; then 6698ea133fd7Smrg versuffix= 6699ea133fd7Smrg else 6700ea133fd7Smrg versuffix=".0.0" 6701ea133fd7Smrg fi 6702ea133fd7Smrg fi 6703ea133fd7Smrg 6704ea133fd7Smrg # Remove version info from name if versioning should be avoided 6705ea133fd7Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 6706ea133fd7Smrg major= 6707ea133fd7Smrg versuffix= 6708ea133fd7Smrg verstring="" 6709ea133fd7Smrg fi 6710ea133fd7Smrg 6711ea133fd7Smrg # Check to see if the archive will have undefined symbols. 6712ea133fd7Smrg if test "$allow_undefined" = yes; then 6713ea133fd7Smrg if test "$allow_undefined_flag" = unsupported; then 6714ea133fd7Smrg func_warning "undefined symbols not allowed in $host shared libraries" 6715ea133fd7Smrg build_libtool_libs=no 6716ea133fd7Smrg build_old_libs=yes 6717ea133fd7Smrg fi 6718ea133fd7Smrg else 6719ea133fd7Smrg # Don't allow undefined symbols. 6720ea133fd7Smrg allow_undefined_flag="$no_undefined_flag" 6721ea133fd7Smrg fi 6722ea133fd7Smrg 6723ea133fd7Smrg fi 6724ea133fd7Smrg 6725ea133fd7Smrg func_generate_dlsyms "$libname" "$libname" "yes" 6726ea133fd7Smrg libobjs="$libobjs $symfileobj" 6727ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 6728ea133fd7Smrg 6729ea133fd7Smrg if test "$mode" != relink; then 6730ea133fd7Smrg # Remove our outputs, but don't remove object files since they 6731ea133fd7Smrg # may have been created when compiling PIC objects. 6732ea133fd7Smrg removelist= 6733ea133fd7Smrg tempremovelist=`$ECHO "$output_objdir/*"` 6734ea133fd7Smrg for p in $tempremovelist; do 6735ea133fd7Smrg case $p in 6736ea133fd7Smrg *.$objext | *.gcno) 6737ea133fd7Smrg ;; 6738ea133fd7Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 6739ea133fd7Smrg if test "X$precious_files_regex" != "X"; then 6740ea133fd7Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 6741ea133fd7Smrg then 6742ea133fd7Smrg continue 6743ea133fd7Smrg fi 6744ea133fd7Smrg fi 6745ea133fd7Smrg removelist="$removelist $p" 6746ea133fd7Smrg ;; 6747ea133fd7Smrg *) ;; 6748ea133fd7Smrg esac 6749ea133fd7Smrg done 6750ea133fd7Smrg test -n "$removelist" && \ 6751ea133fd7Smrg func_show_eval "${RM}r \$removelist" 6752ea133fd7Smrg fi 6753ea133fd7Smrg 6754ea133fd7Smrg # Now set the variables for building old libraries. 6755ea133fd7Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 6756ea133fd7Smrg oldlibs="$oldlibs $output_objdir/$libname.$libext" 6757ea133fd7Smrg 6758ea133fd7Smrg # Transform .lo files to .o files. 675925b89263Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 6760ea133fd7Smrg fi 6761ea133fd7Smrg 6762ea133fd7Smrg # Eliminate all temporary directories. 6763ea133fd7Smrg #for path in $notinst_path; do 676425b89263Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 676525b89263Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 676625b89263Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 6767ea133fd7Smrg #done 6768ea133fd7Smrg 6769ea133fd7Smrg if test -n "$xrpath"; then 6770ea133fd7Smrg # If the user specified any rpath flags, then add them. 6771ea133fd7Smrg temp_xrpath= 6772ea133fd7Smrg for libdir in $xrpath; do 6773ea133fd7Smrg temp_xrpath="$temp_xrpath -R$libdir" 6774ea133fd7Smrg case "$finalize_rpath " in 6775ea133fd7Smrg *" $libdir "*) ;; 6776ea133fd7Smrg *) finalize_rpath="$finalize_rpath $libdir" ;; 6777ea133fd7Smrg esac 6778ea133fd7Smrg done 6779ea133fd7Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 6780ea133fd7Smrg dependency_libs="$temp_xrpath $dependency_libs" 6781ea133fd7Smrg fi 6782ea133fd7Smrg fi 6783ea133fd7Smrg 6784ea133fd7Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 6785ea133fd7Smrg old_dlfiles="$dlfiles" 6786ea133fd7Smrg dlfiles= 6787ea133fd7Smrg for lib in $old_dlfiles; do 6788ea133fd7Smrg case " $dlprefiles $dlfiles " in 6789ea133fd7Smrg *" $lib "*) ;; 6790ea133fd7Smrg *) dlfiles="$dlfiles $lib" ;; 6791ea133fd7Smrg esac 6792ea133fd7Smrg done 6793ea133fd7Smrg 6794ea133fd7Smrg # Make sure dlprefiles contains only unique files 6795ea133fd7Smrg old_dlprefiles="$dlprefiles" 6796ea133fd7Smrg dlprefiles= 6797ea133fd7Smrg for lib in $old_dlprefiles; do 6798ea133fd7Smrg case "$dlprefiles " in 6799ea133fd7Smrg *" $lib "*) ;; 6800ea133fd7Smrg *) dlprefiles="$dlprefiles $lib" ;; 6801ea133fd7Smrg esac 6802ea133fd7Smrg done 6803ea133fd7Smrg 6804ea133fd7Smrg if test "$build_libtool_libs" = yes; then 6805ea133fd7Smrg if test -n "$rpath"; then 6806ea133fd7Smrg case $host in 680725b89263Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 6808ea133fd7Smrg # these systems don't actually have a c library (as such)! 6809ea133fd7Smrg ;; 6810ea133fd7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 6811ea133fd7Smrg # Rhapsody C library is in the System framework 6812ea133fd7Smrg deplibs="$deplibs System.ltframework" 6813ea133fd7Smrg ;; 6814ea133fd7Smrg *-*-netbsd*) 6815ea133fd7Smrg # Don't link with libc until the a.out ld.so is fixed. 6816ea133fd7Smrg ;; 6817ea133fd7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 6818ea133fd7Smrg # Do not include libc due to us having libc/libc_r. 6819ea133fd7Smrg ;; 6820ea133fd7Smrg *-*-sco3.2v5* | *-*-sco5v6*) 6821ea133fd7Smrg # Causes problems with __ctype 6822ea133fd7Smrg ;; 6823ea133fd7Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 6824ea133fd7Smrg # Compiler inserts libc in the correct place for threads to work 6825ea133fd7Smrg ;; 6826ea133fd7Smrg *) 6827ea133fd7Smrg # Add libc to deplibs on all other systems if necessary. 6828ea133fd7Smrg if test "$build_libtool_need_lc" = "yes"; then 6829ea133fd7Smrg deplibs="$deplibs -lc" 6830ea133fd7Smrg fi 6831ea133fd7Smrg ;; 6832ea133fd7Smrg esac 6833ea133fd7Smrg fi 6834ea133fd7Smrg 6835ea133fd7Smrg # Transform deplibs into only deplibs that can be linked in shared. 6836ea133fd7Smrg name_save=$name 6837ea133fd7Smrg libname_save=$libname 6838ea133fd7Smrg release_save=$release 6839ea133fd7Smrg versuffix_save=$versuffix 6840ea133fd7Smrg major_save=$major 6841ea133fd7Smrg # I'm not sure if I'm treating the release correctly. I think 6842ea133fd7Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 6843ea133fd7Smrg # add it in twice. Is that correct? 6844ea133fd7Smrg release="" 6845ea133fd7Smrg versuffix="" 6846ea133fd7Smrg major="" 6847ea133fd7Smrg newdeplibs= 6848ea133fd7Smrg droppeddeps=no 6849ea133fd7Smrg case $deplibs_check_method in 6850ea133fd7Smrg pass_all) 6851ea133fd7Smrg # Don't check for shared/static. Everything works. 6852ea133fd7Smrg # This might be a little naive. We might want to check 6853ea133fd7Smrg # whether the library exists or not. But this is on 6854ea133fd7Smrg # osf3 & osf4 and I'm not really sure... Just 6855ea133fd7Smrg # implementing what was already the behavior. 6856ea133fd7Smrg newdeplibs=$deplibs 6857ea133fd7Smrg ;; 6858ea133fd7Smrg test_compile) 6859ea133fd7Smrg # This code stresses the "libraries are programs" paradigm to its 6860ea133fd7Smrg # limits. Maybe even breaks it. We compile a program, linking it 6861ea133fd7Smrg # against the deplibs as a proxy for the library. Then we can check 6862ea133fd7Smrg # whether they linked in statically or dynamically with ldd. 6863ea133fd7Smrg $opt_dry_run || $RM conftest.c 6864ea133fd7Smrg cat > conftest.c <<EOF 6865ea133fd7Smrg int main() { return 0; } 6866ea133fd7SmrgEOF 6867ea133fd7Smrg $opt_dry_run || $RM conftest 6868ea133fd7Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 6869ea133fd7Smrg ldd_output=`ldd conftest` 6870ea133fd7Smrg for i in $deplibs; do 6871ea133fd7Smrg case $i in 6872ea133fd7Smrg -l*) 6873ea133fd7Smrg func_stripname -l '' "$i" 6874ea133fd7Smrg name=$func_stripname_result 6875ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6876ea133fd7Smrg case " $predeps $postdeps " in 6877ea133fd7Smrg *" $i "*) 6878ea133fd7Smrg newdeplibs="$newdeplibs $i" 6879ea133fd7Smrg i="" 6880ea133fd7Smrg ;; 6881ea133fd7Smrg esac 6882ea133fd7Smrg fi 6883ea133fd7Smrg if test -n "$i" ; then 6884ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 6885ea133fd7Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 6886ea133fd7Smrg set dummy $deplib_matches; shift 6887ea133fd7Smrg deplib_match=$1 6888ea133fd7Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 6889ea133fd7Smrg newdeplibs="$newdeplibs $i" 6890ea133fd7Smrg else 6891ea133fd7Smrg droppeddeps=yes 689225b89263Smrg echo 6893ea133fd7Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 689425b89263Smrg echo "*** I have the capability to make that library automatically link in when" 689525b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 689625b89263Smrg echo "*** shared version of the library, which I believe you do not have" 689725b89263Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 689825b89263Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 6899ea133fd7Smrg fi 6900ea133fd7Smrg fi 6901ea133fd7Smrg ;; 6902ea133fd7Smrg *) 6903ea133fd7Smrg newdeplibs="$newdeplibs $i" 6904ea133fd7Smrg ;; 6905ea133fd7Smrg esac 6906ea133fd7Smrg done 6907ea133fd7Smrg else 6908ea133fd7Smrg # Error occurred in the first compile. Let's try to salvage 6909ea133fd7Smrg # the situation: Compile a separate program for each library. 6910ea133fd7Smrg for i in $deplibs; do 6911ea133fd7Smrg case $i in 6912ea133fd7Smrg -l*) 6913ea133fd7Smrg func_stripname -l '' "$i" 6914ea133fd7Smrg name=$func_stripname_result 6915ea133fd7Smrg $opt_dry_run || $RM conftest 6916ea133fd7Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 6917ea133fd7Smrg ldd_output=`ldd conftest` 6918ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6919ea133fd7Smrg case " $predeps $postdeps " in 6920ea133fd7Smrg *" $i "*) 6921ea133fd7Smrg newdeplibs="$newdeplibs $i" 6922ea133fd7Smrg i="" 6923ea133fd7Smrg ;; 6924ea133fd7Smrg esac 6925ea133fd7Smrg fi 6926ea133fd7Smrg if test -n "$i" ; then 6927ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 6928ea133fd7Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 6929ea133fd7Smrg set dummy $deplib_matches; shift 6930ea133fd7Smrg deplib_match=$1 6931ea133fd7Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 6932ea133fd7Smrg newdeplibs="$newdeplibs $i" 6933ea133fd7Smrg else 6934ea133fd7Smrg droppeddeps=yes 693525b89263Smrg echo 6936ea133fd7Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 693725b89263Smrg echo "*** I have the capability to make that library automatically link in when" 693825b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 693925b89263Smrg echo "*** shared version of the library, which you do not appear to have" 694025b89263Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 694125b89263Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 6942ea133fd7Smrg fi 6943ea133fd7Smrg fi 6944ea133fd7Smrg else 6945ea133fd7Smrg droppeddeps=yes 694625b89263Smrg echo 6947ea133fd7Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 694825b89263Smrg echo "*** make it link in! You will probably need to install it or some" 694925b89263Smrg echo "*** library that it depends on before this library will be fully" 695025b89263Smrg echo "*** functional. Installing it before continuing would be even better." 6951ea133fd7Smrg fi 6952ea133fd7Smrg ;; 6953ea133fd7Smrg *) 6954ea133fd7Smrg newdeplibs="$newdeplibs $i" 6955ea133fd7Smrg ;; 6956ea133fd7Smrg esac 6957ea133fd7Smrg done 6958ea133fd7Smrg fi 6959ea133fd7Smrg ;; 6960ea133fd7Smrg file_magic*) 6961ea133fd7Smrg set dummy $deplibs_check_method; shift 6962ea133fd7Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 6963ea133fd7Smrg for a_deplib in $deplibs; do 6964ea133fd7Smrg case $a_deplib in 6965ea133fd7Smrg -l*) 6966ea133fd7Smrg func_stripname -l '' "$a_deplib" 6967ea133fd7Smrg name=$func_stripname_result 6968ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6969ea133fd7Smrg case " $predeps $postdeps " in 6970ea133fd7Smrg *" $a_deplib "*) 6971ea133fd7Smrg newdeplibs="$newdeplibs $a_deplib" 6972ea133fd7Smrg a_deplib="" 6973ea133fd7Smrg ;; 6974ea133fd7Smrg esac 6975ea133fd7Smrg fi 6976ea133fd7Smrg if test -n "$a_deplib" ; then 6977ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 6978ea133fd7Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 6979ea133fd7Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 6980ea133fd7Smrg for potent_lib in $potential_libs; do 6981ea133fd7Smrg # Follow soft links. 6982ea133fd7Smrg if ls -lLd "$potent_lib" 2>/dev/null | 6983ea133fd7Smrg $GREP " -> " >/dev/null; then 6984ea133fd7Smrg continue 6985ea133fd7Smrg fi 6986ea133fd7Smrg # The statement above tries to avoid entering an 6987ea133fd7Smrg # endless loop below, in case of cyclic links. 6988ea133fd7Smrg # We might still enter an endless loop, since a link 6989ea133fd7Smrg # loop can be closed while we follow links, 6990ea133fd7Smrg # but so what? 6991ea133fd7Smrg potlib="$potent_lib" 6992ea133fd7Smrg while test -h "$potlib" 2>/dev/null; do 6993ea133fd7Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 6994ea133fd7Smrg case $potliblink in 6995ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 699625b89263Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 6997ea133fd7Smrg esac 6998ea133fd7Smrg done 6999ea133fd7Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 7000ea133fd7Smrg $SED -e 10q | 7001ea133fd7Smrg $EGREP "$file_magic_regex" > /dev/null; then 7002ea133fd7Smrg newdeplibs="$newdeplibs $a_deplib" 7003ea133fd7Smrg a_deplib="" 7004ea133fd7Smrg break 2 7005ea133fd7Smrg fi 7006ea133fd7Smrg done 7007ea133fd7Smrg done 7008ea133fd7Smrg fi 7009ea133fd7Smrg if test -n "$a_deplib" ; then 7010ea133fd7Smrg droppeddeps=yes 701125b89263Smrg echo 7012ea133fd7Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 701325b89263Smrg echo "*** I have the capability to make that library automatically link in when" 701425b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 701525b89263Smrg echo "*** shared version of the library, which you do not appear to have" 701625b89263Smrg echo "*** because I did check the linker path looking for a file starting" 7017ea133fd7Smrg if test -z "$potlib" ; then 7018ea133fd7Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 7019ea133fd7Smrg else 7020ea133fd7Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7021ea133fd7Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 7022ea133fd7Smrg fi 7023ea133fd7Smrg fi 7024ea133fd7Smrg ;; 7025ea133fd7Smrg *) 7026ea133fd7Smrg # Add a -L argument. 7027ea133fd7Smrg newdeplibs="$newdeplibs $a_deplib" 7028ea133fd7Smrg ;; 7029ea133fd7Smrg esac 7030ea133fd7Smrg done # Gone through all deplibs. 7031ea133fd7Smrg ;; 7032ea133fd7Smrg match_pattern*) 7033ea133fd7Smrg set dummy $deplibs_check_method; shift 7034ea133fd7Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7035ea133fd7Smrg for a_deplib in $deplibs; do 7036ea133fd7Smrg case $a_deplib in 7037ea133fd7Smrg -l*) 7038ea133fd7Smrg func_stripname -l '' "$a_deplib" 7039ea133fd7Smrg name=$func_stripname_result 7040ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7041ea133fd7Smrg case " $predeps $postdeps " in 7042ea133fd7Smrg *" $a_deplib "*) 7043ea133fd7Smrg newdeplibs="$newdeplibs $a_deplib" 7044ea133fd7Smrg a_deplib="" 7045ea133fd7Smrg ;; 7046ea133fd7Smrg esac 7047ea133fd7Smrg fi 7048ea133fd7Smrg if test -n "$a_deplib" ; then 7049ea133fd7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7050ea133fd7Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7051ea133fd7Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 7052ea133fd7Smrg for potent_lib in $potential_libs; do 7053ea133fd7Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 705425b89263Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 7055ea133fd7Smrg $EGREP "$match_pattern_regex" > /dev/null; then 7056ea133fd7Smrg newdeplibs="$newdeplibs $a_deplib" 7057ea133fd7Smrg a_deplib="" 7058ea133fd7Smrg break 2 7059ea133fd7Smrg fi 7060ea133fd7Smrg done 7061ea133fd7Smrg done 7062ea133fd7Smrg fi 7063ea133fd7Smrg if test -n "$a_deplib" ; then 7064ea133fd7Smrg droppeddeps=yes 706525b89263Smrg echo 7066ea133fd7Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 706725b89263Smrg echo "*** I have the capability to make that library automatically link in when" 706825b89263Smrg echo "*** you link to this library. But I can only do this if you have a" 706925b89263Smrg echo "*** shared version of the library, which you do not appear to have" 707025b89263Smrg echo "*** because I did check the linker path looking for a file starting" 7071ea133fd7Smrg if test -z "$potlib" ; then 7072ea133fd7Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 7073ea133fd7Smrg else 7074ea133fd7Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7075ea133fd7Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 7076ea133fd7Smrg fi 7077ea133fd7Smrg fi 7078ea133fd7Smrg ;; 7079ea133fd7Smrg *) 7080ea133fd7Smrg # Add a -L argument. 7081ea133fd7Smrg newdeplibs="$newdeplibs $a_deplib" 7082ea133fd7Smrg ;; 7083ea133fd7Smrg esac 7084ea133fd7Smrg done # Gone through all deplibs. 7085ea133fd7Smrg ;; 7086ea133fd7Smrg none | unknown | *) 7087ea133fd7Smrg newdeplibs="" 708825b89263Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7089ea133fd7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7090ea133fd7Smrg for i in $predeps $postdeps ; do 7091ea133fd7Smrg # can't use Xsed below, because $i might contain '/' 709225b89263Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 7093ea133fd7Smrg done 7094ea133fd7Smrg fi 709525b89263Smrg case $tmp_deplibs in 709625b89263Smrg *[!\ \ ]*) 709725b89263Smrg echo 7098ea133fd7Smrg if test "X$deplibs_check_method" = "Xnone"; then 709925b89263Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 7100ea133fd7Smrg else 710125b89263Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 7102ea133fd7Smrg fi 710325b89263Smrg echo "*** All declared inter-library dependencies are being dropped." 7104ea133fd7Smrg droppeddeps=yes 710525b89263Smrg ;; 710625b89263Smrg esac 7107ea133fd7Smrg ;; 7108ea133fd7Smrg esac 7109ea133fd7Smrg versuffix=$versuffix_save 7110ea133fd7Smrg major=$major_save 7111ea133fd7Smrg release=$release_save 7112ea133fd7Smrg libname=$libname_save 7113ea133fd7Smrg name=$name_save 7114ea133fd7Smrg 7115ea133fd7Smrg case $host in 7116ea133fd7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7117ea133fd7Smrg # On Rhapsody replace the C library with the System framework 711825b89263Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 7119ea133fd7Smrg ;; 7120ea133fd7Smrg esac 7121ea133fd7Smrg 7122ea133fd7Smrg if test "$droppeddeps" = yes; then 7123ea133fd7Smrg if test "$module" = yes; then 712425b89263Smrg echo 712525b89263Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 7126ea133fd7Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 712725b89263Smrg echo "*** a static module, that should work as long as the dlopening" 712825b89263Smrg echo "*** application is linked with the -dlopen flag." 7129ea133fd7Smrg if test -z "$global_symbol_pipe"; then 713025b89263Smrg echo 713125b89263Smrg echo "*** However, this would only work if libtool was able to extract symbol" 713225b89263Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 713325b89263Smrg echo "*** not find such a program. So, this module is probably useless." 713425b89263Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 7135ea133fd7Smrg fi 7136ea133fd7Smrg if test "$build_old_libs" = no; then 7137ea133fd7Smrg oldlibs="$output_objdir/$libname.$libext" 7138ea133fd7Smrg build_libtool_libs=module 7139ea133fd7Smrg build_old_libs=yes 7140ea133fd7Smrg else 7141ea133fd7Smrg build_libtool_libs=no 7142ea133fd7Smrg fi 7143ea133fd7Smrg else 714425b89263Smrg echo "*** The inter-library dependencies that have been dropped here will be" 714525b89263Smrg echo "*** automatically added whenever a program is linked with this library" 714625b89263Smrg echo "*** or is declared to -dlopen it." 7147ea133fd7Smrg 7148ea133fd7Smrg if test "$allow_undefined" = no; then 714925b89263Smrg echo 715025b89263Smrg echo "*** Since this library must not contain undefined symbols," 715125b89263Smrg echo "*** because either the platform does not support them or" 715225b89263Smrg echo "*** it was explicitly requested with -no-undefined," 715325b89263Smrg echo "*** libtool will only create a static version of it." 7154ea133fd7Smrg if test "$build_old_libs" = no; then 7155ea133fd7Smrg oldlibs="$output_objdir/$libname.$libext" 7156ea133fd7Smrg build_libtool_libs=module 7157ea133fd7Smrg build_old_libs=yes 7158ea133fd7Smrg else 7159ea133fd7Smrg build_libtool_libs=no 7160ea133fd7Smrg fi 7161ea133fd7Smrg fi 7162ea133fd7Smrg fi 7163ea133fd7Smrg fi 7164ea133fd7Smrg # Done checking deplibs! 7165ea133fd7Smrg deplibs=$newdeplibs 7166ea133fd7Smrg fi 7167ea133fd7Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 7168ea133fd7Smrg case $host in 7169ea133fd7Smrg *-*-darwin*) 717025b89263Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 717125b89263Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 717225b89263Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7173ea133fd7Smrg ;; 7174ea133fd7Smrg esac 7175ea133fd7Smrg 7176ea133fd7Smrg # move library search paths that coincide with paths to not yet 7177ea133fd7Smrg # installed libraries to the beginning of the library search list 7178ea133fd7Smrg new_libs= 7179ea133fd7Smrg for path in $notinst_path; do 7180ea133fd7Smrg case " $new_libs " in 7181ea133fd7Smrg *" -L$path/$objdir "*) ;; 7182ea133fd7Smrg *) 7183ea133fd7Smrg case " $deplibs " in 7184ea133fd7Smrg *" -L$path/$objdir "*) 7185ea133fd7Smrg new_libs="$new_libs -L$path/$objdir" ;; 7186ea133fd7Smrg esac 7187ea133fd7Smrg ;; 7188ea133fd7Smrg esac 7189ea133fd7Smrg done 7190ea133fd7Smrg for deplib in $deplibs; do 7191ea133fd7Smrg case $deplib in 7192ea133fd7Smrg -L*) 7193ea133fd7Smrg case " $new_libs " in 7194ea133fd7Smrg *" $deplib "*) ;; 7195ea133fd7Smrg *) new_libs="$new_libs $deplib" ;; 7196ea133fd7Smrg esac 7197ea133fd7Smrg ;; 7198ea133fd7Smrg *) new_libs="$new_libs $deplib" ;; 7199ea133fd7Smrg esac 7200ea133fd7Smrg done 7201ea133fd7Smrg deplibs="$new_libs" 7202ea133fd7Smrg 7203ea133fd7Smrg # All the library-specific variables (install_libdir is set above). 7204ea133fd7Smrg library_names= 7205ea133fd7Smrg old_library= 7206ea133fd7Smrg dlname= 7207ea133fd7Smrg 7208ea133fd7Smrg # Test again, we may have decided not to build it any more 7209ea133fd7Smrg if test "$build_libtool_libs" = yes; then 7210ea133fd7Smrg if test "$hardcode_into_libs" = yes; then 7211ea133fd7Smrg # Hardcode the library paths 7212ea133fd7Smrg hardcode_libdirs= 7213ea133fd7Smrg dep_rpath= 7214ea133fd7Smrg rpath="$finalize_rpath" 7215ea133fd7Smrg test "$mode" != relink && rpath="$compile_rpath$rpath" 7216ea133fd7Smrg for libdir in $rpath; do 7217ea133fd7Smrg if test -n "$hardcode_libdir_flag_spec"; then 7218ea133fd7Smrg if test -n "$hardcode_libdir_separator"; then 7219ea133fd7Smrg if test -z "$hardcode_libdirs"; then 7220ea133fd7Smrg hardcode_libdirs="$libdir" 7221ea133fd7Smrg else 7222ea133fd7Smrg # Just accumulate the unique libdirs. 7223ea133fd7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 7224ea133fd7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 7225ea133fd7Smrg ;; 7226ea133fd7Smrg *) 7227ea133fd7Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 7228ea133fd7Smrg ;; 7229ea133fd7Smrg esac 7230ea133fd7Smrg fi 7231ea133fd7Smrg else 7232ea133fd7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 7233ea133fd7Smrg dep_rpath="$dep_rpath $flag" 7234ea133fd7Smrg fi 7235ea133fd7Smrg elif test -n "$runpath_var"; then 7236ea133fd7Smrg case "$perm_rpath " in 7237ea133fd7Smrg *" $libdir "*) ;; 7238ea133fd7Smrg *) perm_rpath="$perm_rpath $libdir" ;; 7239ea133fd7Smrg esac 7240ea133fd7Smrg fi 7241ea133fd7Smrg done 7242ea133fd7Smrg # Substitute the hardcoded libdirs into the rpath. 7243ea133fd7Smrg if test -n "$hardcode_libdir_separator" && 7244ea133fd7Smrg test -n "$hardcode_libdirs"; then 7245ea133fd7Smrg libdir="$hardcode_libdirs" 7246ea133fd7Smrg if test -n "$hardcode_libdir_flag_spec_ld"; then 7247ea133fd7Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 7248ea133fd7Smrg else 7249ea133fd7Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec\" 7250ea133fd7Smrg fi 7251ea133fd7Smrg fi 7252ea133fd7Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 7253ea133fd7Smrg # We should set the runpath_var. 7254ea133fd7Smrg rpath= 7255ea133fd7Smrg for dir in $perm_rpath; do 7256ea133fd7Smrg rpath="$rpath$dir:" 7257ea133fd7Smrg done 7258ea133fd7Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 7259ea133fd7Smrg fi 7260ea133fd7Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 7261ea133fd7Smrg fi 7262a253d6aeSmrg 7263ea133fd7Smrg shlibpath="$finalize_shlibpath" 7264ea133fd7Smrg test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 7265ea133fd7Smrg if test -n "$shlibpath"; then 7266ea133fd7Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 7267ea133fd7Smrg fi 7268a253d6aeSmrg 7269ea133fd7Smrg # Get the real and link names of the library. 7270ea133fd7Smrg eval shared_ext=\"$shrext_cmds\" 7271ea133fd7Smrg eval library_names=\"$library_names_spec\" 7272ea133fd7Smrg set dummy $library_names 7273ea133fd7Smrg shift 7274ea133fd7Smrg realname="$1" 7275ea133fd7Smrg shift 7276a253d6aeSmrg 7277ea133fd7Smrg if test -n "$soname_spec"; then 7278ea133fd7Smrg eval soname=\"$soname_spec\" 7279ea133fd7Smrg else 7280ea133fd7Smrg soname="$realname" 7281ea133fd7Smrg fi 7282ea133fd7Smrg if test -z "$dlname"; then 7283ea133fd7Smrg dlname=$soname 7284ea133fd7Smrg fi 7285a253d6aeSmrg 7286ea133fd7Smrg lib="$output_objdir/$realname" 7287ea133fd7Smrg linknames= 7288ea133fd7Smrg for link 7289ea133fd7Smrg do 7290ea133fd7Smrg linknames="$linknames $link" 7291ea133fd7Smrg done 7292a253d6aeSmrg 7293ea133fd7Smrg # Use standard objects if they are pic 729425b89263Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 7295ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 7296a253d6aeSmrg 7297ea133fd7Smrg delfiles= 7298ea133fd7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 7299ea133fd7Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 7300ea133fd7Smrg export_symbols="$output_objdir/$libname.uexp" 7301ea133fd7Smrg delfiles="$delfiles $export_symbols" 7302ea133fd7Smrg fi 7303a253d6aeSmrg 7304ea133fd7Smrg orig_export_symbols= 7305ea133fd7Smrg case $host_os in 7306ea133fd7Smrg cygwin* | mingw* | cegcc*) 7307ea133fd7Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 7308ea133fd7Smrg # exporting using user supplied symfile 7309ea133fd7Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 7310ea133fd7Smrg # and it's NOT already a .def file. Must figure out 7311ea133fd7Smrg # which of the given symbols are data symbols and tag 7312ea133fd7Smrg # them as such. So, trigger use of export_symbols_cmds. 7313ea133fd7Smrg # export_symbols gets reassigned inside the "prepare 7314ea133fd7Smrg # the list of exported symbols" if statement, so the 7315ea133fd7Smrg # include_expsyms logic still works. 7316ea133fd7Smrg orig_export_symbols="$export_symbols" 7317ea133fd7Smrg export_symbols= 7318ea133fd7Smrg always_export_symbols=yes 7319ea133fd7Smrg fi 7320ea133fd7Smrg fi 7321ea133fd7Smrg ;; 7322ea133fd7Smrg esac 7323a253d6aeSmrg 7324ea133fd7Smrg # Prepare the list of exported symbols 7325ea133fd7Smrg if test -z "$export_symbols"; then 7326ea133fd7Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 7327ea133fd7Smrg func_verbose "generating symbol list for \`$libname.la'" 7328ea133fd7Smrg export_symbols="$output_objdir/$libname.exp" 7329ea133fd7Smrg $opt_dry_run || $RM $export_symbols 7330ea133fd7Smrg cmds=$export_symbols_cmds 7331ea133fd7Smrg save_ifs="$IFS"; IFS='~' 7332ea133fd7Smrg for cmd in $cmds; do 7333ea133fd7Smrg IFS="$save_ifs" 7334ea133fd7Smrg eval cmd=\"$cmd\" 7335ea133fd7Smrg func_len " $cmd" 7336ea133fd7Smrg len=$func_len_result 7337ea133fd7Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 7338ea133fd7Smrg func_show_eval "$cmd" 'exit $?' 7339ea133fd7Smrg skipped_export=false 7340ea133fd7Smrg else 7341ea133fd7Smrg # The command line is too long to execute in one step. 7342ea133fd7Smrg func_verbose "using reloadable object file for export list..." 7343ea133fd7Smrg skipped_export=: 7344ea133fd7Smrg # Break out early, otherwise skipped_export may be 7345ea133fd7Smrg # set to false by a later but shorter cmd. 7346ea133fd7Smrg break 7347ea133fd7Smrg fi 7348ea133fd7Smrg done 7349ea133fd7Smrg IFS="$save_ifs" 7350ea133fd7Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 7351ea133fd7Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 7352ea133fd7Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 7353ea133fd7Smrg fi 7354ea133fd7Smrg fi 7355ea133fd7Smrg fi 7356a253d6aeSmrg 7357ea133fd7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 7358ea133fd7Smrg tmp_export_symbols="$export_symbols" 7359ea133fd7Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 736025b89263Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 7361ea133fd7Smrg fi 7362a253d6aeSmrg 7363ea133fd7Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 7364ea133fd7Smrg # The given exports_symbols file has to be filtered, so filter it. 7365ea133fd7Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 7366ea133fd7Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 7367ea133fd7Smrg # 's' commands which not all seds can handle. GNU sed should be fine 7368ea133fd7Smrg # though. Also, the filter scales superlinearly with the number of 7369ea133fd7Smrg # global variables. join(1) would be nice here, but unfortunately 7370ea133fd7Smrg # isn't a blessed tool. 7371ea133fd7Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 7372ea133fd7Smrg delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" 7373ea133fd7Smrg export_symbols=$output_objdir/$libname.def 7374ea133fd7Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 7375a253d6aeSmrg fi 7376a253d6aeSmrg 7377ea133fd7Smrg tmp_deplibs= 7378ea133fd7Smrg for test_deplib in $deplibs; do 7379ea133fd7Smrg case " $convenience " in 7380ea133fd7Smrg *" $test_deplib "*) ;; 7381ea133fd7Smrg *) 7382ea133fd7Smrg tmp_deplibs="$tmp_deplibs $test_deplib" 7383ea133fd7Smrg ;; 7384ea133fd7Smrg esac 7385ea133fd7Smrg done 7386ea133fd7Smrg deplibs="$tmp_deplibs" 7387a253d6aeSmrg 7388ea133fd7Smrg if test -n "$convenience"; then 7389ea133fd7Smrg if test -n "$whole_archive_flag_spec" && 7390ea133fd7Smrg test "$compiler_needs_object" = yes && 7391ea133fd7Smrg test -z "$libobjs"; then 7392ea133fd7Smrg # extract the archives, so we have objects to list. 7393ea133fd7Smrg # TODO: could optimize this to just extract one archive. 7394ea133fd7Smrg whole_archive_flag_spec= 7395ea133fd7Smrg fi 7396ea133fd7Smrg if test -n "$whole_archive_flag_spec"; then 7397ea133fd7Smrg save_libobjs=$libobjs 7398ea133fd7Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 7399ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 7400ea133fd7Smrg else 7401ea133fd7Smrg gentop="$output_objdir/${outputname}x" 7402ea133fd7Smrg generated="$generated $gentop" 7403a253d6aeSmrg 7404ea133fd7Smrg func_extract_archives $gentop $convenience 7405ea133fd7Smrg libobjs="$libobjs $func_extract_archives_result" 7406ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 7407ea133fd7Smrg fi 7408ea133fd7Smrg fi 7409a253d6aeSmrg 7410ea133fd7Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 7411ea133fd7Smrg eval flag=\"$thread_safe_flag_spec\" 7412ea133fd7Smrg linker_flags="$linker_flags $flag" 7413ea133fd7Smrg fi 7414a253d6aeSmrg 7415ea133fd7Smrg # Make a backup of the uninstalled library when relinking 7416ea133fd7Smrg if test "$mode" = relink; then 7417ea133fd7Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 7418a253d6aeSmrg fi 7419a253d6aeSmrg 7420ea133fd7Smrg # Do each of the archive commands. 7421ea133fd7Smrg if test "$module" = yes && test -n "$module_cmds" ; then 7422ea133fd7Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 7423ea133fd7Smrg eval test_cmds=\"$module_expsym_cmds\" 7424ea133fd7Smrg cmds=$module_expsym_cmds 7425ea133fd7Smrg else 7426ea133fd7Smrg eval test_cmds=\"$module_cmds\" 7427ea133fd7Smrg cmds=$module_cmds 7428ea133fd7Smrg fi 7429ea133fd7Smrg else 7430ea133fd7Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 7431ea133fd7Smrg eval test_cmds=\"$archive_expsym_cmds\" 7432ea133fd7Smrg cmds=$archive_expsym_cmds 7433ea133fd7Smrg else 7434ea133fd7Smrg eval test_cmds=\"$archive_cmds\" 7435ea133fd7Smrg cmds=$archive_cmds 7436ea133fd7Smrg fi 7437a253d6aeSmrg fi 7438a253d6aeSmrg 7439ea133fd7Smrg if test "X$skipped_export" != "X:" && 7440ea133fd7Smrg func_len " $test_cmds" && 7441ea133fd7Smrg len=$func_len_result && 7442ea133fd7Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 7443ea133fd7Smrg : 7444ea133fd7Smrg else 7445ea133fd7Smrg # The command line is too long to link in one step, link piecewise 7446ea133fd7Smrg # or, if using GNU ld and skipped_export is not :, use a linker 7447ea133fd7Smrg # script. 7448a253d6aeSmrg 7449ea133fd7Smrg # Save the value of $output and $libobjs because we want to 7450ea133fd7Smrg # use them later. If we have whole_archive_flag_spec, we 7451ea133fd7Smrg # want to use save_libobjs as it was before 7452ea133fd7Smrg # whole_archive_flag_spec was expanded, because we can't 7453ea133fd7Smrg # assume the linker understands whole_archive_flag_spec. 7454ea133fd7Smrg # This may have to be revisited, in case too many 7455ea133fd7Smrg # convenience libraries get linked in and end up exceeding 7456ea133fd7Smrg # the spec. 7457ea133fd7Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 7458ea133fd7Smrg save_libobjs=$libobjs 7459ea133fd7Smrg fi 7460ea133fd7Smrg save_output=$output 746125b89263Smrg func_basename "$output" 746225b89263Smrg output_la=$func_basename_result 7463a253d6aeSmrg 7464ea133fd7Smrg # Clear the reloadable object creation command queue and 7465ea133fd7Smrg # initialize k to one. 7466ea133fd7Smrg test_cmds= 7467ea133fd7Smrg concat_cmds= 7468ea133fd7Smrg objlist= 7469ea133fd7Smrg last_robj= 7470ea133fd7Smrg k=1 7471a253d6aeSmrg 7472ea133fd7Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 7473ea133fd7Smrg output=${output_objdir}/${output_la}.lnkscript 7474ea133fd7Smrg func_verbose "creating GNU ld script: $output" 747525b89263Smrg echo 'INPUT (' > $output 7476ea133fd7Smrg for obj in $save_libobjs 7477ea133fd7Smrg do 7478ea133fd7Smrg $ECHO "$obj" >> $output 7479ea133fd7Smrg done 748025b89263Smrg echo ')' >> $output 7481ea133fd7Smrg delfiles="$delfiles $output" 7482ea133fd7Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 7483ea133fd7Smrg output=${output_objdir}/${output_la}.lnk 7484ea133fd7Smrg func_verbose "creating linker input file list: $output" 7485ea133fd7Smrg : > $output 7486ea133fd7Smrg set x $save_libobjs 7487ea133fd7Smrg shift 7488ea133fd7Smrg firstobj= 7489ea133fd7Smrg if test "$compiler_needs_object" = yes; then 7490ea133fd7Smrg firstobj="$1 " 7491ea133fd7Smrg shift 7492ea133fd7Smrg fi 7493ea133fd7Smrg for obj 7494ea133fd7Smrg do 7495ea133fd7Smrg $ECHO "$obj" >> $output 7496ea133fd7Smrg done 7497ea133fd7Smrg delfiles="$delfiles $output" 7498ea133fd7Smrg output=$firstobj\"$file_list_spec$output\" 7499ea133fd7Smrg else 7500ea133fd7Smrg if test -n "$save_libobjs"; then 7501ea133fd7Smrg func_verbose "creating reloadable object files..." 7502ea133fd7Smrg output=$output_objdir/$output_la-${k}.$objext 7503ea133fd7Smrg eval test_cmds=\"$reload_cmds\" 7504ea133fd7Smrg func_len " $test_cmds" 7505ea133fd7Smrg len0=$func_len_result 7506ea133fd7Smrg len=$len0 7507ea133fd7Smrg 7508ea133fd7Smrg # Loop over the list of objects to be linked. 7509ea133fd7Smrg for obj in $save_libobjs 7510ea133fd7Smrg do 7511ea133fd7Smrg func_len " $obj" 7512ea133fd7Smrg func_arith $len + $func_len_result 7513ea133fd7Smrg len=$func_arith_result 7514ea133fd7Smrg if test "X$objlist" = X || 7515ea133fd7Smrg test "$len" -lt "$max_cmd_len"; then 7516ea133fd7Smrg func_append objlist " $obj" 7517ea133fd7Smrg else 7518ea133fd7Smrg # The command $test_cmds is almost too long, add a 7519ea133fd7Smrg # command to the queue. 7520ea133fd7Smrg if test "$k" -eq 1 ; then 7521ea133fd7Smrg # The first file doesn't have a previous command to add. 752225b89263Smrg reload_objs=$objlist 752325b89263Smrg eval concat_cmds=\"$reload_cmds\" 7524ea133fd7Smrg else 7525ea133fd7Smrg # All subsequent reloadable object files will link in 7526ea133fd7Smrg # the last one created. 752725b89263Smrg reload_objs="$objlist $last_robj" 752825b89263Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 7529ea133fd7Smrg fi 7530ea133fd7Smrg last_robj=$output_objdir/$output_la-${k}.$objext 7531ea133fd7Smrg func_arith $k + 1 7532ea133fd7Smrg k=$func_arith_result 7533ea133fd7Smrg output=$output_objdir/$output_la-${k}.$objext 753425b89263Smrg objlist=" $obj" 7535ea133fd7Smrg func_len " $last_robj" 7536ea133fd7Smrg func_arith $len0 + $func_len_result 7537ea133fd7Smrg len=$func_arith_result 7538ea133fd7Smrg fi 7539ea133fd7Smrg done 7540ea133fd7Smrg # Handle the remaining objects by creating one last 7541ea133fd7Smrg # reloadable object file. All subsequent reloadable object 7542ea133fd7Smrg # files will link in the last one created. 7543ea133fd7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 754425b89263Smrg reload_objs="$objlist $last_robj" 754525b89263Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 7546ea133fd7Smrg if test -n "$last_robj"; then 7547ea133fd7Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 7548ea133fd7Smrg fi 7549ea133fd7Smrg delfiles="$delfiles $output" 7550a253d6aeSmrg 7551ea133fd7Smrg else 7552ea133fd7Smrg output= 7553ea133fd7Smrg fi 7554a253d6aeSmrg 7555ea133fd7Smrg if ${skipped_export-false}; then 7556ea133fd7Smrg func_verbose "generating symbol list for \`$libname.la'" 7557ea133fd7Smrg export_symbols="$output_objdir/$libname.exp" 7558ea133fd7Smrg $opt_dry_run || $RM $export_symbols 7559ea133fd7Smrg libobjs=$output 7560ea133fd7Smrg # Append the command to create the export file. 7561ea133fd7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 7562ea133fd7Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 7563ea133fd7Smrg if test -n "$last_robj"; then 7564ea133fd7Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 7565ea133fd7Smrg fi 7566ea133fd7Smrg fi 7567a253d6aeSmrg 7568ea133fd7Smrg test -n "$save_libobjs" && 7569ea133fd7Smrg func_verbose "creating a temporary reloadable object file: $output" 7570a253d6aeSmrg 7571ea133fd7Smrg # Loop through the commands generated above and execute them. 7572ea133fd7Smrg save_ifs="$IFS"; IFS='~' 7573ea133fd7Smrg for cmd in $concat_cmds; do 7574ea133fd7Smrg IFS="$save_ifs" 7575ea133fd7Smrg $opt_silent || { 7576ea133fd7Smrg func_quote_for_expand "$cmd" 7577ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 7578ea133fd7Smrg } 7579ea133fd7Smrg $opt_dry_run || eval "$cmd" || { 7580ea133fd7Smrg lt_exit=$? 7581ea133fd7Smrg 7582ea133fd7Smrg # Restore the uninstalled library and exit 7583ea133fd7Smrg if test "$mode" = relink; then 7584ea133fd7Smrg ( cd "$output_objdir" && \ 7585ea133fd7Smrg $RM "${realname}T" && \ 7586ea133fd7Smrg $MV "${realname}U" "$realname" ) 7587ea133fd7Smrg fi 7588a253d6aeSmrg 7589ea133fd7Smrg exit $lt_exit 7590ea133fd7Smrg } 7591ea133fd7Smrg done 7592ea133fd7Smrg IFS="$save_ifs" 7593ea133fd7Smrg 7594ea133fd7Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 7595ea133fd7Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 7596ea133fd7Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 7597a253d6aeSmrg fi 7598a253d6aeSmrg fi 7599a253d6aeSmrg 7600ea133fd7Smrg if ${skipped_export-false}; then 7601ea133fd7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 7602ea133fd7Smrg tmp_export_symbols="$export_symbols" 7603ea133fd7Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 760425b89263Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 7605ea133fd7Smrg fi 7606a253d6aeSmrg 7607ea133fd7Smrg if test -n "$orig_export_symbols"; then 7608ea133fd7Smrg # The given exports_symbols file has to be filtered, so filter it. 7609ea133fd7Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 7610ea133fd7Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 7611ea133fd7Smrg # 's' commands which not all seds can handle. GNU sed should be fine 7612ea133fd7Smrg # though. Also, the filter scales superlinearly with the number of 7613ea133fd7Smrg # global variables. join(1) would be nice here, but unfortunately 7614ea133fd7Smrg # isn't a blessed tool. 7615ea133fd7Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 7616ea133fd7Smrg delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" 7617ea133fd7Smrg export_symbols=$output_objdir/$libname.def 7618ea133fd7Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 7619ea133fd7Smrg fi 7620ea133fd7Smrg fi 7621a253d6aeSmrg 7622ea133fd7Smrg libobjs=$output 7623ea133fd7Smrg # Restore the value of output. 7624ea133fd7Smrg output=$save_output 7625a253d6aeSmrg 7626ea133fd7Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 7627ea133fd7Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 7628ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 7629ea133fd7Smrg fi 7630ea133fd7Smrg # Expand the library linking commands again to reset the 7631ea133fd7Smrg # value of $libobjs for piecewise linking. 7632ea133fd7Smrg 7633ea133fd7Smrg # Do each of the archive commands. 7634ea133fd7Smrg if test "$module" = yes && test -n "$module_cmds" ; then 7635ea133fd7Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 7636ea133fd7Smrg cmds=$module_expsym_cmds 7637a253d6aeSmrg else 7638ea133fd7Smrg cmds=$module_cmds 7639a253d6aeSmrg fi 7640a253d6aeSmrg else 7641ea133fd7Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 7642ea133fd7Smrg cmds=$archive_expsym_cmds 7643ea133fd7Smrg else 7644ea133fd7Smrg cmds=$archive_cmds 7645ea133fd7Smrg fi 7646a253d6aeSmrg fi 7647a253d6aeSmrg fi 7648a253d6aeSmrg 7649ea133fd7Smrg if test -n "$delfiles"; then 7650ea133fd7Smrg # Append the command to remove temporary files to $cmds. 7651ea133fd7Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 7652ea133fd7Smrg fi 7653a253d6aeSmrg 7654ea133fd7Smrg # Add any objects from preloaded convenience libraries 7655ea133fd7Smrg if test -n "$dlprefiles"; then 7656ea133fd7Smrg gentop="$output_objdir/${outputname}x" 7657ea133fd7Smrg generated="$generated $gentop" 7658a253d6aeSmrg 7659ea133fd7Smrg func_extract_archives $gentop $dlprefiles 7660ea133fd7Smrg libobjs="$libobjs $func_extract_archives_result" 7661ea133fd7Smrg test "X$libobjs" = "X " && libobjs= 7662a253d6aeSmrg fi 7663a253d6aeSmrg 7664ea133fd7Smrg save_ifs="$IFS"; IFS='~' 7665ea133fd7Smrg for cmd in $cmds; do 7666ea133fd7Smrg IFS="$save_ifs" 7667ea133fd7Smrg eval cmd=\"$cmd\" 7668ea133fd7Smrg $opt_silent || { 7669ea133fd7Smrg func_quote_for_expand "$cmd" 7670ea133fd7Smrg eval "func_echo $func_quote_for_expand_result" 7671ea133fd7Smrg } 7672ea133fd7Smrg $opt_dry_run || eval "$cmd" || { 7673ea133fd7Smrg lt_exit=$? 7674a253d6aeSmrg 7675ea133fd7Smrg # Restore the uninstalled library and exit 7676ea133fd7Smrg if test "$mode" = relink; then 7677ea133fd7Smrg ( cd "$output_objdir" && \ 7678ea133fd7Smrg $RM "${realname}T" && \ 7679ea133fd7Smrg $MV "${realname}U" "$realname" ) 7680ea133fd7Smrg fi 7681ea133fd7Smrg 7682ea133fd7Smrg exit $lt_exit 7683ea133fd7Smrg } 7684ea133fd7Smrg done 7685ea133fd7Smrg IFS="$save_ifs" 7686ea133fd7Smrg 7687ea133fd7Smrg # Restore the uninstalled library and exit 7688ea133fd7Smrg if test "$mode" = relink; then 7689ea133fd7Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 7690ea133fd7Smrg 7691ea133fd7Smrg if test -n "$convenience"; then 7692ea133fd7Smrg if test -z "$whole_archive_flag_spec"; then 7693ea133fd7Smrg func_show_eval '${RM}r "$gentop"' 7694a253d6aeSmrg fi 7695a253d6aeSmrg fi 7696a253d6aeSmrg 7697ea133fd7Smrg exit $EXIT_SUCCESS 7698ea133fd7Smrg fi 7699a253d6aeSmrg 7700ea133fd7Smrg # Create links to the real library. 7701ea133fd7Smrg for linkname in $linknames; do 7702ea133fd7Smrg if test "$realname" != "$linkname"; then 7703ea133fd7Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 7704ea133fd7Smrg fi 7705ea133fd7Smrg done 7706ea133fd7Smrg 7707ea133fd7Smrg # If -module or -export-dynamic was specified, set the dlname. 7708ea133fd7Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 7709ea133fd7Smrg # On all known operating systems, these are identical. 7710ea133fd7Smrg dlname="$soname" 7711ea133fd7Smrg fi 7712ea133fd7Smrg fi 7713ea133fd7Smrg ;; 7714ea133fd7Smrg 7715ea133fd7Smrg obj) 7716ea133fd7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7717ea133fd7Smrg func_warning "\`-dlopen' is ignored for objects" 7718ea133fd7Smrg fi 7719ea133fd7Smrg 7720ea133fd7Smrg case " $deplibs" in 7721ea133fd7Smrg *\ -l* | *\ -L*) 7722ea133fd7Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 7723ea133fd7Smrg esac 7724ea133fd7Smrg 7725ea133fd7Smrg test -n "$rpath" && \ 7726ea133fd7Smrg func_warning "\`-rpath' is ignored for objects" 7727ea133fd7Smrg 7728ea133fd7Smrg test -n "$xrpath" && \ 7729ea133fd7Smrg func_warning "\`-R' is ignored for objects" 7730ea133fd7Smrg 7731ea133fd7Smrg test -n "$vinfo" && \ 7732ea133fd7Smrg func_warning "\`-version-info' is ignored for objects" 7733ea133fd7Smrg 7734ea133fd7Smrg test -n "$release" && \ 7735ea133fd7Smrg func_warning "\`-release' is ignored for objects" 7736ea133fd7Smrg 7737ea133fd7Smrg case $output in 7738ea133fd7Smrg *.lo) 7739ea133fd7Smrg test -n "$objs$old_deplibs" && \ 7740ea133fd7Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 7741ea133fd7Smrg 7742ea133fd7Smrg libobj=$output 7743ea133fd7Smrg func_lo2o "$libobj" 7744ea133fd7Smrg obj=$func_lo2o_result 7745ea133fd7Smrg ;; 7746ea133fd7Smrg *) 7747ea133fd7Smrg libobj= 7748ea133fd7Smrg obj="$output" 7749ea133fd7Smrg ;; 7750ea133fd7Smrg esac 7751ea133fd7Smrg 7752ea133fd7Smrg # Delete the old objects. 7753ea133fd7Smrg $opt_dry_run || $RM $obj $libobj 7754ea133fd7Smrg 7755ea133fd7Smrg # Objects from convenience libraries. This assumes 7756ea133fd7Smrg # single-version convenience libraries. Whenever we create 7757ea133fd7Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 7758ea133fd7Smrg # the extraction. 7759ea133fd7Smrg reload_conv_objs= 7760ea133fd7Smrg gentop= 7761ea133fd7Smrg # reload_cmds runs $LD directly, so let us get rid of 7762ea133fd7Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 7763ea133fd7Smrg # turning comma into space.. 7764ea133fd7Smrg wl= 7765ea133fd7Smrg 7766ea133fd7Smrg if test -n "$convenience"; then 7767ea133fd7Smrg if test -n "$whole_archive_flag_spec"; then 7768ea133fd7Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 776925b89263Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 7770ea133fd7Smrg else 7771ea133fd7Smrg gentop="$output_objdir/${obj}x" 7772ea133fd7Smrg generated="$generated $gentop" 7773ea133fd7Smrg 7774ea133fd7Smrg func_extract_archives $gentop $convenience 7775ea133fd7Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 7776ea133fd7Smrg fi 7777ea133fd7Smrg fi 7778a253d6aeSmrg 7779ea133fd7Smrg # Create the old-style object. 778025b89263Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 7781a253d6aeSmrg 7782ea133fd7Smrg output="$obj" 7783ea133fd7Smrg func_execute_cmds "$reload_cmds" 'exit $?' 7784a253d6aeSmrg 7785ea133fd7Smrg # Exit if we aren't doing a library object file. 7786ea133fd7Smrg if test -z "$libobj"; then 7787ea133fd7Smrg if test -n "$gentop"; then 7788ea133fd7Smrg func_show_eval '${RM}r "$gentop"' 7789ea133fd7Smrg fi 7790a253d6aeSmrg 7791ea133fd7Smrg exit $EXIT_SUCCESS 7792ea133fd7Smrg fi 7793a253d6aeSmrg 7794ea133fd7Smrg if test "$build_libtool_libs" != yes; then 7795ea133fd7Smrg if test -n "$gentop"; then 7796ea133fd7Smrg func_show_eval '${RM}r "$gentop"' 7797ea133fd7Smrg fi 7798a253d6aeSmrg 7799ea133fd7Smrg # Create an invalid libtool object if no PIC, so that we don't 7800ea133fd7Smrg # accidentally link it into a program. 7801ea133fd7Smrg # $show "echo timestamp > $libobj" 7802ea133fd7Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 7803ea133fd7Smrg exit $EXIT_SUCCESS 7804ea133fd7Smrg fi 7805a253d6aeSmrg 7806ea133fd7Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 7807ea133fd7Smrg # Only do commands if we really have different PIC objects. 7808ea133fd7Smrg reload_objs="$libobjs $reload_conv_objs" 7809ea133fd7Smrg output="$libobj" 7810ea133fd7Smrg func_execute_cmds "$reload_cmds" 'exit $?' 7811a253d6aeSmrg fi 7812a253d6aeSmrg 7813ea133fd7Smrg if test -n "$gentop"; then 7814ea133fd7Smrg func_show_eval '${RM}r "$gentop"' 7815ea133fd7Smrg fi 7816a253d6aeSmrg 7817ea133fd7Smrg exit $EXIT_SUCCESS 7818ea133fd7Smrg ;; 7819a253d6aeSmrg 7820ea133fd7Smrg prog) 7821ea133fd7Smrg case $host in 7822ea133fd7Smrg *cygwin*) func_stripname '' '.exe' "$output" 7823ea133fd7Smrg output=$func_stripname_result.exe;; 7824a253d6aeSmrg esac 7825ea133fd7Smrg test -n "$vinfo" && \ 7826ea133fd7Smrg func_warning "\`-version-info' is ignored for programs" 7827a253d6aeSmrg 7828ea133fd7Smrg test -n "$release" && \ 7829ea133fd7Smrg func_warning "\`-release' is ignored for programs" 7830a253d6aeSmrg 7831ea133fd7Smrg test "$preload" = yes \ 7832ea133fd7Smrg && test "$dlopen_support" = unknown \ 7833ea133fd7Smrg && test "$dlopen_self" = unknown \ 7834ea133fd7Smrg && test "$dlopen_self_static" = unknown && \ 7835ea133fd7Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 7836a253d6aeSmrg 7837ea133fd7Smrg case $host in 7838ea133fd7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7839ea133fd7Smrg # On Rhapsody replace the C library is the System framework 784025b89263Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 784125b89263Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 7842a253d6aeSmrg ;; 7843a253d6aeSmrg esac 7844a253d6aeSmrg 7845ea133fd7Smrg case $host in 7846ea133fd7Smrg *-*-darwin*) 7847ea133fd7Smrg # Don't allow lazy linking, it breaks C++ global constructors 7848ea133fd7Smrg # But is supposedly fixed on 10.4 or later (yay!). 7849ea133fd7Smrg if test "$tagname" = CXX ; then 7850ea133fd7Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 7851ea133fd7Smrg 10.[0123]) 7852ea133fd7Smrg compile_command="$compile_command ${wl}-bind_at_load" 7853ea133fd7Smrg finalize_command="$finalize_command ${wl}-bind_at_load" 7854ea133fd7Smrg ;; 7855ea133fd7Smrg esac 7856ea133fd7Smrg fi 7857ea133fd7Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 785825b89263Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 785925b89263Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7860a253d6aeSmrg ;; 7861a253d6aeSmrg esac 7862a253d6aeSmrg 7863a253d6aeSmrg 7864ea133fd7Smrg # move library search paths that coincide with paths to not yet 7865ea133fd7Smrg # installed libraries to the beginning of the library search list 7866ea133fd7Smrg new_libs= 7867ea133fd7Smrg for path in $notinst_path; do 7868ea133fd7Smrg case " $new_libs " in 7869ea133fd7Smrg *" -L$path/$objdir "*) ;; 7870a253d6aeSmrg *) 7871ea133fd7Smrg case " $compile_deplibs " in 7872ea133fd7Smrg *" -L$path/$objdir "*) 7873ea133fd7Smrg new_libs="$new_libs -L$path/$objdir" ;; 7874ea133fd7Smrg esac 7875a253d6aeSmrg ;; 7876a253d6aeSmrg esac 7877a253d6aeSmrg done 7878ea133fd7Smrg for deplib in $compile_deplibs; do 7879ea133fd7Smrg case $deplib in 7880ea133fd7Smrg -L*) 7881ea133fd7Smrg case " $new_libs " in 7882ea133fd7Smrg *" $deplib "*) ;; 7883ea133fd7Smrg *) new_libs="$new_libs $deplib" ;; 7884ea133fd7Smrg esac 7885ea133fd7Smrg ;; 7886ea133fd7Smrg *) new_libs="$new_libs $deplib" ;; 7887ea133fd7Smrg esac 7888ea133fd7Smrg done 7889ea133fd7Smrg compile_deplibs="$new_libs" 7890a253d6aeSmrg 7891a253d6aeSmrg 7892ea133fd7Smrg compile_command="$compile_command $compile_deplibs" 7893ea133fd7Smrg finalize_command="$finalize_command $finalize_deplibs" 7894a253d6aeSmrg 7895ea133fd7Smrg if test -n "$rpath$xrpath"; then 7896ea133fd7Smrg # If the user specified any rpath flags, then add them. 7897ea133fd7Smrg for libdir in $rpath $xrpath; do 7898ea133fd7Smrg # This is the magic to use -rpath. 7899ea133fd7Smrg case "$finalize_rpath " in 7900ea133fd7Smrg *" $libdir "*) ;; 7901ea133fd7Smrg *) finalize_rpath="$finalize_rpath $libdir" ;; 7902ea133fd7Smrg esac 7903ea133fd7Smrg done 7904ea133fd7Smrg fi 7905a253d6aeSmrg 7906ea133fd7Smrg # Now hardcode the library paths 7907ea133fd7Smrg rpath= 7908ea133fd7Smrg hardcode_libdirs= 7909ea133fd7Smrg for libdir in $compile_rpath $finalize_rpath; do 7910ea133fd7Smrg if test -n "$hardcode_libdir_flag_spec"; then 7911ea133fd7Smrg if test -n "$hardcode_libdir_separator"; then 7912ea133fd7Smrg if test -z "$hardcode_libdirs"; then 7913ea133fd7Smrg hardcode_libdirs="$libdir" 7914ea133fd7Smrg else 7915ea133fd7Smrg # Just accumulate the unique libdirs. 7916ea133fd7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 7917ea133fd7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 7918ea133fd7Smrg ;; 7919ea133fd7Smrg *) 7920ea133fd7Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 7921ea133fd7Smrg ;; 7922ea133fd7Smrg esac 7923ea133fd7Smrg fi 7924ea133fd7Smrg else 7925ea133fd7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 7926ea133fd7Smrg rpath="$rpath $flag" 7927ea133fd7Smrg fi 7928ea133fd7Smrg elif test -n "$runpath_var"; then 7929ea133fd7Smrg case "$perm_rpath " in 7930a253d6aeSmrg *" $libdir "*) ;; 7931ea133fd7Smrg *) perm_rpath="$perm_rpath $libdir" ;; 7932a253d6aeSmrg esac 7933ea133fd7Smrg fi 7934ea133fd7Smrg case $host in 7935ea133fd7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7936ea133fd7Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 7937ea133fd7Smrg case :$dllsearchpath: in 7938ea133fd7Smrg *":$libdir:"*) ;; 7939ea133fd7Smrg ::) dllsearchpath=$libdir;; 7940ea133fd7Smrg *) dllsearchpath="$dllsearchpath:$libdir";; 7941ea133fd7Smrg esac 7942ea133fd7Smrg case :$dllsearchpath: in 7943ea133fd7Smrg *":$testbindir:"*) ;; 7944ea133fd7Smrg ::) dllsearchpath=$testbindir;; 7945ea133fd7Smrg *) dllsearchpath="$dllsearchpath:$testbindir";; 7946ea133fd7Smrg esac 7947ea133fd7Smrg ;; 7948ea133fd7Smrg esac 7949ea133fd7Smrg done 7950ea133fd7Smrg # Substitute the hardcoded libdirs into the rpath. 7951ea133fd7Smrg if test -n "$hardcode_libdir_separator" && 7952ea133fd7Smrg test -n "$hardcode_libdirs"; then 7953ea133fd7Smrg libdir="$hardcode_libdirs" 7954ea133fd7Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 7955ea133fd7Smrg fi 7956ea133fd7Smrg compile_rpath="$rpath" 7957ea133fd7Smrg 7958ea133fd7Smrg rpath= 7959ea133fd7Smrg hardcode_libdirs= 7960ea133fd7Smrg for libdir in $finalize_rpath; do 7961ea133fd7Smrg if test -n "$hardcode_libdir_flag_spec"; then 7962ea133fd7Smrg if test -n "$hardcode_libdir_separator"; then 7963ea133fd7Smrg if test -z "$hardcode_libdirs"; then 7964ea133fd7Smrg hardcode_libdirs="$libdir" 7965ea133fd7Smrg else 7966ea133fd7Smrg # Just accumulate the unique libdirs. 7967ea133fd7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 7968ea133fd7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 7969ea133fd7Smrg ;; 7970ea133fd7Smrg *) 7971ea133fd7Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 7972ea133fd7Smrg ;; 7973ea133fd7Smrg esac 7974ea133fd7Smrg fi 7975ea133fd7Smrg else 7976ea133fd7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 7977ea133fd7Smrg rpath="$rpath $flag" 7978ea133fd7Smrg fi 7979ea133fd7Smrg elif test -n "$runpath_var"; then 7980ea133fd7Smrg case "$finalize_perm_rpath " in 7981a253d6aeSmrg *" $libdir "*) ;; 7982ea133fd7Smrg *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; 7983a253d6aeSmrg esac 7984a253d6aeSmrg fi 7985ea133fd7Smrg done 7986ea133fd7Smrg # Substitute the hardcoded libdirs into the rpath. 7987ea133fd7Smrg if test -n "$hardcode_libdir_separator" && 7988ea133fd7Smrg test -n "$hardcode_libdirs"; then 7989ea133fd7Smrg libdir="$hardcode_libdirs" 7990ea133fd7Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 7991ea133fd7Smrg fi 7992ea133fd7Smrg finalize_rpath="$rpath" 7993a253d6aeSmrg 7994ea133fd7Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 7995ea133fd7Smrg # Transform all the library objects into standard objects. 799625b89263Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 799725b89263Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 7998ea133fd7Smrg fi 7999a253d6aeSmrg 8000ea133fd7Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8001a253d6aeSmrg 8002ea133fd7Smrg # template prelinking step 8003ea133fd7Smrg if test -n "$prelink_cmds"; then 8004ea133fd7Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 8005ea133fd7Smrg fi 8006a253d6aeSmrg 8007ea133fd7Smrg wrappers_required=yes 8008ea133fd7Smrg case $host in 800925b89263Smrg *cegcc* | *mingw32ce*) 801025b89263Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 801125b89263Smrg wrappers_required=no 801225b89263Smrg ;; 8013ea133fd7Smrg *cygwin* | *mingw* ) 8014ea133fd7Smrg if test "$build_libtool_libs" != yes; then 8015ea133fd7Smrg wrappers_required=no 8016ea133fd7Smrg fi 8017ea133fd7Smrg ;; 8018ea133fd7Smrg *) 8019ea133fd7Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8020ea133fd7Smrg wrappers_required=no 8021ea133fd7Smrg fi 8022ea133fd7Smrg ;; 8023ea133fd7Smrg esac 8024ea133fd7Smrg if test "$wrappers_required" = no; then 8025ea133fd7Smrg # Replace the output file specification. 802625b89263Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8027ea133fd7Smrg link_command="$compile_command$compile_rpath" 8028a253d6aeSmrg 8029ea133fd7Smrg # We have no uninstalled library dependencies, so finalize right now. 8030ea133fd7Smrg exit_status=0 8031ea133fd7Smrg func_show_eval "$link_command" 'exit_status=$?' 8032a253d6aeSmrg 8033ea133fd7Smrg # Delete the generated files. 8034ea133fd7Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 8035ea133fd7Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8036ea133fd7Smrg fi 8037a253d6aeSmrg 8038ea133fd7Smrg exit $exit_status 8039ea133fd7Smrg fi 8040a253d6aeSmrg 8041ea133fd7Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 8042ea133fd7Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 8043ea133fd7Smrg fi 8044ea133fd7Smrg if test -n "$finalize_shlibpath"; then 8045ea133fd7Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 8046ea133fd7Smrg fi 8047a253d6aeSmrg 8048ea133fd7Smrg compile_var= 8049ea133fd7Smrg finalize_var= 8050ea133fd7Smrg if test -n "$runpath_var"; then 8051ea133fd7Smrg if test -n "$perm_rpath"; then 8052ea133fd7Smrg # We should set the runpath_var. 8053ea133fd7Smrg rpath= 8054ea133fd7Smrg for dir in $perm_rpath; do 8055ea133fd7Smrg rpath="$rpath$dir:" 8056a253d6aeSmrg done 8057ea133fd7Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8058a253d6aeSmrg fi 8059ea133fd7Smrg if test -n "$finalize_perm_rpath"; then 8060ea133fd7Smrg # We should set the runpath_var. 8061ea133fd7Smrg rpath= 8062ea133fd7Smrg for dir in $finalize_perm_rpath; do 8063ea133fd7Smrg rpath="$rpath$dir:" 8064ea133fd7Smrg done 8065ea133fd7Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8066ea133fd7Smrg fi 8067ea133fd7Smrg fi 8068a253d6aeSmrg 8069ea133fd7Smrg if test "$no_install" = yes; then 8070ea133fd7Smrg # We don't need to create a wrapper script. 8071ea133fd7Smrg link_command="$compile_var$compile_command$compile_rpath" 8072ea133fd7Smrg # Replace the output file specification. 807325b89263Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8074ea133fd7Smrg # Delete the old output file. 8075ea133fd7Smrg $opt_dry_run || $RM $output 8076ea133fd7Smrg # Link the executable and exit 8077ea133fd7Smrg func_show_eval "$link_command" 'exit $?' 8078ea133fd7Smrg exit $EXIT_SUCCESS 8079ea133fd7Smrg fi 8080a253d6aeSmrg 8081ea133fd7Smrg if test "$hardcode_action" = relink; then 8082ea133fd7Smrg # Fast installation is not supported 8083ea133fd7Smrg link_command="$compile_var$compile_command$compile_rpath" 8084ea133fd7Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8085a253d6aeSmrg 8086ea133fd7Smrg func_warning "this platform does not like uninstalled shared libraries" 8087ea133fd7Smrg func_warning "\`$output' will be relinked during installation" 8088ea133fd7Smrg else 8089ea133fd7Smrg if test "$fast_install" != no; then 8090ea133fd7Smrg link_command="$finalize_var$compile_command$finalize_rpath" 8091ea133fd7Smrg if test "$fast_install" = yes; then 809225b89263Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 8093ea133fd7Smrg else 8094ea133fd7Smrg # fast_install is set to needless 8095ea133fd7Smrg relink_command= 8096ea133fd7Smrg fi 8097a253d6aeSmrg else 8098ea133fd7Smrg link_command="$compile_var$compile_command$compile_rpath" 8099ea133fd7Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8100a253d6aeSmrg fi 8101ea133fd7Smrg fi 8102a253d6aeSmrg 8103ea133fd7Smrg # Replace the output file specification. 810425b89263Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8105a253d6aeSmrg 8106ea133fd7Smrg # Delete the old output files. 8107ea133fd7Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8108a253d6aeSmrg 8109ea133fd7Smrg func_show_eval "$link_command" 'exit $?' 8110a253d6aeSmrg 8111ea133fd7Smrg # Now create the wrapper script. 8112ea133fd7Smrg func_verbose "creating $output" 8113a253d6aeSmrg 8114ea133fd7Smrg # Quote the relink command for shipping. 8115ea133fd7Smrg if test -n "$relink_command"; then 8116ea133fd7Smrg # Preserve any variables that may affect compiler behavior 8117ea133fd7Smrg for var in $variables_saved_for_relink; do 8118ea133fd7Smrg if eval test -z \"\${$var+set}\"; then 8119ea133fd7Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 8120ea133fd7Smrg elif eval var_value=\$$var; test -z "$var_value"; then 8121ea133fd7Smrg relink_command="$var=; export $var; $relink_command" 8122ea133fd7Smrg else 8123ea133fd7Smrg func_quote_for_eval "$var_value" 8124ea133fd7Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 8125ea133fd7Smrg fi 8126ea133fd7Smrg done 8127ea133fd7Smrg relink_command="(cd `pwd`; $relink_command)" 812825b89263Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 8129ea133fd7Smrg fi 8130a253d6aeSmrg 8131ea133fd7Smrg # Only actually do things if not in dry run mode. 8132ea133fd7Smrg $opt_dry_run || { 8133ea133fd7Smrg # win32 will think the script is a binary if it has 8134ea133fd7Smrg # a .exe suffix, so we strip it off here. 8135ea133fd7Smrg case $output in 8136ea133fd7Smrg *.exe) func_stripname '' '.exe' "$output" 8137ea133fd7Smrg output=$func_stripname_result ;; 8138ea133fd7Smrg esac 8139ea133fd7Smrg # test for cygwin because mv fails w/o .exe extensions 8140a253d6aeSmrg case $host in 8141ea133fd7Smrg *cygwin*) 8142ea133fd7Smrg exeext=.exe 8143ea133fd7Smrg func_stripname '' '.exe' "$outputname" 8144ea133fd7Smrg outputname=$func_stripname_result ;; 8145ea133fd7Smrg *) exeext= ;; 8146a253d6aeSmrg esac 8147ea133fd7Smrg case $host in 8148ea133fd7Smrg *cygwin* | *mingw* ) 8149ea133fd7Smrg func_dirname_and_basename "$output" "" "." 8150ea133fd7Smrg output_name=$func_basename_result 8151ea133fd7Smrg output_path=$func_dirname_result 8152ea133fd7Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 8153ea133fd7Smrg cwrapper="$output_path/$output_name.exe" 8154ea133fd7Smrg $RM $cwrappersource $cwrapper 8155ea133fd7Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 8156ea133fd7Smrg 8157ea133fd7Smrg func_emit_cwrapperexe_src > $cwrappersource 8158ea133fd7Smrg 8159ea133fd7Smrg # The wrapper executable is built using the $host compiler, 8160ea133fd7Smrg # because it contains $host paths and files. If cross- 8161ea133fd7Smrg # compiling, it, like the target executable, must be 8162ea133fd7Smrg # executed on the $host or under an emulation environment. 8163ea133fd7Smrg $opt_dry_run || { 8164ea133fd7Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 8165ea133fd7Smrg $STRIP $cwrapper 8166ea133fd7Smrg } 8167a253d6aeSmrg 8168ea133fd7Smrg # Now, create the wrapper script for func_source use: 8169ea133fd7Smrg func_ltwrapper_scriptname $cwrapper 8170ea133fd7Smrg $RM $func_ltwrapper_scriptname_result 8171ea133fd7Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 8172ea133fd7Smrg $opt_dry_run || { 8173ea133fd7Smrg # note: this script will not be executed, so do not chmod. 8174ea133fd7Smrg if test "x$build" = "x$host" ; then 8175ea133fd7Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 8176a253d6aeSmrg else 8177ea133fd7Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 8178a253d6aeSmrg fi 8179ea133fd7Smrg } 8180ea133fd7Smrg ;; 8181ea133fd7Smrg * ) 8182ea133fd7Smrg $RM $output 8183ea133fd7Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 8184a253d6aeSmrg 8185ea133fd7Smrg func_emit_wrapper no > $output 8186ea133fd7Smrg chmod +x $output 8187a253d6aeSmrg ;; 8188a253d6aeSmrg esac 8189ea133fd7Smrg } 8190ea133fd7Smrg exit $EXIT_SUCCESS 8191ea133fd7Smrg ;; 8192ea133fd7Smrg esac 8193a253d6aeSmrg 8194ea133fd7Smrg # See if we need to build an old-fashioned archive. 8195ea133fd7Smrg for oldlib in $oldlibs; do 8196a253d6aeSmrg 8197ea133fd7Smrg if test "$build_libtool_libs" = convenience; then 8198ea133fd7Smrg oldobjs="$libobjs_save $symfileobj" 8199ea133fd7Smrg addlibs="$convenience" 8200ea133fd7Smrg build_libtool_libs=no 8201ea133fd7Smrg else 8202ea133fd7Smrg if test "$build_libtool_libs" = module; then 8203ea133fd7Smrg oldobjs="$libobjs_save" 8204ea133fd7Smrg build_libtool_libs=no 8205ea133fd7Smrg else 8206ea133fd7Smrg oldobjs="$old_deplibs $non_pic_objects" 8207ea133fd7Smrg if test "$preload" = yes && test -f "$symfileobj"; then 8208ea133fd7Smrg oldobjs="$oldobjs $symfileobj" 8209ea133fd7Smrg fi 8210ea133fd7Smrg fi 8211ea133fd7Smrg addlibs="$old_convenience" 8212a253d6aeSmrg fi 8213a253d6aeSmrg 8214ea133fd7Smrg if test -n "$addlibs"; then 8215ea133fd7Smrg gentop="$output_objdir/${outputname}x" 8216ea133fd7Smrg generated="$generated $gentop" 8217a253d6aeSmrg 8218ea133fd7Smrg func_extract_archives $gentop $addlibs 8219ea133fd7Smrg oldobjs="$oldobjs $func_extract_archives_result" 8220ea133fd7Smrg fi 8221a253d6aeSmrg 8222ea133fd7Smrg # Do each command in the archive commands. 8223ea133fd7Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 8224ea133fd7Smrg cmds=$old_archive_from_new_cmds 8225ea133fd7Smrg else 8226a253d6aeSmrg 8227ea133fd7Smrg # Add any objects from preloaded convenience libraries 8228ea133fd7Smrg if test -n "$dlprefiles"; then 8229ea133fd7Smrg gentop="$output_objdir/${outputname}x" 8230ea133fd7Smrg generated="$generated $gentop" 8231a253d6aeSmrg 8232ea133fd7Smrg func_extract_archives $gentop $dlprefiles 8233ea133fd7Smrg oldobjs="$oldobjs $func_extract_archives_result" 8234ea133fd7Smrg fi 8235a253d6aeSmrg 8236ea133fd7Smrg # POSIX demands no paths to be encoded in archives. We have 8237ea133fd7Smrg # to avoid creating archives with duplicate basenames if we 8238ea133fd7Smrg # might have to extract them afterwards, e.g., when creating a 8239ea133fd7Smrg # static archive out of a convenience library, or when linking 8240ea133fd7Smrg # the entirety of a libtool archive into another (currently 8241ea133fd7Smrg # not supported by libtool). 8242ea133fd7Smrg if (for obj in $oldobjs 8243ea133fd7Smrg do 8244ea133fd7Smrg func_basename "$obj" 8245ea133fd7Smrg $ECHO "$func_basename_result" 8246ea133fd7Smrg done | sort | sort -uc >/dev/null 2>&1); then 8247ea133fd7Smrg : 8248ea133fd7Smrg else 824925b89263Smrg echo "copying selected object files to avoid basename conflicts..." 8250ea133fd7Smrg gentop="$output_objdir/${outputname}x" 8251ea133fd7Smrg generated="$generated $gentop" 8252ea133fd7Smrg func_mkdir_p "$gentop" 8253ea133fd7Smrg save_oldobjs=$oldobjs 8254ea133fd7Smrg oldobjs= 8255ea133fd7Smrg counter=1 8256ea133fd7Smrg for obj in $save_oldobjs 8257ea133fd7Smrg do 8258ea133fd7Smrg func_basename "$obj" 8259ea133fd7Smrg objbase="$func_basename_result" 8260ea133fd7Smrg case " $oldobjs " in 8261ea133fd7Smrg " ") oldobjs=$obj ;; 8262ea133fd7Smrg *[\ /]"$objbase "*) 8263ea133fd7Smrg while :; do 8264ea133fd7Smrg # Make sure we don't pick an alternate name that also 8265ea133fd7Smrg # overlaps. 8266ea133fd7Smrg newobj=lt$counter-$objbase 8267ea133fd7Smrg func_arith $counter + 1 8268ea133fd7Smrg counter=$func_arith_result 8269ea133fd7Smrg case " $oldobjs " in 8270ea133fd7Smrg *[\ /]"$newobj "*) ;; 8271ea133fd7Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 8272ea133fd7Smrg esac 8273ea133fd7Smrg done 8274ea133fd7Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 8275ea133fd7Smrg oldobjs="$oldobjs $gentop/$newobj" 8276ea133fd7Smrg ;; 8277ea133fd7Smrg *) oldobjs="$oldobjs $obj" ;; 8278ea133fd7Smrg esac 8279a253d6aeSmrg done 8280a253d6aeSmrg fi 8281ea133fd7Smrg eval cmds=\"$old_archive_cmds\" 8282a253d6aeSmrg 8283ea133fd7Smrg func_len " $cmds" 8284ea133fd7Smrg len=$func_len_result 8285ea133fd7Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8286ea133fd7Smrg cmds=$old_archive_cmds 8287ea133fd7Smrg else 8288ea133fd7Smrg # the command line is too long to link in one step, link in parts 8289ea133fd7Smrg func_verbose "using piecewise archive linking..." 8290ea133fd7Smrg save_RANLIB=$RANLIB 8291ea133fd7Smrg RANLIB=: 8292ea133fd7Smrg objlist= 8293ea133fd7Smrg concat_cmds= 8294ea133fd7Smrg save_oldobjs=$oldobjs 8295ea133fd7Smrg oldobjs= 8296ea133fd7Smrg # Is there a better way of finding the last object in the list? 8297ea133fd7Smrg for obj in $save_oldobjs 8298ea133fd7Smrg do 8299ea133fd7Smrg last_oldobj=$obj 8300ea133fd7Smrg done 8301ea133fd7Smrg eval test_cmds=\"$old_archive_cmds\" 8302ea133fd7Smrg func_len " $test_cmds" 8303ea133fd7Smrg len0=$func_len_result 8304ea133fd7Smrg len=$len0 8305ea133fd7Smrg for obj in $save_oldobjs 8306ea133fd7Smrg do 8307ea133fd7Smrg func_len " $obj" 8308ea133fd7Smrg func_arith $len + $func_len_result 8309ea133fd7Smrg len=$func_arith_result 8310ea133fd7Smrg func_append objlist " $obj" 8311ea133fd7Smrg if test "$len" -lt "$max_cmd_len"; then 8312ea133fd7Smrg : 8313ea133fd7Smrg else 8314ea133fd7Smrg # the above command should be used before it gets too long 8315ea133fd7Smrg oldobjs=$objlist 8316ea133fd7Smrg if test "$obj" = "$last_oldobj" ; then 8317ea133fd7Smrg RANLIB=$save_RANLIB 8318ea133fd7Smrg fi 8319ea133fd7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8320ea133fd7Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 8321ea133fd7Smrg objlist= 8322ea133fd7Smrg len=$len0 8323ea133fd7Smrg fi 8324ea133fd7Smrg done 8325ea133fd7Smrg RANLIB=$save_RANLIB 8326ea133fd7Smrg oldobjs=$objlist 8327ea133fd7Smrg if test "X$oldobjs" = "X" ; then 8328ea133fd7Smrg eval cmds=\"\$concat_cmds\" 8329ea133fd7Smrg else 8330ea133fd7Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 8331ea133fd7Smrg fi 8332ea133fd7Smrg fi 8333ea133fd7Smrg fi 8334ea133fd7Smrg func_execute_cmds "$cmds" 'exit $?' 8335a253d6aeSmrg done 8336a253d6aeSmrg 8337ea133fd7Smrg test -n "$generated" && \ 8338ea133fd7Smrg func_show_eval "${RM}r$generated" 8339a253d6aeSmrg 8340ea133fd7Smrg # Now create the libtool archive. 8341ea133fd7Smrg case $output in 8342ea133fd7Smrg *.la) 8343ea133fd7Smrg old_library= 8344ea133fd7Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 8345ea133fd7Smrg func_verbose "creating $output" 8346a253d6aeSmrg 8347ea133fd7Smrg # Preserve any variables that may affect compiler behavior 8348ea133fd7Smrg for var in $variables_saved_for_relink; do 8349ea133fd7Smrg if eval test -z \"\${$var+set}\"; then 8350ea133fd7Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 8351ea133fd7Smrg elif eval var_value=\$$var; test -z "$var_value"; then 8352ea133fd7Smrg relink_command="$var=; export $var; $relink_command" 8353a253d6aeSmrg else 8354ea133fd7Smrg func_quote_for_eval "$var_value" 8355ea133fd7Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 8356a253d6aeSmrg fi 8357ea133fd7Smrg done 8358ea133fd7Smrg # Quote the link command for shipping. 8359ea133fd7Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 836025b89263Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 8361ea133fd7Smrg if test "$hardcode_automatic" = yes ; then 8362ea133fd7Smrg relink_command= 8363ea133fd7Smrg fi 8364a253d6aeSmrg 8365ea133fd7Smrg # Only create the output if not a dry run. 8366ea133fd7Smrg $opt_dry_run || { 8367ea133fd7Smrg for installed in no yes; do 8368ea133fd7Smrg if test "$installed" = yes; then 8369ea133fd7Smrg if test -z "$install_libdir"; then 8370ea133fd7Smrg break 8371ea133fd7Smrg fi 8372ea133fd7Smrg output="$output_objdir/$outputname"i 8373ea133fd7Smrg # Replace all uninstalled libtool libraries with the installed ones 8374ea133fd7Smrg newdependency_libs= 8375ea133fd7Smrg for deplib in $dependency_libs; do 8376ea133fd7Smrg case $deplib in 8377ea133fd7Smrg *.la) 8378ea133fd7Smrg func_basename "$deplib" 8379ea133fd7Smrg name="$func_basename_result" 8380ea133fd7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8381ea133fd7Smrg test -z "$libdir" && \ 8382ea133fd7Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 8383ea133fd7Smrg newdependency_libs="$newdependency_libs $libdir/$name" 8384ea133fd7Smrg ;; 8385ea133fd7Smrg *) newdependency_libs="$newdependency_libs $deplib" ;; 8386ea133fd7Smrg esac 8387ea133fd7Smrg done 8388ea133fd7Smrg dependency_libs="$newdependency_libs" 8389ea133fd7Smrg newdlfiles= 8390ea133fd7Smrg 8391ea133fd7Smrg for lib in $dlfiles; do 8392ea133fd7Smrg case $lib in 8393ea133fd7Smrg *.la) 8394ea133fd7Smrg func_basename "$lib" 8395ea133fd7Smrg name="$func_basename_result" 8396ea133fd7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 8397ea133fd7Smrg test -z "$libdir" && \ 8398ea133fd7Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 8399ea133fd7Smrg newdlfiles="$newdlfiles $libdir/$name" 8400ea133fd7Smrg ;; 8401ea133fd7Smrg *) newdlfiles="$newdlfiles $lib" ;; 8402ea133fd7Smrg esac 8403ea133fd7Smrg done 8404ea133fd7Smrg dlfiles="$newdlfiles" 8405ea133fd7Smrg newdlprefiles= 8406ea133fd7Smrg for lib in $dlprefiles; do 8407ea133fd7Smrg case $lib in 8408ea133fd7Smrg *.la) 8409ea133fd7Smrg # Only pass preopened files to the pseudo-archive (for 8410ea133fd7Smrg # eventual linking with the app. that links it) if we 8411ea133fd7Smrg # didn't already link the preopened objects directly into 8412ea133fd7Smrg # the library: 8413ea133fd7Smrg func_basename "$lib" 8414ea133fd7Smrg name="$func_basename_result" 8415ea133fd7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 8416ea133fd7Smrg test -z "$libdir" && \ 8417ea133fd7Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 8418ea133fd7Smrg newdlprefiles="$newdlprefiles $libdir/$name" 8419ea133fd7Smrg ;; 8420ea133fd7Smrg esac 8421ea133fd7Smrg done 8422ea133fd7Smrg dlprefiles="$newdlprefiles" 8423ea133fd7Smrg else 8424ea133fd7Smrg newdlfiles= 8425ea133fd7Smrg for lib in $dlfiles; do 8426ea133fd7Smrg case $lib in 8427ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 8428ea133fd7Smrg *) abs=`pwd`"/$lib" ;; 8429ea133fd7Smrg esac 8430ea133fd7Smrg newdlfiles="$newdlfiles $abs" 8431ea133fd7Smrg done 8432ea133fd7Smrg dlfiles="$newdlfiles" 8433ea133fd7Smrg newdlprefiles= 8434ea133fd7Smrg for lib in $dlprefiles; do 8435ea133fd7Smrg case $lib in 8436ea133fd7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 8437ea133fd7Smrg *) abs=`pwd`"/$lib" ;; 8438ea133fd7Smrg esac 8439ea133fd7Smrg newdlprefiles="$newdlprefiles $abs" 8440ea133fd7Smrg done 8441ea133fd7Smrg dlprefiles="$newdlprefiles" 8442ea133fd7Smrg fi 8443ea133fd7Smrg $RM $output 8444ea133fd7Smrg # place dlname in correct position for cygwin 844525b89263Smrg # In fact, it would be nice if we could use this code for all target 844625b89263Smrg # systems that can't hard-code library paths into their executables 844725b89263Smrg # and that have no shared library path variable independent of PATH, 844825b89263Smrg # but it turns out we can't easily determine that from inspecting 844925b89263Smrg # libtool variables, so we have to hard-code the OSs to which it 845025b89263Smrg # applies here; at the moment, that means platforms that use the PE 845125b89263Smrg # object format with DLL files. See the long comment at the top of 845225b89263Smrg # tests/bindir.at for full details. 8453ea133fd7Smrg tdlname=$dlname 8454ea133fd7Smrg case $host,$output,$installed,$module,$dlname in 845525b89263Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 845625b89263Smrg # If a -bindir argument was supplied, place the dll there. 845725b89263Smrg if test "x$bindir" != x ; 845825b89263Smrg then 845925b89263Smrg func_relative_path "$install_libdir" "$bindir" 846025b89263Smrg tdlname=$func_relative_path_result$dlname 846125b89263Smrg else 846225b89263Smrg # Otherwise fall back on heuristic. 846325b89263Smrg tdlname=../bin/$dlname 846425b89263Smrg fi 846525b89263Smrg ;; 8466ea133fd7Smrg esac 8467ea133fd7Smrg $ECHO > $output "\ 8468ea133fd7Smrg# $outputname - a libtool library file 8469ea133fd7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 8470ea133fd7Smrg# 8471ea133fd7Smrg# Please DO NOT delete this file! 8472ea133fd7Smrg# It is necessary for linking the library. 8473a253d6aeSmrg 8474ea133fd7Smrg# The name that we can dlopen(3). 8475ea133fd7Smrgdlname='$tdlname' 8476a253d6aeSmrg 8477ea133fd7Smrg# Names of this library. 8478ea133fd7Smrglibrary_names='$library_names' 8479a253d6aeSmrg 8480ea133fd7Smrg# The name of the static archive. 8481ea133fd7Smrgold_library='$old_library' 8482a253d6aeSmrg 8483ea133fd7Smrg# Linker flags that can not go in dependency_libs. 8484ea133fd7Smrginherited_linker_flags='$new_inherited_linker_flags' 8485a253d6aeSmrg 8486ea133fd7Smrg# Libraries that this one depends upon. 8487ea133fd7Smrgdependency_libs='$dependency_libs' 8488a253d6aeSmrg 8489ea133fd7Smrg# Names of additional weak libraries provided by this library 8490ea133fd7Smrgweak_library_names='$weak_libs' 8491a253d6aeSmrg 8492ea133fd7Smrg# Version information for $libname. 8493ea133fd7Smrgcurrent=$current 8494ea133fd7Smrgage=$age 8495ea133fd7Smrgrevision=$revision 8496a253d6aeSmrg 8497ea133fd7Smrg# Is this an already installed library? 8498ea133fd7Smrginstalled=$installed 8499a253d6aeSmrg 8500ea133fd7Smrg# Should we warn about portability when linking against -modules? 8501ea133fd7Smrgshouldnotlink=$module 8502a253d6aeSmrg 8503ea133fd7Smrg# Files to dlopen/dlpreopen 8504ea133fd7Smrgdlopen='$dlfiles' 8505ea133fd7Smrgdlpreopen='$dlprefiles' 8506a253d6aeSmrg 8507ea133fd7Smrg# Directory that this library needs to be installed in: 8508ea133fd7Smrglibdir='$install_libdir'" 8509ea133fd7Smrg if test "$installed" = no && test "$need_relink" = yes; then 8510ea133fd7Smrg $ECHO >> $output "\ 8511ea133fd7Smrgrelink_command=\"$relink_command\"" 8512ea133fd7Smrg fi 8513ea133fd7Smrg done 8514ea133fd7Smrg } 8515a253d6aeSmrg 8516ea133fd7Smrg # Do a symbolic link so that the libtool archive can be found in 8517ea133fd7Smrg # LD_LIBRARY_PATH before the program is installed. 8518ea133fd7Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 8519ea133fd7Smrg ;; 8520ea133fd7Smrg esac 8521ea133fd7Smrg exit $EXIT_SUCCESS 8522ea133fd7Smrg} 8523a253d6aeSmrg 8524ea133fd7Smrg{ test "$mode" = link || test "$mode" = relink; } && 8525ea133fd7Smrg func_mode_link ${1+"$@"} 8526a253d6aeSmrg 8527a253d6aeSmrg 8528ea133fd7Smrg# func_mode_uninstall arg... 8529ea133fd7Smrgfunc_mode_uninstall () 8530ea133fd7Smrg{ 8531ea133fd7Smrg $opt_debug 8532ea133fd7Smrg RM="$nonopt" 8533a253d6aeSmrg files= 8534a253d6aeSmrg rmforce= 8535a253d6aeSmrg exit_status=0 8536a253d6aeSmrg 8537a253d6aeSmrg # This variable tells wrapper scripts just to set variables rather 8538a253d6aeSmrg # than running their programs. 8539a253d6aeSmrg libtool_install_magic="$magic" 8540a253d6aeSmrg 8541a253d6aeSmrg for arg 8542a253d6aeSmrg do 8543a253d6aeSmrg case $arg in 8544ea133fd7Smrg -f) RM="$RM $arg"; rmforce=yes ;; 8545ea133fd7Smrg -*) RM="$RM $arg" ;; 8546a253d6aeSmrg *) files="$files $arg" ;; 8547a253d6aeSmrg esac 8548a253d6aeSmrg done 8549a253d6aeSmrg 8550ea133fd7Smrg test -z "$RM" && \ 8551ea133fd7Smrg func_fatal_help "you must specify an RM program" 8552a253d6aeSmrg 8553a253d6aeSmrg rmdirs= 8554a253d6aeSmrg 8555a253d6aeSmrg origobjdir="$objdir" 8556a253d6aeSmrg for file in $files; do 8557ea133fd7Smrg func_dirname "$file" "" "." 8558ea133fd7Smrg dir="$func_dirname_result" 8559ea133fd7Smrg if test "X$dir" = X.; then 8560a253d6aeSmrg objdir="$origobjdir" 8561a253d6aeSmrg else 8562a253d6aeSmrg objdir="$dir/$origobjdir" 8563a253d6aeSmrg fi 8564ea133fd7Smrg func_basename "$file" 8565ea133fd7Smrg name="$func_basename_result" 8566a253d6aeSmrg test "$mode" = uninstall && objdir="$dir" 8567a253d6aeSmrg 8568a253d6aeSmrg # Remember objdir for removal later, being careful to avoid duplicates 8569a253d6aeSmrg if test "$mode" = clean; then 8570a253d6aeSmrg case " $rmdirs " in 8571a253d6aeSmrg *" $objdir "*) ;; 8572a253d6aeSmrg *) rmdirs="$rmdirs $objdir" ;; 8573a253d6aeSmrg esac 8574a253d6aeSmrg fi 8575a253d6aeSmrg 8576a253d6aeSmrg # Don't error if the file doesn't exist and rm -f was used. 8577ea133fd7Smrg if { test -L "$file"; } >/dev/null 2>&1 || 8578ea133fd7Smrg { test -h "$file"; } >/dev/null 2>&1 || 8579ea133fd7Smrg test -f "$file"; then 8580a253d6aeSmrg : 8581a253d6aeSmrg elif test -d "$file"; then 8582a253d6aeSmrg exit_status=1 8583a253d6aeSmrg continue 8584a253d6aeSmrg elif test "$rmforce" = yes; then 8585a253d6aeSmrg continue 8586a253d6aeSmrg fi 8587a253d6aeSmrg 8588a253d6aeSmrg rmfiles="$file" 8589a253d6aeSmrg 8590a253d6aeSmrg case $name in 8591a253d6aeSmrg *.la) 8592a253d6aeSmrg # Possibly a libtool archive, so verify it. 8593ea133fd7Smrg if func_lalib_p "$file"; then 8594ea133fd7Smrg func_source $dir/$name 8595a253d6aeSmrg 8596a253d6aeSmrg # Delete the libtool libraries and symlinks. 8597a253d6aeSmrg for n in $library_names; do 8598a253d6aeSmrg rmfiles="$rmfiles $objdir/$n" 8599a253d6aeSmrg done 8600a253d6aeSmrg test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" 8601a253d6aeSmrg 8602a253d6aeSmrg case "$mode" in 8603a253d6aeSmrg clean) 8604a253d6aeSmrg case " $library_names " in 8605a253d6aeSmrg # " " in the beginning catches empty $dlname 8606a253d6aeSmrg *" $dlname "*) ;; 8607a253d6aeSmrg *) rmfiles="$rmfiles $objdir/$dlname" ;; 8608a253d6aeSmrg esac 8609ea133fd7Smrg test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" 8610a253d6aeSmrg ;; 8611a253d6aeSmrg uninstall) 8612a253d6aeSmrg if test -n "$library_names"; then 8613a253d6aeSmrg # Do each command in the postuninstall commands. 8614ea133fd7Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 8615a253d6aeSmrg fi 8616a253d6aeSmrg 8617a253d6aeSmrg if test -n "$old_library"; then 8618a253d6aeSmrg # Do each command in the old_postuninstall commands. 8619ea133fd7Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 8620a253d6aeSmrg fi 8621a253d6aeSmrg # FIXME: should reinstall the best remaining shared library. 8622a253d6aeSmrg ;; 8623a253d6aeSmrg esac 8624a253d6aeSmrg fi 8625a253d6aeSmrg ;; 8626a253d6aeSmrg 8627a253d6aeSmrg *.lo) 8628a253d6aeSmrg # Possibly a libtool object, so verify it. 8629ea133fd7Smrg if func_lalib_p "$file"; then 8630a253d6aeSmrg 8631a253d6aeSmrg # Read the .lo file 8632ea133fd7Smrg func_source $dir/$name 8633a253d6aeSmrg 8634a253d6aeSmrg # Add PIC object to the list of files to remove. 8635ea133fd7Smrg if test -n "$pic_object" && 8636ea133fd7Smrg test "$pic_object" != none; then 8637a253d6aeSmrg rmfiles="$rmfiles $dir/$pic_object" 8638a253d6aeSmrg fi 8639a253d6aeSmrg 8640a253d6aeSmrg # Add non-PIC object to the list of files to remove. 8641ea133fd7Smrg if test -n "$non_pic_object" && 8642ea133fd7Smrg test "$non_pic_object" != none; then 8643a253d6aeSmrg rmfiles="$rmfiles $dir/$non_pic_object" 8644a253d6aeSmrg fi 8645a253d6aeSmrg fi 8646a253d6aeSmrg ;; 8647a253d6aeSmrg 8648a253d6aeSmrg *) 8649a253d6aeSmrg if test "$mode" = clean ; then 8650a253d6aeSmrg noexename=$name 8651a253d6aeSmrg case $file in 8652a253d6aeSmrg *.exe) 8653ea133fd7Smrg func_stripname '' '.exe' "$file" 8654ea133fd7Smrg file=$func_stripname_result 8655ea133fd7Smrg func_stripname '' '.exe' "$name" 8656ea133fd7Smrg noexename=$func_stripname_result 8657a253d6aeSmrg # $file with .exe has already been added to rmfiles, 8658a253d6aeSmrg # add $file without .exe 8659a253d6aeSmrg rmfiles="$rmfiles $file" 8660a253d6aeSmrg ;; 8661a253d6aeSmrg esac 8662a253d6aeSmrg # Do a test to see if this is a libtool program. 8663ea133fd7Smrg if func_ltwrapper_p "$file"; then 8664ea133fd7Smrg if func_ltwrapper_executable_p "$file"; then 8665ea133fd7Smrg func_ltwrapper_scriptname "$file" 8666ea133fd7Smrg relink_command= 8667ea133fd7Smrg func_source $func_ltwrapper_scriptname_result 8668ea133fd7Smrg rmfiles="$rmfiles $func_ltwrapper_scriptname_result" 8669ea133fd7Smrg else 8670ea133fd7Smrg relink_command= 8671ea133fd7Smrg func_source $dir/$noexename 8672ea133fd7Smrg fi 8673a253d6aeSmrg 8674a253d6aeSmrg # note $name still contains .exe if it was in $file originally 8675a253d6aeSmrg # as does the version of $file that was added into $rmfiles 8676a253d6aeSmrg rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" 8677a253d6aeSmrg if test "$fast_install" = yes && test -n "$relink_command"; then 8678a253d6aeSmrg rmfiles="$rmfiles $objdir/lt-$name" 8679a253d6aeSmrg fi 8680a253d6aeSmrg if test "X$noexename" != "X$name" ; then 8681a253d6aeSmrg rmfiles="$rmfiles $objdir/lt-${noexename}.c" 8682a253d6aeSmrg fi 8683a253d6aeSmrg fi 8684a253d6aeSmrg fi 8685a253d6aeSmrg ;; 8686a253d6aeSmrg esac 8687ea133fd7Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 8688a253d6aeSmrg done 8689a253d6aeSmrg objdir="$origobjdir" 8690a253d6aeSmrg 8691a253d6aeSmrg # Try to remove the ${objdir}s in the directories where we deleted files 8692a253d6aeSmrg for dir in $rmdirs; do 8693a253d6aeSmrg if test -d "$dir"; then 8694ea133fd7Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 8695a253d6aeSmrg fi 8696a253d6aeSmrg done 8697a253d6aeSmrg 8698a253d6aeSmrg exit $exit_status 8699ea133fd7Smrg} 8700a253d6aeSmrg 8701ea133fd7Smrg{ test "$mode" = uninstall || test "$mode" = clean; } && 8702ea133fd7Smrg func_mode_uninstall ${1+"$@"} 8703a253d6aeSmrg 8704ea133fd7Smrgtest -z "$mode" && { 8705ea133fd7Smrg help="$generic_help" 8706ea133fd7Smrg func_fatal_help "you must specify a MODE" 8707ea133fd7Smrg} 8708ea133fd7Smrg 8709ea133fd7Smrgtest -z "$exec_cmd" && \ 8710ea133fd7Smrg func_fatal_help "invalid operation mode \`$mode'" 8711a253d6aeSmrg 8712a253d6aeSmrgif test -n "$exec_cmd"; then 8713ea133fd7Smrg eval exec "$exec_cmd" 8714a253d6aeSmrg exit $EXIT_FAILURE 8715a253d6aeSmrgfi 8716a253d6aeSmrg 8717ea133fd7Smrgexit $exit_status 8718a253d6aeSmrg 8719a253d6aeSmrg 8720a253d6aeSmrg# The TAGs below are defined such that we never get into a situation 8721a253d6aeSmrg# in which we disable both kinds of libraries. Given conflicting 8722a253d6aeSmrg# choices, we go for a static library, that is the most portable, 8723a253d6aeSmrg# since we can't tell whether shared libraries were disabled because 8724a253d6aeSmrg# the user asked for that or because the platform doesn't support 8725a253d6aeSmrg# them. This is particularly important on AIX, because we don't 8726a253d6aeSmrg# support having both static and shared libraries enabled at the same 8727a253d6aeSmrg# time on that platform, so we default to a shared-only configuration. 8728a253d6aeSmrg# If a disable-shared tag is given, we'll fallback to a static-only 8729a253d6aeSmrg# configuration. But we'll never go from static-only to shared-only. 8730a253d6aeSmrg 8731a253d6aeSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 8732ea133fd7Smrgbuild_libtool_libs=no 8733ea133fd7Smrgbuild_old_libs=yes 8734a253d6aeSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 8735a253d6aeSmrg 8736a253d6aeSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 8737ea133fd7Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 8738a253d6aeSmrg# ### END LIBTOOL TAG CONFIG: disable-static 8739a253d6aeSmrg 8740a253d6aeSmrg# Local Variables: 8741a253d6aeSmrg# mode:shell-script 8742a253d6aeSmrg# sh-indentation:2 8743a253d6aeSmrg# End: 8744ea133fd7Smrg# vi:sw=2 8745ea133fd7Smrg 8746