ltmain.sh revision 63847c39
163847c39Smrg 263847c39Smrg# libtool (GNU libtool) 2.4.2 363847c39Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 463847c39Smrg 5d8556812Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 663847c39Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 763847c39Smrg# This is free software; see the source for copying conditions. There is NO 863847c39Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 963847c39Smrg 1063847c39Smrg# GNU Libtool is free software; you can redistribute it and/or modify 1176888252Smrg# it under the terms of the GNU General Public License as published by 1276888252Smrg# the Free Software Foundation; either version 2 of the License, or 1376888252Smrg# (at your option) any later version. 1476888252Smrg# 1563847c39Smrg# As a special exception to the GNU General Public License, 1663847c39Smrg# if you distribute this file as part of a program or library that 1763847c39Smrg# is built using GNU Libtool, you may include this file under the 1863847c39Smrg# same distribution terms that you use for the rest of that program. 1963847c39Smrg# 2063847c39Smrg# GNU Libtool is distributed in the hope that it will be useful, but 2176888252Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 2276888252Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2376888252Smrg# General Public License for more details. 2476888252Smrg# 2576888252Smrg# You should have received a copy of the GNU General Public License 2663847c39Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 2763847c39Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 2863847c39Smrg# or obtained by writing to the Free Software Foundation, Inc., 2963847c39Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30d8556812Smrg 3163847c39Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 3263847c39Smrg# 3363847c39Smrg# Provide generalized library-building support services. 3463847c39Smrg# 3563847c39Smrg# --config show all configuration variables 3663847c39Smrg# --debug enable verbose shell tracing 3763847c39Smrg# -n, --dry-run display commands without modifying any files 3863847c39Smrg# --features display basic configuration information and exit 3963847c39Smrg# --mode=MODE use operation mode MODE 4063847c39Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 4163847c39Smrg# --quiet, --silent don't print informational messages 4263847c39Smrg# --no-quiet, --no-silent 4363847c39Smrg# print informational messages (default) 4463847c39Smrg# --no-warn don't display warning messages 4563847c39Smrg# --tag=TAG use configuration variables from tag TAG 4663847c39Smrg# -v, --verbose print more informational messages than default 4763847c39Smrg# --no-verbose don't print the extra informational messages 4863847c39Smrg# --version print version information 4963847c39Smrg# -h, --help, --help-all print short, long, or detailed help message 5063847c39Smrg# 5163847c39Smrg# MODE must be one of the following: 5263847c39Smrg# 5363847c39Smrg# clean remove files from the build directory 5463847c39Smrg# compile compile a source file into a libtool object 5563847c39Smrg# execute automatically set library path, then run a program 5663847c39Smrg# finish complete the installation of libtool libraries 5763847c39Smrg# install install libraries or executables 5863847c39Smrg# link create a library or an executable 5963847c39Smrg# uninstall remove libraries from an installed directory 6063847c39Smrg# 6163847c39Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 6263847c39Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 6363847c39Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 6463847c39Smrg# 6563847c39Smrg# When reporting a bug, please describe a test case to reproduce it and 6663847c39Smrg# include the following information: 6763847c39Smrg# 6863847c39Smrg# host-triplet: $host 6963847c39Smrg# shell: $SHELL 7063847c39Smrg# compiler: $LTCC 7163847c39Smrg# compiler flags: $LTCFLAGS 7263847c39Smrg# linker: $LD (gnu? $with_gnu_ld) 7363847c39Smrg# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 7463847c39Smrg# automake: $automake_version 7563847c39Smrg# autoconf: $autoconf_version 7663847c39Smrg# 7763847c39Smrg# Report bugs to <bug-libtool@gnu.org>. 7863847c39Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 7963847c39Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 8086dafe34Smrg 8163847c39SmrgPROGRAM=libtool 8286dafe34SmrgPACKAGE=libtool 8363847c39SmrgVERSION="2.4.2 Debian-2.4.2-1ubuntu1" 8463847c39SmrgTIMESTAMP="" 8563847c39Smrgpackage_revision=1.3337 8686dafe34Smrg 8763847c39Smrg# Be Bourne compatible 8886dafe34Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 8986dafe34Smrg emulate sh 9086dafe34Smrg NULLCMD=: 9186dafe34Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 9286dafe34Smrg # is contrary to our usage. Disable this feature. 9386dafe34Smrg alias -g '${1+"$@"}'='"$@"' 9486dafe34Smrg setopt NO_GLOB_SUBST 9586dafe34Smrgelse 9686dafe34Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 9786dafe34Smrgfi 9886dafe34SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 9986dafe34SmrgDUALCASE=1; export DUALCASE # for MKS sh 10086dafe34Smrg 10163847c39Smrg# A function that is used when there is no print builtin or printf. 10263847c39Smrgfunc_fallback_echo () 10363847c39Smrg{ 10463847c39Smrg eval 'cat <<_LTECHO_EOF 10563847c39Smrg$1 10663847c39Smrg_LTECHO_EOF' 10763847c39Smrg} 108d8556812Smrg 10963847c39Smrg# NLS nuisances: We save the old values to restore during execute mode. 11063847c39Smrglt_user_locale= 11163847c39Smrglt_safe_locale= 11286dafe34Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 11386dafe34Smrgdo 11486dafe34Smrg eval "if test \"\${$lt_var+set}\" = set; then 11563847c39Smrg save_$lt_var=\$$lt_var 11663847c39Smrg $lt_var=C 11786dafe34Smrg export $lt_var 11863847c39Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 11963847c39Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 12086dafe34Smrg fi" 12186dafe34Smrgdone 12263847c39SmrgLC_ALL=C 12363847c39SmrgLANGUAGE=C 12463847c39Smrgexport LANGUAGE LC_ALL 12563847c39Smrg 12663847c39Smrg$lt_unset CDPATH 12786dafe34Smrg 12863847c39Smrg 12963847c39Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 13063847c39Smrg# is ksh but when the shell is invoked as "sh" and the current value of 13163847c39Smrg# the _XPG environment variable is not equal to 1 (one), the special 13263847c39Smrg# positional parameter $0, within a function call, is the name of the 13363847c39Smrg# function. 13463847c39Smrgprogpath="$0" 13563847c39Smrg 13663847c39Smrg 13763847c39Smrg 13863847c39Smrg: ${CP="cp -f"} 13963847c39Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 14063847c39Smrg: ${MAKE="make"} 14163847c39Smrg: ${MKDIR="mkdir"} 14263847c39Smrg: ${MV="mv -f"} 14363847c39Smrg: ${RM="rm -f"} 14463847c39Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 14563847c39Smrg: ${Xsed="$SED -e 1s/^X//"} 14663847c39Smrg 14763847c39Smrg# Global variables: 14863847c39SmrgEXIT_SUCCESS=0 14963847c39SmrgEXIT_FAILURE=1 15063847c39SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 15163847c39SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 15263847c39Smrg 15363847c39Smrgexit_status=$EXIT_SUCCESS 15486dafe34Smrg 15586dafe34Smrg# Make sure IFS has a sensible default 15686dafe34Smrglt_nl=' 15786dafe34Smrg' 15886dafe34SmrgIFS=" $lt_nl" 15986dafe34Smrg 16063847c39Smrgdirname="s,/[^/]*$,," 16163847c39Smrgbasename="s,^.*/,," 16286dafe34Smrg 16363847c39Smrg# func_dirname file append nondir_replacement 16463847c39Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 16563847c39Smrg# otherwise set result to NONDIR_REPLACEMENT. 16663847c39Smrgfunc_dirname () 16763847c39Smrg{ 16863847c39Smrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 16963847c39Smrg if test "X$func_dirname_result" = "X${1}"; then 17063847c39Smrg func_dirname_result="${3}" 17163847c39Smrg else 17263847c39Smrg func_dirname_result="$func_dirname_result${2}" 17363847c39Smrg fi 17463847c39Smrg} # func_dirname may be replaced by extended shell implementation 17563847c39Smrg 17663847c39Smrg 17763847c39Smrg# func_basename file 17863847c39Smrgfunc_basename () 17963847c39Smrg{ 18063847c39Smrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 18163847c39Smrg} # func_basename may be replaced by extended shell implementation 18263847c39Smrg 18363847c39Smrg 18463847c39Smrg# func_dirname_and_basename file append nondir_replacement 18563847c39Smrg# perform func_basename and func_dirname in a single function 18663847c39Smrg# call: 18763847c39Smrg# dirname: Compute the dirname of FILE. If nonempty, 18863847c39Smrg# add APPEND to the result, otherwise set result 18963847c39Smrg# to NONDIR_REPLACEMENT. 19063847c39Smrg# value returned in "$func_dirname_result" 19163847c39Smrg# basename: Compute filename of FILE. 19263847c39Smrg# value retuned in "$func_basename_result" 19363847c39Smrg# Implementation must be kept synchronized with func_dirname 19463847c39Smrg# and func_basename. For efficiency, we do not delegate to 19563847c39Smrg# those functions but instead duplicate the functionality here. 19663847c39Smrgfunc_dirname_and_basename () 19763847c39Smrg{ 19863847c39Smrg # Extract subdirectory from the argument. 19963847c39Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 20063847c39Smrg if test "X$func_dirname_result" = "X${1}"; then 20163847c39Smrg func_dirname_result="${3}" 20263847c39Smrg else 20363847c39Smrg func_dirname_result="$func_dirname_result${2}" 20463847c39Smrg fi 20563847c39Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 20663847c39Smrg} # func_dirname_and_basename may be replaced by extended shell implementation 20763847c39Smrg 20863847c39Smrg 20963847c39Smrg# func_stripname prefix suffix name 21063847c39Smrg# strip PREFIX and SUFFIX off of NAME. 21163847c39Smrg# PREFIX and SUFFIX must not contain globbing or regex special 21263847c39Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 21363847c39Smrg# dot (in which case that matches only a dot). 21463847c39Smrg# func_strip_suffix prefix name 21563847c39Smrgfunc_stripname () 21663847c39Smrg{ 21763847c39Smrg case ${2} in 21863847c39Smrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 21963847c39Smrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 22063847c39Smrg esac 22163847c39Smrg} # func_stripname may be replaced by extended shell implementation 22263847c39Smrg 22363847c39Smrg 22463847c39Smrg# These SED scripts presuppose an absolute path with a trailing slash. 22563847c39Smrgpathcar='s,^/\([^/]*\).*$,\1,' 22663847c39Smrgpathcdr='s,^/[^/]*,,' 22763847c39Smrgremovedotparts=':dotsl 22863847c39Smrg s@/\./@/@g 22963847c39Smrg t dotsl 23063847c39Smrg s,/\.$,/,' 23163847c39Smrgcollapseslashes='s@/\{1,\}@/@g' 23263847c39Smrgfinalslash='s,/*$,/,' 23363847c39Smrg 23463847c39Smrg# func_normal_abspath PATH 23563847c39Smrg# Remove doubled-up and trailing slashes, "." path components, 23663847c39Smrg# and cancel out any ".." path components in PATH after making 23763847c39Smrg# it an absolute path. 23863847c39Smrg# value returned in "$func_normal_abspath_result" 23963847c39Smrgfunc_normal_abspath () 24063847c39Smrg{ 24163847c39Smrg # Start from root dir and reassemble the path. 24263847c39Smrg func_normal_abspath_result= 24363847c39Smrg func_normal_abspath_tpath=$1 24463847c39Smrg func_normal_abspath_altnamespace= 24563847c39Smrg case $func_normal_abspath_tpath in 24663847c39Smrg "") 24763847c39Smrg # Empty path, that just means $cwd. 24863847c39Smrg func_stripname '' '/' "`pwd`" 24963847c39Smrg func_normal_abspath_result=$func_stripname_result 25063847c39Smrg return 25163847c39Smrg ;; 25263847c39Smrg # The next three entries are used to spot a run of precisely 25363847c39Smrg # two leading slashes without using negated character classes; 25463847c39Smrg # we take advantage of case's first-match behaviour. 25563847c39Smrg ///*) 25663847c39Smrg # Unusual form of absolute path, do nothing. 25763847c39Smrg ;; 25863847c39Smrg //*) 25963847c39Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 26063847c39Smrg # and for example Cygwin uses it to access remote file shares 26163847c39Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 26263847c39Smrg func_normal_abspath_altnamespace=/ 26363847c39Smrg ;; 26463847c39Smrg /*) 26563847c39Smrg # Absolute path, do nothing. 26663847c39Smrg ;; 26763847c39Smrg *) 26863847c39Smrg # Relative path, prepend $cwd. 26963847c39Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 27063847c39Smrg ;; 27163847c39Smrg esac 27263847c39Smrg # Cancel out all the simple stuff to save iterations. We also want 27363847c39Smrg # the path to end with a slash for ease of parsing, so make sure 27463847c39Smrg # there is one (and only one) here. 27563847c39Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 27663847c39Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 27763847c39Smrg while :; do 27863847c39Smrg # Processed it all yet? 27963847c39Smrg if test "$func_normal_abspath_tpath" = / ; then 28063847c39Smrg # If we ascended to the root using ".." the result may be empty now. 28163847c39Smrg if test -z "$func_normal_abspath_result" ; then 28263847c39Smrg func_normal_abspath_result=/ 28363847c39Smrg fi 28463847c39Smrg break 28563847c39Smrg fi 28663847c39Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 28763847c39Smrg -e "$pathcar"` 28863847c39Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 28963847c39Smrg -e "$pathcdr"` 29063847c39Smrg # Figure out what to do with it 29163847c39Smrg case $func_normal_abspath_tcomponent in 29263847c39Smrg "") 29363847c39Smrg # Trailing empty path component, ignore it. 29463847c39Smrg ;; 29563847c39Smrg ..) 29663847c39Smrg # Parent dir; strip last assembled component from result. 29763847c39Smrg func_dirname "$func_normal_abspath_result" 29863847c39Smrg func_normal_abspath_result=$func_dirname_result 29963847c39Smrg ;; 30063847c39Smrg *) 30163847c39Smrg # Actual path component, append it. 30263847c39Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 30363847c39Smrg ;; 30463847c39Smrg esac 30563847c39Smrg done 30663847c39Smrg # Restore leading double-slash if one was found on entry. 30763847c39Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 30863847c39Smrg} 30963847c39Smrg 31063847c39Smrg# func_relative_path SRCDIR DSTDIR 31163847c39Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 31263847c39Smrg# slash if non-empty, suitable for immediately appending a filename 31363847c39Smrg# without needing to append a separator. 31463847c39Smrg# value returned in "$func_relative_path_result" 31563847c39Smrgfunc_relative_path () 31663847c39Smrg{ 31763847c39Smrg func_relative_path_result= 31863847c39Smrg func_normal_abspath "$1" 31963847c39Smrg func_relative_path_tlibdir=$func_normal_abspath_result 32063847c39Smrg func_normal_abspath "$2" 32163847c39Smrg func_relative_path_tbindir=$func_normal_abspath_result 32263847c39Smrg 32363847c39Smrg # Ascend the tree starting from libdir 32463847c39Smrg while :; do 32563847c39Smrg # check if we have found a prefix of bindir 32663847c39Smrg case $func_relative_path_tbindir in 32763847c39Smrg $func_relative_path_tlibdir) 32863847c39Smrg # found an exact match 32963847c39Smrg func_relative_path_tcancelled= 33063847c39Smrg break 33163847c39Smrg ;; 33263847c39Smrg $func_relative_path_tlibdir*) 33363847c39Smrg # found a matching prefix 33463847c39Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 33563847c39Smrg func_relative_path_tcancelled=$func_stripname_result 33663847c39Smrg if test -z "$func_relative_path_result"; then 33763847c39Smrg func_relative_path_result=. 33863847c39Smrg fi 33963847c39Smrg break 34063847c39Smrg ;; 34163847c39Smrg *) 34263847c39Smrg func_dirname $func_relative_path_tlibdir 34363847c39Smrg func_relative_path_tlibdir=${func_dirname_result} 34463847c39Smrg if test "x$func_relative_path_tlibdir" = x ; then 34563847c39Smrg # Have to descend all the way to the root! 34663847c39Smrg func_relative_path_result=../$func_relative_path_result 34763847c39Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 34863847c39Smrg break 34963847c39Smrg fi 35063847c39Smrg func_relative_path_result=../$func_relative_path_result 35163847c39Smrg ;; 35263847c39Smrg esac 35363847c39Smrg done 35463847c39Smrg 35563847c39Smrg # Now calculate path; take care to avoid doubling-up slashes. 35663847c39Smrg func_stripname '' '/' "$func_relative_path_result" 35763847c39Smrg func_relative_path_result=$func_stripname_result 35863847c39Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 35963847c39Smrg if test "x$func_stripname_result" != x ; then 36063847c39Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 36163847c39Smrg fi 36263847c39Smrg 36363847c39Smrg # Normalisation. If bindir is libdir, return empty string, 36463847c39Smrg # else relative path ending with a slash; either way, target 36563847c39Smrg # file name can be directly appended. 36663847c39Smrg if test ! -z "$func_relative_path_result"; then 36763847c39Smrg func_stripname './' '' "$func_relative_path_result/" 36863847c39Smrg func_relative_path_result=$func_stripname_result 36963847c39Smrg fi 37063847c39Smrg} 37163847c39Smrg 37263847c39Smrg# The name of this program: 37363847c39Smrgfunc_dirname_and_basename "$progpath" 37463847c39Smrgprogname=$func_basename_result 37563847c39Smrg 37663847c39Smrg# Make sure we have an absolute path for reexecution: 37763847c39Smrgcase $progpath in 37863847c39Smrg [\\/]*|[A-Za-z]:\\*) ;; 37963847c39Smrg *[\\/]*) 38063847c39Smrg progdir=$func_dirname_result 38163847c39Smrg progdir=`cd "$progdir" && pwd` 38263847c39Smrg progpath="$progdir/$progname" 38363847c39Smrg ;; 38463847c39Smrg *) 38563847c39Smrg save_IFS="$IFS" 38663847c39Smrg IFS=${PATH_SEPARATOR-:} 38763847c39Smrg for progdir in $PATH; do 38863847c39Smrg IFS="$save_IFS" 38963847c39Smrg test -x "$progdir/$progname" && break 39063847c39Smrg done 39163847c39Smrg IFS="$save_IFS" 39263847c39Smrg test -n "$progdir" || progdir=`pwd` 39363847c39Smrg progpath="$progdir/$progname" 39463847c39Smrg ;; 39563847c39Smrgesac 39663847c39Smrg 39763847c39Smrg# Sed substitution that helps us do robust quoting. It backslashifies 39863847c39Smrg# metacharacters that are still active within double-quoted strings. 39963847c39SmrgXsed="${SED}"' -e 1s/^X//' 40063847c39Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 40163847c39Smrg 40263847c39Smrg# Same as above, but do not quote variable references. 40363847c39Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 40463847c39Smrg 40563847c39Smrg# Sed substitution that turns a string into a regex matching for the 40663847c39Smrg# string literally. 40763847c39Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 40863847c39Smrg 40963847c39Smrg# Sed substitution that converts a w32 file name or path 41063847c39Smrg# which contains forward slashes, into one that contains 41163847c39Smrg# (escaped) backslashes. A very naive implementation. 41263847c39Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 41363847c39Smrg 41463847c39Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 41563847c39Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 41663847c39Smrg# in input to double_quote_subst, that '$' was protected from expansion. 41763847c39Smrg# Since each input `\' is now two `\'s, look for any number of runs of 41863847c39Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 41963847c39Smrgbs='\\' 42063847c39Smrgbs2='\\\\' 42163847c39Smrgbs4='\\\\\\\\' 42263847c39Smrgdollar='\$' 42363847c39Smrgsed_double_backslash="\ 42463847c39Smrg s/$bs4/&\\ 42563847c39Smrg/g 42663847c39Smrg s/^$bs2$dollar/$bs&/ 42763847c39Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 42863847c39Smrg s/\n//g" 42963847c39Smrg 43063847c39Smrg# Standard options: 43163847c39Smrgopt_dry_run=false 43263847c39Smrgopt_help=false 43363847c39Smrgopt_quiet=false 43463847c39Smrgopt_verbose=false 43563847c39Smrgopt_warning=: 43663847c39Smrg 43763847c39Smrg# func_echo arg... 43863847c39Smrg# Echo program name prefixed message, along with the current mode 43963847c39Smrg# name if it has been set yet. 44063847c39Smrgfunc_echo () 44163847c39Smrg{ 44263847c39Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 44363847c39Smrg} 44463847c39Smrg 44563847c39Smrg# func_verbose arg... 44663847c39Smrg# Echo program name prefixed message in verbose mode only. 44763847c39Smrgfunc_verbose () 44863847c39Smrg{ 44963847c39Smrg $opt_verbose && func_echo ${1+"$@"} 45063847c39Smrg 45163847c39Smrg # A bug in bash halts the script if the last line of a function 45263847c39Smrg # fails when set -e is in force, so we need another command to 45363847c39Smrg # work around that: 45463847c39Smrg : 45563847c39Smrg} 45663847c39Smrg 45763847c39Smrg# func_echo_all arg... 45863847c39Smrg# Invoke $ECHO with all args, space-separated. 45963847c39Smrgfunc_echo_all () 46063847c39Smrg{ 46163847c39Smrg $ECHO "$*" 46263847c39Smrg} 46363847c39Smrg 46463847c39Smrg# func_error arg... 46563847c39Smrg# Echo program name prefixed message to standard error. 46663847c39Smrgfunc_error () 46763847c39Smrg{ 46863847c39Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 46963847c39Smrg} 47063847c39Smrg 47163847c39Smrg# func_warning arg... 47263847c39Smrg# Echo program name prefixed warning message to standard error. 47363847c39Smrgfunc_warning () 47463847c39Smrg{ 47563847c39Smrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 47663847c39Smrg 47763847c39Smrg # bash bug again: 47863847c39Smrg : 47963847c39Smrg} 48063847c39Smrg 48163847c39Smrg# func_fatal_error arg... 48263847c39Smrg# Echo program name prefixed message to standard error, and exit. 48363847c39Smrgfunc_fatal_error () 48463847c39Smrg{ 48563847c39Smrg func_error ${1+"$@"} 48663847c39Smrg exit $EXIT_FAILURE 48763847c39Smrg} 48863847c39Smrg 48963847c39Smrg# func_fatal_help arg... 49063847c39Smrg# Echo program name prefixed message to standard error, followed by 49163847c39Smrg# a help hint, and exit. 49263847c39Smrgfunc_fatal_help () 49363847c39Smrg{ 49463847c39Smrg func_error ${1+"$@"} 49563847c39Smrg func_fatal_error "$help" 49663847c39Smrg} 49763847c39Smrghelp="Try \`$progname --help' for more information." ## default 49863847c39Smrg 49963847c39Smrg 50063847c39Smrg# func_grep expression filename 50163847c39Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 50263847c39Smrgfunc_grep () 50363847c39Smrg{ 50463847c39Smrg $GREP "$1" "$2" >/dev/null 2>&1 50563847c39Smrg} 50663847c39Smrg 50763847c39Smrg 50863847c39Smrg# func_mkdir_p directory-path 50963847c39Smrg# Make sure the entire path to DIRECTORY-PATH is available. 51063847c39Smrgfunc_mkdir_p () 51163847c39Smrg{ 51263847c39Smrg my_directory_path="$1" 51363847c39Smrg my_dir_list= 51463847c39Smrg 51563847c39Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 51663847c39Smrg 51763847c39Smrg # Protect directory names starting with `-' 51863847c39Smrg case $my_directory_path in 51963847c39Smrg -*) my_directory_path="./$my_directory_path" ;; 52063847c39Smrg esac 52163847c39Smrg 52263847c39Smrg # While some portion of DIR does not yet exist... 52363847c39Smrg while test ! -d "$my_directory_path"; do 52463847c39Smrg # ...make a list in topmost first order. Use a colon delimited 52563847c39Smrg # list incase some portion of path contains whitespace. 52663847c39Smrg my_dir_list="$my_directory_path:$my_dir_list" 52763847c39Smrg 52863847c39Smrg # If the last portion added has no slash in it, the list is done 52963847c39Smrg case $my_directory_path in */*) ;; *) break ;; esac 53063847c39Smrg 53163847c39Smrg # ...otherwise throw away the child directory and loop 53263847c39Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 53363847c39Smrg done 53463847c39Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 53563847c39Smrg 53663847c39Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 53763847c39Smrg for my_dir in $my_dir_list; do 53863847c39Smrg IFS="$save_mkdir_p_IFS" 53963847c39Smrg # mkdir can fail with a `File exist' error if two processes 54063847c39Smrg # try to create one of the directories concurrently. Don't 54163847c39Smrg # stop in that case! 54263847c39Smrg $MKDIR "$my_dir" 2>/dev/null || : 54363847c39Smrg done 54463847c39Smrg IFS="$save_mkdir_p_IFS" 54563847c39Smrg 54663847c39Smrg # Bail out if we (or some other process) failed to create a directory. 54763847c39Smrg test -d "$my_directory_path" || \ 54863847c39Smrg func_fatal_error "Failed to create \`$1'" 54963847c39Smrg fi 55063847c39Smrg} 55176888252Smrg 55276888252Smrg 55376888252Smrg# func_mktempdir [string] 55476888252Smrg# Make a temporary directory that won't clash with other running 55576888252Smrg# libtool processes, and avoids race conditions if possible. If 55676888252Smrg# given, STRING is the basename for that directory. 55776888252Smrgfunc_mktempdir () 55876888252Smrg{ 55976888252Smrg my_template="${TMPDIR-/tmp}/${1-$progname}" 56076888252Smrg 56163847c39Smrg if test "$opt_dry_run" = ":"; then 56276888252Smrg # Return a directory name, but don't create it in dry-run mode 56376888252Smrg my_tmpdir="${my_template}-$$" 56476888252Smrg else 56576888252Smrg 56676888252Smrg # If mktemp works, use that first and foremost 56776888252Smrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 56876888252Smrg 56976888252Smrg if test ! -d "$my_tmpdir"; then 57063847c39Smrg # Failing that, at least try and use $RANDOM to avoid a race 57163847c39Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 57276888252Smrg 57363847c39Smrg save_mktempdir_umask=`umask` 57463847c39Smrg umask 0077 57563847c39Smrg $MKDIR "$my_tmpdir" 57663847c39Smrg umask $save_mktempdir_umask 57776888252Smrg fi 57876888252Smrg 57976888252Smrg # If we're not in dry-run mode, bomb out on failure 58063847c39Smrg test -d "$my_tmpdir" || \ 58163847c39Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 58276888252Smrg fi 58376888252Smrg 58463847c39Smrg $ECHO "$my_tmpdir" 58576888252Smrg} 58676888252Smrg 58776888252Smrg 58863847c39Smrg# func_quote_for_eval arg 58963847c39Smrg# Aesthetically quote ARG to be evaled later. 59063847c39Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 59163847c39Smrg# is double-quoted, suitable for a subsequent eval, whereas 59263847c39Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 59363847c39Smrg# which are still active within double quotes backslashified. 59463847c39Smrgfunc_quote_for_eval () 59576888252Smrg{ 59663847c39Smrg case $1 in 59763847c39Smrg *[\\\`\"\$]*) 59863847c39Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 59963847c39Smrg *) 60063847c39Smrg func_quote_for_eval_unquoted_result="$1" ;; 60163847c39Smrg esac 60263847c39Smrg 60363847c39Smrg case $func_quote_for_eval_unquoted_result in 60463847c39Smrg # Double-quote args containing shell metacharacters to delay 60563847c39Smrg # word splitting, command substitution and and variable 60663847c39Smrg # expansion for a subsequent eval. 60763847c39Smrg # Many Bourne shells cannot handle close brackets correctly 60863847c39Smrg # in scan sets, so we specify it separately. 60963847c39Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 61063847c39Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 61163847c39Smrg ;; 61263847c39Smrg *) 61363847c39Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 61463847c39Smrg esac 61563847c39Smrg} 61663847c39Smrg 61763847c39Smrg 61863847c39Smrg# func_quote_for_expand arg 61963847c39Smrg# Aesthetically quote ARG to be evaled later; same as above, 62063847c39Smrg# but do not quote variable references. 62163847c39Smrgfunc_quote_for_expand () 62263847c39Smrg{ 62363847c39Smrg case $1 in 62463847c39Smrg *[\\\`\"]*) 62563847c39Smrg my_arg=`$ECHO "$1" | $SED \ 62663847c39Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 62763847c39Smrg *) 62863847c39Smrg my_arg="$1" ;; 62963847c39Smrg esac 63063847c39Smrg 63163847c39Smrg case $my_arg in 63263847c39Smrg # Double-quote args containing shell metacharacters to delay 63363847c39Smrg # word splitting and command substitution for a subsequent eval. 63463847c39Smrg # Many Bourne shells cannot handle close brackets correctly 63563847c39Smrg # in scan sets, so we specify it separately. 63663847c39Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 63763847c39Smrg my_arg="\"$my_arg\"" 63863847c39Smrg ;; 63963847c39Smrg esac 64063847c39Smrg 64163847c39Smrg func_quote_for_expand_result="$my_arg" 64263847c39Smrg} 64363847c39Smrg 64463847c39Smrg 64563847c39Smrg# func_show_eval cmd [fail_exp] 64663847c39Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 64763847c39Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 64863847c39Smrg# is given, then evaluate it. 64963847c39Smrgfunc_show_eval () 65063847c39Smrg{ 65163847c39Smrg my_cmd="$1" 65263847c39Smrg my_fail_exp="${2-:}" 65363847c39Smrg 65463847c39Smrg ${opt_silent-false} || { 65563847c39Smrg func_quote_for_expand "$my_cmd" 65663847c39Smrg eval "func_echo $func_quote_for_expand_result" 65763847c39Smrg } 65863847c39Smrg 65963847c39Smrg if ${opt_dry_run-false}; then :; else 66063847c39Smrg eval "$my_cmd" 66163847c39Smrg my_status=$? 66263847c39Smrg if test "$my_status" -eq 0; then :; else 66363847c39Smrg eval "(exit $my_status); $my_fail_exp" 66463847c39Smrg fi 665d8556812Smrg fi 66663847c39Smrg} 66763847c39Smrg 66863847c39Smrg 66963847c39Smrg# func_show_eval_locale cmd [fail_exp] 67063847c39Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 67163847c39Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 67263847c39Smrg# is given, then evaluate it. Use the saved locale for evaluation. 67363847c39Smrgfunc_show_eval_locale () 67463847c39Smrg{ 67563847c39Smrg my_cmd="$1" 67663847c39Smrg my_fail_exp="${2-:}" 67763847c39Smrg 67863847c39Smrg ${opt_silent-false} || { 67963847c39Smrg func_quote_for_expand "$my_cmd" 68063847c39Smrg eval "func_echo $func_quote_for_expand_result" 68163847c39Smrg } 68263847c39Smrg 68363847c39Smrg if ${opt_dry_run-false}; then :; else 68463847c39Smrg eval "$lt_user_locale 68563847c39Smrg $my_cmd" 68663847c39Smrg my_status=$? 68763847c39Smrg eval "$lt_safe_locale" 68863847c39Smrg if test "$my_status" -eq 0; then :; else 68963847c39Smrg eval "(exit $my_status); $my_fail_exp" 69063847c39Smrg fi 69163847c39Smrg fi 69263847c39Smrg} 69363847c39Smrg 69463847c39Smrg# func_tr_sh 69563847c39Smrg# Turn $1 into a string suitable for a shell variable name. 69663847c39Smrg# Result is stored in $func_tr_sh_result. All characters 69763847c39Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 69863847c39Smrg# if $1 begins with a digit, a '_' is prepended as well. 69963847c39Smrgfunc_tr_sh () 70063847c39Smrg{ 70163847c39Smrg case $1 in 70263847c39Smrg [0-9]* | *[!a-zA-Z0-9_]*) 70363847c39Smrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 704d8556812Smrg ;; 70563847c39Smrg * ) 70663847c39Smrg func_tr_sh_result=$1 707d8556812Smrg ;; 708d8556812Smrg esac 70976888252Smrg} 71076888252Smrg 71176888252Smrg 71263847c39Smrg# func_version 71363847c39Smrg# Echo version message to standard output and exit. 71463847c39Smrgfunc_version () 71576888252Smrg{ 71663847c39Smrg $opt_debug 71763847c39Smrg 71863847c39Smrg $SED -n '/(C)/!b go 71963847c39Smrg :more 72063847c39Smrg /\./!{ 72163847c39Smrg N 72263847c39Smrg s/\n# / / 72363847c39Smrg b more 72463847c39Smrg } 72563847c39Smrg :go 72663847c39Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 72763847c39Smrg s/^# // 72863847c39Smrg s/^# *$// 72963847c39Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 73063847c39Smrg p 73163847c39Smrg }' < "$progpath" 73263847c39Smrg exit $? 73376888252Smrg} 73476888252Smrg 73563847c39Smrg# func_usage 73663847c39Smrg# Echo short help message to standard output and exit. 73763847c39Smrgfunc_usage () 73876888252Smrg{ 73963847c39Smrg $opt_debug 74063847c39Smrg 74163847c39Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 74263847c39Smrg s/^# // 74363847c39Smrg s/^# *$// 74463847c39Smrg s/\$progname/'$progname'/ 74563847c39Smrg p 74663847c39Smrg }' < "$progpath" 74763847c39Smrg echo 74863847c39Smrg $ECHO "run \`$progname --help | more' for full usage" 74963847c39Smrg exit $? 75076888252Smrg} 75176888252Smrg 75263847c39Smrg# func_help [NOEXIT] 75363847c39Smrg# Echo long help message to standard output and exit, 75463847c39Smrg# unless 'noexit' is passed as argument. 75563847c39Smrgfunc_help () 75676888252Smrg{ 75763847c39Smrg $opt_debug 75863847c39Smrg 75963847c39Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 76063847c39Smrg :print 76163847c39Smrg s/^# // 76263847c39Smrg s/^# *$// 76363847c39Smrg s*\$progname*'$progname'* 76463847c39Smrg s*\$host*'"$host"'* 76563847c39Smrg s*\$SHELL*'"$SHELL"'* 76663847c39Smrg s*\$LTCC*'"$LTCC"'* 76763847c39Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 76863847c39Smrg s*\$LD*'"$LD"'* 76963847c39Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 77063847c39Smrg s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 77163847c39Smrg s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 77263847c39Smrg p 77363847c39Smrg d 77463847c39Smrg } 77563847c39Smrg /^# .* home page:/b print 77663847c39Smrg /^# General help using/b print 77763847c39Smrg ' < "$progpath" 77863847c39Smrg ret=$? 77963847c39Smrg if test -z "$1"; then 78063847c39Smrg exit $ret 78186dafe34Smrg fi 78263847c39Smrg} 78376888252Smrg 78463847c39Smrg# func_missing_arg argname 78563847c39Smrg# Echo program name prefixed message to standard error and set global 78663847c39Smrg# exit_cmd. 78763847c39Smrgfunc_missing_arg () 78863847c39Smrg{ 78963847c39Smrg $opt_debug 79076888252Smrg 79163847c39Smrg func_error "missing argument for $1." 79263847c39Smrg exit_cmd=exit 79386dafe34Smrg} 79486dafe34Smrg 79586dafe34Smrg 79663847c39Smrg# func_split_short_opt shortopt 79763847c39Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 79863847c39Smrg# variables after splitting SHORTOPT after the 2nd character. 79963847c39Smrgfunc_split_short_opt () 80063847c39Smrg{ 80163847c39Smrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 80263847c39Smrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 80363847c39Smrg 80463847c39Smrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 80563847c39Smrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 80663847c39Smrg} # func_split_short_opt may be replaced by extended shell implementation 80786dafe34Smrg 80876888252Smrg 80963847c39Smrg# func_split_long_opt longopt 81063847c39Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 81163847c39Smrg# variables after splitting LONGOPT at the `=' sign. 81263847c39Smrgfunc_split_long_opt () 81363847c39Smrg{ 81463847c39Smrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 81563847c39Smrg my_sed_long_arg='1s/^--[^=]*=//' 81676888252Smrg 81763847c39Smrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 81863847c39Smrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 81963847c39Smrg} # func_split_long_opt may be replaced by extended shell implementation 82076888252Smrg 82163847c39Smrgexit_cmd=: 82276888252Smrg 82386dafe34Smrg 82486dafe34Smrg 82586dafe34Smrg 82676888252Smrg 82763847c39Smrgmagic="%%%MAGIC variable%%%" 82863847c39Smrgmagic_exe="%%%MAGIC EXE variable%%%" 82963847c39Smrg 83063847c39Smrg# Global variables. 83163847c39Smrgnonopt= 83263847c39Smrgpreserve_args= 83363847c39Smrglo2o="s/\\.lo\$/.${objext}/" 83463847c39Smrgo2lo="s/\\.${objext}\$/.lo/" 83563847c39Smrgextracted_archives= 83663847c39Smrgextracted_serial=0 83763847c39Smrg 83863847c39Smrg# If this variable is set in any of the actions, the command in it 83963847c39Smrg# will be execed at the end. This prevents here-documents from being 84063847c39Smrg# left over by shells. 84163847c39Smrgexec_cmd= 84263847c39Smrg 84363847c39Smrg# func_append var value 84463847c39Smrg# Append VALUE to the end of shell variable VAR. 84563847c39Smrgfunc_append () 84663847c39Smrg{ 84763847c39Smrg eval "${1}=\$${1}\${2}" 84863847c39Smrg} # func_append may be replaced by extended shell implementation 84963847c39Smrg 85063847c39Smrg# func_append_quoted var value 85163847c39Smrg# Quote VALUE and append to the end of shell variable VAR, separated 85263847c39Smrg# by a space. 85363847c39Smrgfunc_append_quoted () 85463847c39Smrg{ 85563847c39Smrg func_quote_for_eval "${2}" 85663847c39Smrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 85763847c39Smrg} # func_append_quoted may be replaced by extended shell implementation 85863847c39Smrg 85963847c39Smrg 86063847c39Smrg# func_arith arithmetic-term... 86163847c39Smrgfunc_arith () 86263847c39Smrg{ 86363847c39Smrg func_arith_result=`expr "${@}"` 86463847c39Smrg} # func_arith may be replaced by extended shell implementation 86563847c39Smrg 86663847c39Smrg 86763847c39Smrg# func_len string 86863847c39Smrg# STRING may not start with a hyphen. 86963847c39Smrgfunc_len () 87063847c39Smrg{ 87163847c39Smrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 87263847c39Smrg} # func_len may be replaced by extended shell implementation 87363847c39Smrg 87463847c39Smrg 87563847c39Smrg# func_lo2o object 87663847c39Smrgfunc_lo2o () 87763847c39Smrg{ 87863847c39Smrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 87963847c39Smrg} # func_lo2o may be replaced by extended shell implementation 88063847c39Smrg 88163847c39Smrg 88263847c39Smrg# func_xform libobj-or-source 88363847c39Smrgfunc_xform () 88463847c39Smrg{ 88563847c39Smrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 88663847c39Smrg} # func_xform may be replaced by extended shell implementation 88763847c39Smrg 88863847c39Smrg 88963847c39Smrg# func_fatal_configuration arg... 89063847c39Smrg# Echo program name prefixed message to standard error, followed by 89163847c39Smrg# a configuration failure hint, and exit. 89263847c39Smrgfunc_fatal_configuration () 89363847c39Smrg{ 89463847c39Smrg func_error ${1+"$@"} 89563847c39Smrg func_error "See the $PACKAGE documentation for more information." 89663847c39Smrg func_fatal_error "Fatal configuration error." 89763847c39Smrg} 89863847c39Smrg 89963847c39Smrg 90063847c39Smrg# func_config 90163847c39Smrg# Display the configuration for all the tags in this script. 90263847c39Smrgfunc_config () 90363847c39Smrg{ 90463847c39Smrg re_begincf='^# ### BEGIN LIBTOOL' 90563847c39Smrg re_endcf='^# ### END LIBTOOL' 90663847c39Smrg 90763847c39Smrg # Default configuration. 90863847c39Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 90963847c39Smrg 91076888252Smrg # Now print the configurations for the tags. 91176888252Smrg for tagname in $taglist; do 91263847c39Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 91376888252Smrg done 914d8556812Smrg 91563847c39Smrg exit $? 91663847c39Smrg} 917d8556812Smrg 91863847c39Smrg# func_features 91963847c39Smrg# Display the features supported by this script. 92063847c39Smrgfunc_features () 92163847c39Smrg{ 92263847c39Smrg echo "host: $host" 92376888252Smrg if test "$build_libtool_libs" = yes; then 92463847c39Smrg echo "enable shared libraries" 92576888252Smrg else 92663847c39Smrg echo "disable shared libraries" 92776888252Smrg fi 92876888252Smrg if test "$build_old_libs" = yes; then 92963847c39Smrg echo "enable static libraries" 93076888252Smrg else 93163847c39Smrg echo "disable static libraries" 93276888252Smrg fi 93376888252Smrg 93463847c39Smrg exit $? 93563847c39Smrg} 93676888252Smrg 93763847c39Smrg# func_enable_tag tagname 93863847c39Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 93963847c39Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 94063847c39Smrg# variable here. 94163847c39Smrgfunc_enable_tag () 94263847c39Smrg{ 94363847c39Smrg # Global variable: 94463847c39Smrg tagname="$1" 94576888252Smrg 94663847c39Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 94763847c39Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 94863847c39Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 949d8556812Smrg 95063847c39Smrg # Validate tagname. 95163847c39Smrg case $tagname in 95263847c39Smrg *[!-_A-Za-z0-9,/]*) 95363847c39Smrg func_fatal_error "invalid tag name: $tagname" 95463847c39Smrg ;; 95563847c39Smrg esac 956d8556812Smrg 95763847c39Smrg # Don't test for the "default" C tag, as we know it's 95863847c39Smrg # there but not specially marked. 95963847c39Smrg case $tagname in 96063847c39Smrg CC) ;; 96163847c39Smrg *) 96263847c39Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 96363847c39Smrg taglist="$taglist $tagname" 96463847c39Smrg 96563847c39Smrg # Evaluate the configuration. Be careful to quote the path 96663847c39Smrg # and the sed script, to avoid splitting on whitespace, but 96763847c39Smrg # also don't use non-portable quotes within backquotes within 96863847c39Smrg # quotes we have to do it in 2 steps: 96963847c39Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 97063847c39Smrg eval "$extractedcf" 97163847c39Smrg else 97263847c39Smrg func_error "ignoring unknown tag $tagname" 97363847c39Smrg fi 97463847c39Smrg ;; 97563847c39Smrg esac 97663847c39Smrg} 977d8556812Smrg 97863847c39Smrg# func_check_version_match 97963847c39Smrg# Ensure that we are using m4 macros, and libtool script from the same 98063847c39Smrg# release of libtool. 98163847c39Smrgfunc_check_version_match () 98263847c39Smrg{ 98363847c39Smrg if test "$package_revision" != "$macro_revision"; then 98463847c39Smrg if test "$VERSION" != "$macro_version"; then 98563847c39Smrg if test -z "$macro_version"; then 98663847c39Smrg cat >&2 <<_LT_EOF 98763847c39Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 98863847c39Smrg$progname: definition of this LT_INIT comes from an older release. 98963847c39Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99063847c39Smrg$progname: and run autoconf again. 99163847c39Smrg_LT_EOF 99263847c39Smrg else 99363847c39Smrg cat >&2 <<_LT_EOF 99463847c39Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99563847c39Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 99663847c39Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99763847c39Smrg$progname: and run autoconf again. 99863847c39Smrg_LT_EOF 99963847c39Smrg fi 100063847c39Smrg else 100163847c39Smrg cat >&2 <<_LT_EOF 100263847c39Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 100363847c39Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 100463847c39Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 100563847c39Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 100663847c39Smrg_LT_EOF 100763847c39Smrg fi 1008d8556812Smrg 100963847c39Smrg exit $EXIT_MISMATCH 101063847c39Smrg fi 101163847c39Smrg} 101276888252Smrg 101386dafe34Smrg 101463847c39Smrg# Shorthand for --mode=foo, only valid as the first argument 101563847c39Smrgcase $1 in 101663847c39Smrgclean|clea|cle|cl) 101763847c39Smrg shift; set dummy --mode clean ${1+"$@"}; shift 101863847c39Smrg ;; 101963847c39Smrgcompile|compil|compi|comp|com|co|c) 102063847c39Smrg shift; set dummy --mode compile ${1+"$@"}; shift 102163847c39Smrg ;; 102263847c39Smrgexecute|execut|execu|exec|exe|ex|e) 102363847c39Smrg shift; set dummy --mode execute ${1+"$@"}; shift 102463847c39Smrg ;; 102563847c39Smrgfinish|finis|fini|fin|fi|f) 102663847c39Smrg shift; set dummy --mode finish ${1+"$@"}; shift 1027d8556812Smrg ;; 102863847c39Smrginstall|instal|insta|inst|ins|in|i) 102963847c39Smrg shift; set dummy --mode install ${1+"$@"}; shift 1030d8556812Smrg ;; 103163847c39Smrglink|lin|li|l) 103263847c39Smrg shift; set dummy --mode link ${1+"$@"}; shift 103363847c39Smrg ;; 103463847c39Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 103563847c39Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 1036d8556812Smrg ;; 1037d8556812Smrgesac 103886dafe34Smrg 103986dafe34Smrg 104086dafe34Smrg 104163847c39Smrg# Option defaults: 104263847c39Smrgopt_debug=: 104363847c39Smrgopt_dry_run=false 104463847c39Smrgopt_config=false 104563847c39Smrgopt_preserve_dup_deps=false 104663847c39Smrgopt_features=false 104763847c39Smrgopt_finish=false 104863847c39Smrgopt_help=false 104963847c39Smrgopt_help_all=false 105063847c39Smrgopt_silent=: 105163847c39Smrgopt_warning=: 105263847c39Smrgopt_verbose=: 105363847c39Smrgopt_silent=false 105463847c39Smrgopt_verbose=false 105586dafe34Smrg 105663847c39Smrg 105763847c39Smrg# Parse options once, thoroughly. This comes as soon as possible in the 105863847c39Smrg# script to make things like `--version' happen as quickly as we can. 105963847c39Smrg{ 106063847c39Smrg # this just eases exit handling 106163847c39Smrg while test $# -gt 0; do 106263847c39Smrg opt="$1" 106363847c39Smrg shift 106463847c39Smrg case $opt in 106563847c39Smrg --debug|-x) opt_debug='set -x' 106663847c39Smrg func_echo "enabling shell trace mode" 106763847c39Smrg $opt_debug 106863847c39Smrg ;; 106963847c39Smrg --dry-run|--dryrun|-n) 107063847c39Smrg opt_dry_run=: 107163847c39Smrg ;; 107263847c39Smrg --config) 107363847c39Smrg opt_config=: 107463847c39Smrgfunc_config 107563847c39Smrg ;; 107663847c39Smrg --dlopen|-dlopen) 107763847c39Smrg optarg="$1" 107863847c39Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 107963847c39Smrg}$optarg" 108063847c39Smrg shift 108163847c39Smrg ;; 108263847c39Smrg --preserve-dup-deps) 108363847c39Smrg opt_preserve_dup_deps=: 108463847c39Smrg ;; 108563847c39Smrg --features) 108663847c39Smrg opt_features=: 108763847c39Smrgfunc_features 108863847c39Smrg ;; 108963847c39Smrg --finish) 109063847c39Smrg opt_finish=: 109163847c39Smrgset dummy --mode finish ${1+"$@"}; shift 109263847c39Smrg ;; 109363847c39Smrg --help) 109463847c39Smrg opt_help=: 109563847c39Smrg ;; 109663847c39Smrg --help-all) 109763847c39Smrg opt_help_all=: 109863847c39Smrgopt_help=': help-all' 109963847c39Smrg ;; 110063847c39Smrg --mode) 110163847c39Smrg test $# = 0 && func_missing_arg $opt && break 110263847c39Smrg optarg="$1" 110363847c39Smrg opt_mode="$optarg" 110463847c39Smrgcase $optarg in 110563847c39Smrg # Valid mode arguments: 110663847c39Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 110763847c39Smrg 110863847c39Smrg # Catch anything else as an error 110963847c39Smrg *) func_error "invalid argument for $opt" 111063847c39Smrg exit_cmd=exit 111163847c39Smrg break 111263847c39Smrg ;; 111363847c39Smrgesac 111463847c39Smrg shift 111563847c39Smrg ;; 111663847c39Smrg --no-silent|--no-quiet) 111763847c39Smrg opt_silent=false 111863847c39Smrgfunc_append preserve_args " $opt" 111963847c39Smrg ;; 112063847c39Smrg --no-warning|--no-warn) 112163847c39Smrg opt_warning=false 112263847c39Smrgfunc_append preserve_args " $opt" 112363847c39Smrg ;; 112463847c39Smrg --no-verbose) 112563847c39Smrg opt_verbose=false 112663847c39Smrgfunc_append preserve_args " $opt" 112763847c39Smrg ;; 112863847c39Smrg --silent|--quiet) 112963847c39Smrg opt_silent=: 113063847c39Smrgfunc_append preserve_args " $opt" 113163847c39Smrg opt_verbose=false 113263847c39Smrg ;; 113363847c39Smrg --verbose|-v) 113463847c39Smrg opt_verbose=: 113563847c39Smrgfunc_append preserve_args " $opt" 113663847c39Smrgopt_silent=false 113763847c39Smrg ;; 113863847c39Smrg --tag) 113963847c39Smrg test $# = 0 && func_missing_arg $opt && break 114063847c39Smrg optarg="$1" 114163847c39Smrg opt_tag="$optarg" 114263847c39Smrgfunc_append preserve_args " $opt $optarg" 114363847c39Smrgfunc_enable_tag "$optarg" 114463847c39Smrg shift 114563847c39Smrg ;; 114663847c39Smrg 114763847c39Smrg -\?|-h) func_usage ;; 114863847c39Smrg --help) func_help ;; 114963847c39Smrg --version) func_version ;; 115063847c39Smrg 115163847c39Smrg # Separate optargs to long options: 115263847c39Smrg --*=*) 115363847c39Smrg func_split_long_opt "$opt" 115463847c39Smrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 115563847c39Smrg shift 115663847c39Smrg ;; 115763847c39Smrg 115863847c39Smrg # Separate non-argument short options: 115963847c39Smrg -\?*|-h*|-n*|-v*) 116063847c39Smrg func_split_short_opt "$opt" 116163847c39Smrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 116263847c39Smrg shift 116363847c39Smrg ;; 116463847c39Smrg 116563847c39Smrg --) break ;; 116663847c39Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 116763847c39Smrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1168d8556812Smrg esac 116963847c39Smrg done 117076888252Smrg 117163847c39Smrg # Validate options: 117263847c39Smrg 117363847c39Smrg # save first non-option argument 117463847c39Smrg if test "$#" -gt 0; then 117563847c39Smrg nonopt="$opt" 117663847c39Smrg shift 117776888252Smrg fi 117876888252Smrg 117963847c39Smrg # preserve --debug 118063847c39Smrg test "$opt_debug" = : || func_append preserve_args " --debug" 118176888252Smrg 118263847c39Smrg case $host in 118363847c39Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 118463847c39Smrg # don't eliminate duplications in $postdeps and $predeps 118563847c39Smrg opt_duplicate_compiler_generated_deps=: 118663847c39Smrg ;; 118763847c39Smrg *) 118863847c39Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 118963847c39Smrg ;; 119063847c39Smrg esac 119176888252Smrg 119263847c39Smrg $opt_help || { 119363847c39Smrg # Sanity checks first: 119463847c39Smrg func_check_version_match 119576888252Smrg 119663847c39Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 119763847c39Smrg func_fatal_configuration "not configured to build any kind of library" 119863847c39Smrg fi 119986dafe34Smrg 120063847c39Smrg # Darwin sucks 120163847c39Smrg eval std_shrext=\"$shrext_cmds\" 120286dafe34Smrg 120363847c39Smrg # Only execute mode is allowed to have -dlopen flags. 120463847c39Smrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 120563847c39Smrg func_error "unrecognized option \`-dlopen'" 120663847c39Smrg $ECHO "$help" 1>&2 120763847c39Smrg exit $EXIT_FAILURE 120863847c39Smrg fi 120986dafe34Smrg 121063847c39Smrg # Change the help message to a mode-specific one. 121163847c39Smrg generic_help="$help" 121263847c39Smrg help="Try \`$progname --help --mode=$opt_mode' for more information." 121363847c39Smrg } 1214d8556812Smrg 121576888252Smrg 121663847c39Smrg # Bail if the options were screwed 121763847c39Smrg $exit_cmd $EXIT_FAILURE 121863847c39Smrg} 121976888252Smrg 122076888252Smrg 1221d8556812Smrg 1222d8556812Smrg 122363847c39Smrg## ----------- ## 122463847c39Smrg## Main. ## 122563847c39Smrg## ----------- ## 122676888252Smrg 122763847c39Smrg# func_lalib_p file 122863847c39Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 122963847c39Smrg# This function is only a basic sanity check; it will hardly flush out 123063847c39Smrg# determined imposters. 123163847c39Smrgfunc_lalib_p () 123263847c39Smrg{ 123363847c39Smrg test -f "$1" && 123463847c39Smrg $SED -e 4q "$1" 2>/dev/null \ 123563847c39Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 123663847c39Smrg} 123776888252Smrg 123863847c39Smrg# func_lalib_unsafe_p file 123963847c39Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 124063847c39Smrg# This function implements the same check as func_lalib_p without 124163847c39Smrg# resorting to external programs. To this end, it redirects stdin and 124263847c39Smrg# closes it afterwards, without saving the original file descriptor. 124363847c39Smrg# As a safety measure, use it only where a negative result would be 124463847c39Smrg# fatal anyway. Works if `file' does not exist. 124563847c39Smrgfunc_lalib_unsafe_p () 124663847c39Smrg{ 124763847c39Smrg lalib_p=no 124863847c39Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 124963847c39Smrg for lalib_p_l in 1 2 3 4 125063847c39Smrg do 125163847c39Smrg read lalib_p_line 125263847c39Smrg case "$lalib_p_line" in 125363847c39Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 125463847c39Smrg esac 125563847c39Smrg done 125663847c39Smrg exec 0<&5 5<&- 125763847c39Smrg fi 125863847c39Smrg test "$lalib_p" = yes 125963847c39Smrg} 126076888252Smrg 126163847c39Smrg# func_ltwrapper_script_p file 126263847c39Smrg# True iff FILE is a libtool wrapper script 126363847c39Smrg# This function is only a basic sanity check; it will hardly flush out 126463847c39Smrg# determined imposters. 126563847c39Smrgfunc_ltwrapper_script_p () 126663847c39Smrg{ 126763847c39Smrg func_lalib_p "$1" 126863847c39Smrg} 1269d8556812Smrg 127063847c39Smrg# func_ltwrapper_executable_p file 127163847c39Smrg# True iff FILE is a libtool wrapper executable 127263847c39Smrg# This function is only a basic sanity check; it will hardly flush out 127363847c39Smrg# determined imposters. 127463847c39Smrgfunc_ltwrapper_executable_p () 127563847c39Smrg{ 127663847c39Smrg func_ltwrapper_exec_suffix= 127763847c39Smrg case $1 in 127863847c39Smrg *.exe) ;; 127963847c39Smrg *) func_ltwrapper_exec_suffix=.exe ;; 128076888252Smrg esac 128163847c39Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 128263847c39Smrg} 128376888252Smrg 128463847c39Smrg# func_ltwrapper_scriptname file 128563847c39Smrg# Assumes file is an ltwrapper_executable 128663847c39Smrg# uses $file to determine the appropriate filename for a 128763847c39Smrg# temporary ltwrapper_script. 128863847c39Smrgfunc_ltwrapper_scriptname () 128963847c39Smrg{ 129063847c39Smrg func_dirname_and_basename "$1" "" "." 129163847c39Smrg func_stripname '' '.exe' "$func_basename_result" 129263847c39Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 129363847c39Smrg} 129476888252Smrg 129563847c39Smrg# func_ltwrapper_p file 129663847c39Smrg# True iff FILE is a libtool wrapper script or wrapper executable 129763847c39Smrg# This function is only a basic sanity check; it will hardly flush out 129863847c39Smrg# determined imposters. 129963847c39Smrgfunc_ltwrapper_p () 130063847c39Smrg{ 130163847c39Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 130263847c39Smrg} 130376888252Smrg 130476888252Smrg 130563847c39Smrg# func_execute_cmds commands fail_cmd 130663847c39Smrg# Execute tilde-delimited COMMANDS. 130763847c39Smrg# If FAIL_CMD is given, eval that upon failure. 130863847c39Smrg# FAIL_CMD may read-access the current command in variable CMD! 130963847c39Smrgfunc_execute_cmds () 131063847c39Smrg{ 131163847c39Smrg $opt_debug 131263847c39Smrg save_ifs=$IFS; IFS='~' 131363847c39Smrg for cmd in $1; do 131463847c39Smrg IFS=$save_ifs 131563847c39Smrg eval cmd=\"$cmd\" 131663847c39Smrg func_show_eval "$cmd" "${2-:}" 131776888252Smrg done 131863847c39Smrg IFS=$save_ifs 131963847c39Smrg} 132076888252Smrg 132176888252Smrg 132263847c39Smrg# func_source file 132363847c39Smrg# Source FILE, adding directory component if necessary. 132463847c39Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 132563847c39Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 132663847c39Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 132763847c39Smrg# `FILE.' does not work on cygwin managed mounts. 132863847c39Smrgfunc_source () 132963847c39Smrg{ 133063847c39Smrg $opt_debug 133163847c39Smrg case $1 in 133263847c39Smrg */* | *\\*) . "$1" ;; 133363847c39Smrg *) . "./$1" ;; 133463847c39Smrg esac 133563847c39Smrg} 133676888252Smrg 133776888252Smrg 133863847c39Smrg# func_resolve_sysroot PATH 133963847c39Smrg# Replace a leading = in PATH with a sysroot. Store the result into 134063847c39Smrg# func_resolve_sysroot_result 134163847c39Smrgfunc_resolve_sysroot () 134263847c39Smrg{ 134363847c39Smrg func_resolve_sysroot_result=$1 134463847c39Smrg case $func_resolve_sysroot_result in 134563847c39Smrg =*) 134663847c39Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 134763847c39Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 134863847c39Smrg ;; 134963847c39Smrg esac 135063847c39Smrg} 1351d8556812Smrg 135263847c39Smrg# func_replace_sysroot PATH 135363847c39Smrg# If PATH begins with the sysroot, replace it with = and 135463847c39Smrg# store the result into func_replace_sysroot_result. 135563847c39Smrgfunc_replace_sysroot () 135663847c39Smrg{ 135763847c39Smrg case "$lt_sysroot:$1" in 135863847c39Smrg ?*:"$lt_sysroot"*) 135963847c39Smrg func_stripname "$lt_sysroot" '' "$1" 136063847c39Smrg func_replace_sysroot_result="=$func_stripname_result" 136163847c39Smrg ;; 136263847c39Smrg *) 136363847c39Smrg # Including no sysroot. 136463847c39Smrg func_replace_sysroot_result=$1 136563847c39Smrg ;; 136663847c39Smrg esac 136763847c39Smrg} 136876888252Smrg 136963847c39Smrg# func_infer_tag arg 137063847c39Smrg# Infer tagged configuration to use if any are available and 137163847c39Smrg# if one wasn't chosen via the "--tag" command line option. 137263847c39Smrg# Only attempt this if the compiler in the base compile 137363847c39Smrg# command doesn't match the default compiler. 137463847c39Smrg# arg is usually of the form 'gcc ...' 137563847c39Smrgfunc_infer_tag () 137663847c39Smrg{ 137763847c39Smrg $opt_debug 137863847c39Smrg if test -n "$available_tags" && test -z "$tagname"; then 137963847c39Smrg CC_quoted= 138063847c39Smrg for arg in $CC; do 138163847c39Smrg func_append_quoted CC_quoted "$arg" 138263847c39Smrg done 138363847c39Smrg CC_expanded=`func_echo_all $CC` 138463847c39Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 138563847c39Smrg case $@ in 138663847c39Smrg # Blanks in the command may have been stripped by the calling shell, 138763847c39Smrg # but not from the CC environment variable when configure was run. 138863847c39Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 138963847c39Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 139063847c39Smrg # Blanks at the start of $base_compile will cause this to fail 139163847c39Smrg # if we don't check for them as well. 139263847c39Smrg *) 139363847c39Smrg for z in $available_tags; do 139463847c39Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 139563847c39Smrg # Evaluate the configuration. 139663847c39Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 139763847c39Smrg CC_quoted= 139863847c39Smrg for arg in $CC; do 139963847c39Smrg # Double-quote args containing other shell metacharacters. 140063847c39Smrg func_append_quoted CC_quoted "$arg" 140163847c39Smrg done 140263847c39Smrg CC_expanded=`func_echo_all $CC` 140363847c39Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 140463847c39Smrg case "$@ " in 140563847c39Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 140663847c39Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 140763847c39Smrg # The compiler in the base compile command matches 140863847c39Smrg # the one in the tagged configuration. 140963847c39Smrg # Assume this is the tagged configuration we want. 141063847c39Smrg tagname=$z 141163847c39Smrg break 141263847c39Smrg ;; 141363847c39Smrg esac 141463847c39Smrg fi 141563847c39Smrg done 141663847c39Smrg # If $tagname still isn't set, then no tagged configuration 141763847c39Smrg # was found and let the user know that the "--tag" command 141863847c39Smrg # line option must be used. 141963847c39Smrg if test -z "$tagname"; then 142063847c39Smrg func_echo "unable to infer tagged configuration" 142163847c39Smrg func_fatal_error "specify a tag with \`--tag'" 142263847c39Smrg# else 142363847c39Smrg# func_verbose "using $tagname tagged configuration" 142463847c39Smrg fi 142563847c39Smrg ;; 142663847c39Smrg esac 142776888252Smrg fi 142863847c39Smrg} 142976888252Smrg 143076888252Smrg 143176888252Smrg 143263847c39Smrg# func_write_libtool_object output_name pic_name nonpic_name 143363847c39Smrg# Create a libtool object file (analogous to a ".la" file), 143463847c39Smrg# but don't create it if we're doing a dry run. 143563847c39Smrgfunc_write_libtool_object () 143663847c39Smrg{ 143763847c39Smrg write_libobj=${1} 143863847c39Smrg if test "$build_libtool_libs" = yes; then 143963847c39Smrg write_lobj=\'${2}\' 144063847c39Smrg else 144163847c39Smrg write_lobj=none 144276888252Smrg fi 144376888252Smrg 144463847c39Smrg if test "$build_old_libs" = yes; then 144563847c39Smrg write_oldobj=\'${3}\' 144663847c39Smrg else 144763847c39Smrg write_oldobj=none 144876888252Smrg fi 1449d8556812Smrg 145063847c39Smrg $opt_dry_run || { 145163847c39Smrg cat >${write_libobj}T <<EOF 145263847c39Smrg# $write_libobj - a libtool object file 145363847c39Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1454d8556812Smrg# 1455d8556812Smrg# Please DO NOT delete this file! 1456d8556812Smrg# It is necessary for linking the library. 1457d8556812Smrg 1458d8556812Smrg# Name of the PIC object. 145963847c39Smrgpic_object=$write_lobj 146076888252Smrg 146163847c39Smrg# Name of the non-PIC object 146263847c39Smrgnon_pic_object=$write_oldobj 146376888252Smrg 146463847c39SmrgEOF 146563847c39Smrg $MV "${write_libobj}T" "${write_libobj}" 146663847c39Smrg } 146763847c39Smrg} 146876888252Smrg 146976888252Smrg 147063847c39Smrg################################################## 147163847c39Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 147263847c39Smrg################################################## 147376888252Smrg 147463847c39Smrg# func_convert_core_file_wine_to_w32 ARG 147563847c39Smrg# Helper function used by file name conversion functions when $build is *nix, 147663847c39Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 147763847c39Smrg# correctly configured wine environment available, with the winepath program 147863847c39Smrg# in $build's $PATH. 147963847c39Smrg# 148063847c39Smrg# ARG is the $build file name to be converted to w32 format. 148163847c39Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 148263847c39Smrg# be empty on error (or when ARG is empty) 148363847c39Smrgfunc_convert_core_file_wine_to_w32 () 148463847c39Smrg{ 148563847c39Smrg $opt_debug 148663847c39Smrg func_convert_core_file_wine_to_w32_result="$1" 148763847c39Smrg if test -n "$1"; then 148863847c39Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 148963847c39Smrg # are forced to check the contents of stdout. On the other hand, if the 149063847c39Smrg # command is not found, the shell will set an exit code of 127 and print 149163847c39Smrg # *an error message* to stdout. So we must check for both error code of 149263847c39Smrg # zero AND non-empty stdout, which explains the odd construction: 149363847c39Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 149463847c39Smrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 149563847c39Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 149663847c39Smrg $SED -e "$lt_sed_naive_backslashify"` 149763847c39Smrg else 149863847c39Smrg func_convert_core_file_wine_to_w32_result= 149963847c39Smrg fi 150063847c39Smrg fi 150163847c39Smrg} 150263847c39Smrg# end: func_convert_core_file_wine_to_w32 1503d8556812Smrg 150463847c39Smrg 150563847c39Smrg# func_convert_core_path_wine_to_w32 ARG 150663847c39Smrg# Helper function used by path conversion functions when $build is *nix, and 150763847c39Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 150863847c39Smrg# configured wine environment available, with the winepath program in $build's 150963847c39Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 151063847c39Smrg# 151163847c39Smrg# ARG is path to be converted from $build format to win32. 151263847c39Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 151363847c39Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 151463847c39Smrg# are convertible, then the result may be empty. 151563847c39Smrgfunc_convert_core_path_wine_to_w32 () 151663847c39Smrg{ 151763847c39Smrg $opt_debug 151863847c39Smrg # unfortunately, winepath doesn't convert paths, only file names 151963847c39Smrg func_convert_core_path_wine_to_w32_result="" 152063847c39Smrg if test -n "$1"; then 152163847c39Smrg oldIFS=$IFS 152263847c39Smrg IFS=: 152363847c39Smrg for func_convert_core_path_wine_to_w32_f in $1; do 152463847c39Smrg IFS=$oldIFS 152563847c39Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 152663847c39Smrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 152763847c39Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 152863847c39Smrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 152963847c39Smrg else 153063847c39Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 153163847c39Smrg fi 1532d8556812Smrg fi 153363847c39Smrg done 153463847c39Smrg IFS=$oldIFS 153563847c39Smrg fi 153663847c39Smrg} 153763847c39Smrg# end: func_convert_core_path_wine_to_w32 153863847c39Smrg 153963847c39Smrg 154063847c39Smrg# func_cygpath ARGS... 154163847c39Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 154263847c39Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 154363847c39Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 154463847c39Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 154563847c39Smrg# file name or path is assumed to be in w32 format, as previously converted 154663847c39Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 154763847c39Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 154863847c39Smrg# Cygwin format). Returns an empty string on error. 154963847c39Smrg# 155063847c39Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 155163847c39Smrg# be converted. 155263847c39Smrg# 155363847c39Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 155463847c39Smrg# environment variable; do not put it in $PATH. 155563847c39Smrgfunc_cygpath () 155663847c39Smrg{ 155763847c39Smrg $opt_debug 155863847c39Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 155963847c39Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 156063847c39Smrg if test "$?" -ne 0; then 156163847c39Smrg # on failure, ensure result is empty 156263847c39Smrg func_cygpath_result= 156363847c39Smrg fi 156463847c39Smrg else 156563847c39Smrg func_cygpath_result= 156663847c39Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 156763847c39Smrg fi 156863847c39Smrg} 156963847c39Smrg#end: func_cygpath 157076888252Smrg 157176888252Smrg 157263847c39Smrg# func_convert_core_msys_to_w32 ARG 157363847c39Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 157463847c39Smrg# result in func_convert_core_msys_to_w32_result. 157563847c39Smrgfunc_convert_core_msys_to_w32 () 157663847c39Smrg{ 157763847c39Smrg $opt_debug 157863847c39Smrg # awkward: cmd appends spaces to result 157963847c39Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 158063847c39Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 158163847c39Smrg} 158263847c39Smrg#end: func_convert_core_msys_to_w32 158376888252Smrg 158476888252Smrg 158563847c39Smrg# func_convert_file_check ARG1 ARG2 158663847c39Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 158763847c39Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 158863847c39Smrg# func_to_host_file_result to ARG1). 158963847c39Smrgfunc_convert_file_check () 159063847c39Smrg{ 159163847c39Smrg $opt_debug 159263847c39Smrg if test -z "$2" && test -n "$1" ; then 159363847c39Smrg func_error "Could not determine host file name corresponding to" 159463847c39Smrg func_error " \`$1'" 159563847c39Smrg func_error "Continuing, but uninstalled executables may not work." 159663847c39Smrg # Fallback: 159763847c39Smrg func_to_host_file_result="$1" 159863847c39Smrg fi 159963847c39Smrg} 160063847c39Smrg# end func_convert_file_check 160176888252Smrg 160276888252Smrg 160363847c39Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 160463847c39Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 160563847c39Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 160663847c39Smrg# func_to_host_file_result to a simplistic fallback value (see below). 160763847c39Smrgfunc_convert_path_check () 160863847c39Smrg{ 160963847c39Smrg $opt_debug 161063847c39Smrg if test -z "$4" && test -n "$3"; then 161163847c39Smrg func_error "Could not determine the host path corresponding to" 161263847c39Smrg func_error " \`$3'" 161363847c39Smrg func_error "Continuing, but uninstalled executables may not work." 161463847c39Smrg # Fallback. This is a deliberately simplistic "conversion" and 161563847c39Smrg # should not be "improved". See libtool.info. 161663847c39Smrg if test "x$1" != "x$2"; then 161763847c39Smrg lt_replace_pathsep_chars="s|$1|$2|g" 161863847c39Smrg func_to_host_path_result=`echo "$3" | 161963847c39Smrg $SED -e "$lt_replace_pathsep_chars"` 162063847c39Smrg else 162163847c39Smrg func_to_host_path_result="$3" 162263847c39Smrg fi 162363847c39Smrg fi 162463847c39Smrg} 162563847c39Smrg# end func_convert_path_check 1626d8556812Smrg 1627d8556812Smrg 162863847c39Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 162963847c39Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 163063847c39Smrg# and appending REPL if ORIG matches BACKPAT. 163163847c39Smrgfunc_convert_path_front_back_pathsep () 163263847c39Smrg{ 163363847c39Smrg $opt_debug 163463847c39Smrg case $4 in 163563847c39Smrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 163663847c39Smrg ;; 163763847c39Smrg esac 163863847c39Smrg case $4 in 163963847c39Smrg $2 ) func_append func_to_host_path_result "$3" 164063847c39Smrg ;; 164163847c39Smrg esac 164263847c39Smrg} 164363847c39Smrg# end func_convert_path_front_back_pathsep 1644d8556812Smrg 164576888252Smrg 164663847c39Smrg################################################## 164763847c39Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 164863847c39Smrg################################################## 164963847c39Smrg# invoked via `$to_host_file_cmd ARG' 165063847c39Smrg# 165163847c39Smrg# In each case, ARG is the path to be converted from $build to $host format. 165263847c39Smrg# Result will be available in $func_to_host_file_result. 165376888252Smrg 165476888252Smrg 165563847c39Smrg# func_to_host_file ARG 165663847c39Smrg# Converts the file name ARG from $build format to $host format. Return result 165763847c39Smrg# in func_to_host_file_result. 165863847c39Smrgfunc_to_host_file () 165963847c39Smrg{ 166063847c39Smrg $opt_debug 166163847c39Smrg $to_host_file_cmd "$1" 166263847c39Smrg} 166363847c39Smrg# end func_to_host_file 166476888252Smrg 166576888252Smrg 166663847c39Smrg# func_to_tool_file ARG LAZY 166763847c39Smrg# converts the file name ARG from $build format to toolchain format. Return 166863847c39Smrg# result in func_to_tool_file_result. If the conversion in use is listed 166963847c39Smrg# in (the comma separated) LAZY, no conversion takes place. 167063847c39Smrgfunc_to_tool_file () 167163847c39Smrg{ 167263847c39Smrg $opt_debug 167363847c39Smrg case ,$2, in 167463847c39Smrg *,"$to_tool_file_cmd",*) 167563847c39Smrg func_to_tool_file_result=$1 167663847c39Smrg ;; 167763847c39Smrg *) 167863847c39Smrg $to_tool_file_cmd "$1" 167963847c39Smrg func_to_tool_file_result=$func_to_host_file_result 168063847c39Smrg ;; 168163847c39Smrg esac 168263847c39Smrg} 168363847c39Smrg# end func_to_tool_file 168476888252Smrg 168576888252Smrg 168663847c39Smrg# func_convert_file_noop ARG 168763847c39Smrg# Copy ARG to func_to_host_file_result. 168863847c39Smrgfunc_convert_file_noop () 168963847c39Smrg{ 169063847c39Smrg func_to_host_file_result="$1" 169163847c39Smrg} 169263847c39Smrg# end func_convert_file_noop 1693d8556812Smrg 1694d8556812Smrg 169563847c39Smrg# func_convert_file_msys_to_w32 ARG 169663847c39Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 169763847c39Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 169863847c39Smrg# func_to_host_file_result. 169963847c39Smrgfunc_convert_file_msys_to_w32 () 170063847c39Smrg{ 170163847c39Smrg $opt_debug 170263847c39Smrg func_to_host_file_result="$1" 170363847c39Smrg if test -n "$1"; then 170463847c39Smrg func_convert_core_msys_to_w32 "$1" 170563847c39Smrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 170663847c39Smrg fi 170763847c39Smrg func_convert_file_check "$1" "$func_to_host_file_result" 170863847c39Smrg} 170963847c39Smrg# end func_convert_file_msys_to_w32 1710d8556812Smrg 171176888252Smrg 171263847c39Smrg# func_convert_file_cygwin_to_w32 ARG 171363847c39Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 171463847c39Smrg# func_to_host_file_result. 171563847c39Smrgfunc_convert_file_cygwin_to_w32 () 171663847c39Smrg{ 171763847c39Smrg $opt_debug 171863847c39Smrg func_to_host_file_result="$1" 171963847c39Smrg if test -n "$1"; then 172063847c39Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 172163847c39Smrg # LT_CYGPATH in this case. 172263847c39Smrg func_to_host_file_result=`cygpath -m "$1"` 172363847c39Smrg fi 172463847c39Smrg func_convert_file_check "$1" "$func_to_host_file_result" 172563847c39Smrg} 172663847c39Smrg# end func_convert_file_cygwin_to_w32 172776888252Smrg 172876888252Smrg 172963847c39Smrg# func_convert_file_nix_to_w32 ARG 173063847c39Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 173163847c39Smrg# and a working winepath. Returns result in func_to_host_file_result. 173263847c39Smrgfunc_convert_file_nix_to_w32 () 173363847c39Smrg{ 173463847c39Smrg $opt_debug 173563847c39Smrg func_to_host_file_result="$1" 173663847c39Smrg if test -n "$1"; then 173763847c39Smrg func_convert_core_file_wine_to_w32 "$1" 173863847c39Smrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 173963847c39Smrg fi 174063847c39Smrg func_convert_file_check "$1" "$func_to_host_file_result" 174163847c39Smrg} 174263847c39Smrg# end func_convert_file_nix_to_w32 174376888252Smrg 174476888252Smrg 174563847c39Smrg# func_convert_file_msys_to_cygwin ARG 174663847c39Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 174763847c39Smrg# Returns result in func_to_host_file_result. 174863847c39Smrgfunc_convert_file_msys_to_cygwin () 174963847c39Smrg{ 175063847c39Smrg $opt_debug 175163847c39Smrg func_to_host_file_result="$1" 175263847c39Smrg if test -n "$1"; then 175363847c39Smrg func_convert_core_msys_to_w32 "$1" 175463847c39Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 175563847c39Smrg func_to_host_file_result="$func_cygpath_result" 175663847c39Smrg fi 175763847c39Smrg func_convert_file_check "$1" "$func_to_host_file_result" 175863847c39Smrg} 175963847c39Smrg# end func_convert_file_msys_to_cygwin 176076888252Smrg 176176888252Smrg 176263847c39Smrg# func_convert_file_nix_to_cygwin ARG 176363847c39Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 176463847c39Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 176563847c39Smrg# in func_to_host_file_result. 176663847c39Smrgfunc_convert_file_nix_to_cygwin () 176763847c39Smrg{ 176863847c39Smrg $opt_debug 176963847c39Smrg func_to_host_file_result="$1" 177063847c39Smrg if test -n "$1"; then 177163847c39Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 177263847c39Smrg func_convert_core_file_wine_to_w32 "$1" 177363847c39Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 177463847c39Smrg func_to_host_file_result="$func_cygpath_result" 177563847c39Smrg fi 177663847c39Smrg func_convert_file_check "$1" "$func_to_host_file_result" 177763847c39Smrg} 177863847c39Smrg# end func_convert_file_nix_to_cygwin 177976888252Smrg 178076888252Smrg 178163847c39Smrg############################################# 178263847c39Smrg# $build to $host PATH CONVERSION FUNCTIONS # 178363847c39Smrg############################################# 178463847c39Smrg# invoked via `$to_host_path_cmd ARG' 178563847c39Smrg# 178663847c39Smrg# In each case, ARG is the path to be converted from $build to $host format. 178763847c39Smrg# The result will be available in $func_to_host_path_result. 178863847c39Smrg# 178963847c39Smrg# Path separators are also converted from $build format to $host format. If 179063847c39Smrg# ARG begins or ends with a path separator character, it is preserved (but 179163847c39Smrg# converted to $host format) on output. 179263847c39Smrg# 179363847c39Smrg# All path conversion functions are named using the following convention: 179463847c39Smrg# file name conversion function : func_convert_file_X_to_Y () 179563847c39Smrg# path conversion function : func_convert_path_X_to_Y () 179663847c39Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 179763847c39Smrg# same. If conversion functions are added for new $build/$host combinations, 179863847c39Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 179963847c39Smrg# will break. 180063847c39Smrg 180163847c39Smrg 180263847c39Smrg# func_init_to_host_path_cmd 180363847c39Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 180463847c39Smrg# appropriate value, based on the value of $to_host_file_cmd. 180563847c39Smrgto_host_path_cmd= 180663847c39Smrgfunc_init_to_host_path_cmd () 180763847c39Smrg{ 180863847c39Smrg $opt_debug 180963847c39Smrg if test -z "$to_host_path_cmd"; then 181063847c39Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 181163847c39Smrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 181263847c39Smrg fi 181363847c39Smrg} 181476888252Smrg 181576888252Smrg 181663847c39Smrg# func_to_host_path ARG 181763847c39Smrg# Converts the path ARG from $build format to $host format. Return result 181863847c39Smrg# in func_to_host_path_result. 181963847c39Smrgfunc_to_host_path () 182063847c39Smrg{ 182163847c39Smrg $opt_debug 182263847c39Smrg func_init_to_host_path_cmd 182363847c39Smrg $to_host_path_cmd "$1" 182463847c39Smrg} 182563847c39Smrg# end func_to_host_path 182676888252Smrg 182776888252Smrg 182863847c39Smrg# func_convert_path_noop ARG 182963847c39Smrg# Copy ARG to func_to_host_path_result. 183063847c39Smrgfunc_convert_path_noop () 183163847c39Smrg{ 183263847c39Smrg func_to_host_path_result="$1" 183363847c39Smrg} 183463847c39Smrg# end func_convert_path_noop 183576888252Smrg 183676888252Smrg 183763847c39Smrg# func_convert_path_msys_to_w32 ARG 183863847c39Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 183963847c39Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 184063847c39Smrg# func_to_host_path_result. 184163847c39Smrgfunc_convert_path_msys_to_w32 () 184263847c39Smrg{ 184363847c39Smrg $opt_debug 184463847c39Smrg func_to_host_path_result="$1" 184563847c39Smrg if test -n "$1"; then 184663847c39Smrg # Remove leading and trailing path separator characters from ARG. MSYS 184763847c39Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 184863847c39Smrg # and winepath ignores them completely. 184963847c39Smrg func_stripname : : "$1" 185063847c39Smrg func_to_host_path_tmp1=$func_stripname_result 185163847c39Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 185263847c39Smrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 185363847c39Smrg func_convert_path_check : ";" \ 185463847c39Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 185563847c39Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 185663847c39Smrg fi 185763847c39Smrg} 185863847c39Smrg# end func_convert_path_msys_to_w32 185976888252Smrg 186076888252Smrg 186163847c39Smrg# func_convert_path_cygwin_to_w32 ARG 186263847c39Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 186363847c39Smrg# func_to_host_file_result. 186463847c39Smrgfunc_convert_path_cygwin_to_w32 () 186563847c39Smrg{ 186663847c39Smrg $opt_debug 186763847c39Smrg func_to_host_path_result="$1" 186863847c39Smrg if test -n "$1"; then 186963847c39Smrg # See func_convert_path_msys_to_w32: 187063847c39Smrg func_stripname : : "$1" 187163847c39Smrg func_to_host_path_tmp1=$func_stripname_result 187263847c39Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 187363847c39Smrg func_convert_path_check : ";" \ 187463847c39Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 187563847c39Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 187663847c39Smrg fi 187763847c39Smrg} 187863847c39Smrg# end func_convert_path_cygwin_to_w32 187976888252Smrg 188076888252Smrg 188163847c39Smrg# func_convert_path_nix_to_w32 ARG 188263847c39Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 188363847c39Smrg# a working winepath. Returns result in func_to_host_file_result. 188463847c39Smrgfunc_convert_path_nix_to_w32 () 188563847c39Smrg{ 188663847c39Smrg $opt_debug 188763847c39Smrg func_to_host_path_result="$1" 188863847c39Smrg if test -n "$1"; then 188963847c39Smrg # See func_convert_path_msys_to_w32: 189063847c39Smrg func_stripname : : "$1" 189163847c39Smrg func_to_host_path_tmp1=$func_stripname_result 189263847c39Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 189363847c39Smrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 189463847c39Smrg func_convert_path_check : ";" \ 189563847c39Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 189663847c39Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 189763847c39Smrg fi 189863847c39Smrg} 189963847c39Smrg# end func_convert_path_nix_to_w32 190076888252Smrg 190176888252Smrg 190263847c39Smrg# func_convert_path_msys_to_cygwin ARG 190363847c39Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 190463847c39Smrg# Returns result in func_to_host_file_result. 190563847c39Smrgfunc_convert_path_msys_to_cygwin () 190663847c39Smrg{ 190763847c39Smrg $opt_debug 190863847c39Smrg func_to_host_path_result="$1" 190963847c39Smrg if test -n "$1"; then 191063847c39Smrg # See func_convert_path_msys_to_w32: 191163847c39Smrg func_stripname : : "$1" 191263847c39Smrg func_to_host_path_tmp1=$func_stripname_result 191363847c39Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 191463847c39Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 191563847c39Smrg func_to_host_path_result="$func_cygpath_result" 191663847c39Smrg func_convert_path_check : : \ 191763847c39Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 191863847c39Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 191963847c39Smrg fi 192063847c39Smrg} 192163847c39Smrg# end func_convert_path_msys_to_cygwin 192276888252Smrg 192376888252Smrg 192463847c39Smrg# func_convert_path_nix_to_cygwin ARG 192563847c39Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 192663847c39Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 192763847c39Smrg# func_to_host_file_result. 192863847c39Smrgfunc_convert_path_nix_to_cygwin () 192963847c39Smrg{ 193063847c39Smrg $opt_debug 193163847c39Smrg func_to_host_path_result="$1" 193263847c39Smrg if test -n "$1"; then 193363847c39Smrg # Remove leading and trailing path separator characters from 193463847c39Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 193563847c39Smrg # into '.;' and ';.', and winepath ignores them completely. 193663847c39Smrg func_stripname : : "$1" 193763847c39Smrg func_to_host_path_tmp1=$func_stripname_result 193863847c39Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 193963847c39Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 194063847c39Smrg func_to_host_path_result="$func_cygpath_result" 194163847c39Smrg func_convert_path_check : : \ 194263847c39Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 194363847c39Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 194463847c39Smrg fi 194563847c39Smrg} 194663847c39Smrg# end func_convert_path_nix_to_cygwin 194776888252Smrg 194876888252Smrg 194963847c39Smrg# func_mode_compile arg... 195063847c39Smrgfunc_mode_compile () 195163847c39Smrg{ 195263847c39Smrg $opt_debug 195363847c39Smrg # Get the compilation command and the source file. 195463847c39Smrg base_compile= 195563847c39Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 195663847c39Smrg suppress_opt=yes 195763847c39Smrg suppress_output= 195863847c39Smrg arg_mode=normal 195963847c39Smrg libobj= 196063847c39Smrg later= 196163847c39Smrg pie_flag= 196263847c39Smrg 196363847c39Smrg for arg 196463847c39Smrg do 196563847c39Smrg case $arg_mode in 196663847c39Smrg arg ) 196763847c39Smrg # do not "continue". Instead, add this to base_compile 196863847c39Smrg lastarg="$arg" 196963847c39Smrg arg_mode=normal 197063847c39Smrg ;; 197163847c39Smrg 197263847c39Smrg target ) 197363847c39Smrg libobj="$arg" 197463847c39Smrg arg_mode=normal 197563847c39Smrg continue 197663847c39Smrg ;; 197763847c39Smrg 197863847c39Smrg normal ) 197963847c39Smrg # Accept any command-line options. 198063847c39Smrg case $arg in 198163847c39Smrg -o) 198263847c39Smrg test -n "$libobj" && \ 198363847c39Smrg func_fatal_error "you cannot specify \`-o' more than once" 198463847c39Smrg arg_mode=target 1985d8556812Smrg continue 1986d8556812Smrg ;; 198763847c39Smrg 198863847c39Smrg -pie | -fpie | -fPIE) 198963847c39Smrg func_append pie_flag " $arg" 1990d8556812Smrg continue 1991d8556812Smrg ;; 199263847c39Smrg 199363847c39Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 199463847c39Smrg func_append later " $arg" 1995d8556812Smrg continue 1996d8556812Smrg ;; 199763847c39Smrg 199863847c39Smrg -no-suppress) 199963847c39Smrg suppress_opt=no 2000d8556812Smrg continue 2001d8556812Smrg ;; 200276888252Smrg 200363847c39Smrg -Xcompiler) 200463847c39Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 200563847c39Smrg continue # The current "srcfile" will either be retained or 200663847c39Smrg ;; # replaced later. I would guess that would be a bug. 200776888252Smrg 200863847c39Smrg -Wc,*) 200963847c39Smrg func_stripname '-Wc,' '' "$arg" 201063847c39Smrg args=$func_stripname_result 201163847c39Smrg lastarg= 201263847c39Smrg save_ifs="$IFS"; IFS=',' 201363847c39Smrg for arg in $args; do 201463847c39Smrg IFS="$save_ifs" 201563847c39Smrg func_append_quoted lastarg "$arg" 201663847c39Smrg done 201763847c39Smrg IFS="$save_ifs" 201863847c39Smrg func_stripname ' ' '' "$lastarg" 201963847c39Smrg lastarg=$func_stripname_result 202076888252Smrg 202163847c39Smrg # Add the arguments to base_compile. 202263847c39Smrg func_append base_compile " $lastarg" 202363847c39Smrg continue 202463847c39Smrg ;; 202576888252Smrg 202663847c39Smrg *) 202763847c39Smrg # Accept the current argument as the source file. 202863847c39Smrg # The previous "srcfile" becomes the current argument. 202963847c39Smrg # 203063847c39Smrg lastarg="$srcfile" 203163847c39Smrg srcfile="$arg" 203263847c39Smrg ;; 203363847c39Smrg esac # case $arg 2034d8556812Smrg ;; 203563847c39Smrg esac # case $arg_mode 203676888252Smrg 203763847c39Smrg # Aesthetically quote the previous argument. 203863847c39Smrg func_append_quoted base_compile "$lastarg" 203963847c39Smrg done # for arg 204076888252Smrg 204163847c39Smrg case $arg_mode in 204263847c39Smrg arg) 204363847c39Smrg func_fatal_error "you must specify an argument for -Xcompile" 204463847c39Smrg ;; 204563847c39Smrg target) 204663847c39Smrg func_fatal_error "you must specify a target with \`-o'" 204763847c39Smrg ;; 204863847c39Smrg *) 204963847c39Smrg # Get the name of the library object. 205063847c39Smrg test -z "$libobj" && { 205163847c39Smrg func_basename "$srcfile" 205263847c39Smrg libobj="$func_basename_result" 205363847c39Smrg } 205463847c39Smrg ;; 205563847c39Smrg esac 205676888252Smrg 205763847c39Smrg # Recognize several different file suffixes. 205863847c39Smrg # If the user specifies -o file.o, it is replaced with file.lo 205963847c39Smrg case $libobj in 206063847c39Smrg *.[cCFSifmso] | \ 206163847c39Smrg *.ada | *.adb | *.ads | *.asm | \ 206263847c39Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 206363847c39Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 206463847c39Smrg func_xform "$libobj" 206563847c39Smrg libobj=$func_xform_result 206663847c39Smrg ;; 206763847c39Smrg esac 206876888252Smrg 206963847c39Smrg case $libobj in 207063847c39Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 207163847c39Smrg *) 207263847c39Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 207363847c39Smrg ;; 207463847c39Smrg esac 207576888252Smrg 207663847c39Smrg func_infer_tag $base_compile 207776888252Smrg 207863847c39Smrg for arg in $later; do 207963847c39Smrg case $arg in 208063847c39Smrg -shared) 208163847c39Smrg test "$build_libtool_libs" != yes && \ 208263847c39Smrg func_fatal_configuration "can not build a shared library" 208363847c39Smrg build_old_libs=no 2084d8556812Smrg continue 2085d8556812Smrg ;; 208676888252Smrg 208763847c39Smrg -static) 208863847c39Smrg build_libtool_libs=no 208963847c39Smrg build_old_libs=yes 2090d8556812Smrg continue 2091d8556812Smrg ;; 209276888252Smrg 209363847c39Smrg -prefer-pic) 209463847c39Smrg pic_mode=yes 2095d8556812Smrg continue 2096d8556812Smrg ;; 209776888252Smrg 209863847c39Smrg -prefer-non-pic) 209963847c39Smrg pic_mode=no 2100d8556812Smrg continue 210176888252Smrg ;; 210263847c39Smrg esac 210363847c39Smrg done 210476888252Smrg 210563847c39Smrg func_quote_for_eval "$libobj" 210663847c39Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 210763847c39Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 210863847c39Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 210963847c39Smrg func_dirname_and_basename "$obj" "/" "" 211063847c39Smrg objname="$func_basename_result" 211163847c39Smrg xdir="$func_dirname_result" 211263847c39Smrg lobj=${xdir}$objdir/$objname 211376888252Smrg 211463847c39Smrg test -z "$base_compile" && \ 211563847c39Smrg func_fatal_help "you must specify a compilation command" 211676888252Smrg 211763847c39Smrg # Delete any leftover library objects. 211863847c39Smrg if test "$build_old_libs" = yes; then 211963847c39Smrg removelist="$obj $lobj $libobj ${libobj}T" 212063847c39Smrg else 212163847c39Smrg removelist="$lobj $libobj ${libobj}T" 212263847c39Smrg fi 212376888252Smrg 212463847c39Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 212563847c39Smrg case $host_os in 212663847c39Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 212763847c39Smrg pic_mode=default 212863847c39Smrg ;; 212963847c39Smrg esac 213063847c39Smrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 213163847c39Smrg # non-PIC code in shared libraries is not supported 213263847c39Smrg pic_mode=default 213363847c39Smrg fi 213476888252Smrg 213563847c39Smrg # Calculate the filename of the output object if compiler does 213663847c39Smrg # not support -o with -c 213763847c39Smrg if test "$compiler_c_o" = no; then 213863847c39Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 213963847c39Smrg lockfile="$output_obj.lock" 214063847c39Smrg else 214163847c39Smrg output_obj= 214263847c39Smrg need_locks=no 214363847c39Smrg lockfile= 214463847c39Smrg fi 214576888252Smrg 214663847c39Smrg # Lock this critical section if it is needed 214763847c39Smrg # We use this script file to make the link, it avoids creating a new file 214863847c39Smrg if test "$need_locks" = yes; then 214963847c39Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 215063847c39Smrg func_echo "Waiting for $lockfile to be removed" 215163847c39Smrg sleep 2 215263847c39Smrg done 215363847c39Smrg elif test "$need_locks" = warn; then 215463847c39Smrg if test -f "$lockfile"; then 215563847c39Smrg $ECHO "\ 215663847c39Smrg*** ERROR, $lockfile exists and contains: 215763847c39Smrg`cat $lockfile 2>/dev/null` 215876888252Smrg 215963847c39SmrgThis indicates that another process is trying to use the same 216063847c39Smrgtemporary object file, and libtool could not work around it because 216163847c39Smrgyour compiler does not support \`-c' and \`-o' together. If you 216263847c39Smrgrepeat this compilation, it may succeed, by chance, but you had better 216363847c39Smrgavoid parallel builds (make -j) in this platform, or get a better 216463847c39Smrgcompiler." 216576888252Smrg 216663847c39Smrg $opt_dry_run || $RM $removelist 216763847c39Smrg exit $EXIT_FAILURE 216863847c39Smrg fi 216963847c39Smrg func_append removelist " $output_obj" 217063847c39Smrg $ECHO "$srcfile" > "$lockfile" 217163847c39Smrg fi 217276888252Smrg 217363847c39Smrg $opt_dry_run || $RM $removelist 217463847c39Smrg func_append removelist " $lockfile" 217563847c39Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 217676888252Smrg 217763847c39Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 217863847c39Smrg srcfile=$func_to_tool_file_result 217963847c39Smrg func_quote_for_eval "$srcfile" 218063847c39Smrg qsrcfile=$func_quote_for_eval_result 218176888252Smrg 218263847c39Smrg # Only build a PIC object if we are building libtool libraries. 218363847c39Smrg if test "$build_libtool_libs" = yes; then 218463847c39Smrg # Without this assignment, base_compile gets emptied. 218563847c39Smrg fbsd_hideous_sh_bug=$base_compile 218676888252Smrg 218763847c39Smrg if test "$pic_mode" != no; then 218863847c39Smrg command="$base_compile $qsrcfile $pic_flag" 218963847c39Smrg else 219063847c39Smrg # Don't build PIC code 219163847c39Smrg command="$base_compile $qsrcfile" 219263847c39Smrg fi 219376888252Smrg 219463847c39Smrg func_mkdir_p "$xdir$objdir" 219576888252Smrg 219663847c39Smrg if test -z "$output_obj"; then 219763847c39Smrg # Place PIC objects in $objdir 219863847c39Smrg func_append command " -o $lobj" 219963847c39Smrg fi 220086dafe34Smrg 220163847c39Smrg func_show_eval_locale "$command" \ 220263847c39Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 220376888252Smrg 220463847c39Smrg if test "$need_locks" = warn && 220563847c39Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 220663847c39Smrg $ECHO "\ 220763847c39Smrg*** ERROR, $lockfile contains: 220863847c39Smrg`cat $lockfile 2>/dev/null` 2209d8556812Smrg 221063847c39Smrgbut it should contain: 221163847c39Smrg$srcfile 2212d8556812Smrg 221363847c39SmrgThis indicates that another process is trying to use the same 221463847c39Smrgtemporary object file, and libtool could not work around it because 221563847c39Smrgyour compiler does not support \`-c' and \`-o' together. If you 221663847c39Smrgrepeat this compilation, it may succeed, by chance, but you had better 221763847c39Smrgavoid parallel builds (make -j) in this platform, or get a better 221863847c39Smrgcompiler." 221976888252Smrg 222063847c39Smrg $opt_dry_run || $RM $removelist 222163847c39Smrg exit $EXIT_FAILURE 222263847c39Smrg fi 222376888252Smrg 222463847c39Smrg # Just move the object if needed, then go on to compile the next one 222563847c39Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 222663847c39Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 222763847c39Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 222863847c39Smrg fi 222976888252Smrg 223063847c39Smrg # Allow error messages only from the first compilation. 223163847c39Smrg if test "$suppress_opt" = yes; then 223263847c39Smrg suppress_output=' >/dev/null 2>&1' 223363847c39Smrg fi 223463847c39Smrg fi 223576888252Smrg 223663847c39Smrg # Only build a position-dependent object if we build old libraries. 223763847c39Smrg if test "$build_old_libs" = yes; then 223863847c39Smrg if test "$pic_mode" != yes; then 223963847c39Smrg # Don't build PIC code 224063847c39Smrg command="$base_compile $qsrcfile$pie_flag" 224163847c39Smrg else 224263847c39Smrg command="$base_compile $qsrcfile $pic_flag" 224363847c39Smrg fi 224463847c39Smrg if test "$compiler_c_o" = yes; then 224563847c39Smrg func_append command " -o $obj" 224663847c39Smrg fi 224776888252Smrg 224863847c39Smrg # Suppress compiler output if we already did a PIC compilation. 224963847c39Smrg func_append command "$suppress_output" 225063847c39Smrg func_show_eval_locale "$command" \ 225163847c39Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 225286dafe34Smrg 225363847c39Smrg if test "$need_locks" = warn && 225463847c39Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 225563847c39Smrg $ECHO "\ 225663847c39Smrg*** ERROR, $lockfile contains: 225763847c39Smrg`cat $lockfile 2>/dev/null` 225876888252Smrg 225963847c39Smrgbut it should contain: 226063847c39Smrg$srcfile 226186dafe34Smrg 226263847c39SmrgThis indicates that another process is trying to use the same 226363847c39Smrgtemporary object file, and libtool could not work around it because 226463847c39Smrgyour compiler does not support \`-c' and \`-o' together. If you 226563847c39Smrgrepeat this compilation, it may succeed, by chance, but you had better 226663847c39Smrgavoid parallel builds (make -j) in this platform, or get a better 226763847c39Smrgcompiler." 226886dafe34Smrg 226963847c39Smrg $opt_dry_run || $RM $removelist 227063847c39Smrg exit $EXIT_FAILURE 227163847c39Smrg fi 227286dafe34Smrg 227363847c39Smrg # Just move the object if needed 227463847c39Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 227563847c39Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 227663847c39Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 227763847c39Smrg fi 227863847c39Smrg fi 227986dafe34Smrg 228063847c39Smrg $opt_dry_run || { 228163847c39Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 228286dafe34Smrg 228363847c39Smrg # Unlock the critical section if it was locked 228463847c39Smrg if test "$need_locks" != no; then 228563847c39Smrg removelist=$lockfile 228663847c39Smrg $RM "$lockfile" 228763847c39Smrg fi 228863847c39Smrg } 228986dafe34Smrg 229063847c39Smrg exit $EXIT_SUCCESS 229163847c39Smrg} 229286dafe34Smrg 229363847c39Smrg$opt_help || { 229463847c39Smrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 229563847c39Smrg} 229686dafe34Smrg 229763847c39Smrgfunc_mode_help () 229863847c39Smrg{ 229963847c39Smrg # We need to display help for each of the modes. 230063847c39Smrg case $opt_mode in 230163847c39Smrg "") 230263847c39Smrg # Generic help is extracted from the usage comments 230363847c39Smrg # at the start of this file. 230463847c39Smrg func_help 230563847c39Smrg ;; 230686dafe34Smrg 230763847c39Smrg clean) 230863847c39Smrg $ECHO \ 230963847c39Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 231086dafe34Smrg 231163847c39SmrgRemove files from the build directory. 2312d8556812Smrg 231363847c39SmrgRM is the name of the program to use to delete files associated with each FILE 231463847c39Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 231563847c39Smrgto RM. 231676888252Smrg 231763847c39SmrgIf FILE is a libtool library, object or program, all the files associated 231863847c39Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 231963847c39Smrg ;; 232076888252Smrg 232163847c39Smrg compile) 232263847c39Smrg $ECHO \ 232363847c39Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 232476888252Smrg 232563847c39SmrgCompile a source file into a libtool library object. 232676888252Smrg 232763847c39SmrgThis mode accepts the following additional options: 232876888252Smrg 232963847c39Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 233063847c39Smrg -no-suppress do not suppress compiler output for multiple passes 233163847c39Smrg -prefer-pic try to build PIC objects only 233263847c39Smrg -prefer-non-pic try to build non-PIC objects only 233363847c39Smrg -shared do not build a \`.o' file suitable for static linking 233463847c39Smrg -static only build a \`.o' file suitable for static linking 233563847c39Smrg -Wc,FLAG pass FLAG directly to the compiler 233686dafe34Smrg 233763847c39SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 233863847c39Smrgfrom the given SOURCEFILE. 233976888252Smrg 234063847c39SmrgThe output file name is determined by removing the directory component from 234163847c39SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 234263847c39Smrglibrary object suffix, \`.lo'." 234363847c39Smrg ;; 234486dafe34Smrg 234563847c39Smrg execute) 234663847c39Smrg $ECHO \ 234763847c39Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 234876888252Smrg 234963847c39SmrgAutomatically set library path, then run a program. 235076888252Smrg 235163847c39SmrgThis mode accepts the following additional options: 235276888252Smrg 235363847c39Smrg -dlopen FILE add the directory containing FILE to the library path 235486dafe34Smrg 235563847c39SmrgThis mode sets the library path environment variable according to \`-dlopen' 235663847c39Smrgflags. 235776888252Smrg 235863847c39SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 235963847c39Smrginto their corresponding uninstalled binary, and any of their required library 236063847c39Smrgdirectories are added to the library path. 236176888252Smrg 236263847c39SmrgThen, COMMAND is executed, with ARGS as arguments." 236363847c39Smrg ;; 236463847c39Smrg 236563847c39Smrg finish) 236663847c39Smrg $ECHO \ 236763847c39Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 236863847c39Smrg 236963847c39SmrgComplete the installation of libtool libraries. 237063847c39Smrg 237163847c39SmrgEach LIBDIR is a directory that contains libtool libraries. 237263847c39Smrg 237363847c39SmrgThe commands that this mode executes may require superuser privileges. Use 237463847c39Smrgthe \`--dry-run' option if you just want to see what would be executed." 237563847c39Smrg ;; 237663847c39Smrg 237763847c39Smrg install) 237863847c39Smrg $ECHO \ 237963847c39Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 238063847c39Smrg 238163847c39SmrgInstall executables or libraries. 238263847c39Smrg 238363847c39SmrgINSTALL-COMMAND is the installation command. The first component should be 238463847c39Smrgeither the \`install' or \`cp' program. 238563847c39Smrg 238663847c39SmrgThe following components of INSTALL-COMMAND are treated specially: 238763847c39Smrg 238863847c39Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 238963847c39Smrg 239063847c39SmrgThe rest of the components are interpreted as arguments to that command (only 239163847c39SmrgBSD-compatible install options are recognized)." 239263847c39Smrg ;; 239363847c39Smrg 239463847c39Smrg link) 239563847c39Smrg $ECHO \ 239663847c39Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 239763847c39Smrg 239863847c39SmrgLink object files or libraries together to form another library, or to 239963847c39Smrgcreate an executable program. 240063847c39Smrg 240163847c39SmrgLINK-COMMAND is a command using the C compiler that you would use to create 240263847c39Smrga program from several object files. 240363847c39Smrg 240463847c39SmrgThe following components of LINK-COMMAND are treated specially: 240563847c39Smrg 240663847c39Smrg -all-static do not do any dynamic linking at all 240763847c39Smrg -avoid-version do not add a version suffix if possible 240863847c39Smrg -bindir BINDIR specify path to binaries directory (for systems where 240963847c39Smrg libraries must be found in the PATH setting at runtime) 241063847c39Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 241163847c39Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 241263847c39Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 241363847c39Smrg -export-symbols SYMFILE 241463847c39Smrg try to export only the symbols listed in SYMFILE 241563847c39Smrg -export-symbols-regex REGEX 241663847c39Smrg try to export only the symbols matching REGEX 241763847c39Smrg -LLIBDIR search LIBDIR for required installed libraries 241863847c39Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 241963847c39Smrg -module build a library that can dlopened 242063847c39Smrg -no-fast-install disable the fast-install mode 242163847c39Smrg -no-install link a not-installable executable 242263847c39Smrg -no-undefined declare that a library does not refer to external symbols 242363847c39Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 242463847c39Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 242563847c39Smrg -precious-files-regex REGEX 242663847c39Smrg don't remove output files matching REGEX 242763847c39Smrg -release RELEASE specify package release information 242863847c39Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 242963847c39Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 243063847c39Smrg -shared only do dynamic linking of libtool libraries 243163847c39Smrg -shrext SUFFIX override the standard shared library file extension 243263847c39Smrg -static do not do any dynamic linking of uninstalled libtool libraries 243363847c39Smrg -static-libtool-libs 243463847c39Smrg do not do any dynamic linking of libtool libraries 243563847c39Smrg -version-info CURRENT[:REVISION[:AGE]] 243663847c39Smrg specify library version info [each variable defaults to 0] 243763847c39Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 243863847c39Smrg -Wc,FLAG 243963847c39Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 244063847c39Smrg -Wl,FLAG 244163847c39Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 244263847c39Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 244363847c39Smrg 244463847c39SmrgAll other options (arguments beginning with \`-') are ignored. 244563847c39Smrg 244663847c39SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 244763847c39Smrgtreated as uninstalled libtool libraries, other files are standard or library 244863847c39Smrgobject files. 244963847c39Smrg 245063847c39SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 245163847c39Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 245263847c39Smrgrequired, except when creating a convenience library. 245363847c39Smrg 245463847c39SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 245563847c39Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 245663847c39Smrg 245763847c39SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 245863847c39Smrgis created, otherwise an executable program is created." 245963847c39Smrg ;; 246063847c39Smrg 246163847c39Smrg uninstall) 246263847c39Smrg $ECHO \ 246363847c39Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 246463847c39Smrg 246563847c39SmrgRemove libraries from an installation directory. 246663847c39Smrg 246763847c39SmrgRM is the name of the program to use to delete files associated with each FILE 246863847c39Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 246963847c39Smrgto RM. 247063847c39Smrg 247163847c39SmrgIf FILE is a libtool library, all the files associated with it are deleted. 247263847c39SmrgOtherwise, only FILE itself is deleted using RM." 247363847c39Smrg ;; 247463847c39Smrg 247563847c39Smrg *) 247663847c39Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 247763847c39Smrg ;; 2478d8556812Smrg esac 247976888252Smrg 248063847c39Smrg echo 248163847c39Smrg $ECHO "Try \`$progname --help' for more information about other modes." 248263847c39Smrg} 248386dafe34Smrg 248463847c39Smrg# Now that we've collected a possible --mode arg, show help if necessary 248563847c39Smrgif $opt_help; then 248663847c39Smrg if test "$opt_help" = :; then 248763847c39Smrg func_mode_help 248863847c39Smrg else 248963847c39Smrg { 249063847c39Smrg func_help noexit 249163847c39Smrg for opt_mode in compile link execute install finish uninstall clean; do 249263847c39Smrg func_mode_help 249363847c39Smrg done 249463847c39Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 249563847c39Smrg { 249663847c39Smrg func_help noexit 249763847c39Smrg for opt_mode in compile link execute install finish uninstall clean; do 249863847c39Smrg echo 249963847c39Smrg func_mode_help 250063847c39Smrg done 250163847c39Smrg } | 250263847c39Smrg sed '1d 250363847c39Smrg /^When reporting/,/^Report/{ 250463847c39Smrg H 250563847c39Smrg d 250663847c39Smrg } 250763847c39Smrg $x 250863847c39Smrg /information about other modes/d 250963847c39Smrg /more detailed .*MODE/d 251063847c39Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 251163847c39Smrg fi 251263847c39Smrg exit $? 251363847c39Smrgfi 251486dafe34Smrg 251586dafe34Smrg 251663847c39Smrg# func_mode_execute arg... 251763847c39Smrgfunc_mode_execute () 251863847c39Smrg{ 251963847c39Smrg $opt_debug 252063847c39Smrg # The first argument is the command name. 252163847c39Smrg cmd="$nonopt" 252263847c39Smrg test -z "$cmd" && \ 252363847c39Smrg func_fatal_help "you must specify a COMMAND" 252463847c39Smrg 252563847c39Smrg # Handle -dlopen flags immediately. 252663847c39Smrg for file in $opt_dlopen; do 252763847c39Smrg test -f "$file" \ 252863847c39Smrg || func_fatal_help "\`$file' is not a file" 252963847c39Smrg 253063847c39Smrg dir= 253163847c39Smrg case $file in 253263847c39Smrg *.la) 253363847c39Smrg func_resolve_sysroot "$file" 253463847c39Smrg file=$func_resolve_sysroot_result 253563847c39Smrg 253663847c39Smrg # Check to see that this really is a libtool archive. 253763847c39Smrg func_lalib_unsafe_p "$file" \ 253863847c39Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 253963847c39Smrg 254063847c39Smrg # Read the libtool library. 254163847c39Smrg dlname= 254263847c39Smrg library_names= 254363847c39Smrg func_source "$file" 254463847c39Smrg 254563847c39Smrg # Skip this library if it cannot be dlopened. 254663847c39Smrg if test -z "$dlname"; then 254763847c39Smrg # Warn if it was a shared library. 254863847c39Smrg test -n "$library_names" && \ 254963847c39Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 255063847c39Smrg continue 255163847c39Smrg fi 255263847c39Smrg 255363847c39Smrg func_dirname "$file" "" "." 255463847c39Smrg dir="$func_dirname_result" 255563847c39Smrg 255663847c39Smrg if test -f "$dir/$objdir/$dlname"; then 255763847c39Smrg func_append dir "/$objdir" 255863847c39Smrg else 255963847c39Smrg if test ! -f "$dir/$dlname"; then 256063847c39Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 256163847c39Smrg fi 256263847c39Smrg fi 256386dafe34Smrg ;; 256463847c39Smrg 256563847c39Smrg *.lo) 256663847c39Smrg # Just add the directory containing the .lo file. 256763847c39Smrg func_dirname "$file" "" "." 256863847c39Smrg dir="$func_dirname_result" 2569d8556812Smrg ;; 257063847c39Smrg 257163847c39Smrg *) 257263847c39Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 257363847c39Smrg continue 257486dafe34Smrg ;; 257563847c39Smrg esac 257663847c39Smrg 257763847c39Smrg # Get the absolute pathname. 257863847c39Smrg absdir=`cd "$dir" && pwd` 257963847c39Smrg test -n "$absdir" && dir="$absdir" 258063847c39Smrg 258163847c39Smrg # Now add the directory to shlibpath_var. 258263847c39Smrg if eval "test -z \"\$$shlibpath_var\""; then 258363847c39Smrg eval "$shlibpath_var=\"\$dir\"" 258463847c39Smrg else 258563847c39Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2586d8556812Smrg fi 258763847c39Smrg done 258863847c39Smrg 258963847c39Smrg # This variable tells wrapper scripts just to set shlibpath_var 259063847c39Smrg # rather than running their programs. 259163847c39Smrg libtool_execute_magic="$magic" 259263847c39Smrg 259363847c39Smrg # Check if any of the arguments is a wrapper script. 259463847c39Smrg args= 259563847c39Smrg for file 259663847c39Smrg do 259763847c39Smrg case $file in 259863847c39Smrg -* | *.la | *.lo ) ;; 259963847c39Smrg *) 260063847c39Smrg # Do a test to see if this is really a libtool program. 260163847c39Smrg if func_ltwrapper_script_p "$file"; then 260263847c39Smrg func_source "$file" 260363847c39Smrg # Transform arg to wrapped name. 260463847c39Smrg file="$progdir/$program" 260563847c39Smrg elif func_ltwrapper_executable_p "$file"; then 260663847c39Smrg func_ltwrapper_scriptname "$file" 260763847c39Smrg func_source "$func_ltwrapper_scriptname_result" 260863847c39Smrg # Transform arg to wrapped name. 260963847c39Smrg file="$progdir/$program" 261063847c39Smrg fi 261163847c39Smrg ;; 261263847c39Smrg esac 261363847c39Smrg # Quote arguments (to preserve shell metacharacters). 261463847c39Smrg func_append_quoted args "$file" 261563847c39Smrg done 261663847c39Smrg 261763847c39Smrg if test "X$opt_dry_run" = Xfalse; then 261863847c39Smrg if test -n "$shlibpath_var"; then 261963847c39Smrg # Export the shlibpath_var. 262063847c39Smrg eval "export $shlibpath_var" 2621d8556812Smrg fi 262263847c39Smrg 262363847c39Smrg # Restore saved environment variables 262463847c39Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 262563847c39Smrg do 262663847c39Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 262763847c39Smrg $lt_var=\$save_$lt_var; export $lt_var 262863847c39Smrg else 262963847c39Smrg $lt_unset $lt_var 263063847c39Smrg fi" 263163847c39Smrg done 263263847c39Smrg 263363847c39Smrg # Now prepare to actually exec the command. 263463847c39Smrg exec_cmd="\$cmd$args" 263563847c39Smrg else 263663847c39Smrg # Display what would be done. 263763847c39Smrg if test -n "$shlibpath_var"; then 263863847c39Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 263963847c39Smrg echo "export $shlibpath_var" 2640d8556812Smrg fi 264163847c39Smrg $ECHO "$cmd$args" 264263847c39Smrg exit $EXIT_SUCCESS 264363847c39Smrg fi 264463847c39Smrg} 264576888252Smrg 264663847c39Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 264776888252Smrg 264876888252Smrg 264963847c39Smrg# func_mode_finish arg... 265063847c39Smrgfunc_mode_finish () 265163847c39Smrg{ 265263847c39Smrg $opt_debug 265363847c39Smrg libs= 265463847c39Smrg libdirs= 265563847c39Smrg admincmds= 265676888252Smrg 265763847c39Smrg for opt in "$nonopt" ${1+"$@"} 265863847c39Smrg do 265963847c39Smrg if test -d "$opt"; then 266063847c39Smrg func_append libdirs " $opt" 266176888252Smrg 266263847c39Smrg elif test -f "$opt"; then 266363847c39Smrg if func_lalib_unsafe_p "$opt"; then 266463847c39Smrg func_append libs " $opt" 266563847c39Smrg else 266663847c39Smrg func_warning "\`$opt' is not a valid libtool archive" 2667d8556812Smrg fi 266876888252Smrg 266963847c39Smrg else 267063847c39Smrg func_fatal_error "invalid argument \`$opt'" 267163847c39Smrg fi 267263847c39Smrg done 267376888252Smrg 267463847c39Smrg if test -n "$libs"; then 267563847c39Smrg if test -n "$lt_sysroot"; then 267663847c39Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 267763847c39Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 267863847c39Smrg else 267963847c39Smrg sysroot_cmd= 268063847c39Smrg fi 268176888252Smrg 268263847c39Smrg # Remove sysroot references 268363847c39Smrg if $opt_dry_run; then 268463847c39Smrg for lib in $libs; do 268563847c39Smrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 268663847c39Smrg done 268763847c39Smrg else 268863847c39Smrg tmpdir=`func_mktempdir` 268963847c39Smrg for lib in $libs; do 269063847c39Smrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 269163847c39Smrg > $tmpdir/tmp-la 269263847c39Smrg mv -f $tmpdir/tmp-la $lib 2693d8556812Smrg done 269463847c39Smrg ${RM}r "$tmpdir" 269563847c39Smrg fi 269663847c39Smrg fi 269763847c39Smrg 269863847c39Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 269963847c39Smrg for libdir in $libdirs; do 270063847c39Smrg if test -n "$finish_cmds"; then 270163847c39Smrg # Do each command in the finish commands. 270263847c39Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 270363847c39Smrg'"$cmd"'"' 270463847c39Smrg fi 270563847c39Smrg if test -n "$finish_eval"; then 270663847c39Smrg # Do the single finish_eval. 270763847c39Smrg eval cmds=\"$finish_eval\" 270863847c39Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 270963847c39Smrg $cmds" 271076888252Smrg fi 271163847c39Smrg done 271263847c39Smrg fi 271376888252Smrg 271463847c39Smrg # Exit here if they wanted silent mode. 271563847c39Smrg $opt_silent && exit $EXIT_SUCCESS 271676888252Smrg 271763847c39Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 271863847c39Smrg echo "----------------------------------------------------------------------" 271963847c39Smrg echo "Libraries have been installed in:" 272063847c39Smrg for libdir in $libdirs; do 272163847c39Smrg $ECHO " $libdir" 272263847c39Smrg done 272363847c39Smrg echo 272463847c39Smrg echo "If you ever happen to want to link against installed libraries" 272563847c39Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 272663847c39Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 272763847c39Smrg echo "flag during linking and do at least one of the following:" 272863847c39Smrg if test -n "$shlibpath_var"; then 272963847c39Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 273063847c39Smrg echo " during execution" 273163847c39Smrg fi 273263847c39Smrg if test -n "$runpath_var"; then 273363847c39Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 273463847c39Smrg echo " during linking" 273563847c39Smrg fi 273663847c39Smrg if test -n "$hardcode_libdir_flag_spec"; then 273763847c39Smrg libdir=LIBDIR 273863847c39Smrg eval flag=\"$hardcode_libdir_flag_spec\" 273963847c39Smrg 274063847c39Smrg $ECHO " - use the \`$flag' linker flag" 274163847c39Smrg fi 274263847c39Smrg if test -n "$admincmds"; then 274363847c39Smrg $ECHO " - have your system administrator run these commands:$admincmds" 274463847c39Smrg fi 274563847c39Smrg if test -f /etc/ld.so.conf; then 274663847c39Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 274763847c39Smrg fi 274863847c39Smrg echo 274963847c39Smrg 275063847c39Smrg echo "See any operating system documentation about shared libraries for" 275163847c39Smrg case $host in 275263847c39Smrg solaris2.[6789]|solaris2.1[0-9]) 275363847c39Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 275463847c39Smrg echo "pages." 275563847c39Smrg ;; 2756d8556812Smrg *) 275763847c39Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 2758d8556812Smrg ;; 275963847c39Smrg esac 276063847c39Smrg echo "----------------------------------------------------------------------" 276163847c39Smrg fi 276263847c39Smrg exit $EXIT_SUCCESS 276363847c39Smrg} 276476888252Smrg 276563847c39Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 276676888252Smrg 276776888252Smrg 276863847c39Smrg# func_mode_install arg... 276963847c39Smrgfunc_mode_install () 277063847c39Smrg{ 277163847c39Smrg $opt_debug 277263847c39Smrg # There may be an optional sh(1) argument at the beginning of 277363847c39Smrg # install_prog (especially on Windows NT). 277463847c39Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 277563847c39Smrg # Allow the use of GNU shtool's install command. 277663847c39Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 277763847c39Smrg # Aesthetically quote it. 277863847c39Smrg func_quote_for_eval "$nonopt" 277963847c39Smrg install_prog="$func_quote_for_eval_result " 278063847c39Smrg arg=$1 278163847c39Smrg shift 278263847c39Smrg else 278363847c39Smrg install_prog= 278463847c39Smrg arg=$nonopt 278563847c39Smrg fi 278663847c39Smrg 278763847c39Smrg # The real first argument should be the name of the installation program. 278863847c39Smrg # Aesthetically quote it. 278963847c39Smrg func_quote_for_eval "$arg" 279063847c39Smrg func_append install_prog "$func_quote_for_eval_result" 279163847c39Smrg install_shared_prog=$install_prog 279263847c39Smrg case " $install_prog " in 279363847c39Smrg *[\\\ /]cp\ *) install_cp=: ;; 279463847c39Smrg *) install_cp=false ;; 279563847c39Smrg esac 279663847c39Smrg 279763847c39Smrg # We need to accept at least all the BSD install flags. 279863847c39Smrg dest= 279963847c39Smrg files= 280063847c39Smrg opts= 280163847c39Smrg prev= 280263847c39Smrg install_type= 280363847c39Smrg isdir=no 280463847c39Smrg stripme= 280563847c39Smrg no_mode=: 280663847c39Smrg for arg 280763847c39Smrg do 280863847c39Smrg arg2= 280963847c39Smrg if test -n "$dest"; then 281063847c39Smrg func_append files " $dest" 281163847c39Smrg dest=$arg 281263847c39Smrg continue 281363847c39Smrg fi 281463847c39Smrg 281563847c39Smrg case $arg in 281663847c39Smrg -d) isdir=yes ;; 281763847c39Smrg -f) 281863847c39Smrg if $install_cp; then :; else 281963847c39Smrg prev=$arg 282063847c39Smrg fi 282163847c39Smrg ;; 282263847c39Smrg -g | -m | -o) 282363847c39Smrg prev=$arg 282463847c39Smrg ;; 282563847c39Smrg -s) 282663847c39Smrg stripme=" -s" 282763847c39Smrg continue 282863847c39Smrg ;; 282963847c39Smrg -*) 283063847c39Smrg ;; 283163847c39Smrg *) 283263847c39Smrg # If the previous option needed an argument, then skip it. 283363847c39Smrg if test -n "$prev"; then 283463847c39Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 283563847c39Smrg arg2=$install_override_mode 283663847c39Smrg no_mode=false 2837d8556812Smrg fi 283863847c39Smrg prev= 283963847c39Smrg else 284063847c39Smrg dest=$arg 2841d8556812Smrg continue 2842d8556812Smrg fi 284363847c39Smrg ;; 284463847c39Smrg esac 284576888252Smrg 284663847c39Smrg # Aesthetically quote the argument. 284763847c39Smrg func_quote_for_eval "$arg" 284863847c39Smrg func_append install_prog " $func_quote_for_eval_result" 284963847c39Smrg if test -n "$arg2"; then 285063847c39Smrg func_quote_for_eval "$arg2" 285163847c39Smrg fi 285263847c39Smrg func_append install_shared_prog " $func_quote_for_eval_result" 285363847c39Smrg done 285476888252Smrg 285563847c39Smrg test -z "$install_prog" && \ 285663847c39Smrg func_fatal_help "you must specify an install program" 285776888252Smrg 285863847c39Smrg test -n "$prev" && \ 285963847c39Smrg func_fatal_help "the \`$prev' option requires an argument" 286076888252Smrg 286163847c39Smrg if test -n "$install_override_mode" && $no_mode; then 286263847c39Smrg if $install_cp; then :; else 286363847c39Smrg func_quote_for_eval "$install_override_mode" 286463847c39Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 286563847c39Smrg fi 286663847c39Smrg fi 286776888252Smrg 286863847c39Smrg if test -z "$files"; then 286963847c39Smrg if test -z "$dest"; then 287063847c39Smrg func_fatal_help "no file or destination specified" 287163847c39Smrg else 287263847c39Smrg func_fatal_help "you must specify a destination" 287363847c39Smrg fi 287463847c39Smrg fi 287576888252Smrg 287663847c39Smrg # Strip any trailing slash from the destination. 287763847c39Smrg func_stripname '' '/' "$dest" 287863847c39Smrg dest=$func_stripname_result 287976888252Smrg 288063847c39Smrg # Check to see that the destination is a directory. 288163847c39Smrg test -d "$dest" && isdir=yes 288263847c39Smrg if test "$isdir" = yes; then 288363847c39Smrg destdir="$dest" 288463847c39Smrg destname= 288563847c39Smrg else 288663847c39Smrg func_dirname_and_basename "$dest" "" "." 288763847c39Smrg destdir="$func_dirname_result" 288863847c39Smrg destname="$func_basename_result" 288976888252Smrg 289063847c39Smrg # Not a directory, so check to see that there is only one file specified. 289163847c39Smrg set dummy $files; shift 289263847c39Smrg test "$#" -gt 1 && \ 289363847c39Smrg func_fatal_help "\`$dest' is not a directory" 289463847c39Smrg fi 289563847c39Smrg case $destdir in 289663847c39Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 289763847c39Smrg *) 289863847c39Smrg for file in $files; do 289963847c39Smrg case $file in 290063847c39Smrg *.lo) ;; 290163847c39Smrg *) 290263847c39Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 290363847c39Smrg ;; 290463847c39Smrg esac 290563847c39Smrg done 290663847c39Smrg ;; 290763847c39Smrg esac 290876888252Smrg 290963847c39Smrg # This variable tells wrapper scripts just to set variables rather 291063847c39Smrg # than running their programs. 291163847c39Smrg libtool_install_magic="$magic" 291276888252Smrg 291363847c39Smrg staticlibs= 291463847c39Smrg future_libdirs= 291563847c39Smrg current_libdirs= 291663847c39Smrg for file in $files; do 291776888252Smrg 291863847c39Smrg # Do each installation. 291963847c39Smrg case $file in 292063847c39Smrg *.$libext) 292163847c39Smrg # Do the static libraries later. 292263847c39Smrg func_append staticlibs " $file" 292363847c39Smrg ;; 292476888252Smrg 292563847c39Smrg *.la) 292663847c39Smrg func_resolve_sysroot "$file" 292763847c39Smrg file=$func_resolve_sysroot_result 292876888252Smrg 292963847c39Smrg # Check to see that this really is a libtool archive. 293063847c39Smrg func_lalib_unsafe_p "$file" \ 293163847c39Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 293276888252Smrg 293363847c39Smrg library_names= 293463847c39Smrg old_library= 293563847c39Smrg relink_command= 293663847c39Smrg func_source "$file" 293776888252Smrg 293863847c39Smrg # Add the libdir to current_libdirs if it is the destination. 293963847c39Smrg if test "X$destdir" = "X$libdir"; then 294063847c39Smrg case "$current_libdirs " in 294163847c39Smrg *" $libdir "*) ;; 294263847c39Smrg *) func_append current_libdirs " $libdir" ;; 294363847c39Smrg esac 294463847c39Smrg else 294563847c39Smrg # Note the libdir as a future libdir. 294663847c39Smrg case "$future_libdirs " in 294763847c39Smrg *" $libdir "*) ;; 294863847c39Smrg *) func_append future_libdirs " $libdir" ;; 294963847c39Smrg esac 295063847c39Smrg fi 295176888252Smrg 295263847c39Smrg func_dirname "$file" "/" "" 295363847c39Smrg dir="$func_dirname_result" 295463847c39Smrg func_append dir "$objdir" 295576888252Smrg 295663847c39Smrg if test -n "$relink_command"; then 295763847c39Smrg # Determine the prefix the user has applied to our future dir. 295863847c39Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 295976888252Smrg 296063847c39Smrg # Don't allow the user to place us outside of our expected 296163847c39Smrg # location b/c this prevents finding dependent libraries that 296263847c39Smrg # are installed to the same prefix. 296363847c39Smrg # At present, this check doesn't affect windows .dll's that 296463847c39Smrg # are installed into $libdir/../bin (currently, that works fine) 296563847c39Smrg # but it's something to keep an eye on. 296663847c39Smrg test "$inst_prefix_dir" = "$destdir" && \ 296763847c39Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 296863847c39Smrg 296963847c39Smrg if test -n "$inst_prefix_dir"; then 297063847c39Smrg # Stick the inst_prefix_dir data into the link command. 297163847c39Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2972d8556812Smrg else 297363847c39Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2974d8556812Smrg fi 297576888252Smrg 297663847c39Smrg func_warning "relinking \`$file'" 297763847c39Smrg func_show_eval "$relink_command" \ 297863847c39Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 297963847c39Smrg fi 298063847c39Smrg 298163847c39Smrg # See the names of the shared library. 298263847c39Smrg set dummy $library_names; shift 298363847c39Smrg if test -n "$1"; then 298463847c39Smrg realname="$1" 298563847c39Smrg shift 298663847c39Smrg 298763847c39Smrg srcname="$realname" 298863847c39Smrg test -n "$relink_command" && srcname="$realname"T 298963847c39Smrg 299063847c39Smrg # Install the shared library and build the symlinks. 299163847c39Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 299263847c39Smrg 'exit $?' 299363847c39Smrg tstripme="$stripme" 299463847c39Smrg case $host_os in 299563847c39Smrg cygwin* | mingw* | pw32* | cegcc*) 299663847c39Smrg case $realname in 299763847c39Smrg *.dll.a) 299863847c39Smrg tstripme="" 299963847c39Smrg ;; 300063847c39Smrg esac 300163847c39Smrg ;; 300263847c39Smrg esac 300363847c39Smrg if test -n "$tstripme" && test -n "$striplib"; then 300463847c39Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 3005d8556812Smrg fi 300676888252Smrg 300763847c39Smrg if test "$#" -gt 0; then 300863847c39Smrg # Delete the old symlinks, and create new ones. 300963847c39Smrg # Try `ln -sf' first, because the `ln' binary might depend on 301063847c39Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 301163847c39Smrg # so we also need to try rm && ln -s. 301263847c39Smrg for linkname 301363847c39Smrg do 301463847c39Smrg test "$linkname" != "$realname" \ 301563847c39Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3016d8556812Smrg done 3017d8556812Smrg fi 301876888252Smrg 301963847c39Smrg # Do each command in the postinstall commands. 302063847c39Smrg lib="$destdir/$realname" 302163847c39Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 302263847c39Smrg fi 302386dafe34Smrg 302463847c39Smrg # Install the pseudo-library for information purposes. 302563847c39Smrg func_basename "$file" 302663847c39Smrg name="$func_basename_result" 302763847c39Smrg instname="$dir/$name"i 302863847c39Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3029d8556812Smrg 303063847c39Smrg # Maybe install the static library, too. 303163847c39Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 303263847c39Smrg ;; 303363847c39Smrg 303463847c39Smrg *.lo) 303563847c39Smrg # Install (i.e. copy) a libtool object. 303663847c39Smrg 303763847c39Smrg # Figure out destination file name, if it wasn't already specified. 303863847c39Smrg if test -n "$destname"; then 303963847c39Smrg destfile="$destdir/$destname" 3040d8556812Smrg else 304163847c39Smrg func_basename "$file" 304263847c39Smrg destfile="$func_basename_result" 304363847c39Smrg destfile="$destdir/$destfile" 3044d8556812Smrg fi 304563847c39Smrg 304663847c39Smrg # Deduce the name of the destination old-style object file. 304763847c39Smrg case $destfile in 304863847c39Smrg *.lo) 304963847c39Smrg func_lo2o "$destfile" 305063847c39Smrg staticdest=$func_lo2o_result 305163847c39Smrg ;; 305263847c39Smrg *.$objext) 305363847c39Smrg staticdest="$destfile" 305463847c39Smrg destfile= 305563847c39Smrg ;; 305663847c39Smrg *) 305763847c39Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 305886dafe34Smrg ;; 305986dafe34Smrg esac 306086dafe34Smrg 306163847c39Smrg # Install the libtool object if requested. 306263847c39Smrg test -n "$destfile" && \ 306363847c39Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 306486dafe34Smrg 306563847c39Smrg # Install the old object if enabled. 306663847c39Smrg if test "$build_old_libs" = yes; then 306763847c39Smrg # Deduce the name of the old-style object file. 306863847c39Smrg func_lo2o "$file" 306963847c39Smrg staticobj=$func_lo2o_result 307063847c39Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 307163847c39Smrg fi 307263847c39Smrg exit $EXIT_SUCCESS 307363847c39Smrg ;; 307476888252Smrg 307563847c39Smrg *) 307663847c39Smrg # Figure out destination file name, if it wasn't already specified. 307763847c39Smrg if test -n "$destname"; then 307863847c39Smrg destfile="$destdir/$destname" 307963847c39Smrg else 308063847c39Smrg func_basename "$file" 308163847c39Smrg destfile="$func_basename_result" 308263847c39Smrg destfile="$destdir/$destfile" 308363847c39Smrg fi 308476888252Smrg 308563847c39Smrg # If the file is missing, and there is a .exe on the end, strip it 308663847c39Smrg # because it is most likely a libtool script we actually want to 308763847c39Smrg # install 308863847c39Smrg stripped_ext="" 308963847c39Smrg case $file in 309063847c39Smrg *.exe) 309163847c39Smrg if test ! -f "$file"; then 309263847c39Smrg func_stripname '' '.exe' "$file" 309363847c39Smrg file=$func_stripname_result 309463847c39Smrg stripped_ext=".exe" 309563847c39Smrg fi 309663847c39Smrg ;; 309763847c39Smrg esac 309876888252Smrg 309963847c39Smrg # Do a test to see if this is really a libtool program. 310063847c39Smrg case $host in 310163847c39Smrg *cygwin* | *mingw*) 310263847c39Smrg if func_ltwrapper_executable_p "$file"; then 310363847c39Smrg func_ltwrapper_scriptname "$file" 310463847c39Smrg wrapper=$func_ltwrapper_scriptname_result 310563847c39Smrg else 310663847c39Smrg func_stripname '' '.exe' "$file" 310763847c39Smrg wrapper=$func_stripname_result 310863847c39Smrg fi 310963847c39Smrg ;; 311063847c39Smrg *) 311163847c39Smrg wrapper=$file 311263847c39Smrg ;; 311363847c39Smrg esac 311463847c39Smrg if func_ltwrapper_script_p "$wrapper"; then 311563847c39Smrg notinst_deplibs= 311663847c39Smrg relink_command= 311776888252Smrg 311863847c39Smrg func_source "$wrapper" 311976888252Smrg 312063847c39Smrg # Check the variables that should have been set. 312163847c39Smrg test -z "$generated_by_libtool_version" && \ 312263847c39Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 312376888252Smrg 312463847c39Smrg finalize=yes 312563847c39Smrg for lib in $notinst_deplibs; do 312663847c39Smrg # Check to see that each library is installed. 312763847c39Smrg libdir= 312863847c39Smrg if test -f "$lib"; then 312963847c39Smrg func_source "$lib" 313063847c39Smrg fi 313163847c39Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 313263847c39Smrg if test -n "$libdir" && test ! -f "$libfile"; then 313363847c39Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 313463847c39Smrg finalize=no 313563847c39Smrg fi 313663847c39Smrg done 313776888252Smrg 313863847c39Smrg relink_command= 313963847c39Smrg func_source "$wrapper" 314063847c39Smrg 314163847c39Smrg outputname= 314263847c39Smrg if test "$fast_install" = no && test -n "$relink_command"; then 314363847c39Smrg $opt_dry_run || { 314463847c39Smrg if test "$finalize" = yes; then 314563847c39Smrg tmpdir=`func_mktempdir` 314663847c39Smrg func_basename "$file$stripped_ext" 314763847c39Smrg file="$func_basename_result" 314863847c39Smrg outputname="$tmpdir/$file" 314963847c39Smrg # Replace the output file specification. 315063847c39Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 315163847c39Smrg 315263847c39Smrg $opt_silent || { 315363847c39Smrg func_quote_for_expand "$relink_command" 315463847c39Smrg eval "func_echo $func_quote_for_expand_result" 315563847c39Smrg } 315663847c39Smrg if eval "$relink_command"; then : 315763847c39Smrg else 315863847c39Smrg func_error "error: relink \`$file' with the above command before installing it" 315963847c39Smrg $opt_dry_run || ${RM}r "$tmpdir" 316063847c39Smrg continue 316163847c39Smrg fi 316263847c39Smrg file="$outputname" 316363847c39Smrg else 316463847c39Smrg func_warning "cannot relink \`$file'" 316563847c39Smrg fi 316663847c39Smrg } 316763847c39Smrg else 316863847c39Smrg # Install the binary that we compiled earlier. 316963847c39Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 317063847c39Smrg fi 3171d8556812Smrg fi 317263847c39Smrg 317363847c39Smrg # remove .exe since cygwin /usr/bin/install will append another 317463847c39Smrg # one anyway 317563847c39Smrg case $install_prog,$host in 317663847c39Smrg */usr/bin/install*,*cygwin*) 317763847c39Smrg case $file:$destfile in 317863847c39Smrg *.exe:*.exe) 317963847c39Smrg # this is ok 318063847c39Smrg ;; 318163847c39Smrg *.exe:*) 318263847c39Smrg destfile=$destfile.exe 318363847c39Smrg ;; 318463847c39Smrg *:*.exe) 318563847c39Smrg func_stripname '' '.exe' "$destfile" 318663847c39Smrg destfile=$func_stripname_result 318763847c39Smrg ;; 318863847c39Smrg esac 318963847c39Smrg ;; 319063847c39Smrg esac 319163847c39Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 319263847c39Smrg $opt_dry_run || if test -n "$outputname"; then 319363847c39Smrg ${RM}r "$tmpdir" 3194d8556812Smrg fi 3195d8556812Smrg ;; 3196d8556812Smrg esac 319763847c39Smrg done 319886dafe34Smrg 319963847c39Smrg for file in $staticlibs; do 320063847c39Smrg func_basename "$file" 320163847c39Smrg name="$func_basename_result" 320286dafe34Smrg 320363847c39Smrg # Set up the ranlib parameters. 320463847c39Smrg oldlib="$destdir/$name" 320563847c39Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 320663847c39Smrg tool_oldlib=$func_to_tool_file_result 320786dafe34Smrg 320863847c39Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 320963847c39Smrg 321063847c39Smrg if test -n "$stripme" && test -n "$old_striplib"; then 321163847c39Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 3212d8556812Smrg fi 321386dafe34Smrg 321463847c39Smrg # Do each command in the postinstall commands. 321563847c39Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 321663847c39Smrg done 321786dafe34Smrg 321863847c39Smrg test -n "$future_libdirs" && \ 321963847c39Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 322086dafe34Smrg 322163847c39Smrg if test -n "$current_libdirs"; then 322263847c39Smrg # Maybe just do a dry run. 322363847c39Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 322463847c39Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 322563847c39Smrg else 322663847c39Smrg exit $EXIT_SUCCESS 322763847c39Smrg fi 322863847c39Smrg} 322986dafe34Smrg 323063847c39Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 323186dafe34Smrg 323286dafe34Smrg 323363847c39Smrg# func_generate_dlsyms outputname originator pic_p 323463847c39Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 323563847c39Smrg# a dlpreopen symbol table. 323663847c39Smrgfunc_generate_dlsyms () 323763847c39Smrg{ 323863847c39Smrg $opt_debug 323963847c39Smrg my_outputname="$1" 324063847c39Smrg my_originator="$2" 324163847c39Smrg my_pic_p="${3-no}" 324263847c39Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 324363847c39Smrg my_dlsyms= 324463847c39Smrg 324563847c39Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 324663847c39Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 324763847c39Smrg my_dlsyms="${my_outputname}S.c" 324863847c39Smrg else 324963847c39Smrg func_error "not configured to extract global symbols from dlpreopened files" 325063847c39Smrg fi 325163847c39Smrg fi 325286dafe34Smrg 325363847c39Smrg if test -n "$my_dlsyms"; then 325463847c39Smrg case $my_dlsyms in 325563847c39Smrg "") ;; 325663847c39Smrg *.c) 325763847c39Smrg # Discover the nlist of each of the dlfiles. 325863847c39Smrg nlist="$output_objdir/${my_outputname}.nm" 325986dafe34Smrg 326063847c39Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 326186dafe34Smrg 326263847c39Smrg # Parse the name list into a source file. 326363847c39Smrg func_verbose "creating $output_objdir/$my_dlsyms" 326486dafe34Smrg 326563847c39Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 326663847c39Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 326763847c39Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 326886dafe34Smrg 326963847c39Smrg#ifdef __cplusplus 327063847c39Smrgextern \"C\" { 327163847c39Smrg#endif 327286dafe34Smrg 327363847c39Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 327463847c39Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 327563847c39Smrg#endif 327686dafe34Smrg 327763847c39Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 327863847c39Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 327963847c39Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 328063847c39Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 328163847c39Smrg# define LT_DLSYM_CONST 328263847c39Smrg#elif defined(__osf__) 328363847c39Smrg/* This system does not cope well with relocations in const data. */ 328463847c39Smrg# define LT_DLSYM_CONST 328563847c39Smrg#else 328663847c39Smrg# define LT_DLSYM_CONST const 328763847c39Smrg#endif 328886dafe34Smrg 328963847c39Smrg/* External symbol declarations for the compiler. */\ 329063847c39Smrg" 329186dafe34Smrg 329263847c39Smrg if test "$dlself" = yes; then 329363847c39Smrg func_verbose "generating symbol list for \`$output'" 329486dafe34Smrg 329563847c39Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 329676888252Smrg 329763847c39Smrg # Add our own program objects to the symbol list. 329863847c39Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 329963847c39Smrg for progfile in $progfiles; do 330063847c39Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 330163847c39Smrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 330263847c39Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3303d8556812Smrg done 330476888252Smrg 330563847c39Smrg if test -n "$exclude_expsyms"; then 330663847c39Smrg $opt_dry_run || { 330763847c39Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 330863847c39Smrg eval '$MV "$nlist"T "$nlist"' 330963847c39Smrg } 331063847c39Smrg fi 331176888252Smrg 331263847c39Smrg if test -n "$export_symbols_regex"; then 331363847c39Smrg $opt_dry_run || { 331463847c39Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 331563847c39Smrg eval '$MV "$nlist"T "$nlist"' 331663847c39Smrg } 331763847c39Smrg fi 331876888252Smrg 331963847c39Smrg # Prepare the list of exported symbols 332063847c39Smrg if test -z "$export_symbols"; then 332163847c39Smrg export_symbols="$output_objdir/$outputname.exp" 332263847c39Smrg $opt_dry_run || { 332363847c39Smrg $RM $export_symbols 332463847c39Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 332563847c39Smrg case $host in 332663847c39Smrg *cygwin* | *mingw* | *cegcc* ) 332763847c39Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 332863847c39Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 332963847c39Smrg ;; 333063847c39Smrg esac 333163847c39Smrg } 333263847c39Smrg else 333363847c39Smrg $opt_dry_run || { 333463847c39Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 333563847c39Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 333663847c39Smrg eval '$MV "$nlist"T "$nlist"' 333763847c39Smrg case $host in 333863847c39Smrg *cygwin* | *mingw* | *cegcc* ) 333963847c39Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 334063847c39Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 334163847c39Smrg ;; 334263847c39Smrg esac 334363847c39Smrg } 334463847c39Smrg fi 334563847c39Smrg fi 334676888252Smrg 334763847c39Smrg for dlprefile in $dlprefiles; do 334863847c39Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 334963847c39Smrg func_basename "$dlprefile" 335063847c39Smrg name="$func_basename_result" 335163847c39Smrg case $host in 335263847c39Smrg *cygwin* | *mingw* | *cegcc* ) 335363847c39Smrg # if an import library, we need to obtain dlname 335463847c39Smrg if func_win32_import_lib_p "$dlprefile"; then 335563847c39Smrg func_tr_sh "$dlprefile" 335663847c39Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 335763847c39Smrg dlprefile_dlbasename="" 335863847c39Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 335963847c39Smrg # Use subshell, to avoid clobbering current variable values 336063847c39Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 336163847c39Smrg if test -n "$dlprefile_dlname" ; then 336263847c39Smrg func_basename "$dlprefile_dlname" 336363847c39Smrg dlprefile_dlbasename="$func_basename_result" 336463847c39Smrg else 336563847c39Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 336663847c39Smrg $sharedlib_from_linklib_cmd "$dlprefile" 336763847c39Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 336863847c39Smrg fi 336963847c39Smrg fi 337063847c39Smrg $opt_dry_run || { 337163847c39Smrg if test -n "$dlprefile_dlbasename" ; then 337263847c39Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 337363847c39Smrg else 337463847c39Smrg func_warning "Could not compute DLL name from $name" 337563847c39Smrg eval '$ECHO ": $name " >> "$nlist"' 337663847c39Smrg fi 337763847c39Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 337863847c39Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 337963847c39Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 338063847c39Smrg } 338163847c39Smrg else # not an import lib 338263847c39Smrg $opt_dry_run || { 338363847c39Smrg eval '$ECHO ": $name " >> "$nlist"' 338463847c39Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 338563847c39Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 338663847c39Smrg } 338763847c39Smrg fi 338863847c39Smrg ;; 338963847c39Smrg *) 339063847c39Smrg $opt_dry_run || { 339163847c39Smrg eval '$ECHO ": $name " >> "$nlist"' 339263847c39Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 339363847c39Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 339463847c39Smrg } 339563847c39Smrg ;; 339663847c39Smrg esac 339763847c39Smrg done 339876888252Smrg 339963847c39Smrg $opt_dry_run || { 340063847c39Smrg # Make sure we have at least an empty file. 340163847c39Smrg test -f "$nlist" || : > "$nlist" 340276888252Smrg 340363847c39Smrg if test -n "$exclude_expsyms"; then 340463847c39Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 340563847c39Smrg $MV "$nlist"T "$nlist" 340663847c39Smrg fi 340776888252Smrg 340863847c39Smrg # Try sorting and uniquifying the output. 340963847c39Smrg if $GREP -v "^: " < "$nlist" | 341063847c39Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 341163847c39Smrg sort -k 3 341263847c39Smrg else 341363847c39Smrg sort +2 341463847c39Smrg fi | 341563847c39Smrg uniq > "$nlist"S; then 341663847c39Smrg : 341763847c39Smrg else 341863847c39Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 341963847c39Smrg fi 342076888252Smrg 342163847c39Smrg if test -f "$nlist"S; then 342263847c39Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 342363847c39Smrg else 342463847c39Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 342563847c39Smrg fi 342676888252Smrg 342763847c39Smrg echo >> "$output_objdir/$my_dlsyms" "\ 342863847c39Smrg 342963847c39Smrg/* The mapping between symbol names and symbols. */ 343063847c39Smrgtypedef struct { 343163847c39Smrg const char *name; 343263847c39Smrg void *address; 343363847c39Smrg} lt_dlsymlist; 343463847c39Smrgextern LT_DLSYM_CONST lt_dlsymlist 343563847c39Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 343663847c39SmrgLT_DLSYM_CONST lt_dlsymlist 343763847c39Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 343863847c39Smrg{\ 343963847c39Smrg { \"$my_originator\", (void *) 0 }," 344063847c39Smrg 344163847c39Smrg case $need_lib_prefix in 344263847c39Smrg no) 344363847c39Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 344486dafe34Smrg ;; 3445d8556812Smrg *) 344663847c39Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3447d8556812Smrg ;; 3448d8556812Smrg esac 344963847c39Smrg echo >> "$output_objdir/$my_dlsyms" "\ 345063847c39Smrg {0, (void *) 0} 345163847c39Smrg}; 345276888252Smrg 345363847c39Smrg/* This works around a problem in FreeBSD linker */ 345463847c39Smrg#ifdef FREEBSD_WORKAROUND 345563847c39Smrgstatic const void *lt_preloaded_setup() { 345663847c39Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 345763847c39Smrg} 345863847c39Smrg#endif 345976888252Smrg 346063847c39Smrg#ifdef __cplusplus 346163847c39Smrg} 346263847c39Smrg#endif\ 346363847c39Smrg" 346463847c39Smrg } # !$opt_dry_run 346576888252Smrg 346663847c39Smrg pic_flag_for_symtable= 346763847c39Smrg case "$compile_command " in 346863847c39Smrg *" -static "*) ;; 346963847c39Smrg *) 347063847c39Smrg case $host in 347163847c39Smrg # compiling the symbol table file with pic_flag works around 347263847c39Smrg # a FreeBSD bug that causes programs to crash when -lm is 347363847c39Smrg # linked before any other PIC object. But we must not use 347463847c39Smrg # pic_flag when linking with -static. The problem exists in 347563847c39Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 347663847c39Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 347763847c39Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 347863847c39Smrg *-*-hpux*) 347963847c39Smrg pic_flag_for_symtable=" $pic_flag" ;; 348063847c39Smrg *) 348163847c39Smrg if test "X$my_pic_p" != Xno; then 348263847c39Smrg pic_flag_for_symtable=" $pic_flag" 348363847c39Smrg fi 348463847c39Smrg ;; 348563847c39Smrg esac 348663847c39Smrg ;; 348763847c39Smrg esac 348863847c39Smrg symtab_cflags= 348963847c39Smrg for arg in $LTCFLAGS; do 349063847c39Smrg case $arg in 349163847c39Smrg -pie | -fpie | -fPIE) ;; 349263847c39Smrg *) func_append symtab_cflags " $arg" ;; 3493d8556812Smrg esac 3494d8556812Smrg done 349576888252Smrg 349663847c39Smrg # Now compile the dynamic symbol file. 349763847c39Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 349876888252Smrg 349963847c39Smrg # Clean up the generated files. 350063847c39Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 350176888252Smrg 350263847c39Smrg # Transform the symbol file into the correct name. 350363847c39Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 350463847c39Smrg case $host in 350563847c39Smrg *cygwin* | *mingw* | *cegcc* ) 350663847c39Smrg if test -f "$output_objdir/$my_outputname.def"; then 350763847c39Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350863847c39Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350963847c39Smrg else 351063847c39Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351163847c39Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351263847c39Smrg fi 351363847c39Smrg ;; 351463847c39Smrg *) 351563847c39Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351663847c39Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351763847c39Smrg ;; 351863847c39Smrg esac 351963847c39Smrg ;; 352063847c39Smrg *) 352163847c39Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 352263847c39Smrg ;; 352363847c39Smrg esac 352463847c39Smrg else 352563847c39Smrg # We keep going just in case the user didn't refer to 352663847c39Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 352763847c39Smrg # really was required. 352876888252Smrg 352963847c39Smrg # Nullify the symbol file. 353063847c39Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 353163847c39Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 353263847c39Smrg fi 353363847c39Smrg} 353476888252Smrg 353563847c39Smrg# func_win32_libid arg 353663847c39Smrg# return the library type of file 'arg' 353763847c39Smrg# 353863847c39Smrg# Need a lot of goo to handle *both* DLLs and import libs 353963847c39Smrg# Has to be a shell function in order to 'eat' the argument 354063847c39Smrg# that is supplied when $file_magic_command is called. 354163847c39Smrg# Despite the name, also deal with 64 bit binaries. 354263847c39Smrgfunc_win32_libid () 354363847c39Smrg{ 354463847c39Smrg $opt_debug 354563847c39Smrg win32_libid_type="unknown" 354663847c39Smrg win32_fileres=`file -L $1 2>/dev/null` 354763847c39Smrg case $win32_fileres in 354863847c39Smrg *ar\ archive\ import\ library*) # definitely import 354963847c39Smrg win32_libid_type="x86 archive import" 355063847c39Smrg ;; 355163847c39Smrg *ar\ archive*) # could be an import, or static 355263847c39Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 355363847c39Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 355463847c39Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 355563847c39Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 355663847c39Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 355763847c39Smrg $SED -n -e ' 355863847c39Smrg 1,100{ 355963847c39Smrg / I /{ 356063847c39Smrg s,.*,import, 356163847c39Smrg p 356263847c39Smrg q 356363847c39Smrg } 356463847c39Smrg }'` 356563847c39Smrg case $win32_nmres in 356663847c39Smrg import*) win32_libid_type="x86 archive import";; 356763847c39Smrg *) win32_libid_type="x86 archive static";; 356863847c39Smrg esac 356963847c39Smrg fi 357063847c39Smrg ;; 357163847c39Smrg *DLL*) 357263847c39Smrg win32_libid_type="x86 DLL" 357363847c39Smrg ;; 357463847c39Smrg *executable*) # but shell scripts are "executable" too... 357563847c39Smrg case $win32_fileres in 357663847c39Smrg *MS\ Windows\ PE\ Intel*) 357763847c39Smrg win32_libid_type="x86 DLL" 357863847c39Smrg ;; 357963847c39Smrg esac 358063847c39Smrg ;; 358163847c39Smrg esac 358263847c39Smrg $ECHO "$win32_libid_type" 358363847c39Smrg} 358463847c39Smrg 358563847c39Smrg# func_cygming_dll_for_implib ARG 358663847c39Smrg# 358763847c39Smrg# Platform-specific function to extract the 358863847c39Smrg# name of the DLL associated with the specified 358963847c39Smrg# import library ARG. 359063847c39Smrg# Invoked by eval'ing the libtool variable 359163847c39Smrg# $sharedlib_from_linklib_cmd 359263847c39Smrg# Result is available in the variable 359363847c39Smrg# $sharedlib_from_linklib_result 359463847c39Smrgfunc_cygming_dll_for_implib () 359563847c39Smrg{ 359663847c39Smrg $opt_debug 359763847c39Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 359863847c39Smrg} 359963847c39Smrg 360063847c39Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 360163847c39Smrg# 360263847c39Smrg# The is the core of a fallback implementation of a 360363847c39Smrg# platform-specific function to extract the name of the 360463847c39Smrg# DLL associated with the specified import library LIBNAME. 360563847c39Smrg# 360663847c39Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 360763847c39Smrg# on the platform and compiler that created the implib. 360863847c39Smrg# 360963847c39Smrg# Echos the name of the DLL associated with the 361063847c39Smrg# specified import library. 361163847c39Smrgfunc_cygming_dll_for_implib_fallback_core () 361263847c39Smrg{ 361363847c39Smrg $opt_debug 361463847c39Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 361563847c39Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 361663847c39Smrg $SED '/^Contents of section '"$match_literal"':/{ 361763847c39Smrg # Place marker at beginning of archive member dllname section 361863847c39Smrg s/.*/====MARK====/ 361963847c39Smrg p 362063847c39Smrg d 362163847c39Smrg } 362263847c39Smrg # These lines can sometimes be longer than 43 characters, but 362363847c39Smrg # are always uninteresting 362463847c39Smrg /:[ ]*file format pe[i]\{,1\}-/d 362563847c39Smrg /^In archive [^:]*:/d 362663847c39Smrg # Ensure marker is printed 362763847c39Smrg /^====MARK====/p 362863847c39Smrg # Remove all lines with less than 43 characters 362963847c39Smrg /^.\{43\}/!d 363063847c39Smrg # From remaining lines, remove first 43 characters 363163847c39Smrg s/^.\{43\}//' | 363263847c39Smrg $SED -n ' 363363847c39Smrg # Join marker and all lines until next marker into a single line 363463847c39Smrg /^====MARK====/ b para 363563847c39Smrg H 363663847c39Smrg $ b para 363763847c39Smrg b 363863847c39Smrg :para 363963847c39Smrg x 364063847c39Smrg s/\n//g 364163847c39Smrg # Remove the marker 364263847c39Smrg s/^====MARK====// 364363847c39Smrg # Remove trailing dots and whitespace 364463847c39Smrg s/[\. \t]*$// 364563847c39Smrg # Print 364663847c39Smrg /./p' | 364763847c39Smrg # we now have a list, one entry per line, of the stringified 364863847c39Smrg # contents of the appropriate section of all members of the 364963847c39Smrg # archive which possess that section. Heuristic: eliminate 365063847c39Smrg # all those which have a first or second character that is 365163847c39Smrg # a '.' (that is, objdump's representation of an unprintable 365263847c39Smrg # character.) This should work for all archives with less than 365363847c39Smrg # 0x302f exports -- but will fail for DLLs whose name actually 365463847c39Smrg # begins with a literal '.' or a single character followed by 365563847c39Smrg # a '.'. 365663847c39Smrg # 365763847c39Smrg # Of those that remain, print the first one. 365863847c39Smrg $SED -e '/^\./d;/^.\./d;q' 365963847c39Smrg} 366063847c39Smrg 366163847c39Smrg# func_cygming_gnu_implib_p ARG 366263847c39Smrg# This predicate returns with zero status (TRUE) if 366363847c39Smrg# ARG is a GNU/binutils-style import library. Returns 366463847c39Smrg# with nonzero status (FALSE) otherwise. 366563847c39Smrgfunc_cygming_gnu_implib_p () 366663847c39Smrg{ 366763847c39Smrg $opt_debug 366863847c39Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 366963847c39Smrg func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` 367063847c39Smrg test -n "$func_cygming_gnu_implib_tmp" 367163847c39Smrg} 367263847c39Smrg 367363847c39Smrg# func_cygming_ms_implib_p ARG 367463847c39Smrg# This predicate returns with zero status (TRUE) if 367563847c39Smrg# ARG is an MS-style import library. Returns 367663847c39Smrg# with nonzero status (FALSE) otherwise. 367763847c39Smrgfunc_cygming_ms_implib_p () 367863847c39Smrg{ 367963847c39Smrg $opt_debug 368063847c39Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 368163847c39Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 368263847c39Smrg test -n "$func_cygming_ms_implib_tmp" 368363847c39Smrg} 368463847c39Smrg 368563847c39Smrg# func_cygming_dll_for_implib_fallback ARG 368663847c39Smrg# Platform-specific function to extract the 368763847c39Smrg# name of the DLL associated with the specified 368863847c39Smrg# import library ARG. 368963847c39Smrg# 369063847c39Smrg# This fallback implementation is for use when $DLLTOOL 369163847c39Smrg# does not support the --identify-strict option. 369263847c39Smrg# Invoked by eval'ing the libtool variable 369363847c39Smrg# $sharedlib_from_linklib_cmd 369463847c39Smrg# Result is available in the variable 369563847c39Smrg# $sharedlib_from_linklib_result 369663847c39Smrgfunc_cygming_dll_for_implib_fallback () 369763847c39Smrg{ 369863847c39Smrg $opt_debug 369963847c39Smrg if func_cygming_gnu_implib_p "$1" ; then 370063847c39Smrg # binutils import library 370163847c39Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 370263847c39Smrg elif func_cygming_ms_implib_p "$1" ; then 370363847c39Smrg # ms-generated import library 370463847c39Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 370563847c39Smrg else 370663847c39Smrg # unknown 370763847c39Smrg sharedlib_from_linklib_result="" 370863847c39Smrg fi 370963847c39Smrg} 371063847c39Smrg 371163847c39Smrg 371263847c39Smrg# func_extract_an_archive dir oldlib 371363847c39Smrgfunc_extract_an_archive () 371463847c39Smrg{ 371563847c39Smrg $opt_debug 371663847c39Smrg f_ex_an_ar_dir="$1"; shift 371763847c39Smrg f_ex_an_ar_oldlib="$1" 371863847c39Smrg if test "$lock_old_archive_extraction" = yes; then 371963847c39Smrg lockfile=$f_ex_an_ar_oldlib.lock 372063847c39Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 372163847c39Smrg func_echo "Waiting for $lockfile to be removed" 372263847c39Smrg sleep 2 3723d8556812Smrg done 372463847c39Smrg fi 372563847c39Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 372663847c39Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 372763847c39Smrg if test "$lock_old_archive_extraction" = yes; then 372863847c39Smrg $opt_dry_run || rm -f "$lockfile" 372963847c39Smrg fi 373063847c39Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 373163847c39Smrg : 373263847c39Smrg else 373363847c39Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 373463847c39Smrg fi 373563847c39Smrg} 373676888252Smrg 373763847c39Smrg 373863847c39Smrg# func_extract_archives gentop oldlib ... 373963847c39Smrgfunc_extract_archives () 374063847c39Smrg{ 374163847c39Smrg $opt_debug 374263847c39Smrg my_gentop="$1"; shift 374363847c39Smrg my_oldlibs=${1+"$@"} 374463847c39Smrg my_oldobjs="" 374563847c39Smrg my_xlib="" 374663847c39Smrg my_xabs="" 374763847c39Smrg my_xdir="" 374863847c39Smrg 374963847c39Smrg for my_xlib in $my_oldlibs; do 375063847c39Smrg # Extract the objects. 375163847c39Smrg case $my_xlib in 375263847c39Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 375363847c39Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 375463847c39Smrg esac 375563847c39Smrg func_basename "$my_xlib" 375663847c39Smrg my_xlib="$func_basename_result" 375763847c39Smrg my_xlib_u=$my_xlib 375863847c39Smrg while :; do 375963847c39Smrg case " $extracted_archives " in 376063847c39Smrg *" $my_xlib_u "*) 376163847c39Smrg func_arith $extracted_serial + 1 376263847c39Smrg extracted_serial=$func_arith_result 376363847c39Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 376463847c39Smrg *) break ;; 3765d8556812Smrg esac 3766d8556812Smrg done 376763847c39Smrg extracted_archives="$extracted_archives $my_xlib_u" 376863847c39Smrg my_xdir="$my_gentop/$my_xlib_u" 376976888252Smrg 377063847c39Smrg func_mkdir_p "$my_xdir" 377176888252Smrg 377263847c39Smrg case $host in 377363847c39Smrg *-darwin*) 377463847c39Smrg func_verbose "Extracting $my_xabs" 377563847c39Smrg # Do not bother doing anything if just a dry run 377663847c39Smrg $opt_dry_run || { 377763847c39Smrg darwin_orig_dir=`pwd` 377863847c39Smrg cd $my_xdir || exit $? 377963847c39Smrg darwin_archive=$my_xabs 378063847c39Smrg darwin_curdir=`pwd` 378163847c39Smrg darwin_base_archive=`basename "$darwin_archive"` 378263847c39Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 378363847c39Smrg if test -n "$darwin_arches"; then 378463847c39Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 378563847c39Smrg darwin_arch= 378663847c39Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 378763847c39Smrg for darwin_arch in $darwin_arches ; do 378863847c39Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 378963847c39Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 379063847c39Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 379163847c39Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 379263847c39Smrg cd "$darwin_curdir" 379363847c39Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 379463847c39Smrg done # $darwin_arches 379563847c39Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 379663847c39Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 379763847c39Smrg darwin_file= 379863847c39Smrg darwin_files= 379963847c39Smrg for darwin_file in $darwin_filelist; do 380063847c39Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 380163847c39Smrg $LIPO -create -output "$darwin_file" $darwin_files 380263847c39Smrg done # $darwin_filelist 380363847c39Smrg $RM -rf unfat-$$ 380463847c39Smrg cd "$darwin_orig_dir" 3805d8556812Smrg else 380663847c39Smrg cd $darwin_orig_dir 380763847c39Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 380863847c39Smrg fi # $darwin_arches 380963847c39Smrg } # !$opt_dry_run 381063847c39Smrg ;; 381163847c39Smrg *) 381263847c39Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 381363847c39Smrg ;; 381463847c39Smrg esac 381563847c39Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 381663847c39Smrg done 381776888252Smrg 381863847c39Smrg func_extract_archives_result="$my_oldobjs" 381963847c39Smrg} 382076888252Smrg 382176888252Smrg 382263847c39Smrg# func_emit_wrapper [arg=no] 382363847c39Smrg# 382463847c39Smrg# Emit a libtool wrapper script on stdout. 382563847c39Smrg# Don't directly open a file because we may want to 382663847c39Smrg# incorporate the script contents within a cygwin/mingw 382763847c39Smrg# wrapper executable. Must ONLY be called from within 382863847c39Smrg# func_mode_link because it depends on a number of variables 382963847c39Smrg# set therein. 383063847c39Smrg# 383163847c39Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 383263847c39Smrg# variable will take. If 'yes', then the emitted script 383363847c39Smrg# will assume that the directory in which it is stored is 383463847c39Smrg# the $objdir directory. This is a cygwin/mingw-specific 383563847c39Smrg# behavior. 383663847c39Smrgfunc_emit_wrapper () 383763847c39Smrg{ 383863847c39Smrg func_emit_wrapper_arg1=${1-no} 383976888252Smrg 384063847c39Smrg $ECHO "\ 384163847c39Smrg#! $SHELL 384276888252Smrg 384363847c39Smrg# $output - temporary wrapper script for $objdir/$outputname 384463847c39Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 384563847c39Smrg# 384663847c39Smrg# The $output program cannot be directly executed until all the libtool 384763847c39Smrg# libraries that it depends on are installed. 384863847c39Smrg# 384963847c39Smrg# This wrapper script should never be moved out of the build directory. 385063847c39Smrg# If it is, it will not operate correctly. 385176888252Smrg 385263847c39Smrg# Sed substitution that helps us do robust quoting. It backslashifies 385363847c39Smrg# metacharacters that are still active within double-quoted strings. 385463847c39Smrgsed_quote_subst='$sed_quote_subst' 385576888252Smrg 385663847c39Smrg# Be Bourne compatible 385763847c39Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 385863847c39Smrg emulate sh 385963847c39Smrg NULLCMD=: 386063847c39Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 386163847c39Smrg # is contrary to our usage. Disable this feature. 386263847c39Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 386363847c39Smrg setopt NO_GLOB_SUBST 386463847c39Smrgelse 386563847c39Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 386663847c39Smrgfi 386763847c39SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 386863847c39SmrgDUALCASE=1; export DUALCASE # for MKS sh 386976888252Smrg 387063847c39Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 387163847c39Smrg# if CDPATH is set. 387263847c39Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 387376888252Smrg 387463847c39Smrgrelink_command=\"$relink_command\" 387576888252Smrg 387663847c39Smrg# This environment variable determines our operation mode. 387763847c39Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 387863847c39Smrg # install mode needs the following variables: 387963847c39Smrg generated_by_libtool_version='$macro_version' 388063847c39Smrg notinst_deplibs='$notinst_deplibs' 388163847c39Smrgelse 388263847c39Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 388363847c39Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 388463847c39Smrg file=\"\$0\"" 388576888252Smrg 388663847c39Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 388763847c39Smrg $ECHO "\ 388876888252Smrg 388963847c39Smrg# A function that is used when there is no print builtin or printf. 389063847c39Smrgfunc_fallback_echo () 389163847c39Smrg{ 389263847c39Smrg eval 'cat <<_LTECHO_EOF 389363847c39Smrg\$1 389463847c39Smrg_LTECHO_EOF' 389563847c39Smrg} 389663847c39Smrg ECHO=\"$qECHO\" 389763847c39Smrg fi 389876888252Smrg 389963847c39Smrg# Very basic option parsing. These options are (a) specific to 390063847c39Smrg# the libtool wrapper, (b) are identical between the wrapper 390163847c39Smrg# /script/ and the wrapper /executable/ which is used only on 390263847c39Smrg# windows platforms, and (c) all begin with the string "--lt-" 390363847c39Smrg# (application programs are unlikely to have options which match 390463847c39Smrg# this pattern). 390563847c39Smrg# 390663847c39Smrg# There are only two supported options: --lt-debug and 390763847c39Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 390863847c39Smrg# 390963847c39Smrg# The first argument to this parsing function should be the 391063847c39Smrg# script's $0 value, followed by "$@". 391163847c39Smrglt_option_debug= 391263847c39Smrgfunc_parse_lt_options () 391363847c39Smrg{ 391463847c39Smrg lt_script_arg0=\$0 391563847c39Smrg shift 391663847c39Smrg for lt_opt 391763847c39Smrg do 391863847c39Smrg case \"\$lt_opt\" in 391963847c39Smrg --lt-debug) lt_option_debug=1 ;; 392063847c39Smrg --lt-dump-script) 392163847c39Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 392263847c39Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 392363847c39Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 392463847c39Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 392563847c39Smrg exit 0 392663847c39Smrg ;; 392763847c39Smrg --lt-*) 392863847c39Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 392963847c39Smrg exit 1 393063847c39Smrg ;; 393163847c39Smrg esac 393263847c39Smrg done 393376888252Smrg 393463847c39Smrg # Print the debug banner immediately: 393563847c39Smrg if test -n \"\$lt_option_debug\"; then 393663847c39Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 393763847c39Smrg fi 393863847c39Smrg} 393976888252Smrg 394063847c39Smrg# Used when --lt-debug. Prints its arguments to stdout 394163847c39Smrg# (redirection is the responsibility of the caller) 394263847c39Smrgfunc_lt_dump_args () 394363847c39Smrg{ 394463847c39Smrg lt_dump_args_N=1; 394563847c39Smrg for lt_arg 394663847c39Smrg do 394763847c39Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 394863847c39Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 394963847c39Smrg done 395063847c39Smrg} 395176888252Smrg 395263847c39Smrg# Core function for launching the target application 395363847c39Smrgfunc_exec_program_core () 395463847c39Smrg{ 395563847c39Smrg" 395663847c39Smrg case $host in 395763847c39Smrg # Backslashes separate directories on plain windows 395863847c39Smrg *-*-mingw | *-*-os2* | *-cegcc*) 395963847c39Smrg $ECHO "\ 396063847c39Smrg if test -n \"\$lt_option_debug\"; then 396163847c39Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 396263847c39Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 396363847c39Smrg fi 396463847c39Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 396563847c39Smrg" 396663847c39Smrg ;; 396776888252Smrg 396863847c39Smrg *) 396963847c39Smrg $ECHO "\ 397063847c39Smrg if test -n \"\$lt_option_debug\"; then 397163847c39Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 397263847c39Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 397363847c39Smrg fi 397463847c39Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 397563847c39Smrg" 397663847c39Smrg ;; 397763847c39Smrg esac 397863847c39Smrg $ECHO "\ 397963847c39Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 398063847c39Smrg exit 1 398163847c39Smrg} 398276888252Smrg 398363847c39Smrg# A function to encapsulate launching the target application 398463847c39Smrg# Strips options in the --lt-* namespace from \$@ and 398563847c39Smrg# launches target application with the remaining arguments. 398663847c39Smrgfunc_exec_program () 398763847c39Smrg{ 398863847c39Smrg case \" \$* \" in 398963847c39Smrg *\\ --lt-*) 399063847c39Smrg for lt_wr_arg 399163847c39Smrg do 399263847c39Smrg case \$lt_wr_arg in 399363847c39Smrg --lt-*) ;; 399463847c39Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 399563847c39Smrg esac 399663847c39Smrg shift 399763847c39Smrg done ;; 399863847c39Smrg esac 399963847c39Smrg func_exec_program_core \${1+\"\$@\"} 400063847c39Smrg} 400176888252Smrg 400263847c39Smrg # Parse options 400363847c39Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 400476888252Smrg 400563847c39Smrg # Find the directory that this script lives in. 400663847c39Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 400763847c39Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 400876888252Smrg 400963847c39Smrg # Follow symbolic links until we get to the real thisdir. 401063847c39Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 401163847c39Smrg while test -n \"\$file\"; do 401263847c39Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 401376888252Smrg 401463847c39Smrg # If there was a directory component, then change thisdir. 401563847c39Smrg if test \"x\$destdir\" != \"x\$file\"; then 401663847c39Smrg case \"\$destdir\" in 401763847c39Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 401863847c39Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 401963847c39Smrg esac 402063847c39Smrg fi 402176888252Smrg 402263847c39Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 402363847c39Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 402463847c39Smrg done 402576888252Smrg 402663847c39Smrg # Usually 'no', except on cygwin/mingw when embedded into 402763847c39Smrg # the cwrapper. 402863847c39Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 402963847c39Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 403063847c39Smrg # special case for '.' 403163847c39Smrg if test \"\$thisdir\" = \".\"; then 403263847c39Smrg thisdir=\`pwd\` 403363847c39Smrg fi 403463847c39Smrg # remove .libs from thisdir 403563847c39Smrg case \"\$thisdir\" in 403663847c39Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 403763847c39Smrg $objdir ) thisdir=. ;; 403863847c39Smrg esac 403963847c39Smrg fi 404076888252Smrg 404163847c39Smrg # Try to get the absolute directory name. 404263847c39Smrg absdir=\`cd \"\$thisdir\" && pwd\` 404363847c39Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 404463847c39Smrg" 404576888252Smrg 404663847c39Smrg if test "$fast_install" = yes; then 404763847c39Smrg $ECHO "\ 404863847c39Smrg program=lt-'$outputname'$exeext 404963847c39Smrg progdir=\"\$thisdir/$objdir\" 405076888252Smrg 405163847c39Smrg if test ! -f \"\$progdir/\$program\" || 405263847c39Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 405363847c39Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 405476888252Smrg 405563847c39Smrg file=\"\$\$-\$program\" 405676888252Smrg 405763847c39Smrg if test ! -d \"\$progdir\"; then 405863847c39Smrg $MKDIR \"\$progdir\" 405963847c39Smrg else 406063847c39Smrg $RM \"\$progdir/\$file\" 406163847c39Smrg fi" 406276888252Smrg 406363847c39Smrg $ECHO "\ 406476888252Smrg 406563847c39Smrg # relink executable if necessary 406663847c39Smrg if test -n \"\$relink_command\"; then 406763847c39Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 406863847c39Smrg else 406963847c39Smrg $ECHO \"\$relink_command_output\" >&2 407063847c39Smrg $RM \"\$progdir/\$file\" 407163847c39Smrg exit 1 407263847c39Smrg fi 407363847c39Smrg fi 4074d8556812Smrg 407563847c39Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 407663847c39Smrg { $RM \"\$progdir/\$program\"; 407763847c39Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 407863847c39Smrg $RM \"\$progdir/\$file\" 407963847c39Smrg fi" 408063847c39Smrg else 408163847c39Smrg $ECHO "\ 408263847c39Smrg program='$outputname' 408363847c39Smrg progdir=\"\$thisdir/$objdir\" 408463847c39Smrg" 408563847c39Smrg fi 4086d8556812Smrg 408763847c39Smrg $ECHO "\ 4088d8556812Smrg 408963847c39Smrg if test -f \"\$progdir/\$program\"; then" 409063847c39Smrg 409163847c39Smrg # fixup the dll searchpath if we need to. 409263847c39Smrg # 409363847c39Smrg # Fix the DLL searchpath if we need to. Do this before prepending 409463847c39Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 409563847c39Smrg # libraries must come first. 409663847c39Smrg if test -n "$dllsearchpath"; then 409763847c39Smrg $ECHO "\ 409863847c39Smrg # Add the dll search path components to the executable PATH 409963847c39Smrg PATH=$dllsearchpath:\$PATH 410063847c39Smrg" 4101d8556812Smrg fi 4102d8556812Smrg 410363847c39Smrg # Export our shlibpath_var if we have one. 410463847c39Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 410563847c39Smrg $ECHO "\ 410663847c39Smrg # Add our own library path to $shlibpath_var 410763847c39Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4108d8556812Smrg 410963847c39Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 411063847c39Smrg # The second colon is a workaround for a bug in BeOS R4 sed 411163847c39Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 411263847c39Smrg 411363847c39Smrg export $shlibpath_var 411463847c39Smrg" 4115d8556812Smrg fi 411676888252Smrg 411763847c39Smrg $ECHO "\ 411863847c39Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 411963847c39Smrg # Run the actual program with our arguments. 412063847c39Smrg func_exec_program \${1+\"\$@\"} 412163847c39Smrg fi 412263847c39Smrg else 412363847c39Smrg # The program doesn't exist. 412463847c39Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 412563847c39Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 412663847c39Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 412763847c39Smrg exit 1 412863847c39Smrg fi 412963847c39Smrgfi\ 413063847c39Smrg" 413163847c39Smrg} 413276888252Smrg 413376888252Smrg 413463847c39Smrg# func_emit_cwrapperexe_src 413563847c39Smrg# emit the source code for a wrapper executable on stdout 413663847c39Smrg# Must ONLY be called from within func_mode_link because 413763847c39Smrg# it depends on a number of variable set therein. 413863847c39Smrgfunc_emit_cwrapperexe_src () 413963847c39Smrg{ 414063847c39Smrg cat <<EOF 4141d8556812Smrg 414263847c39Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 414363847c39Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4144d8556812Smrg 414563847c39Smrg The $output program cannot be directly executed until all the libtool 414663847c39Smrg libraries that it depends on are installed. 4147d8556812Smrg 414863847c39Smrg This wrapper executable should never be moved out of the build directory. 414963847c39Smrg If it is, it will not operate correctly. 415063847c39Smrg*/ 415163847c39SmrgEOF 415263847c39Smrg cat <<"EOF" 415363847c39Smrg#ifdef _MSC_VER 415463847c39Smrg# define _CRT_SECURE_NO_DEPRECATE 1 415563847c39Smrg#endif 415663847c39Smrg#include <stdio.h> 415763847c39Smrg#include <stdlib.h> 415863847c39Smrg#ifdef _MSC_VER 415963847c39Smrg# include <direct.h> 416063847c39Smrg# include <process.h> 416163847c39Smrg# include <io.h> 416263847c39Smrg#else 416363847c39Smrg# include <unistd.h> 416463847c39Smrg# include <stdint.h> 416563847c39Smrg# ifdef __CYGWIN__ 416663847c39Smrg# include <io.h> 416763847c39Smrg# endif 416863847c39Smrg#endif 416963847c39Smrg#include <malloc.h> 417063847c39Smrg#include <stdarg.h> 417163847c39Smrg#include <assert.h> 417263847c39Smrg#include <string.h> 417363847c39Smrg#include <ctype.h> 417463847c39Smrg#include <errno.h> 417563847c39Smrg#include <fcntl.h> 417663847c39Smrg#include <sys/stat.h> 4177d8556812Smrg 417863847c39Smrg/* declarations of non-ANSI functions */ 417963847c39Smrg#if defined(__MINGW32__) 418063847c39Smrg# ifdef __STRICT_ANSI__ 418163847c39Smrgint _putenv (const char *); 418263847c39Smrg# endif 418363847c39Smrg#elif defined(__CYGWIN__) 418463847c39Smrg# ifdef __STRICT_ANSI__ 418563847c39Smrgchar *realpath (const char *, char *); 418663847c39Smrgint putenv (char *); 418763847c39Smrgint setenv (const char *, const char *, int); 418863847c39Smrg# endif 418963847c39Smrg/* #elif defined (other platforms) ... */ 419063847c39Smrg#endif 419176888252Smrg 419263847c39Smrg/* portability defines, excluding path handling macros */ 419363847c39Smrg#if defined(_MSC_VER) 419463847c39Smrg# define setmode _setmode 419563847c39Smrg# define stat _stat 419663847c39Smrg# define chmod _chmod 419763847c39Smrg# define getcwd _getcwd 419863847c39Smrg# define putenv _putenv 419963847c39Smrg# define S_IXUSR _S_IEXEC 420063847c39Smrg# ifndef _INTPTR_T_DEFINED 420163847c39Smrg# define _INTPTR_T_DEFINED 420263847c39Smrg# define intptr_t int 420363847c39Smrg# endif 420463847c39Smrg#elif defined(__MINGW32__) 420563847c39Smrg# define setmode _setmode 420663847c39Smrg# define stat _stat 420763847c39Smrg# define chmod _chmod 420863847c39Smrg# define getcwd _getcwd 420963847c39Smrg# define putenv _putenv 421063847c39Smrg#elif defined(__CYGWIN__) 421163847c39Smrg# define HAVE_SETENV 421263847c39Smrg# define FOPEN_WB "wb" 421363847c39Smrg/* #elif defined (other platforms) ... */ 421463847c39Smrg#endif 421576888252Smrg 421663847c39Smrg#if defined(PATH_MAX) 421763847c39Smrg# define LT_PATHMAX PATH_MAX 421863847c39Smrg#elif defined(MAXPATHLEN) 421963847c39Smrg# define LT_PATHMAX MAXPATHLEN 422063847c39Smrg#else 422163847c39Smrg# define LT_PATHMAX 1024 422263847c39Smrg#endif 422376888252Smrg 422463847c39Smrg#ifndef S_IXOTH 422563847c39Smrg# define S_IXOTH 0 422663847c39Smrg#endif 422763847c39Smrg#ifndef S_IXGRP 422863847c39Smrg# define S_IXGRP 0 422963847c39Smrg#endif 423076888252Smrg 423163847c39Smrg/* path handling portability macros */ 423263847c39Smrg#ifndef DIR_SEPARATOR 423363847c39Smrg# define DIR_SEPARATOR '/' 423463847c39Smrg# define PATH_SEPARATOR ':' 423563847c39Smrg#endif 423676888252Smrg 423763847c39Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 423863847c39Smrg defined (__OS2__) 423963847c39Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 424063847c39Smrg# define FOPEN_WB "wb" 424163847c39Smrg# ifndef DIR_SEPARATOR_2 424263847c39Smrg# define DIR_SEPARATOR_2 '\\' 424363847c39Smrg# endif 424463847c39Smrg# ifndef PATH_SEPARATOR_2 424563847c39Smrg# define PATH_SEPARATOR_2 ';' 424663847c39Smrg# endif 424763847c39Smrg#endif 424876888252Smrg 424963847c39Smrg#ifndef DIR_SEPARATOR_2 425063847c39Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 425163847c39Smrg#else /* DIR_SEPARATOR_2 */ 425263847c39Smrg# define IS_DIR_SEPARATOR(ch) \ 425363847c39Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 425463847c39Smrg#endif /* DIR_SEPARATOR_2 */ 425576888252Smrg 425663847c39Smrg#ifndef PATH_SEPARATOR_2 425763847c39Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 425863847c39Smrg#else /* PATH_SEPARATOR_2 */ 425963847c39Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 426063847c39Smrg#endif /* PATH_SEPARATOR_2 */ 426176888252Smrg 426263847c39Smrg#ifndef FOPEN_WB 426363847c39Smrg# define FOPEN_WB "w" 426463847c39Smrg#endif 426563847c39Smrg#ifndef _O_BINARY 426663847c39Smrg# define _O_BINARY 0 426763847c39Smrg#endif 426876888252Smrg 426963847c39Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 427063847c39Smrg#define XFREE(stale) do { \ 427163847c39Smrg if (stale) { free ((void *) stale); stale = 0; } \ 427263847c39Smrg} while (0) 427376888252Smrg 427463847c39Smrg#if defined(LT_DEBUGWRAPPER) 427563847c39Smrgstatic int lt_debug = 1; 427663847c39Smrg#else 427763847c39Smrgstatic int lt_debug = 0; 427863847c39Smrg#endif 427976888252Smrg 428063847c39Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 428163847c39Smrg 428263847c39Smrgvoid *xmalloc (size_t num); 428363847c39Smrgchar *xstrdup (const char *string); 428463847c39Smrgconst char *base_name (const char *name); 428563847c39Smrgchar *find_executable (const char *wrapper); 428663847c39Smrgchar *chase_symlinks (const char *pathspec); 428763847c39Smrgint make_executable (const char *path); 428863847c39Smrgint check_executable (const char *path); 428963847c39Smrgchar *strendzap (char *str, const char *pat); 429063847c39Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 429163847c39Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 429263847c39Smrgstatic const char *nonnull (const char *s); 429363847c39Smrgstatic const char *nonempty (const char *s); 429463847c39Smrgvoid lt_setenv (const char *name, const char *value); 429563847c39Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 429663847c39Smrgvoid lt_update_exe_path (const char *name, const char *value); 429763847c39Smrgvoid lt_update_lib_path (const char *name, const char *value); 429863847c39Smrgchar **prepare_spawn (char **argv); 429963847c39Smrgvoid lt_dump_script (FILE *f); 430063847c39SmrgEOF 430176888252Smrg 430263847c39Smrg cat <<EOF 430363847c39Smrgvolatile const char * MAGIC_EXE = "$magic_exe"; 430463847c39Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 430563847c39SmrgEOF 430676888252Smrg 430763847c39Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 430863847c39Smrg func_to_host_path "$temp_rpath" 430963847c39Smrg cat <<EOF 431063847c39Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 431163847c39SmrgEOF 431263847c39Smrg else 431363847c39Smrg cat <<"EOF" 431463847c39Smrgconst char * LIB_PATH_VALUE = ""; 431563847c39SmrgEOF 431663847c39Smrg fi 431776888252Smrg 431863847c39Smrg if test -n "$dllsearchpath"; then 431963847c39Smrg func_to_host_path "$dllsearchpath:" 432063847c39Smrg cat <<EOF 432163847c39Smrgconst char * EXE_PATH_VARNAME = "PATH"; 432263847c39Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 432363847c39SmrgEOF 432463847c39Smrg else 432563847c39Smrg cat <<"EOF" 432663847c39Smrgconst char * EXE_PATH_VARNAME = ""; 432763847c39Smrgconst char * EXE_PATH_VALUE = ""; 432863847c39SmrgEOF 432963847c39Smrg fi 433076888252Smrg 433163847c39Smrg if test "$fast_install" = yes; then 433263847c39Smrg cat <<EOF 433363847c39Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 433463847c39SmrgEOF 433563847c39Smrg else 433663847c39Smrg cat <<EOF 433763847c39Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 433863847c39SmrgEOF 433963847c39Smrg fi 434076888252Smrg 434176888252Smrg 434263847c39Smrg cat <<"EOF" 434376888252Smrg 434463847c39Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 434576888252Smrg 434663847c39Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 434763847c39Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 434863847c39Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 434976888252Smrg 435063847c39Smrgint 435163847c39Smrgmain (int argc, char *argv[]) 435263847c39Smrg{ 435363847c39Smrg char **newargz; 435463847c39Smrg int newargc; 435563847c39Smrg char *tmp_pathspec; 435663847c39Smrg char *actual_cwrapper_path; 435763847c39Smrg char *actual_cwrapper_name; 435863847c39Smrg char *target_name; 435963847c39Smrg char *lt_argv_zero; 436063847c39Smrg intptr_t rval = 127; 436163847c39Smrg 436263847c39Smrg int i; 436376888252Smrg 436463847c39Smrg program_name = (char *) xstrdup (base_name (argv[0])); 436563847c39Smrg newargz = XMALLOC (char *, argc + 1); 436676888252Smrg 436763847c39Smrg /* very simple arg parsing; don't want to rely on getopt 436863847c39Smrg * also, copy all non cwrapper options to newargz, except 436963847c39Smrg * argz[0], which is handled differently 437063847c39Smrg */ 437163847c39Smrg newargc=0; 437263847c39Smrg for (i = 1; i < argc; i++) 437363847c39Smrg { 437463847c39Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 437563847c39Smrg { 437663847c39SmrgEOF 437763847c39Smrg case "$host" in 437863847c39Smrg *mingw* | *cygwin* ) 437963847c39Smrg # make stdout use "unix" line endings 438063847c39Smrg echo " setmode(1,_O_BINARY);" 438163847c39Smrg ;; 438263847c39Smrg esac 438376888252Smrg 438463847c39Smrg cat <<"EOF" 438563847c39Smrg lt_dump_script (stdout); 438663847c39Smrg return 0; 438763847c39Smrg } 438863847c39Smrg if (strcmp (argv[i], debug_opt) == 0) 438963847c39Smrg { 439063847c39Smrg lt_debug = 1; 439163847c39Smrg continue; 439263847c39Smrg } 439363847c39Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 439463847c39Smrg { 439563847c39Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 439663847c39Smrg namespace, but it is not one of the ones we know about and 439763847c39Smrg have already dealt with, above (inluding dump-script), then 439863847c39Smrg report an error. Otherwise, targets might begin to believe 439963847c39Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 440063847c39Smrg namespace. The first time any user complains about this, we'll 440163847c39Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 440263847c39Smrg or a configure.ac-settable value. 440363847c39Smrg */ 440463847c39Smrg lt_fatal (__FILE__, __LINE__, 440563847c39Smrg "unrecognized %s option: '%s'", 440663847c39Smrg ltwrapper_option_prefix, argv[i]); 440763847c39Smrg } 440863847c39Smrg /* otherwise ... */ 440963847c39Smrg newargz[++newargc] = xstrdup (argv[i]); 441063847c39Smrg } 441163847c39Smrg newargz[++newargc] = NULL; 441276888252Smrg 441363847c39SmrgEOF 441463847c39Smrg cat <<EOF 441563847c39Smrg /* The GNU banner must be the first non-error debug message */ 441663847c39Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 441763847c39SmrgEOF 441863847c39Smrg cat <<"EOF" 441963847c39Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 442063847c39Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 442163847c39Smrg 442263847c39Smrg tmp_pathspec = find_executable (argv[0]); 442363847c39Smrg if (tmp_pathspec == NULL) 442463847c39Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 442563847c39Smrg lt_debugprintf (__FILE__, __LINE__, 442663847c39Smrg "(main) found exe (before symlink chase) at: %s\n", 442763847c39Smrg tmp_pathspec); 442863847c39Smrg 442963847c39Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 443063847c39Smrg lt_debugprintf (__FILE__, __LINE__, 443163847c39Smrg "(main) found exe (after symlink chase) at: %s\n", 443263847c39Smrg actual_cwrapper_path); 443363847c39Smrg XFREE (tmp_pathspec); 443463847c39Smrg 443563847c39Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 443663847c39Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 443763847c39Smrg 443863847c39Smrg /* wrapper name transforms */ 443963847c39Smrg strendzap (actual_cwrapper_name, ".exe"); 444063847c39Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 444163847c39Smrg XFREE (actual_cwrapper_name); 444263847c39Smrg actual_cwrapper_name = tmp_pathspec; 444363847c39Smrg tmp_pathspec = 0; 444463847c39Smrg 444563847c39Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 444663847c39Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 444763847c39Smrg strendzap (target_name, ".exe"); 444863847c39Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 444963847c39Smrg XFREE (target_name); 445063847c39Smrg target_name = tmp_pathspec; 445163847c39Smrg tmp_pathspec = 0; 445263847c39Smrg 445363847c39Smrg lt_debugprintf (__FILE__, __LINE__, 445463847c39Smrg "(main) libtool target name: %s\n", 445563847c39Smrg target_name); 445663847c39SmrgEOF 445763847c39Smrg 445863847c39Smrg cat <<EOF 445963847c39Smrg newargz[0] = 446063847c39Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 446163847c39Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 446263847c39Smrg strcpy (newargz[0], actual_cwrapper_path); 446363847c39Smrg strcat (newargz[0], "$objdir"); 446463847c39Smrg strcat (newargz[0], "/"); 446563847c39SmrgEOF 446663847c39Smrg 446763847c39Smrg cat <<"EOF" 446863847c39Smrg /* stop here, and copy so we don't have to do this twice */ 446963847c39Smrg tmp_pathspec = xstrdup (newargz[0]); 447063847c39Smrg 447163847c39Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 447263847c39Smrg strcat (newargz[0], actual_cwrapper_name); 447363847c39Smrg 447463847c39Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 447563847c39Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 447663847c39Smrg XFREE (tmp_pathspec); 447763847c39Smrg tmp_pathspec = NULL; 447863847c39SmrgEOF 447963847c39Smrg 448063847c39Smrg case $host_os in 448163847c39Smrg mingw*) 448263847c39Smrg cat <<"EOF" 448363847c39Smrg { 448463847c39Smrg char* p; 448563847c39Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 448663847c39Smrg { 448763847c39Smrg *p = '/'; 448863847c39Smrg } 448963847c39Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 449063847c39Smrg { 449163847c39Smrg *p = '/'; 449263847c39Smrg } 449363847c39Smrg } 449463847c39SmrgEOF 449563847c39Smrg ;; 449663847c39Smrg esac 449763847c39Smrg 449863847c39Smrg cat <<"EOF" 449963847c39Smrg XFREE (target_name); 450063847c39Smrg XFREE (actual_cwrapper_path); 450163847c39Smrg XFREE (actual_cwrapper_name); 450263847c39Smrg 450363847c39Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 450463847c39Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 450563847c39Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 450663847c39Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 450763847c39Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 450863847c39Smrg libraries must come first. */ 450963847c39Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 451063847c39Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 451163847c39Smrg 451263847c39Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 451363847c39Smrg nonnull (lt_argv_zero)); 451463847c39Smrg for (i = 0; i < newargc; i++) 451563847c39Smrg { 451663847c39Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 451763847c39Smrg i, nonnull (newargz[i])); 451863847c39Smrg } 451963847c39Smrg 452063847c39SmrgEOF 452163847c39Smrg 452263847c39Smrg case $host_os in 452363847c39Smrg mingw*) 452463847c39Smrg cat <<"EOF" 452563847c39Smrg /* execv doesn't actually work on mingw as expected on unix */ 452663847c39Smrg newargz = prepare_spawn (newargz); 452763847c39Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 452863847c39Smrg if (rval == -1) 452963847c39Smrg { 453063847c39Smrg /* failed to start process */ 453163847c39Smrg lt_debugprintf (__FILE__, __LINE__, 453263847c39Smrg "(main) failed to launch target \"%s\": %s\n", 453363847c39Smrg lt_argv_zero, nonnull (strerror (errno))); 453463847c39Smrg return 127; 453563847c39Smrg } 453663847c39Smrg return rval; 453763847c39SmrgEOF 4538d8556812Smrg ;; 4539d8556812Smrg *) 454063847c39Smrg cat <<"EOF" 454163847c39Smrg execv (lt_argv_zero, newargz); 454263847c39Smrg return rval; /* =127, but avoids unused variable warning */ 454363847c39SmrgEOF 4544d8556812Smrg ;; 454563847c39Smrg esac 454676888252Smrg 454763847c39Smrg cat <<"EOF" 454863847c39Smrg} 454976888252Smrg 455063847c39Smrgvoid * 455163847c39Smrgxmalloc (size_t num) 455263847c39Smrg{ 455363847c39Smrg void *p = (void *) malloc (num); 455463847c39Smrg if (!p) 455563847c39Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 455676888252Smrg 455763847c39Smrg return p; 455863847c39Smrg} 455976888252Smrg 456063847c39Smrgchar * 456163847c39Smrgxstrdup (const char *string) 456263847c39Smrg{ 456363847c39Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 456463847c39Smrg string) : NULL; 456563847c39Smrg} 456676888252Smrg 456763847c39Smrgconst char * 456863847c39Smrgbase_name (const char *name) 456963847c39Smrg{ 457063847c39Smrg const char *base; 457176888252Smrg 457263847c39Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 457363847c39Smrg /* Skip over the disk name in MSDOS pathnames. */ 457463847c39Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 457563847c39Smrg name += 2; 4576d8556812Smrg#endif 457776888252Smrg 457863847c39Smrg for (base = name; *name; name++) 457963847c39Smrg if (IS_DIR_SEPARATOR (*name)) 458063847c39Smrg base = name + 1; 458163847c39Smrg return base; 458263847c39Smrg} 458376888252Smrg 458463847c39Smrgint 458563847c39Smrgcheck_executable (const char *path) 458663847c39Smrg{ 458763847c39Smrg struct stat st; 458876888252Smrg 458963847c39Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 459063847c39Smrg nonempty (path)); 459163847c39Smrg if ((!path) || (!*path)) 459263847c39Smrg return 0; 459376888252Smrg 459463847c39Smrg if ((stat (path, &st) >= 0) 459563847c39Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 459663847c39Smrg return 1; 459763847c39Smrg else 459863847c39Smrg return 0; 459963847c39Smrg} 460076888252Smrg 460163847c39Smrgint 460263847c39Smrgmake_executable (const char *path) 460363847c39Smrg{ 460463847c39Smrg int rval = 0; 460563847c39Smrg struct stat st; 460676888252Smrg 460763847c39Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 460863847c39Smrg nonempty (path)); 460963847c39Smrg if ((!path) || (!*path)) 461063847c39Smrg return 0; 461176888252Smrg 461263847c39Smrg if (stat (path, &st) >= 0) 461363847c39Smrg { 461463847c39Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 461563847c39Smrg } 461663847c39Smrg return rval; 461763847c39Smrg} 461876888252Smrg 461963847c39Smrg/* Searches for the full path of the wrapper. Returns 462063847c39Smrg newly allocated full path name if found, NULL otherwise 462163847c39Smrg Does not chase symlinks, even on platforms that support them. 462263847c39Smrg*/ 462363847c39Smrgchar * 462463847c39Smrgfind_executable (const char *wrapper) 462563847c39Smrg{ 462663847c39Smrg int has_slash = 0; 462763847c39Smrg const char *p; 462863847c39Smrg const char *p_next; 462963847c39Smrg /* static buffer for getcwd */ 463063847c39Smrg char tmp[LT_PATHMAX + 1]; 463163847c39Smrg int tmp_len; 463263847c39Smrg char *concat_name; 463376888252Smrg 463463847c39Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 463563847c39Smrg nonempty (wrapper)); 463676888252Smrg 463763847c39Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 463863847c39Smrg return NULL; 463976888252Smrg 464063847c39Smrg /* Absolute path? */ 464163847c39Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 464263847c39Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 464363847c39Smrg { 464463847c39Smrg concat_name = xstrdup (wrapper); 464563847c39Smrg if (check_executable (concat_name)) 464663847c39Smrg return concat_name; 464763847c39Smrg XFREE (concat_name); 464863847c39Smrg } 464963847c39Smrg else 465063847c39Smrg { 465163847c39Smrg#endif 465263847c39Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 465363847c39Smrg { 465463847c39Smrg concat_name = xstrdup (wrapper); 465563847c39Smrg if (check_executable (concat_name)) 465663847c39Smrg return concat_name; 465763847c39Smrg XFREE (concat_name); 465863847c39Smrg } 465963847c39Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 466063847c39Smrg } 466163847c39Smrg#endif 466276888252Smrg 466363847c39Smrg for (p = wrapper; *p; p++) 466463847c39Smrg if (*p == '/') 466563847c39Smrg { 466663847c39Smrg has_slash = 1; 466763847c39Smrg break; 466863847c39Smrg } 466963847c39Smrg if (!has_slash) 467063847c39Smrg { 467163847c39Smrg /* no slashes; search PATH */ 467263847c39Smrg const char *path = getenv ("PATH"); 467363847c39Smrg if (path != NULL) 467463847c39Smrg { 467563847c39Smrg for (p = path; *p; p = p_next) 467663847c39Smrg { 467763847c39Smrg const char *q; 467863847c39Smrg size_t p_len; 467963847c39Smrg for (q = p; *q; q++) 468063847c39Smrg if (IS_PATH_SEPARATOR (*q)) 468163847c39Smrg break; 468263847c39Smrg p_len = q - p; 468363847c39Smrg p_next = (*q == '\0' ? q : q + 1); 468463847c39Smrg if (p_len == 0) 468563847c39Smrg { 468663847c39Smrg /* empty path: current directory */ 468763847c39Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 468863847c39Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 468963847c39Smrg nonnull (strerror (errno))); 469063847c39Smrg tmp_len = strlen (tmp); 469163847c39Smrg concat_name = 469263847c39Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 469363847c39Smrg memcpy (concat_name, tmp, tmp_len); 469463847c39Smrg concat_name[tmp_len] = '/'; 469563847c39Smrg strcpy (concat_name + tmp_len + 1, wrapper); 469663847c39Smrg } 469763847c39Smrg else 469863847c39Smrg { 469963847c39Smrg concat_name = 470063847c39Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 470163847c39Smrg memcpy (concat_name, p, p_len); 470263847c39Smrg concat_name[p_len] = '/'; 470363847c39Smrg strcpy (concat_name + p_len + 1, wrapper); 470463847c39Smrg } 470563847c39Smrg if (check_executable (concat_name)) 470663847c39Smrg return concat_name; 470763847c39Smrg XFREE (concat_name); 470863847c39Smrg } 470963847c39Smrg } 471063847c39Smrg /* not found in PATH; assume curdir */ 471163847c39Smrg } 471263847c39Smrg /* Relative path | not found in path: prepend cwd */ 471363847c39Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 471463847c39Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 471563847c39Smrg nonnull (strerror (errno))); 471663847c39Smrg tmp_len = strlen (tmp); 471763847c39Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 471863847c39Smrg memcpy (concat_name, tmp, tmp_len); 471963847c39Smrg concat_name[tmp_len] = '/'; 472063847c39Smrg strcpy (concat_name + tmp_len + 1, wrapper); 472176888252Smrg 472263847c39Smrg if (check_executable (concat_name)) 472363847c39Smrg return concat_name; 472463847c39Smrg XFREE (concat_name); 472563847c39Smrg return NULL; 472663847c39Smrg} 472776888252Smrg 472863847c39Smrgchar * 472963847c39Smrgchase_symlinks (const char *pathspec) 473063847c39Smrg{ 473163847c39Smrg#ifndef S_ISLNK 473263847c39Smrg return xstrdup (pathspec); 473363847c39Smrg#else 473463847c39Smrg char buf[LT_PATHMAX]; 473563847c39Smrg struct stat s; 473663847c39Smrg char *tmp_pathspec = xstrdup (pathspec); 473763847c39Smrg char *p; 473863847c39Smrg int has_symlinks = 0; 473963847c39Smrg while (strlen (tmp_pathspec) && !has_symlinks) 474063847c39Smrg { 474163847c39Smrg lt_debugprintf (__FILE__, __LINE__, 474263847c39Smrg "checking path component for symlinks: %s\n", 474363847c39Smrg tmp_pathspec); 474463847c39Smrg if (lstat (tmp_pathspec, &s) == 0) 474563847c39Smrg { 474663847c39Smrg if (S_ISLNK (s.st_mode) != 0) 474763847c39Smrg { 474863847c39Smrg has_symlinks = 1; 474963847c39Smrg break; 475063847c39Smrg } 475163847c39Smrg 475263847c39Smrg /* search backwards for last DIR_SEPARATOR */ 475363847c39Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 475463847c39Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 475563847c39Smrg p--; 475663847c39Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 475763847c39Smrg { 475863847c39Smrg /* no more DIR_SEPARATORS left */ 475963847c39Smrg break; 476063847c39Smrg } 476163847c39Smrg *p = '\0'; 476263847c39Smrg } 476363847c39Smrg else 476463847c39Smrg { 476563847c39Smrg lt_fatal (__FILE__, __LINE__, 476663847c39Smrg "error accessing file \"%s\": %s", 476763847c39Smrg tmp_pathspec, nonnull (strerror (errno))); 476863847c39Smrg } 476963847c39Smrg } 477063847c39Smrg XFREE (tmp_pathspec); 477176888252Smrg 477263847c39Smrg if (!has_symlinks) 477363847c39Smrg { 477463847c39Smrg return xstrdup (pathspec); 477563847c39Smrg } 477676888252Smrg 477763847c39Smrg tmp_pathspec = realpath (pathspec, buf); 477863847c39Smrg if (tmp_pathspec == 0) 477963847c39Smrg { 478063847c39Smrg lt_fatal (__FILE__, __LINE__, 478163847c39Smrg "could not follow symlinks for %s", pathspec); 478263847c39Smrg } 478363847c39Smrg return xstrdup (tmp_pathspec); 4784d8556812Smrg#endif 478563847c39Smrg} 478676888252Smrg 478763847c39Smrgchar * 478863847c39Smrgstrendzap (char *str, const char *pat) 478963847c39Smrg{ 479063847c39Smrg size_t len, patlen; 479176888252Smrg 479263847c39Smrg assert (str != NULL); 479363847c39Smrg assert (pat != NULL); 479476888252Smrg 479563847c39Smrg len = strlen (str); 479663847c39Smrg patlen = strlen (pat); 479776888252Smrg 479863847c39Smrg if (patlen <= len) 479963847c39Smrg { 480063847c39Smrg str += len - patlen; 480163847c39Smrg if (strcmp (str, pat) == 0) 480263847c39Smrg *str = '\0'; 480363847c39Smrg } 480463847c39Smrg return str; 4805d8556812Smrg} 480686dafe34Smrg 480763847c39Smrgvoid 480863847c39Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 480963847c39Smrg{ 481063847c39Smrg va_list args; 481163847c39Smrg if (lt_debug) 481263847c39Smrg { 481363847c39Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 481463847c39Smrg va_start (args, fmt); 481563847c39Smrg (void) vfprintf (stderr, fmt, args); 481663847c39Smrg va_end (args); 481763847c39Smrg } 481863847c39Smrg} 481986dafe34Smrg 482063847c39Smrgstatic void 482163847c39Smrglt_error_core (int exit_status, const char *file, 482263847c39Smrg int line, const char *mode, 482363847c39Smrg const char *message, va_list ap) 482463847c39Smrg{ 482563847c39Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 482663847c39Smrg vfprintf (stderr, message, ap); 482763847c39Smrg fprintf (stderr, ".\n"); 482886dafe34Smrg 482963847c39Smrg if (exit_status >= 0) 483063847c39Smrg exit (exit_status); 4831d8556812Smrg} 483286dafe34Smrg 483363847c39Smrgvoid 483463847c39Smrglt_fatal (const char *file, int line, const char *message, ...) 483563847c39Smrg{ 483663847c39Smrg va_list ap; 483763847c39Smrg va_start (ap, message); 483863847c39Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 483963847c39Smrg va_end (ap); 4840d8556812Smrg} 484186dafe34Smrg 484263847c39Smrgstatic const char * 484363847c39Smrgnonnull (const char *s) 484463847c39Smrg{ 484563847c39Smrg return s ? s : "(null)"; 484663847c39Smrg} 484786dafe34Smrg 484863847c39Smrgstatic const char * 484963847c39Smrgnonempty (const char *s) 485063847c39Smrg{ 485163847c39Smrg return (s && !*s) ? "(empty)" : nonnull (s); 485263847c39Smrg} 485386dafe34Smrg 485463847c39Smrgvoid 485563847c39Smrglt_setenv (const char *name, const char *value) 485663847c39Smrg{ 485763847c39Smrg lt_debugprintf (__FILE__, __LINE__, 485863847c39Smrg "(lt_setenv) setting '%s' to '%s'\n", 485963847c39Smrg nonnull (name), nonnull (value)); 486063847c39Smrg { 486163847c39Smrg#ifdef HAVE_SETENV 486263847c39Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 486363847c39Smrg char *str = xstrdup (value); 486463847c39Smrg setenv (name, str, 1); 486563847c39Smrg#else 486663847c39Smrg int len = strlen (name) + 1 + strlen (value) + 1; 486763847c39Smrg char *str = XMALLOC (char, len); 486863847c39Smrg sprintf (str, "%s=%s", name, value); 486963847c39Smrg if (putenv (str) != EXIT_SUCCESS) 487063847c39Smrg { 487163847c39Smrg XFREE (str); 487263847c39Smrg } 487363847c39Smrg#endif 487463847c39Smrg } 487563847c39Smrg} 487686dafe34Smrg 487763847c39Smrgchar * 487863847c39Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 487963847c39Smrg{ 488063847c39Smrg char *new_value; 488163847c39Smrg if (orig_value && *orig_value) 488263847c39Smrg { 488363847c39Smrg int orig_value_len = strlen (orig_value); 488463847c39Smrg int add_len = strlen (add); 488563847c39Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 488663847c39Smrg if (to_end) 488763847c39Smrg { 488863847c39Smrg strcpy (new_value, orig_value); 488963847c39Smrg strcpy (new_value + orig_value_len, add); 489063847c39Smrg } 4891d8556812Smrg else 489263847c39Smrg { 489363847c39Smrg strcpy (new_value, add); 489463847c39Smrg strcpy (new_value + add_len, orig_value); 489563847c39Smrg } 489663847c39Smrg } 489763847c39Smrg else 489863847c39Smrg { 489963847c39Smrg new_value = xstrdup (add); 490063847c39Smrg } 490163847c39Smrg return new_value; 490263847c39Smrg} 490386dafe34Smrg 490463847c39Smrgvoid 490563847c39Smrglt_update_exe_path (const char *name, const char *value) 490663847c39Smrg{ 490763847c39Smrg lt_debugprintf (__FILE__, __LINE__, 490863847c39Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 490963847c39Smrg nonnull (name), nonnull (value)); 491086dafe34Smrg 491163847c39Smrg if (name && *name && value && *value) 491263847c39Smrg { 491363847c39Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 491463847c39Smrg /* some systems can't cope with a ':'-terminated path #' */ 491563847c39Smrg int len = strlen (new_value); 491663847c39Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 491763847c39Smrg { 491863847c39Smrg new_value[len-1] = '\0'; 491963847c39Smrg } 492063847c39Smrg lt_setenv (name, new_value); 492163847c39Smrg XFREE (new_value); 492263847c39Smrg } 492363847c39Smrg} 492486dafe34Smrg 492563847c39Smrgvoid 492663847c39Smrglt_update_lib_path (const char *name, const char *value) 492763847c39Smrg{ 492863847c39Smrg lt_debugprintf (__FILE__, __LINE__, 492963847c39Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 493063847c39Smrg nonnull (name), nonnull (value)); 493186dafe34Smrg 493263847c39Smrg if (name && *name && value && *value) 493363847c39Smrg { 493463847c39Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 493563847c39Smrg lt_setenv (name, new_value); 493663847c39Smrg XFREE (new_value); 493763847c39Smrg } 493863847c39Smrg} 493986dafe34Smrg 4940d8556812SmrgEOF 494163847c39Smrg case $host_os in 494263847c39Smrg mingw*) 494363847c39Smrg cat <<"EOF" 494463847c39Smrg 494563847c39Smrg/* Prepares an argument vector before calling spawn(). 494663847c39Smrg Note that spawn() does not by itself call the command interpreter 494763847c39Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 494863847c39Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 494963847c39Smrg GetVersionEx(&v); 495063847c39Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 495163847c39Smrg }) ? "cmd.exe" : "command.com"). 495263847c39Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 495363847c39Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 495463847c39Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 495563847c39Smrg special way: 495663847c39Smrg - Space and tab are interpreted as delimiters. They are not treated as 495763847c39Smrg delimiters if they are surrounded by double quotes: "...". 495863847c39Smrg - Unescaped double quotes are removed from the input. Their only effect is 495963847c39Smrg that within double quotes, space and tab are treated like normal 496063847c39Smrg characters. 496163847c39Smrg - Backslashes not followed by double quotes are not special. 496263847c39Smrg - But 2*n+1 backslashes followed by a double quote become 496363847c39Smrg n backslashes followed by a double quote (n >= 0): 496463847c39Smrg \" -> " 496563847c39Smrg \\\" -> \" 496663847c39Smrg \\\\\" -> \\" 496763847c39Smrg */ 496863847c39Smrg#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" 496963847c39Smrg#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" 497063847c39Smrgchar ** 497163847c39Smrgprepare_spawn (char **argv) 4972d8556812Smrg{ 497363847c39Smrg size_t argc; 497463847c39Smrg char **new_argv; 497563847c39Smrg size_t i; 497686dafe34Smrg 497763847c39Smrg /* Count number of arguments. */ 497863847c39Smrg for (argc = 0; argv[argc] != NULL; argc++) 497963847c39Smrg ; 498086dafe34Smrg 498163847c39Smrg /* Allocate new argument vector. */ 498263847c39Smrg new_argv = XMALLOC (char *, argc + 1); 498386dafe34Smrg 498463847c39Smrg /* Put quoted arguments into the new argument vector. */ 498563847c39Smrg for (i = 0; i < argc; i++) 498663847c39Smrg { 498763847c39Smrg const char *string = argv[i]; 498863847c39Smrg 498963847c39Smrg if (string[0] == '\0') 499063847c39Smrg new_argv[i] = xstrdup ("\"\""); 499163847c39Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 499263847c39Smrg { 499363847c39Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 499463847c39Smrg size_t length; 499563847c39Smrg unsigned int backslashes; 499663847c39Smrg const char *s; 499763847c39Smrg char *quoted_string; 499863847c39Smrg char *p; 499963847c39Smrg 500063847c39Smrg length = 0; 500163847c39Smrg backslashes = 0; 500263847c39Smrg if (quote_around) 500363847c39Smrg length++; 500463847c39Smrg for (s = string; *s != '\0'; s++) 500563847c39Smrg { 500663847c39Smrg char c = *s; 500763847c39Smrg if (c == '"') 500863847c39Smrg length += backslashes + 1; 500963847c39Smrg length++; 501063847c39Smrg if (c == '\\') 501163847c39Smrg backslashes++; 501263847c39Smrg else 501363847c39Smrg backslashes = 0; 501463847c39Smrg } 501563847c39Smrg if (quote_around) 501663847c39Smrg length += backslashes + 1; 501763847c39Smrg 501863847c39Smrg quoted_string = XMALLOC (char, length + 1); 501963847c39Smrg 502063847c39Smrg p = quoted_string; 502163847c39Smrg backslashes = 0; 502263847c39Smrg if (quote_around) 502363847c39Smrg *p++ = '"'; 502463847c39Smrg for (s = string; *s != '\0'; s++) 502563847c39Smrg { 502663847c39Smrg char c = *s; 502763847c39Smrg if (c == '"') 502863847c39Smrg { 502963847c39Smrg unsigned int j; 503063847c39Smrg for (j = backslashes + 1; j > 0; j--) 503163847c39Smrg *p++ = '\\'; 503263847c39Smrg } 503363847c39Smrg *p++ = c; 503463847c39Smrg if (c == '\\') 503563847c39Smrg backslashes++; 503663847c39Smrg else 503763847c39Smrg backslashes = 0; 503863847c39Smrg } 503963847c39Smrg if (quote_around) 504063847c39Smrg { 504163847c39Smrg unsigned int j; 504263847c39Smrg for (j = backslashes; j > 0; j--) 504363847c39Smrg *p++ = '\\'; 504463847c39Smrg *p++ = '"'; 504563847c39Smrg } 504663847c39Smrg *p = '\0'; 504786dafe34Smrg 504863847c39Smrg new_argv[i] = quoted_string; 504963847c39Smrg } 505063847c39Smrg else 505163847c39Smrg new_argv[i] = (char *) string; 505263847c39Smrg } 505363847c39Smrg new_argv[argc] = NULL; 505486dafe34Smrg 505563847c39Smrg return new_argv; 505663847c39Smrg} 5057d8556812SmrgEOF 505863847c39Smrg ;; 505963847c39Smrg esac 506086dafe34Smrg 506163847c39Smrg cat <<"EOF" 506263847c39Smrgvoid lt_dump_script (FILE* f) 506363847c39Smrg{ 5064d8556812SmrgEOF 506563847c39Smrg func_emit_wrapper yes | 506663847c39Smrg $SED -n -e ' 506763847c39Smrgs/^\(.\{79\}\)\(..*\)/\1\ 506863847c39Smrg\2/ 506963847c39Smrgh 507063847c39Smrgs/\([\\"]\)/\\\1/g 507163847c39Smrgs/$/\\n/ 507263847c39Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 507363847c39Smrgg 507463847c39SmrgD' 507563847c39Smrg cat <<"EOF" 5076d8556812Smrg} 507763847c39SmrgEOF 5078d8556812Smrg} 507963847c39Smrg# end: func_emit_cwrapperexe_src 508086dafe34Smrg 508163847c39Smrg# func_win32_import_lib_p ARG 508263847c39Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 508363847c39Smrgfunc_win32_import_lib_p () 5084d8556812Smrg{ 508563847c39Smrg $opt_debug 508663847c39Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 508763847c39Smrg *import*) : ;; 508863847c39Smrg *) false ;; 508963847c39Smrg esac 5090d8556812Smrg} 509186dafe34Smrg 509263847c39Smrg# func_mode_link arg... 509363847c39Smrgfunc_mode_link () 5094d8556812Smrg{ 509563847c39Smrg $opt_debug 509663847c39Smrg case $host in 509763847c39Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 509863847c39Smrg # It is impossible to link a dll without this setting, and 509963847c39Smrg # we shouldn't force the makefile maintainer to figure out 510063847c39Smrg # which system we are compiling for in order to pass an extra 510163847c39Smrg # flag for every libtool invocation. 510263847c39Smrg # allow_undefined=no 510386dafe34Smrg 510463847c39Smrg # FIXME: Unfortunately, there are problems with the above when trying 510563847c39Smrg # to make a dll which has undefined symbols, in which case not 510663847c39Smrg # even a static library is built. For now, we need to specify 510763847c39Smrg # -no-undefined on the libtool link line when we can be certain 510863847c39Smrg # that all symbols are satisfied, otherwise we get a static library. 510963847c39Smrg allow_undefined=yes 511063847c39Smrg ;; 511163847c39Smrg *) 511263847c39Smrg allow_undefined=yes 511363847c39Smrg ;; 511463847c39Smrg esac 511563847c39Smrg libtool_args=$nonopt 511663847c39Smrg base_compile="$nonopt $@" 511763847c39Smrg compile_command=$nonopt 511863847c39Smrg finalize_command=$nonopt 511986dafe34Smrg 512063847c39Smrg compile_rpath= 512163847c39Smrg finalize_rpath= 512263847c39Smrg compile_shlibpath= 512363847c39Smrg finalize_shlibpath= 512463847c39Smrg convenience= 512563847c39Smrg old_convenience= 512663847c39Smrg deplibs= 512763847c39Smrg old_deplibs= 512863847c39Smrg compiler_flags= 512963847c39Smrg linker_flags= 513063847c39Smrg dllsearchpath= 513163847c39Smrg lib_search_path=`pwd` 513263847c39Smrg inst_prefix_dir= 513363847c39Smrg new_inherited_linker_flags= 513486dafe34Smrg 513563847c39Smrg avoid_version=no 513663847c39Smrg bindir= 513763847c39Smrg dlfiles= 513863847c39Smrg dlprefiles= 513963847c39Smrg dlself=no 514063847c39Smrg export_dynamic=no 514163847c39Smrg export_symbols= 514263847c39Smrg export_symbols_regex= 514363847c39Smrg generated= 514463847c39Smrg libobjs= 514563847c39Smrg ltlibs= 514663847c39Smrg module=no 514763847c39Smrg no_install=no 514863847c39Smrg objs= 514963847c39Smrg non_pic_objects= 515063847c39Smrg precious_files_regex= 515163847c39Smrg prefer_static_libs=no 515263847c39Smrg preload=no 515363847c39Smrg prev= 515463847c39Smrg prevarg= 515563847c39Smrg release= 515663847c39Smrg rpath= 515763847c39Smrg xrpath= 515863847c39Smrg perm_rpath= 515963847c39Smrg temp_rpath= 516063847c39Smrg thread_safe=no 516163847c39Smrg vinfo= 516263847c39Smrg vinfo_number=no 516363847c39Smrg weak_libs= 516463847c39Smrg single_module="${wl}-single_module" 516563847c39Smrg func_infer_tag $base_compile 516686dafe34Smrg 516763847c39Smrg # We need to know -static, to get the right output filenames. 516863847c39Smrg for arg 516963847c39Smrg do 517063847c39Smrg case $arg in 517163847c39Smrg -shared) 517263847c39Smrg test "$build_libtool_libs" != yes && \ 517363847c39Smrg func_fatal_configuration "can not build a shared library" 517463847c39Smrg build_old_libs=no 517563847c39Smrg break 517663847c39Smrg ;; 517763847c39Smrg -all-static | -static | -static-libtool-libs) 517863847c39Smrg case $arg in 517963847c39Smrg -all-static) 518063847c39Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 518163847c39Smrg func_warning "complete static linking is impossible in this configuration" 518263847c39Smrg fi 518363847c39Smrg if test -n "$link_static_flag"; then 518463847c39Smrg dlopen_self=$dlopen_self_static 518563847c39Smrg fi 518663847c39Smrg prefer_static_libs=yes 518763847c39Smrg ;; 518863847c39Smrg -static) 518963847c39Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 519063847c39Smrg dlopen_self=$dlopen_self_static 519163847c39Smrg fi 519263847c39Smrg prefer_static_libs=built 519363847c39Smrg ;; 519463847c39Smrg -static-libtool-libs) 519563847c39Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 519663847c39Smrg dlopen_self=$dlopen_self_static 519763847c39Smrg fi 519863847c39Smrg prefer_static_libs=yes 519963847c39Smrg ;; 520063847c39Smrg esac 520163847c39Smrg build_libtool_libs=no 520263847c39Smrg build_old_libs=yes 520363847c39Smrg break 520463847c39Smrg ;; 520563847c39Smrg esac 520663847c39Smrg done 520786dafe34Smrg 520863847c39Smrg # See if our shared archives depend on static archives. 520963847c39Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 521086dafe34Smrg 521163847c39Smrg # Go through the arguments, transforming them on the way. 521263847c39Smrg while test "$#" -gt 0; do 521363847c39Smrg arg="$1" 521463847c39Smrg shift 521563847c39Smrg func_quote_for_eval "$arg" 521663847c39Smrg qarg=$func_quote_for_eval_unquoted_result 521763847c39Smrg func_append libtool_args " $func_quote_for_eval_result" 521876888252Smrg 521963847c39Smrg # If the previous option needs an argument, assign it. 522063847c39Smrg if test -n "$prev"; then 522163847c39Smrg case $prev in 522263847c39Smrg output) 522363847c39Smrg func_append compile_command " @OUTPUT@" 522463847c39Smrg func_append finalize_command " @OUTPUT@" 522563847c39Smrg ;; 522663847c39Smrg esac 5227d8556812Smrg 522863847c39Smrg case $prev in 522963847c39Smrg bindir) 523063847c39Smrg bindir="$arg" 523163847c39Smrg prev= 523263847c39Smrg continue 523363847c39Smrg ;; 523463847c39Smrg dlfiles|dlprefiles) 523563847c39Smrg if test "$preload" = no; then 523663847c39Smrg # Add the symbol object into the linking commands. 523763847c39Smrg func_append compile_command " @SYMFILE@" 523863847c39Smrg func_append finalize_command " @SYMFILE@" 523963847c39Smrg preload=yes 524063847c39Smrg fi 524163847c39Smrg case $arg in 524263847c39Smrg *.la | *.lo) ;; # We handle these cases below. 524363847c39Smrg force) 524463847c39Smrg if test "$dlself" = no; then 524563847c39Smrg dlself=needless 524663847c39Smrg export_dynamic=yes 524763847c39Smrg fi 524863847c39Smrg prev= 524963847c39Smrg continue 525063847c39Smrg ;; 525163847c39Smrg self) 525263847c39Smrg if test "$prev" = dlprefiles; then 525363847c39Smrg dlself=yes 525463847c39Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 525563847c39Smrg dlself=yes 525663847c39Smrg else 525763847c39Smrg dlself=needless 525863847c39Smrg export_dynamic=yes 525963847c39Smrg fi 526063847c39Smrg prev= 526163847c39Smrg continue 526263847c39Smrg ;; 526363847c39Smrg *) 526463847c39Smrg if test "$prev" = dlfiles; then 526563847c39Smrg func_append dlfiles " $arg" 526663847c39Smrg else 526763847c39Smrg func_append dlprefiles " $arg" 526863847c39Smrg fi 526963847c39Smrg prev= 527063847c39Smrg continue 527163847c39Smrg ;; 527263847c39Smrg esac 527363847c39Smrg ;; 527463847c39Smrg expsyms) 527563847c39Smrg export_symbols="$arg" 527663847c39Smrg test -f "$arg" \ 527763847c39Smrg || func_fatal_error "symbol file \`$arg' does not exist" 527863847c39Smrg prev= 527963847c39Smrg continue 528063847c39Smrg ;; 528163847c39Smrg expsyms_regex) 528263847c39Smrg export_symbols_regex="$arg" 528363847c39Smrg prev= 528463847c39Smrg continue 528563847c39Smrg ;; 528663847c39Smrg framework) 528763847c39Smrg case $host in 528863847c39Smrg *-*-darwin*) 528963847c39Smrg case "$deplibs " in 529063847c39Smrg *" $qarg.ltframework "*) ;; 529163847c39Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 529263847c39Smrg ;; 529363847c39Smrg esac 529463847c39Smrg ;; 529563847c39Smrg esac 529663847c39Smrg prev= 529763847c39Smrg continue 529863847c39Smrg ;; 529963847c39Smrg inst_prefix) 530063847c39Smrg inst_prefix_dir="$arg" 530163847c39Smrg prev= 530263847c39Smrg continue 530363847c39Smrg ;; 530463847c39Smrg objectlist) 530563847c39Smrg if test -f "$arg"; then 530663847c39Smrg save_arg=$arg 530763847c39Smrg moreargs= 530863847c39Smrg for fil in `cat "$save_arg"` 530963847c39Smrg do 531063847c39Smrg# func_append moreargs " $fil" 531163847c39Smrg arg=$fil 531263847c39Smrg # A libtool-controlled object. 5313d8556812Smrg 531463847c39Smrg # Check to see that this really is a libtool object. 531563847c39Smrg if func_lalib_unsafe_p "$arg"; then 531663847c39Smrg pic_object= 531763847c39Smrg non_pic_object= 5318d8556812Smrg 531963847c39Smrg # Read the .lo file 532063847c39Smrg func_source "$arg" 5321d8556812Smrg 532263847c39Smrg if test -z "$pic_object" || 532363847c39Smrg test -z "$non_pic_object" || 532463847c39Smrg test "$pic_object" = none && 532563847c39Smrg test "$non_pic_object" = none; then 532663847c39Smrg func_fatal_error "cannot find name of object for \`$arg'" 532763847c39Smrg fi 5328d8556812Smrg 532963847c39Smrg # Extract subdirectory from the argument. 533063847c39Smrg func_dirname "$arg" "/" "" 533163847c39Smrg xdir="$func_dirname_result" 5332d8556812Smrg 533363847c39Smrg if test "$pic_object" != none; then 533463847c39Smrg # Prepend the subdirectory the object is found in. 533563847c39Smrg pic_object="$xdir$pic_object" 5336d8556812Smrg 533763847c39Smrg if test "$prev" = dlfiles; then 533863847c39Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 533963847c39Smrg func_append dlfiles " $pic_object" 534063847c39Smrg prev= 534163847c39Smrg continue 534263847c39Smrg else 534363847c39Smrg # If libtool objects are unsupported, then we need to preload. 534463847c39Smrg prev=dlprefiles 534563847c39Smrg fi 534663847c39Smrg fi 5347d8556812Smrg 534863847c39Smrg # CHECK ME: I think I busted this. -Ossama 534963847c39Smrg if test "$prev" = dlprefiles; then 535063847c39Smrg # Preload the old-style object. 535163847c39Smrg func_append dlprefiles " $pic_object" 535263847c39Smrg prev= 535363847c39Smrg fi 5354d8556812Smrg 535563847c39Smrg # A PIC object. 535663847c39Smrg func_append libobjs " $pic_object" 535763847c39Smrg arg="$pic_object" 535863847c39Smrg fi 5359d8556812Smrg 536063847c39Smrg # Non-PIC object. 536163847c39Smrg if test "$non_pic_object" != none; then 536263847c39Smrg # Prepend the subdirectory the object is found in. 536363847c39Smrg non_pic_object="$xdir$non_pic_object" 5364d8556812Smrg 536563847c39Smrg # A standard non-PIC object 536663847c39Smrg func_append non_pic_objects " $non_pic_object" 536763847c39Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 536863847c39Smrg arg="$non_pic_object" 536963847c39Smrg fi 537063847c39Smrg else 537163847c39Smrg # If the PIC object exists, use it instead. 537263847c39Smrg # $xdir was prepended to $pic_object above. 537363847c39Smrg non_pic_object="$pic_object" 537463847c39Smrg func_append non_pic_objects " $non_pic_object" 537563847c39Smrg fi 537663847c39Smrg else 537763847c39Smrg # Only an error if not doing a dry-run. 537863847c39Smrg if $opt_dry_run; then 537963847c39Smrg # Extract subdirectory from the argument. 538063847c39Smrg func_dirname "$arg" "/" "" 538163847c39Smrg xdir="$func_dirname_result" 538263847c39Smrg 538363847c39Smrg func_lo2o "$arg" 538463847c39Smrg pic_object=$xdir$objdir/$func_lo2o_result 538563847c39Smrg non_pic_object=$xdir$func_lo2o_result 538663847c39Smrg func_append libobjs " $pic_object" 538763847c39Smrg func_append non_pic_objects " $non_pic_object" 538863847c39Smrg else 538963847c39Smrg func_fatal_error "\`$arg' is not a valid libtool object" 539063847c39Smrg fi 539163847c39Smrg fi 539263847c39Smrg done 539363847c39Smrg else 539463847c39Smrg func_fatal_error "link input file \`$arg' does not exist" 539563847c39Smrg fi 539663847c39Smrg arg=$save_arg 539763847c39Smrg prev= 539863847c39Smrg continue 539963847c39Smrg ;; 540063847c39Smrg precious_regex) 540163847c39Smrg precious_files_regex="$arg" 540263847c39Smrg prev= 540363847c39Smrg continue 540463847c39Smrg ;; 540563847c39Smrg release) 540663847c39Smrg release="-$arg" 540763847c39Smrg prev= 540863847c39Smrg continue 540963847c39Smrg ;; 541063847c39Smrg rpath | xrpath) 541163847c39Smrg # We need an absolute path. 541263847c39Smrg case $arg in 541363847c39Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 541463847c39Smrg *) 541563847c39Smrg func_fatal_error "only absolute run-paths are allowed" 541663847c39Smrg ;; 541763847c39Smrg esac 541863847c39Smrg if test "$prev" = rpath; then 541963847c39Smrg case "$rpath " in 542063847c39Smrg *" $arg "*) ;; 542163847c39Smrg *) func_append rpath " $arg" ;; 542263847c39Smrg esac 542363847c39Smrg else 542463847c39Smrg case "$xrpath " in 542563847c39Smrg *" $arg "*) ;; 542663847c39Smrg *) func_append xrpath " $arg" ;; 542763847c39Smrg esac 542863847c39Smrg fi 542963847c39Smrg prev= 543063847c39Smrg continue 543163847c39Smrg ;; 543263847c39Smrg shrext) 543363847c39Smrg shrext_cmds="$arg" 543463847c39Smrg prev= 543563847c39Smrg continue 543663847c39Smrg ;; 543763847c39Smrg weak) 543863847c39Smrg func_append weak_libs " $arg" 543963847c39Smrg prev= 544063847c39Smrg continue 544163847c39Smrg ;; 544263847c39Smrg xcclinker) 544363847c39Smrg func_append linker_flags " $qarg" 544463847c39Smrg func_append compiler_flags " $qarg" 544563847c39Smrg prev= 544663847c39Smrg func_append compile_command " $qarg" 544763847c39Smrg func_append finalize_command " $qarg" 544863847c39Smrg continue 544963847c39Smrg ;; 545063847c39Smrg xcompiler) 545163847c39Smrg func_append compiler_flags " $qarg" 545263847c39Smrg prev= 545363847c39Smrg func_append compile_command " $qarg" 545463847c39Smrg func_append finalize_command " $qarg" 545563847c39Smrg continue 545663847c39Smrg ;; 545763847c39Smrg xlinker) 545863847c39Smrg func_append linker_flags " $qarg" 545963847c39Smrg func_append compiler_flags " $wl$qarg" 546063847c39Smrg prev= 546163847c39Smrg func_append compile_command " $wl$qarg" 546263847c39Smrg func_append finalize_command " $wl$qarg" 546363847c39Smrg continue 546463847c39Smrg ;; 546563847c39Smrg *) 546663847c39Smrg eval "$prev=\"\$arg\"" 546763847c39Smrg prev= 546863847c39Smrg continue 546963847c39Smrg ;; 547063847c39Smrg esac 547163847c39Smrg fi # test -n "$prev" 5472d8556812Smrg 547363847c39Smrg prevarg="$arg" 5474d8556812Smrg 547563847c39Smrg case $arg in 547663847c39Smrg -all-static) 547763847c39Smrg if test -n "$link_static_flag"; then 547863847c39Smrg # See comment for -static flag below, for more details. 547963847c39Smrg func_append compile_command " $link_static_flag" 548063847c39Smrg func_append finalize_command " $link_static_flag" 548163847c39Smrg fi 548263847c39Smrg continue 548363847c39Smrg ;; 5484d8556812Smrg 548563847c39Smrg -allow-undefined) 548663847c39Smrg # FIXME: remove this flag sometime in the future. 548763847c39Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 548863847c39Smrg ;; 5489d8556812Smrg 549063847c39Smrg -avoid-version) 549163847c39Smrg avoid_version=yes 549263847c39Smrg continue 549363847c39Smrg ;; 5494d8556812Smrg 549563847c39Smrg -bindir) 549663847c39Smrg prev=bindir 549763847c39Smrg continue 549863847c39Smrg ;; 549976888252Smrg 550063847c39Smrg -dlopen) 550163847c39Smrg prev=dlfiles 550263847c39Smrg continue 550363847c39Smrg ;; 550476888252Smrg 550563847c39Smrg -dlpreopen) 550663847c39Smrg prev=dlprefiles 550763847c39Smrg continue 550863847c39Smrg ;; 550976888252Smrg 551063847c39Smrg -export-dynamic) 551163847c39Smrg export_dynamic=yes 551263847c39Smrg continue 551363847c39Smrg ;; 551476888252Smrg 551563847c39Smrg -export-symbols | -export-symbols-regex) 551663847c39Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 551763847c39Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 551863847c39Smrg fi 551963847c39Smrg if test "X$arg" = "X-export-symbols"; then 552063847c39Smrg prev=expsyms 552163847c39Smrg else 552263847c39Smrg prev=expsyms_regex 552363847c39Smrg fi 552463847c39Smrg continue 552563847c39Smrg ;; 552676888252Smrg 552763847c39Smrg -framework) 552863847c39Smrg prev=framework 552963847c39Smrg continue 553063847c39Smrg ;; 553176888252Smrg 553263847c39Smrg -inst-prefix-dir) 553363847c39Smrg prev=inst_prefix 553463847c39Smrg continue 553563847c39Smrg ;; 553676888252Smrg 553763847c39Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 553863847c39Smrg # so, if we see these flags be careful not to treat them like -L 553963847c39Smrg -L[A-Z][A-Z]*:*) 554063847c39Smrg case $with_gcc/$host in 554163847c39Smrg no/*-*-irix* | /*-*-irix*) 554263847c39Smrg func_append compile_command " $arg" 554363847c39Smrg func_append finalize_command " $arg" 554463847c39Smrg ;; 554563847c39Smrg esac 554663847c39Smrg continue 554763847c39Smrg ;; 554876888252Smrg 554963847c39Smrg -L*) 555063847c39Smrg func_stripname "-L" '' "$arg" 555163847c39Smrg if test -z "$func_stripname_result"; then 555263847c39Smrg if test "$#" -gt 0; then 555363847c39Smrg func_fatal_error "require no space between \`-L' and \`$1'" 555463847c39Smrg else 555563847c39Smrg func_fatal_error "need path for \`-L' option" 555663847c39Smrg fi 555763847c39Smrg fi 555863847c39Smrg func_resolve_sysroot "$func_stripname_result" 555963847c39Smrg dir=$func_resolve_sysroot_result 556063847c39Smrg # We need an absolute path. 556163847c39Smrg case $dir in 556263847c39Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 556363847c39Smrg *) 556463847c39Smrg absdir=`cd "$dir" && pwd` 556563847c39Smrg test -z "$absdir" && \ 556663847c39Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 556763847c39Smrg dir="$absdir" 556863847c39Smrg ;; 556963847c39Smrg esac 557063847c39Smrg case "$deplibs " in 557163847c39Smrg *" -L$dir "* | *" $arg "*) 557263847c39Smrg # Will only happen for absolute or sysroot arguments 557363847c39Smrg ;; 557463847c39Smrg *) 557563847c39Smrg # Preserve sysroot, but never include relative directories 557663847c39Smrg case $dir in 557763847c39Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 557863847c39Smrg *) func_append deplibs " -L$dir" ;; 557963847c39Smrg esac 558063847c39Smrg func_append lib_search_path " $dir" 558163847c39Smrg ;; 558263847c39Smrg esac 558363847c39Smrg case $host in 558463847c39Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 558563847c39Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 558663847c39Smrg case :$dllsearchpath: in 558763847c39Smrg *":$dir:"*) ;; 558863847c39Smrg ::) dllsearchpath=$dir;; 558963847c39Smrg *) func_append dllsearchpath ":$dir";; 559063847c39Smrg esac 559163847c39Smrg case :$dllsearchpath: in 559263847c39Smrg *":$testbindir:"*) ;; 559363847c39Smrg ::) dllsearchpath=$testbindir;; 559463847c39Smrg *) func_append dllsearchpath ":$testbindir";; 559563847c39Smrg esac 559663847c39Smrg ;; 559763847c39Smrg esac 559863847c39Smrg continue 559963847c39Smrg ;; 560076888252Smrg 560163847c39Smrg -l*) 560263847c39Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 560363847c39Smrg case $host in 560463847c39Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 560563847c39Smrg # These systems don't actually have a C or math library (as such) 560663847c39Smrg continue 560763847c39Smrg ;; 560863847c39Smrg *-*-os2*) 560963847c39Smrg # These systems don't actually have a C library (as such) 561063847c39Smrg test "X$arg" = "X-lc" && continue 561163847c39Smrg ;; 561263847c39Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 561363847c39Smrg # Do not include libc due to us having libc/libc_r. 561463847c39Smrg test "X$arg" = "X-lc" && continue 561563847c39Smrg ;; 561663847c39Smrg *-*-rhapsody* | *-*-darwin1.[012]) 561763847c39Smrg # Rhapsody C and math libraries are in the System framework 561863847c39Smrg func_append deplibs " System.ltframework" 561963847c39Smrg continue 562063847c39Smrg ;; 562163847c39Smrg *-*-sco3.2v5* | *-*-sco5v6*) 562263847c39Smrg # Causes problems with __ctype 562363847c39Smrg test "X$arg" = "X-lc" && continue 562463847c39Smrg ;; 562563847c39Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 562663847c39Smrg # Compiler inserts libc in the correct place for threads to work 562763847c39Smrg test "X$arg" = "X-lc" && continue 562863847c39Smrg ;; 562963847c39Smrg esac 563063847c39Smrg elif test "X$arg" = "X-lc_r"; then 563163847c39Smrg case $host in 563263847c39Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 563363847c39Smrg # Do not include libc_r directly, use -pthread flag. 563463847c39Smrg continue 563563847c39Smrg ;; 563663847c39Smrg esac 563763847c39Smrg fi 563863847c39Smrg func_append deplibs " $arg" 563963847c39Smrg continue 564063847c39Smrg ;; 564163847c39Smrg 564263847c39Smrg -module) 564363847c39Smrg module=yes 564463847c39Smrg continue 564563847c39Smrg ;; 564663847c39Smrg 564763847c39Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 564863847c39Smrg # classes, name mangling, and exception handling. 564963847c39Smrg # Darwin uses the -arch flag to determine output architecture. 565063847c39Smrg -model|-arch|-isysroot|--sysroot) 565163847c39Smrg func_append compiler_flags " $arg" 565263847c39Smrg func_append compile_command " $arg" 565363847c39Smrg func_append finalize_command " $arg" 565463847c39Smrg prev=xcompiler 565563847c39Smrg continue 565663847c39Smrg ;; 565763847c39Smrg 565863847c39Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 565963847c39Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 566063847c39Smrg func_append compiler_flags " $arg" 566163847c39Smrg func_append compile_command " $arg" 566263847c39Smrg func_append finalize_command " $arg" 566363847c39Smrg case "$new_inherited_linker_flags " in 566463847c39Smrg *" $arg "*) ;; 566563847c39Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 566663847c39Smrg esac 566763847c39Smrg continue 566863847c39Smrg ;; 566963847c39Smrg 567063847c39Smrg -multi_module) 567163847c39Smrg single_module="${wl}-multi_module" 567263847c39Smrg continue 567363847c39Smrg ;; 567463847c39Smrg 567563847c39Smrg -no-fast-install) 567663847c39Smrg fast_install=no 567763847c39Smrg continue 567863847c39Smrg ;; 567963847c39Smrg 568063847c39Smrg -no-install) 568163847c39Smrg case $host in 568263847c39Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 568363847c39Smrg # The PATH hackery in wrapper scripts is required on Windows 568463847c39Smrg # and Darwin in order for the loader to find any dlls it needs. 568563847c39Smrg func_warning "\`-no-install' is ignored for $host" 568663847c39Smrg func_warning "assuming \`-no-fast-install' instead" 568763847c39Smrg fast_install=no 568863847c39Smrg ;; 568963847c39Smrg *) no_install=yes ;; 569063847c39Smrg esac 569163847c39Smrg continue 569263847c39Smrg ;; 569363847c39Smrg 569463847c39Smrg -no-undefined) 569563847c39Smrg allow_undefined=no 569663847c39Smrg continue 569763847c39Smrg ;; 569863847c39Smrg 569963847c39Smrg -objectlist) 570063847c39Smrg prev=objectlist 570163847c39Smrg continue 570263847c39Smrg ;; 570363847c39Smrg 570463847c39Smrg -o) prev=output ;; 570563847c39Smrg 570663847c39Smrg -precious-files-regex) 570763847c39Smrg prev=precious_regex 570863847c39Smrg continue 570963847c39Smrg ;; 571063847c39Smrg 571163847c39Smrg -release) 571263847c39Smrg prev=release 571363847c39Smrg continue 571463847c39Smrg ;; 571563847c39Smrg 571663847c39Smrg -rpath) 571763847c39Smrg prev=rpath 571863847c39Smrg continue 571963847c39Smrg ;; 572063847c39Smrg 572163847c39Smrg -R) 572263847c39Smrg prev=xrpath 572363847c39Smrg continue 572463847c39Smrg ;; 572563847c39Smrg 572663847c39Smrg -R*) 572763847c39Smrg func_stripname '-R' '' "$arg" 572863847c39Smrg dir=$func_stripname_result 572963847c39Smrg # We need an absolute path. 573063847c39Smrg case $dir in 573163847c39Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 573263847c39Smrg =*) 573363847c39Smrg func_stripname '=' '' "$dir" 573463847c39Smrg dir=$lt_sysroot$func_stripname_result 573563847c39Smrg ;; 573663847c39Smrg *) 573763847c39Smrg func_fatal_error "only absolute run-paths are allowed" 573863847c39Smrg ;; 573963847c39Smrg esac 574063847c39Smrg case "$xrpath " in 574163847c39Smrg *" $dir "*) ;; 574263847c39Smrg *) func_append xrpath " $dir" ;; 574363847c39Smrg esac 574463847c39Smrg continue 574563847c39Smrg ;; 574663847c39Smrg 574763847c39Smrg -shared) 574863847c39Smrg # The effects of -shared are defined in a previous loop. 574963847c39Smrg continue 575063847c39Smrg ;; 575163847c39Smrg 575263847c39Smrg -shrext) 575363847c39Smrg prev=shrext 575463847c39Smrg continue 575563847c39Smrg ;; 575663847c39Smrg 575763847c39Smrg -static | -static-libtool-libs) 575863847c39Smrg # The effects of -static are defined in a previous loop. 575963847c39Smrg # We used to do the same as -all-static on platforms that 576063847c39Smrg # didn't have a PIC flag, but the assumption that the effects 576163847c39Smrg # would be equivalent was wrong. It would break on at least 576263847c39Smrg # Digital Unix and AIX. 576363847c39Smrg continue 576463847c39Smrg ;; 576563847c39Smrg 576663847c39Smrg -thread-safe) 576763847c39Smrg thread_safe=yes 576863847c39Smrg continue 576963847c39Smrg ;; 577063847c39Smrg 577163847c39Smrg -version-info) 577263847c39Smrg prev=vinfo 577363847c39Smrg continue 577463847c39Smrg ;; 577563847c39Smrg 577663847c39Smrg -version-number) 577763847c39Smrg prev=vinfo 577863847c39Smrg vinfo_number=yes 577963847c39Smrg continue 578063847c39Smrg ;; 578163847c39Smrg 578263847c39Smrg -weak) 578363847c39Smrg prev=weak 578463847c39Smrg continue 578563847c39Smrg ;; 578663847c39Smrg 578763847c39Smrg -Wc,*) 578863847c39Smrg func_stripname '-Wc,' '' "$arg" 578963847c39Smrg args=$func_stripname_result 579063847c39Smrg arg= 579163847c39Smrg save_ifs="$IFS"; IFS=',' 579263847c39Smrg for flag in $args; do 579363847c39Smrg IFS="$save_ifs" 579463847c39Smrg func_quote_for_eval "$flag" 579563847c39Smrg func_append arg " $func_quote_for_eval_result" 579663847c39Smrg func_append compiler_flags " $func_quote_for_eval_result" 579763847c39Smrg done 579863847c39Smrg IFS="$save_ifs" 579963847c39Smrg func_stripname ' ' '' "$arg" 580063847c39Smrg arg=$func_stripname_result 580163847c39Smrg ;; 580263847c39Smrg 580363847c39Smrg -Wl,*) 580463847c39Smrg func_stripname '-Wl,' '' "$arg" 580563847c39Smrg args=$func_stripname_result 580663847c39Smrg arg= 580763847c39Smrg save_ifs="$IFS"; IFS=',' 580863847c39Smrg for flag in $args; do 580963847c39Smrg IFS="$save_ifs" 581063847c39Smrg func_quote_for_eval "$flag" 581163847c39Smrg func_append arg " $wl$func_quote_for_eval_result" 581263847c39Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 581363847c39Smrg func_append linker_flags " $func_quote_for_eval_result" 581463847c39Smrg done 581563847c39Smrg IFS="$save_ifs" 581663847c39Smrg func_stripname ' ' '' "$arg" 581763847c39Smrg arg=$func_stripname_result 581863847c39Smrg ;; 581963847c39Smrg 582063847c39Smrg -Xcompiler) 582163847c39Smrg prev=xcompiler 582263847c39Smrg continue 582363847c39Smrg ;; 582463847c39Smrg 582563847c39Smrg -Xlinker) 582663847c39Smrg prev=xlinker 582763847c39Smrg continue 582863847c39Smrg ;; 582963847c39Smrg 583063847c39Smrg -XCClinker) 583163847c39Smrg prev=xcclinker 583263847c39Smrg continue 583363847c39Smrg ;; 583463847c39Smrg 583563847c39Smrg # -msg_* for osf cc 583663847c39Smrg -msg_*) 583763847c39Smrg func_quote_for_eval "$arg" 583863847c39Smrg arg="$func_quote_for_eval_result" 583963847c39Smrg ;; 584063847c39Smrg 584163847c39Smrg # Flags to be passed through unchanged, with rationale: 584263847c39Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 584363847c39Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 584463847c39Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 584563847c39Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 584663847c39Smrg # -q* compiler args for the IBM compiler 584763847c39Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 584863847c39Smrg # -F/path path to uninstalled frameworks, gcc on darwin 584963847c39Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 585063847c39Smrg # @file GCC response files 585163847c39Smrg # -tp=* Portland pgcc target processor selection 585263847c39Smrg # --sysroot=* for sysroot support 585363847c39Smrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 585463847c39Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 585563847c39Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 585663847c39Smrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 585763847c39Smrg func_quote_for_eval "$arg" 585863847c39Smrg arg="$func_quote_for_eval_result" 585963847c39Smrg func_append compile_command " $arg" 586063847c39Smrg func_append finalize_command " $arg" 586163847c39Smrg func_append compiler_flags " $arg" 586263847c39Smrg continue 586363847c39Smrg ;; 586463847c39Smrg 586563847c39Smrg # Some other compiler flag. 586663847c39Smrg -* | +*) 586763847c39Smrg func_quote_for_eval "$arg" 586863847c39Smrg arg="$func_quote_for_eval_result" 586963847c39Smrg ;; 587063847c39Smrg 587163847c39Smrg *.$objext) 587263847c39Smrg # A standard object. 587363847c39Smrg func_append objs " $arg" 587463847c39Smrg ;; 587563847c39Smrg 587663847c39Smrg *.lo) 587763847c39Smrg # A libtool-controlled object. 587863847c39Smrg 587963847c39Smrg # Check to see that this really is a libtool object. 588063847c39Smrg if func_lalib_unsafe_p "$arg"; then 588163847c39Smrg pic_object= 588263847c39Smrg non_pic_object= 588363847c39Smrg 588463847c39Smrg # Read the .lo file 588563847c39Smrg func_source "$arg" 588663847c39Smrg 588763847c39Smrg if test -z "$pic_object" || 588863847c39Smrg test -z "$non_pic_object" || 588963847c39Smrg test "$pic_object" = none && 589063847c39Smrg test "$non_pic_object" = none; then 589163847c39Smrg func_fatal_error "cannot find name of object for \`$arg'" 589263847c39Smrg fi 589363847c39Smrg 589463847c39Smrg # Extract subdirectory from the argument. 589563847c39Smrg func_dirname "$arg" "/" "" 589663847c39Smrg xdir="$func_dirname_result" 589763847c39Smrg 589863847c39Smrg if test "$pic_object" != none; then 589963847c39Smrg # Prepend the subdirectory the object is found in. 590063847c39Smrg pic_object="$xdir$pic_object" 590163847c39Smrg 590263847c39Smrg if test "$prev" = dlfiles; then 590363847c39Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 590463847c39Smrg func_append dlfiles " $pic_object" 590563847c39Smrg prev= 590663847c39Smrg continue 590763847c39Smrg else 590863847c39Smrg # If libtool objects are unsupported, then we need to preload. 590963847c39Smrg prev=dlprefiles 591063847c39Smrg fi 591163847c39Smrg fi 591263847c39Smrg 591363847c39Smrg # CHECK ME: I think I busted this. -Ossama 591463847c39Smrg if test "$prev" = dlprefiles; then 591563847c39Smrg # Preload the old-style object. 591663847c39Smrg func_append dlprefiles " $pic_object" 591763847c39Smrg prev= 591863847c39Smrg fi 591963847c39Smrg 592063847c39Smrg # A PIC object. 592163847c39Smrg func_append libobjs " $pic_object" 592263847c39Smrg arg="$pic_object" 592363847c39Smrg fi 592463847c39Smrg 592563847c39Smrg # Non-PIC object. 592663847c39Smrg if test "$non_pic_object" != none; then 592763847c39Smrg # Prepend the subdirectory the object is found in. 592863847c39Smrg non_pic_object="$xdir$non_pic_object" 592963847c39Smrg 593063847c39Smrg # A standard non-PIC object 593163847c39Smrg func_append non_pic_objects " $non_pic_object" 593263847c39Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 593363847c39Smrg arg="$non_pic_object" 593463847c39Smrg fi 593563847c39Smrg else 593663847c39Smrg # If the PIC object exists, use it instead. 593763847c39Smrg # $xdir was prepended to $pic_object above. 593863847c39Smrg non_pic_object="$pic_object" 593963847c39Smrg func_append non_pic_objects " $non_pic_object" 594063847c39Smrg fi 594163847c39Smrg else 594263847c39Smrg # Only an error if not doing a dry-run. 594363847c39Smrg if $opt_dry_run; then 594463847c39Smrg # Extract subdirectory from the argument. 594563847c39Smrg func_dirname "$arg" "/" "" 594663847c39Smrg xdir="$func_dirname_result" 594763847c39Smrg 594863847c39Smrg func_lo2o "$arg" 594963847c39Smrg pic_object=$xdir$objdir/$func_lo2o_result 595063847c39Smrg non_pic_object=$xdir$func_lo2o_result 595163847c39Smrg func_append libobjs " $pic_object" 595263847c39Smrg func_append non_pic_objects " $non_pic_object" 595363847c39Smrg else 595463847c39Smrg func_fatal_error "\`$arg' is not a valid libtool object" 595563847c39Smrg fi 595663847c39Smrg fi 595763847c39Smrg ;; 595863847c39Smrg 595963847c39Smrg *.$libext) 596063847c39Smrg # An archive. 596163847c39Smrg func_append deplibs " $arg" 596263847c39Smrg func_append old_deplibs " $arg" 596363847c39Smrg continue 596463847c39Smrg ;; 596563847c39Smrg 596663847c39Smrg *.la) 596763847c39Smrg # A libtool-controlled library. 596863847c39Smrg 596963847c39Smrg func_resolve_sysroot "$arg" 597063847c39Smrg if test "$prev" = dlfiles; then 597163847c39Smrg # This library was specified with -dlopen. 597263847c39Smrg func_append dlfiles " $func_resolve_sysroot_result" 597363847c39Smrg prev= 597463847c39Smrg elif test "$prev" = dlprefiles; then 597563847c39Smrg # The library was specified with -dlpreopen. 597663847c39Smrg func_append dlprefiles " $func_resolve_sysroot_result" 597763847c39Smrg prev= 597863847c39Smrg else 597963847c39Smrg func_append deplibs " $func_resolve_sysroot_result" 598063847c39Smrg fi 598163847c39Smrg continue 598263847c39Smrg ;; 598363847c39Smrg 598463847c39Smrg # Some other compiler argument. 598563847c39Smrg *) 598663847c39Smrg # Unknown arguments in both finalize_command and compile_command need 598763847c39Smrg # to be aesthetically quoted because they are evaled later. 598863847c39Smrg func_quote_for_eval "$arg" 598963847c39Smrg arg="$func_quote_for_eval_result" 599063847c39Smrg ;; 599163847c39Smrg esac # arg 599263847c39Smrg 599363847c39Smrg # Now actually substitute the argument into the commands. 599463847c39Smrg if test -n "$arg"; then 599563847c39Smrg func_append compile_command " $arg" 599663847c39Smrg func_append finalize_command " $arg" 599763847c39Smrg fi 599863847c39Smrg done # argument parsing loop 599963847c39Smrg 600063847c39Smrg test -n "$prev" && \ 600163847c39Smrg func_fatal_help "the \`$prevarg' option requires an argument" 600263847c39Smrg 600363847c39Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 600463847c39Smrg eval arg=\"$export_dynamic_flag_spec\" 600563847c39Smrg func_append compile_command " $arg" 600663847c39Smrg func_append finalize_command " $arg" 600763847c39Smrg fi 600863847c39Smrg 600963847c39Smrg oldlibs= 601063847c39Smrg # calculate the name of the file, without its directory 601163847c39Smrg func_basename "$output" 601263847c39Smrg outputname="$func_basename_result" 601363847c39Smrg libobjs_save="$libobjs" 601463847c39Smrg 601563847c39Smrg if test -n "$shlibpath_var"; then 601663847c39Smrg # get the directories listed in $shlibpath_var 601763847c39Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 601863847c39Smrg else 601963847c39Smrg shlib_search_path= 602063847c39Smrg fi 602163847c39Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 602263847c39Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 602363847c39Smrg 602463847c39Smrg func_dirname "$output" "/" "" 602563847c39Smrg output_objdir="$func_dirname_result$objdir" 602663847c39Smrg func_to_tool_file "$output_objdir/" 602763847c39Smrg tool_output_objdir=$func_to_tool_file_result 602863847c39Smrg # Create the object directory. 602963847c39Smrg func_mkdir_p "$output_objdir" 603063847c39Smrg 603163847c39Smrg # Determine the type of output 603263847c39Smrg case $output in 603363847c39Smrg "") 603463847c39Smrg func_fatal_help "you must specify an output file" 603563847c39Smrg ;; 603663847c39Smrg *.$libext) linkmode=oldlib ;; 603763847c39Smrg *.lo | *.$objext) linkmode=obj ;; 603863847c39Smrg *.la) linkmode=lib ;; 603963847c39Smrg *) linkmode=prog ;; # Anything else should be a program. 604063847c39Smrg esac 604163847c39Smrg 604263847c39Smrg specialdeplibs= 604363847c39Smrg 604463847c39Smrg libs= 604563847c39Smrg # Find all interdependent deplibs by searching for libraries 604663847c39Smrg # that are linked more than once (e.g. -la -lb -la) 604763847c39Smrg for deplib in $deplibs; do 604863847c39Smrg if $opt_preserve_dup_deps ; then 604963847c39Smrg case "$libs " in 605063847c39Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 605163847c39Smrg esac 605263847c39Smrg fi 605363847c39Smrg func_append libs " $deplib" 605463847c39Smrg done 605563847c39Smrg 605663847c39Smrg if test "$linkmode" = lib; then 605763847c39Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 605863847c39Smrg 605963847c39Smrg # Compute libraries that are listed more than once in $predeps 606063847c39Smrg # $postdeps and mark them as special (i.e., whose duplicates are 606163847c39Smrg # not to be eliminated). 606263847c39Smrg pre_post_deps= 606363847c39Smrg if $opt_duplicate_compiler_generated_deps; then 606463847c39Smrg for pre_post_dep in $predeps $postdeps; do 606563847c39Smrg case "$pre_post_deps " in 606663847c39Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 606763847c39Smrg esac 606863847c39Smrg func_append pre_post_deps " $pre_post_dep" 606963847c39Smrg done 607063847c39Smrg fi 607163847c39Smrg pre_post_deps= 607263847c39Smrg fi 607363847c39Smrg 607463847c39Smrg deplibs= 607563847c39Smrg newdependency_libs= 607663847c39Smrg newlib_search_path= 607763847c39Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 607863847c39Smrg notinst_deplibs= # not-installed libtool libraries 607963847c39Smrg notinst_path= # paths that contain not-installed libtool libraries 608063847c39Smrg 608163847c39Smrg case $linkmode in 608263847c39Smrg lib) 608363847c39Smrg passes="conv dlpreopen link" 608463847c39Smrg for file in $dlfiles $dlprefiles; do 608563847c39Smrg case $file in 608663847c39Smrg *.la) ;; 608763847c39Smrg *) 608863847c39Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 608963847c39Smrg ;; 609063847c39Smrg esac 609163847c39Smrg done 609263847c39Smrg ;; 609363847c39Smrg prog) 609463847c39Smrg compile_deplibs= 609563847c39Smrg finalize_deplibs= 609663847c39Smrg alldeplibs=no 609763847c39Smrg newdlfiles= 609863847c39Smrg newdlprefiles= 609963847c39Smrg passes="conv scan dlopen dlpreopen link" 610063847c39Smrg ;; 610163847c39Smrg *) passes="conv" 610263847c39Smrg ;; 610363847c39Smrg esac 610463847c39Smrg 610563847c39Smrg for pass in $passes; do 610663847c39Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 610763847c39Smrg # so that -L comes before libs that need it for instance... 610863847c39Smrg if test "$linkmode,$pass" = "lib,link"; then 610963847c39Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 611063847c39Smrg ## order, and fix it there properly 611163847c39Smrg tmp_deplibs= 611263847c39Smrg for deplib in $deplibs; do 611363847c39Smrg tmp_deplibs="$deplib $tmp_deplibs" 611463847c39Smrg done 611563847c39Smrg deplibs="$tmp_deplibs" 611663847c39Smrg fi 611763847c39Smrg 611863847c39Smrg if test "$linkmode,$pass" = "lib,link" || 611963847c39Smrg test "$linkmode,$pass" = "prog,scan"; then 612063847c39Smrg libs="$deplibs" 612163847c39Smrg deplibs= 612263847c39Smrg fi 612363847c39Smrg if test "$linkmode" = prog; then 612463847c39Smrg case $pass in 612563847c39Smrg dlopen) libs="$dlfiles" ;; 612663847c39Smrg dlpreopen) libs="$dlprefiles" ;; 612763847c39Smrg link) 612863847c39Smrg libs="$deplibs %DEPLIBS%" 612963847c39Smrg test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" 613063847c39Smrg ;; 613163847c39Smrg esac 613263847c39Smrg fi 613363847c39Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 613463847c39Smrg # Collect and forward deplibs of preopened libtool libs 613563847c39Smrg for lib in $dlprefiles; do 613663847c39Smrg # Ignore non-libtool-libs 613763847c39Smrg dependency_libs= 613863847c39Smrg func_resolve_sysroot "$lib" 613963847c39Smrg case $lib in 614063847c39Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 614163847c39Smrg esac 614263847c39Smrg 614363847c39Smrg # Collect preopened libtool deplibs, except any this library 614463847c39Smrg # has declared as weak libs 614563847c39Smrg for deplib in $dependency_libs; do 614663847c39Smrg func_basename "$deplib" 614763847c39Smrg deplib_base=$func_basename_result 614863847c39Smrg case " $weak_libs " in 614963847c39Smrg *" $deplib_base "*) ;; 615063847c39Smrg *) func_append deplibs " $deplib" ;; 615163847c39Smrg esac 615263847c39Smrg done 615363847c39Smrg done 615463847c39Smrg libs="$dlprefiles" 615563847c39Smrg fi 615663847c39Smrg if test "$pass" = dlopen; then 615763847c39Smrg # Collect dlpreopened libraries 615863847c39Smrg save_deplibs="$deplibs" 615963847c39Smrg deplibs= 616063847c39Smrg fi 616163847c39Smrg 616263847c39Smrg for deplib in $libs; do 616363847c39Smrg lib= 616463847c39Smrg found=no 616563847c39Smrg case $deplib in 616663847c39Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 616763847c39Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 616863847c39Smrg if test "$linkmode,$pass" = "prog,link"; then 616963847c39Smrg compile_deplibs="$deplib $compile_deplibs" 617063847c39Smrg finalize_deplibs="$deplib $finalize_deplibs" 617163847c39Smrg else 617263847c39Smrg func_append compiler_flags " $deplib" 617363847c39Smrg if test "$linkmode" = lib ; then 617463847c39Smrg case "$new_inherited_linker_flags " in 617563847c39Smrg *" $deplib "*) ;; 617663847c39Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 617763847c39Smrg esac 617863847c39Smrg fi 617963847c39Smrg fi 618063847c39Smrg continue 618163847c39Smrg ;; 618263847c39Smrg -l*) 618363847c39Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 618463847c39Smrg func_warning "\`-l' is ignored for archives/objects" 618563847c39Smrg continue 618663847c39Smrg fi 618763847c39Smrg func_stripname '-l' '' "$deplib" 618863847c39Smrg name=$func_stripname_result 618963847c39Smrg if test "$linkmode" = lib; then 619063847c39Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 619163847c39Smrg else 619263847c39Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 619363847c39Smrg fi 619463847c39Smrg for searchdir in $searchdirs; do 619563847c39Smrg for search_ext in .la $std_shrext .so .a; do 619663847c39Smrg # Search the libtool library 619763847c39Smrg lib="$searchdir/lib${name}${search_ext}" 619863847c39Smrg if test -f "$lib"; then 619963847c39Smrg if test "$search_ext" = ".la"; then 620063847c39Smrg found=yes 620163847c39Smrg else 620263847c39Smrg found=no 620363847c39Smrg fi 620463847c39Smrg break 2 620563847c39Smrg fi 620663847c39Smrg done 620763847c39Smrg done 620863847c39Smrg if test "$found" != yes; then 620963847c39Smrg # deplib doesn't seem to be a libtool library 621063847c39Smrg if test "$linkmode,$pass" = "prog,link"; then 621163847c39Smrg compile_deplibs="$deplib $compile_deplibs" 621263847c39Smrg finalize_deplibs="$deplib $finalize_deplibs" 621363847c39Smrg else 621463847c39Smrg deplibs="$deplib $deplibs" 621563847c39Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 621663847c39Smrg fi 621763847c39Smrg continue 621863847c39Smrg else # deplib is a libtool library 621963847c39Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 622063847c39Smrg # We need to do some special things here, and not later. 622163847c39Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 622263847c39Smrg case " $predeps $postdeps " in 622363847c39Smrg *" $deplib "*) 622463847c39Smrg if func_lalib_p "$lib"; then 622563847c39Smrg library_names= 622663847c39Smrg old_library= 622763847c39Smrg func_source "$lib" 622863847c39Smrg for l in $old_library $library_names; do 622963847c39Smrg ll="$l" 623063847c39Smrg done 623163847c39Smrg if test "X$ll" = "X$old_library" ; then # only static version available 623263847c39Smrg found=no 623363847c39Smrg func_dirname "$lib" "" "." 623463847c39Smrg ladir="$func_dirname_result" 623563847c39Smrg lib=$ladir/$old_library 623663847c39Smrg if test "$linkmode,$pass" = "prog,link"; then 623763847c39Smrg compile_deplibs="$deplib $compile_deplibs" 623863847c39Smrg finalize_deplibs="$deplib $finalize_deplibs" 623963847c39Smrg else 624063847c39Smrg deplibs="$deplib $deplibs" 624163847c39Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 624263847c39Smrg fi 624363847c39Smrg continue 624463847c39Smrg fi 624563847c39Smrg fi 624663847c39Smrg ;; 624763847c39Smrg *) ;; 624863847c39Smrg esac 624963847c39Smrg fi 625063847c39Smrg fi 625163847c39Smrg ;; # -l 625263847c39Smrg *.ltframework) 625363847c39Smrg if test "$linkmode,$pass" = "prog,link"; then 625463847c39Smrg compile_deplibs="$deplib $compile_deplibs" 625563847c39Smrg finalize_deplibs="$deplib $finalize_deplibs" 625663847c39Smrg else 625763847c39Smrg deplibs="$deplib $deplibs" 625863847c39Smrg if test "$linkmode" = lib ; then 625963847c39Smrg case "$new_inherited_linker_flags " in 626063847c39Smrg *" $deplib "*) ;; 626163847c39Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 626263847c39Smrg esac 626363847c39Smrg fi 626463847c39Smrg fi 626563847c39Smrg continue 626663847c39Smrg ;; 626763847c39Smrg -L*) 626863847c39Smrg case $linkmode in 626963847c39Smrg lib) 627063847c39Smrg deplibs="$deplib $deplibs" 627163847c39Smrg test "$pass" = conv && continue 627263847c39Smrg newdependency_libs="$deplib $newdependency_libs" 627363847c39Smrg func_stripname '-L' '' "$deplib" 627463847c39Smrg func_resolve_sysroot "$func_stripname_result" 627563847c39Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 627663847c39Smrg ;; 627763847c39Smrg prog) 627863847c39Smrg if test "$pass" = conv; then 627963847c39Smrg deplibs="$deplib $deplibs" 628063847c39Smrg continue 628163847c39Smrg fi 628263847c39Smrg if test "$pass" = scan; then 628363847c39Smrg deplibs="$deplib $deplibs" 628463847c39Smrg else 628563847c39Smrg compile_deplibs="$deplib $compile_deplibs" 628663847c39Smrg finalize_deplibs="$deplib $finalize_deplibs" 628763847c39Smrg fi 628863847c39Smrg func_stripname '-L' '' "$deplib" 628963847c39Smrg func_resolve_sysroot "$func_stripname_result" 629063847c39Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 629163847c39Smrg ;; 629263847c39Smrg *) 629363847c39Smrg func_warning "\`-L' is ignored for archives/objects" 629463847c39Smrg ;; 629563847c39Smrg esac # linkmode 629663847c39Smrg continue 629763847c39Smrg ;; # -L 629863847c39Smrg -R*) 629963847c39Smrg if test "$pass" = link; then 630063847c39Smrg func_stripname '-R' '' "$deplib" 630163847c39Smrg func_resolve_sysroot "$func_stripname_result" 630263847c39Smrg dir=$func_resolve_sysroot_result 630363847c39Smrg # Make sure the xrpath contains only unique directories. 630463847c39Smrg case "$xrpath " in 630563847c39Smrg *" $dir "*) ;; 630663847c39Smrg *) func_append xrpath " $dir" ;; 630763847c39Smrg esac 630863847c39Smrg fi 630963847c39Smrg deplibs="$deplib $deplibs" 631063847c39Smrg continue 631163847c39Smrg ;; 631263847c39Smrg *.la) 631363847c39Smrg func_resolve_sysroot "$deplib" 631463847c39Smrg lib=$func_resolve_sysroot_result 631563847c39Smrg ;; 631663847c39Smrg *.$libext) 631763847c39Smrg if test "$pass" = conv; then 631863847c39Smrg deplibs="$deplib $deplibs" 631963847c39Smrg continue 632063847c39Smrg fi 632163847c39Smrg case $linkmode in 632263847c39Smrg lib) 632363847c39Smrg # Linking convenience modules into shared libraries is allowed, 632463847c39Smrg # but linking other static libraries is non-portable. 632563847c39Smrg case " $dlpreconveniencelibs " in 632663847c39Smrg *" $deplib "*) ;; 632763847c39Smrg *) 632863847c39Smrg valid_a_lib=no 632963847c39Smrg case $deplibs_check_method in 633063847c39Smrg match_pattern*) 633163847c39Smrg set dummy $deplibs_check_method; shift 633263847c39Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 633363847c39Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 633463847c39Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 633563847c39Smrg valid_a_lib=yes 633663847c39Smrg fi 633763847c39Smrg ;; 633863847c39Smrg pass_all) 633963847c39Smrg valid_a_lib=yes 634063847c39Smrg ;; 634163847c39Smrg esac 634263847c39Smrg if test "$valid_a_lib" != yes; then 634363847c39Smrg echo 634463847c39Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 634563847c39Smrg echo "*** I have the capability to make that library automatically link in when" 634663847c39Smrg echo "*** you link to this library. But I can only do this if you have a" 634763847c39Smrg echo "*** shared version of the library, which you do not appear to have" 634863847c39Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 634963847c39Smrg echo "*** that it is just a static archive that I should not use here." 635063847c39Smrg else 635163847c39Smrg echo 635263847c39Smrg $ECHO "*** Warning: Linking the shared library $output against the" 635363847c39Smrg $ECHO "*** static library $deplib is not portable!" 635463847c39Smrg deplibs="$deplib $deplibs" 635563847c39Smrg fi 635663847c39Smrg ;; 635763847c39Smrg esac 635863847c39Smrg continue 635963847c39Smrg ;; 636063847c39Smrg prog) 636163847c39Smrg if test "$pass" != link; then 636263847c39Smrg deplibs="$deplib $deplibs" 636363847c39Smrg else 636463847c39Smrg compile_deplibs="$deplib $compile_deplibs" 636563847c39Smrg finalize_deplibs="$deplib $finalize_deplibs" 636663847c39Smrg fi 636763847c39Smrg continue 636863847c39Smrg ;; 636963847c39Smrg esac # linkmode 637063847c39Smrg ;; # *.$libext 637163847c39Smrg *.lo | *.$objext) 637263847c39Smrg if test "$pass" = conv; then 637363847c39Smrg deplibs="$deplib $deplibs" 637463847c39Smrg elif test "$linkmode" = prog; then 637563847c39Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 637663847c39Smrg # If there is no dlopen support or we're linking statically, 637763847c39Smrg # we need to preload. 637863847c39Smrg func_append newdlprefiles " $deplib" 637963847c39Smrg compile_deplibs="$deplib $compile_deplibs" 638063847c39Smrg finalize_deplibs="$deplib $finalize_deplibs" 638163847c39Smrg else 638263847c39Smrg func_append newdlfiles " $deplib" 638363847c39Smrg fi 638463847c39Smrg fi 638563847c39Smrg continue 638663847c39Smrg ;; 638763847c39Smrg %DEPLIBS%) 638863847c39Smrg alldeplibs=yes 638963847c39Smrg continue 639063847c39Smrg ;; 639163847c39Smrg esac # case $deplib 639263847c39Smrg 639363847c39Smrg if test "$found" = yes || test -f "$lib"; then : 639463847c39Smrg else 639563847c39Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 639663847c39Smrg fi 639763847c39Smrg 639863847c39Smrg # Check to see that this really is a libtool archive. 639963847c39Smrg func_lalib_unsafe_p "$lib" \ 640063847c39Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 640163847c39Smrg 640263847c39Smrg func_dirname "$lib" "" "." 640363847c39Smrg ladir="$func_dirname_result" 640463847c39Smrg 640563847c39Smrg dlname= 640663847c39Smrg dlopen= 640763847c39Smrg dlpreopen= 640863847c39Smrg libdir= 640963847c39Smrg library_names= 641063847c39Smrg old_library= 641163847c39Smrg inherited_linker_flags= 641263847c39Smrg # If the library was installed with an old release of libtool, 641363847c39Smrg # it will not redefine variables installed, or shouldnotlink 641463847c39Smrg installed=yes 641563847c39Smrg shouldnotlink=no 641663847c39Smrg avoidtemprpath= 641763847c39Smrg 641863847c39Smrg 641963847c39Smrg # Read the .la file 642063847c39Smrg func_source "$lib" 642163847c39Smrg 642263847c39Smrg # Convert "-framework foo" to "foo.ltframework" 642363847c39Smrg if test -n "$inherited_linker_flags"; then 642463847c39Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 642563847c39Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 642663847c39Smrg case " $new_inherited_linker_flags " in 642763847c39Smrg *" $tmp_inherited_linker_flag "*) ;; 642863847c39Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 642963847c39Smrg esac 643063847c39Smrg done 643163847c39Smrg fi 643263847c39Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 643363847c39Smrg if test "$linkmode,$pass" = "lib,link" || 643463847c39Smrg test "$linkmode,$pass" = "prog,scan" || 643563847c39Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 643663847c39Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 643763847c39Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 643863847c39Smrg fi 643963847c39Smrg 644063847c39Smrg if test "$pass" = conv; then 644163847c39Smrg # Only check for convenience libraries 644263847c39Smrg deplibs="$lib $deplibs" 644363847c39Smrg if test -z "$libdir"; then 644463847c39Smrg if test -z "$old_library"; then 644563847c39Smrg func_fatal_error "cannot find name of link library for \`$lib'" 644663847c39Smrg fi 644763847c39Smrg # It is a libtool convenience library, so add in its objects. 644863847c39Smrg func_append convenience " $ladir/$objdir/$old_library" 644963847c39Smrg func_append old_convenience " $ladir/$objdir/$old_library" 645063847c39Smrg tmp_libs= 645163847c39Smrg for deplib in $dependency_libs; do 645263847c39Smrg deplibs="$deplib $deplibs" 645363847c39Smrg if $opt_preserve_dup_deps ; then 645463847c39Smrg case "$tmp_libs " in 645563847c39Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 645663847c39Smrg esac 645763847c39Smrg fi 645863847c39Smrg func_append tmp_libs " $deplib" 645963847c39Smrg done 646063847c39Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 646163847c39Smrg func_fatal_error "\`$lib' is not a convenience library" 646263847c39Smrg fi 646363847c39Smrg continue 646463847c39Smrg fi # $pass = conv 646563847c39Smrg 646663847c39Smrg 646763847c39Smrg # Get the name of the library we link against. 646863847c39Smrg linklib= 646963847c39Smrg if test -n "$old_library" && 647063847c39Smrg { test "$prefer_static_libs" = yes || 647163847c39Smrg test "$prefer_static_libs,$installed" = "built,no"; }; then 647263847c39Smrg linklib=$old_library 647363847c39Smrg else 647463847c39Smrg for l in $old_library $library_names; do 647563847c39Smrg linklib="$l" 647663847c39Smrg done 647763847c39Smrg fi 647863847c39Smrg if test -z "$linklib"; then 647963847c39Smrg func_fatal_error "cannot find name of link library for \`$lib'" 648063847c39Smrg fi 648163847c39Smrg 648263847c39Smrg # This library was specified with -dlopen. 648363847c39Smrg if test "$pass" = dlopen; then 648463847c39Smrg if test -z "$libdir"; then 648563847c39Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 648663847c39Smrg fi 648763847c39Smrg if test -z "$dlname" || 648863847c39Smrg test "$dlopen_support" != yes || 648963847c39Smrg test "$build_libtool_libs" = no; then 649063847c39Smrg # If there is no dlname, no dlopen support or we're linking 649163847c39Smrg # statically, we need to preload. We also need to preload any 649263847c39Smrg # dependent libraries so libltdl's deplib preloader doesn't 649363847c39Smrg # bomb out in the load deplibs phase. 649463847c39Smrg func_append dlprefiles " $lib $dependency_libs" 649563847c39Smrg else 649663847c39Smrg func_append newdlfiles " $lib" 649763847c39Smrg fi 649863847c39Smrg continue 649963847c39Smrg fi # $pass = dlopen 650063847c39Smrg 650163847c39Smrg # We need an absolute path. 650263847c39Smrg case $ladir in 650363847c39Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 650463847c39Smrg *) 650563847c39Smrg abs_ladir=`cd "$ladir" && pwd` 650663847c39Smrg if test -z "$abs_ladir"; then 650763847c39Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 650863847c39Smrg func_warning "passing it literally to the linker, although it might fail" 650963847c39Smrg abs_ladir="$ladir" 651063847c39Smrg fi 651163847c39Smrg ;; 651263847c39Smrg esac 651363847c39Smrg func_basename "$lib" 651463847c39Smrg laname="$func_basename_result" 651563847c39Smrg 651663847c39Smrg # Find the relevant object directory and library name. 651763847c39Smrg if test "X$installed" = Xyes; then 651863847c39Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 651963847c39Smrg func_warning "library \`$lib' was moved." 652063847c39Smrg dir="$ladir" 652163847c39Smrg absdir="$abs_ladir" 652263847c39Smrg libdir="$abs_ladir" 652363847c39Smrg else 652463847c39Smrg dir="$lt_sysroot$libdir" 652563847c39Smrg absdir="$lt_sysroot$libdir" 652663847c39Smrg fi 652763847c39Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 652863847c39Smrg else 652963847c39Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 653063847c39Smrg dir="$ladir" 653163847c39Smrg absdir="$abs_ladir" 653263847c39Smrg # Remove this search path later 653363847c39Smrg func_append notinst_path " $abs_ladir" 653463847c39Smrg else 653563847c39Smrg dir="$ladir/$objdir" 653663847c39Smrg absdir="$abs_ladir/$objdir" 653763847c39Smrg # Remove this search path later 653863847c39Smrg func_append notinst_path " $abs_ladir" 653963847c39Smrg fi 654063847c39Smrg fi # $installed = yes 654163847c39Smrg func_stripname 'lib' '.la' "$laname" 654263847c39Smrg name=$func_stripname_result 654363847c39Smrg 654463847c39Smrg # This library was specified with -dlpreopen. 654563847c39Smrg if test "$pass" = dlpreopen; then 654663847c39Smrg if test -z "$libdir" && test "$linkmode" = prog; then 654763847c39Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 654863847c39Smrg fi 654963847c39Smrg case "$host" in 655063847c39Smrg # special handling for platforms with PE-DLLs. 655163847c39Smrg *cygwin* | *mingw* | *cegcc* ) 655263847c39Smrg # Linker will automatically link against shared library if both 655363847c39Smrg # static and shared are present. Therefore, ensure we extract 655463847c39Smrg # symbols from the import library if a shared library is present 655563847c39Smrg # (otherwise, the dlopen module name will be incorrect). We do 655663847c39Smrg # this by putting the import library name into $newdlprefiles. 655763847c39Smrg # We recover the dlopen module name by 'saving' the la file 655863847c39Smrg # name in a special purpose variable, and (later) extracting the 655963847c39Smrg # dlname from the la file. 656063847c39Smrg if test -n "$dlname"; then 656163847c39Smrg func_tr_sh "$dir/$linklib" 656263847c39Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 656363847c39Smrg func_append newdlprefiles " $dir/$linklib" 656463847c39Smrg else 656563847c39Smrg func_append newdlprefiles " $dir/$old_library" 656663847c39Smrg # Keep a list of preopened convenience libraries to check 656763847c39Smrg # that they are being used correctly in the link pass. 656863847c39Smrg test -z "$libdir" && \ 656963847c39Smrg func_append dlpreconveniencelibs " $dir/$old_library" 657063847c39Smrg fi 657163847c39Smrg ;; 657263847c39Smrg * ) 657363847c39Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 657463847c39Smrg # are required to link). 657563847c39Smrg if test -n "$old_library"; then 657663847c39Smrg func_append newdlprefiles " $dir/$old_library" 657763847c39Smrg # Keep a list of preopened convenience libraries to check 657863847c39Smrg # that they are being used correctly in the link pass. 657963847c39Smrg test -z "$libdir" && \ 658063847c39Smrg func_append dlpreconveniencelibs " $dir/$old_library" 658163847c39Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 658263847c39Smrg elif test -n "$dlname"; then 658363847c39Smrg func_append newdlprefiles " $dir/$dlname" 658463847c39Smrg else 658563847c39Smrg func_append newdlprefiles " $dir/$linklib" 658663847c39Smrg fi 658763847c39Smrg ;; 658863847c39Smrg esac 658963847c39Smrg fi # $pass = dlpreopen 659063847c39Smrg 659163847c39Smrg if test -z "$libdir"; then 659263847c39Smrg # Link the convenience library 659363847c39Smrg if test "$linkmode" = lib; then 659463847c39Smrg deplibs="$dir/$old_library $deplibs" 659563847c39Smrg elif test "$linkmode,$pass" = "prog,link"; then 659663847c39Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 659763847c39Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 659863847c39Smrg else 659963847c39Smrg deplibs="$lib $deplibs" # used for prog,scan pass 660063847c39Smrg fi 660163847c39Smrg continue 660263847c39Smrg fi 660363847c39Smrg 660463847c39Smrg 660563847c39Smrg if test "$linkmode" = prog && test "$pass" != link; then 660663847c39Smrg func_append newlib_search_path " $ladir" 660763847c39Smrg deplibs="$lib $deplibs" 660863847c39Smrg 660963847c39Smrg linkalldeplibs=no 661063847c39Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 661163847c39Smrg test "$build_libtool_libs" = no; then 661263847c39Smrg linkalldeplibs=yes 661363847c39Smrg fi 661463847c39Smrg 661563847c39Smrg tmp_libs= 661663847c39Smrg for deplib in $dependency_libs; do 661763847c39Smrg case $deplib in 661863847c39Smrg -L*) func_stripname '-L' '' "$deplib" 661963847c39Smrg func_resolve_sysroot "$func_stripname_result" 662063847c39Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 662163847c39Smrg ;; 662263847c39Smrg esac 662363847c39Smrg # Need to link against all dependency_libs? 662463847c39Smrg if test "$linkalldeplibs" = yes; then 662563847c39Smrg deplibs="$deplib $deplibs" 662663847c39Smrg else 662763847c39Smrg # Need to hardcode shared library paths 662863847c39Smrg # or/and link against static libraries 662963847c39Smrg newdependency_libs="$deplib $newdependency_libs" 663063847c39Smrg fi 663163847c39Smrg if $opt_preserve_dup_deps ; then 663263847c39Smrg case "$tmp_libs " in 663363847c39Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 663463847c39Smrg esac 663563847c39Smrg fi 663663847c39Smrg func_append tmp_libs " $deplib" 663763847c39Smrg done # for deplib 663863847c39Smrg continue 663963847c39Smrg fi # $linkmode = prog... 664063847c39Smrg 664163847c39Smrg if test "$linkmode,$pass" = "prog,link"; then 664263847c39Smrg if test -n "$library_names" && 664363847c39Smrg { { test "$prefer_static_libs" = no || 664463847c39Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 664563847c39Smrg test -z "$old_library"; }; then 664663847c39Smrg # We need to hardcode the library path 664763847c39Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 664863847c39Smrg # Make sure the rpath contains only unique directories. 664963847c39Smrg case "$temp_rpath:" in 665063847c39Smrg *"$absdir:"*) ;; 665163847c39Smrg *) func_append temp_rpath "$absdir:" ;; 665263847c39Smrg esac 665363847c39Smrg fi 665463847c39Smrg 665563847c39Smrg # Hardcode the library path. 665663847c39Smrg # Skip directories that are in the system default run-time 665763847c39Smrg # search path. 665863847c39Smrg case " $sys_lib_dlsearch_path " in 665963847c39Smrg *" $absdir "*) ;; 666063847c39Smrg *) 666163847c39Smrg case "$compile_rpath " in 666263847c39Smrg *" $absdir "*) ;; 666363847c39Smrg *) func_append compile_rpath " $absdir" ;; 666463847c39Smrg esac 666563847c39Smrg ;; 666663847c39Smrg esac 666763847c39Smrg case " $sys_lib_dlsearch_path " in 666863847c39Smrg *" $libdir "*) ;; 666963847c39Smrg *) 667063847c39Smrg case "$finalize_rpath " in 667163847c39Smrg *" $libdir "*) ;; 667263847c39Smrg *) func_append finalize_rpath " $libdir" ;; 667363847c39Smrg esac 667463847c39Smrg ;; 667563847c39Smrg esac 667663847c39Smrg fi # $linkmode,$pass = prog,link... 667763847c39Smrg 667863847c39Smrg if test "$alldeplibs" = yes && 667963847c39Smrg { test "$deplibs_check_method" = pass_all || 668063847c39Smrg { test "$build_libtool_libs" = yes && 668163847c39Smrg test -n "$library_names"; }; }; then 668263847c39Smrg # We only need to search for static libraries 668363847c39Smrg continue 668463847c39Smrg fi 668563847c39Smrg fi 668663847c39Smrg 668763847c39Smrg link_static=no # Whether the deplib will be linked statically 668863847c39Smrg use_static_libs=$prefer_static_libs 668963847c39Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 669063847c39Smrg use_static_libs=no 669163847c39Smrg fi 669263847c39Smrg if test -n "$library_names" && 669363847c39Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 669463847c39Smrg case $host in 669563847c39Smrg *cygwin* | *mingw* | *cegcc*) 669663847c39Smrg # No point in relinking DLLs because paths are not encoded 669763847c39Smrg func_append notinst_deplibs " $lib" 669863847c39Smrg need_relink=no 669963847c39Smrg ;; 670063847c39Smrg *) 670163847c39Smrg if test "$installed" = no; then 670263847c39Smrg func_append notinst_deplibs " $lib" 670363847c39Smrg need_relink=yes 670463847c39Smrg fi 670563847c39Smrg ;; 670663847c39Smrg esac 670763847c39Smrg # This is a shared library 670863847c39Smrg 670963847c39Smrg # Warn about portability, can't link against -module's on some 671063847c39Smrg # systems (darwin). Don't bleat about dlopened modules though! 671163847c39Smrg dlopenmodule="" 671263847c39Smrg for dlpremoduletest in $dlprefiles; do 671363847c39Smrg if test "X$dlpremoduletest" = "X$lib"; then 671463847c39Smrg dlopenmodule="$dlpremoduletest" 671563847c39Smrg break 671663847c39Smrg fi 671763847c39Smrg done 671863847c39Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 671963847c39Smrg echo 672063847c39Smrg if test "$linkmode" = prog; then 672163847c39Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 672263847c39Smrg else 672363847c39Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 672463847c39Smrg fi 672563847c39Smrg $ECHO "*** $linklib is not portable!" 672663847c39Smrg fi 672763847c39Smrg if test "$linkmode" = lib && 672863847c39Smrg test "$hardcode_into_libs" = yes; then 672963847c39Smrg # Hardcode the library path. 673063847c39Smrg # Skip directories that are in the system default run-time 673163847c39Smrg # search path. 673263847c39Smrg case " $sys_lib_dlsearch_path " in 673363847c39Smrg *" $absdir "*) ;; 673463847c39Smrg *) 673563847c39Smrg case "$compile_rpath " in 673663847c39Smrg *" $absdir "*) ;; 673763847c39Smrg *) func_append compile_rpath " $absdir" ;; 673863847c39Smrg esac 673963847c39Smrg ;; 674063847c39Smrg esac 674163847c39Smrg case " $sys_lib_dlsearch_path " in 674263847c39Smrg *" $libdir "*) ;; 674363847c39Smrg *) 674463847c39Smrg case "$finalize_rpath " in 674563847c39Smrg *" $libdir "*) ;; 674663847c39Smrg *) func_append finalize_rpath " $libdir" ;; 674763847c39Smrg esac 674863847c39Smrg ;; 674963847c39Smrg esac 675063847c39Smrg fi 675163847c39Smrg 675263847c39Smrg if test -n "$old_archive_from_expsyms_cmds"; then 675363847c39Smrg # figure out the soname 675463847c39Smrg set dummy $library_names 675563847c39Smrg shift 675663847c39Smrg realname="$1" 675763847c39Smrg shift 675863847c39Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 675963847c39Smrg # use dlname if we got it. it's perfectly good, no? 676063847c39Smrg if test -n "$dlname"; then 676163847c39Smrg soname="$dlname" 676263847c39Smrg elif test -n "$soname_spec"; then 676363847c39Smrg # bleh windows 676463847c39Smrg case $host in 676563847c39Smrg *cygwin* | mingw* | *cegcc*) 676663847c39Smrg func_arith $current - $age 676763847c39Smrg major=$func_arith_result 676863847c39Smrg versuffix="-$major" 676963847c39Smrg ;; 677063847c39Smrg esac 677163847c39Smrg eval soname=\"$soname_spec\" 677263847c39Smrg else 677363847c39Smrg soname="$realname" 677463847c39Smrg fi 677563847c39Smrg 677663847c39Smrg # Make a new name for the extract_expsyms_cmds to use 677763847c39Smrg soroot="$soname" 677863847c39Smrg func_basename "$soroot" 677963847c39Smrg soname="$func_basename_result" 678063847c39Smrg func_stripname 'lib' '.dll' "$soname" 678163847c39Smrg newlib=libimp-$func_stripname_result.a 678263847c39Smrg 678363847c39Smrg # If the library has no export list, then create one now 678463847c39Smrg if test -f "$output_objdir/$soname-def"; then : 678563847c39Smrg else 678663847c39Smrg func_verbose "extracting exported symbol list from \`$soname'" 678763847c39Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 678863847c39Smrg fi 678963847c39Smrg 679063847c39Smrg # Create $newlib 679163847c39Smrg if test -f "$output_objdir/$newlib"; then :; else 679263847c39Smrg func_verbose "generating import library for \`$soname'" 679363847c39Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 679463847c39Smrg fi 679563847c39Smrg # make sure the library variables are pointing to the new library 679663847c39Smrg dir=$output_objdir 679763847c39Smrg linklib=$newlib 679863847c39Smrg fi # test -n "$old_archive_from_expsyms_cmds" 679963847c39Smrg 680063847c39Smrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 680163847c39Smrg add_shlibpath= 680263847c39Smrg add_dir= 680363847c39Smrg add= 680463847c39Smrg lib_linked=yes 680563847c39Smrg case $hardcode_action in 680663847c39Smrg immediate | unsupported) 680763847c39Smrg if test "$hardcode_direct" = no; then 680863847c39Smrg add="$dir/$linklib" 680963847c39Smrg case $host in 681063847c39Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 681163847c39Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 681263847c39Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 681363847c39Smrg *-*-unixware7*) add_dir="-L$dir" ;; 681463847c39Smrg *-*-darwin* ) 681563847c39Smrg # if the lib is a (non-dlopened) module then we can not 681663847c39Smrg # link against it, someone is ignoring the earlier warnings 681763847c39Smrg if /usr/bin/file -L $add 2> /dev/null | 681863847c39Smrg $GREP ": [^:]* bundle" >/dev/null ; then 681963847c39Smrg if test "X$dlopenmodule" != "X$lib"; then 682063847c39Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 682163847c39Smrg if test -z "$old_library" ; then 682263847c39Smrg echo 682363847c39Smrg echo "*** And there doesn't seem to be a static archive available" 682463847c39Smrg echo "*** The link will probably fail, sorry" 682563847c39Smrg else 682663847c39Smrg add="$dir/$old_library" 682763847c39Smrg fi 682863847c39Smrg elif test -n "$old_library"; then 682963847c39Smrg add="$dir/$old_library" 683063847c39Smrg fi 683163847c39Smrg fi 683263847c39Smrg esac 683363847c39Smrg elif test "$hardcode_minus_L" = no; then 683463847c39Smrg case $host in 683563847c39Smrg *-*-sunos*) add_shlibpath="$dir" ;; 683663847c39Smrg esac 683763847c39Smrg add_dir="-L$dir" 683863847c39Smrg add="-l$name" 683963847c39Smrg elif test "$hardcode_shlibpath_var" = no; then 684063847c39Smrg add_shlibpath="$dir" 684163847c39Smrg add="-l$name" 684263847c39Smrg else 684363847c39Smrg lib_linked=no 684463847c39Smrg fi 684563847c39Smrg ;; 684663847c39Smrg relink) 684763847c39Smrg if test "$hardcode_direct" = yes && 684863847c39Smrg test "$hardcode_direct_absolute" = no; then 684963847c39Smrg add="$dir/$linklib" 685063847c39Smrg elif test "$hardcode_minus_L" = yes; then 685163847c39Smrg add_dir="-L$absdir" 685263847c39Smrg # Try looking first in the location we're being installed to. 685363847c39Smrg if test -n "$inst_prefix_dir"; then 685463847c39Smrg case $libdir in 685563847c39Smrg [\\/]*) 685663847c39Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 685763847c39Smrg ;; 685863847c39Smrg esac 685963847c39Smrg fi 686063847c39Smrg add="-l$name" 686163847c39Smrg elif test "$hardcode_shlibpath_var" = yes; then 686263847c39Smrg add_shlibpath="$dir" 686363847c39Smrg add="-l$name" 686463847c39Smrg else 686563847c39Smrg lib_linked=no 686663847c39Smrg fi 686763847c39Smrg ;; 686863847c39Smrg *) lib_linked=no ;; 686963847c39Smrg esac 687063847c39Smrg 687163847c39Smrg if test "$lib_linked" != yes; then 687263847c39Smrg func_fatal_configuration "unsupported hardcode properties" 687363847c39Smrg fi 687463847c39Smrg 687563847c39Smrg if test -n "$add_shlibpath"; then 687663847c39Smrg case :$compile_shlibpath: in 687763847c39Smrg *":$add_shlibpath:"*) ;; 687863847c39Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 687963847c39Smrg esac 688063847c39Smrg fi 688163847c39Smrg if test "$linkmode" = prog; then 688263847c39Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 688363847c39Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 688463847c39Smrg else 688563847c39Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 688663847c39Smrg test -n "$add" && deplibs="$add $deplibs" 688763847c39Smrg if test "$hardcode_direct" != yes && 688863847c39Smrg test "$hardcode_minus_L" != yes && 688963847c39Smrg test "$hardcode_shlibpath_var" = yes; then 689063847c39Smrg case :$finalize_shlibpath: in 689163847c39Smrg *":$libdir:"*) ;; 689263847c39Smrg *) func_append finalize_shlibpath "$libdir:" ;; 689363847c39Smrg esac 689463847c39Smrg fi 689563847c39Smrg fi 689663847c39Smrg fi 689763847c39Smrg 689863847c39Smrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 689963847c39Smrg add_shlibpath= 690063847c39Smrg add_dir= 690163847c39Smrg add= 690263847c39Smrg # Finalize command for both is simple: just hardcode it. 690363847c39Smrg if test "$hardcode_direct" = yes && 690463847c39Smrg test "$hardcode_direct_absolute" = no; then 690563847c39Smrg add="$libdir/$linklib" 690663847c39Smrg elif test "$hardcode_minus_L" = yes; then 690763847c39Smrg add_dir="-L$libdir" 690863847c39Smrg add="-l$name" 690963847c39Smrg elif test "$hardcode_shlibpath_var" = yes; then 691063847c39Smrg case :$finalize_shlibpath: in 691163847c39Smrg *":$libdir:"*) ;; 691263847c39Smrg *) func_append finalize_shlibpath "$libdir:" ;; 691363847c39Smrg esac 691463847c39Smrg add="-l$name" 691563847c39Smrg elif test "$hardcode_automatic" = yes; then 691663847c39Smrg if test -n "$inst_prefix_dir" && 691763847c39Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 691863847c39Smrg add="$inst_prefix_dir$libdir/$linklib" 691963847c39Smrg else 692063847c39Smrg add="$libdir/$linklib" 692163847c39Smrg fi 692263847c39Smrg else 692363847c39Smrg # We cannot seem to hardcode it, guess we'll fake it. 692463847c39Smrg add_dir="-L$libdir" 692563847c39Smrg # Try looking first in the location we're being installed to. 692663847c39Smrg if test -n "$inst_prefix_dir"; then 692763847c39Smrg case $libdir in 692863847c39Smrg [\\/]*) 692963847c39Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 693063847c39Smrg ;; 693163847c39Smrg esac 693263847c39Smrg fi 693363847c39Smrg add="-l$name" 693463847c39Smrg fi 693563847c39Smrg 693663847c39Smrg if test "$linkmode" = prog; then 693763847c39Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 693863847c39Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 693963847c39Smrg else 694063847c39Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 694163847c39Smrg test -n "$add" && deplibs="$add $deplibs" 694263847c39Smrg fi 694363847c39Smrg fi 694463847c39Smrg elif test "$linkmode" = prog; then 694563847c39Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 694663847c39Smrg # is not unsupported. This is valid on all known static and 694763847c39Smrg # shared platforms. 694863847c39Smrg if test "$hardcode_direct" != unsupported; then 694963847c39Smrg test -n "$old_library" && linklib="$old_library" 695063847c39Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 695163847c39Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 695263847c39Smrg else 695363847c39Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 695463847c39Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 695563847c39Smrg fi 695663847c39Smrg elif test "$build_libtool_libs" = yes; then 695763847c39Smrg # Not a shared library 695863847c39Smrg if test "$deplibs_check_method" != pass_all; then 695963847c39Smrg # We're trying link a shared library against a static one 696063847c39Smrg # but the system doesn't support it. 696163847c39Smrg 696263847c39Smrg # Just print a warning and add the library to dependency_libs so 696363847c39Smrg # that the program can be linked against the static library. 696463847c39Smrg echo 696563847c39Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 696663847c39Smrg echo "*** I have the capability to make that library automatically link in when" 696763847c39Smrg echo "*** you link to this library. But I can only do this if you have a" 696863847c39Smrg echo "*** shared version of the library, which you do not appear to have." 696963847c39Smrg if test "$module" = yes; then 697063847c39Smrg echo "*** But as you try to build a module library, libtool will still create " 697163847c39Smrg echo "*** a static module, that should work as long as the dlopening application" 697263847c39Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 697363847c39Smrg if test -z "$global_symbol_pipe"; then 697463847c39Smrg echo 697563847c39Smrg echo "*** However, this would only work if libtool was able to extract symbol" 697663847c39Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 697763847c39Smrg echo "*** not find such a program. So, this module is probably useless." 697863847c39Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 697963847c39Smrg fi 698063847c39Smrg if test "$build_old_libs" = no; then 698163847c39Smrg build_libtool_libs=module 698263847c39Smrg build_old_libs=yes 698363847c39Smrg else 698463847c39Smrg build_libtool_libs=no 698563847c39Smrg fi 698663847c39Smrg fi 698763847c39Smrg else 698863847c39Smrg deplibs="$dir/$old_library $deplibs" 698963847c39Smrg link_static=yes 699063847c39Smrg fi 699163847c39Smrg fi # link shared/static library? 699263847c39Smrg 699363847c39Smrg if test "$linkmode" = lib; then 699463847c39Smrg if test -n "$dependency_libs" && 699563847c39Smrg { test "$hardcode_into_libs" != yes || 699663847c39Smrg test "$build_old_libs" = yes || 699763847c39Smrg test "$link_static" = yes; }; then 699863847c39Smrg # Extract -R from dependency_libs 699963847c39Smrg temp_deplibs= 700063847c39Smrg for libdir in $dependency_libs; do 700163847c39Smrg case $libdir in 700263847c39Smrg -R*) func_stripname '-R' '' "$libdir" 700363847c39Smrg temp_xrpath=$func_stripname_result 700463847c39Smrg case " $xrpath " in 700563847c39Smrg *" $temp_xrpath "*) ;; 700663847c39Smrg *) func_append xrpath " $temp_xrpath";; 700763847c39Smrg esac;; 700863847c39Smrg *) func_append temp_deplibs " $libdir";; 700963847c39Smrg esac 701063847c39Smrg done 701163847c39Smrg dependency_libs="$temp_deplibs" 701263847c39Smrg fi 701363847c39Smrg 701463847c39Smrg func_append newlib_search_path " $absdir" 701563847c39Smrg # Link against this library 701663847c39Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 701763847c39Smrg # ... and its dependency_libs 701863847c39Smrg tmp_libs= 701963847c39Smrg for deplib in $dependency_libs; do 702063847c39Smrg newdependency_libs="$deplib $newdependency_libs" 702163847c39Smrg case $deplib in 702263847c39Smrg -L*) func_stripname '-L' '' "$deplib" 702363847c39Smrg func_resolve_sysroot "$func_stripname_result";; 702463847c39Smrg *) func_resolve_sysroot "$deplib" ;; 702563847c39Smrg esac 702663847c39Smrg if $opt_preserve_dup_deps ; then 702763847c39Smrg case "$tmp_libs " in 702863847c39Smrg *" $func_resolve_sysroot_result "*) 702963847c39Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 703063847c39Smrg esac 703163847c39Smrg fi 703263847c39Smrg func_append tmp_libs " $func_resolve_sysroot_result" 703363847c39Smrg done 703463847c39Smrg 703563847c39Smrg if test "$link_all_deplibs" != no; then 703663847c39Smrg # Add the search paths of all dependency libraries 703763847c39Smrg for deplib in $dependency_libs; do 703863847c39Smrg path= 703963847c39Smrg case $deplib in 704063847c39Smrg -L*) path="$deplib" ;; 704163847c39Smrg *.la) 704263847c39Smrg func_resolve_sysroot "$deplib" 704363847c39Smrg deplib=$func_resolve_sysroot_result 704463847c39Smrg func_dirname "$deplib" "" "." 704563847c39Smrg dir=$func_dirname_result 704663847c39Smrg # We need an absolute path. 704763847c39Smrg case $dir in 704863847c39Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 704963847c39Smrg *) 705063847c39Smrg absdir=`cd "$dir" && pwd` 705163847c39Smrg if test -z "$absdir"; then 705263847c39Smrg func_warning "cannot determine absolute directory name of \`$dir'" 705363847c39Smrg absdir="$dir" 705463847c39Smrg fi 705563847c39Smrg ;; 705663847c39Smrg esac 705763847c39Smrg if $GREP "^installed=no" $deplib > /dev/null; then 705863847c39Smrg case $host in 705963847c39Smrg *-*-darwin*) 706063847c39Smrg depdepl= 706163847c39Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 706263847c39Smrg if test -n "$deplibrary_names" ; then 706363847c39Smrg for tmp in $deplibrary_names ; do 706463847c39Smrg depdepl=$tmp 706563847c39Smrg done 706663847c39Smrg if test -f "$absdir/$objdir/$depdepl" ; then 706763847c39Smrg depdepl="$absdir/$objdir/$depdepl" 706863847c39Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 706963847c39Smrg if test -z "$darwin_install_name"; then 707063847c39Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 707163847c39Smrg fi 707263847c39Smrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 707363847c39Smrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 707463847c39Smrg path= 707563847c39Smrg fi 707663847c39Smrg fi 707763847c39Smrg ;; 707863847c39Smrg *) 707963847c39Smrg path="-L$absdir/$objdir" 708063847c39Smrg ;; 708163847c39Smrg esac 708263847c39Smrg else 708363847c39Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 708463847c39Smrg test -z "$libdir" && \ 708563847c39Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 708663847c39Smrg test "$absdir" != "$libdir" && \ 708763847c39Smrg func_warning "\`$deplib' seems to be moved" 708863847c39Smrg 708963847c39Smrg path="-L$absdir" 709063847c39Smrg fi 709163847c39Smrg ;; 709263847c39Smrg esac 709363847c39Smrg case " $deplibs " in 709463847c39Smrg *" $path "*) ;; 709563847c39Smrg *) deplibs="$path $deplibs" ;; 709663847c39Smrg esac 709763847c39Smrg done 709863847c39Smrg fi # link_all_deplibs != no 709963847c39Smrg fi # linkmode = lib 710063847c39Smrg done # for deplib in $libs 710163847c39Smrg if test "$pass" = link; then 710263847c39Smrg if test "$linkmode" = "prog"; then 710363847c39Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 710463847c39Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 710563847c39Smrg else 710663847c39Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 710763847c39Smrg fi 710863847c39Smrg fi 710963847c39Smrg dependency_libs="$newdependency_libs" 711063847c39Smrg if test "$pass" = dlpreopen; then 711163847c39Smrg # Link the dlpreopened libraries before other libraries 711263847c39Smrg for deplib in $save_deplibs; do 711363847c39Smrg deplibs="$deplib $deplibs" 711463847c39Smrg done 711563847c39Smrg fi 711663847c39Smrg if test "$pass" != dlopen; then 711763847c39Smrg if test "$pass" != conv; then 711863847c39Smrg # Make sure lib_search_path contains only unique directories. 711963847c39Smrg lib_search_path= 712063847c39Smrg for dir in $newlib_search_path; do 712163847c39Smrg case "$lib_search_path " in 712263847c39Smrg *" $dir "*) ;; 712363847c39Smrg *) func_append lib_search_path " $dir" ;; 712463847c39Smrg esac 712563847c39Smrg done 712663847c39Smrg newlib_search_path= 712763847c39Smrg fi 712863847c39Smrg 712963847c39Smrg if test "$linkmode,$pass" != "prog,link"; then 713063847c39Smrg vars="deplibs" 713163847c39Smrg else 713263847c39Smrg vars="compile_deplibs finalize_deplibs" 713363847c39Smrg fi 713463847c39Smrg for var in $vars dependency_libs; do 713563847c39Smrg # Add libraries to $var in reverse order 713663847c39Smrg eval tmp_libs=\"\$$var\" 713763847c39Smrg new_libs= 713863847c39Smrg for deplib in $tmp_libs; do 713963847c39Smrg # FIXME: Pedantically, this is the right thing to do, so 714063847c39Smrg # that some nasty dependency loop isn't accidentally 714163847c39Smrg # broken: 714263847c39Smrg #new_libs="$deplib $new_libs" 714363847c39Smrg # Pragmatically, this seems to cause very few problems in 714463847c39Smrg # practice: 714563847c39Smrg case $deplib in 714663847c39Smrg -L*) new_libs="$deplib $new_libs" ;; 714763847c39Smrg -R*) ;; 714863847c39Smrg *) 714963847c39Smrg # And here is the reason: when a library appears more 715063847c39Smrg # than once as an explicit dependence of a library, or 715163847c39Smrg # is implicitly linked in more than once by the 715263847c39Smrg # compiler, it is considered special, and multiple 715363847c39Smrg # occurrences thereof are not removed. Compare this 715463847c39Smrg # with having the same library being listed as a 715563847c39Smrg # dependency of multiple other libraries: in this case, 715663847c39Smrg # we know (pedantically, we assume) the library does not 715763847c39Smrg # need to be listed more than once, so we keep only the 715863847c39Smrg # last copy. This is not always right, but it is rare 715963847c39Smrg # enough that we require users that really mean to play 716063847c39Smrg # such unportable linking tricks to link the library 716163847c39Smrg # using -Wl,-lname, so that libtool does not consider it 716263847c39Smrg # for duplicate removal. 716363847c39Smrg case " $specialdeplibs " in 716463847c39Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 716563847c39Smrg *) 716663847c39Smrg case " $new_libs " in 716763847c39Smrg *" $deplib "*) ;; 716863847c39Smrg *) new_libs="$deplib $new_libs" ;; 716963847c39Smrg esac 717063847c39Smrg ;; 717163847c39Smrg esac 717263847c39Smrg ;; 717363847c39Smrg esac 717463847c39Smrg done 717563847c39Smrg tmp_libs= 717663847c39Smrg for deplib in $new_libs; do 717763847c39Smrg case $deplib in 717863847c39Smrg -L*) 717963847c39Smrg case " $tmp_libs " in 718063847c39Smrg *" $deplib "*) ;; 718163847c39Smrg *) func_append tmp_libs " $deplib" ;; 718263847c39Smrg esac 718363847c39Smrg ;; 718463847c39Smrg *) func_append tmp_libs " $deplib" ;; 718563847c39Smrg esac 718663847c39Smrg done 718763847c39Smrg eval $var=\"$tmp_libs\" 718863847c39Smrg done # for var 718963847c39Smrg fi 719063847c39Smrg # Last step: remove runtime libs from dependency_libs 719163847c39Smrg # (they stay in deplibs) 719263847c39Smrg tmp_libs= 719363847c39Smrg for i in $dependency_libs ; do 719463847c39Smrg case " $predeps $postdeps $compiler_lib_search_path " in 719563847c39Smrg *" $i "*) 719663847c39Smrg i="" 719763847c39Smrg ;; 719863847c39Smrg esac 719963847c39Smrg if test -n "$i" ; then 720063847c39Smrg func_append tmp_libs " $i" 720163847c39Smrg fi 720263847c39Smrg done 720363847c39Smrg dependency_libs=$tmp_libs 720463847c39Smrg done # for pass 720563847c39Smrg if test "$linkmode" = prog; then 720663847c39Smrg dlfiles="$newdlfiles" 720763847c39Smrg fi 720863847c39Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 720963847c39Smrg dlprefiles="$newdlprefiles" 721063847c39Smrg fi 721163847c39Smrg 721263847c39Smrg case $linkmode in 721363847c39Smrg oldlib) 721463847c39Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 721563847c39Smrg func_warning "\`-dlopen' is ignored for archives" 721663847c39Smrg fi 721763847c39Smrg 721863847c39Smrg case " $deplibs" in 721963847c39Smrg *\ -l* | *\ -L*) 722063847c39Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 722163847c39Smrg esac 722263847c39Smrg 722363847c39Smrg test -n "$rpath" && \ 722463847c39Smrg func_warning "\`-rpath' is ignored for archives" 722563847c39Smrg 722663847c39Smrg test -n "$xrpath" && \ 722763847c39Smrg func_warning "\`-R' is ignored for archives" 722863847c39Smrg 722963847c39Smrg test -n "$vinfo" && \ 723063847c39Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 723163847c39Smrg 723263847c39Smrg test -n "$release" && \ 723363847c39Smrg func_warning "\`-release' is ignored for archives" 723463847c39Smrg 723563847c39Smrg test -n "$export_symbols$export_symbols_regex" && \ 723663847c39Smrg func_warning "\`-export-symbols' is ignored for archives" 723763847c39Smrg 723863847c39Smrg # Now set the variables for building old libraries. 723963847c39Smrg build_libtool_libs=no 724063847c39Smrg oldlibs="$output" 724163847c39Smrg func_append objs "$old_deplibs" 724263847c39Smrg ;; 724363847c39Smrg 724463847c39Smrg lib) 724563847c39Smrg # Make sure we only generate libraries of the form `libNAME.la'. 724663847c39Smrg case $outputname in 724763847c39Smrg lib*) 724863847c39Smrg func_stripname 'lib' '.la' "$outputname" 724963847c39Smrg name=$func_stripname_result 725063847c39Smrg eval shared_ext=\"$shrext_cmds\" 725163847c39Smrg eval libname=\"$libname_spec\" 725263847c39Smrg ;; 725363847c39Smrg *) 725463847c39Smrg test "$module" = no && \ 725563847c39Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 725663847c39Smrg 725763847c39Smrg if test "$need_lib_prefix" != no; then 725863847c39Smrg # Add the "lib" prefix for modules if required 725963847c39Smrg func_stripname '' '.la' "$outputname" 726063847c39Smrg name=$func_stripname_result 726163847c39Smrg eval shared_ext=\"$shrext_cmds\" 726263847c39Smrg eval libname=\"$libname_spec\" 726363847c39Smrg else 726463847c39Smrg func_stripname '' '.la' "$outputname" 726563847c39Smrg libname=$func_stripname_result 726663847c39Smrg fi 726763847c39Smrg ;; 726863847c39Smrg esac 726963847c39Smrg 727063847c39Smrg if test -n "$objs"; then 727163847c39Smrg if test "$deplibs_check_method" != pass_all; then 727263847c39Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 727363847c39Smrg else 727463847c39Smrg echo 727563847c39Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 727663847c39Smrg $ECHO "*** objects $objs is not portable!" 727763847c39Smrg func_append libobjs " $objs" 727863847c39Smrg fi 727963847c39Smrg fi 728063847c39Smrg 728163847c39Smrg test "$dlself" != no && \ 728263847c39Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 728363847c39Smrg 728463847c39Smrg set dummy $rpath 728563847c39Smrg shift 728663847c39Smrg test "$#" -gt 1 && \ 728763847c39Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 728863847c39Smrg 728963847c39Smrg install_libdir="$1" 729063847c39Smrg 729163847c39Smrg oldlibs= 729263847c39Smrg if test -z "$rpath"; then 729363847c39Smrg if test "$build_libtool_libs" = yes; then 729463847c39Smrg # Building a libtool convenience library. 729563847c39Smrg # Some compilers have problems with a `.al' extension so 729663847c39Smrg # convenience libraries should have the same extension an 729763847c39Smrg # archive normally would. 729863847c39Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 729963847c39Smrg build_libtool_libs=convenience 730063847c39Smrg build_old_libs=yes 730163847c39Smrg fi 730263847c39Smrg 730363847c39Smrg test -n "$vinfo" && \ 730463847c39Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 730563847c39Smrg 730663847c39Smrg test -n "$release" && \ 730763847c39Smrg func_warning "\`-release' is ignored for convenience libraries" 730863847c39Smrg else 730963847c39Smrg 731063847c39Smrg # Parse the version information argument. 731163847c39Smrg save_ifs="$IFS"; IFS=':' 731263847c39Smrg set dummy $vinfo 0 0 0 731363847c39Smrg shift 731463847c39Smrg IFS="$save_ifs" 731563847c39Smrg 731663847c39Smrg test -n "$7" && \ 731763847c39Smrg func_fatal_help "too many parameters to \`-version-info'" 731863847c39Smrg 731963847c39Smrg # convert absolute version numbers to libtool ages 732063847c39Smrg # this retains compatibility with .la files and attempts 732163847c39Smrg # to make the code below a bit more comprehensible 732263847c39Smrg 732363847c39Smrg case $vinfo_number in 732463847c39Smrg yes) 732563847c39Smrg number_major="$1" 732663847c39Smrg number_minor="$2" 732763847c39Smrg number_revision="$3" 732863847c39Smrg # 732963847c39Smrg # There are really only two kinds -- those that 733063847c39Smrg # use the current revision as the major version 733163847c39Smrg # and those that subtract age and use age as 733263847c39Smrg # a minor version. But, then there is irix 733363847c39Smrg # which has an extra 1 added just for fun 733463847c39Smrg # 733563847c39Smrg case $version_type in 733663847c39Smrg # correct linux to gnu/linux during the next big refactor 733763847c39Smrg darwin|linux|osf|windows|none) 733863847c39Smrg func_arith $number_major + $number_minor 733963847c39Smrg current=$func_arith_result 734063847c39Smrg age="$number_minor" 734163847c39Smrg revision="$number_revision" 734263847c39Smrg ;; 734363847c39Smrg freebsd-aout|freebsd-elf|qnx|sunos) 734463847c39Smrg current="$number_major" 734563847c39Smrg revision="$number_minor" 734663847c39Smrg age="0" 734763847c39Smrg ;; 734863847c39Smrg irix|nonstopux) 734963847c39Smrg func_arith $number_major + $number_minor 735063847c39Smrg current=$func_arith_result 735163847c39Smrg age="$number_minor" 735263847c39Smrg revision="$number_minor" 735363847c39Smrg lt_irix_increment=no 735463847c39Smrg ;; 735563847c39Smrg *) 735663847c39Smrg func_fatal_configuration "$modename: unknown library version type \`$version_type'" 735763847c39Smrg ;; 735863847c39Smrg esac 735963847c39Smrg ;; 736063847c39Smrg no) 736163847c39Smrg current="$1" 736263847c39Smrg revision="$2" 736363847c39Smrg age="$3" 736463847c39Smrg ;; 736563847c39Smrg esac 736663847c39Smrg 736763847c39Smrg # Check that each of the things are valid numbers. 736863847c39Smrg case $current in 736963847c39Smrg 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]) ;; 737063847c39Smrg *) 737163847c39Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 737263847c39Smrg func_fatal_error "\`$vinfo' is not valid version information" 737363847c39Smrg ;; 737463847c39Smrg esac 737563847c39Smrg 737663847c39Smrg case $revision in 737763847c39Smrg 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]) ;; 737863847c39Smrg *) 737963847c39Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 738063847c39Smrg func_fatal_error "\`$vinfo' is not valid version information" 738163847c39Smrg ;; 738263847c39Smrg esac 738363847c39Smrg 738463847c39Smrg case $age in 738563847c39Smrg 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]) ;; 738663847c39Smrg *) 738763847c39Smrg func_error "AGE \`$age' must be a nonnegative integer" 738863847c39Smrg func_fatal_error "\`$vinfo' is not valid version information" 738963847c39Smrg ;; 739063847c39Smrg esac 739163847c39Smrg 739263847c39Smrg if test "$age" -gt "$current"; then 739363847c39Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 739463847c39Smrg func_fatal_error "\`$vinfo' is not valid version information" 739563847c39Smrg fi 739663847c39Smrg 739763847c39Smrg # Calculate the version variables. 739863847c39Smrg major= 739963847c39Smrg versuffix= 740063847c39Smrg verstring= 740163847c39Smrg case $version_type in 740263847c39Smrg none) ;; 740363847c39Smrg 740463847c39Smrg darwin) 740563847c39Smrg # Like Linux, but with the current version available in 740663847c39Smrg # verstring for coding it into the library header 740763847c39Smrg func_arith $current - $age 740863847c39Smrg major=.$func_arith_result 740963847c39Smrg versuffix="$major.$age.$revision" 741063847c39Smrg # Darwin ld doesn't like 0 for these options... 741163847c39Smrg func_arith $current + 1 741263847c39Smrg minor_current=$func_arith_result 741363847c39Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 741463847c39Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 741563847c39Smrg ;; 741663847c39Smrg 741763847c39Smrg freebsd-aout) 741863847c39Smrg major=".$current" 741963847c39Smrg versuffix=".$current.$revision"; 742063847c39Smrg ;; 742163847c39Smrg 742263847c39Smrg freebsd-elf) 742363847c39Smrg major=".$current" 742463847c39Smrg versuffix=".$current" 742563847c39Smrg ;; 742663847c39Smrg 742763847c39Smrg irix | nonstopux) 742863847c39Smrg if test "X$lt_irix_increment" = "Xno"; then 742963847c39Smrg func_arith $current - $age 743063847c39Smrg else 743163847c39Smrg func_arith $current - $age + 1 743263847c39Smrg fi 743363847c39Smrg major=$func_arith_result 743463847c39Smrg 743563847c39Smrg case $version_type in 743663847c39Smrg nonstopux) verstring_prefix=nonstopux ;; 743763847c39Smrg *) verstring_prefix=sgi ;; 743863847c39Smrg esac 743963847c39Smrg verstring="$verstring_prefix$major.$revision" 744063847c39Smrg 744163847c39Smrg # Add in all the interfaces that we are compatible with. 744263847c39Smrg loop=$revision 744363847c39Smrg while test "$loop" -ne 0; do 744463847c39Smrg func_arith $revision - $loop 744563847c39Smrg iface=$func_arith_result 744663847c39Smrg func_arith $loop - 1 744763847c39Smrg loop=$func_arith_result 744863847c39Smrg verstring="$verstring_prefix$major.$iface:$verstring" 744963847c39Smrg done 745063847c39Smrg 745163847c39Smrg # Before this point, $major must not contain `.'. 745263847c39Smrg major=.$major 745363847c39Smrg versuffix="$major.$revision" 745463847c39Smrg ;; 745563847c39Smrg 745663847c39Smrg linux) # correct to gnu/linux during the next big refactor 745763847c39Smrg func_arith $current - $age 745863847c39Smrg major=.$func_arith_result 745963847c39Smrg versuffix="$major.$age.$revision" 746063847c39Smrg ;; 746163847c39Smrg 746263847c39Smrg osf) 746363847c39Smrg func_arith $current - $age 746463847c39Smrg major=.$func_arith_result 746563847c39Smrg versuffix=".$current.$age.$revision" 746663847c39Smrg verstring="$current.$age.$revision" 746763847c39Smrg 746863847c39Smrg # Add in all the interfaces that we are compatible with. 746963847c39Smrg loop=$age 747063847c39Smrg while test "$loop" -ne 0; do 747163847c39Smrg func_arith $current - $loop 747263847c39Smrg iface=$func_arith_result 747363847c39Smrg func_arith $loop - 1 747463847c39Smrg loop=$func_arith_result 747563847c39Smrg verstring="$verstring:${iface}.0" 747663847c39Smrg done 747763847c39Smrg 747863847c39Smrg # Make executables depend on our current version. 747963847c39Smrg func_append verstring ":${current}.0" 748063847c39Smrg ;; 748163847c39Smrg 748263847c39Smrg qnx) 748363847c39Smrg major=".$current" 748463847c39Smrg versuffix=".$current" 748563847c39Smrg ;; 748663847c39Smrg 748763847c39Smrg sunos) 748863847c39Smrg major=".$current" 748963847c39Smrg versuffix=".$current.$revision" 749063847c39Smrg ;; 749163847c39Smrg 749263847c39Smrg windows) 749363847c39Smrg # Use '-' rather than '.', since we only want one 749463847c39Smrg # extension on DOS 8.3 filesystems. 749563847c39Smrg func_arith $current - $age 749663847c39Smrg major=$func_arith_result 749763847c39Smrg versuffix="-$major" 749863847c39Smrg ;; 749963847c39Smrg 750063847c39Smrg *) 750163847c39Smrg func_fatal_configuration "unknown library version type \`$version_type'" 750263847c39Smrg ;; 750363847c39Smrg esac 750463847c39Smrg 750563847c39Smrg # Clear the version info if we defaulted, and they specified a release. 750663847c39Smrg if test -z "$vinfo" && test -n "$release"; then 750763847c39Smrg major= 750863847c39Smrg case $version_type in 750963847c39Smrg darwin) 751063847c39Smrg # we can't check for "0.0" in archive_cmds due to quoting 751163847c39Smrg # problems, so we reset it completely 751263847c39Smrg verstring= 751363847c39Smrg ;; 751463847c39Smrg *) 751563847c39Smrg verstring="0.0" 751663847c39Smrg ;; 751763847c39Smrg esac 751863847c39Smrg if test "$need_version" = no; then 751963847c39Smrg versuffix= 752063847c39Smrg else 752163847c39Smrg versuffix=".0.0" 752263847c39Smrg fi 752363847c39Smrg fi 752463847c39Smrg 752563847c39Smrg # Remove version info from name if versioning should be avoided 752663847c39Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 752763847c39Smrg major= 752863847c39Smrg versuffix= 752963847c39Smrg verstring="" 753063847c39Smrg fi 753163847c39Smrg 753263847c39Smrg # Check to see if the archive will have undefined symbols. 753363847c39Smrg if test "$allow_undefined" = yes; then 753463847c39Smrg if test "$allow_undefined_flag" = unsupported; then 753563847c39Smrg func_warning "undefined symbols not allowed in $host shared libraries" 753663847c39Smrg build_libtool_libs=no 753763847c39Smrg build_old_libs=yes 753863847c39Smrg fi 753963847c39Smrg else 754063847c39Smrg # Don't allow undefined symbols. 754163847c39Smrg allow_undefined_flag="$no_undefined_flag" 754263847c39Smrg fi 754363847c39Smrg 754463847c39Smrg fi 754563847c39Smrg 754663847c39Smrg func_generate_dlsyms "$libname" "$libname" "yes" 754763847c39Smrg func_append libobjs " $symfileobj" 754863847c39Smrg test "X$libobjs" = "X " && libobjs= 754963847c39Smrg 755063847c39Smrg if test "$opt_mode" != relink; then 755163847c39Smrg # Remove our outputs, but don't remove object files since they 755263847c39Smrg # may have been created when compiling PIC objects. 755363847c39Smrg removelist= 755463847c39Smrg tempremovelist=`$ECHO "$output_objdir/*"` 755563847c39Smrg for p in $tempremovelist; do 755663847c39Smrg case $p in 755763847c39Smrg *.$objext | *.gcno) 755863847c39Smrg ;; 755963847c39Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 756063847c39Smrg if test "X$precious_files_regex" != "X"; then 756163847c39Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 756263847c39Smrg then 756363847c39Smrg continue 756463847c39Smrg fi 756563847c39Smrg fi 756663847c39Smrg func_append removelist " $p" 756763847c39Smrg ;; 756863847c39Smrg *) ;; 756963847c39Smrg esac 757063847c39Smrg done 757163847c39Smrg test -n "$removelist" && \ 757263847c39Smrg func_show_eval "${RM}r \$removelist" 757363847c39Smrg fi 757463847c39Smrg 757563847c39Smrg # Now set the variables for building old libraries. 757663847c39Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 757763847c39Smrg func_append oldlibs " $output_objdir/$libname.$libext" 757863847c39Smrg 757963847c39Smrg # Transform .lo files to .o files. 758063847c39Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 758163847c39Smrg fi 758263847c39Smrg 758363847c39Smrg # Eliminate all temporary directories. 758463847c39Smrg #for path in $notinst_path; do 758563847c39Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 758663847c39Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 758763847c39Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 758863847c39Smrg #done 758963847c39Smrg 759063847c39Smrg if test -n "$xrpath"; then 759163847c39Smrg # If the user specified any rpath flags, then add them. 759263847c39Smrg temp_xrpath= 759363847c39Smrg for libdir in $xrpath; do 759463847c39Smrg func_replace_sysroot "$libdir" 759563847c39Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 759663847c39Smrg case "$finalize_rpath " in 759763847c39Smrg *" $libdir "*) ;; 759863847c39Smrg *) func_append finalize_rpath " $libdir" ;; 759963847c39Smrg esac 760063847c39Smrg done 760163847c39Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 760263847c39Smrg dependency_libs="$temp_xrpath $dependency_libs" 760363847c39Smrg fi 760463847c39Smrg fi 760563847c39Smrg 760663847c39Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 760763847c39Smrg old_dlfiles="$dlfiles" 760863847c39Smrg dlfiles= 760963847c39Smrg for lib in $old_dlfiles; do 761063847c39Smrg case " $dlprefiles $dlfiles " in 761163847c39Smrg *" $lib "*) ;; 761263847c39Smrg *) func_append dlfiles " $lib" ;; 761363847c39Smrg esac 761463847c39Smrg done 761563847c39Smrg 761663847c39Smrg # Make sure dlprefiles contains only unique files 761763847c39Smrg old_dlprefiles="$dlprefiles" 761863847c39Smrg dlprefiles= 761963847c39Smrg for lib in $old_dlprefiles; do 762063847c39Smrg case "$dlprefiles " in 762163847c39Smrg *" $lib "*) ;; 762263847c39Smrg *) func_append dlprefiles " $lib" ;; 762363847c39Smrg esac 762463847c39Smrg done 762563847c39Smrg 762663847c39Smrg if test "$build_libtool_libs" = yes; then 762763847c39Smrg if test -n "$rpath"; then 762863847c39Smrg case $host in 762963847c39Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 763063847c39Smrg # these systems don't actually have a c library (as such)! 763163847c39Smrg ;; 763263847c39Smrg *-*-rhapsody* | *-*-darwin1.[012]) 763363847c39Smrg # Rhapsody C library is in the System framework 763463847c39Smrg func_append deplibs " System.ltframework" 763563847c39Smrg ;; 763663847c39Smrg *-*-netbsd*) 763763847c39Smrg # Don't link with libc until the a.out ld.so is fixed. 763863847c39Smrg ;; 763963847c39Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 764063847c39Smrg # Do not include libc due to us having libc/libc_r. 764163847c39Smrg ;; 764263847c39Smrg *-*-sco3.2v5* | *-*-sco5v6*) 764363847c39Smrg # Causes problems with __ctype 764463847c39Smrg ;; 764563847c39Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 764663847c39Smrg # Compiler inserts libc in the correct place for threads to work 764763847c39Smrg ;; 764863847c39Smrg *) 764963847c39Smrg # Add libc to deplibs on all other systems if necessary. 765063847c39Smrg if test "$build_libtool_need_lc" = "yes"; then 765163847c39Smrg func_append deplibs " -lc" 765263847c39Smrg fi 765363847c39Smrg ;; 765463847c39Smrg esac 765563847c39Smrg fi 765663847c39Smrg 765763847c39Smrg # Transform deplibs into only deplibs that can be linked in shared. 765863847c39Smrg name_save=$name 765963847c39Smrg libname_save=$libname 766063847c39Smrg release_save=$release 766163847c39Smrg versuffix_save=$versuffix 766263847c39Smrg major_save=$major 766363847c39Smrg # I'm not sure if I'm treating the release correctly. I think 766463847c39Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 766563847c39Smrg # add it in twice. Is that correct? 766663847c39Smrg release="" 766763847c39Smrg versuffix="" 766863847c39Smrg major="" 766963847c39Smrg newdeplibs= 767063847c39Smrg droppeddeps=no 767163847c39Smrg case $deplibs_check_method in 767263847c39Smrg pass_all) 767363847c39Smrg # Don't check for shared/static. Everything works. 767463847c39Smrg # This might be a little naive. We might want to check 767563847c39Smrg # whether the library exists or not. But this is on 767663847c39Smrg # osf3 & osf4 and I'm not really sure... Just 767763847c39Smrg # implementing what was already the behavior. 767863847c39Smrg newdeplibs=$deplibs 767963847c39Smrg ;; 768063847c39Smrg test_compile) 768163847c39Smrg # This code stresses the "libraries are programs" paradigm to its 768263847c39Smrg # limits. Maybe even breaks it. We compile a program, linking it 768363847c39Smrg # against the deplibs as a proxy for the library. Then we can check 768463847c39Smrg # whether they linked in statically or dynamically with ldd. 768563847c39Smrg $opt_dry_run || $RM conftest.c 768663847c39Smrg cat > conftest.c <<EOF 768763847c39Smrg int main() { return 0; } 768863847c39SmrgEOF 768963847c39Smrg $opt_dry_run || $RM conftest 769063847c39Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 769163847c39Smrg ldd_output=`ldd conftest` 769263847c39Smrg for i in $deplibs; do 769363847c39Smrg case $i in 769463847c39Smrg -l*) 769563847c39Smrg func_stripname -l '' "$i" 769663847c39Smrg name=$func_stripname_result 769763847c39Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 769863847c39Smrg case " $predeps $postdeps " in 769963847c39Smrg *" $i "*) 770063847c39Smrg func_append newdeplibs " $i" 770163847c39Smrg i="" 770263847c39Smrg ;; 770363847c39Smrg esac 770463847c39Smrg fi 770563847c39Smrg if test -n "$i" ; then 770663847c39Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 770763847c39Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 770863847c39Smrg set dummy $deplib_matches; shift 770963847c39Smrg deplib_match=$1 771063847c39Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 771163847c39Smrg func_append newdeplibs " $i" 771263847c39Smrg else 771363847c39Smrg droppeddeps=yes 771463847c39Smrg echo 771563847c39Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 771663847c39Smrg echo "*** I have the capability to make that library automatically link in when" 771763847c39Smrg echo "*** you link to this library. But I can only do this if you have a" 771863847c39Smrg echo "*** shared version of the library, which I believe you do not have" 771963847c39Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 772063847c39Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 772163847c39Smrg fi 772263847c39Smrg fi 772363847c39Smrg ;; 772463847c39Smrg *) 772563847c39Smrg func_append newdeplibs " $i" 772663847c39Smrg ;; 772763847c39Smrg esac 772863847c39Smrg done 772963847c39Smrg else 773063847c39Smrg # Error occurred in the first compile. Let's try to salvage 773163847c39Smrg # the situation: Compile a separate program for each library. 773263847c39Smrg for i in $deplibs; do 773363847c39Smrg case $i in 773463847c39Smrg -l*) 773563847c39Smrg func_stripname -l '' "$i" 773663847c39Smrg name=$func_stripname_result 773763847c39Smrg $opt_dry_run || $RM conftest 773863847c39Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 773963847c39Smrg ldd_output=`ldd conftest` 774063847c39Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 774163847c39Smrg case " $predeps $postdeps " in 774263847c39Smrg *" $i "*) 774363847c39Smrg func_append newdeplibs " $i" 774463847c39Smrg i="" 774563847c39Smrg ;; 774663847c39Smrg esac 774763847c39Smrg fi 774863847c39Smrg if test -n "$i" ; then 774963847c39Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 775063847c39Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 775163847c39Smrg set dummy $deplib_matches; shift 775263847c39Smrg deplib_match=$1 775363847c39Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 775463847c39Smrg func_append newdeplibs " $i" 775563847c39Smrg else 775663847c39Smrg droppeddeps=yes 775763847c39Smrg echo 775863847c39Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 775963847c39Smrg echo "*** I have the capability to make that library automatically link in when" 776063847c39Smrg echo "*** you link to this library. But I can only do this if you have a" 776163847c39Smrg echo "*** shared version of the library, which you do not appear to have" 776263847c39Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 776363847c39Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 776463847c39Smrg fi 776563847c39Smrg fi 776663847c39Smrg else 776763847c39Smrg droppeddeps=yes 776863847c39Smrg echo 776963847c39Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 777063847c39Smrg echo "*** make it link in! You will probably need to install it or some" 777163847c39Smrg echo "*** library that it depends on before this library will be fully" 777263847c39Smrg echo "*** functional. Installing it before continuing would be even better." 777363847c39Smrg fi 777463847c39Smrg ;; 777563847c39Smrg *) 777663847c39Smrg func_append newdeplibs " $i" 777763847c39Smrg ;; 777863847c39Smrg esac 777963847c39Smrg done 778063847c39Smrg fi 778163847c39Smrg ;; 778263847c39Smrg file_magic*) 778363847c39Smrg set dummy $deplibs_check_method; shift 778463847c39Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 778563847c39Smrg for a_deplib in $deplibs; do 778663847c39Smrg case $a_deplib in 778763847c39Smrg -l*) 778863847c39Smrg func_stripname -l '' "$a_deplib" 778963847c39Smrg name=$func_stripname_result 779063847c39Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 779163847c39Smrg case " $predeps $postdeps " in 779263847c39Smrg *" $a_deplib "*) 779363847c39Smrg func_append newdeplibs " $a_deplib" 779463847c39Smrg a_deplib="" 779563847c39Smrg ;; 779663847c39Smrg esac 779763847c39Smrg fi 779863847c39Smrg if test -n "$a_deplib" ; then 779963847c39Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 780063847c39Smrg if test -n "$file_magic_glob"; then 780163847c39Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 780263847c39Smrg else 780363847c39Smrg libnameglob=$libname 780463847c39Smrg fi 780563847c39Smrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 780663847c39Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 780763847c39Smrg if test "$want_nocaseglob" = yes; then 780863847c39Smrg shopt -s nocaseglob 780963847c39Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 781063847c39Smrg $nocaseglob 781163847c39Smrg else 781263847c39Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 781363847c39Smrg fi 781463847c39Smrg for potent_lib in $potential_libs; do 781563847c39Smrg # Follow soft links. 781663847c39Smrg if ls -lLd "$potent_lib" 2>/dev/null | 781763847c39Smrg $GREP " -> " >/dev/null; then 781863847c39Smrg continue 781963847c39Smrg fi 782063847c39Smrg # The statement above tries to avoid entering an 782163847c39Smrg # endless loop below, in case of cyclic links. 782263847c39Smrg # We might still enter an endless loop, since a link 782363847c39Smrg # loop can be closed while we follow links, 782463847c39Smrg # but so what? 782563847c39Smrg potlib="$potent_lib" 782663847c39Smrg while test -h "$potlib" 2>/dev/null; do 782763847c39Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 782863847c39Smrg case $potliblink in 782963847c39Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 783063847c39Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 783163847c39Smrg esac 783263847c39Smrg done 783363847c39Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 783463847c39Smrg $SED -e 10q | 783563847c39Smrg $EGREP "$file_magic_regex" > /dev/null; then 783663847c39Smrg func_append newdeplibs " $a_deplib" 783763847c39Smrg a_deplib="" 783863847c39Smrg break 2 783963847c39Smrg fi 784063847c39Smrg done 784163847c39Smrg done 784263847c39Smrg fi 784363847c39Smrg if test -n "$a_deplib" ; then 784463847c39Smrg droppeddeps=yes 784563847c39Smrg echo 784663847c39Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 784763847c39Smrg echo "*** I have the capability to make that library automatically link in when" 784863847c39Smrg echo "*** you link to this library. But I can only do this if you have a" 784963847c39Smrg echo "*** shared version of the library, which you do not appear to have" 785063847c39Smrg echo "*** because I did check the linker path looking for a file starting" 785163847c39Smrg if test -z "$potlib" ; then 785263847c39Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 785363847c39Smrg else 785463847c39Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 785563847c39Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 785663847c39Smrg fi 785763847c39Smrg fi 785863847c39Smrg ;; 785963847c39Smrg *) 786063847c39Smrg # Add a -L argument. 786163847c39Smrg func_append newdeplibs " $a_deplib" 786263847c39Smrg ;; 786363847c39Smrg esac 786463847c39Smrg done # Gone through all deplibs. 786563847c39Smrg ;; 786663847c39Smrg match_pattern*) 786763847c39Smrg set dummy $deplibs_check_method; shift 786863847c39Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 786963847c39Smrg for a_deplib in $deplibs; do 787063847c39Smrg case $a_deplib in 787163847c39Smrg -l*) 787263847c39Smrg func_stripname -l '' "$a_deplib" 787363847c39Smrg name=$func_stripname_result 787463847c39Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 787563847c39Smrg case " $predeps $postdeps " in 787663847c39Smrg *" $a_deplib "*) 787763847c39Smrg func_append newdeplibs " $a_deplib" 787863847c39Smrg a_deplib="" 787963847c39Smrg ;; 788063847c39Smrg esac 788163847c39Smrg fi 788263847c39Smrg if test -n "$a_deplib" ; then 788363847c39Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 788463847c39Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 788563847c39Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 788663847c39Smrg for potent_lib in $potential_libs; do 788763847c39Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 788863847c39Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 788963847c39Smrg $EGREP "$match_pattern_regex" > /dev/null; then 789063847c39Smrg func_append newdeplibs " $a_deplib" 789163847c39Smrg a_deplib="" 789263847c39Smrg break 2 789363847c39Smrg fi 789463847c39Smrg done 789563847c39Smrg done 789663847c39Smrg fi 789763847c39Smrg if test -n "$a_deplib" ; then 789863847c39Smrg droppeddeps=yes 789963847c39Smrg echo 790063847c39Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 790163847c39Smrg echo "*** I have the capability to make that library automatically link in when" 790263847c39Smrg echo "*** you link to this library. But I can only do this if you have a" 790363847c39Smrg echo "*** shared version of the library, which you do not appear to have" 790463847c39Smrg echo "*** because I did check the linker path looking for a file starting" 790563847c39Smrg if test -z "$potlib" ; then 790663847c39Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 790763847c39Smrg else 790863847c39Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 790963847c39Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 791063847c39Smrg fi 791163847c39Smrg fi 791263847c39Smrg ;; 791363847c39Smrg *) 791463847c39Smrg # Add a -L argument. 791563847c39Smrg func_append newdeplibs " $a_deplib" 791663847c39Smrg ;; 791763847c39Smrg esac 791863847c39Smrg done # Gone through all deplibs. 791963847c39Smrg ;; 792063847c39Smrg none | unknown | *) 792163847c39Smrg newdeplibs="" 792263847c39Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 792363847c39Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 792463847c39Smrg for i in $predeps $postdeps ; do 792563847c39Smrg # can't use Xsed below, because $i might contain '/' 792663847c39Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 792763847c39Smrg done 792863847c39Smrg fi 792963847c39Smrg case $tmp_deplibs in 793063847c39Smrg *[!\ \ ]*) 793163847c39Smrg echo 793263847c39Smrg if test "X$deplibs_check_method" = "Xnone"; then 793363847c39Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 793463847c39Smrg else 793563847c39Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 793663847c39Smrg fi 793763847c39Smrg echo "*** All declared inter-library dependencies are being dropped." 793863847c39Smrg droppeddeps=yes 793963847c39Smrg ;; 794063847c39Smrg esac 794163847c39Smrg ;; 794263847c39Smrg esac 794363847c39Smrg versuffix=$versuffix_save 794463847c39Smrg major=$major_save 794563847c39Smrg release=$release_save 794663847c39Smrg libname=$libname_save 794763847c39Smrg name=$name_save 794876888252Smrg 794963847c39Smrg case $host in 795063847c39Smrg *-*-rhapsody* | *-*-darwin1.[012]) 795163847c39Smrg # On Rhapsody replace the C library with the System framework 795263847c39Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 795363847c39Smrg ;; 795463847c39Smrg esac 795576888252Smrg 795663847c39Smrg if test "$droppeddeps" = yes; then 795763847c39Smrg if test "$module" = yes; then 795863847c39Smrg echo 795963847c39Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 796063847c39Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 796163847c39Smrg echo "*** a static module, that should work as long as the dlopening" 796263847c39Smrg echo "*** application is linked with the -dlopen flag." 796363847c39Smrg if test -z "$global_symbol_pipe"; then 796463847c39Smrg echo 796563847c39Smrg echo "*** However, this would only work if libtool was able to extract symbol" 796663847c39Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 796763847c39Smrg echo "*** not find such a program. So, this module is probably useless." 796863847c39Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 796963847c39Smrg fi 797063847c39Smrg if test "$build_old_libs" = no; then 797163847c39Smrg oldlibs="$output_objdir/$libname.$libext" 797263847c39Smrg build_libtool_libs=module 797363847c39Smrg build_old_libs=yes 797463847c39Smrg else 797563847c39Smrg build_libtool_libs=no 797663847c39Smrg fi 797763847c39Smrg else 797863847c39Smrg echo "*** The inter-library dependencies that have been dropped here will be" 797963847c39Smrg echo "*** automatically added whenever a program is linked with this library" 798063847c39Smrg echo "*** or is declared to -dlopen it." 798176888252Smrg 798263847c39Smrg if test "$allow_undefined" = no; then 798363847c39Smrg echo 798463847c39Smrg echo "*** Since this library must not contain undefined symbols," 798563847c39Smrg echo "*** because either the platform does not support them or" 798663847c39Smrg echo "*** it was explicitly requested with -no-undefined," 798763847c39Smrg echo "*** libtool will only create a static version of it." 798863847c39Smrg if test "$build_old_libs" = no; then 798963847c39Smrg oldlibs="$output_objdir/$libname.$libext" 799063847c39Smrg build_libtool_libs=module 799163847c39Smrg build_old_libs=yes 799263847c39Smrg else 799363847c39Smrg build_libtool_libs=no 799463847c39Smrg fi 799563847c39Smrg fi 799663847c39Smrg fi 799786dafe34Smrg fi 799863847c39Smrg # Done checking deplibs! 799963847c39Smrg deplibs=$newdeplibs 800063847c39Smrg fi 800163847c39Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 800263847c39Smrg case $host in 800363847c39Smrg *-*-darwin*) 800463847c39Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 800563847c39Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 800663847c39Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 800763847c39Smrg ;; 800863847c39Smrg esac 800976888252Smrg 801063847c39Smrg # move library search paths that coincide with paths to not yet 801163847c39Smrg # installed libraries to the beginning of the library search list 801263847c39Smrg new_libs= 801363847c39Smrg for path in $notinst_path; do 801463847c39Smrg case " $new_libs " in 801563847c39Smrg *" -L$path/$objdir "*) ;; 801663847c39Smrg *) 801763847c39Smrg case " $deplibs " in 801863847c39Smrg *" -L$path/$objdir "*) 801963847c39Smrg func_append new_libs " -L$path/$objdir" ;; 802063847c39Smrg esac 802163847c39Smrg ;; 802263847c39Smrg esac 802363847c39Smrg done 802463847c39Smrg for deplib in $deplibs; do 802563847c39Smrg case $deplib in 802663847c39Smrg -L*) 802763847c39Smrg case " $new_libs " in 802863847c39Smrg *" $deplib "*) ;; 802963847c39Smrg *) func_append new_libs " $deplib" ;; 803063847c39Smrg esac 803163847c39Smrg ;; 803263847c39Smrg *) func_append new_libs " $deplib" ;; 803363847c39Smrg esac 803463847c39Smrg done 803563847c39Smrg deplibs="$new_libs" 803676888252Smrg 803763847c39Smrg # All the library-specific variables (install_libdir is set above). 803863847c39Smrg library_names= 803963847c39Smrg old_library= 804063847c39Smrg dlname= 804176888252Smrg 804263847c39Smrg # Test again, we may have decided not to build it any more 804363847c39Smrg if test "$build_libtool_libs" = yes; then 804463847c39Smrg # Remove ${wl} instances when linking with ld. 804563847c39Smrg # FIXME: should test the right _cmds variable. 804663847c39Smrg case $archive_cmds in 804763847c39Smrg *\$LD\ *) wl= ;; 804863847c39Smrg esac 804963847c39Smrg if test "$hardcode_into_libs" = yes; then 805063847c39Smrg # Hardcode the library paths 805163847c39Smrg hardcode_libdirs= 805263847c39Smrg dep_rpath= 805363847c39Smrg rpath="$finalize_rpath" 805463847c39Smrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 805563847c39Smrg for libdir in $rpath; do 805663847c39Smrg if test -n "$hardcode_libdir_flag_spec"; then 805763847c39Smrg if test -n "$hardcode_libdir_separator"; then 805863847c39Smrg func_replace_sysroot "$libdir" 805963847c39Smrg libdir=$func_replace_sysroot_result 806063847c39Smrg if test -z "$hardcode_libdirs"; then 806163847c39Smrg hardcode_libdirs="$libdir" 806263847c39Smrg else 806363847c39Smrg # Just accumulate the unique libdirs. 806463847c39Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 806563847c39Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 806663847c39Smrg ;; 806763847c39Smrg *) 806863847c39Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 806963847c39Smrg ;; 807063847c39Smrg esac 807163847c39Smrg fi 807263847c39Smrg else 807363847c39Smrg eval flag=\"$hardcode_libdir_flag_spec\" 807463847c39Smrg func_append dep_rpath " $flag" 807563847c39Smrg fi 807663847c39Smrg elif test -n "$runpath_var"; then 807763847c39Smrg case "$perm_rpath " in 807863847c39Smrg *" $libdir "*) ;; 807963847c39Smrg *) func_append perm_rpath " $libdir" ;; 808063847c39Smrg esac 808163847c39Smrg fi 808263847c39Smrg done 808363847c39Smrg # Substitute the hardcoded libdirs into the rpath. 808463847c39Smrg if test -n "$hardcode_libdir_separator" && 808563847c39Smrg test -n "$hardcode_libdirs"; then 808663847c39Smrg libdir="$hardcode_libdirs" 808763847c39Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 808863847c39Smrg fi 808963847c39Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 809063847c39Smrg # We should set the runpath_var. 809163847c39Smrg rpath= 809263847c39Smrg for dir in $perm_rpath; do 809363847c39Smrg func_append rpath "$dir:" 809463847c39Smrg done 809563847c39Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 809663847c39Smrg fi 809763847c39Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 8098d8556812Smrg fi 809976888252Smrg 810063847c39Smrg shlibpath="$finalize_shlibpath" 810163847c39Smrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 810263847c39Smrg if test -n "$shlibpath"; then 810363847c39Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 8104d8556812Smrg fi 810576888252Smrg 810663847c39Smrg # Get the real and link names of the library. 810763847c39Smrg eval shared_ext=\"$shrext_cmds\" 810863847c39Smrg eval library_names=\"$library_names_spec\" 810963847c39Smrg set dummy $library_names 811063847c39Smrg shift 811163847c39Smrg realname="$1" 811263847c39Smrg shift 811376888252Smrg 811463847c39Smrg if test -n "$soname_spec"; then 811563847c39Smrg eval soname=\"$soname_spec\" 8116d8556812Smrg else 811763847c39Smrg soname="$realname" 811863847c39Smrg fi 811963847c39Smrg if test -z "$dlname"; then 812063847c39Smrg dlname=$soname 8121d8556812Smrg fi 812276888252Smrg 812363847c39Smrg lib="$output_objdir/$realname" 812463847c39Smrg linknames= 812563847c39Smrg for link 812663847c39Smrg do 812763847c39Smrg func_append linknames " $link" 812863847c39Smrg done 812976888252Smrg 813063847c39Smrg # Use standard objects if they are pic 813163847c39Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 813263847c39Smrg test "X$libobjs" = "X " && libobjs= 813386dafe34Smrg 813463847c39Smrg delfiles= 813563847c39Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 813663847c39Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 813763847c39Smrg export_symbols="$output_objdir/$libname.uexp" 813863847c39Smrg func_append delfiles " $export_symbols" 813963847c39Smrg fi 814076888252Smrg 814163847c39Smrg orig_export_symbols= 814263847c39Smrg case $host_os in 814363847c39Smrg cygwin* | mingw* | cegcc*) 814463847c39Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 814563847c39Smrg # exporting using user supplied symfile 814663847c39Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 814763847c39Smrg # and it's NOT already a .def file. Must figure out 814863847c39Smrg # which of the given symbols are data symbols and tag 814963847c39Smrg # them as such. So, trigger use of export_symbols_cmds. 815063847c39Smrg # export_symbols gets reassigned inside the "prepare 815163847c39Smrg # the list of exported symbols" if statement, so the 815263847c39Smrg # include_expsyms logic still works. 815363847c39Smrg orig_export_symbols="$export_symbols" 815463847c39Smrg export_symbols= 815563847c39Smrg always_export_symbols=yes 815686dafe34Smrg fi 815786dafe34Smrg fi 815863847c39Smrg ;; 815963847c39Smrg esac 816076888252Smrg 816163847c39Smrg # Prepare the list of exported symbols 816263847c39Smrg if test -z "$export_symbols"; then 816363847c39Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 816463847c39Smrg func_verbose "generating symbol list for \`$libname.la'" 816563847c39Smrg export_symbols="$output_objdir/$libname.exp" 816663847c39Smrg $opt_dry_run || $RM $export_symbols 816763847c39Smrg cmds=$export_symbols_cmds 816863847c39Smrg save_ifs="$IFS"; IFS='~' 816963847c39Smrg for cmd1 in $cmds; do 817063847c39Smrg IFS="$save_ifs" 817163847c39Smrg # Take the normal branch if the nm_file_list_spec branch 817263847c39Smrg # doesn't work or if tool conversion is not needed. 817363847c39Smrg case $nm_file_list_spec~$to_tool_file_cmd in 817463847c39Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 817563847c39Smrg try_normal_branch=yes 817663847c39Smrg eval cmd=\"$cmd1\" 817763847c39Smrg func_len " $cmd" 817863847c39Smrg len=$func_len_result 817963847c39Smrg ;; 818063847c39Smrg *) 818163847c39Smrg try_normal_branch=no 818263847c39Smrg ;; 818363847c39Smrg esac 818463847c39Smrg if test "$try_normal_branch" = yes \ 818563847c39Smrg && { test "$len" -lt "$max_cmd_len" \ 818663847c39Smrg || test "$max_cmd_len" -le -1; } 818763847c39Smrg then 818863847c39Smrg func_show_eval "$cmd" 'exit $?' 818963847c39Smrg skipped_export=false 819063847c39Smrg elif test -n "$nm_file_list_spec"; then 819163847c39Smrg func_basename "$output" 819263847c39Smrg output_la=$func_basename_result 819363847c39Smrg save_libobjs=$libobjs 819463847c39Smrg save_output=$output 819563847c39Smrg output=${output_objdir}/${output_la}.nm 819663847c39Smrg func_to_tool_file "$output" 819763847c39Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 819863847c39Smrg func_append delfiles " $output" 819963847c39Smrg func_verbose "creating $NM input file list: $output" 820063847c39Smrg for obj in $save_libobjs; do 820163847c39Smrg func_to_tool_file "$obj" 820263847c39Smrg $ECHO "$func_to_tool_file_result" 820363847c39Smrg done > "$output" 820463847c39Smrg eval cmd=\"$cmd1\" 820563847c39Smrg func_show_eval "$cmd" 'exit $?' 820663847c39Smrg output=$save_output 820763847c39Smrg libobjs=$save_libobjs 820863847c39Smrg skipped_export=false 820963847c39Smrg else 821063847c39Smrg # The command line is too long to execute in one step. 821163847c39Smrg func_verbose "using reloadable object file for export list..." 821263847c39Smrg skipped_export=: 821363847c39Smrg # Break out early, otherwise skipped_export may be 821463847c39Smrg # set to false by a later but shorter cmd. 821563847c39Smrg break 821663847c39Smrg fi 821763847c39Smrg done 821863847c39Smrg IFS="$save_ifs" 821963847c39Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 822063847c39Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 822163847c39Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 822263847c39Smrg fi 822363847c39Smrg fi 822463847c39Smrg fi 822563847c39Smrg 822663847c39Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 822763847c39Smrg tmp_export_symbols="$export_symbols" 822863847c39Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 822963847c39Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8230d8556812Smrg fi 823176888252Smrg 823263847c39Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 823363847c39Smrg # The given exports_symbols file has to be filtered, so filter it. 823463847c39Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 823563847c39Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 823663847c39Smrg # 's' commands which not all seds can handle. GNU sed should be fine 823763847c39Smrg # though. Also, the filter scales superlinearly with the number of 823863847c39Smrg # global variables. join(1) would be nice here, but unfortunately 823963847c39Smrg # isn't a blessed tool. 824063847c39Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 824163847c39Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 824263847c39Smrg export_symbols=$output_objdir/$libname.def 824363847c39Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 824463847c39Smrg fi 824586dafe34Smrg 824663847c39Smrg tmp_deplibs= 824763847c39Smrg for test_deplib in $deplibs; do 824863847c39Smrg case " $convenience " in 824963847c39Smrg *" $test_deplib "*) ;; 825063847c39Smrg *) 825163847c39Smrg func_append tmp_deplibs " $test_deplib" 825263847c39Smrg ;; 825363847c39Smrg esac 825463847c39Smrg done 825563847c39Smrg deplibs="$tmp_deplibs" 8256d8556812Smrg 825763847c39Smrg if test -n "$convenience"; then 825863847c39Smrg if test -n "$whole_archive_flag_spec" && 825963847c39Smrg test "$compiler_needs_object" = yes && 826063847c39Smrg test -z "$libobjs"; then 826163847c39Smrg # extract the archives, so we have objects to list. 826263847c39Smrg # TODO: could optimize this to just extract one archive. 826363847c39Smrg whole_archive_flag_spec= 826463847c39Smrg fi 826563847c39Smrg if test -n "$whole_archive_flag_spec"; then 826663847c39Smrg save_libobjs=$libobjs 826763847c39Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 826863847c39Smrg test "X$libobjs" = "X " && libobjs= 826976888252Smrg else 827063847c39Smrg gentop="$output_objdir/${outputname}x" 827163847c39Smrg func_append generated " $gentop" 827263847c39Smrg 827363847c39Smrg func_extract_archives $gentop $convenience 827463847c39Smrg func_append libobjs " $func_extract_archives_result" 827563847c39Smrg test "X$libobjs" = "X " && libobjs= 827676888252Smrg fi 827776888252Smrg fi 827886dafe34Smrg 827963847c39Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 828063847c39Smrg eval flag=\"$thread_safe_flag_spec\" 828163847c39Smrg func_append linker_flags " $flag" 828263847c39Smrg fi 828376888252Smrg 828463847c39Smrg # Make a backup of the uninstalled library when relinking 828563847c39Smrg if test "$opt_mode" = relink; then 828663847c39Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 828763847c39Smrg fi 828886dafe34Smrg 828963847c39Smrg # Do each of the archive commands. 829063847c39Smrg if test "$module" = yes && test -n "$module_cmds" ; then 829163847c39Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 829263847c39Smrg eval test_cmds=\"$module_expsym_cmds\" 829363847c39Smrg cmds=$module_expsym_cmds 829463847c39Smrg else 829563847c39Smrg eval test_cmds=\"$module_cmds\" 829663847c39Smrg cmds=$module_cmds 829763847c39Smrg fi 8298d8556812Smrg else 829963847c39Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 830063847c39Smrg eval test_cmds=\"$archive_expsym_cmds\" 830163847c39Smrg cmds=$archive_expsym_cmds 830263847c39Smrg else 830363847c39Smrg eval test_cmds=\"$archive_cmds\" 830463847c39Smrg cmds=$archive_cmds 830563847c39Smrg fi 830686dafe34Smrg fi 830786dafe34Smrg 830863847c39Smrg if test "X$skipped_export" != "X:" && 830963847c39Smrg func_len " $test_cmds" && 831063847c39Smrg len=$func_len_result && 831163847c39Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 831263847c39Smrg : 831363847c39Smrg else 831463847c39Smrg # The command line is too long to link in one step, link piecewise 831563847c39Smrg # or, if using GNU ld and skipped_export is not :, use a linker 831663847c39Smrg # script. 831786dafe34Smrg 831863847c39Smrg # Save the value of $output and $libobjs because we want to 831963847c39Smrg # use them later. If we have whole_archive_flag_spec, we 832063847c39Smrg # want to use save_libobjs as it was before 832163847c39Smrg # whole_archive_flag_spec was expanded, because we can't 832263847c39Smrg # assume the linker understands whole_archive_flag_spec. 832363847c39Smrg # This may have to be revisited, in case too many 832463847c39Smrg # convenience libraries get linked in and end up exceeding 832563847c39Smrg # the spec. 832663847c39Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 832763847c39Smrg save_libobjs=$libobjs 832863847c39Smrg fi 832963847c39Smrg save_output=$output 833063847c39Smrg func_basename "$output" 833163847c39Smrg output_la=$func_basename_result 833263847c39Smrg 833363847c39Smrg # Clear the reloadable object creation command queue and 833463847c39Smrg # initialize k to one. 833563847c39Smrg test_cmds= 833663847c39Smrg concat_cmds= 833763847c39Smrg objlist= 833863847c39Smrg last_robj= 833963847c39Smrg k=1 834063847c39Smrg 834163847c39Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 834263847c39Smrg output=${output_objdir}/${output_la}.lnkscript 834363847c39Smrg func_verbose "creating GNU ld script: $output" 834463847c39Smrg echo 'INPUT (' > $output 834563847c39Smrg for obj in $save_libobjs 834663847c39Smrg do 834763847c39Smrg func_to_tool_file "$obj" 834863847c39Smrg $ECHO "$func_to_tool_file_result" >> $output 834963847c39Smrg done 835063847c39Smrg echo ')' >> $output 835163847c39Smrg func_append delfiles " $output" 835263847c39Smrg func_to_tool_file "$output" 835363847c39Smrg output=$func_to_tool_file_result 835463847c39Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 835563847c39Smrg output=${output_objdir}/${output_la}.lnk 835663847c39Smrg func_verbose "creating linker input file list: $output" 835763847c39Smrg : > $output 835863847c39Smrg set x $save_libobjs 835963847c39Smrg shift 836063847c39Smrg firstobj= 836163847c39Smrg if test "$compiler_needs_object" = yes; then 836263847c39Smrg firstobj="$1 " 836363847c39Smrg shift 8364d8556812Smrg fi 836563847c39Smrg for obj 836663847c39Smrg do 836763847c39Smrg func_to_tool_file "$obj" 836863847c39Smrg $ECHO "$func_to_tool_file_result" >> $output 8369d8556812Smrg done 837063847c39Smrg func_append delfiles " $output" 837163847c39Smrg func_to_tool_file "$output" 837263847c39Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 837363847c39Smrg else 837463847c39Smrg if test -n "$save_libobjs"; then 837563847c39Smrg func_verbose "creating reloadable object files..." 837663847c39Smrg output=$output_objdir/$output_la-${k}.$objext 837763847c39Smrg eval test_cmds=\"$reload_cmds\" 837863847c39Smrg func_len " $test_cmds" 837963847c39Smrg len0=$func_len_result 838063847c39Smrg len=$len0 838163847c39Smrg 838263847c39Smrg # Loop over the list of objects to be linked. 838363847c39Smrg for obj in $save_libobjs 838463847c39Smrg do 838563847c39Smrg func_len " $obj" 838663847c39Smrg func_arith $len + $func_len_result 838763847c39Smrg len=$func_arith_result 838863847c39Smrg if test "X$objlist" = X || 838963847c39Smrg test "$len" -lt "$max_cmd_len"; then 839063847c39Smrg func_append objlist " $obj" 839163847c39Smrg else 839263847c39Smrg # The command $test_cmds is almost too long, add a 839363847c39Smrg # command to the queue. 839463847c39Smrg if test "$k" -eq 1 ; then 839563847c39Smrg # The first file doesn't have a previous command to add. 839663847c39Smrg reload_objs=$objlist 839763847c39Smrg eval concat_cmds=\"$reload_cmds\" 839863847c39Smrg else 839963847c39Smrg # All subsequent reloadable object files will link in 840063847c39Smrg # the last one created. 840163847c39Smrg reload_objs="$objlist $last_robj" 840263847c39Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 840363847c39Smrg fi 840463847c39Smrg last_robj=$output_objdir/$output_la-${k}.$objext 840563847c39Smrg func_arith $k + 1 840663847c39Smrg k=$func_arith_result 840763847c39Smrg output=$output_objdir/$output_la-${k}.$objext 840863847c39Smrg objlist=" $obj" 840963847c39Smrg func_len " $last_robj" 841063847c39Smrg func_arith $len0 + $func_len_result 841163847c39Smrg len=$func_arith_result 841263847c39Smrg fi 841363847c39Smrg done 841463847c39Smrg # Handle the remaining objects by creating one last 841563847c39Smrg # reloadable object file. All subsequent reloadable object 841663847c39Smrg # files will link in the last one created. 841763847c39Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 841863847c39Smrg reload_objs="$objlist $last_robj" 841963847c39Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 842063847c39Smrg if test -n "$last_robj"; then 842163847c39Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8422d8556812Smrg fi 842363847c39Smrg func_append delfiles " $output" 842463847c39Smrg 842563847c39Smrg else 842663847c39Smrg output= 842763847c39Smrg fi 842863847c39Smrg 842963847c39Smrg if ${skipped_export-false}; then 843063847c39Smrg func_verbose "generating symbol list for \`$libname.la'" 843163847c39Smrg export_symbols="$output_objdir/$libname.exp" 843263847c39Smrg $opt_dry_run || $RM $export_symbols 843363847c39Smrg libobjs=$output 843463847c39Smrg # Append the command to create the export file. 843563847c39Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 843663847c39Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 843763847c39Smrg if test -n "$last_robj"; then 843863847c39Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8439d8556812Smrg fi 844063847c39Smrg fi 844163847c39Smrg 844263847c39Smrg test -n "$save_libobjs" && 844363847c39Smrg func_verbose "creating a temporary reloadable object file: $output" 844463847c39Smrg 844563847c39Smrg # Loop through the commands generated above and execute them. 844663847c39Smrg save_ifs="$IFS"; IFS='~' 844763847c39Smrg for cmd in $concat_cmds; do 844863847c39Smrg IFS="$save_ifs" 844963847c39Smrg $opt_silent || { 845063847c39Smrg func_quote_for_expand "$cmd" 845163847c39Smrg eval "func_echo $func_quote_for_expand_result" 845263847c39Smrg } 845363847c39Smrg $opt_dry_run || eval "$cmd" || { 845463847c39Smrg lt_exit=$? 845563847c39Smrg 845663847c39Smrg # Restore the uninstalled library and exit 845763847c39Smrg if test "$opt_mode" = relink; then 845863847c39Smrg ( cd "$output_objdir" && \ 845963847c39Smrg $RM "${realname}T" && \ 846063847c39Smrg $MV "${realname}U" "$realname" ) 846163847c39Smrg fi 846263847c39Smrg 846363847c39Smrg exit $lt_exit 846463847c39Smrg } 8465d8556812Smrg done 846663847c39Smrg IFS="$save_ifs" 846763847c39Smrg 846863847c39Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 846963847c39Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 847063847c39Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 847163847c39Smrg fi 847263847c39Smrg fi 847363847c39Smrg 847463847c39Smrg if ${skipped_export-false}; then 847563847c39Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 847663847c39Smrg tmp_export_symbols="$export_symbols" 847763847c39Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 847863847c39Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 847963847c39Smrg fi 848063847c39Smrg 848163847c39Smrg if test -n "$orig_export_symbols"; then 848263847c39Smrg # The given exports_symbols file has to be filtered, so filter it. 848363847c39Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 848463847c39Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 848563847c39Smrg # 's' commands which not all seds can handle. GNU sed should be fine 848663847c39Smrg # though. Also, the filter scales superlinearly with the number of 848763847c39Smrg # global variables. join(1) would be nice here, but unfortunately 848863847c39Smrg # isn't a blessed tool. 848963847c39Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 849063847c39Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 849163847c39Smrg export_symbols=$output_objdir/$libname.def 849263847c39Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 849363847c39Smrg fi 849463847c39Smrg fi 849563847c39Smrg 849663847c39Smrg libobjs=$output 849763847c39Smrg # Restore the value of output. 849863847c39Smrg output=$save_output 849963847c39Smrg 850063847c39Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 850163847c39Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 850263847c39Smrg test "X$libobjs" = "X " && libobjs= 850363847c39Smrg fi 850463847c39Smrg # Expand the library linking commands again to reset the 850563847c39Smrg # value of $libobjs for piecewise linking. 850663847c39Smrg 850763847c39Smrg # Do each of the archive commands. 850863847c39Smrg if test "$module" = yes && test -n "$module_cmds" ; then 850963847c39Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 851063847c39Smrg cmds=$module_expsym_cmds 851163847c39Smrg else 851263847c39Smrg cmds=$module_cmds 851363847c39Smrg fi 8514d8556812Smrg else 851563847c39Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 851663847c39Smrg cmds=$archive_expsym_cmds 851763847c39Smrg else 851863847c39Smrg cmds=$archive_cmds 851963847c39Smrg fi 8520d8556812Smrg fi 852163847c39Smrg fi 852286dafe34Smrg 852363847c39Smrg if test -n "$delfiles"; then 852463847c39Smrg # Append the command to remove temporary files to $cmds. 852563847c39Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 852663847c39Smrg fi 852776888252Smrg 852863847c39Smrg # Add any objects from preloaded convenience libraries 852963847c39Smrg if test -n "$dlprefiles"; then 853063847c39Smrg gentop="$output_objdir/${outputname}x" 853163847c39Smrg func_append generated " $gentop" 853276888252Smrg 853363847c39Smrg func_extract_archives $gentop $dlprefiles 853463847c39Smrg func_append libobjs " $func_extract_archives_result" 853563847c39Smrg test "X$libobjs" = "X " && libobjs= 853663847c39Smrg fi 853776888252Smrg 853863847c39Smrg save_ifs="$IFS"; IFS='~' 853963847c39Smrg for cmd in $cmds; do 854063847c39Smrg IFS="$save_ifs" 854163847c39Smrg eval cmd=\"$cmd\" 854263847c39Smrg $opt_silent || { 854363847c39Smrg func_quote_for_expand "$cmd" 854463847c39Smrg eval "func_echo $func_quote_for_expand_result" 854563847c39Smrg } 854663847c39Smrg $opt_dry_run || eval "$cmd" || { 854763847c39Smrg lt_exit=$? 854876888252Smrg 854963847c39Smrg # Restore the uninstalled library and exit 855063847c39Smrg if test "$opt_mode" = relink; then 855163847c39Smrg ( cd "$output_objdir" && \ 855263847c39Smrg $RM "${realname}T" && \ 855363847c39Smrg $MV "${realname}U" "$realname" ) 855463847c39Smrg fi 855576888252Smrg 855663847c39Smrg exit $lt_exit 855763847c39Smrg } 855863847c39Smrg done 855963847c39Smrg IFS="$save_ifs" 856076888252Smrg 856163847c39Smrg # Restore the uninstalled library and exit 856263847c39Smrg if test "$opt_mode" = relink; then 856363847c39Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 856476888252Smrg 856563847c39Smrg if test -n "$convenience"; then 856663847c39Smrg if test -z "$whole_archive_flag_spec"; then 856763847c39Smrg func_show_eval '${RM}r "$gentop"' 856863847c39Smrg fi 856963847c39Smrg fi 857076888252Smrg 857163847c39Smrg exit $EXIT_SUCCESS 857263847c39Smrg fi 857363847c39Smrg 857463847c39Smrg # Create links to the real library. 857563847c39Smrg for linkname in $linknames; do 857663847c39Smrg if test "$realname" != "$linkname"; then 857763847c39Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8578d8556812Smrg fi 8579d8556812Smrg done 858076888252Smrg 858163847c39Smrg # If -module or -export-dynamic was specified, set the dlname. 858263847c39Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 858363847c39Smrg # On all known operating systems, these are identical. 858463847c39Smrg dlname="$soname" 858563847c39Smrg fi 858663847c39Smrg fi 858786dafe34Smrg ;; 858876888252Smrg 858963847c39Smrg obj) 859063847c39Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 859163847c39Smrg func_warning "\`-dlopen' is ignored for objects" 859263847c39Smrg fi 8593d8556812Smrg 859463847c39Smrg case " $deplibs" in 859563847c39Smrg *\ -l* | *\ -L*) 859663847c39Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 859776888252Smrg esac 859876888252Smrg 859963847c39Smrg test -n "$rpath" && \ 860063847c39Smrg func_warning "\`-rpath' is ignored for objects" 860176888252Smrg 860263847c39Smrg test -n "$xrpath" && \ 860363847c39Smrg func_warning "\`-R' is ignored for objects" 860476888252Smrg 860563847c39Smrg test -n "$vinfo" && \ 860663847c39Smrg func_warning "\`-version-info' is ignored for objects" 860763847c39Smrg 860863847c39Smrg test -n "$release" && \ 860963847c39Smrg func_warning "\`-release' is ignored for objects" 861063847c39Smrg 861163847c39Smrg case $output in 861263847c39Smrg *.lo) 861363847c39Smrg test -n "$objs$old_deplibs" && \ 861463847c39Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 861563847c39Smrg 861663847c39Smrg libobj=$output 861763847c39Smrg func_lo2o "$libobj" 861863847c39Smrg obj=$func_lo2o_result 8619d8556812Smrg ;; 8620d8556812Smrg *) 862163847c39Smrg libobj= 862263847c39Smrg obj="$output" 862376888252Smrg ;; 862476888252Smrg esac 862576888252Smrg 862663847c39Smrg # Delete the old objects. 862763847c39Smrg $opt_dry_run || $RM $obj $libobj 862876888252Smrg 862963847c39Smrg # Objects from convenience libraries. This assumes 863063847c39Smrg # single-version convenience libraries. Whenever we create 863163847c39Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 863263847c39Smrg # the extraction. 863363847c39Smrg reload_conv_objs= 863463847c39Smrg gentop= 863563847c39Smrg # reload_cmds runs $LD directly, so let us get rid of 863663847c39Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 863763847c39Smrg # turning comma into space.. 863863847c39Smrg wl= 863976888252Smrg 864063847c39Smrg if test -n "$convenience"; then 864163847c39Smrg if test -n "$whole_archive_flag_spec"; then 864263847c39Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 864363847c39Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 864463847c39Smrg else 864563847c39Smrg gentop="$output_objdir/${obj}x" 864663847c39Smrg func_append generated " $gentop" 8647d8556812Smrg 864863847c39Smrg func_extract_archives $gentop $convenience 864963847c39Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 865063847c39Smrg fi 8651d8556812Smrg fi 8652d8556812Smrg 865363847c39Smrg # If we're not building shared, we need to use non_pic_objs 865463847c39Smrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8655d8556812Smrg 865663847c39Smrg # Create the old-style object. 865763847c39Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8658d8556812Smrg 865963847c39Smrg output="$obj" 866063847c39Smrg func_execute_cmds "$reload_cmds" 'exit $?' 866163847c39Smrg 866263847c39Smrg # Exit if we aren't doing a library object file. 866363847c39Smrg if test -z "$libobj"; then 866463847c39Smrg if test -n "$gentop"; then 866563847c39Smrg func_show_eval '${RM}r "$gentop"' 866663847c39Smrg fi 866763847c39Smrg 866863847c39Smrg exit $EXIT_SUCCESS 8669d8556812Smrg fi 867063847c39Smrg 867163847c39Smrg if test "$build_libtool_libs" != yes; then 867263847c39Smrg if test -n "$gentop"; then 867363847c39Smrg func_show_eval '${RM}r "$gentop"' 867463847c39Smrg fi 867563847c39Smrg 867663847c39Smrg # Create an invalid libtool object if no PIC, so that we don't 867763847c39Smrg # accidentally link it into a program. 867863847c39Smrg # $show "echo timestamp > $libobj" 867963847c39Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 868063847c39Smrg exit $EXIT_SUCCESS 868163847c39Smrg fi 868263847c39Smrg 868363847c39Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 868463847c39Smrg # Only do commands if we really have different PIC objects. 868563847c39Smrg reload_objs="$libobjs $reload_conv_objs" 868663847c39Smrg output="$libobj" 868763847c39Smrg func_execute_cmds "$reload_cmds" 'exit $?' 868863847c39Smrg fi 868963847c39Smrg 869063847c39Smrg if test -n "$gentop"; then 869163847c39Smrg func_show_eval '${RM}r "$gentop"' 869263847c39Smrg fi 869363847c39Smrg 869463847c39Smrg exit $EXIT_SUCCESS 8695d8556812Smrg ;; 869676888252Smrg 869763847c39Smrg prog) 869863847c39Smrg case $host in 869963847c39Smrg *cygwin*) func_stripname '' '.exe' "$output" 870063847c39Smrg output=$func_stripname_result.exe;; 870163847c39Smrg esac 870263847c39Smrg test -n "$vinfo" && \ 870363847c39Smrg func_warning "\`-version-info' is ignored for programs" 870476888252Smrg 870563847c39Smrg test -n "$release" && \ 870663847c39Smrg func_warning "\`-release' is ignored for programs" 870776888252Smrg 870863847c39Smrg test "$preload" = yes \ 870963847c39Smrg && test "$dlopen_support" = unknown \ 871063847c39Smrg && test "$dlopen_self" = unknown \ 871163847c39Smrg && test "$dlopen_self_static" = unknown && \ 871263847c39Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 871363847c39Smrg 871463847c39Smrg case $host in 871563847c39Smrg *-*-rhapsody* | *-*-darwin1.[012]) 871663847c39Smrg # On Rhapsody replace the C library is the System framework 871763847c39Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 871863847c39Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8719d8556812Smrg ;; 872063847c39Smrg esac 8721d8556812Smrg 872263847c39Smrg case $host in 872363847c39Smrg *-*-darwin*) 872463847c39Smrg # Don't allow lazy linking, it breaks C++ global constructors 872563847c39Smrg # But is supposedly fixed on 10.4 or later (yay!). 872663847c39Smrg if test "$tagname" = CXX ; then 872763847c39Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 872863847c39Smrg 10.[0123]) 872963847c39Smrg func_append compile_command " ${wl}-bind_at_load" 873063847c39Smrg func_append finalize_command " ${wl}-bind_at_load" 873163847c39Smrg ;; 873263847c39Smrg esac 8733d8556812Smrg fi 873463847c39Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 873563847c39Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 873663847c39Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 873763847c39Smrg ;; 873863847c39Smrg esac 8739d8556812Smrg 8740d8556812Smrg 874163847c39Smrg # move library search paths that coincide with paths to not yet 874263847c39Smrg # installed libraries to the beginning of the library search list 874363847c39Smrg new_libs= 874463847c39Smrg for path in $notinst_path; do 874563847c39Smrg case " $new_libs " in 874663847c39Smrg *" -L$path/$objdir "*) ;; 874763847c39Smrg *) 874863847c39Smrg case " $compile_deplibs " in 874963847c39Smrg *" -L$path/$objdir "*) 875063847c39Smrg func_append new_libs " -L$path/$objdir" ;; 875186dafe34Smrg esac 875263847c39Smrg ;; 875363847c39Smrg esac 875463847c39Smrg done 875563847c39Smrg for deplib in $compile_deplibs; do 875663847c39Smrg case $deplib in 875763847c39Smrg -L*) 875863847c39Smrg case " $new_libs " in 875963847c39Smrg *" $deplib "*) ;; 876063847c39Smrg *) func_append new_libs " $deplib" ;; 876176888252Smrg esac 876263847c39Smrg ;; 876363847c39Smrg *) func_append new_libs " $deplib" ;; 876463847c39Smrg esac 876563847c39Smrg done 876663847c39Smrg compile_deplibs="$new_libs" 876786dafe34Smrg 8768d8556812Smrg 876963847c39Smrg func_append compile_command " $compile_deplibs" 877063847c39Smrg func_append finalize_command " $finalize_deplibs" 8771d8556812Smrg 877263847c39Smrg if test -n "$rpath$xrpath"; then 877363847c39Smrg # If the user specified any rpath flags, then add them. 877463847c39Smrg for libdir in $rpath $xrpath; do 877563847c39Smrg # This is the magic to use -rpath. 877663847c39Smrg case "$finalize_rpath " in 877763847c39Smrg *" $libdir "*) ;; 877863847c39Smrg *) func_append finalize_rpath " $libdir" ;; 877963847c39Smrg esac 878063847c39Smrg done 878163847c39Smrg fi 8782d8556812Smrg 878363847c39Smrg # Now hardcode the library paths 878463847c39Smrg rpath= 878563847c39Smrg hardcode_libdirs= 878663847c39Smrg for libdir in $compile_rpath $finalize_rpath; do 878763847c39Smrg if test -n "$hardcode_libdir_flag_spec"; then 878863847c39Smrg if test -n "$hardcode_libdir_separator"; then 878963847c39Smrg if test -z "$hardcode_libdirs"; then 879063847c39Smrg hardcode_libdirs="$libdir" 879163847c39Smrg else 879263847c39Smrg # Just accumulate the unique libdirs. 879363847c39Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 879463847c39Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 879563847c39Smrg ;; 879663847c39Smrg *) 879763847c39Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 879863847c39Smrg ;; 879963847c39Smrg esac 880063847c39Smrg fi 8801d8556812Smrg else 880263847c39Smrg eval flag=\"$hardcode_libdir_flag_spec\" 880363847c39Smrg func_append rpath " $flag" 8804d8556812Smrg fi 880563847c39Smrg elif test -n "$runpath_var"; then 880663847c39Smrg case "$perm_rpath " in 880763847c39Smrg *" $libdir "*) ;; 880863847c39Smrg *) func_append perm_rpath " $libdir" ;; 880963847c39Smrg esac 881063847c39Smrg fi 881163847c39Smrg case $host in 881263847c39Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 881363847c39Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 881463847c39Smrg case :$dllsearchpath: in 881563847c39Smrg *":$libdir:"*) ;; 881663847c39Smrg ::) dllsearchpath=$libdir;; 881763847c39Smrg *) func_append dllsearchpath ":$libdir";; 881863847c39Smrg esac 881963847c39Smrg case :$dllsearchpath: in 882063847c39Smrg *":$testbindir:"*) ;; 882163847c39Smrg ::) dllsearchpath=$testbindir;; 882263847c39Smrg *) func_append dllsearchpath ":$testbindir";; 882363847c39Smrg esac 882463847c39Smrg ;; 882563847c39Smrg esac 882663847c39Smrg done 882763847c39Smrg # Substitute the hardcoded libdirs into the rpath. 882863847c39Smrg if test -n "$hardcode_libdir_separator" && 882963847c39Smrg test -n "$hardcode_libdirs"; then 883063847c39Smrg libdir="$hardcode_libdirs" 883163847c39Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 883263847c39Smrg fi 883363847c39Smrg compile_rpath="$rpath" 8834d8556812Smrg 883563847c39Smrg rpath= 883663847c39Smrg hardcode_libdirs= 883763847c39Smrg for libdir in $finalize_rpath; do 883863847c39Smrg if test -n "$hardcode_libdir_flag_spec"; then 883963847c39Smrg if test -n "$hardcode_libdir_separator"; then 884063847c39Smrg if test -z "$hardcode_libdirs"; then 884163847c39Smrg hardcode_libdirs="$libdir" 884263847c39Smrg else 884363847c39Smrg # Just accumulate the unique libdirs. 884463847c39Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 884563847c39Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 884663847c39Smrg ;; 884763847c39Smrg *) 884863847c39Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 884963847c39Smrg ;; 885063847c39Smrg esac 885163847c39Smrg fi 885286dafe34Smrg else 885363847c39Smrg eval flag=\"$hardcode_libdir_flag_spec\" 885463847c39Smrg func_append rpath " $flag" 885586dafe34Smrg fi 885663847c39Smrg elif test -n "$runpath_var"; then 885763847c39Smrg case "$finalize_perm_rpath " in 885863847c39Smrg *" $libdir "*) ;; 885963847c39Smrg *) func_append finalize_perm_rpath " $libdir" ;; 886063847c39Smrg esac 886176888252Smrg fi 886263847c39Smrg done 886363847c39Smrg # Substitute the hardcoded libdirs into the rpath. 886463847c39Smrg if test -n "$hardcode_libdir_separator" && 886563847c39Smrg test -n "$hardcode_libdirs"; then 886663847c39Smrg libdir="$hardcode_libdirs" 886763847c39Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 886863847c39Smrg fi 886963847c39Smrg finalize_rpath="$rpath" 887076888252Smrg 887163847c39Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 887263847c39Smrg # Transform all the library objects into standard objects. 887363847c39Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 887463847c39Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 887563847c39Smrg fi 887676888252Smrg 887763847c39Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 887876888252Smrg 887963847c39Smrg # template prelinking step 888063847c39Smrg if test -n "$prelink_cmds"; then 888163847c39Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 888263847c39Smrg fi 888376888252Smrg 888463847c39Smrg wrappers_required=yes 888563847c39Smrg case $host in 888663847c39Smrg *cegcc* | *mingw32ce*) 888763847c39Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 888863847c39Smrg wrappers_required=no 888963847c39Smrg ;; 889063847c39Smrg *cygwin* | *mingw* ) 889163847c39Smrg if test "$build_libtool_libs" != yes; then 889263847c39Smrg wrappers_required=no 889363847c39Smrg fi 889463847c39Smrg ;; 889563847c39Smrg *) 889663847c39Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 889763847c39Smrg wrappers_required=no 889863847c39Smrg fi 889963847c39Smrg ;; 890063847c39Smrg esac 890163847c39Smrg if test "$wrappers_required" = no; then 890263847c39Smrg # Replace the output file specification. 890363847c39Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 890463847c39Smrg link_command="$compile_command$compile_rpath" 890576888252Smrg 890663847c39Smrg # We have no uninstalled library dependencies, so finalize right now. 890763847c39Smrg exit_status=0 890863847c39Smrg func_show_eval "$link_command" 'exit_status=$?' 890976888252Smrg 891063847c39Smrg if test -n "$postlink_cmds"; then 891163847c39Smrg func_to_tool_file "$output" 891263847c39Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 891363847c39Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 891486dafe34Smrg fi 891576888252Smrg 891663847c39Smrg # Delete the generated files. 891763847c39Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 891863847c39Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 891963847c39Smrg fi 892076888252Smrg 892163847c39Smrg exit $exit_status 892263847c39Smrg fi 892376888252Smrg 892463847c39Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 892563847c39Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 892663847c39Smrg fi 892763847c39Smrg if test -n "$finalize_shlibpath"; then 892863847c39Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 892963847c39Smrg fi 8930d8556812Smrg 893163847c39Smrg compile_var= 893263847c39Smrg finalize_var= 893363847c39Smrg if test -n "$runpath_var"; then 893463847c39Smrg if test -n "$perm_rpath"; then 893563847c39Smrg # We should set the runpath_var. 893663847c39Smrg rpath= 893763847c39Smrg for dir in $perm_rpath; do 893863847c39Smrg func_append rpath "$dir:" 893963847c39Smrg done 894063847c39Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 894176888252Smrg fi 894263847c39Smrg if test -n "$finalize_perm_rpath"; then 894363847c39Smrg # We should set the runpath_var. 894463847c39Smrg rpath= 894563847c39Smrg for dir in $finalize_perm_rpath; do 894663847c39Smrg func_append rpath "$dir:" 894763847c39Smrg done 894863847c39Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 894986dafe34Smrg fi 895063847c39Smrg fi 895176888252Smrg 895263847c39Smrg if test "$no_install" = yes; then 895363847c39Smrg # We don't need to create a wrapper script. 895463847c39Smrg link_command="$compile_var$compile_command$compile_rpath" 895563847c39Smrg # Replace the output file specification. 895663847c39Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 895763847c39Smrg # Delete the old output file. 895863847c39Smrg $opt_dry_run || $RM $output 895963847c39Smrg # Link the executable and exit 896063847c39Smrg func_show_eval "$link_command" 'exit $?' 896176888252Smrg 896263847c39Smrg if test -n "$postlink_cmds"; then 896363847c39Smrg func_to_tool_file "$output" 896463847c39Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 896563847c39Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8966d8556812Smrg fi 896763847c39Smrg 8968d8556812Smrg exit $EXIT_SUCCESS 896963847c39Smrg fi 897076888252Smrg 897163847c39Smrg if test "$hardcode_action" = relink; then 897263847c39Smrg # Fast installation is not supported 897363847c39Smrg link_command="$compile_var$compile_command$compile_rpath" 897463847c39Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 897563847c39Smrg 897663847c39Smrg func_warning "this platform does not like uninstalled shared libraries" 897763847c39Smrg func_warning "\`$output' will be relinked during installation" 897863847c39Smrg else 897963847c39Smrg if test "$fast_install" != no; then 898063847c39Smrg link_command="$finalize_var$compile_command$finalize_rpath" 898163847c39Smrg if test "$fast_install" = yes; then 898263847c39Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 898363847c39Smrg else 898463847c39Smrg # fast_install is set to needless 898563847c39Smrg relink_command= 898663847c39Smrg fi 898776888252Smrg else 898863847c39Smrg link_command="$compile_var$compile_command$compile_rpath" 898963847c39Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 899076888252Smrg fi 899163847c39Smrg fi 899276888252Smrg 899363847c39Smrg # Replace the output file specification. 899463847c39Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 899576888252Smrg 899663847c39Smrg # Delete the old output files. 899763847c39Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 899876888252Smrg 899963847c39Smrg func_show_eval "$link_command" 'exit $?' 900076888252Smrg 900163847c39Smrg if test -n "$postlink_cmds"; then 900263847c39Smrg func_to_tool_file "$output_objdir/$outputname" 900363847c39Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 900463847c39Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 900563847c39Smrg fi 9006d8556812Smrg 900763847c39Smrg # Now create the wrapper script. 900863847c39Smrg func_verbose "creating $output" 9009d8556812Smrg 901063847c39Smrg # Quote the relink command for shipping. 901163847c39Smrg if test -n "$relink_command"; then 901263847c39Smrg # Preserve any variables that may affect compiler behavior 901363847c39Smrg for var in $variables_saved_for_relink; do 901463847c39Smrg if eval test -z \"\${$var+set}\"; then 901563847c39Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 901663847c39Smrg elif eval var_value=\$$var; test -z "$var_value"; then 901763847c39Smrg relink_command="$var=; export $var; $relink_command" 901886dafe34Smrg else 901963847c39Smrg func_quote_for_eval "$var_value" 902063847c39Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 902186dafe34Smrg fi 902263847c39Smrg done 902363847c39Smrg relink_command="(cd `pwd`; $relink_command)" 902463847c39Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 902563847c39Smrg fi 902663847c39Smrg 902763847c39Smrg # Only actually do things if not in dry run mode. 902863847c39Smrg $opt_dry_run || { 902963847c39Smrg # win32 will think the script is a binary if it has 903063847c39Smrg # a .exe suffix, so we strip it off here. 903163847c39Smrg case $output in 903263847c39Smrg *.exe) func_stripname '' '.exe' "$output" 903363847c39Smrg output=$func_stripname_result ;; 903476888252Smrg esac 903563847c39Smrg # test for cygwin because mv fails w/o .exe extensions 903663847c39Smrg case $host in 903763847c39Smrg *cygwin*) 903863847c39Smrg exeext=.exe 903963847c39Smrg func_stripname '' '.exe' "$outputname" 904063847c39Smrg outputname=$func_stripname_result ;; 904163847c39Smrg *) exeext= ;; 904263847c39Smrg esac 904363847c39Smrg case $host in 904463847c39Smrg *cygwin* | *mingw* ) 904563847c39Smrg func_dirname_and_basename "$output" "" "." 904663847c39Smrg output_name=$func_basename_result 904763847c39Smrg output_path=$func_dirname_result 904863847c39Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 904963847c39Smrg cwrapper="$output_path/$output_name.exe" 905063847c39Smrg $RM $cwrappersource $cwrapper 905163847c39Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 905263847c39Smrg 905363847c39Smrg func_emit_cwrapperexe_src > $cwrappersource 905463847c39Smrg 905563847c39Smrg # The wrapper executable is built using the $host compiler, 905663847c39Smrg # because it contains $host paths and files. If cross- 905763847c39Smrg # compiling, it, like the target executable, must be 905863847c39Smrg # executed on the $host or under an emulation environment. 905963847c39Smrg $opt_dry_run || { 906063847c39Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 906163847c39Smrg $STRIP $cwrapper 906263847c39Smrg } 906376888252Smrg 906463847c39Smrg # Now, create the wrapper script for func_source use: 906563847c39Smrg func_ltwrapper_scriptname $cwrapper 906663847c39Smrg $RM $func_ltwrapper_scriptname_result 906763847c39Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 906863847c39Smrg $opt_dry_run || { 906963847c39Smrg # note: this script will not be executed, so do not chmod. 907063847c39Smrg if test "x$build" = "x$host" ; then 907163847c39Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 907263847c39Smrg else 907363847c39Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 907463847c39Smrg fi 907563847c39Smrg } 907663847c39Smrg ;; 907763847c39Smrg * ) 907863847c39Smrg $RM $output 907963847c39Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 908076888252Smrg 908163847c39Smrg func_emit_wrapper no > $output 908263847c39Smrg chmod +x $output 908363847c39Smrg ;; 908463847c39Smrg esac 908563847c39Smrg } 908663847c39Smrg exit $EXIT_SUCCESS 908763847c39Smrg ;; 908863847c39Smrg esac 908976888252Smrg 909063847c39Smrg # See if we need to build an old-fashioned archive. 909163847c39Smrg for oldlib in $oldlibs; do 909276888252Smrg 909363847c39Smrg if test "$build_libtool_libs" = convenience; then 909463847c39Smrg oldobjs="$libobjs_save $symfileobj" 909563847c39Smrg addlibs="$convenience" 909663847c39Smrg build_libtool_libs=no 909763847c39Smrg else 909863847c39Smrg if test "$build_libtool_libs" = module; then 909963847c39Smrg oldobjs="$libobjs_save" 910063847c39Smrg build_libtool_libs=no 910163847c39Smrg else 910263847c39Smrg oldobjs="$old_deplibs $non_pic_objects" 910363847c39Smrg if test "$preload" = yes && test -f "$symfileobj"; then 910463847c39Smrg func_append oldobjs " $symfileobj" 910563847c39Smrg fi 910663847c39Smrg fi 910763847c39Smrg addlibs="$old_convenience" 910876888252Smrg fi 910976888252Smrg 911063847c39Smrg if test -n "$addlibs"; then 911163847c39Smrg gentop="$output_objdir/${outputname}x" 911263847c39Smrg func_append generated " $gentop" 911376888252Smrg 911463847c39Smrg func_extract_archives $gentop $addlibs 911563847c39Smrg func_append oldobjs " $func_extract_archives_result" 911663847c39Smrg fi 911776888252Smrg 911863847c39Smrg # Do each command in the archive commands. 911963847c39Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 912063847c39Smrg cmds=$old_archive_from_new_cmds 912163847c39Smrg else 912276888252Smrg 912363847c39Smrg # Add any objects from preloaded convenience libraries 912463847c39Smrg if test -n "$dlprefiles"; then 912563847c39Smrg gentop="$output_objdir/${outputname}x" 912663847c39Smrg func_append generated " $gentop" 912776888252Smrg 912863847c39Smrg func_extract_archives $gentop $dlprefiles 912963847c39Smrg func_append oldobjs " $func_extract_archives_result" 913063847c39Smrg fi 913176888252Smrg 913263847c39Smrg # POSIX demands no paths to be encoded in archives. We have 913363847c39Smrg # to avoid creating archives with duplicate basenames if we 913463847c39Smrg # might have to extract them afterwards, e.g., when creating a 913563847c39Smrg # static archive out of a convenience library, or when linking 913663847c39Smrg # the entirety of a libtool archive into another (currently 913763847c39Smrg # not supported by libtool). 913863847c39Smrg if (for obj in $oldobjs 913963847c39Smrg do 914063847c39Smrg func_basename "$obj" 914163847c39Smrg $ECHO "$func_basename_result" 914263847c39Smrg done | sort | sort -uc >/dev/null 2>&1); then 914363847c39Smrg : 914463847c39Smrg else 914563847c39Smrg echo "copying selected object files to avoid basename conflicts..." 914663847c39Smrg gentop="$output_objdir/${outputname}x" 914763847c39Smrg func_append generated " $gentop" 914863847c39Smrg func_mkdir_p "$gentop" 914963847c39Smrg save_oldobjs=$oldobjs 915063847c39Smrg oldobjs= 915163847c39Smrg counter=1 915263847c39Smrg for obj in $save_oldobjs 915363847c39Smrg do 915463847c39Smrg func_basename "$obj" 915563847c39Smrg objbase="$func_basename_result" 915663847c39Smrg case " $oldobjs " in 915763847c39Smrg " ") oldobjs=$obj ;; 915863847c39Smrg *[\ /]"$objbase "*) 915963847c39Smrg while :; do 916063847c39Smrg # Make sure we don't pick an alternate name that also 916163847c39Smrg # overlaps. 916263847c39Smrg newobj=lt$counter-$objbase 916363847c39Smrg func_arith $counter + 1 916463847c39Smrg counter=$func_arith_result 916563847c39Smrg case " $oldobjs " in 916663847c39Smrg *[\ /]"$newobj "*) ;; 916763847c39Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 916863847c39Smrg esac 916963847c39Smrg done 917063847c39Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 917163847c39Smrg func_append oldobjs " $gentop/$newobj" 917263847c39Smrg ;; 917363847c39Smrg *) func_append oldobjs " $obj" ;; 917463847c39Smrg esac 917576888252Smrg done 917686dafe34Smrg fi 917763847c39Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 917863847c39Smrg tool_oldlib=$func_to_tool_file_result 917963847c39Smrg eval cmds=\"$old_archive_cmds\" 9180d8556812Smrg 918163847c39Smrg func_len " $cmds" 918263847c39Smrg len=$func_len_result 918363847c39Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 918463847c39Smrg cmds=$old_archive_cmds 918563847c39Smrg elif test -n "$archiver_list_spec"; then 918663847c39Smrg func_verbose "using command file archive linking..." 918763847c39Smrg for obj in $oldobjs 918863847c39Smrg do 918963847c39Smrg func_to_tool_file "$obj" 919063847c39Smrg $ECHO "$func_to_tool_file_result" 919163847c39Smrg done > $output_objdir/$libname.libcmd 919263847c39Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 919363847c39Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 919463847c39Smrg cmds=$old_archive_cmds 919563847c39Smrg else 919663847c39Smrg # the command line is too long to link in one step, link in parts 919763847c39Smrg func_verbose "using piecewise archive linking..." 919863847c39Smrg save_RANLIB=$RANLIB 919963847c39Smrg RANLIB=: 920063847c39Smrg objlist= 920163847c39Smrg concat_cmds= 920263847c39Smrg save_oldobjs=$oldobjs 920363847c39Smrg oldobjs= 920463847c39Smrg # Is there a better way of finding the last object in the list? 920563847c39Smrg for obj in $save_oldobjs 920663847c39Smrg do 920763847c39Smrg last_oldobj=$obj 920863847c39Smrg done 920963847c39Smrg eval test_cmds=\"$old_archive_cmds\" 921063847c39Smrg func_len " $test_cmds" 921163847c39Smrg len0=$func_len_result 921263847c39Smrg len=$len0 921363847c39Smrg for obj in $save_oldobjs 921463847c39Smrg do 921563847c39Smrg func_len " $obj" 921663847c39Smrg func_arith $len + $func_len_result 921763847c39Smrg len=$func_arith_result 921863847c39Smrg func_append objlist " $obj" 921963847c39Smrg if test "$len" -lt "$max_cmd_len"; then 922063847c39Smrg : 922163847c39Smrg else 922263847c39Smrg # the above command should be used before it gets too long 922363847c39Smrg oldobjs=$objlist 922463847c39Smrg if test "$obj" = "$last_oldobj" ; then 922563847c39Smrg RANLIB=$save_RANLIB 922663847c39Smrg fi 922763847c39Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 922863847c39Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 922963847c39Smrg objlist= 923063847c39Smrg len=$len0 923163847c39Smrg fi 923263847c39Smrg done 923363847c39Smrg RANLIB=$save_RANLIB 923463847c39Smrg oldobjs=$objlist 923563847c39Smrg if test "X$oldobjs" = "X" ; then 923663847c39Smrg eval cmds=\"\$concat_cmds\" 923763847c39Smrg else 923863847c39Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 923963847c39Smrg fi 924063847c39Smrg fi 924163847c39Smrg fi 924263847c39Smrg func_execute_cmds "$cmds" 'exit $?' 924376888252Smrg done 924476888252Smrg 924563847c39Smrg test -n "$generated" && \ 924663847c39Smrg func_show_eval "${RM}r$generated" 924776888252Smrg 924863847c39Smrg # Now create the libtool archive. 924963847c39Smrg case $output in 925063847c39Smrg *.la) 925163847c39Smrg old_library= 925263847c39Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 925363847c39Smrg func_verbose "creating $output" 925486dafe34Smrg 925563847c39Smrg # Preserve any variables that may affect compiler behavior 925663847c39Smrg for var in $variables_saved_for_relink; do 925763847c39Smrg if eval test -z \"\${$var+set}\"; then 925863847c39Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 925963847c39Smrg elif eval var_value=\$$var; test -z "$var_value"; then 926063847c39Smrg relink_command="$var=; export $var; $relink_command" 9261d8556812Smrg else 926263847c39Smrg func_quote_for_eval "$var_value" 926363847c39Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9264d8556812Smrg fi 926563847c39Smrg done 926663847c39Smrg # Quote the link command for shipping. 926763847c39Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 926863847c39Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 926963847c39Smrg if test "$hardcode_automatic" = yes ; then 927063847c39Smrg relink_command= 927163847c39Smrg fi 927276888252Smrg 927363847c39Smrg # Only create the output if not a dry run. 927463847c39Smrg $opt_dry_run || { 927563847c39Smrg for installed in no yes; do 927663847c39Smrg if test "$installed" = yes; then 927763847c39Smrg if test -z "$install_libdir"; then 927863847c39Smrg break 927963847c39Smrg fi 928063847c39Smrg output="$output_objdir/$outputname"i 928163847c39Smrg # Replace all uninstalled libtool libraries with the installed ones 928263847c39Smrg newdependency_libs= 928363847c39Smrg for deplib in $dependency_libs; do 928463847c39Smrg case $deplib in 928563847c39Smrg *.la) 928663847c39Smrg func_basename "$deplib" 928763847c39Smrg name="$func_basename_result" 928863847c39Smrg func_resolve_sysroot "$deplib" 928963847c39Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 929063847c39Smrg test -z "$libdir" && \ 929163847c39Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 929263847c39Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 929363847c39Smrg ;; 929463847c39Smrg -L*) 929563847c39Smrg func_stripname -L '' "$deplib" 929663847c39Smrg func_replace_sysroot "$func_stripname_result" 929763847c39Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 929863847c39Smrg ;; 929963847c39Smrg -R*) 930063847c39Smrg func_stripname -R '' "$deplib" 930163847c39Smrg func_replace_sysroot "$func_stripname_result" 930263847c39Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 930363847c39Smrg ;; 930463847c39Smrg *) func_append newdependency_libs " $deplib" ;; 930563847c39Smrg esac 930663847c39Smrg done 930763847c39Smrg dependency_libs="$newdependency_libs" 930863847c39Smrg newdlfiles= 930963847c39Smrg 931063847c39Smrg for lib in $dlfiles; do 931163847c39Smrg case $lib in 931263847c39Smrg *.la) 931363847c39Smrg func_basename "$lib" 931463847c39Smrg name="$func_basename_result" 931563847c39Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 931663847c39Smrg test -z "$libdir" && \ 931763847c39Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 931863847c39Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 931963847c39Smrg ;; 932063847c39Smrg *) func_append newdlfiles " $lib" ;; 932163847c39Smrg esac 932263847c39Smrg done 932363847c39Smrg dlfiles="$newdlfiles" 932463847c39Smrg newdlprefiles= 932563847c39Smrg for lib in $dlprefiles; do 932663847c39Smrg case $lib in 932763847c39Smrg *.la) 932863847c39Smrg # Only pass preopened files to the pseudo-archive (for 932963847c39Smrg # eventual linking with the app. that links it) if we 933063847c39Smrg # didn't already link the preopened objects directly into 933163847c39Smrg # the library: 933263847c39Smrg func_basename "$lib" 933363847c39Smrg name="$func_basename_result" 933463847c39Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 933563847c39Smrg test -z "$libdir" && \ 933663847c39Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 933763847c39Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 933863847c39Smrg ;; 933963847c39Smrg esac 934063847c39Smrg done 934163847c39Smrg dlprefiles="$newdlprefiles" 934263847c39Smrg else 934363847c39Smrg newdlfiles= 934463847c39Smrg for lib in $dlfiles; do 934563847c39Smrg case $lib in 934663847c39Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 934763847c39Smrg *) abs=`pwd`"/$lib" ;; 934863847c39Smrg esac 934963847c39Smrg func_append newdlfiles " $abs" 935063847c39Smrg done 935163847c39Smrg dlfiles="$newdlfiles" 935263847c39Smrg newdlprefiles= 935363847c39Smrg for lib in $dlprefiles; do 935463847c39Smrg case $lib in 935563847c39Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 935663847c39Smrg *) abs=`pwd`"/$lib" ;; 935763847c39Smrg esac 935863847c39Smrg func_append newdlprefiles " $abs" 935963847c39Smrg done 936063847c39Smrg dlprefiles="$newdlprefiles" 936163847c39Smrg fi 936263847c39Smrg $RM $output 936363847c39Smrg # place dlname in correct position for cygwin 936463847c39Smrg # In fact, it would be nice if we could use this code for all target 936563847c39Smrg # systems that can't hard-code library paths into their executables 936663847c39Smrg # and that have no shared library path variable independent of PATH, 936763847c39Smrg # but it turns out we can't easily determine that from inspecting 936863847c39Smrg # libtool variables, so we have to hard-code the OSs to which it 936963847c39Smrg # applies here; at the moment, that means platforms that use the PE 937063847c39Smrg # object format with DLL files. See the long comment at the top of 937163847c39Smrg # tests/bindir.at for full details. 937263847c39Smrg tdlname=$dlname 937363847c39Smrg case $host,$output,$installed,$module,$dlname in 937463847c39Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 937563847c39Smrg # If a -bindir argument was supplied, place the dll there. 937663847c39Smrg if test "x$bindir" != x ; 937763847c39Smrg then 937863847c39Smrg func_relative_path "$install_libdir" "$bindir" 937963847c39Smrg tdlname=$func_relative_path_result$dlname 938063847c39Smrg else 938163847c39Smrg # Otherwise fall back on heuristic. 938263847c39Smrg tdlname=../bin/$dlname 938363847c39Smrg fi 938463847c39Smrg ;; 938563847c39Smrg esac 938663847c39Smrg $ECHO > $output "\ 938763847c39Smrg# $outputname - a libtool library file 938863847c39Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 938963847c39Smrg# 939063847c39Smrg# Please DO NOT delete this file! 939163847c39Smrg# It is necessary for linking the library. 939276888252Smrg 939363847c39Smrg# The name that we can dlopen(3). 939463847c39Smrgdlname='$tdlname' 939576888252Smrg 939663847c39Smrg# Names of this library. 939763847c39Smrglibrary_names='$library_names' 939876888252Smrg 939963847c39Smrg# The name of the static archive. 940063847c39Smrgold_library='$old_library' 940176888252Smrg 940263847c39Smrg# Linker flags that can not go in dependency_libs. 940363847c39Smrginherited_linker_flags='$new_inherited_linker_flags' 940476888252Smrg 940563847c39Smrg# Libraries that this one depends upon. 940663847c39Smrgdependency_libs='$dependency_libs' 940776888252Smrg 940863847c39Smrg# Names of additional weak libraries provided by this library 940963847c39Smrgweak_library_names='$weak_libs' 941076888252Smrg 941163847c39Smrg# Version information for $libname. 941263847c39Smrgcurrent=$current 941363847c39Smrgage=$age 941463847c39Smrgrevision=$revision 941576888252Smrg 941663847c39Smrg# Is this an already installed library? 941763847c39Smrginstalled=$installed 941876888252Smrg 941963847c39Smrg# Should we warn about portability when linking against -modules? 942063847c39Smrgshouldnotlink=$module 942176888252Smrg 942263847c39Smrg# Files to dlopen/dlpreopen 942363847c39Smrgdlopen='$dlfiles' 942463847c39Smrgdlpreopen='$dlprefiles' 942576888252Smrg 942663847c39Smrg# Directory that this library needs to be installed in: 942763847c39Smrglibdir='$install_libdir'" 942863847c39Smrg if test "$installed" = no && test "$need_relink" = yes; then 942963847c39Smrg $ECHO >> $output "\ 943063847c39Smrgrelink_command=\"$relink_command\"" 943163847c39Smrg fi 943263847c39Smrg done 943363847c39Smrg } 943476888252Smrg 943563847c39Smrg # Do a symbolic link so that the libtool archive can be found in 943663847c39Smrg # LD_LIBRARY_PATH before the program is installed. 943763847c39Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 943863847c39Smrg ;; 943963847c39Smrg esac 944063847c39Smrg exit $EXIT_SUCCESS 944163847c39Smrg} 9442d8556812Smrg 944363847c39Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 944463847c39Smrg func_mode_link ${1+"$@"} 944576888252Smrg 944676888252Smrg 944763847c39Smrg# func_mode_uninstall arg... 944863847c39Smrgfunc_mode_uninstall () 944963847c39Smrg{ 945063847c39Smrg $opt_debug 945163847c39Smrg RM="$nonopt" 945276888252Smrg files= 945376888252Smrg rmforce= 945476888252Smrg exit_status=0 945576888252Smrg 945676888252Smrg # This variable tells wrapper scripts just to set variables rather 945776888252Smrg # than running their programs. 945876888252Smrg libtool_install_magic="$magic" 945976888252Smrg 946076888252Smrg for arg 946176888252Smrg do 946276888252Smrg case $arg in 946363847c39Smrg -f) func_append RM " $arg"; rmforce=yes ;; 946463847c39Smrg -*) func_append RM " $arg" ;; 946563847c39Smrg *) func_append files " $arg" ;; 946676888252Smrg esac 946776888252Smrg done 946876888252Smrg 946963847c39Smrg test -z "$RM" && \ 947063847c39Smrg func_fatal_help "you must specify an RM program" 947176888252Smrg 947276888252Smrg rmdirs= 947376888252Smrg 947476888252Smrg for file in $files; do 947563847c39Smrg func_dirname "$file" "" "." 947663847c39Smrg dir="$func_dirname_result" 947763847c39Smrg if test "X$dir" = X.; then 947863847c39Smrg odir="$objdir" 947976888252Smrg else 948063847c39Smrg odir="$dir/$objdir" 948176888252Smrg fi 948263847c39Smrg func_basename "$file" 948363847c39Smrg name="$func_basename_result" 948463847c39Smrg test "$opt_mode" = uninstall && odir="$dir" 948576888252Smrg 948663847c39Smrg # Remember odir for removal later, being careful to avoid duplicates 948763847c39Smrg if test "$opt_mode" = clean; then 948876888252Smrg case " $rmdirs " in 948963847c39Smrg *" $odir "*) ;; 949063847c39Smrg *) func_append rmdirs " $odir" ;; 949176888252Smrg esac 949276888252Smrg fi 949376888252Smrg 949476888252Smrg # Don't error if the file doesn't exist and rm -f was used. 949563847c39Smrg if { test -L "$file"; } >/dev/null 2>&1 || 949663847c39Smrg { test -h "$file"; } >/dev/null 2>&1 || 949763847c39Smrg test -f "$file"; then 949876888252Smrg : 949976888252Smrg elif test -d "$file"; then 950076888252Smrg exit_status=1 950176888252Smrg continue 950276888252Smrg elif test "$rmforce" = yes; then 950376888252Smrg continue 950476888252Smrg fi 950576888252Smrg 950676888252Smrg rmfiles="$file" 950776888252Smrg 950876888252Smrg case $name in 950976888252Smrg *.la) 951076888252Smrg # Possibly a libtool archive, so verify it. 951163847c39Smrg if func_lalib_p "$file"; then 951263847c39Smrg func_source $dir/$name 951376888252Smrg 951476888252Smrg # Delete the libtool libraries and symlinks. 951576888252Smrg for n in $library_names; do 951663847c39Smrg func_append rmfiles " $odir/$n" 951776888252Smrg done 951863847c39Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 951976888252Smrg 952063847c39Smrg case "$opt_mode" in 952176888252Smrg clean) 952263847c39Smrg case " $library_names " in 952376888252Smrg *" $dlname "*) ;; 952463847c39Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 952576888252Smrg esac 952663847c39Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 952776888252Smrg ;; 952876888252Smrg uninstall) 952976888252Smrg if test -n "$library_names"; then 953076888252Smrg # Do each command in the postuninstall commands. 953163847c39Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 953276888252Smrg fi 953376888252Smrg 953476888252Smrg if test -n "$old_library"; then 953576888252Smrg # Do each command in the old_postuninstall commands. 953663847c39Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 953776888252Smrg fi 953876888252Smrg # FIXME: should reinstall the best remaining shared library. 953976888252Smrg ;; 954076888252Smrg esac 954176888252Smrg fi 954276888252Smrg ;; 954376888252Smrg 954476888252Smrg *.lo) 954576888252Smrg # Possibly a libtool object, so verify it. 954663847c39Smrg if func_lalib_p "$file"; then 954776888252Smrg 954876888252Smrg # Read the .lo file 954963847c39Smrg func_source $dir/$name 955076888252Smrg 955176888252Smrg # Add PIC object to the list of files to remove. 955263847c39Smrg if test -n "$pic_object" && 955363847c39Smrg test "$pic_object" != none; then 955463847c39Smrg func_append rmfiles " $dir/$pic_object" 955576888252Smrg fi 955676888252Smrg 955776888252Smrg # Add non-PIC object to the list of files to remove. 955863847c39Smrg if test -n "$non_pic_object" && 955963847c39Smrg test "$non_pic_object" != none; then 956063847c39Smrg func_append rmfiles " $dir/$non_pic_object" 956176888252Smrg fi 956276888252Smrg fi 956376888252Smrg ;; 956476888252Smrg 956576888252Smrg *) 956663847c39Smrg if test "$opt_mode" = clean ; then 956776888252Smrg noexename=$name 956876888252Smrg case $file in 956976888252Smrg *.exe) 957063847c39Smrg func_stripname '' '.exe' "$file" 957163847c39Smrg file=$func_stripname_result 957263847c39Smrg func_stripname '' '.exe' "$name" 957363847c39Smrg noexename=$func_stripname_result 957476888252Smrg # $file with .exe has already been added to rmfiles, 957576888252Smrg # add $file without .exe 957663847c39Smrg func_append rmfiles " $file" 957776888252Smrg ;; 957876888252Smrg esac 957976888252Smrg # Do a test to see if this is a libtool program. 958063847c39Smrg if func_ltwrapper_p "$file"; then 958163847c39Smrg if func_ltwrapper_executable_p "$file"; then 958263847c39Smrg func_ltwrapper_scriptname "$file" 958363847c39Smrg relink_command= 958463847c39Smrg func_source $func_ltwrapper_scriptname_result 958563847c39Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 958663847c39Smrg else 958763847c39Smrg relink_command= 958863847c39Smrg func_source $dir/$noexename 958963847c39Smrg fi 959076888252Smrg 959176888252Smrg # note $name still contains .exe if it was in $file originally 959276888252Smrg # as does the version of $file that was added into $rmfiles 959363847c39Smrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 959476888252Smrg if test "$fast_install" = yes && test -n "$relink_command"; then 959563847c39Smrg func_append rmfiles " $odir/lt-$name" 959676888252Smrg fi 959776888252Smrg if test "X$noexename" != "X$name" ; then 959863847c39Smrg func_append rmfiles " $odir/lt-${noexename}.c" 959976888252Smrg fi 960076888252Smrg fi 960176888252Smrg fi 960276888252Smrg ;; 960376888252Smrg esac 960463847c39Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 960576888252Smrg done 960676888252Smrg 960776888252Smrg # Try to remove the ${objdir}s in the directories where we deleted files 960876888252Smrg for dir in $rmdirs; do 960976888252Smrg if test -d "$dir"; then 961063847c39Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 961176888252Smrg fi 961276888252Smrg done 961376888252Smrg 961476888252Smrg exit $exit_status 961563847c39Smrg} 961676888252Smrg 961763847c39Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 961863847c39Smrg func_mode_uninstall ${1+"$@"} 961986dafe34Smrg 962063847c39Smrgtest -z "$opt_mode" && { 962163847c39Smrg help="$generic_help" 962263847c39Smrg func_fatal_help "you must specify a MODE" 962363847c39Smrg} 962463847c39Smrg 962563847c39Smrgtest -z "$exec_cmd" && \ 962663847c39Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 962776888252Smrg 962876888252Smrgif test -n "$exec_cmd"; then 962963847c39Smrg eval exec "$exec_cmd" 963076888252Smrg exit $EXIT_FAILURE 963176888252Smrgfi 963276888252Smrg 963363847c39Smrgexit $exit_status 9634d8556812Smrg 963576888252Smrg 963676888252Smrg# The TAGs below are defined such that we never get into a situation 963776888252Smrg# in which we disable both kinds of libraries. Given conflicting 963876888252Smrg# choices, we go for a static library, that is the most portable, 963976888252Smrg# since we can't tell whether shared libraries were disabled because 964076888252Smrg# the user asked for that or because the platform doesn't support 964176888252Smrg# them. This is particularly important on AIX, because we don't 964276888252Smrg# support having both static and shared libraries enabled at the same 964376888252Smrg# time on that platform, so we default to a shared-only configuration. 964476888252Smrg# If a disable-shared tag is given, we'll fallback to a static-only 964576888252Smrg# configuration. But we'll never go from static-only to shared-only. 964676888252Smrg 964776888252Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 964863847c39Smrgbuild_libtool_libs=no 964963847c39Smrgbuild_old_libs=yes 965076888252Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 965176888252Smrg 965276888252Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 965363847c39Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 965476888252Smrg# ### END LIBTOOL TAG CONFIG: disable-static 965576888252Smrg 965676888252Smrg# Local Variables: 965776888252Smrg# mode:shell-script 965876888252Smrg# sh-indentation:2 965976888252Smrg# End: 966063847c39Smrg# vi:sw=2 966163847c39Smrg 9662