ltmain.sh revision 89c04b6c
19c9ff80cSmrg 289c04b6cSmrg# libtool (GNU libtool) 2.4.2 39c9ff80cSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 49c9ff80cSmrg 56fae4e5dSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 689c04b6cSmrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 79c9ff80cSmrg# This is free software; see the source for copying conditions. There is NO 89c9ff80cSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 99c9ff80cSmrg 109c9ff80cSmrg# GNU Libtool is free software; you can redistribute it and/or modify 111f0ac6a5Smrg# it under the terms of the GNU General Public License as published by 121f0ac6a5Smrg# the Free Software Foundation; either version 2 of the License, or 131f0ac6a5Smrg# (at your option) any later version. 141f0ac6a5Smrg# 159c9ff80cSmrg# As a special exception to the GNU General Public License, 169c9ff80cSmrg# if you distribute this file as part of a program or library that 179c9ff80cSmrg# is built using GNU Libtool, you may include this file under the 189c9ff80cSmrg# same distribution terms that you use for the rest of that program. 199c9ff80cSmrg# 209c9ff80cSmrg# GNU Libtool is distributed in the hope that it will be useful, but 211f0ac6a5Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 221f0ac6a5Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 231f0ac6a5Smrg# General Public License for more details. 241f0ac6a5Smrg# 251f0ac6a5Smrg# You should have received a copy of the GNU General Public License 269c9ff80cSmrg# along with GNU Libtool; see the file COPYING. If not, a copy 279c9ff80cSmrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 289c9ff80cSmrg# or obtained by writing to the Free Software Foundation, Inc., 299c9ff80cSmrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 301f0ac6a5Smrg 319c9ff80cSmrg# Usage: $progname [OPTION]... [MODE-ARG]... 329c9ff80cSmrg# 339c9ff80cSmrg# Provide generalized library-building support services. 349c9ff80cSmrg# 356fae4e5dSmrg# --config show all configuration variables 366fae4e5dSmrg# --debug enable verbose shell tracing 376fae4e5dSmrg# -n, --dry-run display commands without modifying any files 386fae4e5dSmrg# --features display basic configuration information and exit 396fae4e5dSmrg# --mode=MODE use operation mode MODE 406fae4e5dSmrg# --preserve-dup-deps don't remove duplicate dependency libraries 416fae4e5dSmrg# --quiet, --silent don't print informational messages 426fae4e5dSmrg# --no-quiet, --no-silent 436fae4e5dSmrg# print informational messages (default) 4489c04b6cSmrg# --no-warn don't display warning messages 456fae4e5dSmrg# --tag=TAG use configuration variables from tag TAG 466fae4e5dSmrg# -v, --verbose print more informational messages than default 476fae4e5dSmrg# --no-verbose don't print the extra informational messages 486fae4e5dSmrg# --version print version information 496fae4e5dSmrg# -h, --help, --help-all print short, long, or detailed help message 509c9ff80cSmrg# 519c9ff80cSmrg# MODE must be one of the following: 529c9ff80cSmrg# 536fae4e5dSmrg# clean remove files from the build directory 546fae4e5dSmrg# compile compile a source file into a libtool object 556fae4e5dSmrg# execute automatically set library path, then run a program 566fae4e5dSmrg# finish complete the installation of libtool libraries 576fae4e5dSmrg# install install libraries or executables 586fae4e5dSmrg# link create a library or an executable 596fae4e5dSmrg# uninstall remove libraries from an installed directory 609c9ff80cSmrg# 616fae4e5dSmrg# MODE-ARGS vary depending on the MODE. When passed as first option, 626fae4e5dSmrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 639c9ff80cSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 649c9ff80cSmrg# 659c9ff80cSmrg# When reporting a bug, please describe a test case to reproduce it and 669c9ff80cSmrg# include the following information: 679c9ff80cSmrg# 686fae4e5dSmrg# host-triplet: $host 696fae4e5dSmrg# shell: $SHELL 706fae4e5dSmrg# compiler: $LTCC 716fae4e5dSmrg# compiler flags: $LTCFLAGS 726fae4e5dSmrg# linker: $LD (gnu? $with_gnu_ld) 7389c04b6cSmrg# $progname: (GNU libtool) 2.4.2 746fae4e5dSmrg# automake: $automake_version 756fae4e5dSmrg# autoconf: $autoconf_version 769c9ff80cSmrg# 779c9ff80cSmrg# Report bugs to <bug-libtool@gnu.org>. 786fae4e5dSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 796fae4e5dSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 801f0ac6a5Smrg 816fae4e5dSmrgPROGRAM=libtool 821f0ac6a5SmrgPACKAGE=libtool 8389c04b6cSmrgVERSION=2.4.2 849c9ff80cSmrgTIMESTAMP="" 8589c04b6cSmrgpackage_revision=1.3337 86e5410a46Smrg 879c9ff80cSmrg# Be Bourne compatible 88e5410a46Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 89e5410a46Smrg emulate sh 90e5410a46Smrg NULLCMD=: 91e5410a46Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 92e5410a46Smrg # is contrary to our usage. Disable this feature. 93e5410a46Smrg alias -g '${1+"$@"}'='"$@"' 941f0ac6a5Smrg setopt NO_GLOB_SUBST 95e5410a46Smrgelse 96e5410a46Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 971f0ac6a5Smrgfi 98e5410a46SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 99e5410a46SmrgDUALCASE=1; export DUALCASE # for MKS sh 1001f0ac6a5Smrg 1016fae4e5dSmrg# A function that is used when there is no print builtin or printf. 1026fae4e5dSmrgfunc_fallback_echo () 1036fae4e5dSmrg{ 1046fae4e5dSmrg eval 'cat <<_LTECHO_EOF 1056fae4e5dSmrg$1 1066fae4e5dSmrg_LTECHO_EOF' 1076fae4e5dSmrg} 1086fae4e5dSmrg 1099c9ff80cSmrg# NLS nuisances: We save the old values to restore during execute mode. 1109c9ff80cSmrglt_user_locale= 1119c9ff80cSmrglt_safe_locale= 112e5410a46Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 113e5410a46Smrgdo 114e5410a46Smrg eval "if test \"\${$lt_var+set}\" = set; then 1159c9ff80cSmrg save_$lt_var=\$$lt_var 1169c9ff80cSmrg $lt_var=C 117e5410a46Smrg export $lt_var 1189c9ff80cSmrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 1199c9ff80cSmrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 120e5410a46Smrg fi" 121e5410a46Smrgdone 1226fae4e5dSmrgLC_ALL=C 1236fae4e5dSmrgLANGUAGE=C 1246fae4e5dSmrgexport LANGUAGE LC_ALL 125e5410a46Smrg 1269c9ff80cSmrg$lt_unset CDPATH 1279c9ff80cSmrg 1289c9ff80cSmrg 1296fae4e5dSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 1306fae4e5dSmrg# is ksh but when the shell is invoked as "sh" and the current value of 1316fae4e5dSmrg# the _XPG environment variable is not equal to 1 (one), the special 1326fae4e5dSmrg# positional parameter $0, within a function call, is the name of the 1336fae4e5dSmrg# function. 1346fae4e5dSmrgprogpath="$0" 1359c9ff80cSmrg 1369c9ff80cSmrg 1379c9ff80cSmrg 1389c9ff80cSmrg: ${CP="cp -f"} 1396fae4e5dSmrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 1409c9ff80cSmrg: ${MAKE="make"} 1419c9ff80cSmrg: ${MKDIR="mkdir"} 1429c9ff80cSmrg: ${MV="mv -f"} 1439c9ff80cSmrg: ${RM="rm -f"} 1449c9ff80cSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 1459c9ff80cSmrg: ${Xsed="$SED -e 1s/^X//"} 1469c9ff80cSmrg 1479c9ff80cSmrg# Global variables: 1489c9ff80cSmrgEXIT_SUCCESS=0 1499c9ff80cSmrgEXIT_FAILURE=1 1509c9ff80cSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 1519c9ff80cSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 1529c9ff80cSmrg 1539c9ff80cSmrgexit_status=$EXIT_SUCCESS 1541f0ac6a5Smrg 1551f0ac6a5Smrg# Make sure IFS has a sensible default 1561f0ac6a5Smrglt_nl=' 1571f0ac6a5Smrg' 1581f0ac6a5SmrgIFS=" $lt_nl" 1591f0ac6a5Smrg 1609c9ff80cSmrgdirname="s,/[^/]*$,," 1619c9ff80cSmrgbasename="s,^.*/,," 1629c9ff80cSmrg 1636fae4e5dSmrg# func_dirname file append nondir_replacement 1646fae4e5dSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 1656fae4e5dSmrg# otherwise set result to NONDIR_REPLACEMENT. 1666fae4e5dSmrgfunc_dirname () 1676fae4e5dSmrg{ 1686fae4e5dSmrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 1696fae4e5dSmrg if test "X$func_dirname_result" = "X${1}"; then 1706fae4e5dSmrg func_dirname_result="${3}" 1716fae4e5dSmrg else 1726fae4e5dSmrg func_dirname_result="$func_dirname_result${2}" 1736fae4e5dSmrg fi 1746fae4e5dSmrg} # func_dirname may be replaced by extended shell implementation 1756fae4e5dSmrg 1766fae4e5dSmrg 1776fae4e5dSmrg# func_basename file 1786fae4e5dSmrgfunc_basename () 1796fae4e5dSmrg{ 1806fae4e5dSmrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 1816fae4e5dSmrg} # func_basename may be replaced by extended shell implementation 1826fae4e5dSmrg 1836fae4e5dSmrg 1849c9ff80cSmrg# func_dirname_and_basename file append nondir_replacement 1859c9ff80cSmrg# perform func_basename and func_dirname in a single function 1869c9ff80cSmrg# call: 1879c9ff80cSmrg# dirname: Compute the dirname of FILE. If nonempty, 1889c9ff80cSmrg# add APPEND to the result, otherwise set result 1899c9ff80cSmrg# to NONDIR_REPLACEMENT. 1909c9ff80cSmrg# value returned in "$func_dirname_result" 1919c9ff80cSmrg# basename: Compute filename of FILE. 1929c9ff80cSmrg# value retuned in "$func_basename_result" 1939c9ff80cSmrg# Implementation must be kept synchronized with func_dirname 1949c9ff80cSmrg# and func_basename. For efficiency, we do not delegate to 1959c9ff80cSmrg# those functions but instead duplicate the functionality here. 1969c9ff80cSmrgfunc_dirname_and_basename () 1979c9ff80cSmrg{ 1986fae4e5dSmrg # Extract subdirectory from the argument. 1996fae4e5dSmrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 2006fae4e5dSmrg if test "X$func_dirname_result" = "X${1}"; then 2016fae4e5dSmrg func_dirname_result="${3}" 2026fae4e5dSmrg else 2036fae4e5dSmrg func_dirname_result="$func_dirname_result${2}" 2046fae4e5dSmrg fi 2056fae4e5dSmrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 2066fae4e5dSmrg} # func_dirname_and_basename may be replaced by extended shell implementation 2076fae4e5dSmrg 2086fae4e5dSmrg 2096fae4e5dSmrg# func_stripname prefix suffix name 2106fae4e5dSmrg# strip PREFIX and SUFFIX off of NAME. 2116fae4e5dSmrg# PREFIX and SUFFIX must not contain globbing or regex special 2126fae4e5dSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 2136fae4e5dSmrg# dot (in which case that matches only a dot). 2146fae4e5dSmrg# func_strip_suffix prefix name 2156fae4e5dSmrgfunc_stripname () 2166fae4e5dSmrg{ 2176fae4e5dSmrg case ${2} in 2186fae4e5dSmrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 2196fae4e5dSmrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 2206fae4e5dSmrg esac 2216fae4e5dSmrg} # func_stripname may be replaced by extended shell implementation 2226fae4e5dSmrg 2236fae4e5dSmrg 2246fae4e5dSmrg# These SED scripts presuppose an absolute path with a trailing slash. 2256fae4e5dSmrgpathcar='s,^/\([^/]*\).*$,\1,' 2266fae4e5dSmrgpathcdr='s,^/[^/]*,,' 2276fae4e5dSmrgremovedotparts=':dotsl 2286fae4e5dSmrg s@/\./@/@g 2296fae4e5dSmrg t dotsl 2306fae4e5dSmrg s,/\.$,/,' 2316fae4e5dSmrgcollapseslashes='s@/\{1,\}@/@g' 2326fae4e5dSmrgfinalslash='s,/*$,/,' 2336fae4e5dSmrg 2346fae4e5dSmrg# func_normal_abspath PATH 2356fae4e5dSmrg# Remove doubled-up and trailing slashes, "." path components, 2366fae4e5dSmrg# and cancel out any ".." path components in PATH after making 2376fae4e5dSmrg# it an absolute path. 2386fae4e5dSmrg# value returned in "$func_normal_abspath_result" 2396fae4e5dSmrgfunc_normal_abspath () 2406fae4e5dSmrg{ 2416fae4e5dSmrg # Start from root dir and reassemble the path. 2426fae4e5dSmrg func_normal_abspath_result= 2436fae4e5dSmrg func_normal_abspath_tpath=$1 2446fae4e5dSmrg func_normal_abspath_altnamespace= 2456fae4e5dSmrg case $func_normal_abspath_tpath in 2466fae4e5dSmrg "") 2476fae4e5dSmrg # Empty path, that just means $cwd. 2486fae4e5dSmrg func_stripname '' '/' "`pwd`" 2496fae4e5dSmrg func_normal_abspath_result=$func_stripname_result 2506fae4e5dSmrg return 2516fae4e5dSmrg ;; 2526fae4e5dSmrg # The next three entries are used to spot a run of precisely 2536fae4e5dSmrg # two leading slashes without using negated character classes; 2546fae4e5dSmrg # we take advantage of case's first-match behaviour. 2556fae4e5dSmrg ///*) 2566fae4e5dSmrg # Unusual form of absolute path, do nothing. 2576fae4e5dSmrg ;; 2586fae4e5dSmrg //*) 2596fae4e5dSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 2606fae4e5dSmrg # and for example Cygwin uses it to access remote file shares 2616fae4e5dSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 2626fae4e5dSmrg func_normal_abspath_altnamespace=/ 2636fae4e5dSmrg ;; 2646fae4e5dSmrg /*) 2656fae4e5dSmrg # Absolute path, do nothing. 2666fae4e5dSmrg ;; 2676fae4e5dSmrg *) 2686fae4e5dSmrg # Relative path, prepend $cwd. 2696fae4e5dSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 2706fae4e5dSmrg ;; 2716fae4e5dSmrg esac 2726fae4e5dSmrg # Cancel out all the simple stuff to save iterations. We also want 2736fae4e5dSmrg # the path to end with a slash for ease of parsing, so make sure 2746fae4e5dSmrg # there is one (and only one) here. 2756fae4e5dSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 2766fae4e5dSmrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 2776fae4e5dSmrg while :; do 2786fae4e5dSmrg # Processed it all yet? 2796fae4e5dSmrg if test "$func_normal_abspath_tpath" = / ; then 2806fae4e5dSmrg # If we ascended to the root using ".." the result may be empty now. 2816fae4e5dSmrg if test -z "$func_normal_abspath_result" ; then 2826fae4e5dSmrg func_normal_abspath_result=/ 2836fae4e5dSmrg fi 2846fae4e5dSmrg break 2856fae4e5dSmrg fi 2866fae4e5dSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 2876fae4e5dSmrg -e "$pathcar"` 2886fae4e5dSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 2896fae4e5dSmrg -e "$pathcdr"` 2906fae4e5dSmrg # Figure out what to do with it 2916fae4e5dSmrg case $func_normal_abspath_tcomponent in 2926fae4e5dSmrg "") 2936fae4e5dSmrg # Trailing empty path component, ignore it. 2946fae4e5dSmrg ;; 2956fae4e5dSmrg ..) 2966fae4e5dSmrg # Parent dir; strip last assembled component from result. 2976fae4e5dSmrg func_dirname "$func_normal_abspath_result" 2986fae4e5dSmrg func_normal_abspath_result=$func_dirname_result 2996fae4e5dSmrg ;; 3006fae4e5dSmrg *) 3016fae4e5dSmrg # Actual path component, append it. 3026fae4e5dSmrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 3036fae4e5dSmrg ;; 3046fae4e5dSmrg esac 3056fae4e5dSmrg done 3066fae4e5dSmrg # Restore leading double-slash if one was found on entry. 3076fae4e5dSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 3089c9ff80cSmrg} 3091f0ac6a5Smrg 3106fae4e5dSmrg# func_relative_path SRCDIR DSTDIR 3116fae4e5dSmrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 3126fae4e5dSmrg# slash if non-empty, suitable for immediately appending a filename 3136fae4e5dSmrg# without needing to append a separator. 3146fae4e5dSmrg# value returned in "$func_relative_path_result" 3156fae4e5dSmrgfunc_relative_path () 3166fae4e5dSmrg{ 3176fae4e5dSmrg func_relative_path_result= 3186fae4e5dSmrg func_normal_abspath "$1" 3196fae4e5dSmrg func_relative_path_tlibdir=$func_normal_abspath_result 3206fae4e5dSmrg func_normal_abspath "$2" 3216fae4e5dSmrg func_relative_path_tbindir=$func_normal_abspath_result 3226fae4e5dSmrg 3236fae4e5dSmrg # Ascend the tree starting from libdir 3246fae4e5dSmrg while :; do 3256fae4e5dSmrg # check if we have found a prefix of bindir 3266fae4e5dSmrg case $func_relative_path_tbindir in 3276fae4e5dSmrg $func_relative_path_tlibdir) 3286fae4e5dSmrg # found an exact match 3296fae4e5dSmrg func_relative_path_tcancelled= 3306fae4e5dSmrg break 3316fae4e5dSmrg ;; 3326fae4e5dSmrg $func_relative_path_tlibdir*) 3336fae4e5dSmrg # found a matching prefix 3346fae4e5dSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 3356fae4e5dSmrg func_relative_path_tcancelled=$func_stripname_result 3366fae4e5dSmrg if test -z "$func_relative_path_result"; then 3376fae4e5dSmrg func_relative_path_result=. 3386fae4e5dSmrg fi 3396fae4e5dSmrg break 3406fae4e5dSmrg ;; 3416fae4e5dSmrg *) 3426fae4e5dSmrg func_dirname $func_relative_path_tlibdir 3436fae4e5dSmrg func_relative_path_tlibdir=${func_dirname_result} 3446fae4e5dSmrg if test "x$func_relative_path_tlibdir" = x ; then 3456fae4e5dSmrg # Have to descend all the way to the root! 3466fae4e5dSmrg func_relative_path_result=../$func_relative_path_result 3476fae4e5dSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 3486fae4e5dSmrg break 3496fae4e5dSmrg fi 3506fae4e5dSmrg func_relative_path_result=../$func_relative_path_result 3516fae4e5dSmrg ;; 3526fae4e5dSmrg esac 3536fae4e5dSmrg done 3549c9ff80cSmrg 3556fae4e5dSmrg # Now calculate path; take care to avoid doubling-up slashes. 3566fae4e5dSmrg func_stripname '' '/' "$func_relative_path_result" 3576fae4e5dSmrg func_relative_path_result=$func_stripname_result 3586fae4e5dSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 3596fae4e5dSmrg if test "x$func_stripname_result" != x ; then 3606fae4e5dSmrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 3616fae4e5dSmrg fi 3626fae4e5dSmrg 3636fae4e5dSmrg # Normalisation. If bindir is libdir, return empty string, 3646fae4e5dSmrg # else relative path ending with a slash; either way, target 3656fae4e5dSmrg # file name can be directly appended. 3666fae4e5dSmrg if test ! -z "$func_relative_path_result"; then 3676fae4e5dSmrg func_stripname './' '' "$func_relative_path_result/" 3686fae4e5dSmrg func_relative_path_result=$func_stripname_result 3696fae4e5dSmrg fi 3706fae4e5dSmrg} 3719c9ff80cSmrg 3729c9ff80cSmrg# The name of this program: 3739c9ff80cSmrgfunc_dirname_and_basename "$progpath" 3749c9ff80cSmrgprogname=$func_basename_result 3759c9ff80cSmrg 3769c9ff80cSmrg# Make sure we have an absolute path for reexecution: 3779c9ff80cSmrgcase $progpath in 3789c9ff80cSmrg [\\/]*|[A-Za-z]:\\*) ;; 3799c9ff80cSmrg *[\\/]*) 3809c9ff80cSmrg progdir=$func_dirname_result 3819c9ff80cSmrg progdir=`cd "$progdir" && pwd` 3829c9ff80cSmrg progpath="$progdir/$progname" 3839c9ff80cSmrg ;; 3849c9ff80cSmrg *) 3859c9ff80cSmrg save_IFS="$IFS" 38689c04b6cSmrg IFS=${PATH_SEPARATOR-:} 3879c9ff80cSmrg for progdir in $PATH; do 3889c9ff80cSmrg IFS="$save_IFS" 3899c9ff80cSmrg test -x "$progdir/$progname" && break 3909c9ff80cSmrg done 3919c9ff80cSmrg IFS="$save_IFS" 3929c9ff80cSmrg test -n "$progdir" || progdir=`pwd` 3939c9ff80cSmrg progpath="$progdir/$progname" 3949c9ff80cSmrg ;; 3959c9ff80cSmrgesac 3969c9ff80cSmrg 3979c9ff80cSmrg# Sed substitution that helps us do robust quoting. It backslashifies 3989c9ff80cSmrg# metacharacters that are still active within double-quoted strings. 3999c9ff80cSmrgXsed="${SED}"' -e 1s/^X//' 4009c9ff80cSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 4019c9ff80cSmrg 4029c9ff80cSmrg# Same as above, but do not quote variable references. 4039c9ff80cSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 4049c9ff80cSmrg 4056fae4e5dSmrg# Sed substitution that turns a string into a regex matching for the 4066fae4e5dSmrg# string literally. 4076fae4e5dSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 4086fae4e5dSmrg 4096fae4e5dSmrg# Sed substitution that converts a w32 file name or path 4106fae4e5dSmrg# which contains forward slashes, into one that contains 4116fae4e5dSmrg# (escaped) backslashes. A very naive implementation. 4126fae4e5dSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 4136fae4e5dSmrg 4149c9ff80cSmrg# Re-`\' parameter expansions in output of double_quote_subst that were 4159c9ff80cSmrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 4169c9ff80cSmrg# in input to double_quote_subst, that '$' was protected from expansion. 4179c9ff80cSmrg# Since each input `\' is now two `\'s, look for any number of runs of 4189c9ff80cSmrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 4199c9ff80cSmrgbs='\\' 4209c9ff80cSmrgbs2='\\\\' 4219c9ff80cSmrgbs4='\\\\\\\\' 4229c9ff80cSmrgdollar='\$' 4239c9ff80cSmrgsed_double_backslash="\ 4249c9ff80cSmrg s/$bs4/&\\ 4259c9ff80cSmrg/g 4269c9ff80cSmrg s/^$bs2$dollar/$bs&/ 4279c9ff80cSmrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 4289c9ff80cSmrg s/\n//g" 4299c9ff80cSmrg 4309c9ff80cSmrg# Standard options: 4319c9ff80cSmrgopt_dry_run=false 4329c9ff80cSmrgopt_help=false 4339c9ff80cSmrgopt_quiet=false 4349c9ff80cSmrgopt_verbose=false 4359c9ff80cSmrgopt_warning=: 4369c9ff80cSmrg 4379c9ff80cSmrg# func_echo arg... 4389c9ff80cSmrg# Echo program name prefixed message, along with the current mode 4399c9ff80cSmrg# name if it has been set yet. 4409c9ff80cSmrgfunc_echo () 4419c9ff80cSmrg{ 4426fae4e5dSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 4439c9ff80cSmrg} 4449c9ff80cSmrg 4459c9ff80cSmrg# func_verbose arg... 4469c9ff80cSmrg# Echo program name prefixed message in verbose mode only. 4479c9ff80cSmrgfunc_verbose () 4489c9ff80cSmrg{ 4499c9ff80cSmrg $opt_verbose && func_echo ${1+"$@"} 4509c9ff80cSmrg 4519c9ff80cSmrg # A bug in bash halts the script if the last line of a function 4529c9ff80cSmrg # fails when set -e is in force, so we need another command to 4539c9ff80cSmrg # work around that: 4549c9ff80cSmrg : 4559c9ff80cSmrg} 4569c9ff80cSmrg 4576fae4e5dSmrg# func_echo_all arg... 4586fae4e5dSmrg# Invoke $ECHO with all args, space-separated. 4596fae4e5dSmrgfunc_echo_all () 4606fae4e5dSmrg{ 4616fae4e5dSmrg $ECHO "$*" 4626fae4e5dSmrg} 4636fae4e5dSmrg 4649c9ff80cSmrg# func_error arg... 4659c9ff80cSmrg# Echo program name prefixed message to standard error. 4669c9ff80cSmrgfunc_error () 4679c9ff80cSmrg{ 4686fae4e5dSmrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 4699c9ff80cSmrg} 4709c9ff80cSmrg 4719c9ff80cSmrg# func_warning arg... 4729c9ff80cSmrg# Echo program name prefixed warning message to standard error. 4739c9ff80cSmrgfunc_warning () 4749c9ff80cSmrg{ 4756fae4e5dSmrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 4769c9ff80cSmrg 4779c9ff80cSmrg # bash bug again: 4789c9ff80cSmrg : 4799c9ff80cSmrg} 4809c9ff80cSmrg 4819c9ff80cSmrg# func_fatal_error arg... 4829c9ff80cSmrg# Echo program name prefixed message to standard error, and exit. 4839c9ff80cSmrgfunc_fatal_error () 4849c9ff80cSmrg{ 4859c9ff80cSmrg func_error ${1+"$@"} 4869c9ff80cSmrg exit $EXIT_FAILURE 4879c9ff80cSmrg} 4889c9ff80cSmrg 4899c9ff80cSmrg# func_fatal_help arg... 4909c9ff80cSmrg# Echo program name prefixed message to standard error, followed by 4919c9ff80cSmrg# a help hint, and exit. 4929c9ff80cSmrgfunc_fatal_help () 4939c9ff80cSmrg{ 4949c9ff80cSmrg func_error ${1+"$@"} 4959c9ff80cSmrg func_fatal_error "$help" 4969c9ff80cSmrg} 4979c9ff80cSmrghelp="Try \`$progname --help' for more information." ## default 4989c9ff80cSmrg 4999c9ff80cSmrg 5009c9ff80cSmrg# func_grep expression filename 5019c9ff80cSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 5029c9ff80cSmrgfunc_grep () 5039c9ff80cSmrg{ 5049c9ff80cSmrg $GREP "$1" "$2" >/dev/null 2>&1 5059c9ff80cSmrg} 5069c9ff80cSmrg 5079c9ff80cSmrg 5089c9ff80cSmrg# func_mkdir_p directory-path 5099c9ff80cSmrg# Make sure the entire path to DIRECTORY-PATH is available. 5109c9ff80cSmrgfunc_mkdir_p () 5119c9ff80cSmrg{ 5129c9ff80cSmrg my_directory_path="$1" 5139c9ff80cSmrg my_dir_list= 5149c9ff80cSmrg 5159c9ff80cSmrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 5169c9ff80cSmrg 5179c9ff80cSmrg # Protect directory names starting with `-' 5189c9ff80cSmrg case $my_directory_path in 5199c9ff80cSmrg -*) my_directory_path="./$my_directory_path" ;; 5209c9ff80cSmrg esac 5219c9ff80cSmrg 5229c9ff80cSmrg # While some portion of DIR does not yet exist... 5239c9ff80cSmrg while test ! -d "$my_directory_path"; do 5249c9ff80cSmrg # ...make a list in topmost first order. Use a colon delimited 5259c9ff80cSmrg # list incase some portion of path contains whitespace. 5269c9ff80cSmrg my_dir_list="$my_directory_path:$my_dir_list" 5279c9ff80cSmrg 5289c9ff80cSmrg # If the last portion added has no slash in it, the list is done 5299c9ff80cSmrg case $my_directory_path in */*) ;; *) break ;; esac 5309c9ff80cSmrg 5319c9ff80cSmrg # ...otherwise throw away the child directory and loop 5326fae4e5dSmrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 5339c9ff80cSmrg done 5346fae4e5dSmrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 5359c9ff80cSmrg 5369c9ff80cSmrg save_mkdir_p_IFS="$IFS"; IFS=':' 5379c9ff80cSmrg for my_dir in $my_dir_list; do 5389c9ff80cSmrg IFS="$save_mkdir_p_IFS" 5399c9ff80cSmrg # mkdir can fail with a `File exist' error if two processes 5409c9ff80cSmrg # try to create one of the directories concurrently. Don't 5419c9ff80cSmrg # stop in that case! 5429c9ff80cSmrg $MKDIR "$my_dir" 2>/dev/null || : 5439c9ff80cSmrg done 5449c9ff80cSmrg IFS="$save_mkdir_p_IFS" 5459c9ff80cSmrg 5469c9ff80cSmrg # Bail out if we (or some other process) failed to create a directory. 5479c9ff80cSmrg test -d "$my_directory_path" || \ 5489c9ff80cSmrg func_fatal_error "Failed to create \`$1'" 5499c9ff80cSmrg fi 5509c9ff80cSmrg} 5511f0ac6a5Smrg 5521f0ac6a5Smrg 5531f0ac6a5Smrg# func_mktempdir [string] 5541f0ac6a5Smrg# Make a temporary directory that won't clash with other running 5551f0ac6a5Smrg# libtool processes, and avoids race conditions if possible. If 5561f0ac6a5Smrg# given, STRING is the basename for that directory. 5571f0ac6a5Smrgfunc_mktempdir () 5581f0ac6a5Smrg{ 5591f0ac6a5Smrg my_template="${TMPDIR-/tmp}/${1-$progname}" 5601f0ac6a5Smrg 5619c9ff80cSmrg if test "$opt_dry_run" = ":"; then 5621f0ac6a5Smrg # Return a directory name, but don't create it in dry-run mode 5631f0ac6a5Smrg my_tmpdir="${my_template}-$$" 5641f0ac6a5Smrg else 5651f0ac6a5Smrg 5661f0ac6a5Smrg # If mktemp works, use that first and foremost 5671f0ac6a5Smrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 5681f0ac6a5Smrg 5691f0ac6a5Smrg if test ! -d "$my_tmpdir"; then 5709c9ff80cSmrg # Failing that, at least try and use $RANDOM to avoid a race 5719c9ff80cSmrg my_tmpdir="${my_template}-${RANDOM-0}$$" 5721f0ac6a5Smrg 5739c9ff80cSmrg save_mktempdir_umask=`umask` 5749c9ff80cSmrg umask 0077 5759c9ff80cSmrg $MKDIR "$my_tmpdir" 5769c9ff80cSmrg umask $save_mktempdir_umask 5771f0ac6a5Smrg fi 5781f0ac6a5Smrg 5791f0ac6a5Smrg # If we're not in dry-run mode, bomb out on failure 5809c9ff80cSmrg test -d "$my_tmpdir" || \ 5819c9ff80cSmrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 5821f0ac6a5Smrg fi 5831f0ac6a5Smrg 5846fae4e5dSmrg $ECHO "$my_tmpdir" 5851f0ac6a5Smrg} 5861f0ac6a5Smrg 5871f0ac6a5Smrg 5889c9ff80cSmrg# func_quote_for_eval arg 5899c9ff80cSmrg# Aesthetically quote ARG to be evaled later. 5909c9ff80cSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 5919c9ff80cSmrg# is double-quoted, suitable for a subsequent eval, whereas 5929c9ff80cSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 5939c9ff80cSmrg# which are still active within double quotes backslashified. 5949c9ff80cSmrgfunc_quote_for_eval () 5951f0ac6a5Smrg{ 5969c9ff80cSmrg case $1 in 5979c9ff80cSmrg *[\\\`\"\$]*) 5986fae4e5dSmrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 5999c9ff80cSmrg *) 6009c9ff80cSmrg func_quote_for_eval_unquoted_result="$1" ;; 6019c9ff80cSmrg esac 6029c9ff80cSmrg 6039c9ff80cSmrg case $func_quote_for_eval_unquoted_result in 6049c9ff80cSmrg # Double-quote args containing shell metacharacters to delay 6059c9ff80cSmrg # word splitting, command substitution and and variable 6069c9ff80cSmrg # expansion for a subsequent eval. 6079c9ff80cSmrg # Many Bourne shells cannot handle close brackets correctly 6089c9ff80cSmrg # in scan sets, so we specify it separately. 6099c9ff80cSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 6109c9ff80cSmrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 6119c9ff80cSmrg ;; 6129c9ff80cSmrg *) 6139c9ff80cSmrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 6141f0ac6a5Smrg esac 6151f0ac6a5Smrg} 6161f0ac6a5Smrg 6171f0ac6a5Smrg 6189c9ff80cSmrg# func_quote_for_expand arg 6199c9ff80cSmrg# Aesthetically quote ARG to be evaled later; same as above, 6209c9ff80cSmrg# but do not quote variable references. 6219c9ff80cSmrgfunc_quote_for_expand () 6221f0ac6a5Smrg{ 6239c9ff80cSmrg case $1 in 6249c9ff80cSmrg *[\\\`\"]*) 6256fae4e5dSmrg my_arg=`$ECHO "$1" | $SED \ 6269c9ff80cSmrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 6271f0ac6a5Smrg *) 6289c9ff80cSmrg my_arg="$1" ;; 6299c9ff80cSmrg esac 6309c9ff80cSmrg 6319c9ff80cSmrg case $my_arg in 6329c9ff80cSmrg # Double-quote args containing shell metacharacters to delay 6339c9ff80cSmrg # word splitting and command substitution for a subsequent eval. 6349c9ff80cSmrg # Many Bourne shells cannot handle close brackets correctly 6359c9ff80cSmrg # in scan sets, so we specify it separately. 6369c9ff80cSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 6379c9ff80cSmrg my_arg="\"$my_arg\"" 6389c9ff80cSmrg ;; 6399c9ff80cSmrg esac 6409c9ff80cSmrg 6419c9ff80cSmrg func_quote_for_expand_result="$my_arg" 6421f0ac6a5Smrg} 6431f0ac6a5Smrg 6441f0ac6a5Smrg 6459c9ff80cSmrg# func_show_eval cmd [fail_exp] 6469c9ff80cSmrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6479c9ff80cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6489c9ff80cSmrg# is given, then evaluate it. 6499c9ff80cSmrgfunc_show_eval () 6501f0ac6a5Smrg{ 6519c9ff80cSmrg my_cmd="$1" 6529c9ff80cSmrg my_fail_exp="${2-:}" 6531f0ac6a5Smrg 6549c9ff80cSmrg ${opt_silent-false} || { 6559c9ff80cSmrg func_quote_for_expand "$my_cmd" 6569c9ff80cSmrg eval "func_echo $func_quote_for_expand_result" 6579c9ff80cSmrg } 6589c9ff80cSmrg 6599c9ff80cSmrg if ${opt_dry_run-false}; then :; else 6609c9ff80cSmrg eval "$my_cmd" 6619c9ff80cSmrg my_status=$? 6629c9ff80cSmrg if test "$my_status" -eq 0; then :; else 6639c9ff80cSmrg eval "(exit $my_status); $my_fail_exp" 6649c9ff80cSmrg fi 6651f0ac6a5Smrg fi 6661f0ac6a5Smrg} 6671f0ac6a5Smrg 6689c9ff80cSmrg 6699c9ff80cSmrg# func_show_eval_locale cmd [fail_exp] 6709c9ff80cSmrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6719c9ff80cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6729c9ff80cSmrg# is given, then evaluate it. Use the saved locale for evaluation. 6739c9ff80cSmrgfunc_show_eval_locale () 6741f0ac6a5Smrg{ 6759c9ff80cSmrg my_cmd="$1" 6769c9ff80cSmrg my_fail_exp="${2-:}" 6779c9ff80cSmrg 6789c9ff80cSmrg ${opt_silent-false} || { 6799c9ff80cSmrg func_quote_for_expand "$my_cmd" 6809c9ff80cSmrg eval "func_echo $func_quote_for_expand_result" 6819c9ff80cSmrg } 6829c9ff80cSmrg 6839c9ff80cSmrg if ${opt_dry_run-false}; then :; else 6849c9ff80cSmrg eval "$lt_user_locale 6859c9ff80cSmrg $my_cmd" 6869c9ff80cSmrg my_status=$? 6879c9ff80cSmrg eval "$lt_safe_locale" 6889c9ff80cSmrg if test "$my_status" -eq 0; then :; else 6899c9ff80cSmrg eval "(exit $my_status); $my_fail_exp" 6909c9ff80cSmrg fi 6911f0ac6a5Smrg fi 6929c9ff80cSmrg} 6931f0ac6a5Smrg 6946fae4e5dSmrg# func_tr_sh 6956fae4e5dSmrg# Turn $1 into a string suitable for a shell variable name. 6966fae4e5dSmrg# Result is stored in $func_tr_sh_result. All characters 6976fae4e5dSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 6986fae4e5dSmrg# if $1 begins with a digit, a '_' is prepended as well. 6996fae4e5dSmrgfunc_tr_sh () 7006fae4e5dSmrg{ 7016fae4e5dSmrg case $1 in 7026fae4e5dSmrg [0-9]* | *[!a-zA-Z0-9_]*) 7036fae4e5dSmrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 7046fae4e5dSmrg ;; 7056fae4e5dSmrg * ) 7066fae4e5dSmrg func_tr_sh_result=$1 7076fae4e5dSmrg ;; 7086fae4e5dSmrg esac 7096fae4e5dSmrg} 7109c9ff80cSmrg 7119c9ff80cSmrg 7129c9ff80cSmrg# func_version 7139c9ff80cSmrg# Echo version message to standard output and exit. 7149c9ff80cSmrgfunc_version () 7159c9ff80cSmrg{ 7166fae4e5dSmrg $opt_debug 7176fae4e5dSmrg 7186fae4e5dSmrg $SED -n '/(C)/!b go 7196fae4e5dSmrg :more 7206fae4e5dSmrg /\./!{ 7216fae4e5dSmrg N 7226fae4e5dSmrg s/\n# / / 7236fae4e5dSmrg b more 7246fae4e5dSmrg } 7256fae4e5dSmrg :go 7266fae4e5dSmrg /^# '$PROGRAM' (GNU /,/# warranty; / { 7279c9ff80cSmrg s/^# // 7289c9ff80cSmrg s/^# *$// 7299c9ff80cSmrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 7309c9ff80cSmrg p 7319c9ff80cSmrg }' < "$progpath" 7329c9ff80cSmrg exit $? 7339c9ff80cSmrg} 7349c9ff80cSmrg 7359c9ff80cSmrg# func_usage 7369c9ff80cSmrg# Echo short help message to standard output and exit. 7379c9ff80cSmrgfunc_usage () 7389c9ff80cSmrg{ 7396fae4e5dSmrg $opt_debug 7406fae4e5dSmrg 7416fae4e5dSmrg $SED -n '/^# Usage:/,/^# *.*--help/ { 7429c9ff80cSmrg s/^# // 7439c9ff80cSmrg s/^# *$// 7449c9ff80cSmrg s/\$progname/'$progname'/ 7459c9ff80cSmrg p 7469c9ff80cSmrg }' < "$progpath" 7476fae4e5dSmrg echo 7489c9ff80cSmrg $ECHO "run \`$progname --help | more' for full usage" 7499c9ff80cSmrg exit $? 7509c9ff80cSmrg} 7519c9ff80cSmrg 7526fae4e5dSmrg# func_help [NOEXIT] 7536fae4e5dSmrg# Echo long help message to standard output and exit, 7546fae4e5dSmrg# unless 'noexit' is passed as argument. 7559c9ff80cSmrgfunc_help () 7569c9ff80cSmrg{ 7576fae4e5dSmrg $opt_debug 7586fae4e5dSmrg 7599c9ff80cSmrg $SED -n '/^# Usage:/,/# Report bugs to/ { 7606fae4e5dSmrg :print 7619c9ff80cSmrg s/^# // 7629c9ff80cSmrg s/^# *$// 7639c9ff80cSmrg s*\$progname*'$progname'* 7649c9ff80cSmrg s*\$host*'"$host"'* 7659c9ff80cSmrg s*\$SHELL*'"$SHELL"'* 7669c9ff80cSmrg s*\$LTCC*'"$LTCC"'* 7679c9ff80cSmrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 7689c9ff80cSmrg s*\$LD*'"$LD"'* 7699c9ff80cSmrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 77089c04b6cSmrg s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 77189c04b6cSmrg s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 7729c9ff80cSmrg p 7736fae4e5dSmrg d 7746fae4e5dSmrg } 7756fae4e5dSmrg /^# .* home page:/b print 7766fae4e5dSmrg /^# General help using/b print 7776fae4e5dSmrg ' < "$progpath" 7786fae4e5dSmrg ret=$? 7796fae4e5dSmrg if test -z "$1"; then 7806fae4e5dSmrg exit $ret 7816fae4e5dSmrg fi 7829c9ff80cSmrg} 7839c9ff80cSmrg 7849c9ff80cSmrg# func_missing_arg argname 7859c9ff80cSmrg# Echo program name prefixed message to standard error and set global 7869c9ff80cSmrg# exit_cmd. 7879c9ff80cSmrgfunc_missing_arg () 7889c9ff80cSmrg{ 7896fae4e5dSmrg $opt_debug 7906fae4e5dSmrg 7916fae4e5dSmrg func_error "missing argument for $1." 7929c9ff80cSmrg exit_cmd=exit 7931f0ac6a5Smrg} 7941f0ac6a5Smrg 7951f0ac6a5Smrg 7966fae4e5dSmrg# func_split_short_opt shortopt 7976fae4e5dSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 7986fae4e5dSmrg# variables after splitting SHORTOPT after the 2nd character. 7996fae4e5dSmrgfunc_split_short_opt () 8006fae4e5dSmrg{ 8016fae4e5dSmrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 8026fae4e5dSmrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 8031f0ac6a5Smrg 8046fae4e5dSmrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 8056fae4e5dSmrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 8066fae4e5dSmrg} # func_split_short_opt may be replaced by extended shell implementation 8076fae4e5dSmrg 8086fae4e5dSmrg 8096fae4e5dSmrg# func_split_long_opt longopt 8106fae4e5dSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 8116fae4e5dSmrg# variables after splitting LONGOPT at the `=' sign. 8126fae4e5dSmrgfunc_split_long_opt () 8136fae4e5dSmrg{ 8146fae4e5dSmrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 8156fae4e5dSmrg my_sed_long_arg='1s/^--[^=]*=//' 8166fae4e5dSmrg 8176fae4e5dSmrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 8186fae4e5dSmrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 8196fae4e5dSmrg} # func_split_long_opt may be replaced by extended shell implementation 8206fae4e5dSmrg 8216fae4e5dSmrgexit_cmd=: 8229c9ff80cSmrg 8239c9ff80cSmrg 8249c9ff80cSmrg 8251f0ac6a5Smrg 8261f0ac6a5Smrg 8279c9ff80cSmrgmagic="%%%MAGIC variable%%%" 8289c9ff80cSmrgmagic_exe="%%%MAGIC EXE variable%%%" 8291f0ac6a5Smrg 8309c9ff80cSmrg# Global variables. 8319c9ff80cSmrgnonopt= 8329c9ff80cSmrgpreserve_args= 8339c9ff80cSmrglo2o="s/\\.lo\$/.${objext}/" 8349c9ff80cSmrgo2lo="s/\\.${objext}\$/.lo/" 8359c9ff80cSmrgextracted_archives= 8369c9ff80cSmrgextracted_serial=0 8371f0ac6a5Smrg 8389c9ff80cSmrg# If this variable is set in any of the actions, the command in it 8399c9ff80cSmrg# will be execed at the end. This prevents here-documents from being 8409c9ff80cSmrg# left over by shells. 8419c9ff80cSmrgexec_cmd= 8429c9ff80cSmrg 8436fae4e5dSmrg# func_append var value 8446fae4e5dSmrg# Append VALUE to the end of shell variable VAR. 8456fae4e5dSmrgfunc_append () 8466fae4e5dSmrg{ 8476fae4e5dSmrg eval "${1}=\$${1}\${2}" 8486fae4e5dSmrg} # func_append may be replaced by extended shell implementation 8496fae4e5dSmrg 8506fae4e5dSmrg# func_append_quoted var value 8516fae4e5dSmrg# Quote VALUE and append to the end of shell variable VAR, separated 8526fae4e5dSmrg# by a space. 8536fae4e5dSmrgfunc_append_quoted () 8546fae4e5dSmrg{ 8556fae4e5dSmrg func_quote_for_eval "${2}" 8566fae4e5dSmrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 8576fae4e5dSmrg} # func_append_quoted may be replaced by extended shell implementation 8586fae4e5dSmrg 8596fae4e5dSmrg 8606fae4e5dSmrg# func_arith arithmetic-term... 8616fae4e5dSmrgfunc_arith () 8626fae4e5dSmrg{ 8636fae4e5dSmrg func_arith_result=`expr "${@}"` 8646fae4e5dSmrg} # func_arith may be replaced by extended shell implementation 8656fae4e5dSmrg 8666fae4e5dSmrg 8676fae4e5dSmrg# func_len string 8686fae4e5dSmrg# STRING may not start with a hyphen. 8696fae4e5dSmrgfunc_len () 8706fae4e5dSmrg{ 8716fae4e5dSmrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 8726fae4e5dSmrg} # func_len may be replaced by extended shell implementation 8736fae4e5dSmrg 8746fae4e5dSmrg 8756fae4e5dSmrg# func_lo2o object 8766fae4e5dSmrgfunc_lo2o () 8776fae4e5dSmrg{ 8786fae4e5dSmrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 8796fae4e5dSmrg} # func_lo2o may be replaced by extended shell implementation 8806fae4e5dSmrg 8816fae4e5dSmrg 8826fae4e5dSmrg# func_xform libobj-or-source 8836fae4e5dSmrgfunc_xform () 8846fae4e5dSmrg{ 8856fae4e5dSmrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 8866fae4e5dSmrg} # func_xform may be replaced by extended shell implementation 8876fae4e5dSmrg 8886fae4e5dSmrg 8899c9ff80cSmrg# func_fatal_configuration arg... 8909c9ff80cSmrg# Echo program name prefixed message to standard error, followed by 8919c9ff80cSmrg# a configuration failure hint, and exit. 8929c9ff80cSmrgfunc_fatal_configuration () 8939c9ff80cSmrg{ 8949c9ff80cSmrg func_error ${1+"$@"} 8959c9ff80cSmrg func_error "See the $PACKAGE documentation for more information." 8969c9ff80cSmrg func_fatal_error "Fatal configuration error." 8979c9ff80cSmrg} 8981f0ac6a5Smrg 899e5410a46Smrg 9009c9ff80cSmrg# func_config 9019c9ff80cSmrg# Display the configuration for all the tags in this script. 9029c9ff80cSmrgfunc_config () 9039c9ff80cSmrg{ 9049c9ff80cSmrg re_begincf='^# ### BEGIN LIBTOOL' 9059c9ff80cSmrg re_endcf='^# ### END LIBTOOL' 9069c9ff80cSmrg 9079c9ff80cSmrg # Default configuration. 9089c9ff80cSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 9091f0ac6a5Smrg 9101f0ac6a5Smrg # Now print the configurations for the tags. 9111f0ac6a5Smrg for tagname in $taglist; do 9129c9ff80cSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 9131f0ac6a5Smrg done 9141f0ac6a5Smrg 9159c9ff80cSmrg exit $? 9169c9ff80cSmrg} 9171f0ac6a5Smrg 9189c9ff80cSmrg# func_features 9199c9ff80cSmrg# Display the features supported by this script. 9209c9ff80cSmrgfunc_features () 9219c9ff80cSmrg{ 9226fae4e5dSmrg echo "host: $host" 9231f0ac6a5Smrg if test "$build_libtool_libs" = yes; then 9246fae4e5dSmrg echo "enable shared libraries" 9251f0ac6a5Smrg else 9266fae4e5dSmrg echo "disable shared libraries" 9271f0ac6a5Smrg fi 9281f0ac6a5Smrg if test "$build_old_libs" = yes; then 9296fae4e5dSmrg echo "enable static libraries" 9301f0ac6a5Smrg else 9316fae4e5dSmrg echo "disable static libraries" 9321f0ac6a5Smrg fi 9339c9ff80cSmrg 9341f0ac6a5Smrg exit $? 9359c9ff80cSmrg} 9361f0ac6a5Smrg 9379c9ff80cSmrg# func_enable_tag tagname 9389c9ff80cSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 9399c9ff80cSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 9409c9ff80cSmrg# variable here. 9419c9ff80cSmrgfunc_enable_tag () 9429c9ff80cSmrg{ 9439c9ff80cSmrg # Global variable: 9449c9ff80cSmrg tagname="$1" 9451f0ac6a5Smrg 9469c9ff80cSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 9479c9ff80cSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 9489c9ff80cSmrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 9491f0ac6a5Smrg 9509c9ff80cSmrg # Validate tagname. 9519c9ff80cSmrg case $tagname in 9529c9ff80cSmrg *[!-_A-Za-z0-9,/]*) 9539c9ff80cSmrg func_fatal_error "invalid tag name: $tagname" 9549c9ff80cSmrg ;; 9559c9ff80cSmrg esac 9561f0ac6a5Smrg 9579c9ff80cSmrg # Don't test for the "default" C tag, as we know it's 9589c9ff80cSmrg # there but not specially marked. 9599c9ff80cSmrg case $tagname in 9609c9ff80cSmrg CC) ;; 9619c9ff80cSmrg *) 9629c9ff80cSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 9639c9ff80cSmrg taglist="$taglist $tagname" 9649c9ff80cSmrg 9659c9ff80cSmrg # Evaluate the configuration. Be careful to quote the path 9669c9ff80cSmrg # and the sed script, to avoid splitting on whitespace, but 9679c9ff80cSmrg # also don't use non-portable quotes within backquotes within 9689c9ff80cSmrg # quotes we have to do it in 2 steps: 9699c9ff80cSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 9709c9ff80cSmrg eval "$extractedcf" 9719c9ff80cSmrg else 9729c9ff80cSmrg func_error "ignoring unknown tag $tagname" 9739c9ff80cSmrg fi 9749c9ff80cSmrg ;; 9759c9ff80cSmrg esac 9769c9ff80cSmrg} 9779c9ff80cSmrg 9786fae4e5dSmrg# func_check_version_match 9796fae4e5dSmrg# Ensure that we are using m4 macros, and libtool script from the same 9806fae4e5dSmrg# release of libtool. 9816fae4e5dSmrgfunc_check_version_match () 9829c9ff80cSmrg{ 9836fae4e5dSmrg if test "$package_revision" != "$macro_revision"; then 9846fae4e5dSmrg if test "$VERSION" != "$macro_version"; then 9856fae4e5dSmrg if test -z "$macro_version"; then 9866fae4e5dSmrg cat >&2 <<_LT_EOF 9876fae4e5dSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 9886fae4e5dSmrg$progname: definition of this LT_INIT comes from an older release. 9896fae4e5dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 9906fae4e5dSmrg$progname: and run autoconf again. 9916fae4e5dSmrg_LT_EOF 9926fae4e5dSmrg else 9936fae4e5dSmrg cat >&2 <<_LT_EOF 9946fae4e5dSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 9956fae4e5dSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 9966fae4e5dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 9976fae4e5dSmrg$progname: and run autoconf again. 9986fae4e5dSmrg_LT_EOF 9996fae4e5dSmrg fi 10006fae4e5dSmrg else 10016fae4e5dSmrg cat >&2 <<_LT_EOF 10026fae4e5dSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 10036fae4e5dSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 10046fae4e5dSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 10056fae4e5dSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 10066fae4e5dSmrg_LT_EOF 10076fae4e5dSmrg fi 10081f0ac6a5Smrg 10096fae4e5dSmrg exit $EXIT_MISMATCH 10106fae4e5dSmrg fi 10116fae4e5dSmrg} 10126fae4e5dSmrg 10136fae4e5dSmrg 10146fae4e5dSmrg# Shorthand for --mode=foo, only valid as the first argument 10156fae4e5dSmrgcase $1 in 10166fae4e5dSmrgclean|clea|cle|cl) 10176fae4e5dSmrg shift; set dummy --mode clean ${1+"$@"}; shift 10186fae4e5dSmrg ;; 10196fae4e5dSmrgcompile|compil|compi|comp|com|co|c) 10206fae4e5dSmrg shift; set dummy --mode compile ${1+"$@"}; shift 10216fae4e5dSmrg ;; 10226fae4e5dSmrgexecute|execut|execu|exec|exe|ex|e) 10236fae4e5dSmrg shift; set dummy --mode execute ${1+"$@"}; shift 10246fae4e5dSmrg ;; 10256fae4e5dSmrgfinish|finis|fini|fin|fi|f) 10266fae4e5dSmrg shift; set dummy --mode finish ${1+"$@"}; shift 10276fae4e5dSmrg ;; 10286fae4e5dSmrginstall|instal|insta|inst|ins|in|i) 10296fae4e5dSmrg shift; set dummy --mode install ${1+"$@"}; shift 10306fae4e5dSmrg ;; 10316fae4e5dSmrglink|lin|li|l) 10326fae4e5dSmrg shift; set dummy --mode link ${1+"$@"}; shift 10336fae4e5dSmrg ;; 10346fae4e5dSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 10356fae4e5dSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 10366fae4e5dSmrg ;; 10376fae4e5dSmrgesac 10386fae4e5dSmrg 10396fae4e5dSmrg 10406fae4e5dSmrg 10416fae4e5dSmrg# Option defaults: 10426fae4e5dSmrgopt_debug=: 10436fae4e5dSmrgopt_dry_run=false 10446fae4e5dSmrgopt_config=false 10456fae4e5dSmrgopt_preserve_dup_deps=false 10466fae4e5dSmrgopt_features=false 10476fae4e5dSmrgopt_finish=false 10486fae4e5dSmrgopt_help=false 10496fae4e5dSmrgopt_help_all=false 10506fae4e5dSmrgopt_silent=: 105189c04b6cSmrgopt_warning=: 10526fae4e5dSmrgopt_verbose=: 10536fae4e5dSmrgopt_silent=false 10546fae4e5dSmrgopt_verbose=false 10551f0ac6a5Smrg 10566fae4e5dSmrg 10576fae4e5dSmrg# Parse options once, thoroughly. This comes as soon as possible in the 10586fae4e5dSmrg# script to make things like `--version' happen as quickly as we can. 10596fae4e5dSmrg{ 10606fae4e5dSmrg # this just eases exit handling 10616fae4e5dSmrg while test $# -gt 0; do 10629c9ff80cSmrg opt="$1" 10639c9ff80cSmrg shift 10649c9ff80cSmrg case $opt in 10656fae4e5dSmrg --debug|-x) opt_debug='set -x' 10669c9ff80cSmrg func_echo "enabling shell trace mode" 10679c9ff80cSmrg $opt_debug 10689c9ff80cSmrg ;; 10696fae4e5dSmrg --dry-run|--dryrun|-n) 10706fae4e5dSmrg opt_dry_run=: 10719c9ff80cSmrg ;; 10726fae4e5dSmrg --config) 10736fae4e5dSmrg opt_config=: 10746fae4e5dSmrgfunc_config 10756fae4e5dSmrg ;; 10766fae4e5dSmrg --dlopen|-dlopen) 10776fae4e5dSmrg optarg="$1" 10786fae4e5dSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 10796fae4e5dSmrg}$optarg" 10809c9ff80cSmrg shift 10819c9ff80cSmrg ;; 10829c9ff80cSmrg --preserve-dup-deps) 10836fae4e5dSmrg opt_preserve_dup_deps=: 10849c9ff80cSmrg ;; 10856fae4e5dSmrg --features) 10866fae4e5dSmrg opt_features=: 10876fae4e5dSmrgfunc_features 10886fae4e5dSmrg ;; 10896fae4e5dSmrg --finish) 10906fae4e5dSmrg opt_finish=: 10916fae4e5dSmrgset dummy --mode finish ${1+"$@"}; shift 10926fae4e5dSmrg ;; 10936fae4e5dSmrg --help) 10946fae4e5dSmrg opt_help=: 10956fae4e5dSmrg ;; 10966fae4e5dSmrg --help-all) 10976fae4e5dSmrg opt_help_all=: 10986fae4e5dSmrgopt_help=': help-all' 10996fae4e5dSmrg ;; 11006fae4e5dSmrg --mode) 11016fae4e5dSmrg test $# = 0 && func_missing_arg $opt && break 11026fae4e5dSmrg optarg="$1" 11036fae4e5dSmrg opt_mode="$optarg" 11046fae4e5dSmrgcase $optarg in 11056fae4e5dSmrg # Valid mode arguments: 11066fae4e5dSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 11076fae4e5dSmrg 11086fae4e5dSmrg # Catch anything else as an error 11096fae4e5dSmrg *) func_error "invalid argument for $opt" 11106fae4e5dSmrg exit_cmd=exit 11116fae4e5dSmrg break 11126fae4e5dSmrg ;; 11136fae4e5dSmrgesac 11146fae4e5dSmrg shift 11156fae4e5dSmrg ;; 11166fae4e5dSmrg --no-silent|--no-quiet) 11179c9ff80cSmrg opt_silent=false 111889c04b6cSmrgfunc_append preserve_args " $opt" 111989c04b6cSmrg ;; 112089c04b6cSmrg --no-warning|--no-warn) 112189c04b6cSmrg opt_warning=false 11226fae4e5dSmrgfunc_append preserve_args " $opt" 11239c9ff80cSmrg ;; 11246fae4e5dSmrg --no-verbose) 11256fae4e5dSmrg opt_verbose=false 11266fae4e5dSmrgfunc_append preserve_args " $opt" 11276fae4e5dSmrg ;; 11286fae4e5dSmrg --silent|--quiet) 11296fae4e5dSmrg opt_silent=: 11306fae4e5dSmrgfunc_append preserve_args " $opt" 11316fae4e5dSmrg opt_verbose=false 11326fae4e5dSmrg ;; 11336fae4e5dSmrg --verbose|-v) 11346fae4e5dSmrg opt_verbose=: 11356fae4e5dSmrgfunc_append preserve_args " $opt" 11366fae4e5dSmrgopt_silent=false 11376fae4e5dSmrg ;; 11386fae4e5dSmrg --tag) 11396fae4e5dSmrg test $# = 0 && func_missing_arg $opt && break 11406fae4e5dSmrg optarg="$1" 11416fae4e5dSmrg opt_tag="$optarg" 11426fae4e5dSmrgfunc_append preserve_args " $opt $optarg" 11436fae4e5dSmrgfunc_enable_tag "$optarg" 11449c9ff80cSmrg shift 11459c9ff80cSmrg ;; 11469c9ff80cSmrg 11476fae4e5dSmrg -\?|-h) func_usage ;; 11486fae4e5dSmrg --help) func_help ;; 11496fae4e5dSmrg --version) func_version ;; 11506fae4e5dSmrg 11519c9ff80cSmrg # Separate optargs to long options: 11526fae4e5dSmrg --*=*) 11536fae4e5dSmrg func_split_long_opt "$opt" 11546fae4e5dSmrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 11559c9ff80cSmrg shift 11569c9ff80cSmrg ;; 11579c9ff80cSmrg 11586fae4e5dSmrg # Separate non-argument short options: 11596fae4e5dSmrg -\?*|-h*|-n*|-v*) 11606fae4e5dSmrg func_split_short_opt "$opt" 11616fae4e5dSmrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 11626fae4e5dSmrg shift 11639c9ff80cSmrg ;; 11646fae4e5dSmrg 11656fae4e5dSmrg --) break ;; 11666fae4e5dSmrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 11676fae4e5dSmrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 11689c9ff80cSmrg esac 11699c9ff80cSmrg done 11709c9ff80cSmrg 11716fae4e5dSmrg # Validate options: 11726fae4e5dSmrg 11736fae4e5dSmrg # save first non-option argument 11746fae4e5dSmrg if test "$#" -gt 0; then 11756fae4e5dSmrg nonopt="$opt" 11766fae4e5dSmrg shift 11776fae4e5dSmrg fi 11786fae4e5dSmrg 11796fae4e5dSmrg # preserve --debug 11806fae4e5dSmrg test "$opt_debug" = : || func_append preserve_args " --debug" 11819c9ff80cSmrg 11829c9ff80cSmrg case $host in 11839c9ff80cSmrg *cygwin* | *mingw* | *pw32* | *cegcc*) 11849c9ff80cSmrg # don't eliminate duplications in $postdeps and $predeps 11859c9ff80cSmrg opt_duplicate_compiler_generated_deps=: 11861f0ac6a5Smrg ;; 11871f0ac6a5Smrg *) 11886fae4e5dSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 11899c9ff80cSmrg ;; 11909c9ff80cSmrg esac 11911f0ac6a5Smrg 11926fae4e5dSmrg $opt_help || { 11936fae4e5dSmrg # Sanity checks first: 11946fae4e5dSmrg func_check_version_match 11959c9ff80cSmrg 11966fae4e5dSmrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 11976fae4e5dSmrg func_fatal_configuration "not configured to build any kind of library" 11989c9ff80cSmrg fi 11999c9ff80cSmrg 12006fae4e5dSmrg # Darwin sucks 12016fae4e5dSmrg eval std_shrext=\"$shrext_cmds\" 12029c9ff80cSmrg 12036fae4e5dSmrg # Only execute mode is allowed to have -dlopen flags. 12046fae4e5dSmrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 12056fae4e5dSmrg func_error "unrecognized option \`-dlopen'" 12066fae4e5dSmrg $ECHO "$help" 1>&2 12076fae4e5dSmrg exit $EXIT_FAILURE 12086fae4e5dSmrg fi 12091f0ac6a5Smrg 12106fae4e5dSmrg # Change the help message to a mode-specific one. 12116fae4e5dSmrg generic_help="$help" 12126fae4e5dSmrg help="Try \`$progname --help --mode=$opt_mode' for more information." 12136fae4e5dSmrg } 12149c9ff80cSmrg 12159c9ff80cSmrg 12166fae4e5dSmrg # Bail if the options were screwed 12176fae4e5dSmrg $exit_cmd $EXIT_FAILURE 12186fae4e5dSmrg} 12199c9ff80cSmrg 12209c9ff80cSmrg 12211f0ac6a5Smrg 12221f0ac6a5Smrg 12236fae4e5dSmrg## ----------- ## 12246fae4e5dSmrg## Main. ## 12256fae4e5dSmrg## ----------- ## 12261f0ac6a5Smrg 12279c9ff80cSmrg# func_lalib_p file 12289c9ff80cSmrg# True iff FILE is a libtool `.la' library or `.lo' object file. 12299c9ff80cSmrg# This function is only a basic sanity check; it will hardly flush out 12309c9ff80cSmrg# determined imposters. 12319c9ff80cSmrgfunc_lalib_p () 12329c9ff80cSmrg{ 12339c9ff80cSmrg test -f "$1" && 12349c9ff80cSmrg $SED -e 4q "$1" 2>/dev/null \ 12359c9ff80cSmrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 12369c9ff80cSmrg} 12371f0ac6a5Smrg 12389c9ff80cSmrg# func_lalib_unsafe_p file 12399c9ff80cSmrg# True iff FILE is a libtool `.la' library or `.lo' object file. 12409c9ff80cSmrg# This function implements the same check as func_lalib_p without 12419c9ff80cSmrg# resorting to external programs. To this end, it redirects stdin and 12429c9ff80cSmrg# closes it afterwards, without saving the original file descriptor. 12439c9ff80cSmrg# As a safety measure, use it only where a negative result would be 12449c9ff80cSmrg# fatal anyway. Works if `file' does not exist. 12459c9ff80cSmrgfunc_lalib_unsafe_p () 12469c9ff80cSmrg{ 12479c9ff80cSmrg lalib_p=no 12489c9ff80cSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 12499c9ff80cSmrg for lalib_p_l in 1 2 3 4 12509c9ff80cSmrg do 12519c9ff80cSmrg read lalib_p_line 12529c9ff80cSmrg case "$lalib_p_line" in 12539c9ff80cSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 12549c9ff80cSmrg esac 12559c9ff80cSmrg done 12569c9ff80cSmrg exec 0<&5 5<&- 12579c9ff80cSmrg fi 12589c9ff80cSmrg test "$lalib_p" = yes 12599c9ff80cSmrg} 12601f0ac6a5Smrg 12619c9ff80cSmrg# func_ltwrapper_script_p file 12629c9ff80cSmrg# True iff FILE is a libtool wrapper script 12639c9ff80cSmrg# This function is only a basic sanity check; it will hardly flush out 12649c9ff80cSmrg# determined imposters. 12659c9ff80cSmrgfunc_ltwrapper_script_p () 12669c9ff80cSmrg{ 12679c9ff80cSmrg func_lalib_p "$1" 12689c9ff80cSmrg} 12691f0ac6a5Smrg 12709c9ff80cSmrg# func_ltwrapper_executable_p file 12719c9ff80cSmrg# True iff FILE is a libtool wrapper executable 12729c9ff80cSmrg# This function is only a basic sanity check; it will hardly flush out 12739c9ff80cSmrg# determined imposters. 12749c9ff80cSmrgfunc_ltwrapper_executable_p () 12759c9ff80cSmrg{ 12769c9ff80cSmrg func_ltwrapper_exec_suffix= 12779c9ff80cSmrg case $1 in 12789c9ff80cSmrg *.exe) ;; 12799c9ff80cSmrg *) func_ltwrapper_exec_suffix=.exe ;; 12809c9ff80cSmrg esac 12819c9ff80cSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 12829c9ff80cSmrg} 12831f0ac6a5Smrg 12849c9ff80cSmrg# func_ltwrapper_scriptname file 12859c9ff80cSmrg# Assumes file is an ltwrapper_executable 12869c9ff80cSmrg# uses $file to determine the appropriate filename for a 12879c9ff80cSmrg# temporary ltwrapper_script. 12889c9ff80cSmrgfunc_ltwrapper_scriptname () 12899c9ff80cSmrg{ 12906fae4e5dSmrg func_dirname_and_basename "$1" "" "." 12916fae4e5dSmrg func_stripname '' '.exe' "$func_basename_result" 12926fae4e5dSmrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 12939c9ff80cSmrg} 12949c9ff80cSmrg 12959c9ff80cSmrg# func_ltwrapper_p file 12969c9ff80cSmrg# True iff FILE is a libtool wrapper script or wrapper executable 12979c9ff80cSmrg# This function is only a basic sanity check; it will hardly flush out 12989c9ff80cSmrg# determined imposters. 12999c9ff80cSmrgfunc_ltwrapper_p () 13009c9ff80cSmrg{ 13019c9ff80cSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 13029c9ff80cSmrg} 13039c9ff80cSmrg 13049c9ff80cSmrg 13059c9ff80cSmrg# func_execute_cmds commands fail_cmd 13069c9ff80cSmrg# Execute tilde-delimited COMMANDS. 13079c9ff80cSmrg# If FAIL_CMD is given, eval that upon failure. 13089c9ff80cSmrg# FAIL_CMD may read-access the current command in variable CMD! 13099c9ff80cSmrgfunc_execute_cmds () 13109c9ff80cSmrg{ 13119c9ff80cSmrg $opt_debug 13129c9ff80cSmrg save_ifs=$IFS; IFS='~' 13139c9ff80cSmrg for cmd in $1; do 13149c9ff80cSmrg IFS=$save_ifs 13159c9ff80cSmrg eval cmd=\"$cmd\" 13169c9ff80cSmrg func_show_eval "$cmd" "${2-:}" 13179c9ff80cSmrg done 13189c9ff80cSmrg IFS=$save_ifs 13199c9ff80cSmrg} 13209c9ff80cSmrg 13219c9ff80cSmrg 13229c9ff80cSmrg# func_source file 13239c9ff80cSmrg# Source FILE, adding directory component if necessary. 13249c9ff80cSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 13259c9ff80cSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 13269c9ff80cSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 13279c9ff80cSmrg# `FILE.' does not work on cygwin managed mounts. 13289c9ff80cSmrgfunc_source () 13299c9ff80cSmrg{ 13309c9ff80cSmrg $opt_debug 13319c9ff80cSmrg case $1 in 13329c9ff80cSmrg */* | *\\*) . "$1" ;; 13339c9ff80cSmrg *) . "./$1" ;; 13349c9ff80cSmrg esac 13359c9ff80cSmrg} 13369c9ff80cSmrg 13379c9ff80cSmrg 13386fae4e5dSmrg# func_resolve_sysroot PATH 13396fae4e5dSmrg# Replace a leading = in PATH with a sysroot. Store the result into 13406fae4e5dSmrg# func_resolve_sysroot_result 13416fae4e5dSmrgfunc_resolve_sysroot () 13426fae4e5dSmrg{ 13436fae4e5dSmrg func_resolve_sysroot_result=$1 13446fae4e5dSmrg case $func_resolve_sysroot_result in 13456fae4e5dSmrg =*) 13466fae4e5dSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 13476fae4e5dSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 13486fae4e5dSmrg ;; 13496fae4e5dSmrg esac 13506fae4e5dSmrg} 13516fae4e5dSmrg 13526fae4e5dSmrg# func_replace_sysroot PATH 13536fae4e5dSmrg# If PATH begins with the sysroot, replace it with = and 13546fae4e5dSmrg# store the result into func_replace_sysroot_result. 13556fae4e5dSmrgfunc_replace_sysroot () 13566fae4e5dSmrg{ 13576fae4e5dSmrg case "$lt_sysroot:$1" in 13586fae4e5dSmrg ?*:"$lt_sysroot"*) 13596fae4e5dSmrg func_stripname "$lt_sysroot" '' "$1" 13606fae4e5dSmrg func_replace_sysroot_result="=$func_stripname_result" 13616fae4e5dSmrg ;; 13626fae4e5dSmrg *) 13636fae4e5dSmrg # Including no sysroot. 13646fae4e5dSmrg func_replace_sysroot_result=$1 13656fae4e5dSmrg ;; 13666fae4e5dSmrg esac 13676fae4e5dSmrg} 13686fae4e5dSmrg 13699c9ff80cSmrg# func_infer_tag arg 13709c9ff80cSmrg# Infer tagged configuration to use if any are available and 13719c9ff80cSmrg# if one wasn't chosen via the "--tag" command line option. 13729c9ff80cSmrg# Only attempt this if the compiler in the base compile 13739c9ff80cSmrg# command doesn't match the default compiler. 13749c9ff80cSmrg# arg is usually of the form 'gcc ...' 13759c9ff80cSmrgfunc_infer_tag () 13769c9ff80cSmrg{ 13779c9ff80cSmrg $opt_debug 13789c9ff80cSmrg if test -n "$available_tags" && test -z "$tagname"; then 13799c9ff80cSmrg CC_quoted= 13809c9ff80cSmrg for arg in $CC; do 13816fae4e5dSmrg func_append_quoted CC_quoted "$arg" 13829c9ff80cSmrg done 13836fae4e5dSmrg CC_expanded=`func_echo_all $CC` 13846fae4e5dSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 13859c9ff80cSmrg case $@ in 13869c9ff80cSmrg # Blanks in the command may have been stripped by the calling shell, 13879c9ff80cSmrg # but not from the CC environment variable when configure was run. 13886fae4e5dSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 13896fae4e5dSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 13909c9ff80cSmrg # Blanks at the start of $base_compile will cause this to fail 13919c9ff80cSmrg # if we don't check for them as well. 13929c9ff80cSmrg *) 13939c9ff80cSmrg for z in $available_tags; do 13949c9ff80cSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 13959c9ff80cSmrg # Evaluate the configuration. 13969c9ff80cSmrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 13979c9ff80cSmrg CC_quoted= 13989c9ff80cSmrg for arg in $CC; do 13999c9ff80cSmrg # Double-quote args containing other shell metacharacters. 14006fae4e5dSmrg func_append_quoted CC_quoted "$arg" 14019c9ff80cSmrg done 14026fae4e5dSmrg CC_expanded=`func_echo_all $CC` 14036fae4e5dSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 14049c9ff80cSmrg case "$@ " in 14056fae4e5dSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 14066fae4e5dSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 14079c9ff80cSmrg # The compiler in the base compile command matches 14089c9ff80cSmrg # the one in the tagged configuration. 14099c9ff80cSmrg # Assume this is the tagged configuration we want. 14109c9ff80cSmrg tagname=$z 14119c9ff80cSmrg break 14129c9ff80cSmrg ;; 14139c9ff80cSmrg esac 14149c9ff80cSmrg fi 14159c9ff80cSmrg done 14169c9ff80cSmrg # If $tagname still isn't set, then no tagged configuration 14179c9ff80cSmrg # was found and let the user know that the "--tag" command 14189c9ff80cSmrg # line option must be used. 14199c9ff80cSmrg if test -z "$tagname"; then 14209c9ff80cSmrg func_echo "unable to infer tagged configuration" 14219c9ff80cSmrg func_fatal_error "specify a tag with \`--tag'" 14229c9ff80cSmrg# else 14239c9ff80cSmrg# func_verbose "using $tagname tagged configuration" 14249c9ff80cSmrg fi 14259c9ff80cSmrg ;; 14269c9ff80cSmrg esac 14279c9ff80cSmrg fi 14289c9ff80cSmrg} 14299c9ff80cSmrg 14309c9ff80cSmrg 14319c9ff80cSmrg 14329c9ff80cSmrg# func_write_libtool_object output_name pic_name nonpic_name 14339c9ff80cSmrg# Create a libtool object file (analogous to a ".la" file), 14349c9ff80cSmrg# but don't create it if we're doing a dry run. 14359c9ff80cSmrgfunc_write_libtool_object () 14369c9ff80cSmrg{ 14379c9ff80cSmrg write_libobj=${1} 14389c9ff80cSmrg if test "$build_libtool_libs" = yes; then 14399c9ff80cSmrg write_lobj=\'${2}\' 14409c9ff80cSmrg else 14419c9ff80cSmrg write_lobj=none 14429c9ff80cSmrg fi 14439c9ff80cSmrg 14449c9ff80cSmrg if test "$build_old_libs" = yes; then 14459c9ff80cSmrg write_oldobj=\'${3}\' 14469c9ff80cSmrg else 14479c9ff80cSmrg write_oldobj=none 14489c9ff80cSmrg fi 14499c9ff80cSmrg 14509c9ff80cSmrg $opt_dry_run || { 14519c9ff80cSmrg cat >${write_libobj}T <<EOF 14529c9ff80cSmrg# $write_libobj - a libtool object file 14539c9ff80cSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 14549c9ff80cSmrg# 14559c9ff80cSmrg# Please DO NOT delete this file! 14569c9ff80cSmrg# It is necessary for linking the library. 14579c9ff80cSmrg 14589c9ff80cSmrg# Name of the PIC object. 14599c9ff80cSmrgpic_object=$write_lobj 14609c9ff80cSmrg 14619c9ff80cSmrg# Name of the non-PIC object 14629c9ff80cSmrgnon_pic_object=$write_oldobj 14639c9ff80cSmrg 14649c9ff80cSmrgEOF 14659c9ff80cSmrg $MV "${write_libobj}T" "${write_libobj}" 14669c9ff80cSmrg } 14679c9ff80cSmrg} 14689c9ff80cSmrg 14696fae4e5dSmrg 14706fae4e5dSmrg################################################## 14716fae4e5dSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 14726fae4e5dSmrg################################################## 14736fae4e5dSmrg 14746fae4e5dSmrg# func_convert_core_file_wine_to_w32 ARG 14756fae4e5dSmrg# Helper function used by file name conversion functions when $build is *nix, 14766fae4e5dSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 14776fae4e5dSmrg# correctly configured wine environment available, with the winepath program 14786fae4e5dSmrg# in $build's $PATH. 14796fae4e5dSmrg# 14806fae4e5dSmrg# ARG is the $build file name to be converted to w32 format. 14816fae4e5dSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 14826fae4e5dSmrg# be empty on error (or when ARG is empty) 14836fae4e5dSmrgfunc_convert_core_file_wine_to_w32 () 14846fae4e5dSmrg{ 14856fae4e5dSmrg $opt_debug 14866fae4e5dSmrg func_convert_core_file_wine_to_w32_result="$1" 14876fae4e5dSmrg if test -n "$1"; then 14886fae4e5dSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 14896fae4e5dSmrg # are forced to check the contents of stdout. On the other hand, if the 14906fae4e5dSmrg # command is not found, the shell will set an exit code of 127 and print 14916fae4e5dSmrg # *an error message* to stdout. So we must check for both error code of 14926fae4e5dSmrg # zero AND non-empty stdout, which explains the odd construction: 14936fae4e5dSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 14946fae4e5dSmrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 14956fae4e5dSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 14966fae4e5dSmrg $SED -e "$lt_sed_naive_backslashify"` 14976fae4e5dSmrg else 14986fae4e5dSmrg func_convert_core_file_wine_to_w32_result= 14996fae4e5dSmrg fi 15006fae4e5dSmrg fi 15016fae4e5dSmrg} 15026fae4e5dSmrg# end: func_convert_core_file_wine_to_w32 15036fae4e5dSmrg 15046fae4e5dSmrg 15056fae4e5dSmrg# func_convert_core_path_wine_to_w32 ARG 15066fae4e5dSmrg# Helper function used by path conversion functions when $build is *nix, and 15076fae4e5dSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 15086fae4e5dSmrg# configured wine environment available, with the winepath program in $build's 15096fae4e5dSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 15106fae4e5dSmrg# 15116fae4e5dSmrg# ARG is path to be converted from $build format to win32. 15126fae4e5dSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 15136fae4e5dSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 15146fae4e5dSmrg# are convertible, then the result may be empty. 15156fae4e5dSmrgfunc_convert_core_path_wine_to_w32 () 15166fae4e5dSmrg{ 15176fae4e5dSmrg $opt_debug 15186fae4e5dSmrg # unfortunately, winepath doesn't convert paths, only file names 15196fae4e5dSmrg func_convert_core_path_wine_to_w32_result="" 15206fae4e5dSmrg if test -n "$1"; then 15216fae4e5dSmrg oldIFS=$IFS 15226fae4e5dSmrg IFS=: 15236fae4e5dSmrg for func_convert_core_path_wine_to_w32_f in $1; do 15246fae4e5dSmrg IFS=$oldIFS 15256fae4e5dSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 15266fae4e5dSmrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 15276fae4e5dSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 15286fae4e5dSmrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 15296fae4e5dSmrg else 15306fae4e5dSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 15316fae4e5dSmrg fi 15326fae4e5dSmrg fi 15336fae4e5dSmrg done 15346fae4e5dSmrg IFS=$oldIFS 15356fae4e5dSmrg fi 15366fae4e5dSmrg} 15376fae4e5dSmrg# end: func_convert_core_path_wine_to_w32 15386fae4e5dSmrg 15396fae4e5dSmrg 15406fae4e5dSmrg# func_cygpath ARGS... 15416fae4e5dSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 15426fae4e5dSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 15436fae4e5dSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 15446fae4e5dSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 15456fae4e5dSmrg# file name or path is assumed to be in w32 format, as previously converted 15466fae4e5dSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 15476fae4e5dSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 15486fae4e5dSmrg# Cygwin format). Returns an empty string on error. 15496fae4e5dSmrg# 15506fae4e5dSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 15516fae4e5dSmrg# be converted. 15526fae4e5dSmrg# 15536fae4e5dSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 15546fae4e5dSmrg# environment variable; do not put it in $PATH. 15556fae4e5dSmrgfunc_cygpath () 15566fae4e5dSmrg{ 15576fae4e5dSmrg $opt_debug 15586fae4e5dSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 15596fae4e5dSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 15606fae4e5dSmrg if test "$?" -ne 0; then 15616fae4e5dSmrg # on failure, ensure result is empty 15626fae4e5dSmrg func_cygpath_result= 15636fae4e5dSmrg fi 15646fae4e5dSmrg else 15656fae4e5dSmrg func_cygpath_result= 15666fae4e5dSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 15676fae4e5dSmrg fi 15686fae4e5dSmrg} 15696fae4e5dSmrg#end: func_cygpath 15706fae4e5dSmrg 15716fae4e5dSmrg 15726fae4e5dSmrg# func_convert_core_msys_to_w32 ARG 15736fae4e5dSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 15746fae4e5dSmrg# result in func_convert_core_msys_to_w32_result. 15756fae4e5dSmrgfunc_convert_core_msys_to_w32 () 15766fae4e5dSmrg{ 15776fae4e5dSmrg $opt_debug 15786fae4e5dSmrg # awkward: cmd appends spaces to result 15796fae4e5dSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 15806fae4e5dSmrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 15816fae4e5dSmrg} 15826fae4e5dSmrg#end: func_convert_core_msys_to_w32 15836fae4e5dSmrg 15846fae4e5dSmrg 15856fae4e5dSmrg# func_convert_file_check ARG1 ARG2 15866fae4e5dSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 15876fae4e5dSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 15886fae4e5dSmrg# func_to_host_file_result to ARG1). 15896fae4e5dSmrgfunc_convert_file_check () 15906fae4e5dSmrg{ 15916fae4e5dSmrg $opt_debug 15926fae4e5dSmrg if test -z "$2" && test -n "$1" ; then 15936fae4e5dSmrg func_error "Could not determine host file name corresponding to" 15946fae4e5dSmrg func_error " \`$1'" 15956fae4e5dSmrg func_error "Continuing, but uninstalled executables may not work." 15966fae4e5dSmrg # Fallback: 15976fae4e5dSmrg func_to_host_file_result="$1" 15986fae4e5dSmrg fi 15996fae4e5dSmrg} 16006fae4e5dSmrg# end func_convert_file_check 16016fae4e5dSmrg 16026fae4e5dSmrg 16036fae4e5dSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 16046fae4e5dSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 16056fae4e5dSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 16066fae4e5dSmrg# func_to_host_file_result to a simplistic fallback value (see below). 16076fae4e5dSmrgfunc_convert_path_check () 16086fae4e5dSmrg{ 16096fae4e5dSmrg $opt_debug 16106fae4e5dSmrg if test -z "$4" && test -n "$3"; then 16116fae4e5dSmrg func_error "Could not determine the host path corresponding to" 16126fae4e5dSmrg func_error " \`$3'" 16136fae4e5dSmrg func_error "Continuing, but uninstalled executables may not work." 16146fae4e5dSmrg # Fallback. This is a deliberately simplistic "conversion" and 16156fae4e5dSmrg # should not be "improved". See libtool.info. 16166fae4e5dSmrg if test "x$1" != "x$2"; then 16176fae4e5dSmrg lt_replace_pathsep_chars="s|$1|$2|g" 16186fae4e5dSmrg func_to_host_path_result=`echo "$3" | 16196fae4e5dSmrg $SED -e "$lt_replace_pathsep_chars"` 16206fae4e5dSmrg else 16216fae4e5dSmrg func_to_host_path_result="$3" 16226fae4e5dSmrg fi 16236fae4e5dSmrg fi 16246fae4e5dSmrg} 16256fae4e5dSmrg# end func_convert_path_check 16266fae4e5dSmrg 16276fae4e5dSmrg 16286fae4e5dSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 16296fae4e5dSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 16306fae4e5dSmrg# and appending REPL if ORIG matches BACKPAT. 16316fae4e5dSmrgfunc_convert_path_front_back_pathsep () 16326fae4e5dSmrg{ 16336fae4e5dSmrg $opt_debug 16346fae4e5dSmrg case $4 in 16356fae4e5dSmrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 16366fae4e5dSmrg ;; 16376fae4e5dSmrg esac 16386fae4e5dSmrg case $4 in 16396fae4e5dSmrg $2 ) func_append func_to_host_path_result "$3" 16406fae4e5dSmrg ;; 16416fae4e5dSmrg esac 16426fae4e5dSmrg} 16436fae4e5dSmrg# end func_convert_path_front_back_pathsep 16446fae4e5dSmrg 16456fae4e5dSmrg 16466fae4e5dSmrg################################################## 16476fae4e5dSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 16486fae4e5dSmrg################################################## 16496fae4e5dSmrg# invoked via `$to_host_file_cmd ARG' 16506fae4e5dSmrg# 16516fae4e5dSmrg# In each case, ARG is the path to be converted from $build to $host format. 16526fae4e5dSmrg# Result will be available in $func_to_host_file_result. 16536fae4e5dSmrg 16546fae4e5dSmrg 16556fae4e5dSmrg# func_to_host_file ARG 16566fae4e5dSmrg# Converts the file name ARG from $build format to $host format. Return result 16576fae4e5dSmrg# in func_to_host_file_result. 16586fae4e5dSmrgfunc_to_host_file () 16596fae4e5dSmrg{ 16606fae4e5dSmrg $opt_debug 16616fae4e5dSmrg $to_host_file_cmd "$1" 16626fae4e5dSmrg} 16636fae4e5dSmrg# end func_to_host_file 16646fae4e5dSmrg 16656fae4e5dSmrg 16666fae4e5dSmrg# func_to_tool_file ARG LAZY 16676fae4e5dSmrg# converts the file name ARG from $build format to toolchain format. Return 16686fae4e5dSmrg# result in func_to_tool_file_result. If the conversion in use is listed 16696fae4e5dSmrg# in (the comma separated) LAZY, no conversion takes place. 16706fae4e5dSmrgfunc_to_tool_file () 16716fae4e5dSmrg{ 16726fae4e5dSmrg $opt_debug 16736fae4e5dSmrg case ,$2, in 16746fae4e5dSmrg *,"$to_tool_file_cmd",*) 16756fae4e5dSmrg func_to_tool_file_result=$1 16766fae4e5dSmrg ;; 16776fae4e5dSmrg *) 16786fae4e5dSmrg $to_tool_file_cmd "$1" 16796fae4e5dSmrg func_to_tool_file_result=$func_to_host_file_result 16806fae4e5dSmrg ;; 16816fae4e5dSmrg esac 16826fae4e5dSmrg} 16836fae4e5dSmrg# end func_to_tool_file 16846fae4e5dSmrg 16856fae4e5dSmrg 16866fae4e5dSmrg# func_convert_file_noop ARG 16876fae4e5dSmrg# Copy ARG to func_to_host_file_result. 16886fae4e5dSmrgfunc_convert_file_noop () 16896fae4e5dSmrg{ 16906fae4e5dSmrg func_to_host_file_result="$1" 16916fae4e5dSmrg} 16926fae4e5dSmrg# end func_convert_file_noop 16936fae4e5dSmrg 16946fae4e5dSmrg 16956fae4e5dSmrg# func_convert_file_msys_to_w32 ARG 16966fae4e5dSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 16976fae4e5dSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 16986fae4e5dSmrg# func_to_host_file_result. 16996fae4e5dSmrgfunc_convert_file_msys_to_w32 () 17006fae4e5dSmrg{ 17016fae4e5dSmrg $opt_debug 17026fae4e5dSmrg func_to_host_file_result="$1" 17036fae4e5dSmrg if test -n "$1"; then 17046fae4e5dSmrg func_convert_core_msys_to_w32 "$1" 17056fae4e5dSmrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 17066fae4e5dSmrg fi 17076fae4e5dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17086fae4e5dSmrg} 17096fae4e5dSmrg# end func_convert_file_msys_to_w32 17106fae4e5dSmrg 17116fae4e5dSmrg 17126fae4e5dSmrg# func_convert_file_cygwin_to_w32 ARG 17136fae4e5dSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 17146fae4e5dSmrg# func_to_host_file_result. 17156fae4e5dSmrgfunc_convert_file_cygwin_to_w32 () 17166fae4e5dSmrg{ 17176fae4e5dSmrg $opt_debug 17186fae4e5dSmrg func_to_host_file_result="$1" 17196fae4e5dSmrg if test -n "$1"; then 17206fae4e5dSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 17216fae4e5dSmrg # LT_CYGPATH in this case. 17226fae4e5dSmrg func_to_host_file_result=`cygpath -m "$1"` 17236fae4e5dSmrg fi 17246fae4e5dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17256fae4e5dSmrg} 17266fae4e5dSmrg# end func_convert_file_cygwin_to_w32 17276fae4e5dSmrg 17286fae4e5dSmrg 17296fae4e5dSmrg# func_convert_file_nix_to_w32 ARG 17306fae4e5dSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 17316fae4e5dSmrg# and a working winepath. Returns result in func_to_host_file_result. 17326fae4e5dSmrgfunc_convert_file_nix_to_w32 () 17336fae4e5dSmrg{ 17346fae4e5dSmrg $opt_debug 17356fae4e5dSmrg func_to_host_file_result="$1" 17366fae4e5dSmrg if test -n "$1"; then 17376fae4e5dSmrg func_convert_core_file_wine_to_w32 "$1" 17386fae4e5dSmrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 17396fae4e5dSmrg fi 17406fae4e5dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17416fae4e5dSmrg} 17426fae4e5dSmrg# end func_convert_file_nix_to_w32 17436fae4e5dSmrg 17446fae4e5dSmrg 17456fae4e5dSmrg# func_convert_file_msys_to_cygwin ARG 17466fae4e5dSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 17476fae4e5dSmrg# Returns result in func_to_host_file_result. 17486fae4e5dSmrgfunc_convert_file_msys_to_cygwin () 17496fae4e5dSmrg{ 17506fae4e5dSmrg $opt_debug 17516fae4e5dSmrg func_to_host_file_result="$1" 17526fae4e5dSmrg if test -n "$1"; then 17536fae4e5dSmrg func_convert_core_msys_to_w32 "$1" 17546fae4e5dSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 17556fae4e5dSmrg func_to_host_file_result="$func_cygpath_result" 17566fae4e5dSmrg fi 17576fae4e5dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17586fae4e5dSmrg} 17596fae4e5dSmrg# end func_convert_file_msys_to_cygwin 17606fae4e5dSmrg 17616fae4e5dSmrg 17626fae4e5dSmrg# func_convert_file_nix_to_cygwin ARG 17636fae4e5dSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 17646fae4e5dSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 17656fae4e5dSmrg# in func_to_host_file_result. 17666fae4e5dSmrgfunc_convert_file_nix_to_cygwin () 17676fae4e5dSmrg{ 17686fae4e5dSmrg $opt_debug 17696fae4e5dSmrg func_to_host_file_result="$1" 17706fae4e5dSmrg if test -n "$1"; then 17716fae4e5dSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 17726fae4e5dSmrg func_convert_core_file_wine_to_w32 "$1" 17736fae4e5dSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 17746fae4e5dSmrg func_to_host_file_result="$func_cygpath_result" 17756fae4e5dSmrg fi 17766fae4e5dSmrg func_convert_file_check "$1" "$func_to_host_file_result" 17776fae4e5dSmrg} 17786fae4e5dSmrg# end func_convert_file_nix_to_cygwin 17796fae4e5dSmrg 17806fae4e5dSmrg 17816fae4e5dSmrg############################################# 17826fae4e5dSmrg# $build to $host PATH CONVERSION FUNCTIONS # 17836fae4e5dSmrg############################################# 17846fae4e5dSmrg# invoked via `$to_host_path_cmd ARG' 17856fae4e5dSmrg# 17866fae4e5dSmrg# In each case, ARG is the path to be converted from $build to $host format. 17876fae4e5dSmrg# The result will be available in $func_to_host_path_result. 17886fae4e5dSmrg# 17896fae4e5dSmrg# Path separators are also converted from $build format to $host format. If 17906fae4e5dSmrg# ARG begins or ends with a path separator character, it is preserved (but 17916fae4e5dSmrg# converted to $host format) on output. 17926fae4e5dSmrg# 17936fae4e5dSmrg# All path conversion functions are named using the following convention: 17946fae4e5dSmrg# file name conversion function : func_convert_file_X_to_Y () 17956fae4e5dSmrg# path conversion function : func_convert_path_X_to_Y () 17966fae4e5dSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 17976fae4e5dSmrg# same. If conversion functions are added for new $build/$host combinations, 17986fae4e5dSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 17996fae4e5dSmrg# will break. 18006fae4e5dSmrg 18016fae4e5dSmrg 18026fae4e5dSmrg# func_init_to_host_path_cmd 18036fae4e5dSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 18046fae4e5dSmrg# appropriate value, based on the value of $to_host_file_cmd. 18056fae4e5dSmrgto_host_path_cmd= 18066fae4e5dSmrgfunc_init_to_host_path_cmd () 18076fae4e5dSmrg{ 18086fae4e5dSmrg $opt_debug 18096fae4e5dSmrg if test -z "$to_host_path_cmd"; then 18106fae4e5dSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 18116fae4e5dSmrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 18126fae4e5dSmrg fi 18136fae4e5dSmrg} 18146fae4e5dSmrg 18156fae4e5dSmrg 18166fae4e5dSmrg# func_to_host_path ARG 18176fae4e5dSmrg# Converts the path ARG from $build format to $host format. Return result 18186fae4e5dSmrg# in func_to_host_path_result. 18196fae4e5dSmrgfunc_to_host_path () 18206fae4e5dSmrg{ 18216fae4e5dSmrg $opt_debug 18226fae4e5dSmrg func_init_to_host_path_cmd 18236fae4e5dSmrg $to_host_path_cmd "$1" 18246fae4e5dSmrg} 18256fae4e5dSmrg# end func_to_host_path 18266fae4e5dSmrg 18276fae4e5dSmrg 18286fae4e5dSmrg# func_convert_path_noop ARG 18296fae4e5dSmrg# Copy ARG to func_to_host_path_result. 18306fae4e5dSmrgfunc_convert_path_noop () 18316fae4e5dSmrg{ 18326fae4e5dSmrg func_to_host_path_result="$1" 18336fae4e5dSmrg} 18346fae4e5dSmrg# end func_convert_path_noop 18356fae4e5dSmrg 18366fae4e5dSmrg 18376fae4e5dSmrg# func_convert_path_msys_to_w32 ARG 18386fae4e5dSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 18396fae4e5dSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 18406fae4e5dSmrg# func_to_host_path_result. 18416fae4e5dSmrgfunc_convert_path_msys_to_w32 () 18426fae4e5dSmrg{ 18436fae4e5dSmrg $opt_debug 18446fae4e5dSmrg func_to_host_path_result="$1" 18456fae4e5dSmrg if test -n "$1"; then 18466fae4e5dSmrg # Remove leading and trailing path separator characters from ARG. MSYS 18476fae4e5dSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 18486fae4e5dSmrg # and winepath ignores them completely. 18496fae4e5dSmrg func_stripname : : "$1" 18506fae4e5dSmrg func_to_host_path_tmp1=$func_stripname_result 18516fae4e5dSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 18526fae4e5dSmrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 18536fae4e5dSmrg func_convert_path_check : ";" \ 18546fae4e5dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 18556fae4e5dSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 18566fae4e5dSmrg fi 18576fae4e5dSmrg} 18586fae4e5dSmrg# end func_convert_path_msys_to_w32 18596fae4e5dSmrg 18606fae4e5dSmrg 18616fae4e5dSmrg# func_convert_path_cygwin_to_w32 ARG 18626fae4e5dSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 18636fae4e5dSmrg# func_to_host_file_result. 18646fae4e5dSmrgfunc_convert_path_cygwin_to_w32 () 18656fae4e5dSmrg{ 18666fae4e5dSmrg $opt_debug 18676fae4e5dSmrg func_to_host_path_result="$1" 18686fae4e5dSmrg if test -n "$1"; then 18696fae4e5dSmrg # See func_convert_path_msys_to_w32: 18706fae4e5dSmrg func_stripname : : "$1" 18716fae4e5dSmrg func_to_host_path_tmp1=$func_stripname_result 18726fae4e5dSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 18736fae4e5dSmrg func_convert_path_check : ";" \ 18746fae4e5dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 18756fae4e5dSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 18766fae4e5dSmrg fi 18776fae4e5dSmrg} 18786fae4e5dSmrg# end func_convert_path_cygwin_to_w32 18796fae4e5dSmrg 18806fae4e5dSmrg 18816fae4e5dSmrg# func_convert_path_nix_to_w32 ARG 18826fae4e5dSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 18836fae4e5dSmrg# a working winepath. Returns result in func_to_host_file_result. 18846fae4e5dSmrgfunc_convert_path_nix_to_w32 () 18856fae4e5dSmrg{ 18866fae4e5dSmrg $opt_debug 18876fae4e5dSmrg func_to_host_path_result="$1" 18886fae4e5dSmrg if test -n "$1"; then 18896fae4e5dSmrg # See func_convert_path_msys_to_w32: 18906fae4e5dSmrg func_stripname : : "$1" 18916fae4e5dSmrg func_to_host_path_tmp1=$func_stripname_result 18926fae4e5dSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 18936fae4e5dSmrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 18946fae4e5dSmrg func_convert_path_check : ";" \ 18956fae4e5dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 18966fae4e5dSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 18976fae4e5dSmrg fi 18986fae4e5dSmrg} 18996fae4e5dSmrg# end func_convert_path_nix_to_w32 19006fae4e5dSmrg 19016fae4e5dSmrg 19026fae4e5dSmrg# func_convert_path_msys_to_cygwin ARG 19036fae4e5dSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 19046fae4e5dSmrg# Returns result in func_to_host_file_result. 19056fae4e5dSmrgfunc_convert_path_msys_to_cygwin () 19066fae4e5dSmrg{ 19076fae4e5dSmrg $opt_debug 19086fae4e5dSmrg func_to_host_path_result="$1" 19096fae4e5dSmrg if test -n "$1"; then 19106fae4e5dSmrg # See func_convert_path_msys_to_w32: 19116fae4e5dSmrg func_stripname : : "$1" 19126fae4e5dSmrg func_to_host_path_tmp1=$func_stripname_result 19136fae4e5dSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 19146fae4e5dSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 19156fae4e5dSmrg func_to_host_path_result="$func_cygpath_result" 19166fae4e5dSmrg func_convert_path_check : : \ 19176fae4e5dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 19186fae4e5dSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 19196fae4e5dSmrg fi 19206fae4e5dSmrg} 19216fae4e5dSmrg# end func_convert_path_msys_to_cygwin 19226fae4e5dSmrg 19236fae4e5dSmrg 19246fae4e5dSmrg# func_convert_path_nix_to_cygwin ARG 19256fae4e5dSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 19266fae4e5dSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 19276fae4e5dSmrg# func_to_host_file_result. 19286fae4e5dSmrgfunc_convert_path_nix_to_cygwin () 19296fae4e5dSmrg{ 19306fae4e5dSmrg $opt_debug 19316fae4e5dSmrg func_to_host_path_result="$1" 19326fae4e5dSmrg if test -n "$1"; then 19336fae4e5dSmrg # Remove leading and trailing path separator characters from 19346fae4e5dSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 19356fae4e5dSmrg # into '.;' and ';.', and winepath ignores them completely. 19366fae4e5dSmrg func_stripname : : "$1" 19376fae4e5dSmrg func_to_host_path_tmp1=$func_stripname_result 19386fae4e5dSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 19396fae4e5dSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 19406fae4e5dSmrg func_to_host_path_result="$func_cygpath_result" 19416fae4e5dSmrg func_convert_path_check : : \ 19426fae4e5dSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 19436fae4e5dSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 19446fae4e5dSmrg fi 19456fae4e5dSmrg} 19466fae4e5dSmrg# end func_convert_path_nix_to_cygwin 19476fae4e5dSmrg 19486fae4e5dSmrg 19499c9ff80cSmrg# func_mode_compile arg... 19509c9ff80cSmrgfunc_mode_compile () 19519c9ff80cSmrg{ 19529c9ff80cSmrg $opt_debug 19539c9ff80cSmrg # Get the compilation command and the source file. 19549c9ff80cSmrg base_compile= 19559c9ff80cSmrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 19569c9ff80cSmrg suppress_opt=yes 19579c9ff80cSmrg suppress_output= 19589c9ff80cSmrg arg_mode=normal 19599c9ff80cSmrg libobj= 19609c9ff80cSmrg later= 19619c9ff80cSmrg pie_flag= 19629c9ff80cSmrg 19639c9ff80cSmrg for arg 19649c9ff80cSmrg do 19659c9ff80cSmrg case $arg_mode in 19669c9ff80cSmrg arg ) 19679c9ff80cSmrg # do not "continue". Instead, add this to base_compile 19689c9ff80cSmrg lastarg="$arg" 19699c9ff80cSmrg arg_mode=normal 19709c9ff80cSmrg ;; 19719c9ff80cSmrg 19729c9ff80cSmrg target ) 19739c9ff80cSmrg libobj="$arg" 19749c9ff80cSmrg arg_mode=normal 19759c9ff80cSmrg continue 19769c9ff80cSmrg ;; 19779c9ff80cSmrg 19789c9ff80cSmrg normal ) 19799c9ff80cSmrg # Accept any command-line options. 19809c9ff80cSmrg case $arg in 19819c9ff80cSmrg -o) 19829c9ff80cSmrg test -n "$libobj" && \ 19839c9ff80cSmrg func_fatal_error "you cannot specify \`-o' more than once" 19849c9ff80cSmrg arg_mode=target 19859c9ff80cSmrg continue 19869c9ff80cSmrg ;; 19879c9ff80cSmrg 19889c9ff80cSmrg -pie | -fpie | -fPIE) 19896fae4e5dSmrg func_append pie_flag " $arg" 19909c9ff80cSmrg continue 19919c9ff80cSmrg ;; 19929c9ff80cSmrg 19939c9ff80cSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 19946fae4e5dSmrg func_append later " $arg" 19959c9ff80cSmrg continue 19969c9ff80cSmrg ;; 19979c9ff80cSmrg 19989c9ff80cSmrg -no-suppress) 19991f0ac6a5Smrg suppress_opt=no 20001f0ac6a5Smrg continue 20011f0ac6a5Smrg ;; 20021f0ac6a5Smrg 20031f0ac6a5Smrg -Xcompiler) 20041f0ac6a5Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 20051f0ac6a5Smrg continue # The current "srcfile" will either be retained or 20061f0ac6a5Smrg ;; # replaced later. I would guess that would be a bug. 20071f0ac6a5Smrg 20081f0ac6a5Smrg -Wc,*) 20099c9ff80cSmrg func_stripname '-Wc,' '' "$arg" 20109c9ff80cSmrg args=$func_stripname_result 20111f0ac6a5Smrg lastarg= 20121f0ac6a5Smrg save_ifs="$IFS"; IFS=',' 20139c9ff80cSmrg for arg in $args; do 20141f0ac6a5Smrg IFS="$save_ifs" 20156fae4e5dSmrg func_append_quoted lastarg "$arg" 20161f0ac6a5Smrg done 20171f0ac6a5Smrg IFS="$save_ifs" 20189c9ff80cSmrg func_stripname ' ' '' "$lastarg" 20199c9ff80cSmrg lastarg=$func_stripname_result 20201f0ac6a5Smrg 20211f0ac6a5Smrg # Add the arguments to base_compile. 20226fae4e5dSmrg func_append base_compile " $lastarg" 20231f0ac6a5Smrg continue 20241f0ac6a5Smrg ;; 20251f0ac6a5Smrg 20269c9ff80cSmrg *) 20271f0ac6a5Smrg # Accept the current argument as the source file. 20281f0ac6a5Smrg # The previous "srcfile" becomes the current argument. 20291f0ac6a5Smrg # 20301f0ac6a5Smrg lastarg="$srcfile" 20311f0ac6a5Smrg srcfile="$arg" 20321f0ac6a5Smrg ;; 20331f0ac6a5Smrg esac # case $arg 20341f0ac6a5Smrg ;; 20351f0ac6a5Smrg esac # case $arg_mode 20361f0ac6a5Smrg 20371f0ac6a5Smrg # Aesthetically quote the previous argument. 20386fae4e5dSmrg func_append_quoted base_compile "$lastarg" 20391f0ac6a5Smrg done # for arg 20401f0ac6a5Smrg 20411f0ac6a5Smrg case $arg_mode in 20421f0ac6a5Smrg arg) 20439c9ff80cSmrg func_fatal_error "you must specify an argument for -Xcompile" 20441f0ac6a5Smrg ;; 20451f0ac6a5Smrg target) 20469c9ff80cSmrg func_fatal_error "you must specify a target with \`-o'" 20471f0ac6a5Smrg ;; 20481f0ac6a5Smrg *) 20491f0ac6a5Smrg # Get the name of the library object. 20509c9ff80cSmrg test -z "$libobj" && { 20519c9ff80cSmrg func_basename "$srcfile" 20529c9ff80cSmrg libobj="$func_basename_result" 20539c9ff80cSmrg } 20541f0ac6a5Smrg ;; 20551f0ac6a5Smrg esac 20561f0ac6a5Smrg 20571f0ac6a5Smrg # Recognize several different file suffixes. 20581f0ac6a5Smrg # If the user specifies -o file.o, it is replaced with file.lo 20591f0ac6a5Smrg case $libobj in 20609c9ff80cSmrg *.[cCFSifmso] | \ 20619c9ff80cSmrg *.ada | *.adb | *.ads | *.asm | \ 20629c9ff80cSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 206389c04b6cSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 20649c9ff80cSmrg func_xform "$libobj" 20659c9ff80cSmrg libobj=$func_xform_result 20669c9ff80cSmrg ;; 20671f0ac6a5Smrg esac 20681f0ac6a5Smrg 20691f0ac6a5Smrg case $libobj in 20709c9ff80cSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 20711f0ac6a5Smrg *) 20729c9ff80cSmrg func_fatal_error "cannot determine name of library object from \`$libobj'" 20731f0ac6a5Smrg ;; 20741f0ac6a5Smrg esac 20751f0ac6a5Smrg 20761f0ac6a5Smrg func_infer_tag $base_compile 20771f0ac6a5Smrg 20781f0ac6a5Smrg for arg in $later; do 20791f0ac6a5Smrg case $arg in 20809c9ff80cSmrg -shared) 20819c9ff80cSmrg test "$build_libtool_libs" != yes && \ 20829c9ff80cSmrg func_fatal_configuration "can not build a shared library" 20839c9ff80cSmrg build_old_libs=no 20849c9ff80cSmrg continue 20859c9ff80cSmrg ;; 20869c9ff80cSmrg 20871f0ac6a5Smrg -static) 20889c9ff80cSmrg build_libtool_libs=no 20891f0ac6a5Smrg build_old_libs=yes 20901f0ac6a5Smrg continue 20911f0ac6a5Smrg ;; 20921f0ac6a5Smrg 20931f0ac6a5Smrg -prefer-pic) 20941f0ac6a5Smrg pic_mode=yes 20951f0ac6a5Smrg continue 20961f0ac6a5Smrg ;; 20971f0ac6a5Smrg 20981f0ac6a5Smrg -prefer-non-pic) 20991f0ac6a5Smrg pic_mode=no 21001f0ac6a5Smrg continue 21011f0ac6a5Smrg ;; 21021f0ac6a5Smrg esac 21031f0ac6a5Smrg done 21041f0ac6a5Smrg 21059c9ff80cSmrg func_quote_for_eval "$libobj" 21069c9ff80cSmrg test "X$libobj" != "X$func_quote_for_eval_result" \ 21079c9ff80cSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 21089c9ff80cSmrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 21099c9ff80cSmrg func_dirname_and_basename "$obj" "/" "" 21109c9ff80cSmrg objname="$func_basename_result" 21119c9ff80cSmrg xdir="$func_dirname_result" 21121f0ac6a5Smrg lobj=${xdir}$objdir/$objname 21131f0ac6a5Smrg 21149c9ff80cSmrg test -z "$base_compile" && \ 21159c9ff80cSmrg func_fatal_help "you must specify a compilation command" 21161f0ac6a5Smrg 21171f0ac6a5Smrg # Delete any leftover library objects. 21181f0ac6a5Smrg if test "$build_old_libs" = yes; then 21191f0ac6a5Smrg removelist="$obj $lobj $libobj ${libobj}T" 21201f0ac6a5Smrg else 21211f0ac6a5Smrg removelist="$lobj $libobj ${libobj}T" 21221f0ac6a5Smrg fi 21231f0ac6a5Smrg 21241f0ac6a5Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 21251f0ac6a5Smrg case $host_os in 21269c9ff80cSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 21271f0ac6a5Smrg pic_mode=default 21281f0ac6a5Smrg ;; 21291f0ac6a5Smrg esac 21301f0ac6a5Smrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 21311f0ac6a5Smrg # non-PIC code in shared libraries is not supported 21321f0ac6a5Smrg pic_mode=default 21331f0ac6a5Smrg fi 21341f0ac6a5Smrg 21351f0ac6a5Smrg # Calculate the filename of the output object if compiler does 21361f0ac6a5Smrg # not support -o with -c 21371f0ac6a5Smrg if test "$compiler_c_o" = no; then 21386fae4e5dSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 21391f0ac6a5Smrg lockfile="$output_obj.lock" 21401f0ac6a5Smrg else 21411f0ac6a5Smrg output_obj= 21421f0ac6a5Smrg need_locks=no 21431f0ac6a5Smrg lockfile= 21441f0ac6a5Smrg fi 21451f0ac6a5Smrg 21461f0ac6a5Smrg # Lock this critical section if it is needed 21471f0ac6a5Smrg # We use this script file to make the link, it avoids creating a new file 21481f0ac6a5Smrg if test "$need_locks" = yes; then 21499c9ff80cSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 21509c9ff80cSmrg func_echo "Waiting for $lockfile to be removed" 21511f0ac6a5Smrg sleep 2 21521f0ac6a5Smrg done 21531f0ac6a5Smrg elif test "$need_locks" = warn; then 21541f0ac6a5Smrg if test -f "$lockfile"; then 21559c9ff80cSmrg $ECHO "\ 21561f0ac6a5Smrg*** ERROR, $lockfile exists and contains: 21571f0ac6a5Smrg`cat $lockfile 2>/dev/null` 21581f0ac6a5Smrg 21591f0ac6a5SmrgThis indicates that another process is trying to use the same 21601f0ac6a5Smrgtemporary object file, and libtool could not work around it because 21611f0ac6a5Smrgyour compiler does not support \`-c' and \`-o' together. If you 21621f0ac6a5Smrgrepeat this compilation, it may succeed, by chance, but you had better 21631f0ac6a5Smrgavoid parallel builds (make -j) in this platform, or get a better 21641f0ac6a5Smrgcompiler." 21651f0ac6a5Smrg 21669c9ff80cSmrg $opt_dry_run || $RM $removelist 21671f0ac6a5Smrg exit $EXIT_FAILURE 21681f0ac6a5Smrg fi 21696fae4e5dSmrg func_append removelist " $output_obj" 21709c9ff80cSmrg $ECHO "$srcfile" > "$lockfile" 21711f0ac6a5Smrg fi 21721f0ac6a5Smrg 21739c9ff80cSmrg $opt_dry_run || $RM $removelist 21746fae4e5dSmrg func_append removelist " $lockfile" 21759c9ff80cSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 21769c9ff80cSmrg 21776fae4e5dSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 21786fae4e5dSmrg srcfile=$func_to_tool_file_result 21799c9ff80cSmrg func_quote_for_eval "$srcfile" 21809c9ff80cSmrg qsrcfile=$func_quote_for_eval_result 21811f0ac6a5Smrg 21821f0ac6a5Smrg # Only build a PIC object if we are building libtool libraries. 21831f0ac6a5Smrg if test "$build_libtool_libs" = yes; then 21841f0ac6a5Smrg # Without this assignment, base_compile gets emptied. 21851f0ac6a5Smrg fbsd_hideous_sh_bug=$base_compile 21861f0ac6a5Smrg 21871f0ac6a5Smrg if test "$pic_mode" != no; then 21881f0ac6a5Smrg command="$base_compile $qsrcfile $pic_flag" 21891f0ac6a5Smrg else 21901f0ac6a5Smrg # Don't build PIC code 21911f0ac6a5Smrg command="$base_compile $qsrcfile" 21921f0ac6a5Smrg fi 21931f0ac6a5Smrg 21949c9ff80cSmrg func_mkdir_p "$xdir$objdir" 21951f0ac6a5Smrg 21961f0ac6a5Smrg if test -z "$output_obj"; then 21971f0ac6a5Smrg # Place PIC objects in $objdir 21986fae4e5dSmrg func_append command " -o $lobj" 21991f0ac6a5Smrg fi 22001f0ac6a5Smrg 22019c9ff80cSmrg func_show_eval_locale "$command" \ 22029c9ff80cSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 22031f0ac6a5Smrg 22041f0ac6a5Smrg if test "$need_locks" = warn && 22051f0ac6a5Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 22069c9ff80cSmrg $ECHO "\ 22071f0ac6a5Smrg*** ERROR, $lockfile contains: 22081f0ac6a5Smrg`cat $lockfile 2>/dev/null` 22091f0ac6a5Smrg 22101f0ac6a5Smrgbut it should contain: 22111f0ac6a5Smrg$srcfile 22121f0ac6a5Smrg 22131f0ac6a5SmrgThis indicates that another process is trying to use the same 22141f0ac6a5Smrgtemporary object file, and libtool could not work around it because 22151f0ac6a5Smrgyour compiler does not support \`-c' and \`-o' together. If you 22161f0ac6a5Smrgrepeat this compilation, it may succeed, by chance, but you had better 22171f0ac6a5Smrgavoid parallel builds (make -j) in this platform, or get a better 22181f0ac6a5Smrgcompiler." 22191f0ac6a5Smrg 22209c9ff80cSmrg $opt_dry_run || $RM $removelist 22211f0ac6a5Smrg exit $EXIT_FAILURE 22221f0ac6a5Smrg fi 22231f0ac6a5Smrg 22241f0ac6a5Smrg # Just move the object if needed, then go on to compile the next one 22251f0ac6a5Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 22269c9ff80cSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 22279c9ff80cSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 22281f0ac6a5Smrg fi 22291f0ac6a5Smrg 22301f0ac6a5Smrg # Allow error messages only from the first compilation. 22311f0ac6a5Smrg if test "$suppress_opt" = yes; then 22329c9ff80cSmrg suppress_output=' >/dev/null 2>&1' 22331f0ac6a5Smrg fi 22341f0ac6a5Smrg fi 22351f0ac6a5Smrg 22361f0ac6a5Smrg # Only build a position-dependent object if we build old libraries. 22371f0ac6a5Smrg if test "$build_old_libs" = yes; then 22381f0ac6a5Smrg if test "$pic_mode" != yes; then 22391f0ac6a5Smrg # Don't build PIC code 22409c9ff80cSmrg command="$base_compile $qsrcfile$pie_flag" 22411f0ac6a5Smrg else 22421f0ac6a5Smrg command="$base_compile $qsrcfile $pic_flag" 22431f0ac6a5Smrg fi 22441f0ac6a5Smrg if test "$compiler_c_o" = yes; then 22456fae4e5dSmrg func_append command " -o $obj" 22461f0ac6a5Smrg fi 22471f0ac6a5Smrg 22481f0ac6a5Smrg # Suppress compiler output if we already did a PIC compilation. 22496fae4e5dSmrg func_append command "$suppress_output" 22509c9ff80cSmrg func_show_eval_locale "$command" \ 22519c9ff80cSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 22521f0ac6a5Smrg 22531f0ac6a5Smrg if test "$need_locks" = warn && 22541f0ac6a5Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 22559c9ff80cSmrg $ECHO "\ 22561f0ac6a5Smrg*** ERROR, $lockfile contains: 22571f0ac6a5Smrg`cat $lockfile 2>/dev/null` 22581f0ac6a5Smrg 22591f0ac6a5Smrgbut it should contain: 22601f0ac6a5Smrg$srcfile 22611f0ac6a5Smrg 22621f0ac6a5SmrgThis indicates that another process is trying to use the same 22631f0ac6a5Smrgtemporary object file, and libtool could not work around it because 22641f0ac6a5Smrgyour compiler does not support \`-c' and \`-o' together. If you 22651f0ac6a5Smrgrepeat this compilation, it may succeed, by chance, but you had better 22661f0ac6a5Smrgavoid parallel builds (make -j) in this platform, or get a better 22671f0ac6a5Smrgcompiler." 22681f0ac6a5Smrg 22699c9ff80cSmrg $opt_dry_run || $RM $removelist 22701f0ac6a5Smrg exit $EXIT_FAILURE 22711f0ac6a5Smrg fi 22721f0ac6a5Smrg 22731f0ac6a5Smrg # Just move the object if needed 22741f0ac6a5Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 22759c9ff80cSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 22769c9ff80cSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 22771f0ac6a5Smrg fi 22781f0ac6a5Smrg fi 22791f0ac6a5Smrg 22809c9ff80cSmrg $opt_dry_run || { 22819c9ff80cSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 22821f0ac6a5Smrg 22839c9ff80cSmrg # Unlock the critical section if it was locked 22849c9ff80cSmrg if test "$need_locks" != no; then 22859c9ff80cSmrg removelist=$lockfile 22869c9ff80cSmrg $RM "$lockfile" 22879c9ff80cSmrg fi 22889c9ff80cSmrg } 22891f0ac6a5Smrg 22901f0ac6a5Smrg exit $EXIT_SUCCESS 22919c9ff80cSmrg} 22921f0ac6a5Smrg 22939c9ff80cSmrg$opt_help || { 22946fae4e5dSmrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 22959c9ff80cSmrg} 22961f0ac6a5Smrg 22979c9ff80cSmrgfunc_mode_help () 22989c9ff80cSmrg{ 22999c9ff80cSmrg # We need to display help for each of the modes. 23006fae4e5dSmrg case $opt_mode in 23019c9ff80cSmrg "") 23029c9ff80cSmrg # Generic help is extracted from the usage comments 23039c9ff80cSmrg # at the start of this file. 23049c9ff80cSmrg func_help 23059c9ff80cSmrg ;; 23061f0ac6a5Smrg 23079c9ff80cSmrg clean) 23089c9ff80cSmrg $ECHO \ 23099c9ff80cSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 23101f0ac6a5Smrg 23119c9ff80cSmrgRemove files from the build directory. 23121f0ac6a5Smrg 23139c9ff80cSmrgRM is the name of the program to use to delete files associated with each FILE 23149c9ff80cSmrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 23159c9ff80cSmrgto RM. 23161f0ac6a5Smrg 23179c9ff80cSmrgIf FILE is a libtool library, object or program, all the files associated 23189c9ff80cSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 23199c9ff80cSmrg ;; 23201f0ac6a5Smrg 23219c9ff80cSmrg compile) 23229c9ff80cSmrg $ECHO \ 23239c9ff80cSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 23241f0ac6a5Smrg 23259c9ff80cSmrgCompile a source file into a libtool library object. 23261f0ac6a5Smrg 23279c9ff80cSmrgThis mode accepts the following additional options: 23281f0ac6a5Smrg 23299c9ff80cSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 23309c9ff80cSmrg -no-suppress do not suppress compiler output for multiple passes 23316fae4e5dSmrg -prefer-pic try to build PIC objects only 23326fae4e5dSmrg -prefer-non-pic try to build non-PIC objects only 23339c9ff80cSmrg -shared do not build a \`.o' file suitable for static linking 23349c9ff80cSmrg -static only build a \`.o' file suitable for static linking 23356fae4e5dSmrg -Wc,FLAG pass FLAG directly to the compiler 23361f0ac6a5Smrg 23379c9ff80cSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 23389c9ff80cSmrgfrom the given SOURCEFILE. 23391f0ac6a5Smrg 23409c9ff80cSmrgThe output file name is determined by removing the directory component from 23419c9ff80cSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 23429c9ff80cSmrglibrary object suffix, \`.lo'." 23439c9ff80cSmrg ;; 23441f0ac6a5Smrg 23459c9ff80cSmrg execute) 23469c9ff80cSmrg $ECHO \ 23479c9ff80cSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 23481f0ac6a5Smrg 23499c9ff80cSmrgAutomatically set library path, then run a program. 23501f0ac6a5Smrg 23519c9ff80cSmrgThis mode accepts the following additional options: 23521f0ac6a5Smrg 23539c9ff80cSmrg -dlopen FILE add the directory containing FILE to the library path 23541f0ac6a5Smrg 23559c9ff80cSmrgThis mode sets the library path environment variable according to \`-dlopen' 23569c9ff80cSmrgflags. 23571f0ac6a5Smrg 23589c9ff80cSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 23599c9ff80cSmrginto their corresponding uninstalled binary, and any of their required library 23609c9ff80cSmrgdirectories are added to the library path. 23611f0ac6a5Smrg 23629c9ff80cSmrgThen, COMMAND is executed, with ARGS as arguments." 23639c9ff80cSmrg ;; 23641f0ac6a5Smrg 23659c9ff80cSmrg finish) 23669c9ff80cSmrg $ECHO \ 23679c9ff80cSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 23681f0ac6a5Smrg 23699c9ff80cSmrgComplete the installation of libtool libraries. 23701f0ac6a5Smrg 23719c9ff80cSmrgEach LIBDIR is a directory that contains libtool libraries. 23721f0ac6a5Smrg 23739c9ff80cSmrgThe commands that this mode executes may require superuser privileges. Use 23749c9ff80cSmrgthe \`--dry-run' option if you just want to see what would be executed." 23759c9ff80cSmrg ;; 23761f0ac6a5Smrg 23779c9ff80cSmrg install) 23789c9ff80cSmrg $ECHO \ 23799c9ff80cSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 23801f0ac6a5Smrg 23819c9ff80cSmrgInstall executables or libraries. 23821f0ac6a5Smrg 23839c9ff80cSmrgINSTALL-COMMAND is the installation command. The first component should be 23849c9ff80cSmrgeither the \`install' or \`cp' program. 23851f0ac6a5Smrg 23869c9ff80cSmrgThe following components of INSTALL-COMMAND are treated specially: 23871f0ac6a5Smrg 23886fae4e5dSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 23891f0ac6a5Smrg 23909c9ff80cSmrgThe rest of the components are interpreted as arguments to that command (only 23919c9ff80cSmrgBSD-compatible install options are recognized)." 23929c9ff80cSmrg ;; 23931f0ac6a5Smrg 23949c9ff80cSmrg link) 23959c9ff80cSmrg $ECHO \ 23969c9ff80cSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 23971f0ac6a5Smrg 23989c9ff80cSmrgLink object files or libraries together to form another library, or to 23999c9ff80cSmrgcreate an executable program. 24001f0ac6a5Smrg 24019c9ff80cSmrgLINK-COMMAND is a command using the C compiler that you would use to create 24029c9ff80cSmrga program from several object files. 24031f0ac6a5Smrg 24049c9ff80cSmrgThe following components of LINK-COMMAND are treated specially: 24051f0ac6a5Smrg 24069c9ff80cSmrg -all-static do not do any dynamic linking at all 24079c9ff80cSmrg -avoid-version do not add a version suffix if possible 24086fae4e5dSmrg -bindir BINDIR specify path to binaries directory (for systems where 24096fae4e5dSmrg libraries must be found in the PATH setting at runtime) 24109c9ff80cSmrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 24119c9ff80cSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 24129c9ff80cSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 24139c9ff80cSmrg -export-symbols SYMFILE 24149c9ff80cSmrg try to export only the symbols listed in SYMFILE 24159c9ff80cSmrg -export-symbols-regex REGEX 24169c9ff80cSmrg try to export only the symbols matching REGEX 24179c9ff80cSmrg -LLIBDIR search LIBDIR for required installed libraries 24189c9ff80cSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 24199c9ff80cSmrg -module build a library that can dlopened 24209c9ff80cSmrg -no-fast-install disable the fast-install mode 24219c9ff80cSmrg -no-install link a not-installable executable 24229c9ff80cSmrg -no-undefined declare that a library does not refer to external symbols 24239c9ff80cSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 24249c9ff80cSmrg -objectlist FILE Use a list of object files found in FILE to specify objects 24259c9ff80cSmrg -precious-files-regex REGEX 24269c9ff80cSmrg don't remove output files matching REGEX 24279c9ff80cSmrg -release RELEASE specify package release information 24289c9ff80cSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 24299c9ff80cSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 24309c9ff80cSmrg -shared only do dynamic linking of libtool libraries 24319c9ff80cSmrg -shrext SUFFIX override the standard shared library file extension 24329c9ff80cSmrg -static do not do any dynamic linking of uninstalled libtool libraries 24339c9ff80cSmrg -static-libtool-libs 24349c9ff80cSmrg do not do any dynamic linking of libtool libraries 24359c9ff80cSmrg -version-info CURRENT[:REVISION[:AGE]] 24369c9ff80cSmrg specify library version info [each variable defaults to 0] 24379c9ff80cSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 24386fae4e5dSmrg -Wc,FLAG 24396fae4e5dSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 24406fae4e5dSmrg -Wl,FLAG 24416fae4e5dSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 24426fae4e5dSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 24431f0ac6a5Smrg 24449c9ff80cSmrgAll other options (arguments beginning with \`-') are ignored. 2445e5410a46Smrg 24469c9ff80cSmrgEvery other argument is treated as a filename. Files ending in \`.la' are 24479c9ff80cSmrgtreated as uninstalled libtool libraries, other files are standard or library 24489c9ff80cSmrgobject files. 24491f0ac6a5Smrg 24509c9ff80cSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 24519c9ff80cSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 24529c9ff80cSmrgrequired, except when creating a convenience library. 24531f0ac6a5Smrg 24549c9ff80cSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 24559c9ff80cSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 24561f0ac6a5Smrg 24579c9ff80cSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 24589c9ff80cSmrgis created, otherwise an executable program is created." 24591f0ac6a5Smrg ;; 24601f0ac6a5Smrg 24619c9ff80cSmrg uninstall) 24629c9ff80cSmrg $ECHO \ 24639c9ff80cSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 24641f0ac6a5Smrg 24659c9ff80cSmrgRemove libraries from an installation directory. 24661f0ac6a5Smrg 24679c9ff80cSmrgRM is the name of the program to use to delete files associated with each FILE 24689c9ff80cSmrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 24699c9ff80cSmrgto RM. 24701f0ac6a5Smrg 24719c9ff80cSmrgIf FILE is a libtool library, all the files associated with it are deleted. 24729c9ff80cSmrgOtherwise, only FILE itself is deleted using RM." 24739c9ff80cSmrg ;; 24741f0ac6a5Smrg 24759c9ff80cSmrg *) 24766fae4e5dSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 24779c9ff80cSmrg ;; 24789c9ff80cSmrg esac 24791f0ac6a5Smrg 24806fae4e5dSmrg echo 24819c9ff80cSmrg $ECHO "Try \`$progname --help' for more information about other modes." 24829c9ff80cSmrg} 24831f0ac6a5Smrg 24846fae4e5dSmrg# Now that we've collected a possible --mode arg, show help if necessary 24856fae4e5dSmrgif $opt_help; then 24866fae4e5dSmrg if test "$opt_help" = :; then 24876fae4e5dSmrg func_mode_help 24886fae4e5dSmrg else 24896fae4e5dSmrg { 24906fae4e5dSmrg func_help noexit 24916fae4e5dSmrg for opt_mode in compile link execute install finish uninstall clean; do 24926fae4e5dSmrg func_mode_help 24936fae4e5dSmrg done 24946fae4e5dSmrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 24956fae4e5dSmrg { 24966fae4e5dSmrg func_help noexit 24976fae4e5dSmrg for opt_mode in compile link execute install finish uninstall clean; do 24986fae4e5dSmrg echo 24996fae4e5dSmrg func_mode_help 25006fae4e5dSmrg done 25016fae4e5dSmrg } | 25026fae4e5dSmrg sed '1d 25036fae4e5dSmrg /^When reporting/,/^Report/{ 25046fae4e5dSmrg H 25056fae4e5dSmrg d 25066fae4e5dSmrg } 25076fae4e5dSmrg $x 25086fae4e5dSmrg /information about other modes/d 25096fae4e5dSmrg /more detailed .*MODE/d 25106fae4e5dSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 25116fae4e5dSmrg fi 25126fae4e5dSmrg exit $? 25136fae4e5dSmrgfi 25141f0ac6a5Smrg 25151f0ac6a5Smrg 25169c9ff80cSmrg# func_mode_execute arg... 25179c9ff80cSmrgfunc_mode_execute () 25189c9ff80cSmrg{ 25199c9ff80cSmrg $opt_debug 25209c9ff80cSmrg # The first argument is the command name. 25219c9ff80cSmrg cmd="$nonopt" 25229c9ff80cSmrg test -z "$cmd" && \ 25239c9ff80cSmrg func_fatal_help "you must specify a COMMAND" 25241f0ac6a5Smrg 25259c9ff80cSmrg # Handle -dlopen flags immediately. 25266fae4e5dSmrg for file in $opt_dlopen; do 25279c9ff80cSmrg test -f "$file" \ 25289c9ff80cSmrg || func_fatal_help "\`$file' is not a file" 25291f0ac6a5Smrg 25309c9ff80cSmrg dir= 25319c9ff80cSmrg case $file in 25329c9ff80cSmrg *.la) 25336fae4e5dSmrg func_resolve_sysroot "$file" 25346fae4e5dSmrg file=$func_resolve_sysroot_result 25356fae4e5dSmrg 25369c9ff80cSmrg # Check to see that this really is a libtool archive. 25379c9ff80cSmrg func_lalib_unsafe_p "$file" \ 25389c9ff80cSmrg || func_fatal_help "\`$lib' is not a valid libtool archive" 25391f0ac6a5Smrg 25409c9ff80cSmrg # Read the libtool library. 25419c9ff80cSmrg dlname= 25429c9ff80cSmrg library_names= 25439c9ff80cSmrg func_source "$file" 25441f0ac6a5Smrg 25459c9ff80cSmrg # Skip this library if it cannot be dlopened. 25469c9ff80cSmrg if test -z "$dlname"; then 25479c9ff80cSmrg # Warn if it was a shared library. 25489c9ff80cSmrg test -n "$library_names" && \ 25499c9ff80cSmrg func_warning "\`$file' was not linked with \`-export-dynamic'" 25509c9ff80cSmrg continue 25519c9ff80cSmrg fi 25521f0ac6a5Smrg 25539c9ff80cSmrg func_dirname "$file" "" "." 25549c9ff80cSmrg dir="$func_dirname_result" 25551f0ac6a5Smrg 25569c9ff80cSmrg if test -f "$dir/$objdir/$dlname"; then 25576fae4e5dSmrg func_append dir "/$objdir" 25589c9ff80cSmrg else 25599c9ff80cSmrg if test ! -f "$dir/$dlname"; then 25609c9ff80cSmrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 25619c9ff80cSmrg fi 25629c9ff80cSmrg fi 25631f0ac6a5Smrg ;; 25641f0ac6a5Smrg 25659c9ff80cSmrg *.lo) 25669c9ff80cSmrg # Just add the directory containing the .lo file. 25679c9ff80cSmrg func_dirname "$file" "" "." 25689c9ff80cSmrg dir="$func_dirname_result" 25691f0ac6a5Smrg ;; 25701f0ac6a5Smrg 25719c9ff80cSmrg *) 25729c9ff80cSmrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 25731f0ac6a5Smrg continue 25741f0ac6a5Smrg ;; 25759c9ff80cSmrg esac 25761f0ac6a5Smrg 25779c9ff80cSmrg # Get the absolute pathname. 25789c9ff80cSmrg absdir=`cd "$dir" && pwd` 25799c9ff80cSmrg test -n "$absdir" && dir="$absdir" 25801f0ac6a5Smrg 25819c9ff80cSmrg # Now add the directory to shlibpath_var. 25829c9ff80cSmrg if eval "test -z \"\$$shlibpath_var\""; then 25839c9ff80cSmrg eval "$shlibpath_var=\"\$dir\"" 25849c9ff80cSmrg else 25859c9ff80cSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 25869c9ff80cSmrg fi 25879c9ff80cSmrg done 25881f0ac6a5Smrg 25899c9ff80cSmrg # This variable tells wrapper scripts just to set shlibpath_var 25909c9ff80cSmrg # rather than running their programs. 25919c9ff80cSmrg libtool_execute_magic="$magic" 25921f0ac6a5Smrg 25939c9ff80cSmrg # Check if any of the arguments is a wrapper script. 25949c9ff80cSmrg args= 25959c9ff80cSmrg for file 25969c9ff80cSmrg do 25979c9ff80cSmrg case $file in 25986fae4e5dSmrg -* | *.la | *.lo ) ;; 25999c9ff80cSmrg *) 26009c9ff80cSmrg # Do a test to see if this is really a libtool program. 26019c9ff80cSmrg if func_ltwrapper_script_p "$file"; then 26029c9ff80cSmrg func_source "$file" 26039c9ff80cSmrg # Transform arg to wrapped name. 26049c9ff80cSmrg file="$progdir/$program" 26059c9ff80cSmrg elif func_ltwrapper_executable_p "$file"; then 26069c9ff80cSmrg func_ltwrapper_scriptname "$file" 26079c9ff80cSmrg func_source "$func_ltwrapper_scriptname_result" 26089c9ff80cSmrg # Transform arg to wrapped name. 26099c9ff80cSmrg file="$progdir/$program" 26109c9ff80cSmrg fi 26119c9ff80cSmrg ;; 26129c9ff80cSmrg esac 26139c9ff80cSmrg # Quote arguments (to preserve shell metacharacters). 26146fae4e5dSmrg func_append_quoted args "$file" 26159c9ff80cSmrg done 26161f0ac6a5Smrg 26179c9ff80cSmrg if test "X$opt_dry_run" = Xfalse; then 26189c9ff80cSmrg if test -n "$shlibpath_var"; then 26199c9ff80cSmrg # Export the shlibpath_var. 26209c9ff80cSmrg eval "export $shlibpath_var" 26219c9ff80cSmrg fi 26221f0ac6a5Smrg 26239c9ff80cSmrg # Restore saved environment variables 26249c9ff80cSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 26259c9ff80cSmrg do 26269c9ff80cSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 26279c9ff80cSmrg $lt_var=\$save_$lt_var; export $lt_var 26281f0ac6a5Smrg else 26299c9ff80cSmrg $lt_unset $lt_var 26309c9ff80cSmrg fi" 26319c9ff80cSmrg done 26321f0ac6a5Smrg 26339c9ff80cSmrg # Now prepare to actually exec the command. 26349c9ff80cSmrg exec_cmd="\$cmd$args" 26359c9ff80cSmrg else 26369c9ff80cSmrg # Display what would be done. 26379c9ff80cSmrg if test -n "$shlibpath_var"; then 26389c9ff80cSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 26396fae4e5dSmrg echo "export $shlibpath_var" 26409c9ff80cSmrg fi 26419c9ff80cSmrg $ECHO "$cmd$args" 26429c9ff80cSmrg exit $EXIT_SUCCESS 26439c9ff80cSmrg fi 26449c9ff80cSmrg} 26451f0ac6a5Smrg 26466fae4e5dSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 26476fae4e5dSmrg 26486fae4e5dSmrg 26496fae4e5dSmrg# func_mode_finish arg... 26506fae4e5dSmrgfunc_mode_finish () 26516fae4e5dSmrg{ 26526fae4e5dSmrg $opt_debug 26536fae4e5dSmrg libs= 26546fae4e5dSmrg libdirs= 26556fae4e5dSmrg admincmds= 26566fae4e5dSmrg 26576fae4e5dSmrg for opt in "$nonopt" ${1+"$@"} 26586fae4e5dSmrg do 26596fae4e5dSmrg if test -d "$opt"; then 26606fae4e5dSmrg func_append libdirs " $opt" 26616fae4e5dSmrg 26626fae4e5dSmrg elif test -f "$opt"; then 26636fae4e5dSmrg if func_lalib_unsafe_p "$opt"; then 26646fae4e5dSmrg func_append libs " $opt" 26656fae4e5dSmrg else 26666fae4e5dSmrg func_warning "\`$opt' is not a valid libtool archive" 26676fae4e5dSmrg fi 26686fae4e5dSmrg 26696fae4e5dSmrg else 26706fae4e5dSmrg func_fatal_error "invalid argument \`$opt'" 26716fae4e5dSmrg fi 26726fae4e5dSmrg done 26731f0ac6a5Smrg 26746fae4e5dSmrg if test -n "$libs"; then 26756fae4e5dSmrg if test -n "$lt_sysroot"; then 26766fae4e5dSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 26776fae4e5dSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 26786fae4e5dSmrg else 26796fae4e5dSmrg sysroot_cmd= 26806fae4e5dSmrg fi 26811f0ac6a5Smrg 26826fae4e5dSmrg # Remove sysroot references 26836fae4e5dSmrg if $opt_dry_run; then 26846fae4e5dSmrg for lib in $libs; do 26856fae4e5dSmrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 26866fae4e5dSmrg done 26876fae4e5dSmrg else 26886fae4e5dSmrg tmpdir=`func_mktempdir` 26896fae4e5dSmrg for lib in $libs; do 26906fae4e5dSmrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 26916fae4e5dSmrg > $tmpdir/tmp-la 26926fae4e5dSmrg mv -f $tmpdir/tmp-la $lib 26936fae4e5dSmrg done 26946fae4e5dSmrg ${RM}r "$tmpdir" 26956fae4e5dSmrg fi 26966fae4e5dSmrg fi 26971f0ac6a5Smrg 26989c9ff80cSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 26999c9ff80cSmrg for libdir in $libdirs; do 27009c9ff80cSmrg if test -n "$finish_cmds"; then 27019c9ff80cSmrg # Do each command in the finish commands. 27029c9ff80cSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 27039c9ff80cSmrg'"$cmd"'"' 27041f0ac6a5Smrg fi 27059c9ff80cSmrg if test -n "$finish_eval"; then 27069c9ff80cSmrg # Do the single finish_eval. 27079c9ff80cSmrg eval cmds=\"$finish_eval\" 27086fae4e5dSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 27099c9ff80cSmrg $cmds" 27109c9ff80cSmrg fi 27119c9ff80cSmrg done 27129c9ff80cSmrg fi 27131f0ac6a5Smrg 27149c9ff80cSmrg # Exit here if they wanted silent mode. 27159c9ff80cSmrg $opt_silent && exit $EXIT_SUCCESS 27161f0ac6a5Smrg 27176fae4e5dSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 27186fae4e5dSmrg echo "----------------------------------------------------------------------" 27196fae4e5dSmrg echo "Libraries have been installed in:" 27206fae4e5dSmrg for libdir in $libdirs; do 27216fae4e5dSmrg $ECHO " $libdir" 27226fae4e5dSmrg done 27236fae4e5dSmrg echo 27246fae4e5dSmrg echo "If you ever happen to want to link against installed libraries" 27256fae4e5dSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 27266fae4e5dSmrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 27276fae4e5dSmrg echo "flag during linking and do at least one of the following:" 27286fae4e5dSmrg if test -n "$shlibpath_var"; then 27296fae4e5dSmrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 27306fae4e5dSmrg echo " during execution" 27316fae4e5dSmrg fi 27326fae4e5dSmrg if test -n "$runpath_var"; then 27336fae4e5dSmrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 27346fae4e5dSmrg echo " during linking" 27356fae4e5dSmrg fi 27366fae4e5dSmrg if test -n "$hardcode_libdir_flag_spec"; then 27376fae4e5dSmrg libdir=LIBDIR 27386fae4e5dSmrg eval flag=\"$hardcode_libdir_flag_spec\" 27399c9ff80cSmrg 27406fae4e5dSmrg $ECHO " - use the \`$flag' linker flag" 27416fae4e5dSmrg fi 27426fae4e5dSmrg if test -n "$admincmds"; then 27436fae4e5dSmrg $ECHO " - have your system administrator run these commands:$admincmds" 27446fae4e5dSmrg fi 27456fae4e5dSmrg if test -f /etc/ld.so.conf; then 27466fae4e5dSmrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 27476fae4e5dSmrg fi 27486fae4e5dSmrg echo 27499c9ff80cSmrg 27506fae4e5dSmrg echo "See any operating system documentation about shared libraries for" 27516fae4e5dSmrg case $host in 27526fae4e5dSmrg solaris2.[6789]|solaris2.1[0-9]) 27536fae4e5dSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 27546fae4e5dSmrg echo "pages." 27556fae4e5dSmrg ;; 27566fae4e5dSmrg *) 27576fae4e5dSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 27586fae4e5dSmrg ;; 27596fae4e5dSmrg esac 27606fae4e5dSmrg echo "----------------------------------------------------------------------" 27616fae4e5dSmrg fi 27629c9ff80cSmrg exit $EXIT_SUCCESS 27639c9ff80cSmrg} 27649c9ff80cSmrg 27656fae4e5dSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 27669c9ff80cSmrg 27679c9ff80cSmrg 27689c9ff80cSmrg# func_mode_install arg... 27699c9ff80cSmrgfunc_mode_install () 27709c9ff80cSmrg{ 27719c9ff80cSmrg $opt_debug 27729c9ff80cSmrg # There may be an optional sh(1) argument at the beginning of 27739c9ff80cSmrg # install_prog (especially on Windows NT). 27749c9ff80cSmrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 27759c9ff80cSmrg # Allow the use of GNU shtool's install command. 27766fae4e5dSmrg case $nonopt in *shtool*) :;; *) false;; esac; then 27779c9ff80cSmrg # Aesthetically quote it. 27789c9ff80cSmrg func_quote_for_eval "$nonopt" 27799c9ff80cSmrg install_prog="$func_quote_for_eval_result " 27809c9ff80cSmrg arg=$1 27819c9ff80cSmrg shift 27829c9ff80cSmrg else 27839c9ff80cSmrg install_prog= 27849c9ff80cSmrg arg=$nonopt 27859c9ff80cSmrg fi 27869c9ff80cSmrg 27879c9ff80cSmrg # The real first argument should be the name of the installation program. 27889c9ff80cSmrg # Aesthetically quote it. 27899c9ff80cSmrg func_quote_for_eval "$arg" 27906fae4e5dSmrg func_append install_prog "$func_quote_for_eval_result" 27916fae4e5dSmrg install_shared_prog=$install_prog 27926fae4e5dSmrg case " $install_prog " in 27936fae4e5dSmrg *[\\\ /]cp\ *) install_cp=: ;; 27946fae4e5dSmrg *) install_cp=false ;; 27956fae4e5dSmrg esac 27969c9ff80cSmrg 27979c9ff80cSmrg # We need to accept at least all the BSD install flags. 27989c9ff80cSmrg dest= 27999c9ff80cSmrg files= 28009c9ff80cSmrg opts= 28019c9ff80cSmrg prev= 28029c9ff80cSmrg install_type= 28039c9ff80cSmrg isdir=no 28049c9ff80cSmrg stripme= 28056fae4e5dSmrg no_mode=: 28069c9ff80cSmrg for arg 28079c9ff80cSmrg do 28086fae4e5dSmrg arg2= 28099c9ff80cSmrg if test -n "$dest"; then 28106fae4e5dSmrg func_append files " $dest" 28119c9ff80cSmrg dest=$arg 28129c9ff80cSmrg continue 28139c9ff80cSmrg fi 28149c9ff80cSmrg 28159c9ff80cSmrg case $arg in 28169c9ff80cSmrg -d) isdir=yes ;; 28179c9ff80cSmrg -f) 28186fae4e5dSmrg if $install_cp; then :; else 28196fae4e5dSmrg prev=$arg 28206fae4e5dSmrg fi 28219c9ff80cSmrg ;; 28229c9ff80cSmrg -g | -m | -o) 28239c9ff80cSmrg prev=$arg 28249c9ff80cSmrg ;; 28259c9ff80cSmrg -s) 28269c9ff80cSmrg stripme=" -s" 28279c9ff80cSmrg continue 28289c9ff80cSmrg ;; 28299c9ff80cSmrg -*) 28309c9ff80cSmrg ;; 28319c9ff80cSmrg *) 28329c9ff80cSmrg # If the previous option needed an argument, then skip it. 28339c9ff80cSmrg if test -n "$prev"; then 28346fae4e5dSmrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 28356fae4e5dSmrg arg2=$install_override_mode 28366fae4e5dSmrg no_mode=false 28376fae4e5dSmrg fi 28381f0ac6a5Smrg prev= 28391f0ac6a5Smrg else 28409c9ff80cSmrg dest=$arg 28419c9ff80cSmrg continue 28421f0ac6a5Smrg fi 28431f0ac6a5Smrg ;; 28449c9ff80cSmrg esac 28451f0ac6a5Smrg 28469c9ff80cSmrg # Aesthetically quote the argument. 28479c9ff80cSmrg func_quote_for_eval "$arg" 28486fae4e5dSmrg func_append install_prog " $func_quote_for_eval_result" 28496fae4e5dSmrg if test -n "$arg2"; then 28506fae4e5dSmrg func_quote_for_eval "$arg2" 28516fae4e5dSmrg fi 28526fae4e5dSmrg func_append install_shared_prog " $func_quote_for_eval_result" 28539c9ff80cSmrg done 28541f0ac6a5Smrg 28559c9ff80cSmrg test -z "$install_prog" && \ 28569c9ff80cSmrg func_fatal_help "you must specify an install program" 28571f0ac6a5Smrg 28589c9ff80cSmrg test -n "$prev" && \ 28599c9ff80cSmrg func_fatal_help "the \`$prev' option requires an argument" 28601f0ac6a5Smrg 28616fae4e5dSmrg if test -n "$install_override_mode" && $no_mode; then 28626fae4e5dSmrg if $install_cp; then :; else 28636fae4e5dSmrg func_quote_for_eval "$install_override_mode" 28646fae4e5dSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 28656fae4e5dSmrg fi 28666fae4e5dSmrg fi 28676fae4e5dSmrg 28689c9ff80cSmrg if test -z "$files"; then 28699c9ff80cSmrg if test -z "$dest"; then 28709c9ff80cSmrg func_fatal_help "no file or destination specified" 28719c9ff80cSmrg else 28729c9ff80cSmrg func_fatal_help "you must specify a destination" 28739c9ff80cSmrg fi 28741f0ac6a5Smrg fi 28751f0ac6a5Smrg 28769c9ff80cSmrg # Strip any trailing slash from the destination. 28779c9ff80cSmrg func_stripname '' '/' "$dest" 28789c9ff80cSmrg dest=$func_stripname_result 28791f0ac6a5Smrg 28809c9ff80cSmrg # Check to see that the destination is a directory. 28819c9ff80cSmrg test -d "$dest" && isdir=yes 28829c9ff80cSmrg if test "$isdir" = yes; then 28839c9ff80cSmrg destdir="$dest" 28849c9ff80cSmrg destname= 28851f0ac6a5Smrg else 28869c9ff80cSmrg func_dirname_and_basename "$dest" "" "." 28879c9ff80cSmrg destdir="$func_dirname_result" 28889c9ff80cSmrg destname="$func_basename_result" 28891f0ac6a5Smrg 28909c9ff80cSmrg # Not a directory, so check to see that there is only one file specified. 28919c9ff80cSmrg set dummy $files; shift 28929c9ff80cSmrg test "$#" -gt 1 && \ 28939c9ff80cSmrg func_fatal_help "\`$dest' is not a directory" 28941f0ac6a5Smrg fi 28959c9ff80cSmrg case $destdir in 28969c9ff80cSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 28971f0ac6a5Smrg *) 28989c9ff80cSmrg for file in $files; do 28999c9ff80cSmrg case $file in 29009c9ff80cSmrg *.lo) ;; 29019c9ff80cSmrg *) 29029c9ff80cSmrg func_fatal_help "\`$destdir' must be an absolute directory name" 29039c9ff80cSmrg ;; 29049c9ff80cSmrg esac 29059c9ff80cSmrg done 29061f0ac6a5Smrg ;; 29071f0ac6a5Smrg esac 29081f0ac6a5Smrg 29099c9ff80cSmrg # This variable tells wrapper scripts just to set variables rather 29109c9ff80cSmrg # than running their programs. 29119c9ff80cSmrg libtool_install_magic="$magic" 29121f0ac6a5Smrg 29139c9ff80cSmrg staticlibs= 29149c9ff80cSmrg future_libdirs= 29159c9ff80cSmrg current_libdirs= 29169c9ff80cSmrg for file in $files; do 29171f0ac6a5Smrg 29189c9ff80cSmrg # Do each installation. 29199c9ff80cSmrg case $file in 29209c9ff80cSmrg *.$libext) 29219c9ff80cSmrg # Do the static libraries later. 29226fae4e5dSmrg func_append staticlibs " $file" 29239c9ff80cSmrg ;; 29249c9ff80cSmrg 29259c9ff80cSmrg *.la) 29266fae4e5dSmrg func_resolve_sysroot "$file" 29276fae4e5dSmrg file=$func_resolve_sysroot_result 29286fae4e5dSmrg 29299c9ff80cSmrg # Check to see that this really is a libtool archive. 29309c9ff80cSmrg func_lalib_unsafe_p "$file" \ 29319c9ff80cSmrg || func_fatal_help "\`$file' is not a valid libtool archive" 29329c9ff80cSmrg 29339c9ff80cSmrg library_names= 29349c9ff80cSmrg old_library= 29359c9ff80cSmrg relink_command= 29369c9ff80cSmrg func_source "$file" 29379c9ff80cSmrg 29389c9ff80cSmrg # Add the libdir to current_libdirs if it is the destination. 29399c9ff80cSmrg if test "X$destdir" = "X$libdir"; then 29409c9ff80cSmrg case "$current_libdirs " in 29419c9ff80cSmrg *" $libdir "*) ;; 29426fae4e5dSmrg *) func_append current_libdirs " $libdir" ;; 29431f0ac6a5Smrg esac 29449c9ff80cSmrg else 29459c9ff80cSmrg # Note the libdir as a future libdir. 29469c9ff80cSmrg case "$future_libdirs " in 29479c9ff80cSmrg *" $libdir "*) ;; 29486fae4e5dSmrg *) func_append future_libdirs " $libdir" ;; 29499c9ff80cSmrg esac 29509c9ff80cSmrg fi 29511f0ac6a5Smrg 29529c9ff80cSmrg func_dirname "$file" "/" "" 29539c9ff80cSmrg dir="$func_dirname_result" 29546fae4e5dSmrg func_append dir "$objdir" 29559c9ff80cSmrg 29569c9ff80cSmrg if test -n "$relink_command"; then 29579c9ff80cSmrg # Determine the prefix the user has applied to our future dir. 29586fae4e5dSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 29599c9ff80cSmrg 29609c9ff80cSmrg # Don't allow the user to place us outside of our expected 29619c9ff80cSmrg # location b/c this prevents finding dependent libraries that 29629c9ff80cSmrg # are installed to the same prefix. 29639c9ff80cSmrg # At present, this check doesn't affect windows .dll's that 29649c9ff80cSmrg # are installed into $libdir/../bin (currently, that works fine) 29659c9ff80cSmrg # but it's something to keep an eye on. 29669c9ff80cSmrg test "$inst_prefix_dir" = "$destdir" && \ 29679c9ff80cSmrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 29689c9ff80cSmrg 29699c9ff80cSmrg if test -n "$inst_prefix_dir"; then 29709c9ff80cSmrg # Stick the inst_prefix_dir data into the link command. 29716fae4e5dSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 29729c9ff80cSmrg else 29736fae4e5dSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 29749c9ff80cSmrg fi 29759c9ff80cSmrg 29769c9ff80cSmrg func_warning "relinking \`$file'" 29779c9ff80cSmrg func_show_eval "$relink_command" \ 29789c9ff80cSmrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 29799c9ff80cSmrg fi 29809c9ff80cSmrg 29819c9ff80cSmrg # See the names of the shared library. 29829c9ff80cSmrg set dummy $library_names; shift 29839c9ff80cSmrg if test -n "$1"; then 29849c9ff80cSmrg realname="$1" 29859c9ff80cSmrg shift 29869c9ff80cSmrg 29879c9ff80cSmrg srcname="$realname" 29889c9ff80cSmrg test -n "$relink_command" && srcname="$realname"T 29899c9ff80cSmrg 29909c9ff80cSmrg # Install the shared library and build the symlinks. 29916fae4e5dSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 29929c9ff80cSmrg 'exit $?' 29939c9ff80cSmrg tstripme="$stripme" 29949c9ff80cSmrg case $host_os in 29959c9ff80cSmrg cygwin* | mingw* | pw32* | cegcc*) 29969c9ff80cSmrg case $realname in 29979c9ff80cSmrg *.dll.a) 29989c9ff80cSmrg tstripme="" 29999c9ff80cSmrg ;; 30009c9ff80cSmrg esac 30011f0ac6a5Smrg ;; 30021f0ac6a5Smrg esac 30039c9ff80cSmrg if test -n "$tstripme" && test -n "$striplib"; then 30049c9ff80cSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 30051f0ac6a5Smrg fi 30069c9ff80cSmrg 30079c9ff80cSmrg if test "$#" -gt 0; then 30089c9ff80cSmrg # Delete the old symlinks, and create new ones. 30099c9ff80cSmrg # Try `ln -sf' first, because the `ln' binary might depend on 30109c9ff80cSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 30119c9ff80cSmrg # so we also need to try rm && ln -s. 30129c9ff80cSmrg for linkname 30139c9ff80cSmrg do 30149c9ff80cSmrg test "$linkname" != "$realname" \ 30159c9ff80cSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 30161f0ac6a5Smrg done 30171f0ac6a5Smrg fi 30181f0ac6a5Smrg 30199c9ff80cSmrg # Do each command in the postinstall commands. 30209c9ff80cSmrg lib="$destdir/$realname" 30219c9ff80cSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 30221f0ac6a5Smrg fi 30231f0ac6a5Smrg 30249c9ff80cSmrg # Install the pseudo-library for information purposes. 30259c9ff80cSmrg func_basename "$file" 30269c9ff80cSmrg name="$func_basename_result" 30279c9ff80cSmrg instname="$dir/$name"i 30289c9ff80cSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 30291f0ac6a5Smrg 30309c9ff80cSmrg # Maybe install the static library, too. 30316fae4e5dSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 30329c9ff80cSmrg ;; 30331f0ac6a5Smrg 30349c9ff80cSmrg *.lo) 30359c9ff80cSmrg # Install (i.e. copy) a libtool object. 30361f0ac6a5Smrg 30379c9ff80cSmrg # Figure out destination file name, if it wasn't already specified. 30389c9ff80cSmrg if test -n "$destname"; then 30399c9ff80cSmrg destfile="$destdir/$destname" 30409c9ff80cSmrg else 30419c9ff80cSmrg func_basename "$file" 30429c9ff80cSmrg destfile="$func_basename_result" 30439c9ff80cSmrg destfile="$destdir/$destfile" 30441f0ac6a5Smrg fi 30451f0ac6a5Smrg 30469c9ff80cSmrg # Deduce the name of the destination old-style object file. 30479c9ff80cSmrg case $destfile in 30489c9ff80cSmrg *.lo) 30499c9ff80cSmrg func_lo2o "$destfile" 30509c9ff80cSmrg staticdest=$func_lo2o_result 30519c9ff80cSmrg ;; 30529c9ff80cSmrg *.$objext) 30539c9ff80cSmrg staticdest="$destfile" 30549c9ff80cSmrg destfile= 30559c9ff80cSmrg ;; 30569c9ff80cSmrg *) 30579c9ff80cSmrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 30589c9ff80cSmrg ;; 30599c9ff80cSmrg esac 30601f0ac6a5Smrg 30619c9ff80cSmrg # Install the libtool object if requested. 30629c9ff80cSmrg test -n "$destfile" && \ 30639c9ff80cSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 30641f0ac6a5Smrg 30659c9ff80cSmrg # Install the old object if enabled. 30669c9ff80cSmrg if test "$build_old_libs" = yes; then 30679c9ff80cSmrg # Deduce the name of the old-style object file. 30689c9ff80cSmrg func_lo2o "$file" 30699c9ff80cSmrg staticobj=$func_lo2o_result 30709c9ff80cSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 30711f0ac6a5Smrg fi 30729c9ff80cSmrg exit $EXIT_SUCCESS 30739c9ff80cSmrg ;; 30741f0ac6a5Smrg 30759c9ff80cSmrg *) 30769c9ff80cSmrg # Figure out destination file name, if it wasn't already specified. 30779c9ff80cSmrg if test -n "$destname"; then 30789c9ff80cSmrg destfile="$destdir/$destname" 30799c9ff80cSmrg else 30809c9ff80cSmrg func_basename "$file" 30819c9ff80cSmrg destfile="$func_basename_result" 30829c9ff80cSmrg destfile="$destdir/$destfile" 30839c9ff80cSmrg fi 30841f0ac6a5Smrg 30859c9ff80cSmrg # If the file is missing, and there is a .exe on the end, strip it 30869c9ff80cSmrg # because it is most likely a libtool script we actually want to 30879c9ff80cSmrg # install 30889c9ff80cSmrg stripped_ext="" 30899c9ff80cSmrg case $file in 30909c9ff80cSmrg *.exe) 30919c9ff80cSmrg if test ! -f "$file"; then 30929c9ff80cSmrg func_stripname '' '.exe' "$file" 30939c9ff80cSmrg file=$func_stripname_result 30949c9ff80cSmrg stripped_ext=".exe" 30959c9ff80cSmrg fi 30969c9ff80cSmrg ;; 30979c9ff80cSmrg esac 30989c9ff80cSmrg 30999c9ff80cSmrg # Do a test to see if this is really a libtool program. 31009c9ff80cSmrg case $host in 31019c9ff80cSmrg *cygwin* | *mingw*) 31029c9ff80cSmrg if func_ltwrapper_executable_p "$file"; then 31039c9ff80cSmrg func_ltwrapper_scriptname "$file" 31049c9ff80cSmrg wrapper=$func_ltwrapper_scriptname_result 31059c9ff80cSmrg else 31069c9ff80cSmrg func_stripname '' '.exe' "$file" 31079c9ff80cSmrg wrapper=$func_stripname_result 31089c9ff80cSmrg fi 31099c9ff80cSmrg ;; 31101f0ac6a5Smrg *) 31119c9ff80cSmrg wrapper=$file 31129c9ff80cSmrg ;; 31139c9ff80cSmrg esac 31149c9ff80cSmrg if func_ltwrapper_script_p "$wrapper"; then 31159c9ff80cSmrg notinst_deplibs= 31169c9ff80cSmrg relink_command= 31179c9ff80cSmrg 31189c9ff80cSmrg func_source "$wrapper" 31199c9ff80cSmrg 31209c9ff80cSmrg # Check the variables that should have been set. 31219c9ff80cSmrg test -z "$generated_by_libtool_version" && \ 31229c9ff80cSmrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 31239c9ff80cSmrg 31249c9ff80cSmrg finalize=yes 31259c9ff80cSmrg for lib in $notinst_deplibs; do 31269c9ff80cSmrg # Check to see that each library is installed. 31279c9ff80cSmrg libdir= 31289c9ff80cSmrg if test -f "$lib"; then 31299c9ff80cSmrg func_source "$lib" 31309c9ff80cSmrg fi 31316fae4e5dSmrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 31329c9ff80cSmrg if test -n "$libdir" && test ! -f "$libfile"; then 31339c9ff80cSmrg func_warning "\`$lib' has not been installed in \`$libdir'" 31349c9ff80cSmrg finalize=no 31359c9ff80cSmrg fi 31369c9ff80cSmrg done 31379c9ff80cSmrg 31389c9ff80cSmrg relink_command= 31399c9ff80cSmrg func_source "$wrapper" 31409c9ff80cSmrg 31419c9ff80cSmrg outputname= 31429c9ff80cSmrg if test "$fast_install" = no && test -n "$relink_command"; then 31439c9ff80cSmrg $opt_dry_run || { 31449c9ff80cSmrg if test "$finalize" = yes; then 31459c9ff80cSmrg tmpdir=`func_mktempdir` 31469c9ff80cSmrg func_basename "$file$stripped_ext" 31479c9ff80cSmrg file="$func_basename_result" 31489c9ff80cSmrg outputname="$tmpdir/$file" 31499c9ff80cSmrg # Replace the output file specification. 31506fae4e5dSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 31519c9ff80cSmrg 31529c9ff80cSmrg $opt_silent || { 31539c9ff80cSmrg func_quote_for_expand "$relink_command" 31549c9ff80cSmrg eval "func_echo $func_quote_for_expand_result" 31559c9ff80cSmrg } 31569c9ff80cSmrg if eval "$relink_command"; then : 31579c9ff80cSmrg else 31589c9ff80cSmrg func_error "error: relink \`$file' with the above command before installing it" 31599c9ff80cSmrg $opt_dry_run || ${RM}r "$tmpdir" 31609c9ff80cSmrg continue 31619c9ff80cSmrg fi 31629c9ff80cSmrg file="$outputname" 31639c9ff80cSmrg else 31649c9ff80cSmrg func_warning "cannot relink \`$file'" 31659c9ff80cSmrg fi 31669c9ff80cSmrg } 31679c9ff80cSmrg else 31689c9ff80cSmrg # Install the binary that we compiled earlier. 31696fae4e5dSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 31701f0ac6a5Smrg fi 31719c9ff80cSmrg fi 31729c9ff80cSmrg 31739c9ff80cSmrg # remove .exe since cygwin /usr/bin/install will append another 31749c9ff80cSmrg # one anyway 31759c9ff80cSmrg case $install_prog,$host in 31769c9ff80cSmrg */usr/bin/install*,*cygwin*) 31779c9ff80cSmrg case $file:$destfile in 31789c9ff80cSmrg *.exe:*.exe) 31799c9ff80cSmrg # this is ok 31809c9ff80cSmrg ;; 31819c9ff80cSmrg *.exe:*) 31829c9ff80cSmrg destfile=$destfile.exe 31839c9ff80cSmrg ;; 31849c9ff80cSmrg *:*.exe) 31859c9ff80cSmrg func_stripname '' '.exe' "$destfile" 31869c9ff80cSmrg destfile=$func_stripname_result 31879c9ff80cSmrg ;; 31889c9ff80cSmrg esac 31891f0ac6a5Smrg ;; 31901f0ac6a5Smrg esac 31919c9ff80cSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 31929c9ff80cSmrg $opt_dry_run || if test -n "$outputname"; then 31939c9ff80cSmrg ${RM}r "$tmpdir" 31949c9ff80cSmrg fi 31959c9ff80cSmrg ;; 31969c9ff80cSmrg esac 31979c9ff80cSmrg done 31981f0ac6a5Smrg 31999c9ff80cSmrg for file in $staticlibs; do 32009c9ff80cSmrg func_basename "$file" 32019c9ff80cSmrg name="$func_basename_result" 32029c9ff80cSmrg 32039c9ff80cSmrg # Set up the ranlib parameters. 32049c9ff80cSmrg oldlib="$destdir/$name" 320589c04b6cSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 320689c04b6cSmrg tool_oldlib=$func_to_tool_file_result 32079c9ff80cSmrg 32089c9ff80cSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 32099c9ff80cSmrg 32109c9ff80cSmrg if test -n "$stripme" && test -n "$old_striplib"; then 321189c04b6cSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 32129c9ff80cSmrg fi 32139c9ff80cSmrg 32149c9ff80cSmrg # Do each command in the postinstall commands. 32159c9ff80cSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 32169c9ff80cSmrg done 32179c9ff80cSmrg 32189c9ff80cSmrg test -n "$future_libdirs" && \ 32199c9ff80cSmrg func_warning "remember to run \`$progname --finish$future_libdirs'" 32209c9ff80cSmrg 32219c9ff80cSmrg if test -n "$current_libdirs"; then 32229c9ff80cSmrg # Maybe just do a dry run. 32239c9ff80cSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 32249c9ff80cSmrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 32259c9ff80cSmrg else 32269c9ff80cSmrg exit $EXIT_SUCCESS 32279c9ff80cSmrg fi 32289c9ff80cSmrg} 32299c9ff80cSmrg 32306fae4e5dSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 32319c9ff80cSmrg 32329c9ff80cSmrg 32339c9ff80cSmrg# func_generate_dlsyms outputname originator pic_p 32349c9ff80cSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 32359c9ff80cSmrg# a dlpreopen symbol table. 32369c9ff80cSmrgfunc_generate_dlsyms () 32379c9ff80cSmrg{ 32389c9ff80cSmrg $opt_debug 32399c9ff80cSmrg my_outputname="$1" 32409c9ff80cSmrg my_originator="$2" 32419c9ff80cSmrg my_pic_p="${3-no}" 32429c9ff80cSmrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 32439c9ff80cSmrg my_dlsyms= 32449c9ff80cSmrg 32459c9ff80cSmrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 32469c9ff80cSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 32479c9ff80cSmrg my_dlsyms="${my_outputname}S.c" 32489c9ff80cSmrg else 32499c9ff80cSmrg func_error "not configured to extract global symbols from dlpreopened files" 32509c9ff80cSmrg fi 32519c9ff80cSmrg fi 32529c9ff80cSmrg 32539c9ff80cSmrg if test -n "$my_dlsyms"; then 32549c9ff80cSmrg case $my_dlsyms in 32559c9ff80cSmrg "") ;; 32569c9ff80cSmrg *.c) 32579c9ff80cSmrg # Discover the nlist of each of the dlfiles. 32589c9ff80cSmrg nlist="$output_objdir/${my_outputname}.nm" 32599c9ff80cSmrg 32609c9ff80cSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 32619c9ff80cSmrg 32629c9ff80cSmrg # Parse the name list into a source file. 32639c9ff80cSmrg func_verbose "creating $output_objdir/$my_dlsyms" 32649c9ff80cSmrg 32659c9ff80cSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 32669c9ff80cSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 32679c9ff80cSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 32689c9ff80cSmrg 32699c9ff80cSmrg#ifdef __cplusplus 32709c9ff80cSmrgextern \"C\" { 32719c9ff80cSmrg#endif 32729c9ff80cSmrg 32736fae4e5dSmrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 32746fae4e5dSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 32756fae4e5dSmrg#endif 32766fae4e5dSmrg 32776fae4e5dSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 32786fae4e5dSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 32796fae4e5dSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 32806fae4e5dSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 32816fae4e5dSmrg# define LT_DLSYM_CONST 32826fae4e5dSmrg#elif defined(__osf__) 32836fae4e5dSmrg/* This system does not cope well with relocations in const data. */ 32846fae4e5dSmrg# define LT_DLSYM_CONST 32856fae4e5dSmrg#else 32866fae4e5dSmrg# define LT_DLSYM_CONST const 32876fae4e5dSmrg#endif 32886fae4e5dSmrg 32899c9ff80cSmrg/* External symbol declarations for the compiler. */\ 32909c9ff80cSmrg" 32919c9ff80cSmrg 32929c9ff80cSmrg if test "$dlself" = yes; then 32939c9ff80cSmrg func_verbose "generating symbol list for \`$output'" 32949c9ff80cSmrg 32959c9ff80cSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 32969c9ff80cSmrg 32979c9ff80cSmrg # Add our own program objects to the symbol list. 32986fae4e5dSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 32999c9ff80cSmrg for progfile in $progfiles; do 33006fae4e5dSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 33016fae4e5dSmrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 33026fae4e5dSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 33039c9ff80cSmrg done 33049c9ff80cSmrg 33059c9ff80cSmrg if test -n "$exclude_expsyms"; then 33069c9ff80cSmrg $opt_dry_run || { 33079c9ff80cSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 33089c9ff80cSmrg eval '$MV "$nlist"T "$nlist"' 33099c9ff80cSmrg } 33101f0ac6a5Smrg fi 33119c9ff80cSmrg 33129c9ff80cSmrg if test -n "$export_symbols_regex"; then 33139c9ff80cSmrg $opt_dry_run || { 33149c9ff80cSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 33159c9ff80cSmrg eval '$MV "$nlist"T "$nlist"' 33169c9ff80cSmrg } 33179c9ff80cSmrg fi 33189c9ff80cSmrg 33199c9ff80cSmrg # Prepare the list of exported symbols 33209c9ff80cSmrg if test -z "$export_symbols"; then 33219c9ff80cSmrg export_symbols="$output_objdir/$outputname.exp" 33229c9ff80cSmrg $opt_dry_run || { 33239c9ff80cSmrg $RM $export_symbols 33249c9ff80cSmrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 33259c9ff80cSmrg case $host in 33269c9ff80cSmrg *cygwin* | *mingw* | *cegcc* ) 33279c9ff80cSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 33289c9ff80cSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 33299c9ff80cSmrg ;; 33309c9ff80cSmrg esac 33319c9ff80cSmrg } 33321f0ac6a5Smrg else 33339c9ff80cSmrg $opt_dry_run || { 33349c9ff80cSmrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 33359c9ff80cSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 33369c9ff80cSmrg eval '$MV "$nlist"T "$nlist"' 33379c9ff80cSmrg case $host in 33386fae4e5dSmrg *cygwin* | *mingw* | *cegcc* ) 33399c9ff80cSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 33409c9ff80cSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 33419c9ff80cSmrg ;; 33429c9ff80cSmrg esac 33439c9ff80cSmrg } 33441f0ac6a5Smrg fi 33459c9ff80cSmrg fi 33461f0ac6a5Smrg 33479c9ff80cSmrg for dlprefile in $dlprefiles; do 33489c9ff80cSmrg func_verbose "extracting global C symbols from \`$dlprefile'" 33499c9ff80cSmrg func_basename "$dlprefile" 33509c9ff80cSmrg name="$func_basename_result" 33516fae4e5dSmrg case $host in 33526fae4e5dSmrg *cygwin* | *mingw* | *cegcc* ) 33536fae4e5dSmrg # if an import library, we need to obtain dlname 33546fae4e5dSmrg if func_win32_import_lib_p "$dlprefile"; then 33556fae4e5dSmrg func_tr_sh "$dlprefile" 33566fae4e5dSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 33576fae4e5dSmrg dlprefile_dlbasename="" 33586fae4e5dSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 33596fae4e5dSmrg # Use subshell, to avoid clobbering current variable values 33606fae4e5dSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 33616fae4e5dSmrg if test -n "$dlprefile_dlname" ; then 33626fae4e5dSmrg func_basename "$dlprefile_dlname" 33636fae4e5dSmrg dlprefile_dlbasename="$func_basename_result" 33646fae4e5dSmrg else 33656fae4e5dSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 33666fae4e5dSmrg $sharedlib_from_linklib_cmd "$dlprefile" 33676fae4e5dSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 33686fae4e5dSmrg fi 33696fae4e5dSmrg fi 33706fae4e5dSmrg $opt_dry_run || { 33716fae4e5dSmrg if test -n "$dlprefile_dlbasename" ; then 33726fae4e5dSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 33736fae4e5dSmrg else 33746fae4e5dSmrg func_warning "Could not compute DLL name from $name" 33756fae4e5dSmrg eval '$ECHO ": $name " >> "$nlist"' 33766fae4e5dSmrg fi 33776fae4e5dSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 33786fae4e5dSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 33796fae4e5dSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 33806fae4e5dSmrg } 33816fae4e5dSmrg else # not an import lib 33826fae4e5dSmrg $opt_dry_run || { 33836fae4e5dSmrg eval '$ECHO ": $name " >> "$nlist"' 33846fae4e5dSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 33856fae4e5dSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 33866fae4e5dSmrg } 33876fae4e5dSmrg fi 33886fae4e5dSmrg ;; 33896fae4e5dSmrg *) 33906fae4e5dSmrg $opt_dry_run || { 33916fae4e5dSmrg eval '$ECHO ": $name " >> "$nlist"' 33926fae4e5dSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 33936fae4e5dSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 33946fae4e5dSmrg } 33956fae4e5dSmrg ;; 33966fae4e5dSmrg esac 33979c9ff80cSmrg done 33989c9ff80cSmrg 33999c9ff80cSmrg $opt_dry_run || { 34009c9ff80cSmrg # Make sure we have at least an empty file. 34019c9ff80cSmrg test -f "$nlist" || : > "$nlist" 34029c9ff80cSmrg 34039c9ff80cSmrg if test -n "$exclude_expsyms"; then 34049c9ff80cSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 34059c9ff80cSmrg $MV "$nlist"T "$nlist" 34061f0ac6a5Smrg fi 34079c9ff80cSmrg 34089c9ff80cSmrg # Try sorting and uniquifying the output. 34099c9ff80cSmrg if $GREP -v "^: " < "$nlist" | 34109c9ff80cSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 34119c9ff80cSmrg sort -k 3 34129c9ff80cSmrg else 34139c9ff80cSmrg sort +2 34149c9ff80cSmrg fi | 34159c9ff80cSmrg uniq > "$nlist"S; then 34169c9ff80cSmrg : 34171f0ac6a5Smrg else 34189c9ff80cSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 34191f0ac6a5Smrg fi 34201f0ac6a5Smrg 34219c9ff80cSmrg if test -f "$nlist"S; then 34229c9ff80cSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 34231f0ac6a5Smrg else 34246fae4e5dSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 34251f0ac6a5Smrg fi 34261f0ac6a5Smrg 34276fae4e5dSmrg echo >> "$output_objdir/$my_dlsyms" "\ 34281f0ac6a5Smrg 34299c9ff80cSmrg/* The mapping between symbol names and symbols. */ 34309c9ff80cSmrgtypedef struct { 34319c9ff80cSmrg const char *name; 34329c9ff80cSmrg void *address; 34339c9ff80cSmrg} lt_dlsymlist; 34346fae4e5dSmrgextern LT_DLSYM_CONST lt_dlsymlist 34359c9ff80cSmrglt_${my_prefix}_LTX_preloaded_symbols[]; 34366fae4e5dSmrgLT_DLSYM_CONST lt_dlsymlist 34379c9ff80cSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 34389c9ff80cSmrg{\ 34399c9ff80cSmrg { \"$my_originator\", (void *) 0 }," 34401f0ac6a5Smrg 34419c9ff80cSmrg case $need_lib_prefix in 34429c9ff80cSmrg no) 34439c9ff80cSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 34449c9ff80cSmrg ;; 34459c9ff80cSmrg *) 34469c9ff80cSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 34479c9ff80cSmrg ;; 34489c9ff80cSmrg esac 34496fae4e5dSmrg echo >> "$output_objdir/$my_dlsyms" "\ 34509c9ff80cSmrg {0, (void *) 0} 34519c9ff80cSmrg}; 34521f0ac6a5Smrg 34539c9ff80cSmrg/* This works around a problem in FreeBSD linker */ 34549c9ff80cSmrg#ifdef FREEBSD_WORKAROUND 34559c9ff80cSmrgstatic const void *lt_preloaded_setup() { 34569c9ff80cSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 34579c9ff80cSmrg} 34589c9ff80cSmrg#endif 34599c9ff80cSmrg 34609c9ff80cSmrg#ifdef __cplusplus 34619c9ff80cSmrg} 34629c9ff80cSmrg#endif\ 34639c9ff80cSmrg" 34649c9ff80cSmrg } # !$opt_dry_run 34659c9ff80cSmrg 34669c9ff80cSmrg pic_flag_for_symtable= 34679c9ff80cSmrg case "$compile_command " in 34689c9ff80cSmrg *" -static "*) ;; 34699c9ff80cSmrg *) 34709c9ff80cSmrg case $host in 34719c9ff80cSmrg # compiling the symbol table file with pic_flag works around 34729c9ff80cSmrg # a FreeBSD bug that causes programs to crash when -lm is 34739c9ff80cSmrg # linked before any other PIC object. But we must not use 34749c9ff80cSmrg # pic_flag when linking with -static. The problem exists in 34759c9ff80cSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 347689c04b6cSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 34779c9ff80cSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 34789c9ff80cSmrg *-*-hpux*) 34799c9ff80cSmrg pic_flag_for_symtable=" $pic_flag" ;; 34809c9ff80cSmrg *) 34819c9ff80cSmrg if test "X$my_pic_p" != Xno; then 34829c9ff80cSmrg pic_flag_for_symtable=" $pic_flag" 34831f0ac6a5Smrg fi 34849c9ff80cSmrg ;; 34859c9ff80cSmrg esac 34869c9ff80cSmrg ;; 34879c9ff80cSmrg esac 34889c9ff80cSmrg symtab_cflags= 34899c9ff80cSmrg for arg in $LTCFLAGS; do 34909c9ff80cSmrg case $arg in 34919c9ff80cSmrg -pie | -fpie | -fPIE) ;; 34926fae4e5dSmrg *) func_append symtab_cflags " $arg" ;; 34939c9ff80cSmrg esac 34949c9ff80cSmrg done 34951f0ac6a5Smrg 34969c9ff80cSmrg # Now compile the dynamic symbol file. 34979c9ff80cSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 34981f0ac6a5Smrg 34999c9ff80cSmrg # Clean up the generated files. 35009c9ff80cSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 35011f0ac6a5Smrg 35029c9ff80cSmrg # Transform the symbol file into the correct name. 35039c9ff80cSmrg symfileobj="$output_objdir/${my_outputname}S.$objext" 35049c9ff80cSmrg case $host in 35059c9ff80cSmrg *cygwin* | *mingw* | *cegcc* ) 35069c9ff80cSmrg if test -f "$output_objdir/$my_outputname.def"; then 35076fae4e5dSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 35086fae4e5dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 35099c9ff80cSmrg else 35106fae4e5dSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35116fae4e5dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35121f0ac6a5Smrg fi 35139c9ff80cSmrg ;; 35149c9ff80cSmrg *) 35156fae4e5dSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35166fae4e5dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35179c9ff80cSmrg ;; 35189c9ff80cSmrg esac 35199c9ff80cSmrg ;; 35209c9ff80cSmrg *) 35219c9ff80cSmrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 35229c9ff80cSmrg ;; 35239c9ff80cSmrg esac 35249c9ff80cSmrg else 35259c9ff80cSmrg # We keep going just in case the user didn't refer to 35269c9ff80cSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 35279c9ff80cSmrg # really was required. 35281f0ac6a5Smrg 35299c9ff80cSmrg # Nullify the symbol file. 35306fae4e5dSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 35316fae4e5dSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 35329c9ff80cSmrg fi 35339c9ff80cSmrg} 35341f0ac6a5Smrg 35359c9ff80cSmrg# func_win32_libid arg 35369c9ff80cSmrg# return the library type of file 'arg' 35379c9ff80cSmrg# 35389c9ff80cSmrg# Need a lot of goo to handle *both* DLLs and import libs 35399c9ff80cSmrg# Has to be a shell function in order to 'eat' the argument 35409c9ff80cSmrg# that is supplied when $file_magic_command is called. 35416fae4e5dSmrg# Despite the name, also deal with 64 bit binaries. 35429c9ff80cSmrgfunc_win32_libid () 35439c9ff80cSmrg{ 35449c9ff80cSmrg $opt_debug 35459c9ff80cSmrg win32_libid_type="unknown" 35469c9ff80cSmrg win32_fileres=`file -L $1 2>/dev/null` 35479c9ff80cSmrg case $win32_fileres in 35489c9ff80cSmrg *ar\ archive\ import\ library*) # definitely import 35499c9ff80cSmrg win32_libid_type="x86 archive import" 35509c9ff80cSmrg ;; 35519c9ff80cSmrg *ar\ archive*) # could be an import, or static 35526fae4e5dSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 35539c9ff80cSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 35546fae4e5dSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 35556fae4e5dSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 35566fae4e5dSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 35579c9ff80cSmrg $SED -n -e ' 35589c9ff80cSmrg 1,100{ 35599c9ff80cSmrg / I /{ 35609c9ff80cSmrg s,.*,import, 35619c9ff80cSmrg p 35629c9ff80cSmrg q 35639c9ff80cSmrg } 35649c9ff80cSmrg }'` 35659c9ff80cSmrg case $win32_nmres in 35669c9ff80cSmrg import*) win32_libid_type="x86 archive import";; 35679c9ff80cSmrg *) win32_libid_type="x86 archive static";; 35689c9ff80cSmrg esac 35699c9ff80cSmrg fi 35709c9ff80cSmrg ;; 35719c9ff80cSmrg *DLL*) 35729c9ff80cSmrg win32_libid_type="x86 DLL" 35739c9ff80cSmrg ;; 35749c9ff80cSmrg *executable*) # but shell scripts are "executable" too... 35759c9ff80cSmrg case $win32_fileres in 35769c9ff80cSmrg *MS\ Windows\ PE\ Intel*) 35779c9ff80cSmrg win32_libid_type="x86 DLL" 35789c9ff80cSmrg ;; 35799c9ff80cSmrg esac 35809c9ff80cSmrg ;; 35819c9ff80cSmrg esac 35829c9ff80cSmrg $ECHO "$win32_libid_type" 35839c9ff80cSmrg} 35841f0ac6a5Smrg 35856fae4e5dSmrg# func_cygming_dll_for_implib ARG 35866fae4e5dSmrg# 35876fae4e5dSmrg# Platform-specific function to extract the 35886fae4e5dSmrg# name of the DLL associated with the specified 35896fae4e5dSmrg# import library ARG. 35906fae4e5dSmrg# Invoked by eval'ing the libtool variable 35916fae4e5dSmrg# $sharedlib_from_linklib_cmd 35926fae4e5dSmrg# Result is available in the variable 35936fae4e5dSmrg# $sharedlib_from_linklib_result 35946fae4e5dSmrgfunc_cygming_dll_for_implib () 35956fae4e5dSmrg{ 35966fae4e5dSmrg $opt_debug 35976fae4e5dSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 35986fae4e5dSmrg} 35996fae4e5dSmrg 36006fae4e5dSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 36016fae4e5dSmrg# 36026fae4e5dSmrg# The is the core of a fallback implementation of a 36036fae4e5dSmrg# platform-specific function to extract the name of the 36046fae4e5dSmrg# DLL associated with the specified import library LIBNAME. 36056fae4e5dSmrg# 36066fae4e5dSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 36076fae4e5dSmrg# on the platform and compiler that created the implib. 36086fae4e5dSmrg# 36096fae4e5dSmrg# Echos the name of the DLL associated with the 36106fae4e5dSmrg# specified import library. 36116fae4e5dSmrgfunc_cygming_dll_for_implib_fallback_core () 36126fae4e5dSmrg{ 36136fae4e5dSmrg $opt_debug 36146fae4e5dSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 36156fae4e5dSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 36166fae4e5dSmrg $SED '/^Contents of section '"$match_literal"':/{ 36176fae4e5dSmrg # Place marker at beginning of archive member dllname section 36186fae4e5dSmrg s/.*/====MARK====/ 36196fae4e5dSmrg p 36206fae4e5dSmrg d 36216fae4e5dSmrg } 36226fae4e5dSmrg # These lines can sometimes be longer than 43 characters, but 36236fae4e5dSmrg # are always uninteresting 36246fae4e5dSmrg /:[ ]*file format pe[i]\{,1\}-/d 36256fae4e5dSmrg /^In archive [^:]*:/d 36266fae4e5dSmrg # Ensure marker is printed 36276fae4e5dSmrg /^====MARK====/p 36286fae4e5dSmrg # Remove all lines with less than 43 characters 36296fae4e5dSmrg /^.\{43\}/!d 36306fae4e5dSmrg # From remaining lines, remove first 43 characters 36316fae4e5dSmrg s/^.\{43\}//' | 36326fae4e5dSmrg $SED -n ' 36336fae4e5dSmrg # Join marker and all lines until next marker into a single line 36346fae4e5dSmrg /^====MARK====/ b para 36356fae4e5dSmrg H 36366fae4e5dSmrg $ b para 36376fae4e5dSmrg b 36386fae4e5dSmrg :para 36396fae4e5dSmrg x 36406fae4e5dSmrg s/\n//g 36416fae4e5dSmrg # Remove the marker 36426fae4e5dSmrg s/^====MARK====// 36436fae4e5dSmrg # Remove trailing dots and whitespace 36446fae4e5dSmrg s/[\. \t]*$// 36456fae4e5dSmrg # Print 36466fae4e5dSmrg /./p' | 36476fae4e5dSmrg # we now have a list, one entry per line, of the stringified 36486fae4e5dSmrg # contents of the appropriate section of all members of the 36496fae4e5dSmrg # archive which possess that section. Heuristic: eliminate 36506fae4e5dSmrg # all those which have a first or second character that is 36516fae4e5dSmrg # a '.' (that is, objdump's representation of an unprintable 36526fae4e5dSmrg # character.) This should work for all archives with less than 36536fae4e5dSmrg # 0x302f exports -- but will fail for DLLs whose name actually 36546fae4e5dSmrg # begins with a literal '.' or a single character followed by 36556fae4e5dSmrg # a '.'. 36566fae4e5dSmrg # 36576fae4e5dSmrg # Of those that remain, print the first one. 36586fae4e5dSmrg $SED -e '/^\./d;/^.\./d;q' 36596fae4e5dSmrg} 36606fae4e5dSmrg 36616fae4e5dSmrg# func_cygming_gnu_implib_p ARG 36626fae4e5dSmrg# This predicate returns with zero status (TRUE) if 36636fae4e5dSmrg# ARG is a GNU/binutils-style import library. Returns 36646fae4e5dSmrg# with nonzero status (FALSE) otherwise. 36656fae4e5dSmrgfunc_cygming_gnu_implib_p () 36666fae4e5dSmrg{ 36676fae4e5dSmrg $opt_debug 36686fae4e5dSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 36696fae4e5dSmrg 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)$'` 36706fae4e5dSmrg test -n "$func_cygming_gnu_implib_tmp" 36716fae4e5dSmrg} 36726fae4e5dSmrg 36736fae4e5dSmrg# func_cygming_ms_implib_p ARG 36746fae4e5dSmrg# This predicate returns with zero status (TRUE) if 36756fae4e5dSmrg# ARG is an MS-style import library. Returns 36766fae4e5dSmrg# with nonzero status (FALSE) otherwise. 36776fae4e5dSmrgfunc_cygming_ms_implib_p () 36786fae4e5dSmrg{ 36796fae4e5dSmrg $opt_debug 36806fae4e5dSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 36816fae4e5dSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 36826fae4e5dSmrg test -n "$func_cygming_ms_implib_tmp" 36836fae4e5dSmrg} 36846fae4e5dSmrg 36856fae4e5dSmrg# func_cygming_dll_for_implib_fallback ARG 36866fae4e5dSmrg# Platform-specific function to extract the 36876fae4e5dSmrg# name of the DLL associated with the specified 36886fae4e5dSmrg# import library ARG. 36896fae4e5dSmrg# 36906fae4e5dSmrg# This fallback implementation is for use when $DLLTOOL 36916fae4e5dSmrg# does not support the --identify-strict option. 36926fae4e5dSmrg# Invoked by eval'ing the libtool variable 36936fae4e5dSmrg# $sharedlib_from_linklib_cmd 36946fae4e5dSmrg# Result is available in the variable 36956fae4e5dSmrg# $sharedlib_from_linklib_result 36966fae4e5dSmrgfunc_cygming_dll_for_implib_fallback () 36976fae4e5dSmrg{ 36986fae4e5dSmrg $opt_debug 36996fae4e5dSmrg if func_cygming_gnu_implib_p "$1" ; then 37006fae4e5dSmrg # binutils import library 37016fae4e5dSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 37026fae4e5dSmrg elif func_cygming_ms_implib_p "$1" ; then 37036fae4e5dSmrg # ms-generated import library 37046fae4e5dSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 37056fae4e5dSmrg else 37066fae4e5dSmrg # unknown 37076fae4e5dSmrg sharedlib_from_linklib_result="" 37086fae4e5dSmrg fi 37096fae4e5dSmrg} 37101f0ac6a5Smrg 37111f0ac6a5Smrg 37129c9ff80cSmrg# func_extract_an_archive dir oldlib 37139c9ff80cSmrgfunc_extract_an_archive () 37149c9ff80cSmrg{ 37159c9ff80cSmrg $opt_debug 37169c9ff80cSmrg f_ex_an_ar_dir="$1"; shift 37179c9ff80cSmrg f_ex_an_ar_oldlib="$1" 37186fae4e5dSmrg if test "$lock_old_archive_extraction" = yes; then 37196fae4e5dSmrg lockfile=$f_ex_an_ar_oldlib.lock 37206fae4e5dSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 37216fae4e5dSmrg func_echo "Waiting for $lockfile to be removed" 37226fae4e5dSmrg sleep 2 37236fae4e5dSmrg done 37246fae4e5dSmrg fi 37256fae4e5dSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 37266fae4e5dSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 37276fae4e5dSmrg if test "$lock_old_archive_extraction" = yes; then 37286fae4e5dSmrg $opt_dry_run || rm -f "$lockfile" 37296fae4e5dSmrg fi 37309c9ff80cSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 37319c9ff80cSmrg : 37329c9ff80cSmrg else 37339c9ff80cSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 37349c9ff80cSmrg fi 37359c9ff80cSmrg} 37361f0ac6a5Smrg 37371f0ac6a5Smrg 37389c9ff80cSmrg# func_extract_archives gentop oldlib ... 37399c9ff80cSmrgfunc_extract_archives () 37409c9ff80cSmrg{ 37419c9ff80cSmrg $opt_debug 37429c9ff80cSmrg my_gentop="$1"; shift 37439c9ff80cSmrg my_oldlibs=${1+"$@"} 37449c9ff80cSmrg my_oldobjs="" 37459c9ff80cSmrg my_xlib="" 37469c9ff80cSmrg my_xabs="" 37479c9ff80cSmrg my_xdir="" 37481f0ac6a5Smrg 37499c9ff80cSmrg for my_xlib in $my_oldlibs; do 37509c9ff80cSmrg # Extract the objects. 37519c9ff80cSmrg case $my_xlib in 37529c9ff80cSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 37539c9ff80cSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 37549c9ff80cSmrg esac 37559c9ff80cSmrg func_basename "$my_xlib" 37569c9ff80cSmrg my_xlib="$func_basename_result" 37579c9ff80cSmrg my_xlib_u=$my_xlib 37589c9ff80cSmrg while :; do 37599c9ff80cSmrg case " $extracted_archives " in 37609c9ff80cSmrg *" $my_xlib_u "*) 37619c9ff80cSmrg func_arith $extracted_serial + 1 37629c9ff80cSmrg extracted_serial=$func_arith_result 37639c9ff80cSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 37649c9ff80cSmrg *) break ;; 37659c9ff80cSmrg esac 37669c9ff80cSmrg done 37679c9ff80cSmrg extracted_archives="$extracted_archives $my_xlib_u" 37689c9ff80cSmrg my_xdir="$my_gentop/$my_xlib_u" 37691f0ac6a5Smrg 37709c9ff80cSmrg func_mkdir_p "$my_xdir" 37711f0ac6a5Smrg 37729c9ff80cSmrg case $host in 37739c9ff80cSmrg *-darwin*) 37749c9ff80cSmrg func_verbose "Extracting $my_xabs" 37759c9ff80cSmrg # Do not bother doing anything if just a dry run 37769c9ff80cSmrg $opt_dry_run || { 37779c9ff80cSmrg darwin_orig_dir=`pwd` 37789c9ff80cSmrg cd $my_xdir || exit $? 37799c9ff80cSmrg darwin_archive=$my_xabs 37809c9ff80cSmrg darwin_curdir=`pwd` 37819c9ff80cSmrg darwin_base_archive=`basename "$darwin_archive"` 37829c9ff80cSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 37839c9ff80cSmrg if test -n "$darwin_arches"; then 37849c9ff80cSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 37859c9ff80cSmrg darwin_arch= 37869c9ff80cSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 37879c9ff80cSmrg for darwin_arch in $darwin_arches ; do 37889c9ff80cSmrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 37899c9ff80cSmrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 37909c9ff80cSmrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 37919c9ff80cSmrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 37929c9ff80cSmrg cd "$darwin_curdir" 37939c9ff80cSmrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 37949c9ff80cSmrg done # $darwin_arches 37959c9ff80cSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 37969c9ff80cSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 37979c9ff80cSmrg darwin_file= 37989c9ff80cSmrg darwin_files= 37999c9ff80cSmrg for darwin_file in $darwin_filelist; do 38006fae4e5dSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 38019c9ff80cSmrg $LIPO -create -output "$darwin_file" $darwin_files 38029c9ff80cSmrg done # $darwin_filelist 38039c9ff80cSmrg $RM -rf unfat-$$ 38049c9ff80cSmrg cd "$darwin_orig_dir" 38051f0ac6a5Smrg else 38069c9ff80cSmrg cd $darwin_orig_dir 38079c9ff80cSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 38089c9ff80cSmrg fi # $darwin_arches 38099c9ff80cSmrg } # !$opt_dry_run 38109c9ff80cSmrg ;; 38119c9ff80cSmrg *) 38129c9ff80cSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 38139c9ff80cSmrg ;; 38149c9ff80cSmrg esac 38156fae4e5dSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 38169c9ff80cSmrg done 38171f0ac6a5Smrg 38189c9ff80cSmrg func_extract_archives_result="$my_oldobjs" 38199c9ff80cSmrg} 38201f0ac6a5Smrg 38211f0ac6a5Smrg 38226fae4e5dSmrg# func_emit_wrapper [arg=no] 38236fae4e5dSmrg# 38246fae4e5dSmrg# Emit a libtool wrapper script on stdout. 38256fae4e5dSmrg# Don't directly open a file because we may want to 38266fae4e5dSmrg# incorporate the script contents within a cygwin/mingw 38276fae4e5dSmrg# wrapper executable. Must ONLY be called from within 38286fae4e5dSmrg# func_mode_link because it depends on a number of variables 38296fae4e5dSmrg# set therein. 38309c9ff80cSmrg# 38316fae4e5dSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 38326fae4e5dSmrg# variable will take. If 'yes', then the emitted script 38336fae4e5dSmrg# will assume that the directory in which it is stored is 38346fae4e5dSmrg# the $objdir directory. This is a cygwin/mingw-specific 38356fae4e5dSmrg# behavior. 38366fae4e5dSmrgfunc_emit_wrapper () 38379c9ff80cSmrg{ 38386fae4e5dSmrg func_emit_wrapper_arg1=${1-no} 38391f0ac6a5Smrg 38409c9ff80cSmrg $ECHO "\ 38419c9ff80cSmrg#! $SHELL 38421f0ac6a5Smrg 38439c9ff80cSmrg# $output - temporary wrapper script for $objdir/$outputname 38449c9ff80cSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 38459c9ff80cSmrg# 38469c9ff80cSmrg# The $output program cannot be directly executed until all the libtool 38479c9ff80cSmrg# libraries that it depends on are installed. 38489c9ff80cSmrg# 38499c9ff80cSmrg# This wrapper script should never be moved out of the build directory. 38509c9ff80cSmrg# If it is, it will not operate correctly. 38511f0ac6a5Smrg 38529c9ff80cSmrg# Sed substitution that helps us do robust quoting. It backslashifies 38539c9ff80cSmrg# metacharacters that are still active within double-quoted strings. 38549c9ff80cSmrgsed_quote_subst='$sed_quote_subst' 38551f0ac6a5Smrg 38569c9ff80cSmrg# Be Bourne compatible 38579c9ff80cSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 38589c9ff80cSmrg emulate sh 38599c9ff80cSmrg NULLCMD=: 38609c9ff80cSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 38619c9ff80cSmrg # is contrary to our usage. Disable this feature. 38629c9ff80cSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 38639c9ff80cSmrg setopt NO_GLOB_SUBST 38649c9ff80cSmrgelse 38659c9ff80cSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 38669c9ff80cSmrgfi 38679c9ff80cSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 38689c9ff80cSmrgDUALCASE=1; export DUALCASE # for MKS sh 38691f0ac6a5Smrg 38709c9ff80cSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 38719c9ff80cSmrg# if CDPATH is set. 38729c9ff80cSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 38731f0ac6a5Smrg 38749c9ff80cSmrgrelink_command=\"$relink_command\" 38751f0ac6a5Smrg 38769c9ff80cSmrg# This environment variable determines our operation mode. 38779c9ff80cSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 38789c9ff80cSmrg # install mode needs the following variables: 38799c9ff80cSmrg generated_by_libtool_version='$macro_version' 38809c9ff80cSmrg notinst_deplibs='$notinst_deplibs' 38819c9ff80cSmrgelse 38829c9ff80cSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 38839c9ff80cSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 38846fae4e5dSmrg file=\"\$0\"" 38856fae4e5dSmrg 38866fae4e5dSmrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 38876fae4e5dSmrg $ECHO "\ 38886fae4e5dSmrg 38896fae4e5dSmrg# A function that is used when there is no print builtin or printf. 38906fae4e5dSmrgfunc_fallback_echo () 38916fae4e5dSmrg{ 38926fae4e5dSmrg eval 'cat <<_LTECHO_EOF 38936fae4e5dSmrg\$1 38946fae4e5dSmrg_LTECHO_EOF' 38956fae4e5dSmrg} 38966fae4e5dSmrg ECHO=\"$qECHO\" 38976fae4e5dSmrg fi 38986fae4e5dSmrg 38996fae4e5dSmrg# Very basic option parsing. These options are (a) specific to 39006fae4e5dSmrg# the libtool wrapper, (b) are identical between the wrapper 39016fae4e5dSmrg# /script/ and the wrapper /executable/ which is used only on 39026fae4e5dSmrg# windows platforms, and (c) all begin with the string "--lt-" 39036fae4e5dSmrg# (application programs are unlikely to have options which match 39046fae4e5dSmrg# this pattern). 39056fae4e5dSmrg# 39066fae4e5dSmrg# There are only two supported options: --lt-debug and 39076fae4e5dSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 39086fae4e5dSmrg# 39096fae4e5dSmrg# The first argument to this parsing function should be the 39106fae4e5dSmrg# script's $0 value, followed by "$@". 39116fae4e5dSmrglt_option_debug= 39126fae4e5dSmrgfunc_parse_lt_options () 39136fae4e5dSmrg{ 39146fae4e5dSmrg lt_script_arg0=\$0 39156fae4e5dSmrg shift 39166fae4e5dSmrg for lt_opt 39176fae4e5dSmrg do 39186fae4e5dSmrg case \"\$lt_opt\" in 39196fae4e5dSmrg --lt-debug) lt_option_debug=1 ;; 39206fae4e5dSmrg --lt-dump-script) 39216fae4e5dSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 39226fae4e5dSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 39236fae4e5dSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 39246fae4e5dSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 39256fae4e5dSmrg exit 0 39266fae4e5dSmrg ;; 39276fae4e5dSmrg --lt-*) 39286fae4e5dSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 39296fae4e5dSmrg exit 1 39306fae4e5dSmrg ;; 39316fae4e5dSmrg esac 39326fae4e5dSmrg done 39336fae4e5dSmrg 39346fae4e5dSmrg # Print the debug banner immediately: 39356fae4e5dSmrg if test -n \"\$lt_option_debug\"; then 39366fae4e5dSmrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 39376fae4e5dSmrg fi 39386fae4e5dSmrg} 39396fae4e5dSmrg 39406fae4e5dSmrg# Used when --lt-debug. Prints its arguments to stdout 39416fae4e5dSmrg# (redirection is the responsibility of the caller) 39426fae4e5dSmrgfunc_lt_dump_args () 39436fae4e5dSmrg{ 39446fae4e5dSmrg lt_dump_args_N=1; 39456fae4e5dSmrg for lt_arg 39466fae4e5dSmrg do 39476fae4e5dSmrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 39486fae4e5dSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 39496fae4e5dSmrg done 39506fae4e5dSmrg} 39516fae4e5dSmrg 39526fae4e5dSmrg# Core function for launching the target application 39536fae4e5dSmrgfunc_exec_program_core () 39546fae4e5dSmrg{ 39559c9ff80cSmrg" 39566fae4e5dSmrg case $host in 39576fae4e5dSmrg # Backslashes separate directories on plain windows 39586fae4e5dSmrg *-*-mingw | *-*-os2* | *-cegcc*) 39596fae4e5dSmrg $ECHO "\ 39606fae4e5dSmrg if test -n \"\$lt_option_debug\"; then 39616fae4e5dSmrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 39626fae4e5dSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 39636fae4e5dSmrg fi 39646fae4e5dSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 39656fae4e5dSmrg" 39666fae4e5dSmrg ;; 39676fae4e5dSmrg 39686fae4e5dSmrg *) 39696fae4e5dSmrg $ECHO "\ 39706fae4e5dSmrg if test -n \"\$lt_option_debug\"; then 39716fae4e5dSmrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 39726fae4e5dSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 39736fae4e5dSmrg fi 39746fae4e5dSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 39756fae4e5dSmrg" 39766fae4e5dSmrg ;; 39776fae4e5dSmrg esac 39786fae4e5dSmrg $ECHO "\ 39796fae4e5dSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 39806fae4e5dSmrg exit 1 39816fae4e5dSmrg} 39826fae4e5dSmrg 39836fae4e5dSmrg# A function to encapsulate launching the target application 39846fae4e5dSmrg# Strips options in the --lt-* namespace from \$@ and 39856fae4e5dSmrg# launches target application with the remaining arguments. 39866fae4e5dSmrgfunc_exec_program () 39876fae4e5dSmrg{ 398889c04b6cSmrg case \" \$* \" in 398989c04b6cSmrg *\\ --lt-*) 399089c04b6cSmrg for lt_wr_arg 399189c04b6cSmrg do 399289c04b6cSmrg case \$lt_wr_arg in 399389c04b6cSmrg --lt-*) ;; 399489c04b6cSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 399589c04b6cSmrg esac 399689c04b6cSmrg shift 399789c04b6cSmrg done ;; 399889c04b6cSmrg esac 39996fae4e5dSmrg func_exec_program_core \${1+\"\$@\"} 40006fae4e5dSmrg} 40016fae4e5dSmrg 40026fae4e5dSmrg # Parse options 40036fae4e5dSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 40041f0ac6a5Smrg 40059c9ff80cSmrg # Find the directory that this script lives in. 40066fae4e5dSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 40079c9ff80cSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 40081f0ac6a5Smrg 40099c9ff80cSmrg # Follow symbolic links until we get to the real thisdir. 40106fae4e5dSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 40119c9ff80cSmrg while test -n \"\$file\"; do 40126fae4e5dSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 40131f0ac6a5Smrg 40149c9ff80cSmrg # If there was a directory component, then change thisdir. 40159c9ff80cSmrg if test \"x\$destdir\" != \"x\$file\"; then 40169c9ff80cSmrg case \"\$destdir\" in 40179c9ff80cSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 40189c9ff80cSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 40191f0ac6a5Smrg esac 40209c9ff80cSmrg fi 40211f0ac6a5Smrg 40226fae4e5dSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 40236fae4e5dSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 40249c9ff80cSmrg done 40251f0ac6a5Smrg 40269c9ff80cSmrg # Usually 'no', except on cygwin/mingw when embedded into 40279c9ff80cSmrg # the cwrapper. 40286fae4e5dSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 40299c9ff80cSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 40309c9ff80cSmrg # special case for '.' 40319c9ff80cSmrg if test \"\$thisdir\" = \".\"; then 40329c9ff80cSmrg thisdir=\`pwd\` 40339c9ff80cSmrg fi 40349c9ff80cSmrg # remove .libs from thisdir 40359c9ff80cSmrg case \"\$thisdir\" in 40366fae4e5dSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 40379c9ff80cSmrg $objdir ) thisdir=. ;; 40389c9ff80cSmrg esac 40399c9ff80cSmrg fi 40409c9ff80cSmrg 40419c9ff80cSmrg # Try to get the absolute directory name. 40429c9ff80cSmrg absdir=\`cd \"\$thisdir\" && pwd\` 40439c9ff80cSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 40449c9ff80cSmrg" 40459c9ff80cSmrg 40469c9ff80cSmrg if test "$fast_install" = yes; then 40479c9ff80cSmrg $ECHO "\ 40489c9ff80cSmrg program=lt-'$outputname'$exeext 40499c9ff80cSmrg progdir=\"\$thisdir/$objdir\" 40509c9ff80cSmrg 40519c9ff80cSmrg if test ! -f \"\$progdir/\$program\" || 40529c9ff80cSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 40539c9ff80cSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 40549c9ff80cSmrg 40559c9ff80cSmrg file=\"\$\$-\$program\" 40569c9ff80cSmrg 40579c9ff80cSmrg if test ! -d \"\$progdir\"; then 40589c9ff80cSmrg $MKDIR \"\$progdir\" 40599c9ff80cSmrg else 40609c9ff80cSmrg $RM \"\$progdir/\$file\" 40619c9ff80cSmrg fi" 40629c9ff80cSmrg 40639c9ff80cSmrg $ECHO "\ 40649c9ff80cSmrg 40659c9ff80cSmrg # relink executable if necessary 40669c9ff80cSmrg if test -n \"\$relink_command\"; then 40679c9ff80cSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 40689c9ff80cSmrg else 40699c9ff80cSmrg $ECHO \"\$relink_command_output\" >&2 40709c9ff80cSmrg $RM \"\$progdir/\$file\" 40719c9ff80cSmrg exit 1 40721f0ac6a5Smrg fi 40739c9ff80cSmrg fi 40741f0ac6a5Smrg 40759c9ff80cSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 40769c9ff80cSmrg { $RM \"\$progdir/\$program\"; 40779c9ff80cSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 40789c9ff80cSmrg $RM \"\$progdir/\$file\" 40799c9ff80cSmrg fi" 40809c9ff80cSmrg else 40819c9ff80cSmrg $ECHO "\ 40829c9ff80cSmrg program='$outputname' 40839c9ff80cSmrg progdir=\"\$thisdir/$objdir\" 40849c9ff80cSmrg" 40851f0ac6a5Smrg fi 40861f0ac6a5Smrg 40879c9ff80cSmrg $ECHO "\ 40881f0ac6a5Smrg 40899c9ff80cSmrg if test -f \"\$progdir/\$program\"; then" 40901f0ac6a5Smrg 40916fae4e5dSmrg # fixup the dll searchpath if we need to. 40926fae4e5dSmrg # 40936fae4e5dSmrg # Fix the DLL searchpath if we need to. Do this before prepending 40946fae4e5dSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 40956fae4e5dSmrg # libraries must come first. 40966fae4e5dSmrg if test -n "$dllsearchpath"; then 40976fae4e5dSmrg $ECHO "\ 40986fae4e5dSmrg # Add the dll search path components to the executable PATH 40996fae4e5dSmrg PATH=$dllsearchpath:\$PATH 41006fae4e5dSmrg" 41016fae4e5dSmrg fi 41026fae4e5dSmrg 41039c9ff80cSmrg # Export our shlibpath_var if we have one. 41049c9ff80cSmrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 41059c9ff80cSmrg $ECHO "\ 41069c9ff80cSmrg # Add our own library path to $shlibpath_var 41079c9ff80cSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 41089c9ff80cSmrg 41099c9ff80cSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 41109c9ff80cSmrg # The second colon is a workaround for a bug in BeOS R4 sed 41116fae4e5dSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 41121f0ac6a5Smrg 41139c9ff80cSmrg export $shlibpath_var 41149c9ff80cSmrg" 41151f0ac6a5Smrg fi 41161f0ac6a5Smrg 41179c9ff80cSmrg $ECHO "\ 41189c9ff80cSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 41199c9ff80cSmrg # Run the actual program with our arguments. 41206fae4e5dSmrg func_exec_program \${1+\"\$@\"} 41219c9ff80cSmrg fi 41229c9ff80cSmrg else 41239c9ff80cSmrg # The program doesn't exist. 41249c9ff80cSmrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 41259c9ff80cSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 41266fae4e5dSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 41279c9ff80cSmrg exit 1 41289c9ff80cSmrg fi 41299c9ff80cSmrgfi\ 41309c9ff80cSmrg" 41319c9ff80cSmrg} 41321f0ac6a5Smrg 41331f0ac6a5Smrg 41349c9ff80cSmrg# func_emit_cwrapperexe_src 41359c9ff80cSmrg# emit the source code for a wrapper executable on stdout 41369c9ff80cSmrg# Must ONLY be called from within func_mode_link because 41379c9ff80cSmrg# it depends on a number of variable set therein. 41389c9ff80cSmrgfunc_emit_cwrapperexe_src () 41399c9ff80cSmrg{ 41409c9ff80cSmrg cat <<EOF 41411f0ac6a5Smrg 41429c9ff80cSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 41439c9ff80cSmrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 41441f0ac6a5Smrg 41459c9ff80cSmrg The $output program cannot be directly executed until all the libtool 41469c9ff80cSmrg libraries that it depends on are installed. 41471f0ac6a5Smrg 41489c9ff80cSmrg This wrapper executable should never be moved out of the build directory. 41499c9ff80cSmrg If it is, it will not operate correctly. 41509c9ff80cSmrg*/ 41519c9ff80cSmrgEOF 41529c9ff80cSmrg cat <<"EOF" 41536fae4e5dSmrg#ifdef _MSC_VER 41546fae4e5dSmrg# define _CRT_SECURE_NO_DEPRECATE 1 41556fae4e5dSmrg#endif 41569c9ff80cSmrg#include <stdio.h> 41579c9ff80cSmrg#include <stdlib.h> 41589c9ff80cSmrg#ifdef _MSC_VER 41599c9ff80cSmrg# include <direct.h> 41609c9ff80cSmrg# include <process.h> 41619c9ff80cSmrg# include <io.h> 41629c9ff80cSmrg#else 41639c9ff80cSmrg# include <unistd.h> 41649c9ff80cSmrg# include <stdint.h> 41659c9ff80cSmrg# ifdef __CYGWIN__ 41669c9ff80cSmrg# include <io.h> 41679c9ff80cSmrg# endif 41689c9ff80cSmrg#endif 41699c9ff80cSmrg#include <malloc.h> 41709c9ff80cSmrg#include <stdarg.h> 41719c9ff80cSmrg#include <assert.h> 41729c9ff80cSmrg#include <string.h> 41739c9ff80cSmrg#include <ctype.h> 41749c9ff80cSmrg#include <errno.h> 41759c9ff80cSmrg#include <fcntl.h> 41769c9ff80cSmrg#include <sys/stat.h> 41771f0ac6a5Smrg 41786fae4e5dSmrg/* declarations of non-ANSI functions */ 41796fae4e5dSmrg#if defined(__MINGW32__) 41806fae4e5dSmrg# ifdef __STRICT_ANSI__ 41816fae4e5dSmrgint _putenv (const char *); 41826fae4e5dSmrg# endif 41836fae4e5dSmrg#elif defined(__CYGWIN__) 41846fae4e5dSmrg# ifdef __STRICT_ANSI__ 41856fae4e5dSmrgchar *realpath (const char *, char *); 41866fae4e5dSmrgint putenv (char *); 41876fae4e5dSmrgint setenv (const char *, const char *, int); 41886fae4e5dSmrg# endif 41896fae4e5dSmrg/* #elif defined (other platforms) ... */ 41906fae4e5dSmrg#endif 41916fae4e5dSmrg 41926fae4e5dSmrg/* portability defines, excluding path handling macros */ 41936fae4e5dSmrg#if defined(_MSC_VER) 41946fae4e5dSmrg# define setmode _setmode 41956fae4e5dSmrg# define stat _stat 41966fae4e5dSmrg# define chmod _chmod 41976fae4e5dSmrg# define getcwd _getcwd 41986fae4e5dSmrg# define putenv _putenv 41996fae4e5dSmrg# define S_IXUSR _S_IEXEC 42006fae4e5dSmrg# ifndef _INTPTR_T_DEFINED 42016fae4e5dSmrg# define _INTPTR_T_DEFINED 42026fae4e5dSmrg# define intptr_t int 42036fae4e5dSmrg# endif 42046fae4e5dSmrg#elif defined(__MINGW32__) 42056fae4e5dSmrg# define setmode _setmode 42066fae4e5dSmrg# define stat _stat 42076fae4e5dSmrg# define chmod _chmod 42086fae4e5dSmrg# define getcwd _getcwd 42096fae4e5dSmrg# define putenv _putenv 42106fae4e5dSmrg#elif defined(__CYGWIN__) 42116fae4e5dSmrg# define HAVE_SETENV 42126fae4e5dSmrg# define FOPEN_WB "wb" 42136fae4e5dSmrg/* #elif defined (other platforms) ... */ 42146fae4e5dSmrg#endif 42156fae4e5dSmrg 42169c9ff80cSmrg#if defined(PATH_MAX) 42179c9ff80cSmrg# define LT_PATHMAX PATH_MAX 42189c9ff80cSmrg#elif defined(MAXPATHLEN) 42199c9ff80cSmrg# define LT_PATHMAX MAXPATHLEN 42209c9ff80cSmrg#else 42219c9ff80cSmrg# define LT_PATHMAX 1024 42229c9ff80cSmrg#endif 42231f0ac6a5Smrg 42249c9ff80cSmrg#ifndef S_IXOTH 42259c9ff80cSmrg# define S_IXOTH 0 42269c9ff80cSmrg#endif 42279c9ff80cSmrg#ifndef S_IXGRP 42289c9ff80cSmrg# define S_IXGRP 0 42299c9ff80cSmrg#endif 42301f0ac6a5Smrg 42316fae4e5dSmrg/* path handling portability macros */ 42329c9ff80cSmrg#ifndef DIR_SEPARATOR 42339c9ff80cSmrg# define DIR_SEPARATOR '/' 42349c9ff80cSmrg# define PATH_SEPARATOR ':' 42359c9ff80cSmrg#endif 42361f0ac6a5Smrg 42379c9ff80cSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 42389c9ff80cSmrg defined (__OS2__) 42399c9ff80cSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 42409c9ff80cSmrg# define FOPEN_WB "wb" 42419c9ff80cSmrg# ifndef DIR_SEPARATOR_2 42429c9ff80cSmrg# define DIR_SEPARATOR_2 '\\' 42439c9ff80cSmrg# endif 42449c9ff80cSmrg# ifndef PATH_SEPARATOR_2 42459c9ff80cSmrg# define PATH_SEPARATOR_2 ';' 42469c9ff80cSmrg# endif 42479c9ff80cSmrg#endif 42481f0ac6a5Smrg 42499c9ff80cSmrg#ifndef DIR_SEPARATOR_2 42509c9ff80cSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 42519c9ff80cSmrg#else /* DIR_SEPARATOR_2 */ 42529c9ff80cSmrg# define IS_DIR_SEPARATOR(ch) \ 42539c9ff80cSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 42549c9ff80cSmrg#endif /* DIR_SEPARATOR_2 */ 42551f0ac6a5Smrg 42569c9ff80cSmrg#ifndef PATH_SEPARATOR_2 42579c9ff80cSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 42589c9ff80cSmrg#else /* PATH_SEPARATOR_2 */ 42599c9ff80cSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 42609c9ff80cSmrg#endif /* PATH_SEPARATOR_2 */ 42611f0ac6a5Smrg 42629c9ff80cSmrg#ifndef FOPEN_WB 42639c9ff80cSmrg# define FOPEN_WB "w" 42649c9ff80cSmrg#endif 42659c9ff80cSmrg#ifndef _O_BINARY 42669c9ff80cSmrg# define _O_BINARY 0 42679c9ff80cSmrg#endif 42681f0ac6a5Smrg 42699c9ff80cSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 42709c9ff80cSmrg#define XFREE(stale) do { \ 42719c9ff80cSmrg if (stale) { free ((void *) stale); stale = 0; } \ 42729c9ff80cSmrg} while (0) 42731f0ac6a5Smrg 42746fae4e5dSmrg#if defined(LT_DEBUGWRAPPER) 42756fae4e5dSmrgstatic int lt_debug = 1; 42769c9ff80cSmrg#else 42776fae4e5dSmrgstatic int lt_debug = 0; 42789c9ff80cSmrg#endif 42791f0ac6a5Smrg 42806fae4e5dSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 42811f0ac6a5Smrg 42829c9ff80cSmrgvoid *xmalloc (size_t num); 42839c9ff80cSmrgchar *xstrdup (const char *string); 42849c9ff80cSmrgconst char *base_name (const char *name); 42859c9ff80cSmrgchar *find_executable (const char *wrapper); 42869c9ff80cSmrgchar *chase_symlinks (const char *pathspec); 42879c9ff80cSmrgint make_executable (const char *path); 42889c9ff80cSmrgint check_executable (const char *path); 42899c9ff80cSmrgchar *strendzap (char *str, const char *pat); 42906fae4e5dSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 42916fae4e5dSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 42926fae4e5dSmrgstatic const char *nonnull (const char *s); 42936fae4e5dSmrgstatic const char *nonempty (const char *s); 42949c9ff80cSmrgvoid lt_setenv (const char *name, const char *value); 42959c9ff80cSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 42969c9ff80cSmrgvoid lt_update_exe_path (const char *name, const char *value); 42979c9ff80cSmrgvoid lt_update_lib_path (const char *name, const char *value); 42986fae4e5dSmrgchar **prepare_spawn (char **argv); 42996fae4e5dSmrgvoid lt_dump_script (FILE *f); 43009c9ff80cSmrgEOF 43019c9ff80cSmrg 43029c9ff80cSmrg cat <<EOF 43036fae4e5dSmrgvolatile const char * MAGIC_EXE = "$magic_exe"; 43049c9ff80cSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 43059c9ff80cSmrgEOF 43061f0ac6a5Smrg 43079c9ff80cSmrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 43086fae4e5dSmrg func_to_host_path "$temp_rpath" 43099c9ff80cSmrg cat <<EOF 43106fae4e5dSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 43119c9ff80cSmrgEOF 43129c9ff80cSmrg else 43139c9ff80cSmrg cat <<"EOF" 43149c9ff80cSmrgconst char * LIB_PATH_VALUE = ""; 43159c9ff80cSmrgEOF 43161f0ac6a5Smrg fi 43171f0ac6a5Smrg 43189c9ff80cSmrg if test -n "$dllsearchpath"; then 43196fae4e5dSmrg func_to_host_path "$dllsearchpath:" 43209c9ff80cSmrg cat <<EOF 43219c9ff80cSmrgconst char * EXE_PATH_VARNAME = "PATH"; 43226fae4e5dSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 43231f0ac6a5SmrgEOF 43241f0ac6a5Smrg else 43259c9ff80cSmrg cat <<"EOF" 43269c9ff80cSmrgconst char * EXE_PATH_VARNAME = ""; 43279c9ff80cSmrgconst char * EXE_PATH_VALUE = ""; 43289c9ff80cSmrgEOF 43291f0ac6a5Smrg fi 43309c9ff80cSmrg 43319c9ff80cSmrg if test "$fast_install" = yes; then 43329c9ff80cSmrg cat <<EOF 43339c9ff80cSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 43349c9ff80cSmrgEOF 43351f0ac6a5Smrg else 43369c9ff80cSmrg cat <<EOF 43379c9ff80cSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 43389c9ff80cSmrgEOF 43391f0ac6a5Smrg fi 43401f0ac6a5Smrg 43411f0ac6a5Smrg 43429c9ff80cSmrg cat <<"EOF" 43431f0ac6a5Smrg 43449c9ff80cSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 43451f0ac6a5Smrg 43469c9ff80cSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 43479c9ff80cSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 43486fae4e5dSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 43491f0ac6a5Smrg 43509c9ff80cSmrgint 43519c9ff80cSmrgmain (int argc, char *argv[]) 43529c9ff80cSmrg{ 43539c9ff80cSmrg char **newargz; 43549c9ff80cSmrg int newargc; 43559c9ff80cSmrg char *tmp_pathspec; 43569c9ff80cSmrg char *actual_cwrapper_path; 43579c9ff80cSmrg char *actual_cwrapper_name; 43589c9ff80cSmrg char *target_name; 43599c9ff80cSmrg char *lt_argv_zero; 43609c9ff80cSmrg intptr_t rval = 127; 43611f0ac6a5Smrg 43629c9ff80cSmrg int i; 43631f0ac6a5Smrg 43649c9ff80cSmrg program_name = (char *) xstrdup (base_name (argv[0])); 43656fae4e5dSmrg newargz = XMALLOC (char *, argc + 1); 43661f0ac6a5Smrg 43676fae4e5dSmrg /* very simple arg parsing; don't want to rely on getopt 43686fae4e5dSmrg * also, copy all non cwrapper options to newargz, except 43696fae4e5dSmrg * argz[0], which is handled differently 43706fae4e5dSmrg */ 43716fae4e5dSmrg newargc=0; 43729c9ff80cSmrg for (i = 1; i < argc; i++) 43739c9ff80cSmrg { 43749c9ff80cSmrg if (strcmp (argv[i], dumpscript_opt) == 0) 43759c9ff80cSmrg { 43769c9ff80cSmrgEOF 43779c9ff80cSmrg case "$host" in 43789c9ff80cSmrg *mingw* | *cygwin* ) 43799c9ff80cSmrg # make stdout use "unix" line endings 43809c9ff80cSmrg echo " setmode(1,_O_BINARY);" 43819c9ff80cSmrg ;; 43829c9ff80cSmrg esac 43831f0ac6a5Smrg 43849c9ff80cSmrg cat <<"EOF" 43856fae4e5dSmrg lt_dump_script (stdout); 43869c9ff80cSmrg return 0; 43879c9ff80cSmrg } 43886fae4e5dSmrg if (strcmp (argv[i], debug_opt) == 0) 43896fae4e5dSmrg { 43906fae4e5dSmrg lt_debug = 1; 43916fae4e5dSmrg continue; 43926fae4e5dSmrg } 43936fae4e5dSmrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 43946fae4e5dSmrg { 43956fae4e5dSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 43966fae4e5dSmrg namespace, but it is not one of the ones we know about and 43976fae4e5dSmrg have already dealt with, above (inluding dump-script), then 43986fae4e5dSmrg report an error. Otherwise, targets might begin to believe 43996fae4e5dSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 44006fae4e5dSmrg namespace. The first time any user complains about this, we'll 44016fae4e5dSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 44026fae4e5dSmrg or a configure.ac-settable value. 44036fae4e5dSmrg */ 44046fae4e5dSmrg lt_fatal (__FILE__, __LINE__, 44056fae4e5dSmrg "unrecognized %s option: '%s'", 44066fae4e5dSmrg ltwrapper_option_prefix, argv[i]); 44076fae4e5dSmrg } 44086fae4e5dSmrg /* otherwise ... */ 44096fae4e5dSmrg newargz[++newargc] = xstrdup (argv[i]); 44109c9ff80cSmrg } 44116fae4e5dSmrg newargz[++newargc] = NULL; 44126fae4e5dSmrg 44136fae4e5dSmrgEOF 44146fae4e5dSmrg cat <<EOF 44156fae4e5dSmrg /* The GNU banner must be the first non-error debug message */ 44166fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 44176fae4e5dSmrgEOF 44186fae4e5dSmrg cat <<"EOF" 44196fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 44206fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 44211f0ac6a5Smrg 44229c9ff80cSmrg tmp_pathspec = find_executable (argv[0]); 44239c9ff80cSmrg if (tmp_pathspec == NULL) 44246fae4e5dSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 44256fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, 44266fae4e5dSmrg "(main) found exe (before symlink chase) at: %s\n", 44276fae4e5dSmrg tmp_pathspec); 44289c9ff80cSmrg 44299c9ff80cSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 44306fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, 44316fae4e5dSmrg "(main) found exe (after symlink chase) at: %s\n", 44326fae4e5dSmrg actual_cwrapper_path); 44339c9ff80cSmrg XFREE (tmp_pathspec); 44349c9ff80cSmrg 44356fae4e5dSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 44369c9ff80cSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 44379c9ff80cSmrg 44389c9ff80cSmrg /* wrapper name transforms */ 44399c9ff80cSmrg strendzap (actual_cwrapper_name, ".exe"); 44409c9ff80cSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 44419c9ff80cSmrg XFREE (actual_cwrapper_name); 44429c9ff80cSmrg actual_cwrapper_name = tmp_pathspec; 44439c9ff80cSmrg tmp_pathspec = 0; 44449c9ff80cSmrg 44459c9ff80cSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 44469c9ff80cSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 44479c9ff80cSmrg strendzap (target_name, ".exe"); 44489c9ff80cSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 44499c9ff80cSmrg XFREE (target_name); 44509c9ff80cSmrg target_name = tmp_pathspec; 44519c9ff80cSmrg tmp_pathspec = 0; 44529c9ff80cSmrg 44536fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, 44546fae4e5dSmrg "(main) libtool target name: %s\n", 44556fae4e5dSmrg target_name); 44569c9ff80cSmrgEOF 44571f0ac6a5Smrg 44589c9ff80cSmrg cat <<EOF 44599c9ff80cSmrg newargz[0] = 44609c9ff80cSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 44619c9ff80cSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 44629c9ff80cSmrg strcpy (newargz[0], actual_cwrapper_path); 44639c9ff80cSmrg strcat (newargz[0], "$objdir"); 44649c9ff80cSmrg strcat (newargz[0], "/"); 44659c9ff80cSmrgEOF 44661f0ac6a5Smrg 44679c9ff80cSmrg cat <<"EOF" 44689c9ff80cSmrg /* stop here, and copy so we don't have to do this twice */ 44699c9ff80cSmrg tmp_pathspec = xstrdup (newargz[0]); 44701f0ac6a5Smrg 44719c9ff80cSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 44729c9ff80cSmrg strcat (newargz[0], actual_cwrapper_name); 44731f0ac6a5Smrg 44749c9ff80cSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 44759c9ff80cSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 44769c9ff80cSmrg XFREE (tmp_pathspec); 44779c9ff80cSmrg tmp_pathspec = NULL; 44789c9ff80cSmrgEOF 44791f0ac6a5Smrg 44809c9ff80cSmrg case $host_os in 44819c9ff80cSmrg mingw*) 44829c9ff80cSmrg cat <<"EOF" 44839c9ff80cSmrg { 44849c9ff80cSmrg char* p; 44859c9ff80cSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 44869c9ff80cSmrg { 44879c9ff80cSmrg *p = '/'; 44889c9ff80cSmrg } 44899c9ff80cSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 44909c9ff80cSmrg { 44919c9ff80cSmrg *p = '/'; 44929c9ff80cSmrg } 44939c9ff80cSmrg } 44949c9ff80cSmrgEOF 44959c9ff80cSmrg ;; 44969c9ff80cSmrg esac 44971f0ac6a5Smrg 44989c9ff80cSmrg cat <<"EOF" 44999c9ff80cSmrg XFREE (target_name); 45009c9ff80cSmrg XFREE (actual_cwrapper_path); 45019c9ff80cSmrg XFREE (actual_cwrapper_name); 45021f0ac6a5Smrg 45039c9ff80cSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 45049c9ff80cSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 45056fae4e5dSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 45066fae4e5dSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 45076fae4e5dSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 45086fae4e5dSmrg libraries must come first. */ 45099c9ff80cSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 45106fae4e5dSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 45111f0ac6a5Smrg 45126fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 45136fae4e5dSmrg nonnull (lt_argv_zero)); 45149c9ff80cSmrg for (i = 0; i < newargc; i++) 45159c9ff80cSmrg { 45166fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 45176fae4e5dSmrg i, nonnull (newargz[i])); 45189c9ff80cSmrg } 45191f0ac6a5Smrg 45209c9ff80cSmrgEOF 45211f0ac6a5Smrg 45229c9ff80cSmrg case $host_os in 45239c9ff80cSmrg mingw*) 45249c9ff80cSmrg cat <<"EOF" 45259c9ff80cSmrg /* execv doesn't actually work on mingw as expected on unix */ 45266fae4e5dSmrg newargz = prepare_spawn (newargz); 45279c9ff80cSmrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 45289c9ff80cSmrg if (rval == -1) 45299c9ff80cSmrg { 45309c9ff80cSmrg /* failed to start process */ 45316fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, 45326fae4e5dSmrg "(main) failed to launch target \"%s\": %s\n", 45336fae4e5dSmrg lt_argv_zero, nonnull (strerror (errno))); 45349c9ff80cSmrg return 127; 45359c9ff80cSmrg } 45369c9ff80cSmrg return rval; 45379c9ff80cSmrgEOF 45389c9ff80cSmrg ;; 45399c9ff80cSmrg *) 45409c9ff80cSmrg cat <<"EOF" 45419c9ff80cSmrg execv (lt_argv_zero, newargz); 45429c9ff80cSmrg return rval; /* =127, but avoids unused variable warning */ 45439c9ff80cSmrgEOF 45449c9ff80cSmrg ;; 45459c9ff80cSmrg esac 45461f0ac6a5Smrg 45479c9ff80cSmrg cat <<"EOF" 45489c9ff80cSmrg} 45491f0ac6a5Smrg 45509c9ff80cSmrgvoid * 45519c9ff80cSmrgxmalloc (size_t num) 45529c9ff80cSmrg{ 45539c9ff80cSmrg void *p = (void *) malloc (num); 45549c9ff80cSmrg if (!p) 45556fae4e5dSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 45561f0ac6a5Smrg 45579c9ff80cSmrg return p; 45589c9ff80cSmrg} 45591f0ac6a5Smrg 45609c9ff80cSmrgchar * 45619c9ff80cSmrgxstrdup (const char *string) 45629c9ff80cSmrg{ 45639c9ff80cSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 45649c9ff80cSmrg string) : NULL; 45659c9ff80cSmrg} 45661f0ac6a5Smrg 45679c9ff80cSmrgconst char * 45689c9ff80cSmrgbase_name (const char *name) 45699c9ff80cSmrg{ 45709c9ff80cSmrg const char *base; 45711f0ac6a5Smrg 45729c9ff80cSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 45739c9ff80cSmrg /* Skip over the disk name in MSDOS pathnames. */ 45749c9ff80cSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 45759c9ff80cSmrg name += 2; 45769c9ff80cSmrg#endif 45771f0ac6a5Smrg 45789c9ff80cSmrg for (base = name; *name; name++) 45799c9ff80cSmrg if (IS_DIR_SEPARATOR (*name)) 45809c9ff80cSmrg base = name + 1; 45819c9ff80cSmrg return base; 45829c9ff80cSmrg} 45831f0ac6a5Smrg 45849c9ff80cSmrgint 45859c9ff80cSmrgcheck_executable (const char *path) 45869c9ff80cSmrg{ 45879c9ff80cSmrg struct stat st; 45881f0ac6a5Smrg 45896fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 45906fae4e5dSmrg nonempty (path)); 45919c9ff80cSmrg if ((!path) || (!*path)) 45929c9ff80cSmrg return 0; 45931f0ac6a5Smrg 45949c9ff80cSmrg if ((stat (path, &st) >= 0) 45959c9ff80cSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 45969c9ff80cSmrg return 1; 45979c9ff80cSmrg else 45989c9ff80cSmrg return 0; 45999c9ff80cSmrg} 46001f0ac6a5Smrg 46019c9ff80cSmrgint 46029c9ff80cSmrgmake_executable (const char *path) 46039c9ff80cSmrg{ 46049c9ff80cSmrg int rval = 0; 46059c9ff80cSmrg struct stat st; 46061f0ac6a5Smrg 46076fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 46086fae4e5dSmrg nonempty (path)); 46099c9ff80cSmrg if ((!path) || (!*path)) 46109c9ff80cSmrg return 0; 46111f0ac6a5Smrg 46129c9ff80cSmrg if (stat (path, &st) >= 0) 46139c9ff80cSmrg { 46149c9ff80cSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 46159c9ff80cSmrg } 46169c9ff80cSmrg return rval; 46179c9ff80cSmrg} 46181f0ac6a5Smrg 46199c9ff80cSmrg/* Searches for the full path of the wrapper. Returns 46209c9ff80cSmrg newly allocated full path name if found, NULL otherwise 46219c9ff80cSmrg Does not chase symlinks, even on platforms that support them. 46229c9ff80cSmrg*/ 46239c9ff80cSmrgchar * 46249c9ff80cSmrgfind_executable (const char *wrapper) 46259c9ff80cSmrg{ 46269c9ff80cSmrg int has_slash = 0; 46279c9ff80cSmrg const char *p; 46289c9ff80cSmrg const char *p_next; 46299c9ff80cSmrg /* static buffer for getcwd */ 46309c9ff80cSmrg char tmp[LT_PATHMAX + 1]; 46319c9ff80cSmrg int tmp_len; 46329c9ff80cSmrg char *concat_name; 46331f0ac6a5Smrg 46346fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 46356fae4e5dSmrg nonempty (wrapper)); 46361f0ac6a5Smrg 46379c9ff80cSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 46389c9ff80cSmrg return NULL; 46391f0ac6a5Smrg 46409c9ff80cSmrg /* Absolute path? */ 46419c9ff80cSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 46429c9ff80cSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 46439c9ff80cSmrg { 46449c9ff80cSmrg concat_name = xstrdup (wrapper); 46459c9ff80cSmrg if (check_executable (concat_name)) 46469c9ff80cSmrg return concat_name; 46479c9ff80cSmrg XFREE (concat_name); 46489c9ff80cSmrg } 46499c9ff80cSmrg else 46509c9ff80cSmrg { 46519c9ff80cSmrg#endif 46529c9ff80cSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 46539c9ff80cSmrg { 46549c9ff80cSmrg concat_name = xstrdup (wrapper); 46559c9ff80cSmrg if (check_executable (concat_name)) 46569c9ff80cSmrg return concat_name; 46579c9ff80cSmrg XFREE (concat_name); 46589c9ff80cSmrg } 46599c9ff80cSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 46609c9ff80cSmrg } 46619c9ff80cSmrg#endif 46621f0ac6a5Smrg 46639c9ff80cSmrg for (p = wrapper; *p; p++) 46649c9ff80cSmrg if (*p == '/') 46659c9ff80cSmrg { 46669c9ff80cSmrg has_slash = 1; 46679c9ff80cSmrg break; 46689c9ff80cSmrg } 46699c9ff80cSmrg if (!has_slash) 46709c9ff80cSmrg { 46719c9ff80cSmrg /* no slashes; search PATH */ 46729c9ff80cSmrg const char *path = getenv ("PATH"); 46739c9ff80cSmrg if (path != NULL) 46749c9ff80cSmrg { 46759c9ff80cSmrg for (p = path; *p; p = p_next) 46769c9ff80cSmrg { 46779c9ff80cSmrg const char *q; 46789c9ff80cSmrg size_t p_len; 46799c9ff80cSmrg for (q = p; *q; q++) 46809c9ff80cSmrg if (IS_PATH_SEPARATOR (*q)) 46819c9ff80cSmrg break; 46829c9ff80cSmrg p_len = q - p; 46839c9ff80cSmrg p_next = (*q == '\0' ? q : q + 1); 46849c9ff80cSmrg if (p_len == 0) 46859c9ff80cSmrg { 46869c9ff80cSmrg /* empty path: current directory */ 46879c9ff80cSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 46886fae4e5dSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 46896fae4e5dSmrg nonnull (strerror (errno))); 46909c9ff80cSmrg tmp_len = strlen (tmp); 46919c9ff80cSmrg concat_name = 46929c9ff80cSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 46939c9ff80cSmrg memcpy (concat_name, tmp, tmp_len); 46949c9ff80cSmrg concat_name[tmp_len] = '/'; 46959c9ff80cSmrg strcpy (concat_name + tmp_len + 1, wrapper); 46969c9ff80cSmrg } 46979c9ff80cSmrg else 46989c9ff80cSmrg { 46999c9ff80cSmrg concat_name = 47009c9ff80cSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 47019c9ff80cSmrg memcpy (concat_name, p, p_len); 47029c9ff80cSmrg concat_name[p_len] = '/'; 47039c9ff80cSmrg strcpy (concat_name + p_len + 1, wrapper); 47049c9ff80cSmrg } 47059c9ff80cSmrg if (check_executable (concat_name)) 47069c9ff80cSmrg return concat_name; 47079c9ff80cSmrg XFREE (concat_name); 47089c9ff80cSmrg } 47099c9ff80cSmrg } 47109c9ff80cSmrg /* not found in PATH; assume curdir */ 47119c9ff80cSmrg } 47129c9ff80cSmrg /* Relative path | not found in path: prepend cwd */ 47139c9ff80cSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 47146fae4e5dSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 47156fae4e5dSmrg nonnull (strerror (errno))); 47169c9ff80cSmrg tmp_len = strlen (tmp); 47179c9ff80cSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 47189c9ff80cSmrg memcpy (concat_name, tmp, tmp_len); 47199c9ff80cSmrg concat_name[tmp_len] = '/'; 47209c9ff80cSmrg strcpy (concat_name + tmp_len + 1, wrapper); 47211f0ac6a5Smrg 47229c9ff80cSmrg if (check_executable (concat_name)) 47239c9ff80cSmrg return concat_name; 47249c9ff80cSmrg XFREE (concat_name); 47259c9ff80cSmrg return NULL; 47269c9ff80cSmrg} 47271f0ac6a5Smrg 47289c9ff80cSmrgchar * 47299c9ff80cSmrgchase_symlinks (const char *pathspec) 47309c9ff80cSmrg{ 47319c9ff80cSmrg#ifndef S_ISLNK 47329c9ff80cSmrg return xstrdup (pathspec); 47339c9ff80cSmrg#else 47349c9ff80cSmrg char buf[LT_PATHMAX]; 47359c9ff80cSmrg struct stat s; 47369c9ff80cSmrg char *tmp_pathspec = xstrdup (pathspec); 47379c9ff80cSmrg char *p; 47389c9ff80cSmrg int has_symlinks = 0; 47399c9ff80cSmrg while (strlen (tmp_pathspec) && !has_symlinks) 47409c9ff80cSmrg { 47416fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, 47426fae4e5dSmrg "checking path component for symlinks: %s\n", 47436fae4e5dSmrg tmp_pathspec); 47449c9ff80cSmrg if (lstat (tmp_pathspec, &s) == 0) 47459c9ff80cSmrg { 47469c9ff80cSmrg if (S_ISLNK (s.st_mode) != 0) 47479c9ff80cSmrg { 47489c9ff80cSmrg has_symlinks = 1; 47499c9ff80cSmrg break; 47509c9ff80cSmrg } 47511f0ac6a5Smrg 47529c9ff80cSmrg /* search backwards for last DIR_SEPARATOR */ 47539c9ff80cSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 47549c9ff80cSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 47559c9ff80cSmrg p--; 47569c9ff80cSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 47579c9ff80cSmrg { 47589c9ff80cSmrg /* no more DIR_SEPARATORS left */ 47599c9ff80cSmrg break; 47609c9ff80cSmrg } 47619c9ff80cSmrg *p = '\0'; 47629c9ff80cSmrg } 47639c9ff80cSmrg else 47649c9ff80cSmrg { 47656fae4e5dSmrg lt_fatal (__FILE__, __LINE__, 47666fae4e5dSmrg "error accessing file \"%s\": %s", 47676fae4e5dSmrg tmp_pathspec, nonnull (strerror (errno))); 47689c9ff80cSmrg } 47699c9ff80cSmrg } 47709c9ff80cSmrg XFREE (tmp_pathspec); 47711f0ac6a5Smrg 47729c9ff80cSmrg if (!has_symlinks) 47739c9ff80cSmrg { 47749c9ff80cSmrg return xstrdup (pathspec); 47759c9ff80cSmrg } 47761f0ac6a5Smrg 47779c9ff80cSmrg tmp_pathspec = realpath (pathspec, buf); 47789c9ff80cSmrg if (tmp_pathspec == 0) 47799c9ff80cSmrg { 47806fae4e5dSmrg lt_fatal (__FILE__, __LINE__, 47816fae4e5dSmrg "could not follow symlinks for %s", pathspec); 47829c9ff80cSmrg } 47839c9ff80cSmrg return xstrdup (tmp_pathspec); 47849c9ff80cSmrg#endif 47859c9ff80cSmrg} 47861f0ac6a5Smrg 47879c9ff80cSmrgchar * 47889c9ff80cSmrgstrendzap (char *str, const char *pat) 47899c9ff80cSmrg{ 47909c9ff80cSmrg size_t len, patlen; 47911f0ac6a5Smrg 47929c9ff80cSmrg assert (str != NULL); 47939c9ff80cSmrg assert (pat != NULL); 47941f0ac6a5Smrg 47959c9ff80cSmrg len = strlen (str); 47969c9ff80cSmrg patlen = strlen (pat); 47971f0ac6a5Smrg 47989c9ff80cSmrg if (patlen <= len) 47999c9ff80cSmrg { 48009c9ff80cSmrg str += len - patlen; 48019c9ff80cSmrg if (strcmp (str, pat) == 0) 48029c9ff80cSmrg *str = '\0'; 48039c9ff80cSmrg } 48049c9ff80cSmrg return str; 48059c9ff80cSmrg} 48061f0ac6a5Smrg 48076fae4e5dSmrgvoid 48086fae4e5dSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 48096fae4e5dSmrg{ 48106fae4e5dSmrg va_list args; 48116fae4e5dSmrg if (lt_debug) 48126fae4e5dSmrg { 48136fae4e5dSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 48146fae4e5dSmrg va_start (args, fmt); 48156fae4e5dSmrg (void) vfprintf (stderr, fmt, args); 48166fae4e5dSmrg va_end (args); 48176fae4e5dSmrg } 48186fae4e5dSmrg} 48196fae4e5dSmrg 48209c9ff80cSmrgstatic void 48216fae4e5dSmrglt_error_core (int exit_status, const char *file, 48226fae4e5dSmrg int line, const char *mode, 48239c9ff80cSmrg const char *message, va_list ap) 48249c9ff80cSmrg{ 48256fae4e5dSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 48269c9ff80cSmrg vfprintf (stderr, message, ap); 48279c9ff80cSmrg fprintf (stderr, ".\n"); 48281f0ac6a5Smrg 48299c9ff80cSmrg if (exit_status >= 0) 48309c9ff80cSmrg exit (exit_status); 48319c9ff80cSmrg} 48321f0ac6a5Smrg 48339c9ff80cSmrgvoid 48346fae4e5dSmrglt_fatal (const char *file, int line, const char *message, ...) 48359c9ff80cSmrg{ 48369c9ff80cSmrg va_list ap; 48379c9ff80cSmrg va_start (ap, message); 48386fae4e5dSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 48399c9ff80cSmrg va_end (ap); 48409c9ff80cSmrg} 48411f0ac6a5Smrg 48426fae4e5dSmrgstatic const char * 48436fae4e5dSmrgnonnull (const char *s) 48446fae4e5dSmrg{ 48456fae4e5dSmrg return s ? s : "(null)"; 48466fae4e5dSmrg} 48476fae4e5dSmrg 48486fae4e5dSmrgstatic const char * 48496fae4e5dSmrgnonempty (const char *s) 48506fae4e5dSmrg{ 48516fae4e5dSmrg return (s && !*s) ? "(empty)" : nonnull (s); 48526fae4e5dSmrg} 48536fae4e5dSmrg 48549c9ff80cSmrgvoid 48559c9ff80cSmrglt_setenv (const char *name, const char *value) 48569c9ff80cSmrg{ 48576fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, 48586fae4e5dSmrg "(lt_setenv) setting '%s' to '%s'\n", 48596fae4e5dSmrg nonnull (name), nonnull (value)); 48609c9ff80cSmrg { 48619c9ff80cSmrg#ifdef HAVE_SETENV 48629c9ff80cSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 48639c9ff80cSmrg char *str = xstrdup (value); 48649c9ff80cSmrg setenv (name, str, 1); 48659c9ff80cSmrg#else 48669c9ff80cSmrg int len = strlen (name) + 1 + strlen (value) + 1; 48679c9ff80cSmrg char *str = XMALLOC (char, len); 48689c9ff80cSmrg sprintf (str, "%s=%s", name, value); 48699c9ff80cSmrg if (putenv (str) != EXIT_SUCCESS) 48709c9ff80cSmrg { 48719c9ff80cSmrg XFREE (str); 48729c9ff80cSmrg } 48739c9ff80cSmrg#endif 48749c9ff80cSmrg } 48759c9ff80cSmrg} 48761f0ac6a5Smrg 48779c9ff80cSmrgchar * 48789c9ff80cSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 48799c9ff80cSmrg{ 48809c9ff80cSmrg char *new_value; 48819c9ff80cSmrg if (orig_value && *orig_value) 48829c9ff80cSmrg { 48839c9ff80cSmrg int orig_value_len = strlen (orig_value); 48849c9ff80cSmrg int add_len = strlen (add); 48859c9ff80cSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 48869c9ff80cSmrg if (to_end) 48879c9ff80cSmrg { 48889c9ff80cSmrg strcpy (new_value, orig_value); 48899c9ff80cSmrg strcpy (new_value + orig_value_len, add); 48909c9ff80cSmrg } 48919c9ff80cSmrg else 48929c9ff80cSmrg { 48939c9ff80cSmrg strcpy (new_value, add); 48949c9ff80cSmrg strcpy (new_value + add_len, orig_value); 48959c9ff80cSmrg } 48969c9ff80cSmrg } 48979c9ff80cSmrg else 48989c9ff80cSmrg { 48999c9ff80cSmrg new_value = xstrdup (add); 49009c9ff80cSmrg } 49019c9ff80cSmrg return new_value; 49029c9ff80cSmrg} 49031f0ac6a5Smrg 49049c9ff80cSmrgvoid 49059c9ff80cSmrglt_update_exe_path (const char *name, const char *value) 49069c9ff80cSmrg{ 49076fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, 49086fae4e5dSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 49096fae4e5dSmrg nonnull (name), nonnull (value)); 49101f0ac6a5Smrg 49119c9ff80cSmrg if (name && *name && value && *value) 49129c9ff80cSmrg { 49139c9ff80cSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 49149c9ff80cSmrg /* some systems can't cope with a ':'-terminated path #' */ 49159c9ff80cSmrg int len = strlen (new_value); 49169c9ff80cSmrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 49179c9ff80cSmrg { 49189c9ff80cSmrg new_value[len-1] = '\0'; 49199c9ff80cSmrg } 49209c9ff80cSmrg lt_setenv (name, new_value); 49219c9ff80cSmrg XFREE (new_value); 49229c9ff80cSmrg } 49239c9ff80cSmrg} 49241f0ac6a5Smrg 49259c9ff80cSmrgvoid 49269c9ff80cSmrglt_update_lib_path (const char *name, const char *value) 49279c9ff80cSmrg{ 49286fae4e5dSmrg lt_debugprintf (__FILE__, __LINE__, 49296fae4e5dSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 49306fae4e5dSmrg nonnull (name), nonnull (value)); 49311f0ac6a5Smrg 49329c9ff80cSmrg if (name && *name && value && *value) 49339c9ff80cSmrg { 49349c9ff80cSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 49359c9ff80cSmrg lt_setenv (name, new_value); 49369c9ff80cSmrg XFREE (new_value); 49379c9ff80cSmrg } 49389c9ff80cSmrg} 49391f0ac6a5Smrg 49406fae4e5dSmrgEOF 49416fae4e5dSmrg case $host_os in 49426fae4e5dSmrg mingw*) 49436fae4e5dSmrg cat <<"EOF" 49446fae4e5dSmrg 49456fae4e5dSmrg/* Prepares an argument vector before calling spawn(). 49466fae4e5dSmrg Note that spawn() does not by itself call the command interpreter 49476fae4e5dSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 49486fae4e5dSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 49496fae4e5dSmrg GetVersionEx(&v); 49506fae4e5dSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 49516fae4e5dSmrg }) ? "cmd.exe" : "command.com"). 49526fae4e5dSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 49536fae4e5dSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 49546fae4e5dSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 49556fae4e5dSmrg special way: 49566fae4e5dSmrg - Space and tab are interpreted as delimiters. They are not treated as 49576fae4e5dSmrg delimiters if they are surrounded by double quotes: "...". 49586fae4e5dSmrg - Unescaped double quotes are removed from the input. Their only effect is 49596fae4e5dSmrg that within double quotes, space and tab are treated like normal 49606fae4e5dSmrg characters. 49616fae4e5dSmrg - Backslashes not followed by double quotes are not special. 49626fae4e5dSmrg - But 2*n+1 backslashes followed by a double quote become 49636fae4e5dSmrg n backslashes followed by a double quote (n >= 0): 49646fae4e5dSmrg \" -> " 49656fae4e5dSmrg \\\" -> \" 49666fae4e5dSmrg \\\\\" -> \\" 49676fae4e5dSmrg */ 49686fae4e5dSmrg#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" 49696fae4e5dSmrg#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" 49706fae4e5dSmrgchar ** 49716fae4e5dSmrgprepare_spawn (char **argv) 49726fae4e5dSmrg{ 49736fae4e5dSmrg size_t argc; 49746fae4e5dSmrg char **new_argv; 49756fae4e5dSmrg size_t i; 49766fae4e5dSmrg 49776fae4e5dSmrg /* Count number of arguments. */ 49786fae4e5dSmrg for (argc = 0; argv[argc] != NULL; argc++) 49796fae4e5dSmrg ; 49806fae4e5dSmrg 49816fae4e5dSmrg /* Allocate new argument vector. */ 49826fae4e5dSmrg new_argv = XMALLOC (char *, argc + 1); 49836fae4e5dSmrg 49846fae4e5dSmrg /* Put quoted arguments into the new argument vector. */ 49856fae4e5dSmrg for (i = 0; i < argc; i++) 49866fae4e5dSmrg { 49876fae4e5dSmrg const char *string = argv[i]; 49886fae4e5dSmrg 49896fae4e5dSmrg if (string[0] == '\0') 49906fae4e5dSmrg new_argv[i] = xstrdup ("\"\""); 49916fae4e5dSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 49926fae4e5dSmrg { 49936fae4e5dSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 49946fae4e5dSmrg size_t length; 49956fae4e5dSmrg unsigned int backslashes; 49966fae4e5dSmrg const char *s; 49976fae4e5dSmrg char *quoted_string; 49986fae4e5dSmrg char *p; 49996fae4e5dSmrg 50006fae4e5dSmrg length = 0; 50016fae4e5dSmrg backslashes = 0; 50026fae4e5dSmrg if (quote_around) 50036fae4e5dSmrg length++; 50046fae4e5dSmrg for (s = string; *s != '\0'; s++) 50056fae4e5dSmrg { 50066fae4e5dSmrg char c = *s; 50076fae4e5dSmrg if (c == '"') 50086fae4e5dSmrg length += backslashes + 1; 50096fae4e5dSmrg length++; 50106fae4e5dSmrg if (c == '\\') 50116fae4e5dSmrg backslashes++; 50126fae4e5dSmrg else 50136fae4e5dSmrg backslashes = 0; 50146fae4e5dSmrg } 50156fae4e5dSmrg if (quote_around) 50166fae4e5dSmrg length += backslashes + 1; 50176fae4e5dSmrg 50186fae4e5dSmrg quoted_string = XMALLOC (char, length + 1); 50196fae4e5dSmrg 50206fae4e5dSmrg p = quoted_string; 50216fae4e5dSmrg backslashes = 0; 50226fae4e5dSmrg if (quote_around) 50236fae4e5dSmrg *p++ = '"'; 50246fae4e5dSmrg for (s = string; *s != '\0'; s++) 50256fae4e5dSmrg { 50266fae4e5dSmrg char c = *s; 50276fae4e5dSmrg if (c == '"') 50286fae4e5dSmrg { 50296fae4e5dSmrg unsigned int j; 50306fae4e5dSmrg for (j = backslashes + 1; j > 0; j--) 50316fae4e5dSmrg *p++ = '\\'; 50326fae4e5dSmrg } 50336fae4e5dSmrg *p++ = c; 50346fae4e5dSmrg if (c == '\\') 50356fae4e5dSmrg backslashes++; 50366fae4e5dSmrg else 50376fae4e5dSmrg backslashes = 0; 50386fae4e5dSmrg } 50396fae4e5dSmrg if (quote_around) 50406fae4e5dSmrg { 50416fae4e5dSmrg unsigned int j; 50426fae4e5dSmrg for (j = backslashes; j > 0; j--) 50436fae4e5dSmrg *p++ = '\\'; 50446fae4e5dSmrg *p++ = '"'; 50456fae4e5dSmrg } 50466fae4e5dSmrg *p = '\0'; 50476fae4e5dSmrg 50486fae4e5dSmrg new_argv[i] = quoted_string; 50496fae4e5dSmrg } 50506fae4e5dSmrg else 50516fae4e5dSmrg new_argv[i] = (char *) string; 50526fae4e5dSmrg } 50536fae4e5dSmrg new_argv[argc] = NULL; 50546fae4e5dSmrg 50556fae4e5dSmrg return new_argv; 50566fae4e5dSmrg} 50576fae4e5dSmrgEOF 50586fae4e5dSmrg ;; 50596fae4e5dSmrg esac 50606fae4e5dSmrg 50616fae4e5dSmrg cat <<"EOF" 50626fae4e5dSmrgvoid lt_dump_script (FILE* f) 50636fae4e5dSmrg{ 50646fae4e5dSmrgEOF 50656fae4e5dSmrg func_emit_wrapper yes | 506689c04b6cSmrg $SED -n -e ' 506789c04b6cSmrgs/^\(.\{79\}\)\(..*\)/\1\ 506889c04b6cSmrg\2/ 506989c04b6cSmrgh 507089c04b6cSmrgs/\([\\"]\)/\\\1/g 507189c04b6cSmrgs/$/\\n/ 507289c04b6cSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 507389c04b6cSmrgg 507489c04b6cSmrgD' 50756fae4e5dSmrg cat <<"EOF" 50766fae4e5dSmrg} 50779c9ff80cSmrgEOF 50789c9ff80cSmrg} 50799c9ff80cSmrg# end: func_emit_cwrapperexe_src 50801f0ac6a5Smrg 50816fae4e5dSmrg# func_win32_import_lib_p ARG 50826fae4e5dSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 50836fae4e5dSmrgfunc_win32_import_lib_p () 50846fae4e5dSmrg{ 50856fae4e5dSmrg $opt_debug 50866fae4e5dSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 50876fae4e5dSmrg *import*) : ;; 50886fae4e5dSmrg *) false ;; 50896fae4e5dSmrg esac 50906fae4e5dSmrg} 50916fae4e5dSmrg 50929c9ff80cSmrg# func_mode_link arg... 50939c9ff80cSmrgfunc_mode_link () 50949c9ff80cSmrg{ 50959c9ff80cSmrg $opt_debug 50969c9ff80cSmrg case $host in 50979c9ff80cSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 50989c9ff80cSmrg # It is impossible to link a dll without this setting, and 50999c9ff80cSmrg # we shouldn't force the makefile maintainer to figure out 51009c9ff80cSmrg # which system we are compiling for in order to pass an extra 51019c9ff80cSmrg # flag for every libtool invocation. 51029c9ff80cSmrg # allow_undefined=no 51031f0ac6a5Smrg 51049c9ff80cSmrg # FIXME: Unfortunately, there are problems with the above when trying 51059c9ff80cSmrg # to make a dll which has undefined symbols, in which case not 51069c9ff80cSmrg # even a static library is built. For now, we need to specify 51079c9ff80cSmrg # -no-undefined on the libtool link line when we can be certain 51089c9ff80cSmrg # that all symbols are satisfied, otherwise we get a static library. 51099c9ff80cSmrg allow_undefined=yes 51109c9ff80cSmrg ;; 51119c9ff80cSmrg *) 51129c9ff80cSmrg allow_undefined=yes 51139c9ff80cSmrg ;; 51149c9ff80cSmrg esac 51159c9ff80cSmrg libtool_args=$nonopt 51169c9ff80cSmrg base_compile="$nonopt $@" 51179c9ff80cSmrg compile_command=$nonopt 51189c9ff80cSmrg finalize_command=$nonopt 51191f0ac6a5Smrg 51209c9ff80cSmrg compile_rpath= 51219c9ff80cSmrg finalize_rpath= 51229c9ff80cSmrg compile_shlibpath= 51239c9ff80cSmrg finalize_shlibpath= 51249c9ff80cSmrg convenience= 51259c9ff80cSmrg old_convenience= 51269c9ff80cSmrg deplibs= 51279c9ff80cSmrg old_deplibs= 51289c9ff80cSmrg compiler_flags= 51299c9ff80cSmrg linker_flags= 51309c9ff80cSmrg dllsearchpath= 51319c9ff80cSmrg lib_search_path=`pwd` 51329c9ff80cSmrg inst_prefix_dir= 51339c9ff80cSmrg new_inherited_linker_flags= 51341f0ac6a5Smrg 51359c9ff80cSmrg avoid_version=no 51366fae4e5dSmrg bindir= 51379c9ff80cSmrg dlfiles= 51389c9ff80cSmrg dlprefiles= 51399c9ff80cSmrg dlself=no 51409c9ff80cSmrg export_dynamic=no 51419c9ff80cSmrg export_symbols= 51429c9ff80cSmrg export_symbols_regex= 51439c9ff80cSmrg generated= 51449c9ff80cSmrg libobjs= 51459c9ff80cSmrg ltlibs= 51469c9ff80cSmrg module=no 51479c9ff80cSmrg no_install=no 51489c9ff80cSmrg objs= 51499c9ff80cSmrg non_pic_objects= 51509c9ff80cSmrg precious_files_regex= 51519c9ff80cSmrg prefer_static_libs=no 51529c9ff80cSmrg preload=no 51539c9ff80cSmrg prev= 51549c9ff80cSmrg prevarg= 51559c9ff80cSmrg release= 51569c9ff80cSmrg rpath= 51579c9ff80cSmrg xrpath= 51589c9ff80cSmrg perm_rpath= 51599c9ff80cSmrg temp_rpath= 51609c9ff80cSmrg thread_safe=no 51619c9ff80cSmrg vinfo= 51629c9ff80cSmrg vinfo_number=no 51639c9ff80cSmrg weak_libs= 51649c9ff80cSmrg single_module="${wl}-single_module" 51659c9ff80cSmrg func_infer_tag $base_compile 51669c9ff80cSmrg 51679c9ff80cSmrg # We need to know -static, to get the right output filenames. 51689c9ff80cSmrg for arg 51699c9ff80cSmrg do 51709c9ff80cSmrg case $arg in 51719c9ff80cSmrg -shared) 51729c9ff80cSmrg test "$build_libtool_libs" != yes && \ 51739c9ff80cSmrg func_fatal_configuration "can not build a shared library" 51749c9ff80cSmrg build_old_libs=no 51759c9ff80cSmrg break 51769c9ff80cSmrg ;; 51779c9ff80cSmrg -all-static | -static | -static-libtool-libs) 51789c9ff80cSmrg case $arg in 51799c9ff80cSmrg -all-static) 51809c9ff80cSmrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 51819c9ff80cSmrg func_warning "complete static linking is impossible in this configuration" 51829c9ff80cSmrg fi 51839c9ff80cSmrg if test -n "$link_static_flag"; then 51849c9ff80cSmrg dlopen_self=$dlopen_self_static 51859c9ff80cSmrg fi 51869c9ff80cSmrg prefer_static_libs=yes 51879c9ff80cSmrg ;; 51889c9ff80cSmrg -static) 51899c9ff80cSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 51909c9ff80cSmrg dlopen_self=$dlopen_self_static 51919c9ff80cSmrg fi 51929c9ff80cSmrg prefer_static_libs=built 51939c9ff80cSmrg ;; 51949c9ff80cSmrg -static-libtool-libs) 51959c9ff80cSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 51969c9ff80cSmrg dlopen_self=$dlopen_self_static 51971f0ac6a5Smrg fi 51989c9ff80cSmrg prefer_static_libs=yes 51999c9ff80cSmrg ;; 52009c9ff80cSmrg esac 52019c9ff80cSmrg build_libtool_libs=no 52029c9ff80cSmrg build_old_libs=yes 52039c9ff80cSmrg break 52049c9ff80cSmrg ;; 52059c9ff80cSmrg esac 52069c9ff80cSmrg done 52071f0ac6a5Smrg 52089c9ff80cSmrg # See if our shared archives depend on static archives. 52099c9ff80cSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 52101f0ac6a5Smrg 52119c9ff80cSmrg # Go through the arguments, transforming them on the way. 52129c9ff80cSmrg while test "$#" -gt 0; do 52139c9ff80cSmrg arg="$1" 52149c9ff80cSmrg shift 52159c9ff80cSmrg func_quote_for_eval "$arg" 52169c9ff80cSmrg qarg=$func_quote_for_eval_unquoted_result 52179c9ff80cSmrg func_append libtool_args " $func_quote_for_eval_result" 52181f0ac6a5Smrg 52199c9ff80cSmrg # If the previous option needs an argument, assign it. 52209c9ff80cSmrg if test -n "$prev"; then 52219c9ff80cSmrg case $prev in 52229c9ff80cSmrg output) 52239c9ff80cSmrg func_append compile_command " @OUTPUT@" 52249c9ff80cSmrg func_append finalize_command " @OUTPUT@" 52259c9ff80cSmrg ;; 52269c9ff80cSmrg esac 52271f0ac6a5Smrg 52289c9ff80cSmrg case $prev in 52296fae4e5dSmrg bindir) 52306fae4e5dSmrg bindir="$arg" 52316fae4e5dSmrg prev= 52326fae4e5dSmrg continue 52336fae4e5dSmrg ;; 52349c9ff80cSmrg dlfiles|dlprefiles) 52359c9ff80cSmrg if test "$preload" = no; then 52369c9ff80cSmrg # Add the symbol object into the linking commands. 52379c9ff80cSmrg func_append compile_command " @SYMFILE@" 52389c9ff80cSmrg func_append finalize_command " @SYMFILE@" 52399c9ff80cSmrg preload=yes 52409c9ff80cSmrg fi 52419c9ff80cSmrg case $arg in 52429c9ff80cSmrg *.la | *.lo) ;; # We handle these cases below. 52439c9ff80cSmrg force) 52449c9ff80cSmrg if test "$dlself" = no; then 52459c9ff80cSmrg dlself=needless 52469c9ff80cSmrg export_dynamic=yes 52479c9ff80cSmrg fi 52489c9ff80cSmrg prev= 52499c9ff80cSmrg continue 52509c9ff80cSmrg ;; 52519c9ff80cSmrg self) 52529c9ff80cSmrg if test "$prev" = dlprefiles; then 52539c9ff80cSmrg dlself=yes 52549c9ff80cSmrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 52559c9ff80cSmrg dlself=yes 52561f0ac6a5Smrg else 52579c9ff80cSmrg dlself=needless 52589c9ff80cSmrg export_dynamic=yes 52591f0ac6a5Smrg fi 52609c9ff80cSmrg prev= 52619c9ff80cSmrg continue 52629c9ff80cSmrg ;; 52639c9ff80cSmrg *) 52649c9ff80cSmrg if test "$prev" = dlfiles; then 52656fae4e5dSmrg func_append dlfiles " $arg" 52661f0ac6a5Smrg else 52676fae4e5dSmrg func_append dlprefiles " $arg" 52681f0ac6a5Smrg fi 52699c9ff80cSmrg prev= 52709c9ff80cSmrg continue 52719c9ff80cSmrg ;; 52729c9ff80cSmrg esac 52739c9ff80cSmrg ;; 52749c9ff80cSmrg expsyms) 52759c9ff80cSmrg export_symbols="$arg" 52769c9ff80cSmrg test -f "$arg" \ 52779c9ff80cSmrg || func_fatal_error "symbol file \`$arg' does not exist" 52789c9ff80cSmrg prev= 52799c9ff80cSmrg continue 52809c9ff80cSmrg ;; 52819c9ff80cSmrg expsyms_regex) 52829c9ff80cSmrg export_symbols_regex="$arg" 52839c9ff80cSmrg prev= 52849c9ff80cSmrg continue 52859c9ff80cSmrg ;; 52869c9ff80cSmrg framework) 52871f0ac6a5Smrg case $host in 52889c9ff80cSmrg *-*-darwin*) 52899c9ff80cSmrg case "$deplibs " in 52909c9ff80cSmrg *" $qarg.ltframework "*) ;; 52916fae4e5dSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 52929c9ff80cSmrg ;; 52939c9ff80cSmrg esac 52949c9ff80cSmrg ;; 52951f0ac6a5Smrg esac 52969c9ff80cSmrg prev= 52979c9ff80cSmrg continue 52981f0ac6a5Smrg ;; 52999c9ff80cSmrg inst_prefix) 53009c9ff80cSmrg inst_prefix_dir="$arg" 53019c9ff80cSmrg prev= 53029c9ff80cSmrg continue 53031f0ac6a5Smrg ;; 53049c9ff80cSmrg objectlist) 53059c9ff80cSmrg if test -f "$arg"; then 53069c9ff80cSmrg save_arg=$arg 53079c9ff80cSmrg moreargs= 53089c9ff80cSmrg for fil in `cat "$save_arg"` 53099c9ff80cSmrg do 53106fae4e5dSmrg# func_append moreargs " $fil" 53119c9ff80cSmrg arg=$fil 53129c9ff80cSmrg # A libtool-controlled object. 53131f0ac6a5Smrg 53149c9ff80cSmrg # Check to see that this really is a libtool object. 53159c9ff80cSmrg if func_lalib_unsafe_p "$arg"; then 53169c9ff80cSmrg pic_object= 53179c9ff80cSmrg non_pic_object= 53181f0ac6a5Smrg 53199c9ff80cSmrg # Read the .lo file 53209c9ff80cSmrg func_source "$arg" 53211f0ac6a5Smrg 53229c9ff80cSmrg if test -z "$pic_object" || 53239c9ff80cSmrg test -z "$non_pic_object" || 53249c9ff80cSmrg test "$pic_object" = none && 53259c9ff80cSmrg test "$non_pic_object" = none; then 53269c9ff80cSmrg func_fatal_error "cannot find name of object for \`$arg'" 53279c9ff80cSmrg fi 53281f0ac6a5Smrg 53299c9ff80cSmrg # Extract subdirectory from the argument. 53309c9ff80cSmrg func_dirname "$arg" "/" "" 53319c9ff80cSmrg xdir="$func_dirname_result" 53321f0ac6a5Smrg 53339c9ff80cSmrg if test "$pic_object" != none; then 53349c9ff80cSmrg # Prepend the subdirectory the object is found in. 53359c9ff80cSmrg pic_object="$xdir$pic_object" 53361f0ac6a5Smrg 53379c9ff80cSmrg if test "$prev" = dlfiles; then 53389c9ff80cSmrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 53396fae4e5dSmrg func_append dlfiles " $pic_object" 53409c9ff80cSmrg prev= 53419c9ff80cSmrg continue 53429c9ff80cSmrg else 53439c9ff80cSmrg # If libtool objects are unsupported, then we need to preload. 53449c9ff80cSmrg prev=dlprefiles 53459c9ff80cSmrg fi 53469c9ff80cSmrg fi 53471f0ac6a5Smrg 53489c9ff80cSmrg # CHECK ME: I think I busted this. -Ossama 53499c9ff80cSmrg if test "$prev" = dlprefiles; then 53509c9ff80cSmrg # Preload the old-style object. 53516fae4e5dSmrg func_append dlprefiles " $pic_object" 53529c9ff80cSmrg prev= 53539c9ff80cSmrg fi 53541f0ac6a5Smrg 53559c9ff80cSmrg # A PIC object. 53569c9ff80cSmrg func_append libobjs " $pic_object" 53579c9ff80cSmrg arg="$pic_object" 53589c9ff80cSmrg fi 53591f0ac6a5Smrg 53609c9ff80cSmrg # Non-PIC object. 53619c9ff80cSmrg if test "$non_pic_object" != none; then 53629c9ff80cSmrg # Prepend the subdirectory the object is found in. 53639c9ff80cSmrg non_pic_object="$xdir$non_pic_object" 53641f0ac6a5Smrg 53659c9ff80cSmrg # A standard non-PIC object 53669c9ff80cSmrg func_append non_pic_objects " $non_pic_object" 53679c9ff80cSmrg if test -z "$pic_object" || test "$pic_object" = none ; then 53689c9ff80cSmrg arg="$non_pic_object" 53699c9ff80cSmrg fi 53709c9ff80cSmrg else 53719c9ff80cSmrg # If the PIC object exists, use it instead. 53729c9ff80cSmrg # $xdir was prepended to $pic_object above. 53739c9ff80cSmrg non_pic_object="$pic_object" 53749c9ff80cSmrg func_append non_pic_objects " $non_pic_object" 53759c9ff80cSmrg fi 53769c9ff80cSmrg else 53779c9ff80cSmrg # Only an error if not doing a dry-run. 53789c9ff80cSmrg if $opt_dry_run; then 53799c9ff80cSmrg # Extract subdirectory from the argument. 53809c9ff80cSmrg func_dirname "$arg" "/" "" 53819c9ff80cSmrg xdir="$func_dirname_result" 53829c9ff80cSmrg 53839c9ff80cSmrg func_lo2o "$arg" 53849c9ff80cSmrg pic_object=$xdir$objdir/$func_lo2o_result 53859c9ff80cSmrg non_pic_object=$xdir$func_lo2o_result 53869c9ff80cSmrg func_append libobjs " $pic_object" 53879c9ff80cSmrg func_append non_pic_objects " $non_pic_object" 53889c9ff80cSmrg else 53899c9ff80cSmrg func_fatal_error "\`$arg' is not a valid libtool object" 53909c9ff80cSmrg fi 53919c9ff80cSmrg fi 53929c9ff80cSmrg done 53931f0ac6a5Smrg else 53949c9ff80cSmrg func_fatal_error "link input file \`$arg' does not exist" 53951f0ac6a5Smrg fi 53969c9ff80cSmrg arg=$save_arg 53979c9ff80cSmrg prev= 53989c9ff80cSmrg continue 53999c9ff80cSmrg ;; 54009c9ff80cSmrg precious_regex) 54019c9ff80cSmrg precious_files_regex="$arg" 54029c9ff80cSmrg prev= 54039c9ff80cSmrg continue 54049c9ff80cSmrg ;; 54059c9ff80cSmrg release) 54069c9ff80cSmrg release="-$arg" 54079c9ff80cSmrg prev= 54089c9ff80cSmrg continue 54099c9ff80cSmrg ;; 54109c9ff80cSmrg rpath | xrpath) 54119c9ff80cSmrg # We need an absolute path. 54129c9ff80cSmrg case $arg in 54139c9ff80cSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 54149c9ff80cSmrg *) 54159c9ff80cSmrg func_fatal_error "only absolute run-paths are allowed" 54169c9ff80cSmrg ;; 54179c9ff80cSmrg esac 54189c9ff80cSmrg if test "$prev" = rpath; then 54199c9ff80cSmrg case "$rpath " in 54209c9ff80cSmrg *" $arg "*) ;; 54216fae4e5dSmrg *) func_append rpath " $arg" ;; 54229c9ff80cSmrg esac 54231f0ac6a5Smrg else 54249c9ff80cSmrg case "$xrpath " in 54259c9ff80cSmrg *" $arg "*) ;; 54266fae4e5dSmrg *) func_append xrpath " $arg" ;; 54279c9ff80cSmrg esac 54281f0ac6a5Smrg fi 54299c9ff80cSmrg prev= 54309c9ff80cSmrg continue 54319c9ff80cSmrg ;; 54329c9ff80cSmrg shrext) 54339c9ff80cSmrg shrext_cmds="$arg" 54349c9ff80cSmrg prev= 54359c9ff80cSmrg continue 54369c9ff80cSmrg ;; 54379c9ff80cSmrg weak) 54386fae4e5dSmrg func_append weak_libs " $arg" 54399c9ff80cSmrg prev= 54409c9ff80cSmrg continue 54419c9ff80cSmrg ;; 54429c9ff80cSmrg xcclinker) 54436fae4e5dSmrg func_append linker_flags " $qarg" 54446fae4e5dSmrg func_append compiler_flags " $qarg" 54459c9ff80cSmrg prev= 54469c9ff80cSmrg func_append compile_command " $qarg" 54479c9ff80cSmrg func_append finalize_command " $qarg" 54489c9ff80cSmrg continue 54499c9ff80cSmrg ;; 54509c9ff80cSmrg xcompiler) 54516fae4e5dSmrg func_append compiler_flags " $qarg" 54529c9ff80cSmrg prev= 54539c9ff80cSmrg func_append compile_command " $qarg" 54549c9ff80cSmrg func_append finalize_command " $qarg" 54559c9ff80cSmrg continue 54569c9ff80cSmrg ;; 54579c9ff80cSmrg xlinker) 54586fae4e5dSmrg func_append linker_flags " $qarg" 54596fae4e5dSmrg func_append compiler_flags " $wl$qarg" 54609c9ff80cSmrg prev= 54619c9ff80cSmrg func_append compile_command " $wl$qarg" 54629c9ff80cSmrg func_append finalize_command " $wl$qarg" 54639c9ff80cSmrg continue 54649c9ff80cSmrg ;; 54659c9ff80cSmrg *) 54669c9ff80cSmrg eval "$prev=\"\$arg\"" 54679c9ff80cSmrg prev= 54689c9ff80cSmrg continue 54699c9ff80cSmrg ;; 54701f0ac6a5Smrg esac 54719c9ff80cSmrg fi # test -n "$prev" 54721f0ac6a5Smrg 54739c9ff80cSmrg prevarg="$arg" 54741f0ac6a5Smrg 54759c9ff80cSmrg case $arg in 54769c9ff80cSmrg -all-static) 54779c9ff80cSmrg if test -n "$link_static_flag"; then 54789c9ff80cSmrg # See comment for -static flag below, for more details. 54799c9ff80cSmrg func_append compile_command " $link_static_flag" 54809c9ff80cSmrg func_append finalize_command " $link_static_flag" 54819c9ff80cSmrg fi 54829c9ff80cSmrg continue 54839c9ff80cSmrg ;; 54841f0ac6a5Smrg 54859c9ff80cSmrg -allow-undefined) 54869c9ff80cSmrg # FIXME: remove this flag sometime in the future. 54879c9ff80cSmrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 54889c9ff80cSmrg ;; 54891f0ac6a5Smrg 54909c9ff80cSmrg -avoid-version) 54919c9ff80cSmrg avoid_version=yes 54929c9ff80cSmrg continue 54939c9ff80cSmrg ;; 54941f0ac6a5Smrg 54956fae4e5dSmrg -bindir) 54966fae4e5dSmrg prev=bindir 54976fae4e5dSmrg continue 54986fae4e5dSmrg ;; 54996fae4e5dSmrg 55009c9ff80cSmrg -dlopen) 55019c9ff80cSmrg prev=dlfiles 55029c9ff80cSmrg continue 55039c9ff80cSmrg ;; 55041f0ac6a5Smrg 55059c9ff80cSmrg -dlpreopen) 55069c9ff80cSmrg prev=dlprefiles 55079c9ff80cSmrg continue 55089c9ff80cSmrg ;; 55091f0ac6a5Smrg 55109c9ff80cSmrg -export-dynamic) 55119c9ff80cSmrg export_dynamic=yes 55129c9ff80cSmrg continue 55139c9ff80cSmrg ;; 55141f0ac6a5Smrg 55159c9ff80cSmrg -export-symbols | -export-symbols-regex) 55169c9ff80cSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 55179c9ff80cSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 55189c9ff80cSmrg fi 55199c9ff80cSmrg if test "X$arg" = "X-export-symbols"; then 55209c9ff80cSmrg prev=expsyms 55219c9ff80cSmrg else 55229c9ff80cSmrg prev=expsyms_regex 55239c9ff80cSmrg fi 55249c9ff80cSmrg continue 55259c9ff80cSmrg ;; 55261f0ac6a5Smrg 55279c9ff80cSmrg -framework) 55289c9ff80cSmrg prev=framework 55299c9ff80cSmrg continue 55309c9ff80cSmrg ;; 55311f0ac6a5Smrg 55329c9ff80cSmrg -inst-prefix-dir) 55339c9ff80cSmrg prev=inst_prefix 55349c9ff80cSmrg continue 55359c9ff80cSmrg ;; 55361f0ac6a5Smrg 55379c9ff80cSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 55389c9ff80cSmrg # so, if we see these flags be careful not to treat them like -L 55399c9ff80cSmrg -L[A-Z][A-Z]*:*) 55409c9ff80cSmrg case $with_gcc/$host in 55419c9ff80cSmrg no/*-*-irix* | /*-*-irix*) 55429c9ff80cSmrg func_append compile_command " $arg" 55439c9ff80cSmrg func_append finalize_command " $arg" 55449c9ff80cSmrg ;; 55459c9ff80cSmrg esac 55469c9ff80cSmrg continue 55479c9ff80cSmrg ;; 55481f0ac6a5Smrg 55499c9ff80cSmrg -L*) 55506fae4e5dSmrg func_stripname "-L" '' "$arg" 55516fae4e5dSmrg if test -z "$func_stripname_result"; then 55529c9ff80cSmrg if test "$#" -gt 0; then 55539c9ff80cSmrg func_fatal_error "require no space between \`-L' and \`$1'" 55549c9ff80cSmrg else 55559c9ff80cSmrg func_fatal_error "need path for \`-L' option" 55569c9ff80cSmrg fi 55579c9ff80cSmrg fi 55586fae4e5dSmrg func_resolve_sysroot "$func_stripname_result" 55596fae4e5dSmrg dir=$func_resolve_sysroot_result 55609c9ff80cSmrg # We need an absolute path. 55619c9ff80cSmrg case $dir in 55629c9ff80cSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 55639c9ff80cSmrg *) 55649c9ff80cSmrg absdir=`cd "$dir" && pwd` 55659c9ff80cSmrg test -z "$absdir" && \ 55669c9ff80cSmrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 55679c9ff80cSmrg dir="$absdir" 55689c9ff80cSmrg ;; 55699c9ff80cSmrg esac 55709c9ff80cSmrg case "$deplibs " in 55716fae4e5dSmrg *" -L$dir "* | *" $arg "*) 55726fae4e5dSmrg # Will only happen for absolute or sysroot arguments 55736fae4e5dSmrg ;; 55749c9ff80cSmrg *) 55756fae4e5dSmrg # Preserve sysroot, but never include relative directories 55766fae4e5dSmrg case $dir in 55776fae4e5dSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 55786fae4e5dSmrg *) func_append deplibs " -L$dir" ;; 55796fae4e5dSmrg esac 55806fae4e5dSmrg func_append lib_search_path " $dir" 55819c9ff80cSmrg ;; 55829c9ff80cSmrg esac 55839c9ff80cSmrg case $host in 55849c9ff80cSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 55856fae4e5dSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 55869c9ff80cSmrg case :$dllsearchpath: in 55879c9ff80cSmrg *":$dir:"*) ;; 55889c9ff80cSmrg ::) dllsearchpath=$dir;; 55896fae4e5dSmrg *) func_append dllsearchpath ":$dir";; 55909c9ff80cSmrg esac 55919c9ff80cSmrg case :$dllsearchpath: in 55929c9ff80cSmrg *":$testbindir:"*) ;; 55939c9ff80cSmrg ::) dllsearchpath=$testbindir;; 55946fae4e5dSmrg *) func_append dllsearchpath ":$testbindir";; 55959c9ff80cSmrg esac 55969c9ff80cSmrg ;; 55979c9ff80cSmrg esac 55989c9ff80cSmrg continue 55999c9ff80cSmrg ;; 56001f0ac6a5Smrg 56019c9ff80cSmrg -l*) 56029c9ff80cSmrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 56039c9ff80cSmrg case $host in 56046fae4e5dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 56059c9ff80cSmrg # These systems don't actually have a C or math library (as such) 56069c9ff80cSmrg continue 56079c9ff80cSmrg ;; 56089c9ff80cSmrg *-*-os2*) 56099c9ff80cSmrg # These systems don't actually have a C library (as such) 56109c9ff80cSmrg test "X$arg" = "X-lc" && continue 56119c9ff80cSmrg ;; 56129c9ff80cSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 56139c9ff80cSmrg # Do not include libc due to us having libc/libc_r. 56149c9ff80cSmrg test "X$arg" = "X-lc" && continue 56159c9ff80cSmrg ;; 56169c9ff80cSmrg *-*-rhapsody* | *-*-darwin1.[012]) 56179c9ff80cSmrg # Rhapsody C and math libraries are in the System framework 56186fae4e5dSmrg func_append deplibs " System.ltframework" 56199c9ff80cSmrg continue 56209c9ff80cSmrg ;; 56219c9ff80cSmrg *-*-sco3.2v5* | *-*-sco5v6*) 56229c9ff80cSmrg # Causes problems with __ctype 56239c9ff80cSmrg test "X$arg" = "X-lc" && continue 56249c9ff80cSmrg ;; 56259c9ff80cSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 56269c9ff80cSmrg # Compiler inserts libc in the correct place for threads to work 56279c9ff80cSmrg test "X$arg" = "X-lc" && continue 56289c9ff80cSmrg ;; 56299c9ff80cSmrg esac 56309c9ff80cSmrg elif test "X$arg" = "X-lc_r"; then 56319c9ff80cSmrg case $host in 56329c9ff80cSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 56339c9ff80cSmrg # Do not include libc_r directly, use -pthread flag. 56349c9ff80cSmrg continue 56359c9ff80cSmrg ;; 56369c9ff80cSmrg esac 56379c9ff80cSmrg fi 56386fae4e5dSmrg func_append deplibs " $arg" 56399c9ff80cSmrg continue 56409c9ff80cSmrg ;; 56411f0ac6a5Smrg 56429c9ff80cSmrg -module) 56439c9ff80cSmrg module=yes 56449c9ff80cSmrg continue 56459c9ff80cSmrg ;; 56461f0ac6a5Smrg 56479c9ff80cSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 56489c9ff80cSmrg # classes, name mangling, and exception handling. 56499c9ff80cSmrg # Darwin uses the -arch flag to determine output architecture. 56506fae4e5dSmrg -model|-arch|-isysroot|--sysroot) 56516fae4e5dSmrg func_append compiler_flags " $arg" 56529c9ff80cSmrg func_append compile_command " $arg" 56539c9ff80cSmrg func_append finalize_command " $arg" 56549c9ff80cSmrg prev=xcompiler 56559c9ff80cSmrg continue 56569c9ff80cSmrg ;; 56571f0ac6a5Smrg 565889c04b6cSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 565989c04b6cSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 56606fae4e5dSmrg func_append compiler_flags " $arg" 56619c9ff80cSmrg func_append compile_command " $arg" 56629c9ff80cSmrg func_append finalize_command " $arg" 56639c9ff80cSmrg case "$new_inherited_linker_flags " in 56649c9ff80cSmrg *" $arg "*) ;; 56656fae4e5dSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 56669c9ff80cSmrg esac 56679c9ff80cSmrg continue 56689c9ff80cSmrg ;; 56691f0ac6a5Smrg 56709c9ff80cSmrg -multi_module) 56719c9ff80cSmrg single_module="${wl}-multi_module" 56729c9ff80cSmrg continue 56739c9ff80cSmrg ;; 56741f0ac6a5Smrg 56759c9ff80cSmrg -no-fast-install) 56769c9ff80cSmrg fast_install=no 56779c9ff80cSmrg continue 56789c9ff80cSmrg ;; 56791f0ac6a5Smrg 56809c9ff80cSmrg -no-install) 56819c9ff80cSmrg case $host in 56829c9ff80cSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 56839c9ff80cSmrg # The PATH hackery in wrapper scripts is required on Windows 56849c9ff80cSmrg # and Darwin in order for the loader to find any dlls it needs. 56859c9ff80cSmrg func_warning "\`-no-install' is ignored for $host" 56869c9ff80cSmrg func_warning "assuming \`-no-fast-install' instead" 56879c9ff80cSmrg fast_install=no 56889c9ff80cSmrg ;; 56899c9ff80cSmrg *) no_install=yes ;; 56909c9ff80cSmrg esac 56919c9ff80cSmrg continue 56929c9ff80cSmrg ;; 56931f0ac6a5Smrg 56949c9ff80cSmrg -no-undefined) 56959c9ff80cSmrg allow_undefined=no 56969c9ff80cSmrg continue 56979c9ff80cSmrg ;; 56981f0ac6a5Smrg 56999c9ff80cSmrg -objectlist) 57009c9ff80cSmrg prev=objectlist 57019c9ff80cSmrg continue 57029c9ff80cSmrg ;; 57031f0ac6a5Smrg 57049c9ff80cSmrg -o) prev=output ;; 57051f0ac6a5Smrg 57069c9ff80cSmrg -precious-files-regex) 57079c9ff80cSmrg prev=precious_regex 57089c9ff80cSmrg continue 57099c9ff80cSmrg ;; 57101f0ac6a5Smrg 57119c9ff80cSmrg -release) 57129c9ff80cSmrg prev=release 57139c9ff80cSmrg continue 57149c9ff80cSmrg ;; 57151f0ac6a5Smrg 57169c9ff80cSmrg -rpath) 57179c9ff80cSmrg prev=rpath 57189c9ff80cSmrg continue 57199c9ff80cSmrg ;; 57201f0ac6a5Smrg 57219c9ff80cSmrg -R) 57229c9ff80cSmrg prev=xrpath 57239c9ff80cSmrg continue 57249c9ff80cSmrg ;; 57251f0ac6a5Smrg 57269c9ff80cSmrg -R*) 57279c9ff80cSmrg func_stripname '-R' '' "$arg" 57289c9ff80cSmrg dir=$func_stripname_result 57299c9ff80cSmrg # We need an absolute path. 57309c9ff80cSmrg case $dir in 57319c9ff80cSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 57326fae4e5dSmrg =*) 57336fae4e5dSmrg func_stripname '=' '' "$dir" 57346fae4e5dSmrg dir=$lt_sysroot$func_stripname_result 57356fae4e5dSmrg ;; 57369c9ff80cSmrg *) 57379c9ff80cSmrg func_fatal_error "only absolute run-paths are allowed" 57389c9ff80cSmrg ;; 57399c9ff80cSmrg esac 57409c9ff80cSmrg case "$xrpath " in 57419c9ff80cSmrg *" $dir "*) ;; 57426fae4e5dSmrg *) func_append xrpath " $dir" ;; 57439c9ff80cSmrg esac 57449c9ff80cSmrg continue 57459c9ff80cSmrg ;; 57461f0ac6a5Smrg 57479c9ff80cSmrg -shared) 57489c9ff80cSmrg # The effects of -shared are defined in a previous loop. 57499c9ff80cSmrg continue 57509c9ff80cSmrg ;; 57511f0ac6a5Smrg 57529c9ff80cSmrg -shrext) 57539c9ff80cSmrg prev=shrext 57549c9ff80cSmrg continue 57559c9ff80cSmrg ;; 57561f0ac6a5Smrg 57579c9ff80cSmrg -static | -static-libtool-libs) 57589c9ff80cSmrg # The effects of -static are defined in a previous loop. 57599c9ff80cSmrg # We used to do the same as -all-static on platforms that 57609c9ff80cSmrg # didn't have a PIC flag, but the assumption that the effects 57619c9ff80cSmrg # would be equivalent was wrong. It would break on at least 57629c9ff80cSmrg # Digital Unix and AIX. 57639c9ff80cSmrg continue 57649c9ff80cSmrg ;; 57651f0ac6a5Smrg 57669c9ff80cSmrg -thread-safe) 57679c9ff80cSmrg thread_safe=yes 57689c9ff80cSmrg continue 57699c9ff80cSmrg ;; 57701f0ac6a5Smrg 57719c9ff80cSmrg -version-info) 57729c9ff80cSmrg prev=vinfo 57739c9ff80cSmrg continue 57749c9ff80cSmrg ;; 57751f0ac6a5Smrg 57769c9ff80cSmrg -version-number) 57779c9ff80cSmrg prev=vinfo 57789c9ff80cSmrg vinfo_number=yes 57799c9ff80cSmrg continue 57809c9ff80cSmrg ;; 57811f0ac6a5Smrg 57829c9ff80cSmrg -weak) 57839c9ff80cSmrg prev=weak 57849c9ff80cSmrg continue 57859c9ff80cSmrg ;; 57861f0ac6a5Smrg 57879c9ff80cSmrg -Wc,*) 57889c9ff80cSmrg func_stripname '-Wc,' '' "$arg" 57899c9ff80cSmrg args=$func_stripname_result 57909c9ff80cSmrg arg= 57919c9ff80cSmrg save_ifs="$IFS"; IFS=',' 57929c9ff80cSmrg for flag in $args; do 57939c9ff80cSmrg IFS="$save_ifs" 57949c9ff80cSmrg func_quote_for_eval "$flag" 57956fae4e5dSmrg func_append arg " $func_quote_for_eval_result" 57966fae4e5dSmrg func_append compiler_flags " $func_quote_for_eval_result" 57979c9ff80cSmrg done 57989c9ff80cSmrg IFS="$save_ifs" 57999c9ff80cSmrg func_stripname ' ' '' "$arg" 58009c9ff80cSmrg arg=$func_stripname_result 58019c9ff80cSmrg ;; 58021f0ac6a5Smrg 58039c9ff80cSmrg -Wl,*) 58049c9ff80cSmrg func_stripname '-Wl,' '' "$arg" 58059c9ff80cSmrg args=$func_stripname_result 58069c9ff80cSmrg arg= 58079c9ff80cSmrg save_ifs="$IFS"; IFS=',' 58089c9ff80cSmrg for flag in $args; do 58099c9ff80cSmrg IFS="$save_ifs" 58109c9ff80cSmrg func_quote_for_eval "$flag" 58116fae4e5dSmrg func_append arg " $wl$func_quote_for_eval_result" 58126fae4e5dSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 58136fae4e5dSmrg func_append linker_flags " $func_quote_for_eval_result" 58149c9ff80cSmrg done 58159c9ff80cSmrg IFS="$save_ifs" 58169c9ff80cSmrg func_stripname ' ' '' "$arg" 58179c9ff80cSmrg arg=$func_stripname_result 58189c9ff80cSmrg ;; 58191f0ac6a5Smrg 58209c9ff80cSmrg -Xcompiler) 58219c9ff80cSmrg prev=xcompiler 58229c9ff80cSmrg continue 58239c9ff80cSmrg ;; 58241f0ac6a5Smrg 58259c9ff80cSmrg -Xlinker) 58269c9ff80cSmrg prev=xlinker 58279c9ff80cSmrg continue 58289c9ff80cSmrg ;; 58291f0ac6a5Smrg 58309c9ff80cSmrg -XCClinker) 58319c9ff80cSmrg prev=xcclinker 58329c9ff80cSmrg continue 58339c9ff80cSmrg ;; 58341f0ac6a5Smrg 58359c9ff80cSmrg # -msg_* for osf cc 58369c9ff80cSmrg -msg_*) 58379c9ff80cSmrg func_quote_for_eval "$arg" 58389c9ff80cSmrg arg="$func_quote_for_eval_result" 58399c9ff80cSmrg ;; 58401f0ac6a5Smrg 58416fae4e5dSmrg # Flags to be passed through unchanged, with rationale: 58426fae4e5dSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 58436fae4e5dSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 58446fae4e5dSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 58456fae4e5dSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 58466fae4e5dSmrg # -q* compiler args for the IBM compiler 58476fae4e5dSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 58486fae4e5dSmrg # -F/path path to uninstalled frameworks, gcc on darwin 58496fae4e5dSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 58506fae4e5dSmrg # @file GCC response files 58516fae4e5dSmrg # -tp=* Portland pgcc target processor selection 58526fae4e5dSmrg # --sysroot=* for sysroot support 58536fae4e5dSmrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 58549c9ff80cSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 58556fae4e5dSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 58566fae4e5dSmrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 58579c9ff80cSmrg func_quote_for_eval "$arg" 58589c9ff80cSmrg arg="$func_quote_for_eval_result" 58599c9ff80cSmrg func_append compile_command " $arg" 58609c9ff80cSmrg func_append finalize_command " $arg" 58616fae4e5dSmrg func_append compiler_flags " $arg" 58629c9ff80cSmrg continue 58639c9ff80cSmrg ;; 58641f0ac6a5Smrg 58659c9ff80cSmrg # Some other compiler flag. 58669c9ff80cSmrg -* | +*) 58679c9ff80cSmrg func_quote_for_eval "$arg" 58689c9ff80cSmrg arg="$func_quote_for_eval_result" 58699c9ff80cSmrg ;; 58701f0ac6a5Smrg 58719c9ff80cSmrg *.$objext) 58729c9ff80cSmrg # A standard object. 58736fae4e5dSmrg func_append objs " $arg" 58749c9ff80cSmrg ;; 58751f0ac6a5Smrg 58769c9ff80cSmrg *.lo) 58779c9ff80cSmrg # A libtool-controlled object. 58781f0ac6a5Smrg 58799c9ff80cSmrg # Check to see that this really is a libtool object. 58809c9ff80cSmrg if func_lalib_unsafe_p "$arg"; then 58819c9ff80cSmrg pic_object= 58829c9ff80cSmrg non_pic_object= 58831f0ac6a5Smrg 58849c9ff80cSmrg # Read the .lo file 58859c9ff80cSmrg func_source "$arg" 58861f0ac6a5Smrg 58879c9ff80cSmrg if test -z "$pic_object" || 58889c9ff80cSmrg test -z "$non_pic_object" || 58899c9ff80cSmrg test "$pic_object" = none && 58909c9ff80cSmrg test "$non_pic_object" = none; then 58919c9ff80cSmrg func_fatal_error "cannot find name of object for \`$arg'" 58929c9ff80cSmrg fi 58931f0ac6a5Smrg 58949c9ff80cSmrg # Extract subdirectory from the argument. 58959c9ff80cSmrg func_dirname "$arg" "/" "" 58969c9ff80cSmrg xdir="$func_dirname_result" 5897e5410a46Smrg 58989c9ff80cSmrg if test "$pic_object" != none; then 58999c9ff80cSmrg # Prepend the subdirectory the object is found in. 59009c9ff80cSmrg pic_object="$xdir$pic_object" 59011f0ac6a5Smrg 59029c9ff80cSmrg if test "$prev" = dlfiles; then 59039c9ff80cSmrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 59046fae4e5dSmrg func_append dlfiles " $pic_object" 59059c9ff80cSmrg prev= 59069c9ff80cSmrg continue 59079c9ff80cSmrg else 59089c9ff80cSmrg # If libtool objects are unsupported, then we need to preload. 59099c9ff80cSmrg prev=dlprefiles 59109c9ff80cSmrg fi 59119c9ff80cSmrg fi 59121f0ac6a5Smrg 59139c9ff80cSmrg # CHECK ME: I think I busted this. -Ossama 59149c9ff80cSmrg if test "$prev" = dlprefiles; then 59159c9ff80cSmrg # Preload the old-style object. 59166fae4e5dSmrg func_append dlprefiles " $pic_object" 59179c9ff80cSmrg prev= 59189c9ff80cSmrg fi 59191f0ac6a5Smrg 59209c9ff80cSmrg # A PIC object. 59219c9ff80cSmrg func_append libobjs " $pic_object" 59229c9ff80cSmrg arg="$pic_object" 59239c9ff80cSmrg fi 59241f0ac6a5Smrg 59259c9ff80cSmrg # Non-PIC object. 59269c9ff80cSmrg if test "$non_pic_object" != none; then 59279c9ff80cSmrg # Prepend the subdirectory the object is found in. 59289c9ff80cSmrg non_pic_object="$xdir$non_pic_object" 59291f0ac6a5Smrg 59309c9ff80cSmrg # A standard non-PIC object 59319c9ff80cSmrg func_append non_pic_objects " $non_pic_object" 59329c9ff80cSmrg if test -z "$pic_object" || test "$pic_object" = none ; then 59339c9ff80cSmrg arg="$non_pic_object" 59349c9ff80cSmrg fi 59359c9ff80cSmrg else 59369c9ff80cSmrg # If the PIC object exists, use it instead. 59379c9ff80cSmrg # $xdir was prepended to $pic_object above. 59389c9ff80cSmrg non_pic_object="$pic_object" 59399c9ff80cSmrg func_append non_pic_objects " $non_pic_object" 59409c9ff80cSmrg fi 59419c9ff80cSmrg else 59429c9ff80cSmrg # Only an error if not doing a dry-run. 59439c9ff80cSmrg if $opt_dry_run; then 59449c9ff80cSmrg # Extract subdirectory from the argument. 59459c9ff80cSmrg func_dirname "$arg" "/" "" 59469c9ff80cSmrg xdir="$func_dirname_result" 59479c9ff80cSmrg 59489c9ff80cSmrg func_lo2o "$arg" 59499c9ff80cSmrg pic_object=$xdir$objdir/$func_lo2o_result 59509c9ff80cSmrg non_pic_object=$xdir$func_lo2o_result 59519c9ff80cSmrg func_append libobjs " $pic_object" 59529c9ff80cSmrg func_append non_pic_objects " $non_pic_object" 59539c9ff80cSmrg else 59549c9ff80cSmrg func_fatal_error "\`$arg' is not a valid libtool object" 59559c9ff80cSmrg fi 59569c9ff80cSmrg fi 59579c9ff80cSmrg ;; 59581f0ac6a5Smrg 59599c9ff80cSmrg *.$libext) 59609c9ff80cSmrg # An archive. 59616fae4e5dSmrg func_append deplibs " $arg" 59626fae4e5dSmrg func_append old_deplibs " $arg" 59639c9ff80cSmrg continue 59649c9ff80cSmrg ;; 59659c9ff80cSmrg 59669c9ff80cSmrg *.la) 59679c9ff80cSmrg # A libtool-controlled library. 59689c9ff80cSmrg 59696fae4e5dSmrg func_resolve_sysroot "$arg" 59709c9ff80cSmrg if test "$prev" = dlfiles; then 59719c9ff80cSmrg # This library was specified with -dlopen. 59726fae4e5dSmrg func_append dlfiles " $func_resolve_sysroot_result" 59739c9ff80cSmrg prev= 59749c9ff80cSmrg elif test "$prev" = dlprefiles; then 59759c9ff80cSmrg # The library was specified with -dlpreopen. 59766fae4e5dSmrg func_append dlprefiles " $func_resolve_sysroot_result" 59779c9ff80cSmrg prev= 59789c9ff80cSmrg else 59796fae4e5dSmrg func_append deplibs " $func_resolve_sysroot_result" 59809c9ff80cSmrg fi 59819c9ff80cSmrg continue 59829c9ff80cSmrg ;; 59839c9ff80cSmrg 59849c9ff80cSmrg # Some other compiler argument. 59859c9ff80cSmrg *) 59869c9ff80cSmrg # Unknown arguments in both finalize_command and compile_command need 59879c9ff80cSmrg # to be aesthetically quoted because they are evaled later. 59889c9ff80cSmrg func_quote_for_eval "$arg" 59899c9ff80cSmrg arg="$func_quote_for_eval_result" 59909c9ff80cSmrg ;; 59919c9ff80cSmrg esac # arg 59929c9ff80cSmrg 59939c9ff80cSmrg # Now actually substitute the argument into the commands. 59949c9ff80cSmrg if test -n "$arg"; then 59959c9ff80cSmrg func_append compile_command " $arg" 59969c9ff80cSmrg func_append finalize_command " $arg" 59979c9ff80cSmrg fi 59989c9ff80cSmrg done # argument parsing loop 59999c9ff80cSmrg 60009c9ff80cSmrg test -n "$prev" && \ 60019c9ff80cSmrg func_fatal_help "the \`$prevarg' option requires an argument" 60029c9ff80cSmrg 60039c9ff80cSmrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 60049c9ff80cSmrg eval arg=\"$export_dynamic_flag_spec\" 60059c9ff80cSmrg func_append compile_command " $arg" 60069c9ff80cSmrg func_append finalize_command " $arg" 60079c9ff80cSmrg fi 60089c9ff80cSmrg 60099c9ff80cSmrg oldlibs= 60109c9ff80cSmrg # calculate the name of the file, without its directory 60119c9ff80cSmrg func_basename "$output" 60129c9ff80cSmrg outputname="$func_basename_result" 60139c9ff80cSmrg libobjs_save="$libobjs" 60149c9ff80cSmrg 60159c9ff80cSmrg if test -n "$shlibpath_var"; then 60169c9ff80cSmrg # get the directories listed in $shlibpath_var 60176fae4e5dSmrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 60189c9ff80cSmrg else 60199c9ff80cSmrg shlib_search_path= 60209c9ff80cSmrg fi 60219c9ff80cSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 60229c9ff80cSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 60239c9ff80cSmrg 60249c9ff80cSmrg func_dirname "$output" "/" "" 60259c9ff80cSmrg output_objdir="$func_dirname_result$objdir" 60266fae4e5dSmrg func_to_tool_file "$output_objdir/" 60276fae4e5dSmrg tool_output_objdir=$func_to_tool_file_result 60289c9ff80cSmrg # Create the object directory. 60299c9ff80cSmrg func_mkdir_p "$output_objdir" 60309c9ff80cSmrg 60319c9ff80cSmrg # Determine the type of output 60329c9ff80cSmrg case $output in 60339c9ff80cSmrg "") 60349c9ff80cSmrg func_fatal_help "you must specify an output file" 60359c9ff80cSmrg ;; 60369c9ff80cSmrg *.$libext) linkmode=oldlib ;; 60379c9ff80cSmrg *.lo | *.$objext) linkmode=obj ;; 60389c9ff80cSmrg *.la) linkmode=lib ;; 60399c9ff80cSmrg *) linkmode=prog ;; # Anything else should be a program. 60409c9ff80cSmrg esac 60419c9ff80cSmrg 60429c9ff80cSmrg specialdeplibs= 60439c9ff80cSmrg 60449c9ff80cSmrg libs= 60459c9ff80cSmrg # Find all interdependent deplibs by searching for libraries 60469c9ff80cSmrg # that are linked more than once (e.g. -la -lb -la) 60479c9ff80cSmrg for deplib in $deplibs; do 60486fae4e5dSmrg if $opt_preserve_dup_deps ; then 60499c9ff80cSmrg case "$libs " in 60506fae4e5dSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 60519c9ff80cSmrg esac 60529c9ff80cSmrg fi 60536fae4e5dSmrg func_append libs " $deplib" 60549c9ff80cSmrg done 60559c9ff80cSmrg 60569c9ff80cSmrg if test "$linkmode" = lib; then 60579c9ff80cSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 60589c9ff80cSmrg 60599c9ff80cSmrg # Compute libraries that are listed more than once in $predeps 60609c9ff80cSmrg # $postdeps and mark them as special (i.e., whose duplicates are 60619c9ff80cSmrg # not to be eliminated). 60629c9ff80cSmrg pre_post_deps= 60639c9ff80cSmrg if $opt_duplicate_compiler_generated_deps; then 60649c9ff80cSmrg for pre_post_dep in $predeps $postdeps; do 60659c9ff80cSmrg case "$pre_post_deps " in 60666fae4e5dSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 60679c9ff80cSmrg esac 60686fae4e5dSmrg func_append pre_post_deps " $pre_post_dep" 60699c9ff80cSmrg done 60709c9ff80cSmrg fi 60719c9ff80cSmrg pre_post_deps= 60729c9ff80cSmrg fi 60739c9ff80cSmrg 60749c9ff80cSmrg deplibs= 60759c9ff80cSmrg newdependency_libs= 60769c9ff80cSmrg newlib_search_path= 60779c9ff80cSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 60789c9ff80cSmrg notinst_deplibs= # not-installed libtool libraries 60799c9ff80cSmrg notinst_path= # paths that contain not-installed libtool libraries 60809c9ff80cSmrg 60819c9ff80cSmrg case $linkmode in 60829c9ff80cSmrg lib) 60839c9ff80cSmrg passes="conv dlpreopen link" 60849c9ff80cSmrg for file in $dlfiles $dlprefiles; do 60859c9ff80cSmrg case $file in 60869c9ff80cSmrg *.la) ;; 60879c9ff80cSmrg *) 60889c9ff80cSmrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 60899c9ff80cSmrg ;; 60909c9ff80cSmrg esac 60919c9ff80cSmrg done 60929c9ff80cSmrg ;; 60939c9ff80cSmrg prog) 60949c9ff80cSmrg compile_deplibs= 60959c9ff80cSmrg finalize_deplibs= 60969c9ff80cSmrg alldeplibs=no 60979c9ff80cSmrg newdlfiles= 60989c9ff80cSmrg newdlprefiles= 60999c9ff80cSmrg passes="conv scan dlopen dlpreopen link" 61009c9ff80cSmrg ;; 61019c9ff80cSmrg *) passes="conv" 61029c9ff80cSmrg ;; 61039c9ff80cSmrg esac 61049c9ff80cSmrg 61059c9ff80cSmrg for pass in $passes; do 61069c9ff80cSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 61079c9ff80cSmrg # so that -L comes before libs that need it for instance... 61089c9ff80cSmrg if test "$linkmode,$pass" = "lib,link"; then 61099c9ff80cSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 61109c9ff80cSmrg ## order, and fix it there properly 61119c9ff80cSmrg tmp_deplibs= 61129c9ff80cSmrg for deplib in $deplibs; do 61139c9ff80cSmrg tmp_deplibs="$deplib $tmp_deplibs" 61149c9ff80cSmrg done 61159c9ff80cSmrg deplibs="$tmp_deplibs" 61169c9ff80cSmrg fi 61179c9ff80cSmrg 61189c9ff80cSmrg if test "$linkmode,$pass" = "lib,link" || 61199c9ff80cSmrg test "$linkmode,$pass" = "prog,scan"; then 61209c9ff80cSmrg libs="$deplibs" 61219c9ff80cSmrg deplibs= 61229c9ff80cSmrg fi 61239c9ff80cSmrg if test "$linkmode" = prog; then 61249c9ff80cSmrg case $pass in 61259c9ff80cSmrg dlopen) libs="$dlfiles" ;; 61269c9ff80cSmrg dlpreopen) libs="$dlprefiles" ;; 61279c9ff80cSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 61289c9ff80cSmrg esac 61299c9ff80cSmrg fi 61309c9ff80cSmrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 61319c9ff80cSmrg # Collect and forward deplibs of preopened libtool libs 61329c9ff80cSmrg for lib in $dlprefiles; do 61339c9ff80cSmrg # Ignore non-libtool-libs 61349c9ff80cSmrg dependency_libs= 61356fae4e5dSmrg func_resolve_sysroot "$lib" 61369c9ff80cSmrg case $lib in 61376fae4e5dSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 61389c9ff80cSmrg esac 61399c9ff80cSmrg 61409c9ff80cSmrg # Collect preopened libtool deplibs, except any this library 61419c9ff80cSmrg # has declared as weak libs 61429c9ff80cSmrg for deplib in $dependency_libs; do 61436fae4e5dSmrg func_basename "$deplib" 61446fae4e5dSmrg deplib_base=$func_basename_result 61459c9ff80cSmrg case " $weak_libs " in 61469c9ff80cSmrg *" $deplib_base "*) ;; 61476fae4e5dSmrg *) func_append deplibs " $deplib" ;; 61489c9ff80cSmrg esac 61499c9ff80cSmrg done 61509c9ff80cSmrg done 61519c9ff80cSmrg libs="$dlprefiles" 61529c9ff80cSmrg fi 61539c9ff80cSmrg if test "$pass" = dlopen; then 61549c9ff80cSmrg # Collect dlpreopened libraries 61559c9ff80cSmrg save_deplibs="$deplibs" 61569c9ff80cSmrg deplibs= 61579c9ff80cSmrg fi 61589c9ff80cSmrg 61599c9ff80cSmrg for deplib in $libs; do 61609c9ff80cSmrg lib= 61619c9ff80cSmrg found=no 61629c9ff80cSmrg case $deplib in 616389c04b6cSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 616489c04b6cSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 61659c9ff80cSmrg if test "$linkmode,$pass" = "prog,link"; then 61669c9ff80cSmrg compile_deplibs="$deplib $compile_deplibs" 61679c9ff80cSmrg finalize_deplibs="$deplib $finalize_deplibs" 61689c9ff80cSmrg else 61696fae4e5dSmrg func_append compiler_flags " $deplib" 61709c9ff80cSmrg if test "$linkmode" = lib ; then 61719c9ff80cSmrg case "$new_inherited_linker_flags " in 61729c9ff80cSmrg *" $deplib "*) ;; 61736fae4e5dSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 61749c9ff80cSmrg esac 61759c9ff80cSmrg fi 61769c9ff80cSmrg fi 61779c9ff80cSmrg continue 61789c9ff80cSmrg ;; 61799c9ff80cSmrg -l*) 61809c9ff80cSmrg if test "$linkmode" != lib && test "$linkmode" != prog; then 61819c9ff80cSmrg func_warning "\`-l' is ignored for archives/objects" 61829c9ff80cSmrg continue 61839c9ff80cSmrg fi 61849c9ff80cSmrg func_stripname '-l' '' "$deplib" 61859c9ff80cSmrg name=$func_stripname_result 61869c9ff80cSmrg if test "$linkmode" = lib; then 61879c9ff80cSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 61889c9ff80cSmrg else 61899c9ff80cSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 61909c9ff80cSmrg fi 61919c9ff80cSmrg for searchdir in $searchdirs; do 61929c9ff80cSmrg for search_ext in .la $std_shrext .so .a; do 61939c9ff80cSmrg # Search the libtool library 61949c9ff80cSmrg lib="$searchdir/lib${name}${search_ext}" 61959c9ff80cSmrg if test -f "$lib"; then 61969c9ff80cSmrg if test "$search_ext" = ".la"; then 61979c9ff80cSmrg found=yes 61989c9ff80cSmrg else 61999c9ff80cSmrg found=no 62009c9ff80cSmrg fi 62019c9ff80cSmrg break 2 62029c9ff80cSmrg fi 62039c9ff80cSmrg done 62049c9ff80cSmrg done 62059c9ff80cSmrg if test "$found" != yes; then 62069c9ff80cSmrg # deplib doesn't seem to be a libtool library 62079c9ff80cSmrg if test "$linkmode,$pass" = "prog,link"; then 62089c9ff80cSmrg compile_deplibs="$deplib $compile_deplibs" 62099c9ff80cSmrg finalize_deplibs="$deplib $finalize_deplibs" 62109c9ff80cSmrg else 62119c9ff80cSmrg deplibs="$deplib $deplibs" 62129c9ff80cSmrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 62139c9ff80cSmrg fi 62149c9ff80cSmrg continue 62159c9ff80cSmrg else # deplib is a libtool library 62169c9ff80cSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 62179c9ff80cSmrg # We need to do some special things here, and not later. 62189c9ff80cSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 62199c9ff80cSmrg case " $predeps $postdeps " in 62209c9ff80cSmrg *" $deplib "*) 62219c9ff80cSmrg if func_lalib_p "$lib"; then 62229c9ff80cSmrg library_names= 62239c9ff80cSmrg old_library= 62249c9ff80cSmrg func_source "$lib" 62259c9ff80cSmrg for l in $old_library $library_names; do 62269c9ff80cSmrg ll="$l" 62279c9ff80cSmrg done 62289c9ff80cSmrg if test "X$ll" = "X$old_library" ; then # only static version available 62299c9ff80cSmrg found=no 62309c9ff80cSmrg func_dirname "$lib" "" "." 62319c9ff80cSmrg ladir="$func_dirname_result" 62329c9ff80cSmrg lib=$ladir/$old_library 62339c9ff80cSmrg if test "$linkmode,$pass" = "prog,link"; then 62349c9ff80cSmrg compile_deplibs="$deplib $compile_deplibs" 62359c9ff80cSmrg finalize_deplibs="$deplib $finalize_deplibs" 62369c9ff80cSmrg else 62379c9ff80cSmrg deplibs="$deplib $deplibs" 62389c9ff80cSmrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 62399c9ff80cSmrg fi 62409c9ff80cSmrg continue 62419c9ff80cSmrg fi 62429c9ff80cSmrg fi 62439c9ff80cSmrg ;; 62449c9ff80cSmrg *) ;; 62459c9ff80cSmrg esac 62469c9ff80cSmrg fi 62479c9ff80cSmrg fi 62489c9ff80cSmrg ;; # -l 62499c9ff80cSmrg *.ltframework) 62509c9ff80cSmrg if test "$linkmode,$pass" = "prog,link"; then 62519c9ff80cSmrg compile_deplibs="$deplib $compile_deplibs" 62529c9ff80cSmrg finalize_deplibs="$deplib $finalize_deplibs" 62539c9ff80cSmrg else 62549c9ff80cSmrg deplibs="$deplib $deplibs" 62559c9ff80cSmrg if test "$linkmode" = lib ; then 62569c9ff80cSmrg case "$new_inherited_linker_flags " in 62579c9ff80cSmrg *" $deplib "*) ;; 62586fae4e5dSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 62599c9ff80cSmrg esac 62609c9ff80cSmrg fi 62619c9ff80cSmrg fi 62629c9ff80cSmrg continue 62639c9ff80cSmrg ;; 62649c9ff80cSmrg -L*) 62659c9ff80cSmrg case $linkmode in 62669c9ff80cSmrg lib) 62679c9ff80cSmrg deplibs="$deplib $deplibs" 62689c9ff80cSmrg test "$pass" = conv && continue 62699c9ff80cSmrg newdependency_libs="$deplib $newdependency_libs" 62709c9ff80cSmrg func_stripname '-L' '' "$deplib" 62716fae4e5dSmrg func_resolve_sysroot "$func_stripname_result" 62726fae4e5dSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 62739c9ff80cSmrg ;; 62749c9ff80cSmrg prog) 62759c9ff80cSmrg if test "$pass" = conv; then 62769c9ff80cSmrg deplibs="$deplib $deplibs" 62779c9ff80cSmrg continue 62789c9ff80cSmrg fi 62799c9ff80cSmrg if test "$pass" = scan; then 62809c9ff80cSmrg deplibs="$deplib $deplibs" 62819c9ff80cSmrg else 62829c9ff80cSmrg compile_deplibs="$deplib $compile_deplibs" 62839c9ff80cSmrg finalize_deplibs="$deplib $finalize_deplibs" 62849c9ff80cSmrg fi 62859c9ff80cSmrg func_stripname '-L' '' "$deplib" 62866fae4e5dSmrg func_resolve_sysroot "$func_stripname_result" 62876fae4e5dSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 62889c9ff80cSmrg ;; 62899c9ff80cSmrg *) 62909c9ff80cSmrg func_warning "\`-L' is ignored for archives/objects" 62919c9ff80cSmrg ;; 62929c9ff80cSmrg esac # linkmode 62939c9ff80cSmrg continue 62949c9ff80cSmrg ;; # -L 62959c9ff80cSmrg -R*) 62969c9ff80cSmrg if test "$pass" = link; then 62979c9ff80cSmrg func_stripname '-R' '' "$deplib" 62986fae4e5dSmrg func_resolve_sysroot "$func_stripname_result" 62996fae4e5dSmrg dir=$func_resolve_sysroot_result 63009c9ff80cSmrg # Make sure the xrpath contains only unique directories. 63019c9ff80cSmrg case "$xrpath " in 63029c9ff80cSmrg *" $dir "*) ;; 63036fae4e5dSmrg *) func_append xrpath " $dir" ;; 63049c9ff80cSmrg esac 63059c9ff80cSmrg fi 63069c9ff80cSmrg deplibs="$deplib $deplibs" 63079c9ff80cSmrg continue 63089c9ff80cSmrg ;; 63096fae4e5dSmrg *.la) 63106fae4e5dSmrg func_resolve_sysroot "$deplib" 63116fae4e5dSmrg lib=$func_resolve_sysroot_result 63126fae4e5dSmrg ;; 63139c9ff80cSmrg *.$libext) 63149c9ff80cSmrg if test "$pass" = conv; then 63159c9ff80cSmrg deplibs="$deplib $deplibs" 63169c9ff80cSmrg continue 63179c9ff80cSmrg fi 63189c9ff80cSmrg case $linkmode in 63199c9ff80cSmrg lib) 63209c9ff80cSmrg # Linking convenience modules into shared libraries is allowed, 63219c9ff80cSmrg # but linking other static libraries is non-portable. 63229c9ff80cSmrg case " $dlpreconveniencelibs " in 63239c9ff80cSmrg *" $deplib "*) ;; 63249c9ff80cSmrg *) 63259c9ff80cSmrg valid_a_lib=no 63269c9ff80cSmrg case $deplibs_check_method in 63279c9ff80cSmrg match_pattern*) 63289c9ff80cSmrg set dummy $deplibs_check_method; shift 63299c9ff80cSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 63306fae4e5dSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 63319c9ff80cSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 63329c9ff80cSmrg valid_a_lib=yes 63339c9ff80cSmrg fi 63349c9ff80cSmrg ;; 63359c9ff80cSmrg pass_all) 63369c9ff80cSmrg valid_a_lib=yes 63379c9ff80cSmrg ;; 63389c9ff80cSmrg esac 63399c9ff80cSmrg if test "$valid_a_lib" != yes; then 63406fae4e5dSmrg echo 63419c9ff80cSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 63426fae4e5dSmrg echo "*** I have the capability to make that library automatically link in when" 63436fae4e5dSmrg echo "*** you link to this library. But I can only do this if you have a" 63446fae4e5dSmrg echo "*** shared version of the library, which you do not appear to have" 63456fae4e5dSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 63466fae4e5dSmrg echo "*** that it is just a static archive that I should not use here." 63479c9ff80cSmrg else 63486fae4e5dSmrg echo 63499c9ff80cSmrg $ECHO "*** Warning: Linking the shared library $output against the" 63509c9ff80cSmrg $ECHO "*** static library $deplib is not portable!" 63519c9ff80cSmrg deplibs="$deplib $deplibs" 63529c9ff80cSmrg fi 63539c9ff80cSmrg ;; 63549c9ff80cSmrg esac 63559c9ff80cSmrg continue 63569c9ff80cSmrg ;; 63579c9ff80cSmrg prog) 63589c9ff80cSmrg if test "$pass" != link; then 63599c9ff80cSmrg deplibs="$deplib $deplibs" 63609c9ff80cSmrg else 63619c9ff80cSmrg compile_deplibs="$deplib $compile_deplibs" 63629c9ff80cSmrg finalize_deplibs="$deplib $finalize_deplibs" 63639c9ff80cSmrg fi 63649c9ff80cSmrg continue 63659c9ff80cSmrg ;; 63669c9ff80cSmrg esac # linkmode 63679c9ff80cSmrg ;; # *.$libext 63689c9ff80cSmrg *.lo | *.$objext) 63699c9ff80cSmrg if test "$pass" = conv; then 63709c9ff80cSmrg deplibs="$deplib $deplibs" 63719c9ff80cSmrg elif test "$linkmode" = prog; then 63729c9ff80cSmrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 63739c9ff80cSmrg # If there is no dlopen support or we're linking statically, 63749c9ff80cSmrg # we need to preload. 63756fae4e5dSmrg func_append newdlprefiles " $deplib" 63769c9ff80cSmrg compile_deplibs="$deplib $compile_deplibs" 63779c9ff80cSmrg finalize_deplibs="$deplib $finalize_deplibs" 63789c9ff80cSmrg else 63796fae4e5dSmrg func_append newdlfiles " $deplib" 63809c9ff80cSmrg fi 63819c9ff80cSmrg fi 63829c9ff80cSmrg continue 63839c9ff80cSmrg ;; 63849c9ff80cSmrg %DEPLIBS%) 63859c9ff80cSmrg alldeplibs=yes 63869c9ff80cSmrg continue 63879c9ff80cSmrg ;; 63889c9ff80cSmrg esac # case $deplib 63899c9ff80cSmrg 63909c9ff80cSmrg if test "$found" = yes || test -f "$lib"; then : 63919c9ff80cSmrg else 63929c9ff80cSmrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 63939c9ff80cSmrg fi 63949c9ff80cSmrg 63959c9ff80cSmrg # Check to see that this really is a libtool archive. 63969c9ff80cSmrg func_lalib_unsafe_p "$lib" \ 63979c9ff80cSmrg || func_fatal_error "\`$lib' is not a valid libtool archive" 63989c9ff80cSmrg 63999c9ff80cSmrg func_dirname "$lib" "" "." 64009c9ff80cSmrg ladir="$func_dirname_result" 64019c9ff80cSmrg 64029c9ff80cSmrg dlname= 64039c9ff80cSmrg dlopen= 64049c9ff80cSmrg dlpreopen= 64059c9ff80cSmrg libdir= 64069c9ff80cSmrg library_names= 64079c9ff80cSmrg old_library= 64089c9ff80cSmrg inherited_linker_flags= 64099c9ff80cSmrg # If the library was installed with an old release of libtool, 64109c9ff80cSmrg # it will not redefine variables installed, or shouldnotlink 64119c9ff80cSmrg installed=yes 64129c9ff80cSmrg shouldnotlink=no 64139c9ff80cSmrg avoidtemprpath= 64149c9ff80cSmrg 64159c9ff80cSmrg 64169c9ff80cSmrg # Read the .la file 64179c9ff80cSmrg func_source "$lib" 64189c9ff80cSmrg 64199c9ff80cSmrg # Convert "-framework foo" to "foo.ltframework" 64209c9ff80cSmrg if test -n "$inherited_linker_flags"; then 64216fae4e5dSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 64229c9ff80cSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 64239c9ff80cSmrg case " $new_inherited_linker_flags " in 64249c9ff80cSmrg *" $tmp_inherited_linker_flag "*) ;; 64256fae4e5dSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 64269c9ff80cSmrg esac 64279c9ff80cSmrg done 64289c9ff80cSmrg fi 64296fae4e5dSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 64309c9ff80cSmrg if test "$linkmode,$pass" = "lib,link" || 64319c9ff80cSmrg test "$linkmode,$pass" = "prog,scan" || 64329c9ff80cSmrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 64336fae4e5dSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 64346fae4e5dSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 64359c9ff80cSmrg fi 64369c9ff80cSmrg 64379c9ff80cSmrg if test "$pass" = conv; then 64389c9ff80cSmrg # Only check for convenience libraries 64399c9ff80cSmrg deplibs="$lib $deplibs" 64409c9ff80cSmrg if test -z "$libdir"; then 64419c9ff80cSmrg if test -z "$old_library"; then 64429c9ff80cSmrg func_fatal_error "cannot find name of link library for \`$lib'" 64439c9ff80cSmrg fi 64449c9ff80cSmrg # It is a libtool convenience library, so add in its objects. 64456fae4e5dSmrg func_append convenience " $ladir/$objdir/$old_library" 64466fae4e5dSmrg func_append old_convenience " $ladir/$objdir/$old_library" 64479c9ff80cSmrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 64489c9ff80cSmrg func_fatal_error "\`$lib' is not a convenience library" 64499c9ff80cSmrg fi 64509c9ff80cSmrg tmp_libs= 64519c9ff80cSmrg for deplib in $dependency_libs; do 64529c9ff80cSmrg deplibs="$deplib $deplibs" 64536fae4e5dSmrg if $opt_preserve_dup_deps ; then 64549c9ff80cSmrg case "$tmp_libs " in 64556fae4e5dSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 64569c9ff80cSmrg esac 64579c9ff80cSmrg fi 64586fae4e5dSmrg func_append tmp_libs " $deplib" 64599c9ff80cSmrg done 64609c9ff80cSmrg continue 64619c9ff80cSmrg fi # $pass = conv 64629c9ff80cSmrg 64639c9ff80cSmrg 64649c9ff80cSmrg # Get the name of the library we link against. 64659c9ff80cSmrg linklib= 64666fae4e5dSmrg if test -n "$old_library" && 64676fae4e5dSmrg { test "$prefer_static_libs" = yes || 64686fae4e5dSmrg test "$prefer_static_libs,$installed" = "built,no"; }; then 64696fae4e5dSmrg linklib=$old_library 64706fae4e5dSmrg else 64716fae4e5dSmrg for l in $old_library $library_names; do 64726fae4e5dSmrg linklib="$l" 64736fae4e5dSmrg done 64746fae4e5dSmrg fi 64759c9ff80cSmrg if test -z "$linklib"; then 64769c9ff80cSmrg func_fatal_error "cannot find name of link library for \`$lib'" 64779c9ff80cSmrg fi 64789c9ff80cSmrg 64799c9ff80cSmrg # This library was specified with -dlopen. 64809c9ff80cSmrg if test "$pass" = dlopen; then 64819c9ff80cSmrg if test -z "$libdir"; then 64829c9ff80cSmrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 64839c9ff80cSmrg fi 64849c9ff80cSmrg if test -z "$dlname" || 64859c9ff80cSmrg test "$dlopen_support" != yes || 64869c9ff80cSmrg test "$build_libtool_libs" = no; then 64879c9ff80cSmrg # If there is no dlname, no dlopen support or we're linking 64889c9ff80cSmrg # statically, we need to preload. We also need to preload any 64899c9ff80cSmrg # dependent libraries so libltdl's deplib preloader doesn't 64909c9ff80cSmrg # bomb out in the load deplibs phase. 64916fae4e5dSmrg func_append dlprefiles " $lib $dependency_libs" 64929c9ff80cSmrg else 64936fae4e5dSmrg func_append newdlfiles " $lib" 64949c9ff80cSmrg fi 64959c9ff80cSmrg continue 64969c9ff80cSmrg fi # $pass = dlopen 64979c9ff80cSmrg 64989c9ff80cSmrg # We need an absolute path. 64999c9ff80cSmrg case $ladir in 65009c9ff80cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 65019c9ff80cSmrg *) 65029c9ff80cSmrg abs_ladir=`cd "$ladir" && pwd` 65039c9ff80cSmrg if test -z "$abs_ladir"; then 65049c9ff80cSmrg func_warning "cannot determine absolute directory name of \`$ladir'" 65059c9ff80cSmrg func_warning "passing it literally to the linker, although it might fail" 65069c9ff80cSmrg abs_ladir="$ladir" 65079c9ff80cSmrg fi 65089c9ff80cSmrg ;; 65099c9ff80cSmrg esac 65109c9ff80cSmrg func_basename "$lib" 65119c9ff80cSmrg laname="$func_basename_result" 65129c9ff80cSmrg 65139c9ff80cSmrg # Find the relevant object directory and library name. 65149c9ff80cSmrg if test "X$installed" = Xyes; then 65156fae4e5dSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 65169c9ff80cSmrg func_warning "library \`$lib' was moved." 65179c9ff80cSmrg dir="$ladir" 65189c9ff80cSmrg absdir="$abs_ladir" 65199c9ff80cSmrg libdir="$abs_ladir" 65209c9ff80cSmrg else 65216fae4e5dSmrg dir="$lt_sysroot$libdir" 65226fae4e5dSmrg absdir="$lt_sysroot$libdir" 65239c9ff80cSmrg fi 65249c9ff80cSmrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 65259c9ff80cSmrg else 65269c9ff80cSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 65279c9ff80cSmrg dir="$ladir" 65289c9ff80cSmrg absdir="$abs_ladir" 65299c9ff80cSmrg # Remove this search path later 65306fae4e5dSmrg func_append notinst_path " $abs_ladir" 65319c9ff80cSmrg else 65329c9ff80cSmrg dir="$ladir/$objdir" 65339c9ff80cSmrg absdir="$abs_ladir/$objdir" 65349c9ff80cSmrg # Remove this search path later 65356fae4e5dSmrg func_append notinst_path " $abs_ladir" 65369c9ff80cSmrg fi 65379c9ff80cSmrg fi # $installed = yes 65389c9ff80cSmrg func_stripname 'lib' '.la' "$laname" 65399c9ff80cSmrg name=$func_stripname_result 65409c9ff80cSmrg 65419c9ff80cSmrg # This library was specified with -dlpreopen. 65429c9ff80cSmrg if test "$pass" = dlpreopen; then 65439c9ff80cSmrg if test -z "$libdir" && test "$linkmode" = prog; then 65449c9ff80cSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 65459c9ff80cSmrg fi 65466fae4e5dSmrg case "$host" in 65476fae4e5dSmrg # special handling for platforms with PE-DLLs. 65486fae4e5dSmrg *cygwin* | *mingw* | *cegcc* ) 65496fae4e5dSmrg # Linker will automatically link against shared library if both 65506fae4e5dSmrg # static and shared are present. Therefore, ensure we extract 65516fae4e5dSmrg # symbols from the import library if a shared library is present 65526fae4e5dSmrg # (otherwise, the dlopen module name will be incorrect). We do 65536fae4e5dSmrg # this by putting the import library name into $newdlprefiles. 65546fae4e5dSmrg # We recover the dlopen module name by 'saving' the la file 65556fae4e5dSmrg # name in a special purpose variable, and (later) extracting the 65566fae4e5dSmrg # dlname from the la file. 65576fae4e5dSmrg if test -n "$dlname"; then 65586fae4e5dSmrg func_tr_sh "$dir/$linklib" 65596fae4e5dSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 65606fae4e5dSmrg func_append newdlprefiles " $dir/$linklib" 65616fae4e5dSmrg else 65626fae4e5dSmrg func_append newdlprefiles " $dir/$old_library" 65636fae4e5dSmrg # Keep a list of preopened convenience libraries to check 65646fae4e5dSmrg # that they are being used correctly in the link pass. 65656fae4e5dSmrg test -z "$libdir" && \ 65666fae4e5dSmrg func_append dlpreconveniencelibs " $dir/$old_library" 65676fae4e5dSmrg fi 65686fae4e5dSmrg ;; 65696fae4e5dSmrg * ) 65706fae4e5dSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 65716fae4e5dSmrg # are required to link). 65726fae4e5dSmrg if test -n "$old_library"; then 65736fae4e5dSmrg func_append newdlprefiles " $dir/$old_library" 65746fae4e5dSmrg # Keep a list of preopened convenience libraries to check 65756fae4e5dSmrg # that they are being used correctly in the link pass. 65766fae4e5dSmrg test -z "$libdir" && \ 65776fae4e5dSmrg func_append dlpreconveniencelibs " $dir/$old_library" 65786fae4e5dSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 65796fae4e5dSmrg elif test -n "$dlname"; then 65806fae4e5dSmrg func_append newdlprefiles " $dir/$dlname" 65816fae4e5dSmrg else 65826fae4e5dSmrg func_append newdlprefiles " $dir/$linklib" 65836fae4e5dSmrg fi 65846fae4e5dSmrg ;; 65856fae4e5dSmrg esac 65869c9ff80cSmrg fi # $pass = dlpreopen 65879c9ff80cSmrg 65889c9ff80cSmrg if test -z "$libdir"; then 65899c9ff80cSmrg # Link the convenience library 65909c9ff80cSmrg if test "$linkmode" = lib; then 65919c9ff80cSmrg deplibs="$dir/$old_library $deplibs" 65929c9ff80cSmrg elif test "$linkmode,$pass" = "prog,link"; then 65939c9ff80cSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 65949c9ff80cSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 65959c9ff80cSmrg else 65969c9ff80cSmrg deplibs="$lib $deplibs" # used for prog,scan pass 65979c9ff80cSmrg fi 65989c9ff80cSmrg continue 65999c9ff80cSmrg fi 66009c9ff80cSmrg 66019c9ff80cSmrg 66029c9ff80cSmrg if test "$linkmode" = prog && test "$pass" != link; then 66036fae4e5dSmrg func_append newlib_search_path " $ladir" 66049c9ff80cSmrg deplibs="$lib $deplibs" 66059c9ff80cSmrg 66069c9ff80cSmrg linkalldeplibs=no 66079c9ff80cSmrg if test "$link_all_deplibs" != no || test -z "$library_names" || 66089c9ff80cSmrg test "$build_libtool_libs" = no; then 66099c9ff80cSmrg linkalldeplibs=yes 66109c9ff80cSmrg fi 66119c9ff80cSmrg 66129c9ff80cSmrg tmp_libs= 66139c9ff80cSmrg for deplib in $dependency_libs; do 66149c9ff80cSmrg case $deplib in 66159c9ff80cSmrg -L*) func_stripname '-L' '' "$deplib" 66166fae4e5dSmrg func_resolve_sysroot "$func_stripname_result" 66176fae4e5dSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 66189c9ff80cSmrg ;; 66199c9ff80cSmrg esac 66209c9ff80cSmrg # Need to link against all dependency_libs? 66219c9ff80cSmrg if test "$linkalldeplibs" = yes; then 66229c9ff80cSmrg deplibs="$deplib $deplibs" 66239c9ff80cSmrg else 66249c9ff80cSmrg # Need to hardcode shared library paths 66259c9ff80cSmrg # or/and link against static libraries 66269c9ff80cSmrg newdependency_libs="$deplib $newdependency_libs" 66279c9ff80cSmrg fi 66286fae4e5dSmrg if $opt_preserve_dup_deps ; then 66299c9ff80cSmrg case "$tmp_libs " in 66306fae4e5dSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 66319c9ff80cSmrg esac 66329c9ff80cSmrg fi 66336fae4e5dSmrg func_append tmp_libs " $deplib" 66349c9ff80cSmrg done # for deplib 66359c9ff80cSmrg continue 66369c9ff80cSmrg fi # $linkmode = prog... 66379c9ff80cSmrg 66389c9ff80cSmrg if test "$linkmode,$pass" = "prog,link"; then 66399c9ff80cSmrg if test -n "$library_names" && 66409c9ff80cSmrg { { test "$prefer_static_libs" = no || 66419c9ff80cSmrg test "$prefer_static_libs,$installed" = "built,yes"; } || 66429c9ff80cSmrg test -z "$old_library"; }; then 66439c9ff80cSmrg # We need to hardcode the library path 66449c9ff80cSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 66459c9ff80cSmrg # Make sure the rpath contains only unique directories. 66469c9ff80cSmrg case "$temp_rpath:" in 66479c9ff80cSmrg *"$absdir:"*) ;; 66486fae4e5dSmrg *) func_append temp_rpath "$absdir:" ;; 66499c9ff80cSmrg esac 66509c9ff80cSmrg fi 66519c9ff80cSmrg 66529c9ff80cSmrg # Hardcode the library path. 66539c9ff80cSmrg # Skip directories that are in the system default run-time 66549c9ff80cSmrg # search path. 66559c9ff80cSmrg case " $sys_lib_dlsearch_path " in 66569c9ff80cSmrg *" $absdir "*) ;; 66579c9ff80cSmrg *) 66589c9ff80cSmrg case "$compile_rpath " in 66599c9ff80cSmrg *" $absdir "*) ;; 66606fae4e5dSmrg *) func_append compile_rpath " $absdir" ;; 66619c9ff80cSmrg esac 66629c9ff80cSmrg ;; 66639c9ff80cSmrg esac 66649c9ff80cSmrg case " $sys_lib_dlsearch_path " in 66659c9ff80cSmrg *" $libdir "*) ;; 66669c9ff80cSmrg *) 66679c9ff80cSmrg case "$finalize_rpath " in 66689c9ff80cSmrg *" $libdir "*) ;; 66696fae4e5dSmrg *) func_append finalize_rpath " $libdir" ;; 66709c9ff80cSmrg esac 66719c9ff80cSmrg ;; 66729c9ff80cSmrg esac 66739c9ff80cSmrg fi # $linkmode,$pass = prog,link... 66749c9ff80cSmrg 66759c9ff80cSmrg if test "$alldeplibs" = yes && 66769c9ff80cSmrg { test "$deplibs_check_method" = pass_all || 66779c9ff80cSmrg { test "$build_libtool_libs" = yes && 66789c9ff80cSmrg test -n "$library_names"; }; }; then 66799c9ff80cSmrg # We only need to search for static libraries 66809c9ff80cSmrg continue 66819c9ff80cSmrg fi 66829c9ff80cSmrg fi 66839c9ff80cSmrg 66849c9ff80cSmrg link_static=no # Whether the deplib will be linked statically 66859c9ff80cSmrg use_static_libs=$prefer_static_libs 66869c9ff80cSmrg if test "$use_static_libs" = built && test "$installed" = yes; then 66879c9ff80cSmrg use_static_libs=no 66889c9ff80cSmrg fi 66899c9ff80cSmrg if test -n "$library_names" && 66909c9ff80cSmrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 66919c9ff80cSmrg case $host in 66929c9ff80cSmrg *cygwin* | *mingw* | *cegcc*) 66939c9ff80cSmrg # No point in relinking DLLs because paths are not encoded 66946fae4e5dSmrg func_append notinst_deplibs " $lib" 66959c9ff80cSmrg need_relink=no 66969c9ff80cSmrg ;; 66979c9ff80cSmrg *) 66989c9ff80cSmrg if test "$installed" = no; then 66996fae4e5dSmrg func_append notinst_deplibs " $lib" 67009c9ff80cSmrg need_relink=yes 67019c9ff80cSmrg fi 67029c9ff80cSmrg ;; 67039c9ff80cSmrg esac 67049c9ff80cSmrg # This is a shared library 67059c9ff80cSmrg 67069c9ff80cSmrg # Warn about portability, can't link against -module's on some 67079c9ff80cSmrg # systems (darwin). Don't bleat about dlopened modules though! 67089c9ff80cSmrg dlopenmodule="" 67099c9ff80cSmrg for dlpremoduletest in $dlprefiles; do 67109c9ff80cSmrg if test "X$dlpremoduletest" = "X$lib"; then 67119c9ff80cSmrg dlopenmodule="$dlpremoduletest" 67129c9ff80cSmrg break 67139c9ff80cSmrg fi 67149c9ff80cSmrg done 67159c9ff80cSmrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 67166fae4e5dSmrg echo 67179c9ff80cSmrg if test "$linkmode" = prog; then 67189c9ff80cSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 67199c9ff80cSmrg else 67209c9ff80cSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 67219c9ff80cSmrg fi 67229c9ff80cSmrg $ECHO "*** $linklib is not portable!" 67239c9ff80cSmrg fi 67249c9ff80cSmrg if test "$linkmode" = lib && 67259c9ff80cSmrg test "$hardcode_into_libs" = yes; then 67269c9ff80cSmrg # Hardcode the library path. 67279c9ff80cSmrg # Skip directories that are in the system default run-time 67289c9ff80cSmrg # search path. 67299c9ff80cSmrg case " $sys_lib_dlsearch_path " in 67309c9ff80cSmrg *" $absdir "*) ;; 67319c9ff80cSmrg *) 67329c9ff80cSmrg case "$compile_rpath " in 67339c9ff80cSmrg *" $absdir "*) ;; 67346fae4e5dSmrg *) func_append compile_rpath " $absdir" ;; 67359c9ff80cSmrg esac 67369c9ff80cSmrg ;; 67379c9ff80cSmrg esac 67389c9ff80cSmrg case " $sys_lib_dlsearch_path " in 67399c9ff80cSmrg *" $libdir "*) ;; 67409c9ff80cSmrg *) 67419c9ff80cSmrg case "$finalize_rpath " in 67429c9ff80cSmrg *" $libdir "*) ;; 67436fae4e5dSmrg *) func_append finalize_rpath " $libdir" ;; 67449c9ff80cSmrg esac 67459c9ff80cSmrg ;; 67469c9ff80cSmrg esac 67479c9ff80cSmrg fi 67489c9ff80cSmrg 67499c9ff80cSmrg if test -n "$old_archive_from_expsyms_cmds"; then 67509c9ff80cSmrg # figure out the soname 67519c9ff80cSmrg set dummy $library_names 67529c9ff80cSmrg shift 67539c9ff80cSmrg realname="$1" 67549c9ff80cSmrg shift 67559c9ff80cSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 67569c9ff80cSmrg # use dlname if we got it. it's perfectly good, no? 67579c9ff80cSmrg if test -n "$dlname"; then 67589c9ff80cSmrg soname="$dlname" 67599c9ff80cSmrg elif test -n "$soname_spec"; then 67609c9ff80cSmrg # bleh windows 67619c9ff80cSmrg case $host in 67629c9ff80cSmrg *cygwin* | mingw* | *cegcc*) 67639c9ff80cSmrg func_arith $current - $age 67649c9ff80cSmrg major=$func_arith_result 67659c9ff80cSmrg versuffix="-$major" 67669c9ff80cSmrg ;; 67679c9ff80cSmrg esac 67689c9ff80cSmrg eval soname=\"$soname_spec\" 67699c9ff80cSmrg else 67709c9ff80cSmrg soname="$realname" 67719c9ff80cSmrg fi 67729c9ff80cSmrg 67739c9ff80cSmrg # Make a new name for the extract_expsyms_cmds to use 67749c9ff80cSmrg soroot="$soname" 67759c9ff80cSmrg func_basename "$soroot" 67769c9ff80cSmrg soname="$func_basename_result" 67779c9ff80cSmrg func_stripname 'lib' '.dll' "$soname" 67789c9ff80cSmrg newlib=libimp-$func_stripname_result.a 67799c9ff80cSmrg 67809c9ff80cSmrg # If the library has no export list, then create one now 67819c9ff80cSmrg if test -f "$output_objdir/$soname-def"; then : 67829c9ff80cSmrg else 67839c9ff80cSmrg func_verbose "extracting exported symbol list from \`$soname'" 67849c9ff80cSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 67859c9ff80cSmrg fi 67869c9ff80cSmrg 67879c9ff80cSmrg # Create $newlib 67889c9ff80cSmrg if test -f "$output_objdir/$newlib"; then :; else 67899c9ff80cSmrg func_verbose "generating import library for \`$soname'" 67909c9ff80cSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 67919c9ff80cSmrg fi 67929c9ff80cSmrg # make sure the library variables are pointing to the new library 67939c9ff80cSmrg dir=$output_objdir 67949c9ff80cSmrg linklib=$newlib 67959c9ff80cSmrg fi # test -n "$old_archive_from_expsyms_cmds" 67969c9ff80cSmrg 67976fae4e5dSmrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 67989c9ff80cSmrg add_shlibpath= 67999c9ff80cSmrg add_dir= 68009c9ff80cSmrg add= 68019c9ff80cSmrg lib_linked=yes 68029c9ff80cSmrg case $hardcode_action in 68039c9ff80cSmrg immediate | unsupported) 68049c9ff80cSmrg if test "$hardcode_direct" = no; then 68059c9ff80cSmrg add="$dir/$linklib" 68069c9ff80cSmrg case $host in 68079c9ff80cSmrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 68089c9ff80cSmrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 68099c9ff80cSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 68109c9ff80cSmrg *-*-unixware7*) add_dir="-L$dir" ;; 68119c9ff80cSmrg *-*-darwin* ) 68129c9ff80cSmrg # if the lib is a (non-dlopened) module then we can not 68139c9ff80cSmrg # link against it, someone is ignoring the earlier warnings 68149c9ff80cSmrg if /usr/bin/file -L $add 2> /dev/null | 68159c9ff80cSmrg $GREP ": [^:]* bundle" >/dev/null ; then 68169c9ff80cSmrg if test "X$dlopenmodule" != "X$lib"; then 68179c9ff80cSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 68189c9ff80cSmrg if test -z "$old_library" ; then 68196fae4e5dSmrg echo 68206fae4e5dSmrg echo "*** And there doesn't seem to be a static archive available" 68216fae4e5dSmrg echo "*** The link will probably fail, sorry" 68229c9ff80cSmrg else 68239c9ff80cSmrg add="$dir/$old_library" 68249c9ff80cSmrg fi 68259c9ff80cSmrg elif test -n "$old_library"; then 68269c9ff80cSmrg add="$dir/$old_library" 68279c9ff80cSmrg fi 68289c9ff80cSmrg fi 68299c9ff80cSmrg esac 68309c9ff80cSmrg elif test "$hardcode_minus_L" = no; then 68319c9ff80cSmrg case $host in 68329c9ff80cSmrg *-*-sunos*) add_shlibpath="$dir" ;; 68339c9ff80cSmrg esac 68349c9ff80cSmrg add_dir="-L$dir" 68359c9ff80cSmrg add="-l$name" 68369c9ff80cSmrg elif test "$hardcode_shlibpath_var" = no; then 68379c9ff80cSmrg add_shlibpath="$dir" 68389c9ff80cSmrg add="-l$name" 68399c9ff80cSmrg else 68409c9ff80cSmrg lib_linked=no 68419c9ff80cSmrg fi 68429c9ff80cSmrg ;; 68439c9ff80cSmrg relink) 68449c9ff80cSmrg if test "$hardcode_direct" = yes && 68459c9ff80cSmrg test "$hardcode_direct_absolute" = no; then 68469c9ff80cSmrg add="$dir/$linklib" 68479c9ff80cSmrg elif test "$hardcode_minus_L" = yes; then 684889c04b6cSmrg add_dir="-L$absdir" 68499c9ff80cSmrg # Try looking first in the location we're being installed to. 68509c9ff80cSmrg if test -n "$inst_prefix_dir"; then 68519c9ff80cSmrg case $libdir in 68529c9ff80cSmrg [\\/]*) 68536fae4e5dSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 68549c9ff80cSmrg ;; 68559c9ff80cSmrg esac 68569c9ff80cSmrg fi 68579c9ff80cSmrg add="-l$name" 68589c9ff80cSmrg elif test "$hardcode_shlibpath_var" = yes; then 68599c9ff80cSmrg add_shlibpath="$dir" 68609c9ff80cSmrg add="-l$name" 68619c9ff80cSmrg else 68629c9ff80cSmrg lib_linked=no 68639c9ff80cSmrg fi 68649c9ff80cSmrg ;; 68659c9ff80cSmrg *) lib_linked=no ;; 68669c9ff80cSmrg esac 68679c9ff80cSmrg 68689c9ff80cSmrg if test "$lib_linked" != yes; then 68699c9ff80cSmrg func_fatal_configuration "unsupported hardcode properties" 68709c9ff80cSmrg fi 68719c9ff80cSmrg 68729c9ff80cSmrg if test -n "$add_shlibpath"; then 68739c9ff80cSmrg case :$compile_shlibpath: in 68749c9ff80cSmrg *":$add_shlibpath:"*) ;; 68756fae4e5dSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 68769c9ff80cSmrg esac 68779c9ff80cSmrg fi 68789c9ff80cSmrg if test "$linkmode" = prog; then 68799c9ff80cSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 68809c9ff80cSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 68819c9ff80cSmrg else 68829c9ff80cSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 68839c9ff80cSmrg test -n "$add" && deplibs="$add $deplibs" 68849c9ff80cSmrg if test "$hardcode_direct" != yes && 68859c9ff80cSmrg test "$hardcode_minus_L" != yes && 68869c9ff80cSmrg test "$hardcode_shlibpath_var" = yes; then 68879c9ff80cSmrg case :$finalize_shlibpath: in 68889c9ff80cSmrg *":$libdir:"*) ;; 68896fae4e5dSmrg *) func_append finalize_shlibpath "$libdir:" ;; 68909c9ff80cSmrg esac 68919c9ff80cSmrg fi 68929c9ff80cSmrg fi 68939c9ff80cSmrg fi 68949c9ff80cSmrg 68956fae4e5dSmrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 68969c9ff80cSmrg add_shlibpath= 68979c9ff80cSmrg add_dir= 68989c9ff80cSmrg add= 68999c9ff80cSmrg # Finalize command for both is simple: just hardcode it. 69009c9ff80cSmrg if test "$hardcode_direct" = yes && 69019c9ff80cSmrg test "$hardcode_direct_absolute" = no; then 69029c9ff80cSmrg add="$libdir/$linklib" 69039c9ff80cSmrg elif test "$hardcode_minus_L" = yes; then 69049c9ff80cSmrg add_dir="-L$libdir" 69059c9ff80cSmrg add="-l$name" 69069c9ff80cSmrg elif test "$hardcode_shlibpath_var" = yes; then 69079c9ff80cSmrg case :$finalize_shlibpath: in 69089c9ff80cSmrg *":$libdir:"*) ;; 69096fae4e5dSmrg *) func_append finalize_shlibpath "$libdir:" ;; 69109c9ff80cSmrg esac 69119c9ff80cSmrg add="-l$name" 69129c9ff80cSmrg elif test "$hardcode_automatic" = yes; then 69139c9ff80cSmrg if test -n "$inst_prefix_dir" && 69149c9ff80cSmrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 69159c9ff80cSmrg add="$inst_prefix_dir$libdir/$linklib" 69169c9ff80cSmrg else 69179c9ff80cSmrg add="$libdir/$linklib" 69189c9ff80cSmrg fi 69199c9ff80cSmrg else 69209c9ff80cSmrg # We cannot seem to hardcode it, guess we'll fake it. 69219c9ff80cSmrg add_dir="-L$libdir" 69229c9ff80cSmrg # Try looking first in the location we're being installed to. 69239c9ff80cSmrg if test -n "$inst_prefix_dir"; then 69249c9ff80cSmrg case $libdir in 69259c9ff80cSmrg [\\/]*) 69266fae4e5dSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 69279c9ff80cSmrg ;; 69289c9ff80cSmrg esac 69299c9ff80cSmrg fi 69309c9ff80cSmrg add="-l$name" 69319c9ff80cSmrg fi 69329c9ff80cSmrg 69339c9ff80cSmrg if test "$linkmode" = prog; then 69349c9ff80cSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 69359c9ff80cSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 69369c9ff80cSmrg else 69379c9ff80cSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 69389c9ff80cSmrg test -n "$add" && deplibs="$add $deplibs" 69399c9ff80cSmrg fi 69409c9ff80cSmrg fi 69419c9ff80cSmrg elif test "$linkmode" = prog; then 69429c9ff80cSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 69439c9ff80cSmrg # is not unsupported. This is valid on all known static and 69449c9ff80cSmrg # shared platforms. 69459c9ff80cSmrg if test "$hardcode_direct" != unsupported; then 69469c9ff80cSmrg test -n "$old_library" && linklib="$old_library" 69479c9ff80cSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 69489c9ff80cSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 69499c9ff80cSmrg else 69509c9ff80cSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 69519c9ff80cSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 69529c9ff80cSmrg fi 69539c9ff80cSmrg elif test "$build_libtool_libs" = yes; then 69549c9ff80cSmrg # Not a shared library 69559c9ff80cSmrg if test "$deplibs_check_method" != pass_all; then 69569c9ff80cSmrg # We're trying link a shared library against a static one 69579c9ff80cSmrg # but the system doesn't support it. 69589c9ff80cSmrg 69599c9ff80cSmrg # Just print a warning and add the library to dependency_libs so 69609c9ff80cSmrg # that the program can be linked against the static library. 69616fae4e5dSmrg echo 69629c9ff80cSmrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 69636fae4e5dSmrg echo "*** I have the capability to make that library automatically link in when" 69646fae4e5dSmrg echo "*** you link to this library. But I can only do this if you have a" 69656fae4e5dSmrg echo "*** shared version of the library, which you do not appear to have." 69669c9ff80cSmrg if test "$module" = yes; then 69676fae4e5dSmrg echo "*** But as you try to build a module library, libtool will still create " 69686fae4e5dSmrg echo "*** a static module, that should work as long as the dlopening application" 69696fae4e5dSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 69709c9ff80cSmrg if test -z "$global_symbol_pipe"; then 69716fae4e5dSmrg echo 69726fae4e5dSmrg echo "*** However, this would only work if libtool was able to extract symbol" 69736fae4e5dSmrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 69746fae4e5dSmrg echo "*** not find such a program. So, this module is probably useless." 69756fae4e5dSmrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 69769c9ff80cSmrg fi 69779c9ff80cSmrg if test "$build_old_libs" = no; then 69789c9ff80cSmrg build_libtool_libs=module 69799c9ff80cSmrg build_old_libs=yes 69809c9ff80cSmrg else 69819c9ff80cSmrg build_libtool_libs=no 69829c9ff80cSmrg fi 69839c9ff80cSmrg fi 69849c9ff80cSmrg else 69859c9ff80cSmrg deplibs="$dir/$old_library $deplibs" 69869c9ff80cSmrg link_static=yes 69879c9ff80cSmrg fi 69889c9ff80cSmrg fi # link shared/static library? 69899c9ff80cSmrg 69909c9ff80cSmrg if test "$linkmode" = lib; then 69919c9ff80cSmrg if test -n "$dependency_libs" && 69929c9ff80cSmrg { test "$hardcode_into_libs" != yes || 69939c9ff80cSmrg test "$build_old_libs" = yes || 69949c9ff80cSmrg test "$link_static" = yes; }; then 69959c9ff80cSmrg # Extract -R from dependency_libs 69969c9ff80cSmrg temp_deplibs= 69979c9ff80cSmrg for libdir in $dependency_libs; do 69989c9ff80cSmrg case $libdir in 69999c9ff80cSmrg -R*) func_stripname '-R' '' "$libdir" 70009c9ff80cSmrg temp_xrpath=$func_stripname_result 70019c9ff80cSmrg case " $xrpath " in 70029c9ff80cSmrg *" $temp_xrpath "*) ;; 70036fae4e5dSmrg *) func_append xrpath " $temp_xrpath";; 70049c9ff80cSmrg esac;; 70056fae4e5dSmrg *) func_append temp_deplibs " $libdir";; 70069c9ff80cSmrg esac 70079c9ff80cSmrg done 70089c9ff80cSmrg dependency_libs="$temp_deplibs" 70099c9ff80cSmrg fi 70109c9ff80cSmrg 70116fae4e5dSmrg func_append newlib_search_path " $absdir" 70129c9ff80cSmrg # Link against this library 70139c9ff80cSmrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 70149c9ff80cSmrg # ... and its dependency_libs 70159c9ff80cSmrg tmp_libs= 70169c9ff80cSmrg for deplib in $dependency_libs; do 70179c9ff80cSmrg newdependency_libs="$deplib $newdependency_libs" 70186fae4e5dSmrg case $deplib in 70196fae4e5dSmrg -L*) func_stripname '-L' '' "$deplib" 70206fae4e5dSmrg func_resolve_sysroot "$func_stripname_result";; 70216fae4e5dSmrg *) func_resolve_sysroot "$deplib" ;; 70226fae4e5dSmrg esac 70236fae4e5dSmrg if $opt_preserve_dup_deps ; then 70249c9ff80cSmrg case "$tmp_libs " in 70256fae4e5dSmrg *" $func_resolve_sysroot_result "*) 70266fae4e5dSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 70279c9ff80cSmrg esac 70289c9ff80cSmrg fi 70296fae4e5dSmrg func_append tmp_libs " $func_resolve_sysroot_result" 70309c9ff80cSmrg done 70319c9ff80cSmrg 70329c9ff80cSmrg if test "$link_all_deplibs" != no; then 70339c9ff80cSmrg # Add the search paths of all dependency libraries 70349c9ff80cSmrg for deplib in $dependency_libs; do 70356fae4e5dSmrg path= 70369c9ff80cSmrg case $deplib in 70379c9ff80cSmrg -L*) path="$deplib" ;; 70389c9ff80cSmrg *.la) 70396fae4e5dSmrg func_resolve_sysroot "$deplib" 70406fae4e5dSmrg deplib=$func_resolve_sysroot_result 70419c9ff80cSmrg func_dirname "$deplib" "" "." 70426fae4e5dSmrg dir=$func_dirname_result 70439c9ff80cSmrg # We need an absolute path. 70449c9ff80cSmrg case $dir in 70459c9ff80cSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 70469c9ff80cSmrg *) 70479c9ff80cSmrg absdir=`cd "$dir" && pwd` 70489c9ff80cSmrg if test -z "$absdir"; then 70499c9ff80cSmrg func_warning "cannot determine absolute directory name of \`$dir'" 70509c9ff80cSmrg absdir="$dir" 70519c9ff80cSmrg fi 70529c9ff80cSmrg ;; 70539c9ff80cSmrg esac 70549c9ff80cSmrg if $GREP "^installed=no" $deplib > /dev/null; then 70559c9ff80cSmrg case $host in 70569c9ff80cSmrg *-*-darwin*) 70579c9ff80cSmrg depdepl= 70589c9ff80cSmrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 70599c9ff80cSmrg if test -n "$deplibrary_names" ; then 70609c9ff80cSmrg for tmp in $deplibrary_names ; do 70619c9ff80cSmrg depdepl=$tmp 70629c9ff80cSmrg done 70639c9ff80cSmrg if test -f "$absdir/$objdir/$depdepl" ; then 70649c9ff80cSmrg depdepl="$absdir/$objdir/$depdepl" 70659c9ff80cSmrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 70669c9ff80cSmrg if test -z "$darwin_install_name"; then 70679c9ff80cSmrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 70689c9ff80cSmrg fi 70696fae4e5dSmrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 70706fae4e5dSmrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 70719c9ff80cSmrg path= 70729c9ff80cSmrg fi 70739c9ff80cSmrg fi 70749c9ff80cSmrg ;; 70759c9ff80cSmrg *) 70769c9ff80cSmrg path="-L$absdir/$objdir" 70779c9ff80cSmrg ;; 70789c9ff80cSmrg esac 70799c9ff80cSmrg else 70809c9ff80cSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 70819c9ff80cSmrg test -z "$libdir" && \ 70829c9ff80cSmrg func_fatal_error "\`$deplib' is not a valid libtool archive" 70839c9ff80cSmrg test "$absdir" != "$libdir" && \ 70849c9ff80cSmrg func_warning "\`$deplib' seems to be moved" 70859c9ff80cSmrg 70869c9ff80cSmrg path="-L$absdir" 70879c9ff80cSmrg fi 70889c9ff80cSmrg ;; 70899c9ff80cSmrg esac 70909c9ff80cSmrg case " $deplibs " in 70919c9ff80cSmrg *" $path "*) ;; 70929c9ff80cSmrg *) deplibs="$path $deplibs" ;; 70939c9ff80cSmrg esac 70949c9ff80cSmrg done 70959c9ff80cSmrg fi # link_all_deplibs != no 70969c9ff80cSmrg fi # linkmode = lib 70979c9ff80cSmrg done # for deplib in $libs 70989c9ff80cSmrg if test "$pass" = link; then 70999c9ff80cSmrg if test "$linkmode" = "prog"; then 71009c9ff80cSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 71019c9ff80cSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 71029c9ff80cSmrg else 71036fae4e5dSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 71049c9ff80cSmrg fi 71059c9ff80cSmrg fi 71069c9ff80cSmrg dependency_libs="$newdependency_libs" 71079c9ff80cSmrg if test "$pass" = dlpreopen; then 71089c9ff80cSmrg # Link the dlpreopened libraries before other libraries 71099c9ff80cSmrg for deplib in $save_deplibs; do 71109c9ff80cSmrg deplibs="$deplib $deplibs" 71119c9ff80cSmrg done 71129c9ff80cSmrg fi 71139c9ff80cSmrg if test "$pass" != dlopen; then 71149c9ff80cSmrg if test "$pass" != conv; then 71159c9ff80cSmrg # Make sure lib_search_path contains only unique directories. 71169c9ff80cSmrg lib_search_path= 71179c9ff80cSmrg for dir in $newlib_search_path; do 71189c9ff80cSmrg case "$lib_search_path " in 71199c9ff80cSmrg *" $dir "*) ;; 71206fae4e5dSmrg *) func_append lib_search_path " $dir" ;; 71219c9ff80cSmrg esac 71229c9ff80cSmrg done 71239c9ff80cSmrg newlib_search_path= 71249c9ff80cSmrg fi 71259c9ff80cSmrg 71269c9ff80cSmrg if test "$linkmode,$pass" != "prog,link"; then 71279c9ff80cSmrg vars="deplibs" 71289c9ff80cSmrg else 71299c9ff80cSmrg vars="compile_deplibs finalize_deplibs" 71309c9ff80cSmrg fi 71319c9ff80cSmrg for var in $vars dependency_libs; do 71329c9ff80cSmrg # Add libraries to $var in reverse order 71339c9ff80cSmrg eval tmp_libs=\"\$$var\" 71349c9ff80cSmrg new_libs= 71359c9ff80cSmrg for deplib in $tmp_libs; do 71369c9ff80cSmrg # FIXME: Pedantically, this is the right thing to do, so 71379c9ff80cSmrg # that some nasty dependency loop isn't accidentally 71389c9ff80cSmrg # broken: 71399c9ff80cSmrg #new_libs="$deplib $new_libs" 71409c9ff80cSmrg # Pragmatically, this seems to cause very few problems in 71419c9ff80cSmrg # practice: 71429c9ff80cSmrg case $deplib in 71439c9ff80cSmrg -L*) new_libs="$deplib $new_libs" ;; 71449c9ff80cSmrg -R*) ;; 71459c9ff80cSmrg *) 71469c9ff80cSmrg # And here is the reason: when a library appears more 71479c9ff80cSmrg # than once as an explicit dependence of a library, or 71489c9ff80cSmrg # is implicitly linked in more than once by the 71499c9ff80cSmrg # compiler, it is considered special, and multiple 71509c9ff80cSmrg # occurrences thereof are not removed. Compare this 71519c9ff80cSmrg # with having the same library being listed as a 71529c9ff80cSmrg # dependency of multiple other libraries: in this case, 71539c9ff80cSmrg # we know (pedantically, we assume) the library does not 71549c9ff80cSmrg # need to be listed more than once, so we keep only the 71559c9ff80cSmrg # last copy. This is not always right, but it is rare 71569c9ff80cSmrg # enough that we require users that really mean to play 71579c9ff80cSmrg # such unportable linking tricks to link the library 71589c9ff80cSmrg # using -Wl,-lname, so that libtool does not consider it 71599c9ff80cSmrg # for duplicate removal. 71609c9ff80cSmrg case " $specialdeplibs " in 71619c9ff80cSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 71629c9ff80cSmrg *) 71639c9ff80cSmrg case " $new_libs " in 71649c9ff80cSmrg *" $deplib "*) ;; 71659c9ff80cSmrg *) new_libs="$deplib $new_libs" ;; 71669c9ff80cSmrg esac 71679c9ff80cSmrg ;; 71689c9ff80cSmrg esac 71699c9ff80cSmrg ;; 71709c9ff80cSmrg esac 71719c9ff80cSmrg done 71729c9ff80cSmrg tmp_libs= 71739c9ff80cSmrg for deplib in $new_libs; do 71749c9ff80cSmrg case $deplib in 71759c9ff80cSmrg -L*) 71769c9ff80cSmrg case " $tmp_libs " in 71779c9ff80cSmrg *" $deplib "*) ;; 71786fae4e5dSmrg *) func_append tmp_libs " $deplib" ;; 71799c9ff80cSmrg esac 71809c9ff80cSmrg ;; 71816fae4e5dSmrg *) func_append tmp_libs " $deplib" ;; 71829c9ff80cSmrg esac 71839c9ff80cSmrg done 71849c9ff80cSmrg eval $var=\"$tmp_libs\" 71859c9ff80cSmrg done # for var 71869c9ff80cSmrg fi 71879c9ff80cSmrg # Last step: remove runtime libs from dependency_libs 71889c9ff80cSmrg # (they stay in deplibs) 71899c9ff80cSmrg tmp_libs= 71909c9ff80cSmrg for i in $dependency_libs ; do 71919c9ff80cSmrg case " $predeps $postdeps $compiler_lib_search_path " in 71929c9ff80cSmrg *" $i "*) 71939c9ff80cSmrg i="" 71949c9ff80cSmrg ;; 71959c9ff80cSmrg esac 71969c9ff80cSmrg if test -n "$i" ; then 71976fae4e5dSmrg func_append tmp_libs " $i" 71989c9ff80cSmrg fi 71999c9ff80cSmrg done 72009c9ff80cSmrg dependency_libs=$tmp_libs 72019c9ff80cSmrg done # for pass 72029c9ff80cSmrg if test "$linkmode" = prog; then 72039c9ff80cSmrg dlfiles="$newdlfiles" 72049c9ff80cSmrg fi 72059c9ff80cSmrg if test "$linkmode" = prog || test "$linkmode" = lib; then 72069c9ff80cSmrg dlprefiles="$newdlprefiles" 72079c9ff80cSmrg fi 72089c9ff80cSmrg 72099c9ff80cSmrg case $linkmode in 72109c9ff80cSmrg oldlib) 72119c9ff80cSmrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 72129c9ff80cSmrg func_warning "\`-dlopen' is ignored for archives" 72139c9ff80cSmrg fi 72149c9ff80cSmrg 72159c9ff80cSmrg case " $deplibs" in 72169c9ff80cSmrg *\ -l* | *\ -L*) 72179c9ff80cSmrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 72189c9ff80cSmrg esac 72199c9ff80cSmrg 72209c9ff80cSmrg test -n "$rpath" && \ 72219c9ff80cSmrg func_warning "\`-rpath' is ignored for archives" 72229c9ff80cSmrg 72239c9ff80cSmrg test -n "$xrpath" && \ 72249c9ff80cSmrg func_warning "\`-R' is ignored for archives" 72259c9ff80cSmrg 72269c9ff80cSmrg test -n "$vinfo" && \ 72279c9ff80cSmrg func_warning "\`-version-info/-version-number' is ignored for archives" 72289c9ff80cSmrg 72299c9ff80cSmrg test -n "$release" && \ 72309c9ff80cSmrg func_warning "\`-release' is ignored for archives" 72319c9ff80cSmrg 72329c9ff80cSmrg test -n "$export_symbols$export_symbols_regex" && \ 72339c9ff80cSmrg func_warning "\`-export-symbols' is ignored for archives" 72349c9ff80cSmrg 72359c9ff80cSmrg # Now set the variables for building old libraries. 72369c9ff80cSmrg build_libtool_libs=no 72379c9ff80cSmrg oldlibs="$output" 72386fae4e5dSmrg func_append objs "$old_deplibs" 72399c9ff80cSmrg ;; 72409c9ff80cSmrg 72419c9ff80cSmrg lib) 72429c9ff80cSmrg # Make sure we only generate libraries of the form `libNAME.la'. 72439c9ff80cSmrg case $outputname in 72449c9ff80cSmrg lib*) 72459c9ff80cSmrg func_stripname 'lib' '.la' "$outputname" 72469c9ff80cSmrg name=$func_stripname_result 72479c9ff80cSmrg eval shared_ext=\"$shrext_cmds\" 72489c9ff80cSmrg eval libname=\"$libname_spec\" 72499c9ff80cSmrg ;; 72509c9ff80cSmrg *) 72519c9ff80cSmrg test "$module" = no && \ 72529c9ff80cSmrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 72539c9ff80cSmrg 72549c9ff80cSmrg if test "$need_lib_prefix" != no; then 72559c9ff80cSmrg # Add the "lib" prefix for modules if required 72569c9ff80cSmrg func_stripname '' '.la' "$outputname" 72579c9ff80cSmrg name=$func_stripname_result 72589c9ff80cSmrg eval shared_ext=\"$shrext_cmds\" 72599c9ff80cSmrg eval libname=\"$libname_spec\" 72609c9ff80cSmrg else 72619c9ff80cSmrg func_stripname '' '.la' "$outputname" 72629c9ff80cSmrg libname=$func_stripname_result 72639c9ff80cSmrg fi 72649c9ff80cSmrg ;; 72659c9ff80cSmrg esac 72669c9ff80cSmrg 72679c9ff80cSmrg if test -n "$objs"; then 72689c9ff80cSmrg if test "$deplibs_check_method" != pass_all; then 72699c9ff80cSmrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 72709c9ff80cSmrg else 72716fae4e5dSmrg echo 72729c9ff80cSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 72739c9ff80cSmrg $ECHO "*** objects $objs is not portable!" 72746fae4e5dSmrg func_append libobjs " $objs" 72759c9ff80cSmrg fi 72769c9ff80cSmrg fi 72779c9ff80cSmrg 72789c9ff80cSmrg test "$dlself" != no && \ 72799c9ff80cSmrg func_warning "\`-dlopen self' is ignored for libtool libraries" 72809c9ff80cSmrg 72819c9ff80cSmrg set dummy $rpath 72829c9ff80cSmrg shift 72839c9ff80cSmrg test "$#" -gt 1 && \ 72849c9ff80cSmrg func_warning "ignoring multiple \`-rpath's for a libtool library" 72859c9ff80cSmrg 72869c9ff80cSmrg install_libdir="$1" 72879c9ff80cSmrg 72889c9ff80cSmrg oldlibs= 72899c9ff80cSmrg if test -z "$rpath"; then 72909c9ff80cSmrg if test "$build_libtool_libs" = yes; then 72919c9ff80cSmrg # Building a libtool convenience library. 72929c9ff80cSmrg # Some compilers have problems with a `.al' extension so 72939c9ff80cSmrg # convenience libraries should have the same extension an 72949c9ff80cSmrg # archive normally would. 72959c9ff80cSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 72969c9ff80cSmrg build_libtool_libs=convenience 72979c9ff80cSmrg build_old_libs=yes 72989c9ff80cSmrg fi 72999c9ff80cSmrg 73009c9ff80cSmrg test -n "$vinfo" && \ 73019c9ff80cSmrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 73029c9ff80cSmrg 73039c9ff80cSmrg test -n "$release" && \ 73049c9ff80cSmrg func_warning "\`-release' is ignored for convenience libraries" 73059c9ff80cSmrg else 73069c9ff80cSmrg 73079c9ff80cSmrg # Parse the version information argument. 73089c9ff80cSmrg save_ifs="$IFS"; IFS=':' 73099c9ff80cSmrg set dummy $vinfo 0 0 0 73109c9ff80cSmrg shift 73119c9ff80cSmrg IFS="$save_ifs" 73129c9ff80cSmrg 73139c9ff80cSmrg test -n "$7" && \ 73149c9ff80cSmrg func_fatal_help "too many parameters to \`-version-info'" 73159c9ff80cSmrg 73169c9ff80cSmrg # convert absolute version numbers to libtool ages 73179c9ff80cSmrg # this retains compatibility with .la files and attempts 73189c9ff80cSmrg # to make the code below a bit more comprehensible 73199c9ff80cSmrg 73209c9ff80cSmrg case $vinfo_number in 73219c9ff80cSmrg yes) 73229c9ff80cSmrg number_major="$1" 73239c9ff80cSmrg number_minor="$2" 73249c9ff80cSmrg number_revision="$3" 73259c9ff80cSmrg # 73269c9ff80cSmrg # There are really only two kinds -- those that 73279c9ff80cSmrg # use the current revision as the major version 73289c9ff80cSmrg # and those that subtract age and use age as 73299c9ff80cSmrg # a minor version. But, then there is irix 73309c9ff80cSmrg # which has an extra 1 added just for fun 73319c9ff80cSmrg # 73329c9ff80cSmrg case $version_type in 733389c04b6cSmrg # correct linux to gnu/linux during the next big refactor 73349c9ff80cSmrg darwin|linux|osf|windows|none) 73359c9ff80cSmrg func_arith $number_major + $number_minor 73369c9ff80cSmrg current=$func_arith_result 73379c9ff80cSmrg age="$number_minor" 73389c9ff80cSmrg revision="$number_revision" 73399c9ff80cSmrg ;; 73406fae4e5dSmrg freebsd-aout|freebsd-elf|qnx|sunos) 73419c9ff80cSmrg current="$number_major" 73429c9ff80cSmrg revision="$number_minor" 73439c9ff80cSmrg age="0" 73449c9ff80cSmrg ;; 73459c9ff80cSmrg irix|nonstopux) 73469c9ff80cSmrg func_arith $number_major + $number_minor 73479c9ff80cSmrg current=$func_arith_result 73489c9ff80cSmrg age="$number_minor" 73499c9ff80cSmrg revision="$number_minor" 73509c9ff80cSmrg lt_irix_increment=no 73519c9ff80cSmrg ;; 73529c9ff80cSmrg esac 73539c9ff80cSmrg ;; 73549c9ff80cSmrg no) 73559c9ff80cSmrg current="$1" 73569c9ff80cSmrg revision="$2" 73579c9ff80cSmrg age="$3" 73589c9ff80cSmrg ;; 73599c9ff80cSmrg esac 73609c9ff80cSmrg 73619c9ff80cSmrg # Check that each of the things are valid numbers. 73629c9ff80cSmrg case $current in 73639c9ff80cSmrg 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]) ;; 73649c9ff80cSmrg *) 73659c9ff80cSmrg func_error "CURRENT \`$current' must be a nonnegative integer" 73669c9ff80cSmrg func_fatal_error "\`$vinfo' is not valid version information" 73679c9ff80cSmrg ;; 73689c9ff80cSmrg esac 73699c9ff80cSmrg 73709c9ff80cSmrg case $revision in 73719c9ff80cSmrg 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]) ;; 73729c9ff80cSmrg *) 73739c9ff80cSmrg func_error "REVISION \`$revision' must be a nonnegative integer" 73749c9ff80cSmrg func_fatal_error "\`$vinfo' is not valid version information" 73759c9ff80cSmrg ;; 73769c9ff80cSmrg esac 73779c9ff80cSmrg 73789c9ff80cSmrg case $age in 73799c9ff80cSmrg 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]) ;; 73809c9ff80cSmrg *) 73819c9ff80cSmrg func_error "AGE \`$age' must be a nonnegative integer" 73829c9ff80cSmrg func_fatal_error "\`$vinfo' is not valid version information" 73839c9ff80cSmrg ;; 73849c9ff80cSmrg esac 73859c9ff80cSmrg 73869c9ff80cSmrg if test "$age" -gt "$current"; then 73879c9ff80cSmrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 73889c9ff80cSmrg func_fatal_error "\`$vinfo' is not valid version information" 73899c9ff80cSmrg fi 73909c9ff80cSmrg 73919c9ff80cSmrg # Calculate the version variables. 73929c9ff80cSmrg major= 73939c9ff80cSmrg versuffix= 73949c9ff80cSmrg verstring= 73959c9ff80cSmrg case $version_type in 73969c9ff80cSmrg none) ;; 73979c9ff80cSmrg 73989c9ff80cSmrg darwin) 73999c9ff80cSmrg # Like Linux, but with the current version available in 74009c9ff80cSmrg # verstring for coding it into the library header 74019c9ff80cSmrg func_arith $current - $age 74029c9ff80cSmrg major=.$func_arith_result 74039c9ff80cSmrg versuffix="$major.$age.$revision" 74049c9ff80cSmrg # Darwin ld doesn't like 0 for these options... 74059c9ff80cSmrg func_arith $current + 1 74069c9ff80cSmrg minor_current=$func_arith_result 74079c9ff80cSmrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 74089c9ff80cSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 74099c9ff80cSmrg ;; 74109c9ff80cSmrg 74119c9ff80cSmrg freebsd-aout) 74129c9ff80cSmrg major=".$current" 74139c9ff80cSmrg versuffix=".$current.$revision"; 74149c9ff80cSmrg ;; 74159c9ff80cSmrg 74169c9ff80cSmrg freebsd-elf) 74179c9ff80cSmrg major=".$current" 74189c9ff80cSmrg versuffix=".$current" 74199c9ff80cSmrg ;; 74209c9ff80cSmrg 74219c9ff80cSmrg irix | nonstopux) 74229c9ff80cSmrg if test "X$lt_irix_increment" = "Xno"; then 74239c9ff80cSmrg func_arith $current - $age 74249c9ff80cSmrg else 74259c9ff80cSmrg func_arith $current - $age + 1 74269c9ff80cSmrg fi 74279c9ff80cSmrg major=$func_arith_result 74289c9ff80cSmrg 74299c9ff80cSmrg case $version_type in 74309c9ff80cSmrg nonstopux) verstring_prefix=nonstopux ;; 74319c9ff80cSmrg *) verstring_prefix=sgi ;; 74329c9ff80cSmrg esac 74339c9ff80cSmrg verstring="$verstring_prefix$major.$revision" 74349c9ff80cSmrg 74359c9ff80cSmrg # Add in all the interfaces that we are compatible with. 74369c9ff80cSmrg loop=$revision 74379c9ff80cSmrg while test "$loop" -ne 0; do 74389c9ff80cSmrg func_arith $revision - $loop 74399c9ff80cSmrg iface=$func_arith_result 74409c9ff80cSmrg func_arith $loop - 1 74419c9ff80cSmrg loop=$func_arith_result 74429c9ff80cSmrg verstring="$verstring_prefix$major.$iface:$verstring" 74439c9ff80cSmrg done 74449c9ff80cSmrg 74459c9ff80cSmrg # Before this point, $major must not contain `.'. 74469c9ff80cSmrg major=.$major 74479c9ff80cSmrg versuffix="$major.$revision" 74489c9ff80cSmrg ;; 74499c9ff80cSmrg 745089c04b6cSmrg linux) # correct to gnu/linux during the next big refactor 74519c9ff80cSmrg func_arith $current - $age 74529c9ff80cSmrg major=.$func_arith_result 74539c9ff80cSmrg versuffix="$major.$age.$revision" 74549c9ff80cSmrg ;; 74559c9ff80cSmrg 74569c9ff80cSmrg osf) 74579c9ff80cSmrg func_arith $current - $age 74589c9ff80cSmrg major=.$func_arith_result 74599c9ff80cSmrg versuffix=".$current.$age.$revision" 74609c9ff80cSmrg verstring="$current.$age.$revision" 74619c9ff80cSmrg 74629c9ff80cSmrg # Add in all the interfaces that we are compatible with. 74639c9ff80cSmrg loop=$age 74649c9ff80cSmrg while test "$loop" -ne 0; do 74659c9ff80cSmrg func_arith $current - $loop 74669c9ff80cSmrg iface=$func_arith_result 74679c9ff80cSmrg func_arith $loop - 1 74689c9ff80cSmrg loop=$func_arith_result 74699c9ff80cSmrg verstring="$verstring:${iface}.0" 74709c9ff80cSmrg done 74719c9ff80cSmrg 74729c9ff80cSmrg # Make executables depend on our current version. 74736fae4e5dSmrg func_append verstring ":${current}.0" 74749c9ff80cSmrg ;; 74759c9ff80cSmrg 74769c9ff80cSmrg qnx) 74779c9ff80cSmrg major=".$current" 74789c9ff80cSmrg versuffix=".$current" 74799c9ff80cSmrg ;; 74809c9ff80cSmrg 74819c9ff80cSmrg sunos) 74829c9ff80cSmrg major=".$current" 74839c9ff80cSmrg versuffix=".$current.$revision" 74849c9ff80cSmrg ;; 74859c9ff80cSmrg 74869c9ff80cSmrg windows) 74879c9ff80cSmrg # Use '-' rather than '.', since we only want one 74889c9ff80cSmrg # extension on DOS 8.3 filesystems. 74899c9ff80cSmrg func_arith $current - $age 74909c9ff80cSmrg major=$func_arith_result 74919c9ff80cSmrg versuffix="-$major" 74929c9ff80cSmrg ;; 74939c9ff80cSmrg 74949c9ff80cSmrg *) 74959c9ff80cSmrg func_fatal_configuration "unknown library version type \`$version_type'" 74969c9ff80cSmrg ;; 74979c9ff80cSmrg esac 74989c9ff80cSmrg 74999c9ff80cSmrg # Clear the version info if we defaulted, and they specified a release. 75009c9ff80cSmrg if test -z "$vinfo" && test -n "$release"; then 75019c9ff80cSmrg major= 75029c9ff80cSmrg case $version_type in 75039c9ff80cSmrg darwin) 75049c9ff80cSmrg # we can't check for "0.0" in archive_cmds due to quoting 75059c9ff80cSmrg # problems, so we reset it completely 75069c9ff80cSmrg verstring= 75079c9ff80cSmrg ;; 75089c9ff80cSmrg *) 75099c9ff80cSmrg verstring="0.0" 75109c9ff80cSmrg ;; 75119c9ff80cSmrg esac 75129c9ff80cSmrg if test "$need_version" = no; then 75139c9ff80cSmrg versuffix= 75149c9ff80cSmrg else 75159c9ff80cSmrg versuffix=".0.0" 75169c9ff80cSmrg fi 75179c9ff80cSmrg fi 75189c9ff80cSmrg 75199c9ff80cSmrg # Remove version info from name if versioning should be avoided 75209c9ff80cSmrg if test "$avoid_version" = yes && test "$need_version" = no; then 75219c9ff80cSmrg major= 75229c9ff80cSmrg versuffix= 75239c9ff80cSmrg verstring="" 75249c9ff80cSmrg fi 75259c9ff80cSmrg 75269c9ff80cSmrg # Check to see if the archive will have undefined symbols. 75279c9ff80cSmrg if test "$allow_undefined" = yes; then 75289c9ff80cSmrg if test "$allow_undefined_flag" = unsupported; then 75299c9ff80cSmrg func_warning "undefined symbols not allowed in $host shared libraries" 75309c9ff80cSmrg build_libtool_libs=no 75319c9ff80cSmrg build_old_libs=yes 75329c9ff80cSmrg fi 75339c9ff80cSmrg else 75349c9ff80cSmrg # Don't allow undefined symbols. 75359c9ff80cSmrg allow_undefined_flag="$no_undefined_flag" 75369c9ff80cSmrg fi 75379c9ff80cSmrg 75389c9ff80cSmrg fi 75399c9ff80cSmrg 75409c9ff80cSmrg func_generate_dlsyms "$libname" "$libname" "yes" 75416fae4e5dSmrg func_append libobjs " $symfileobj" 75429c9ff80cSmrg test "X$libobjs" = "X " && libobjs= 75439c9ff80cSmrg 75446fae4e5dSmrg if test "$opt_mode" != relink; then 75459c9ff80cSmrg # Remove our outputs, but don't remove object files since they 75469c9ff80cSmrg # may have been created when compiling PIC objects. 75479c9ff80cSmrg removelist= 75489c9ff80cSmrg tempremovelist=`$ECHO "$output_objdir/*"` 75499c9ff80cSmrg for p in $tempremovelist; do 75509c9ff80cSmrg case $p in 75519c9ff80cSmrg *.$objext | *.gcno) 75529c9ff80cSmrg ;; 75539c9ff80cSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 75549c9ff80cSmrg if test "X$precious_files_regex" != "X"; then 75559c9ff80cSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 75569c9ff80cSmrg then 75579c9ff80cSmrg continue 75589c9ff80cSmrg fi 75599c9ff80cSmrg fi 75606fae4e5dSmrg func_append removelist " $p" 75619c9ff80cSmrg ;; 75629c9ff80cSmrg *) ;; 75639c9ff80cSmrg esac 75649c9ff80cSmrg done 75659c9ff80cSmrg test -n "$removelist" && \ 75669c9ff80cSmrg func_show_eval "${RM}r \$removelist" 75679c9ff80cSmrg fi 75689c9ff80cSmrg 75699c9ff80cSmrg # Now set the variables for building old libraries. 75709c9ff80cSmrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 75716fae4e5dSmrg func_append oldlibs " $output_objdir/$libname.$libext" 75729c9ff80cSmrg 75739c9ff80cSmrg # Transform .lo files to .o files. 75746fae4e5dSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 75759c9ff80cSmrg fi 75769c9ff80cSmrg 75779c9ff80cSmrg # Eliminate all temporary directories. 75789c9ff80cSmrg #for path in $notinst_path; do 75796fae4e5dSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 75806fae4e5dSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 75816fae4e5dSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 75829c9ff80cSmrg #done 75839c9ff80cSmrg 75849c9ff80cSmrg if test -n "$xrpath"; then 75859c9ff80cSmrg # If the user specified any rpath flags, then add them. 75869c9ff80cSmrg temp_xrpath= 75879c9ff80cSmrg for libdir in $xrpath; do 75886fae4e5dSmrg func_replace_sysroot "$libdir" 75896fae4e5dSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 75909c9ff80cSmrg case "$finalize_rpath " in 75919c9ff80cSmrg *" $libdir "*) ;; 75926fae4e5dSmrg *) func_append finalize_rpath " $libdir" ;; 75939c9ff80cSmrg esac 75949c9ff80cSmrg done 75959c9ff80cSmrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 75969c9ff80cSmrg dependency_libs="$temp_xrpath $dependency_libs" 75979c9ff80cSmrg fi 75989c9ff80cSmrg fi 75999c9ff80cSmrg 76009c9ff80cSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 76019c9ff80cSmrg old_dlfiles="$dlfiles" 76029c9ff80cSmrg dlfiles= 76039c9ff80cSmrg for lib in $old_dlfiles; do 76049c9ff80cSmrg case " $dlprefiles $dlfiles " in 76059c9ff80cSmrg *" $lib "*) ;; 76066fae4e5dSmrg *) func_append dlfiles " $lib" ;; 76079c9ff80cSmrg esac 76089c9ff80cSmrg done 76099c9ff80cSmrg 76109c9ff80cSmrg # Make sure dlprefiles contains only unique files 76119c9ff80cSmrg old_dlprefiles="$dlprefiles" 76129c9ff80cSmrg dlprefiles= 76139c9ff80cSmrg for lib in $old_dlprefiles; do 76149c9ff80cSmrg case "$dlprefiles " in 76159c9ff80cSmrg *" $lib "*) ;; 76166fae4e5dSmrg *) func_append dlprefiles " $lib" ;; 76179c9ff80cSmrg esac 76189c9ff80cSmrg done 76199c9ff80cSmrg 76209c9ff80cSmrg if test "$build_libtool_libs" = yes; then 76219c9ff80cSmrg if test -n "$rpath"; then 76229c9ff80cSmrg case $host in 76236fae4e5dSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 76249c9ff80cSmrg # these systems don't actually have a c library (as such)! 76259c9ff80cSmrg ;; 76269c9ff80cSmrg *-*-rhapsody* | *-*-darwin1.[012]) 76279c9ff80cSmrg # Rhapsody C library is in the System framework 76286fae4e5dSmrg func_append deplibs " System.ltframework" 76299c9ff80cSmrg ;; 76309c9ff80cSmrg *-*-netbsd*) 76319c9ff80cSmrg # Don't link with libc until the a.out ld.so is fixed. 76329c9ff80cSmrg ;; 76339c9ff80cSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 76349c9ff80cSmrg # Do not include libc due to us having libc/libc_r. 76359c9ff80cSmrg ;; 76369c9ff80cSmrg *-*-sco3.2v5* | *-*-sco5v6*) 76379c9ff80cSmrg # Causes problems with __ctype 76389c9ff80cSmrg ;; 76399c9ff80cSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 76409c9ff80cSmrg # Compiler inserts libc in the correct place for threads to work 76419c9ff80cSmrg ;; 76429c9ff80cSmrg *) 76439c9ff80cSmrg # Add libc to deplibs on all other systems if necessary. 76449c9ff80cSmrg if test "$build_libtool_need_lc" = "yes"; then 76456fae4e5dSmrg func_append deplibs " -lc" 76469c9ff80cSmrg fi 76479c9ff80cSmrg ;; 76489c9ff80cSmrg esac 76499c9ff80cSmrg fi 76509c9ff80cSmrg 76519c9ff80cSmrg # Transform deplibs into only deplibs that can be linked in shared. 76529c9ff80cSmrg name_save=$name 76539c9ff80cSmrg libname_save=$libname 76549c9ff80cSmrg release_save=$release 76559c9ff80cSmrg versuffix_save=$versuffix 76569c9ff80cSmrg major_save=$major 76579c9ff80cSmrg # I'm not sure if I'm treating the release correctly. I think 76589c9ff80cSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 76599c9ff80cSmrg # add it in twice. Is that correct? 76609c9ff80cSmrg release="" 76619c9ff80cSmrg versuffix="" 76629c9ff80cSmrg major="" 76639c9ff80cSmrg newdeplibs= 76649c9ff80cSmrg droppeddeps=no 76659c9ff80cSmrg case $deplibs_check_method in 76669c9ff80cSmrg pass_all) 76679c9ff80cSmrg # Don't check for shared/static. Everything works. 76689c9ff80cSmrg # This might be a little naive. We might want to check 76699c9ff80cSmrg # whether the library exists or not. But this is on 76709c9ff80cSmrg # osf3 & osf4 and I'm not really sure... Just 76719c9ff80cSmrg # implementing what was already the behavior. 76729c9ff80cSmrg newdeplibs=$deplibs 76739c9ff80cSmrg ;; 76749c9ff80cSmrg test_compile) 76759c9ff80cSmrg # This code stresses the "libraries are programs" paradigm to its 76769c9ff80cSmrg # limits. Maybe even breaks it. We compile a program, linking it 76779c9ff80cSmrg # against the deplibs as a proxy for the library. Then we can check 76789c9ff80cSmrg # whether they linked in statically or dynamically with ldd. 76799c9ff80cSmrg $opt_dry_run || $RM conftest.c 76809c9ff80cSmrg cat > conftest.c <<EOF 76819c9ff80cSmrg int main() { return 0; } 76829c9ff80cSmrgEOF 76839c9ff80cSmrg $opt_dry_run || $RM conftest 76849c9ff80cSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 76859c9ff80cSmrg ldd_output=`ldd conftest` 76869c9ff80cSmrg for i in $deplibs; do 76879c9ff80cSmrg case $i in 76889c9ff80cSmrg -l*) 76899c9ff80cSmrg func_stripname -l '' "$i" 76909c9ff80cSmrg name=$func_stripname_result 76919c9ff80cSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 76929c9ff80cSmrg case " $predeps $postdeps " in 76939c9ff80cSmrg *" $i "*) 76946fae4e5dSmrg func_append newdeplibs " $i" 76959c9ff80cSmrg i="" 76969c9ff80cSmrg ;; 76979c9ff80cSmrg esac 76989c9ff80cSmrg fi 76999c9ff80cSmrg if test -n "$i" ; then 77009c9ff80cSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 77019c9ff80cSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 77029c9ff80cSmrg set dummy $deplib_matches; shift 77039c9ff80cSmrg deplib_match=$1 77049c9ff80cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 77056fae4e5dSmrg func_append newdeplibs " $i" 77069c9ff80cSmrg else 77079c9ff80cSmrg droppeddeps=yes 77086fae4e5dSmrg echo 77099c9ff80cSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 77106fae4e5dSmrg echo "*** I have the capability to make that library automatically link in when" 77116fae4e5dSmrg echo "*** you link to this library. But I can only do this if you have a" 77126fae4e5dSmrg echo "*** shared version of the library, which I believe you do not have" 77136fae4e5dSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 77146fae4e5dSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 77159c9ff80cSmrg fi 77169c9ff80cSmrg fi 77179c9ff80cSmrg ;; 77189c9ff80cSmrg *) 77196fae4e5dSmrg func_append newdeplibs " $i" 77209c9ff80cSmrg ;; 77219c9ff80cSmrg esac 77229c9ff80cSmrg done 77239c9ff80cSmrg else 77249c9ff80cSmrg # Error occurred in the first compile. Let's try to salvage 77259c9ff80cSmrg # the situation: Compile a separate program for each library. 77269c9ff80cSmrg for i in $deplibs; do 77279c9ff80cSmrg case $i in 77289c9ff80cSmrg -l*) 77299c9ff80cSmrg func_stripname -l '' "$i" 77309c9ff80cSmrg name=$func_stripname_result 77319c9ff80cSmrg $opt_dry_run || $RM conftest 77329c9ff80cSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 77339c9ff80cSmrg ldd_output=`ldd conftest` 77349c9ff80cSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 77359c9ff80cSmrg case " $predeps $postdeps " in 77369c9ff80cSmrg *" $i "*) 77376fae4e5dSmrg func_append newdeplibs " $i" 77389c9ff80cSmrg i="" 77399c9ff80cSmrg ;; 77409c9ff80cSmrg esac 77419c9ff80cSmrg fi 77429c9ff80cSmrg if test -n "$i" ; then 77439c9ff80cSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 77449c9ff80cSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 77459c9ff80cSmrg set dummy $deplib_matches; shift 77469c9ff80cSmrg deplib_match=$1 77479c9ff80cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 77486fae4e5dSmrg func_append newdeplibs " $i" 77499c9ff80cSmrg else 77509c9ff80cSmrg droppeddeps=yes 77516fae4e5dSmrg echo 77529c9ff80cSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 77536fae4e5dSmrg echo "*** I have the capability to make that library automatically link in when" 77546fae4e5dSmrg echo "*** you link to this library. But I can only do this if you have a" 77556fae4e5dSmrg echo "*** shared version of the library, which you do not appear to have" 77566fae4e5dSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 77576fae4e5dSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 77589c9ff80cSmrg fi 77599c9ff80cSmrg fi 77609c9ff80cSmrg else 77619c9ff80cSmrg droppeddeps=yes 77626fae4e5dSmrg echo 77639c9ff80cSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 77646fae4e5dSmrg echo "*** make it link in! You will probably need to install it or some" 77656fae4e5dSmrg echo "*** library that it depends on before this library will be fully" 77666fae4e5dSmrg echo "*** functional. Installing it before continuing would be even better." 77679c9ff80cSmrg fi 77689c9ff80cSmrg ;; 77699c9ff80cSmrg *) 77706fae4e5dSmrg func_append newdeplibs " $i" 77719c9ff80cSmrg ;; 77729c9ff80cSmrg esac 77739c9ff80cSmrg done 77749c9ff80cSmrg fi 77759c9ff80cSmrg ;; 77769c9ff80cSmrg file_magic*) 77779c9ff80cSmrg set dummy $deplibs_check_method; shift 77789c9ff80cSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 77799c9ff80cSmrg for a_deplib in $deplibs; do 77809c9ff80cSmrg case $a_deplib in 77819c9ff80cSmrg -l*) 77829c9ff80cSmrg func_stripname -l '' "$a_deplib" 77839c9ff80cSmrg name=$func_stripname_result 77849c9ff80cSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 77859c9ff80cSmrg case " $predeps $postdeps " in 77869c9ff80cSmrg *" $a_deplib "*) 77876fae4e5dSmrg func_append newdeplibs " $a_deplib" 77889c9ff80cSmrg a_deplib="" 77899c9ff80cSmrg ;; 77909c9ff80cSmrg esac 77919c9ff80cSmrg fi 77929c9ff80cSmrg if test -n "$a_deplib" ; then 77939c9ff80cSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 77946fae4e5dSmrg if test -n "$file_magic_glob"; then 77956fae4e5dSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 77966fae4e5dSmrg else 77976fae4e5dSmrg libnameglob=$libname 77986fae4e5dSmrg fi 77996fae4e5dSmrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 78009c9ff80cSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 78016fae4e5dSmrg if test "$want_nocaseglob" = yes; then 78026fae4e5dSmrg shopt -s nocaseglob 78036fae4e5dSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 78046fae4e5dSmrg $nocaseglob 78056fae4e5dSmrg else 78066fae4e5dSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 78076fae4e5dSmrg fi 78089c9ff80cSmrg for potent_lib in $potential_libs; do 78099c9ff80cSmrg # Follow soft links. 78109c9ff80cSmrg if ls -lLd "$potent_lib" 2>/dev/null | 78119c9ff80cSmrg $GREP " -> " >/dev/null; then 78129c9ff80cSmrg continue 78139c9ff80cSmrg fi 78149c9ff80cSmrg # The statement above tries to avoid entering an 78159c9ff80cSmrg # endless loop below, in case of cyclic links. 78169c9ff80cSmrg # We might still enter an endless loop, since a link 78179c9ff80cSmrg # loop can be closed while we follow links, 78189c9ff80cSmrg # but so what? 78199c9ff80cSmrg potlib="$potent_lib" 78209c9ff80cSmrg while test -h "$potlib" 2>/dev/null; do 78219c9ff80cSmrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 78229c9ff80cSmrg case $potliblink in 78239c9ff80cSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 78246fae4e5dSmrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 78259c9ff80cSmrg esac 78269c9ff80cSmrg done 78279c9ff80cSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 78289c9ff80cSmrg $SED -e 10q | 78299c9ff80cSmrg $EGREP "$file_magic_regex" > /dev/null; then 78306fae4e5dSmrg func_append newdeplibs " $a_deplib" 78319c9ff80cSmrg a_deplib="" 78329c9ff80cSmrg break 2 78339c9ff80cSmrg fi 78349c9ff80cSmrg done 78359c9ff80cSmrg done 78369c9ff80cSmrg fi 78379c9ff80cSmrg if test -n "$a_deplib" ; then 78389c9ff80cSmrg droppeddeps=yes 78396fae4e5dSmrg echo 78409c9ff80cSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 78416fae4e5dSmrg echo "*** I have the capability to make that library automatically link in when" 78426fae4e5dSmrg echo "*** you link to this library. But I can only do this if you have a" 78436fae4e5dSmrg echo "*** shared version of the library, which you do not appear to have" 78446fae4e5dSmrg echo "*** because I did check the linker path looking for a file starting" 78459c9ff80cSmrg if test -z "$potlib" ; then 78469c9ff80cSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 78479c9ff80cSmrg else 78489c9ff80cSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 78499c9ff80cSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 78509c9ff80cSmrg fi 78519c9ff80cSmrg fi 78529c9ff80cSmrg ;; 78539c9ff80cSmrg *) 78549c9ff80cSmrg # Add a -L argument. 78556fae4e5dSmrg func_append newdeplibs " $a_deplib" 78569c9ff80cSmrg ;; 78579c9ff80cSmrg esac 78589c9ff80cSmrg done # Gone through all deplibs. 78599c9ff80cSmrg ;; 78609c9ff80cSmrg match_pattern*) 78619c9ff80cSmrg set dummy $deplibs_check_method; shift 78629c9ff80cSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 78639c9ff80cSmrg for a_deplib in $deplibs; do 78649c9ff80cSmrg case $a_deplib in 78659c9ff80cSmrg -l*) 78669c9ff80cSmrg func_stripname -l '' "$a_deplib" 78679c9ff80cSmrg name=$func_stripname_result 78689c9ff80cSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 78699c9ff80cSmrg case " $predeps $postdeps " in 78709c9ff80cSmrg *" $a_deplib "*) 78716fae4e5dSmrg func_append newdeplibs " $a_deplib" 78729c9ff80cSmrg a_deplib="" 78739c9ff80cSmrg ;; 78749c9ff80cSmrg esac 78759c9ff80cSmrg fi 78769c9ff80cSmrg if test -n "$a_deplib" ; then 78779c9ff80cSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 78789c9ff80cSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 78799c9ff80cSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 78809c9ff80cSmrg for potent_lib in $potential_libs; do 78819c9ff80cSmrg potlib="$potent_lib" # see symlink-check above in file_magic test 78826fae4e5dSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 78839c9ff80cSmrg $EGREP "$match_pattern_regex" > /dev/null; then 78846fae4e5dSmrg func_append newdeplibs " $a_deplib" 78859c9ff80cSmrg a_deplib="" 78869c9ff80cSmrg break 2 78879c9ff80cSmrg fi 78889c9ff80cSmrg done 78899c9ff80cSmrg done 78909c9ff80cSmrg fi 78919c9ff80cSmrg if test -n "$a_deplib" ; then 78929c9ff80cSmrg droppeddeps=yes 78936fae4e5dSmrg echo 78949c9ff80cSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 78956fae4e5dSmrg echo "*** I have the capability to make that library automatically link in when" 78966fae4e5dSmrg echo "*** you link to this library. But I can only do this if you have a" 78976fae4e5dSmrg echo "*** shared version of the library, which you do not appear to have" 78986fae4e5dSmrg echo "*** because I did check the linker path looking for a file starting" 78999c9ff80cSmrg if test -z "$potlib" ; then 79009c9ff80cSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 79019c9ff80cSmrg else 79029c9ff80cSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 79039c9ff80cSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 79049c9ff80cSmrg fi 79059c9ff80cSmrg fi 79069c9ff80cSmrg ;; 79079c9ff80cSmrg *) 79089c9ff80cSmrg # Add a -L argument. 79096fae4e5dSmrg func_append newdeplibs " $a_deplib" 79109c9ff80cSmrg ;; 79119c9ff80cSmrg esac 79129c9ff80cSmrg done # Gone through all deplibs. 79139c9ff80cSmrg ;; 79149c9ff80cSmrg none | unknown | *) 79159c9ff80cSmrg newdeplibs="" 79166fae4e5dSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 79179c9ff80cSmrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 79189c9ff80cSmrg for i in $predeps $postdeps ; do 79199c9ff80cSmrg # can't use Xsed below, because $i might contain '/' 79206fae4e5dSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 79219c9ff80cSmrg done 79229c9ff80cSmrg fi 79236fae4e5dSmrg case $tmp_deplibs in 79246fae4e5dSmrg *[!\ \ ]*) 79256fae4e5dSmrg echo 79269c9ff80cSmrg if test "X$deplibs_check_method" = "Xnone"; then 79276fae4e5dSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 79289c9ff80cSmrg else 79296fae4e5dSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 79309c9ff80cSmrg fi 79316fae4e5dSmrg echo "*** All declared inter-library dependencies are being dropped." 79329c9ff80cSmrg droppeddeps=yes 79336fae4e5dSmrg ;; 79346fae4e5dSmrg esac 79359c9ff80cSmrg ;; 79369c9ff80cSmrg esac 79379c9ff80cSmrg versuffix=$versuffix_save 79389c9ff80cSmrg major=$major_save 79399c9ff80cSmrg release=$release_save 79409c9ff80cSmrg libname=$libname_save 79419c9ff80cSmrg name=$name_save 79429c9ff80cSmrg 79439c9ff80cSmrg case $host in 79449c9ff80cSmrg *-*-rhapsody* | *-*-darwin1.[012]) 79459c9ff80cSmrg # On Rhapsody replace the C library with the System framework 79466fae4e5dSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 79479c9ff80cSmrg ;; 79489c9ff80cSmrg esac 79499c9ff80cSmrg 79509c9ff80cSmrg if test "$droppeddeps" = yes; then 79519c9ff80cSmrg if test "$module" = yes; then 79526fae4e5dSmrg echo 79536fae4e5dSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 79549c9ff80cSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 79556fae4e5dSmrg echo "*** a static module, that should work as long as the dlopening" 79566fae4e5dSmrg echo "*** application is linked with the -dlopen flag." 79579c9ff80cSmrg if test -z "$global_symbol_pipe"; then 79586fae4e5dSmrg echo 79596fae4e5dSmrg echo "*** However, this would only work if libtool was able to extract symbol" 79606fae4e5dSmrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 79616fae4e5dSmrg echo "*** not find such a program. So, this module is probably useless." 79626fae4e5dSmrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 79639c9ff80cSmrg fi 79649c9ff80cSmrg if test "$build_old_libs" = no; then 79659c9ff80cSmrg oldlibs="$output_objdir/$libname.$libext" 79669c9ff80cSmrg build_libtool_libs=module 79679c9ff80cSmrg build_old_libs=yes 79689c9ff80cSmrg else 79699c9ff80cSmrg build_libtool_libs=no 79709c9ff80cSmrg fi 79719c9ff80cSmrg else 79726fae4e5dSmrg echo "*** The inter-library dependencies that have been dropped here will be" 79736fae4e5dSmrg echo "*** automatically added whenever a program is linked with this library" 79746fae4e5dSmrg echo "*** or is declared to -dlopen it." 79759c9ff80cSmrg 79769c9ff80cSmrg if test "$allow_undefined" = no; then 79776fae4e5dSmrg echo 79786fae4e5dSmrg echo "*** Since this library must not contain undefined symbols," 79796fae4e5dSmrg echo "*** because either the platform does not support them or" 79806fae4e5dSmrg echo "*** it was explicitly requested with -no-undefined," 79816fae4e5dSmrg echo "*** libtool will only create a static version of it." 79829c9ff80cSmrg if test "$build_old_libs" = no; then 79839c9ff80cSmrg oldlibs="$output_objdir/$libname.$libext" 79849c9ff80cSmrg build_libtool_libs=module 79859c9ff80cSmrg build_old_libs=yes 79869c9ff80cSmrg else 79879c9ff80cSmrg build_libtool_libs=no 79889c9ff80cSmrg fi 79899c9ff80cSmrg fi 79909c9ff80cSmrg fi 79919c9ff80cSmrg fi 79929c9ff80cSmrg # Done checking deplibs! 79939c9ff80cSmrg deplibs=$newdeplibs 79949c9ff80cSmrg fi 79959c9ff80cSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 79969c9ff80cSmrg case $host in 79979c9ff80cSmrg *-*-darwin*) 79986fae4e5dSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 79996fae4e5dSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 80006fae4e5dSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 80019c9ff80cSmrg ;; 80029c9ff80cSmrg esac 80039c9ff80cSmrg 80049c9ff80cSmrg # move library search paths that coincide with paths to not yet 80059c9ff80cSmrg # installed libraries to the beginning of the library search list 80069c9ff80cSmrg new_libs= 80079c9ff80cSmrg for path in $notinst_path; do 80089c9ff80cSmrg case " $new_libs " in 80099c9ff80cSmrg *" -L$path/$objdir "*) ;; 80109c9ff80cSmrg *) 80119c9ff80cSmrg case " $deplibs " in 80129c9ff80cSmrg *" -L$path/$objdir "*) 80136fae4e5dSmrg func_append new_libs " -L$path/$objdir" ;; 80149c9ff80cSmrg esac 80159c9ff80cSmrg ;; 80169c9ff80cSmrg esac 80179c9ff80cSmrg done 80189c9ff80cSmrg for deplib in $deplibs; do 80199c9ff80cSmrg case $deplib in 80209c9ff80cSmrg -L*) 80219c9ff80cSmrg case " $new_libs " in 80229c9ff80cSmrg *" $deplib "*) ;; 80236fae4e5dSmrg *) func_append new_libs " $deplib" ;; 80249c9ff80cSmrg esac 80259c9ff80cSmrg ;; 80266fae4e5dSmrg *) func_append new_libs " $deplib" ;; 80279c9ff80cSmrg esac 80289c9ff80cSmrg done 80299c9ff80cSmrg deplibs="$new_libs" 80309c9ff80cSmrg 80319c9ff80cSmrg # All the library-specific variables (install_libdir is set above). 80329c9ff80cSmrg library_names= 80339c9ff80cSmrg old_library= 80349c9ff80cSmrg dlname= 80359c9ff80cSmrg 80369c9ff80cSmrg # Test again, we may have decided not to build it any more 80379c9ff80cSmrg if test "$build_libtool_libs" = yes; then 803889c04b6cSmrg # Remove ${wl} instances when linking with ld. 803989c04b6cSmrg # FIXME: should test the right _cmds variable. 804089c04b6cSmrg case $archive_cmds in 804189c04b6cSmrg *\$LD\ *) wl= ;; 804289c04b6cSmrg esac 80439c9ff80cSmrg if test "$hardcode_into_libs" = yes; then 80449c9ff80cSmrg # Hardcode the library paths 80459c9ff80cSmrg hardcode_libdirs= 80469c9ff80cSmrg dep_rpath= 80479c9ff80cSmrg rpath="$finalize_rpath" 80486fae4e5dSmrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 80499c9ff80cSmrg for libdir in $rpath; do 80509c9ff80cSmrg if test -n "$hardcode_libdir_flag_spec"; then 80519c9ff80cSmrg if test -n "$hardcode_libdir_separator"; then 80526fae4e5dSmrg func_replace_sysroot "$libdir" 80536fae4e5dSmrg libdir=$func_replace_sysroot_result 80549c9ff80cSmrg if test -z "$hardcode_libdirs"; then 80559c9ff80cSmrg hardcode_libdirs="$libdir" 80569c9ff80cSmrg else 80579c9ff80cSmrg # Just accumulate the unique libdirs. 80589c9ff80cSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 80599c9ff80cSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 80609c9ff80cSmrg ;; 80619c9ff80cSmrg *) 80626fae4e5dSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 80639c9ff80cSmrg ;; 80649c9ff80cSmrg esac 80659c9ff80cSmrg fi 80669c9ff80cSmrg else 80679c9ff80cSmrg eval flag=\"$hardcode_libdir_flag_spec\" 80686fae4e5dSmrg func_append dep_rpath " $flag" 80699c9ff80cSmrg fi 80709c9ff80cSmrg elif test -n "$runpath_var"; then 80719c9ff80cSmrg case "$perm_rpath " in 80729c9ff80cSmrg *" $libdir "*) ;; 807389c04b6cSmrg *) func_append perm_rpath " $libdir" ;; 80749c9ff80cSmrg esac 80759c9ff80cSmrg fi 80769c9ff80cSmrg done 80779c9ff80cSmrg # Substitute the hardcoded libdirs into the rpath. 80789c9ff80cSmrg if test -n "$hardcode_libdir_separator" && 80799c9ff80cSmrg test -n "$hardcode_libdirs"; then 80809c9ff80cSmrg libdir="$hardcode_libdirs" 808189c04b6cSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 80829c9ff80cSmrg fi 80839c9ff80cSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 80849c9ff80cSmrg # We should set the runpath_var. 80859c9ff80cSmrg rpath= 80869c9ff80cSmrg for dir in $perm_rpath; do 80876fae4e5dSmrg func_append rpath "$dir:" 80889c9ff80cSmrg done 80899c9ff80cSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 80909c9ff80cSmrg fi 80919c9ff80cSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 80929c9ff80cSmrg fi 80931f0ac6a5Smrg 80949c9ff80cSmrg shlibpath="$finalize_shlibpath" 80956fae4e5dSmrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 80969c9ff80cSmrg if test -n "$shlibpath"; then 80979c9ff80cSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 80989c9ff80cSmrg fi 80991f0ac6a5Smrg 81009c9ff80cSmrg # Get the real and link names of the library. 81019c9ff80cSmrg eval shared_ext=\"$shrext_cmds\" 81029c9ff80cSmrg eval library_names=\"$library_names_spec\" 81039c9ff80cSmrg set dummy $library_names 81049c9ff80cSmrg shift 81059c9ff80cSmrg realname="$1" 81069c9ff80cSmrg shift 81071f0ac6a5Smrg 81089c9ff80cSmrg if test -n "$soname_spec"; then 81099c9ff80cSmrg eval soname=\"$soname_spec\" 81109c9ff80cSmrg else 81119c9ff80cSmrg soname="$realname" 81129c9ff80cSmrg fi 81139c9ff80cSmrg if test -z "$dlname"; then 81149c9ff80cSmrg dlname=$soname 81159c9ff80cSmrg fi 81161f0ac6a5Smrg 81179c9ff80cSmrg lib="$output_objdir/$realname" 81189c9ff80cSmrg linknames= 81199c9ff80cSmrg for link 81209c9ff80cSmrg do 81216fae4e5dSmrg func_append linknames " $link" 81229c9ff80cSmrg done 81231f0ac6a5Smrg 81249c9ff80cSmrg # Use standard objects if they are pic 81256fae4e5dSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 81269c9ff80cSmrg test "X$libobjs" = "X " && libobjs= 81271f0ac6a5Smrg 81289c9ff80cSmrg delfiles= 81299c9ff80cSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 81309c9ff80cSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 81319c9ff80cSmrg export_symbols="$output_objdir/$libname.uexp" 81326fae4e5dSmrg func_append delfiles " $export_symbols" 81339c9ff80cSmrg fi 81341f0ac6a5Smrg 81359c9ff80cSmrg orig_export_symbols= 81369c9ff80cSmrg case $host_os in 81379c9ff80cSmrg cygwin* | mingw* | cegcc*) 81389c9ff80cSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 81399c9ff80cSmrg # exporting using user supplied symfile 81409c9ff80cSmrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 81419c9ff80cSmrg # and it's NOT already a .def file. Must figure out 81429c9ff80cSmrg # which of the given symbols are data symbols and tag 81439c9ff80cSmrg # them as such. So, trigger use of export_symbols_cmds. 81449c9ff80cSmrg # export_symbols gets reassigned inside the "prepare 81459c9ff80cSmrg # the list of exported symbols" if statement, so the 81469c9ff80cSmrg # include_expsyms logic still works. 81479c9ff80cSmrg orig_export_symbols="$export_symbols" 81489c9ff80cSmrg export_symbols= 81499c9ff80cSmrg always_export_symbols=yes 81509c9ff80cSmrg fi 81519c9ff80cSmrg fi 81529c9ff80cSmrg ;; 81539c9ff80cSmrg esac 81541f0ac6a5Smrg 81559c9ff80cSmrg # Prepare the list of exported symbols 81569c9ff80cSmrg if test -z "$export_symbols"; then 81579c9ff80cSmrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 81589c9ff80cSmrg func_verbose "generating symbol list for \`$libname.la'" 81599c9ff80cSmrg export_symbols="$output_objdir/$libname.exp" 81609c9ff80cSmrg $opt_dry_run || $RM $export_symbols 81619c9ff80cSmrg cmds=$export_symbols_cmds 81629c9ff80cSmrg save_ifs="$IFS"; IFS='~' 81636fae4e5dSmrg for cmd1 in $cmds; do 81649c9ff80cSmrg IFS="$save_ifs" 81656fae4e5dSmrg # Take the normal branch if the nm_file_list_spec branch 81666fae4e5dSmrg # doesn't work or if tool conversion is not needed. 81676fae4e5dSmrg case $nm_file_list_spec~$to_tool_file_cmd in 81686fae4e5dSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 81696fae4e5dSmrg try_normal_branch=yes 81706fae4e5dSmrg eval cmd=\"$cmd1\" 81716fae4e5dSmrg func_len " $cmd" 81726fae4e5dSmrg len=$func_len_result 81736fae4e5dSmrg ;; 81746fae4e5dSmrg *) 81756fae4e5dSmrg try_normal_branch=no 81766fae4e5dSmrg ;; 81776fae4e5dSmrg esac 81786fae4e5dSmrg if test "$try_normal_branch" = yes \ 81796fae4e5dSmrg && { test "$len" -lt "$max_cmd_len" \ 81806fae4e5dSmrg || test "$max_cmd_len" -le -1; } 81816fae4e5dSmrg then 81826fae4e5dSmrg func_show_eval "$cmd" 'exit $?' 81836fae4e5dSmrg skipped_export=false 81846fae4e5dSmrg elif test -n "$nm_file_list_spec"; then 81856fae4e5dSmrg func_basename "$output" 81866fae4e5dSmrg output_la=$func_basename_result 81876fae4e5dSmrg save_libobjs=$libobjs 81886fae4e5dSmrg save_output=$output 81896fae4e5dSmrg output=${output_objdir}/${output_la}.nm 81906fae4e5dSmrg func_to_tool_file "$output" 81916fae4e5dSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 81926fae4e5dSmrg func_append delfiles " $output" 81936fae4e5dSmrg func_verbose "creating $NM input file list: $output" 81946fae4e5dSmrg for obj in $save_libobjs; do 81956fae4e5dSmrg func_to_tool_file "$obj" 81966fae4e5dSmrg $ECHO "$func_to_tool_file_result" 81976fae4e5dSmrg done > "$output" 81986fae4e5dSmrg eval cmd=\"$cmd1\" 81999c9ff80cSmrg func_show_eval "$cmd" 'exit $?' 82006fae4e5dSmrg output=$save_output 82016fae4e5dSmrg libobjs=$save_libobjs 82029c9ff80cSmrg skipped_export=false 82039c9ff80cSmrg else 82049c9ff80cSmrg # The command line is too long to execute in one step. 82059c9ff80cSmrg func_verbose "using reloadable object file for export list..." 82069c9ff80cSmrg skipped_export=: 82079c9ff80cSmrg # Break out early, otherwise skipped_export may be 82089c9ff80cSmrg # set to false by a later but shorter cmd. 82099c9ff80cSmrg break 82109c9ff80cSmrg fi 82119c9ff80cSmrg done 82129c9ff80cSmrg IFS="$save_ifs" 82139c9ff80cSmrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 82149c9ff80cSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 82159c9ff80cSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 82169c9ff80cSmrg fi 82179c9ff80cSmrg fi 82181f0ac6a5Smrg fi 82191f0ac6a5Smrg 82209c9ff80cSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 82219c9ff80cSmrg tmp_export_symbols="$export_symbols" 82229c9ff80cSmrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 82236fae4e5dSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 82249c9ff80cSmrg fi 82251f0ac6a5Smrg 82269c9ff80cSmrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 82279c9ff80cSmrg # The given exports_symbols file has to be filtered, so filter it. 82289c9ff80cSmrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 82299c9ff80cSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 82309c9ff80cSmrg # 's' commands which not all seds can handle. GNU sed should be fine 82319c9ff80cSmrg # though. Also, the filter scales superlinearly with the number of 82329c9ff80cSmrg # global variables. join(1) would be nice here, but unfortunately 82339c9ff80cSmrg # isn't a blessed tool. 82349c9ff80cSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 82356fae4e5dSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 82369c9ff80cSmrg export_symbols=$output_objdir/$libname.def 82379c9ff80cSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 82389c9ff80cSmrg fi 82391f0ac6a5Smrg 82409c9ff80cSmrg tmp_deplibs= 82419c9ff80cSmrg for test_deplib in $deplibs; do 82429c9ff80cSmrg case " $convenience " in 82439c9ff80cSmrg *" $test_deplib "*) ;; 82449c9ff80cSmrg *) 82456fae4e5dSmrg func_append tmp_deplibs " $test_deplib" 82469c9ff80cSmrg ;; 82479c9ff80cSmrg esac 82489c9ff80cSmrg done 82499c9ff80cSmrg deplibs="$tmp_deplibs" 82501f0ac6a5Smrg 82519c9ff80cSmrg if test -n "$convenience"; then 82529c9ff80cSmrg if test -n "$whole_archive_flag_spec" && 82539c9ff80cSmrg test "$compiler_needs_object" = yes && 82549c9ff80cSmrg test -z "$libobjs"; then 82559c9ff80cSmrg # extract the archives, so we have objects to list. 82569c9ff80cSmrg # TODO: could optimize this to just extract one archive. 82579c9ff80cSmrg whole_archive_flag_spec= 82589c9ff80cSmrg fi 82599c9ff80cSmrg if test -n "$whole_archive_flag_spec"; then 82609c9ff80cSmrg save_libobjs=$libobjs 82619c9ff80cSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 82629c9ff80cSmrg test "X$libobjs" = "X " && libobjs= 82639c9ff80cSmrg else 82649c9ff80cSmrg gentop="$output_objdir/${outputname}x" 82656fae4e5dSmrg func_append generated " $gentop" 82661f0ac6a5Smrg 82679c9ff80cSmrg func_extract_archives $gentop $convenience 82686fae4e5dSmrg func_append libobjs " $func_extract_archives_result" 82699c9ff80cSmrg test "X$libobjs" = "X " && libobjs= 82709c9ff80cSmrg fi 82711f0ac6a5Smrg fi 82721f0ac6a5Smrg 82739c9ff80cSmrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 82749c9ff80cSmrg eval flag=\"$thread_safe_flag_spec\" 82756fae4e5dSmrg func_append linker_flags " $flag" 82761f0ac6a5Smrg fi 82771f0ac6a5Smrg 82789c9ff80cSmrg # Make a backup of the uninstalled library when relinking 82796fae4e5dSmrg if test "$opt_mode" = relink; then 82809c9ff80cSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 82819c9ff80cSmrg fi 82821f0ac6a5Smrg 82839c9ff80cSmrg # Do each of the archive commands. 82849c9ff80cSmrg if test "$module" = yes && test -n "$module_cmds" ; then 82859c9ff80cSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 82869c9ff80cSmrg eval test_cmds=\"$module_expsym_cmds\" 82879c9ff80cSmrg cmds=$module_expsym_cmds 82889c9ff80cSmrg else 82899c9ff80cSmrg eval test_cmds=\"$module_cmds\" 82909c9ff80cSmrg cmds=$module_cmds 82919c9ff80cSmrg fi 82921f0ac6a5Smrg else 82939c9ff80cSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 82949c9ff80cSmrg eval test_cmds=\"$archive_expsym_cmds\" 82959c9ff80cSmrg cmds=$archive_expsym_cmds 82969c9ff80cSmrg else 82979c9ff80cSmrg eval test_cmds=\"$archive_cmds\" 82989c9ff80cSmrg cmds=$archive_cmds 82999c9ff80cSmrg fi 83001f0ac6a5Smrg fi 83011f0ac6a5Smrg 83029c9ff80cSmrg if test "X$skipped_export" != "X:" && 83039c9ff80cSmrg func_len " $test_cmds" && 83049c9ff80cSmrg len=$func_len_result && 83059c9ff80cSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 83069c9ff80cSmrg : 83079c9ff80cSmrg else 83089c9ff80cSmrg # The command line is too long to link in one step, link piecewise 83099c9ff80cSmrg # or, if using GNU ld and skipped_export is not :, use a linker 83109c9ff80cSmrg # script. 83111f0ac6a5Smrg 83129c9ff80cSmrg # Save the value of $output and $libobjs because we want to 83139c9ff80cSmrg # use them later. If we have whole_archive_flag_spec, we 83149c9ff80cSmrg # want to use save_libobjs as it was before 83159c9ff80cSmrg # whole_archive_flag_spec was expanded, because we can't 83169c9ff80cSmrg # assume the linker understands whole_archive_flag_spec. 83179c9ff80cSmrg # This may have to be revisited, in case too many 83189c9ff80cSmrg # convenience libraries get linked in and end up exceeding 83199c9ff80cSmrg # the spec. 83209c9ff80cSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 83219c9ff80cSmrg save_libobjs=$libobjs 83229c9ff80cSmrg fi 83239c9ff80cSmrg save_output=$output 83246fae4e5dSmrg func_basename "$output" 83256fae4e5dSmrg output_la=$func_basename_result 83261f0ac6a5Smrg 83279c9ff80cSmrg # Clear the reloadable object creation command queue and 83289c9ff80cSmrg # initialize k to one. 83299c9ff80cSmrg test_cmds= 83309c9ff80cSmrg concat_cmds= 83319c9ff80cSmrg objlist= 83329c9ff80cSmrg last_robj= 83339c9ff80cSmrg k=1 83349c9ff80cSmrg 83359c9ff80cSmrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 83369c9ff80cSmrg output=${output_objdir}/${output_la}.lnkscript 83379c9ff80cSmrg func_verbose "creating GNU ld script: $output" 83386fae4e5dSmrg echo 'INPUT (' > $output 83399c9ff80cSmrg for obj in $save_libobjs 83401f0ac6a5Smrg do 83416fae4e5dSmrg func_to_tool_file "$obj" 83426fae4e5dSmrg $ECHO "$func_to_tool_file_result" >> $output 83439c9ff80cSmrg done 83446fae4e5dSmrg echo ')' >> $output 83456fae4e5dSmrg func_append delfiles " $output" 83466fae4e5dSmrg func_to_tool_file "$output" 83476fae4e5dSmrg output=$func_to_tool_file_result 83489c9ff80cSmrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 83499c9ff80cSmrg output=${output_objdir}/${output_la}.lnk 83509c9ff80cSmrg func_verbose "creating linker input file list: $output" 83519c9ff80cSmrg : > $output 83529c9ff80cSmrg set x $save_libobjs 83539c9ff80cSmrg shift 83549c9ff80cSmrg firstobj= 83559c9ff80cSmrg if test "$compiler_needs_object" = yes; then 83569c9ff80cSmrg firstobj="$1 " 83579c9ff80cSmrg shift 83589c9ff80cSmrg fi 83599c9ff80cSmrg for obj 83609c9ff80cSmrg do 83616fae4e5dSmrg func_to_tool_file "$obj" 83626fae4e5dSmrg $ECHO "$func_to_tool_file_result" >> $output 83639c9ff80cSmrg done 83646fae4e5dSmrg func_append delfiles " $output" 83656fae4e5dSmrg func_to_tool_file "$output" 83666fae4e5dSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 83679c9ff80cSmrg else 83689c9ff80cSmrg if test -n "$save_libobjs"; then 83699c9ff80cSmrg func_verbose "creating reloadable object files..." 83709c9ff80cSmrg output=$output_objdir/$output_la-${k}.$objext 83719c9ff80cSmrg eval test_cmds=\"$reload_cmds\" 83729c9ff80cSmrg func_len " $test_cmds" 83739c9ff80cSmrg len0=$func_len_result 83749c9ff80cSmrg len=$len0 83759c9ff80cSmrg 83769c9ff80cSmrg # Loop over the list of objects to be linked. 83779c9ff80cSmrg for obj in $save_libobjs 83789c9ff80cSmrg do 83799c9ff80cSmrg func_len " $obj" 83809c9ff80cSmrg func_arith $len + $func_len_result 83819c9ff80cSmrg len=$func_arith_result 83829c9ff80cSmrg if test "X$objlist" = X || 83839c9ff80cSmrg test "$len" -lt "$max_cmd_len"; then 83849c9ff80cSmrg func_append objlist " $obj" 83859c9ff80cSmrg else 83869c9ff80cSmrg # The command $test_cmds is almost too long, add a 83879c9ff80cSmrg # command to the queue. 83889c9ff80cSmrg if test "$k" -eq 1 ; then 83899c9ff80cSmrg # The first file doesn't have a previous command to add. 83906fae4e5dSmrg reload_objs=$objlist 83916fae4e5dSmrg eval concat_cmds=\"$reload_cmds\" 83929c9ff80cSmrg else 83939c9ff80cSmrg # All subsequent reloadable object files will link in 83949c9ff80cSmrg # the last one created. 83956fae4e5dSmrg reload_objs="$objlist $last_robj" 83966fae4e5dSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 83979c9ff80cSmrg fi 83989c9ff80cSmrg last_robj=$output_objdir/$output_la-${k}.$objext 83999c9ff80cSmrg func_arith $k + 1 84009c9ff80cSmrg k=$func_arith_result 84019c9ff80cSmrg output=$output_objdir/$output_la-${k}.$objext 84026fae4e5dSmrg objlist=" $obj" 84039c9ff80cSmrg func_len " $last_robj" 84049c9ff80cSmrg func_arith $len0 + $func_len_result 84059c9ff80cSmrg len=$func_arith_result 84069c9ff80cSmrg fi 84079c9ff80cSmrg done 84089c9ff80cSmrg # Handle the remaining objects by creating one last 84099c9ff80cSmrg # reloadable object file. All subsequent reloadable object 84109c9ff80cSmrg # files will link in the last one created. 84119c9ff80cSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 84126fae4e5dSmrg reload_objs="$objlist $last_robj" 84136fae4e5dSmrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 84149c9ff80cSmrg if test -n "$last_robj"; then 84159c9ff80cSmrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 84169c9ff80cSmrg fi 84176fae4e5dSmrg func_append delfiles " $output" 84181f0ac6a5Smrg 84199c9ff80cSmrg else 84209c9ff80cSmrg output= 84219c9ff80cSmrg fi 84221f0ac6a5Smrg 84239c9ff80cSmrg if ${skipped_export-false}; then 84249c9ff80cSmrg func_verbose "generating symbol list for \`$libname.la'" 84259c9ff80cSmrg export_symbols="$output_objdir/$libname.exp" 84269c9ff80cSmrg $opt_dry_run || $RM $export_symbols 84279c9ff80cSmrg libobjs=$output 84289c9ff80cSmrg # Append the command to create the export file. 84299c9ff80cSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 84309c9ff80cSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 84319c9ff80cSmrg if test -n "$last_robj"; then 84329c9ff80cSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 84339c9ff80cSmrg fi 84341f0ac6a5Smrg fi 84351f0ac6a5Smrg 84369c9ff80cSmrg test -n "$save_libobjs" && 84379c9ff80cSmrg func_verbose "creating a temporary reloadable object file: $output" 84381f0ac6a5Smrg 84399c9ff80cSmrg # Loop through the commands generated above and execute them. 84409c9ff80cSmrg save_ifs="$IFS"; IFS='~' 84419c9ff80cSmrg for cmd in $concat_cmds; do 84429c9ff80cSmrg IFS="$save_ifs" 84439c9ff80cSmrg $opt_silent || { 84449c9ff80cSmrg func_quote_for_expand "$cmd" 84459c9ff80cSmrg eval "func_echo $func_quote_for_expand_result" 84469c9ff80cSmrg } 84479c9ff80cSmrg $opt_dry_run || eval "$cmd" || { 84489c9ff80cSmrg lt_exit=$? 84499c9ff80cSmrg 84509c9ff80cSmrg # Restore the uninstalled library and exit 84516fae4e5dSmrg if test "$opt_mode" = relink; then 84529c9ff80cSmrg ( cd "$output_objdir" && \ 84539c9ff80cSmrg $RM "${realname}T" && \ 84549c9ff80cSmrg $MV "${realname}U" "$realname" ) 84559c9ff80cSmrg fi 84561f0ac6a5Smrg 84579c9ff80cSmrg exit $lt_exit 84589c9ff80cSmrg } 84599c9ff80cSmrg done 84609c9ff80cSmrg IFS="$save_ifs" 84611f0ac6a5Smrg 84629c9ff80cSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 84639c9ff80cSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 84649c9ff80cSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 84651f0ac6a5Smrg fi 84661f0ac6a5Smrg fi 84671f0ac6a5Smrg 84689c9ff80cSmrg if ${skipped_export-false}; then 84699c9ff80cSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 84709c9ff80cSmrg tmp_export_symbols="$export_symbols" 84719c9ff80cSmrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 84726fae4e5dSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 84739c9ff80cSmrg fi 84741f0ac6a5Smrg 84759c9ff80cSmrg if test -n "$orig_export_symbols"; then 84769c9ff80cSmrg # The given exports_symbols file has to be filtered, so filter it. 84779c9ff80cSmrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 84789c9ff80cSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 84799c9ff80cSmrg # 's' commands which not all seds can handle. GNU sed should be fine 84809c9ff80cSmrg # though. Also, the filter scales superlinearly with the number of 84819c9ff80cSmrg # global variables. join(1) would be nice here, but unfortunately 84829c9ff80cSmrg # isn't a blessed tool. 84839c9ff80cSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 84846fae4e5dSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 84859c9ff80cSmrg export_symbols=$output_objdir/$libname.def 84869c9ff80cSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 84879c9ff80cSmrg fi 84889c9ff80cSmrg fi 84891f0ac6a5Smrg 84909c9ff80cSmrg libobjs=$output 84919c9ff80cSmrg # Restore the value of output. 84929c9ff80cSmrg output=$save_output 84931f0ac6a5Smrg 84949c9ff80cSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 84959c9ff80cSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 84969c9ff80cSmrg test "X$libobjs" = "X " && libobjs= 84979c9ff80cSmrg fi 84989c9ff80cSmrg # Expand the library linking commands again to reset the 84999c9ff80cSmrg # value of $libobjs for piecewise linking. 85001f0ac6a5Smrg 85019c9ff80cSmrg # Do each of the archive commands. 85029c9ff80cSmrg if test "$module" = yes && test -n "$module_cmds" ; then 85039c9ff80cSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 85049c9ff80cSmrg cmds=$module_expsym_cmds 85059c9ff80cSmrg else 85069c9ff80cSmrg cmds=$module_cmds 85071f0ac6a5Smrg fi 85081f0ac6a5Smrg else 85099c9ff80cSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 85109c9ff80cSmrg cmds=$archive_expsym_cmds 85119c9ff80cSmrg else 85129c9ff80cSmrg cmds=$archive_cmds 85139c9ff80cSmrg fi 85141f0ac6a5Smrg fi 85159c9ff80cSmrg fi 85161f0ac6a5Smrg 85179c9ff80cSmrg if test -n "$delfiles"; then 85189c9ff80cSmrg # Append the command to remove temporary files to $cmds. 85199c9ff80cSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 85209c9ff80cSmrg fi 85211f0ac6a5Smrg 85229c9ff80cSmrg # Add any objects from preloaded convenience libraries 85239c9ff80cSmrg if test -n "$dlprefiles"; then 85249c9ff80cSmrg gentop="$output_objdir/${outputname}x" 85256fae4e5dSmrg func_append generated " $gentop" 85261f0ac6a5Smrg 85279c9ff80cSmrg func_extract_archives $gentop $dlprefiles 85286fae4e5dSmrg func_append libobjs " $func_extract_archives_result" 85299c9ff80cSmrg test "X$libobjs" = "X " && libobjs= 85309c9ff80cSmrg fi 85311f0ac6a5Smrg 85329c9ff80cSmrg save_ifs="$IFS"; IFS='~' 85339c9ff80cSmrg for cmd in $cmds; do 85349c9ff80cSmrg IFS="$save_ifs" 85359c9ff80cSmrg eval cmd=\"$cmd\" 85369c9ff80cSmrg $opt_silent || { 85379c9ff80cSmrg func_quote_for_expand "$cmd" 85389c9ff80cSmrg eval "func_echo $func_quote_for_expand_result" 85399c9ff80cSmrg } 85409c9ff80cSmrg $opt_dry_run || eval "$cmd" || { 85419c9ff80cSmrg lt_exit=$? 85421f0ac6a5Smrg 85439c9ff80cSmrg # Restore the uninstalled library and exit 85446fae4e5dSmrg if test "$opt_mode" = relink; then 85459c9ff80cSmrg ( cd "$output_objdir" && \ 85469c9ff80cSmrg $RM "${realname}T" && \ 85479c9ff80cSmrg $MV "${realname}U" "$realname" ) 85489c9ff80cSmrg fi 85491f0ac6a5Smrg 85509c9ff80cSmrg exit $lt_exit 85519c9ff80cSmrg } 85529c9ff80cSmrg done 85539c9ff80cSmrg IFS="$save_ifs" 85541f0ac6a5Smrg 85559c9ff80cSmrg # Restore the uninstalled library and exit 85566fae4e5dSmrg if test "$opt_mode" = relink; then 85579c9ff80cSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 85581f0ac6a5Smrg 85599c9ff80cSmrg if test -n "$convenience"; then 85609c9ff80cSmrg if test -z "$whole_archive_flag_spec"; then 85619c9ff80cSmrg func_show_eval '${RM}r "$gentop"' 85629c9ff80cSmrg fi 85639c9ff80cSmrg fi 85641f0ac6a5Smrg 85659c9ff80cSmrg exit $EXIT_SUCCESS 85669c9ff80cSmrg fi 85679c9ff80cSmrg 85689c9ff80cSmrg # Create links to the real library. 85699c9ff80cSmrg for linkname in $linknames; do 85709c9ff80cSmrg if test "$realname" != "$linkname"; then 85719c9ff80cSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 85721f0ac6a5Smrg fi 85731f0ac6a5Smrg done 85741f0ac6a5Smrg 85759c9ff80cSmrg # If -module or -export-dynamic was specified, set the dlname. 85769c9ff80cSmrg if test "$module" = yes || test "$export_dynamic" = yes; then 85779c9ff80cSmrg # On all known operating systems, these are identical. 85789c9ff80cSmrg dlname="$soname" 85799c9ff80cSmrg fi 85809c9ff80cSmrg fi 85811f0ac6a5Smrg ;; 85821f0ac6a5Smrg 85839c9ff80cSmrg obj) 85849c9ff80cSmrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 85859c9ff80cSmrg func_warning "\`-dlopen' is ignored for objects" 85869c9ff80cSmrg fi 85871f0ac6a5Smrg 85889c9ff80cSmrg case " $deplibs" in 85899c9ff80cSmrg *\ -l* | *\ -L*) 85909c9ff80cSmrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 85911f0ac6a5Smrg esac 85921f0ac6a5Smrg 85939c9ff80cSmrg test -n "$rpath" && \ 85949c9ff80cSmrg func_warning "\`-rpath' is ignored for objects" 85959c9ff80cSmrg 85969c9ff80cSmrg test -n "$xrpath" && \ 85979c9ff80cSmrg func_warning "\`-R' is ignored for objects" 85981f0ac6a5Smrg 85999c9ff80cSmrg test -n "$vinfo" && \ 86009c9ff80cSmrg func_warning "\`-version-info' is ignored for objects" 86011f0ac6a5Smrg 86029c9ff80cSmrg test -n "$release" && \ 86039c9ff80cSmrg func_warning "\`-release' is ignored for objects" 86049c9ff80cSmrg 86059c9ff80cSmrg case $output in 86069c9ff80cSmrg *.lo) 86079c9ff80cSmrg test -n "$objs$old_deplibs" && \ 86089c9ff80cSmrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 86099c9ff80cSmrg 86109c9ff80cSmrg libobj=$output 86119c9ff80cSmrg func_lo2o "$libobj" 86129c9ff80cSmrg obj=$func_lo2o_result 86131f0ac6a5Smrg ;; 86141f0ac6a5Smrg *) 86159c9ff80cSmrg libobj= 86169c9ff80cSmrg obj="$output" 86171f0ac6a5Smrg ;; 86181f0ac6a5Smrg esac 86191f0ac6a5Smrg 86209c9ff80cSmrg # Delete the old objects. 86219c9ff80cSmrg $opt_dry_run || $RM $obj $libobj 86221f0ac6a5Smrg 86239c9ff80cSmrg # Objects from convenience libraries. This assumes 86249c9ff80cSmrg # single-version convenience libraries. Whenever we create 86259c9ff80cSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 86269c9ff80cSmrg # the extraction. 86279c9ff80cSmrg reload_conv_objs= 86289c9ff80cSmrg gentop= 86299c9ff80cSmrg # reload_cmds runs $LD directly, so let us get rid of 86309c9ff80cSmrg # -Wl from whole_archive_flag_spec and hope we can get by with 86319c9ff80cSmrg # turning comma into space.. 86329c9ff80cSmrg wl= 86331f0ac6a5Smrg 86349c9ff80cSmrg if test -n "$convenience"; then 86359c9ff80cSmrg if test -n "$whole_archive_flag_spec"; then 86369c9ff80cSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 86376fae4e5dSmrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 86389c9ff80cSmrg else 86399c9ff80cSmrg gentop="$output_objdir/${obj}x" 86406fae4e5dSmrg func_append generated " $gentop" 86411f0ac6a5Smrg 86429c9ff80cSmrg func_extract_archives $gentop $convenience 86439c9ff80cSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 86449c9ff80cSmrg fi 86451f0ac6a5Smrg fi 86461f0ac6a5Smrg 86476fae4e5dSmrg # If we're not building shared, we need to use non_pic_objs 86486fae4e5dSmrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 86496fae4e5dSmrg 86509c9ff80cSmrg # Create the old-style object. 86516fae4e5dSmrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 86521f0ac6a5Smrg 86539c9ff80cSmrg output="$obj" 86549c9ff80cSmrg func_execute_cmds "$reload_cmds" 'exit $?' 86551f0ac6a5Smrg 86569c9ff80cSmrg # Exit if we aren't doing a library object file. 86579c9ff80cSmrg if test -z "$libobj"; then 86589c9ff80cSmrg if test -n "$gentop"; then 86599c9ff80cSmrg func_show_eval '${RM}r "$gentop"' 86609c9ff80cSmrg fi 86619c9ff80cSmrg 86629c9ff80cSmrg exit $EXIT_SUCCESS 86631f0ac6a5Smrg fi 86649c9ff80cSmrg 86659c9ff80cSmrg if test "$build_libtool_libs" != yes; then 86669c9ff80cSmrg if test -n "$gentop"; then 86679c9ff80cSmrg func_show_eval '${RM}r "$gentop"' 86689c9ff80cSmrg fi 86699c9ff80cSmrg 86709c9ff80cSmrg # Create an invalid libtool object if no PIC, so that we don't 86719c9ff80cSmrg # accidentally link it into a program. 86729c9ff80cSmrg # $show "echo timestamp > $libobj" 86739c9ff80cSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 86749c9ff80cSmrg exit $EXIT_SUCCESS 86759c9ff80cSmrg fi 86769c9ff80cSmrg 86779c9ff80cSmrg if test -n "$pic_flag" || test "$pic_mode" != default; then 86789c9ff80cSmrg # Only do commands if we really have different PIC objects. 86799c9ff80cSmrg reload_objs="$libobjs $reload_conv_objs" 86809c9ff80cSmrg output="$libobj" 86819c9ff80cSmrg func_execute_cmds "$reload_cmds" 'exit $?' 86829c9ff80cSmrg fi 86839c9ff80cSmrg 86849c9ff80cSmrg if test -n "$gentop"; then 86859c9ff80cSmrg func_show_eval '${RM}r "$gentop"' 86869c9ff80cSmrg fi 86879c9ff80cSmrg 86889c9ff80cSmrg exit $EXIT_SUCCESS 86891f0ac6a5Smrg ;; 86901f0ac6a5Smrg 86919c9ff80cSmrg prog) 86929c9ff80cSmrg case $host in 86939c9ff80cSmrg *cygwin*) func_stripname '' '.exe' "$output" 86949c9ff80cSmrg output=$func_stripname_result.exe;; 86959c9ff80cSmrg esac 86969c9ff80cSmrg test -n "$vinfo" && \ 86979c9ff80cSmrg func_warning "\`-version-info' is ignored for programs" 86981f0ac6a5Smrg 86999c9ff80cSmrg test -n "$release" && \ 87009c9ff80cSmrg func_warning "\`-release' is ignored for programs" 87011f0ac6a5Smrg 87029c9ff80cSmrg test "$preload" = yes \ 87039c9ff80cSmrg && test "$dlopen_support" = unknown \ 87049c9ff80cSmrg && test "$dlopen_self" = unknown \ 87059c9ff80cSmrg && test "$dlopen_self_static" = unknown && \ 87069c9ff80cSmrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 87079c9ff80cSmrg 87089c9ff80cSmrg case $host in 87099c9ff80cSmrg *-*-rhapsody* | *-*-darwin1.[012]) 87109c9ff80cSmrg # On Rhapsody replace the C library is the System framework 87116fae4e5dSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 87126fae4e5dSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 87131f0ac6a5Smrg ;; 87149c9ff80cSmrg esac 87151f0ac6a5Smrg 87169c9ff80cSmrg case $host in 87179c9ff80cSmrg *-*-darwin*) 87189c9ff80cSmrg # Don't allow lazy linking, it breaks C++ global constructors 87199c9ff80cSmrg # But is supposedly fixed on 10.4 or later (yay!). 87209c9ff80cSmrg if test "$tagname" = CXX ; then 87219c9ff80cSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 87229c9ff80cSmrg 10.[0123]) 87236fae4e5dSmrg func_append compile_command " ${wl}-bind_at_load" 87246fae4e5dSmrg func_append finalize_command " ${wl}-bind_at_load" 87259c9ff80cSmrg ;; 87269c9ff80cSmrg esac 87271f0ac6a5Smrg fi 87289c9ff80cSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 87296fae4e5dSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 87306fae4e5dSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 87319c9ff80cSmrg ;; 87329c9ff80cSmrg esac 87331f0ac6a5Smrg 87341f0ac6a5Smrg 87359c9ff80cSmrg # move library search paths that coincide with paths to not yet 87369c9ff80cSmrg # installed libraries to the beginning of the library search list 87379c9ff80cSmrg new_libs= 87389c9ff80cSmrg for path in $notinst_path; do 87399c9ff80cSmrg case " $new_libs " in 87409c9ff80cSmrg *" -L$path/$objdir "*) ;; 87419c9ff80cSmrg *) 87429c9ff80cSmrg case " $compile_deplibs " in 87439c9ff80cSmrg *" -L$path/$objdir "*) 87446fae4e5dSmrg func_append new_libs " -L$path/$objdir" ;; 87451f0ac6a5Smrg esac 87469c9ff80cSmrg ;; 87479c9ff80cSmrg esac 87489c9ff80cSmrg done 87499c9ff80cSmrg for deplib in $compile_deplibs; do 87509c9ff80cSmrg case $deplib in 87519c9ff80cSmrg -L*) 87529c9ff80cSmrg case " $new_libs " in 87539c9ff80cSmrg *" $deplib "*) ;; 87546fae4e5dSmrg *) func_append new_libs " $deplib" ;; 87551f0ac6a5Smrg esac 87569c9ff80cSmrg ;; 87576fae4e5dSmrg *) func_append new_libs " $deplib" ;; 87589c9ff80cSmrg esac 87599c9ff80cSmrg done 87609c9ff80cSmrg compile_deplibs="$new_libs" 87611f0ac6a5Smrg 87621f0ac6a5Smrg 87636fae4e5dSmrg func_append compile_command " $compile_deplibs" 87646fae4e5dSmrg func_append finalize_command " $finalize_deplibs" 87651f0ac6a5Smrg 87669c9ff80cSmrg if test -n "$rpath$xrpath"; then 87679c9ff80cSmrg # If the user specified any rpath flags, then add them. 87689c9ff80cSmrg for libdir in $rpath $xrpath; do 87699c9ff80cSmrg # This is the magic to use -rpath. 87709c9ff80cSmrg case "$finalize_rpath " in 87719c9ff80cSmrg *" $libdir "*) ;; 87726fae4e5dSmrg *) func_append finalize_rpath " $libdir" ;; 87739c9ff80cSmrg esac 87749c9ff80cSmrg done 87759c9ff80cSmrg fi 87761f0ac6a5Smrg 87779c9ff80cSmrg # Now hardcode the library paths 87789c9ff80cSmrg rpath= 87799c9ff80cSmrg hardcode_libdirs= 87809c9ff80cSmrg for libdir in $compile_rpath $finalize_rpath; do 87819c9ff80cSmrg if test -n "$hardcode_libdir_flag_spec"; then 87829c9ff80cSmrg if test -n "$hardcode_libdir_separator"; then 87839c9ff80cSmrg if test -z "$hardcode_libdirs"; then 87849c9ff80cSmrg hardcode_libdirs="$libdir" 87859c9ff80cSmrg else 87869c9ff80cSmrg # Just accumulate the unique libdirs. 87879c9ff80cSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 87889c9ff80cSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 87899c9ff80cSmrg ;; 87909c9ff80cSmrg *) 87916fae4e5dSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 87929c9ff80cSmrg ;; 87939c9ff80cSmrg esac 87949c9ff80cSmrg fi 87951f0ac6a5Smrg else 87969c9ff80cSmrg eval flag=\"$hardcode_libdir_flag_spec\" 87976fae4e5dSmrg func_append rpath " $flag" 87981f0ac6a5Smrg fi 87999c9ff80cSmrg elif test -n "$runpath_var"; then 88009c9ff80cSmrg case "$perm_rpath " in 88019c9ff80cSmrg *" $libdir "*) ;; 88026fae4e5dSmrg *) func_append perm_rpath " $libdir" ;; 88039c9ff80cSmrg esac 88049c9ff80cSmrg fi 88059c9ff80cSmrg case $host in 88069c9ff80cSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 88079c9ff80cSmrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 88089c9ff80cSmrg case :$dllsearchpath: in 88099c9ff80cSmrg *":$libdir:"*) ;; 88109c9ff80cSmrg ::) dllsearchpath=$libdir;; 88116fae4e5dSmrg *) func_append dllsearchpath ":$libdir";; 88129c9ff80cSmrg esac 88139c9ff80cSmrg case :$dllsearchpath: in 88149c9ff80cSmrg *":$testbindir:"*) ;; 88159c9ff80cSmrg ::) dllsearchpath=$testbindir;; 88166fae4e5dSmrg *) func_append dllsearchpath ":$testbindir";; 88179c9ff80cSmrg esac 88189c9ff80cSmrg ;; 88199c9ff80cSmrg esac 88209c9ff80cSmrg done 88219c9ff80cSmrg # Substitute the hardcoded libdirs into the rpath. 88229c9ff80cSmrg if test -n "$hardcode_libdir_separator" && 88239c9ff80cSmrg test -n "$hardcode_libdirs"; then 88249c9ff80cSmrg libdir="$hardcode_libdirs" 88259c9ff80cSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 88269c9ff80cSmrg fi 88279c9ff80cSmrg compile_rpath="$rpath" 88281f0ac6a5Smrg 88299c9ff80cSmrg rpath= 88309c9ff80cSmrg hardcode_libdirs= 88319c9ff80cSmrg for libdir in $finalize_rpath; do 88329c9ff80cSmrg if test -n "$hardcode_libdir_flag_spec"; then 88339c9ff80cSmrg if test -n "$hardcode_libdir_separator"; then 88349c9ff80cSmrg if test -z "$hardcode_libdirs"; then 88359c9ff80cSmrg hardcode_libdirs="$libdir" 88369c9ff80cSmrg else 88379c9ff80cSmrg # Just accumulate the unique libdirs. 88389c9ff80cSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 88399c9ff80cSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 88409c9ff80cSmrg ;; 88419c9ff80cSmrg *) 88426fae4e5dSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 88439c9ff80cSmrg ;; 88449c9ff80cSmrg esac 88459c9ff80cSmrg fi 88461f0ac6a5Smrg else 88479c9ff80cSmrg eval flag=\"$hardcode_libdir_flag_spec\" 88486fae4e5dSmrg func_append rpath " $flag" 88491f0ac6a5Smrg fi 88509c9ff80cSmrg elif test -n "$runpath_var"; then 88519c9ff80cSmrg case "$finalize_perm_rpath " in 88529c9ff80cSmrg *" $libdir "*) ;; 88536fae4e5dSmrg *) func_append finalize_perm_rpath " $libdir" ;; 88549c9ff80cSmrg esac 88551f0ac6a5Smrg fi 88569c9ff80cSmrg done 88579c9ff80cSmrg # Substitute the hardcoded libdirs into the rpath. 88589c9ff80cSmrg if test -n "$hardcode_libdir_separator" && 88599c9ff80cSmrg test -n "$hardcode_libdirs"; then 88609c9ff80cSmrg libdir="$hardcode_libdirs" 88619c9ff80cSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 88629c9ff80cSmrg fi 88639c9ff80cSmrg finalize_rpath="$rpath" 88641f0ac6a5Smrg 88659c9ff80cSmrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 88669c9ff80cSmrg # Transform all the library objects into standard objects. 88676fae4e5dSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 88686fae4e5dSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 88699c9ff80cSmrg fi 88701f0ac6a5Smrg 88719c9ff80cSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 88721f0ac6a5Smrg 88739c9ff80cSmrg # template prelinking step 88749c9ff80cSmrg if test -n "$prelink_cmds"; then 88759c9ff80cSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 88769c9ff80cSmrg fi 88771f0ac6a5Smrg 88789c9ff80cSmrg wrappers_required=yes 88799c9ff80cSmrg case $host in 88806fae4e5dSmrg *cegcc* | *mingw32ce*) 88816fae4e5dSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 88826fae4e5dSmrg wrappers_required=no 88836fae4e5dSmrg ;; 88849c9ff80cSmrg *cygwin* | *mingw* ) 88859c9ff80cSmrg if test "$build_libtool_libs" != yes; then 88869c9ff80cSmrg wrappers_required=no 88879c9ff80cSmrg fi 88889c9ff80cSmrg ;; 88899c9ff80cSmrg *) 88909c9ff80cSmrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 88919c9ff80cSmrg wrappers_required=no 88929c9ff80cSmrg fi 88939c9ff80cSmrg ;; 88949c9ff80cSmrg esac 88959c9ff80cSmrg if test "$wrappers_required" = no; then 88969c9ff80cSmrg # Replace the output file specification. 88976fae4e5dSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 88989c9ff80cSmrg link_command="$compile_command$compile_rpath" 88991f0ac6a5Smrg 89009c9ff80cSmrg # We have no uninstalled library dependencies, so finalize right now. 89019c9ff80cSmrg exit_status=0 89029c9ff80cSmrg func_show_eval "$link_command" 'exit_status=$?' 89031f0ac6a5Smrg 89046fae4e5dSmrg if test -n "$postlink_cmds"; then 89056fae4e5dSmrg func_to_tool_file "$output" 89066fae4e5dSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 89076fae4e5dSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 89086fae4e5dSmrg fi 89096fae4e5dSmrg 89109c9ff80cSmrg # Delete the generated files. 89119c9ff80cSmrg if test -f "$output_objdir/${outputname}S.${objext}"; then 89129c9ff80cSmrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 89131f0ac6a5Smrg fi 89141f0ac6a5Smrg 89159c9ff80cSmrg exit $exit_status 89169c9ff80cSmrg fi 89171f0ac6a5Smrg 89189c9ff80cSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 89199c9ff80cSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 89209c9ff80cSmrg fi 89219c9ff80cSmrg if test -n "$finalize_shlibpath"; then 89229c9ff80cSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 89239c9ff80cSmrg fi 89241f0ac6a5Smrg 89259c9ff80cSmrg compile_var= 89269c9ff80cSmrg finalize_var= 89279c9ff80cSmrg if test -n "$runpath_var"; then 89289c9ff80cSmrg if test -n "$perm_rpath"; then 89299c9ff80cSmrg # We should set the runpath_var. 89309c9ff80cSmrg rpath= 89319c9ff80cSmrg for dir in $perm_rpath; do 89326fae4e5dSmrg func_append rpath "$dir:" 89339c9ff80cSmrg done 89349c9ff80cSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 89351f0ac6a5Smrg fi 89369c9ff80cSmrg if test -n "$finalize_perm_rpath"; then 89379c9ff80cSmrg # We should set the runpath_var. 89389c9ff80cSmrg rpath= 89399c9ff80cSmrg for dir in $finalize_perm_rpath; do 89406fae4e5dSmrg func_append rpath "$dir:" 89419c9ff80cSmrg done 89429c9ff80cSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 89431f0ac6a5Smrg fi 89449c9ff80cSmrg fi 89451f0ac6a5Smrg 89469c9ff80cSmrg if test "$no_install" = yes; then 89479c9ff80cSmrg # We don't need to create a wrapper script. 89489c9ff80cSmrg link_command="$compile_var$compile_command$compile_rpath" 89499c9ff80cSmrg # Replace the output file specification. 89506fae4e5dSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 89519c9ff80cSmrg # Delete the old output file. 89529c9ff80cSmrg $opt_dry_run || $RM $output 89539c9ff80cSmrg # Link the executable and exit 89549c9ff80cSmrg func_show_eval "$link_command" 'exit $?' 89556fae4e5dSmrg 89566fae4e5dSmrg if test -n "$postlink_cmds"; then 89576fae4e5dSmrg func_to_tool_file "$output" 89586fae4e5dSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 89596fae4e5dSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 89606fae4e5dSmrg fi 89616fae4e5dSmrg 89621f0ac6a5Smrg exit $EXIT_SUCCESS 89639c9ff80cSmrg fi 89641f0ac6a5Smrg 89659c9ff80cSmrg if test "$hardcode_action" = relink; then 89669c9ff80cSmrg # Fast installation is not supported 89679c9ff80cSmrg link_command="$compile_var$compile_command$compile_rpath" 89689c9ff80cSmrg relink_command="$finalize_var$finalize_command$finalize_rpath" 89699c9ff80cSmrg 89709c9ff80cSmrg func_warning "this platform does not like uninstalled shared libraries" 89719c9ff80cSmrg func_warning "\`$output' will be relinked during installation" 89729c9ff80cSmrg else 89739c9ff80cSmrg if test "$fast_install" != no; then 89749c9ff80cSmrg link_command="$finalize_var$compile_command$finalize_rpath" 89759c9ff80cSmrg if test "$fast_install" = yes; then 89766fae4e5dSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 89779c9ff80cSmrg else 89789c9ff80cSmrg # fast_install is set to needless 89799c9ff80cSmrg relink_command= 89809c9ff80cSmrg fi 89811f0ac6a5Smrg else 89829c9ff80cSmrg link_command="$compile_var$compile_command$compile_rpath" 89839c9ff80cSmrg relink_command="$finalize_var$finalize_command$finalize_rpath" 89841f0ac6a5Smrg fi 89859c9ff80cSmrg fi 89861f0ac6a5Smrg 89879c9ff80cSmrg # Replace the output file specification. 89886fae4e5dSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 89891f0ac6a5Smrg 89909c9ff80cSmrg # Delete the old output files. 89919c9ff80cSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 89921f0ac6a5Smrg 89939c9ff80cSmrg func_show_eval "$link_command" 'exit $?' 89941f0ac6a5Smrg 89956fae4e5dSmrg if test -n "$postlink_cmds"; then 89966fae4e5dSmrg func_to_tool_file "$output_objdir/$outputname" 89976fae4e5dSmrg 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'` 89986fae4e5dSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 89996fae4e5dSmrg fi 90006fae4e5dSmrg 90019c9ff80cSmrg # Now create the wrapper script. 90029c9ff80cSmrg func_verbose "creating $output" 90031f0ac6a5Smrg 90049c9ff80cSmrg # Quote the relink command for shipping. 90059c9ff80cSmrg if test -n "$relink_command"; then 90069c9ff80cSmrg # Preserve any variables that may affect compiler behavior 90079c9ff80cSmrg for var in $variables_saved_for_relink; do 90089c9ff80cSmrg if eval test -z \"\${$var+set}\"; then 90099c9ff80cSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 90109c9ff80cSmrg elif eval var_value=\$$var; test -z "$var_value"; then 90119c9ff80cSmrg relink_command="$var=; export $var; $relink_command" 90121f0ac6a5Smrg else 90139c9ff80cSmrg func_quote_for_eval "$var_value" 90149c9ff80cSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 90151f0ac6a5Smrg fi 90169c9ff80cSmrg done 90179c9ff80cSmrg relink_command="(cd `pwd`; $relink_command)" 90186fae4e5dSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 90199c9ff80cSmrg fi 90209c9ff80cSmrg 90219c9ff80cSmrg # Only actually do things if not in dry run mode. 90229c9ff80cSmrg $opt_dry_run || { 90239c9ff80cSmrg # win32 will think the script is a binary if it has 90249c9ff80cSmrg # a .exe suffix, so we strip it off here. 90259c9ff80cSmrg case $output in 90269c9ff80cSmrg *.exe) func_stripname '' '.exe' "$output" 90279c9ff80cSmrg output=$func_stripname_result ;; 90289c9ff80cSmrg esac 90299c9ff80cSmrg # test for cygwin because mv fails w/o .exe extensions 90309c9ff80cSmrg case $host in 90319c9ff80cSmrg *cygwin*) 90329c9ff80cSmrg exeext=.exe 90339c9ff80cSmrg func_stripname '' '.exe' "$outputname" 90349c9ff80cSmrg outputname=$func_stripname_result ;; 90359c9ff80cSmrg *) exeext= ;; 90361f0ac6a5Smrg esac 90379c9ff80cSmrg case $host in 90389c9ff80cSmrg *cygwin* | *mingw* ) 90399c9ff80cSmrg func_dirname_and_basename "$output" "" "." 90409c9ff80cSmrg output_name=$func_basename_result 90419c9ff80cSmrg output_path=$func_dirname_result 90429c9ff80cSmrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 90439c9ff80cSmrg cwrapper="$output_path/$output_name.exe" 90449c9ff80cSmrg $RM $cwrappersource $cwrapper 90459c9ff80cSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 90469c9ff80cSmrg 90479c9ff80cSmrg func_emit_cwrapperexe_src > $cwrappersource 90489c9ff80cSmrg 90499c9ff80cSmrg # The wrapper executable is built using the $host compiler, 90509c9ff80cSmrg # because it contains $host paths and files. If cross- 90519c9ff80cSmrg # compiling, it, like the target executable, must be 90529c9ff80cSmrg # executed on the $host or under an emulation environment. 90539c9ff80cSmrg $opt_dry_run || { 90549c9ff80cSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 90559c9ff80cSmrg $STRIP $cwrapper 90569c9ff80cSmrg } 90571f0ac6a5Smrg 90589c9ff80cSmrg # Now, create the wrapper script for func_source use: 90599c9ff80cSmrg func_ltwrapper_scriptname $cwrapper 90609c9ff80cSmrg $RM $func_ltwrapper_scriptname_result 90619c9ff80cSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 90629c9ff80cSmrg $opt_dry_run || { 90639c9ff80cSmrg # note: this script will not be executed, so do not chmod. 90649c9ff80cSmrg if test "x$build" = "x$host" ; then 90659c9ff80cSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 90669c9ff80cSmrg else 90679c9ff80cSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 90689c9ff80cSmrg fi 90699c9ff80cSmrg } 90709c9ff80cSmrg ;; 90719c9ff80cSmrg * ) 90729c9ff80cSmrg $RM $output 90739c9ff80cSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 90741f0ac6a5Smrg 90759c9ff80cSmrg func_emit_wrapper no > $output 90769c9ff80cSmrg chmod +x $output 90779c9ff80cSmrg ;; 90789c9ff80cSmrg esac 90799c9ff80cSmrg } 90809c9ff80cSmrg exit $EXIT_SUCCESS 90819c9ff80cSmrg ;; 90829c9ff80cSmrg esac 90831f0ac6a5Smrg 90849c9ff80cSmrg # See if we need to build an old-fashioned archive. 90859c9ff80cSmrg for oldlib in $oldlibs; do 90861f0ac6a5Smrg 90879c9ff80cSmrg if test "$build_libtool_libs" = convenience; then 90889c9ff80cSmrg oldobjs="$libobjs_save $symfileobj" 90899c9ff80cSmrg addlibs="$convenience" 90909c9ff80cSmrg build_libtool_libs=no 90919c9ff80cSmrg else 90929c9ff80cSmrg if test "$build_libtool_libs" = module; then 90939c9ff80cSmrg oldobjs="$libobjs_save" 90949c9ff80cSmrg build_libtool_libs=no 90959c9ff80cSmrg else 90969c9ff80cSmrg oldobjs="$old_deplibs $non_pic_objects" 90979c9ff80cSmrg if test "$preload" = yes && test -f "$symfileobj"; then 90986fae4e5dSmrg func_append oldobjs " $symfileobj" 90999c9ff80cSmrg fi 91009c9ff80cSmrg fi 91019c9ff80cSmrg addlibs="$old_convenience" 91021f0ac6a5Smrg fi 91031f0ac6a5Smrg 91049c9ff80cSmrg if test -n "$addlibs"; then 91059c9ff80cSmrg gentop="$output_objdir/${outputname}x" 91066fae4e5dSmrg func_append generated " $gentop" 91071f0ac6a5Smrg 91089c9ff80cSmrg func_extract_archives $gentop $addlibs 91096fae4e5dSmrg func_append oldobjs " $func_extract_archives_result" 91109c9ff80cSmrg fi 91111f0ac6a5Smrg 91129c9ff80cSmrg # Do each command in the archive commands. 91139c9ff80cSmrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 91149c9ff80cSmrg cmds=$old_archive_from_new_cmds 91159c9ff80cSmrg else 91161f0ac6a5Smrg 91179c9ff80cSmrg # Add any objects from preloaded convenience libraries 91189c9ff80cSmrg if test -n "$dlprefiles"; then 91199c9ff80cSmrg gentop="$output_objdir/${outputname}x" 91206fae4e5dSmrg func_append generated " $gentop" 91211f0ac6a5Smrg 91229c9ff80cSmrg func_extract_archives $gentop $dlprefiles 91236fae4e5dSmrg func_append oldobjs " $func_extract_archives_result" 91249c9ff80cSmrg fi 91251f0ac6a5Smrg 91269c9ff80cSmrg # POSIX demands no paths to be encoded in archives. We have 91279c9ff80cSmrg # to avoid creating archives with duplicate basenames if we 91289c9ff80cSmrg # might have to extract them afterwards, e.g., when creating a 91299c9ff80cSmrg # static archive out of a convenience library, or when linking 91309c9ff80cSmrg # the entirety of a libtool archive into another (currently 91319c9ff80cSmrg # not supported by libtool). 91329c9ff80cSmrg if (for obj in $oldobjs 91339c9ff80cSmrg do 91349c9ff80cSmrg func_basename "$obj" 91359c9ff80cSmrg $ECHO "$func_basename_result" 91369c9ff80cSmrg done | sort | sort -uc >/dev/null 2>&1); then 91379c9ff80cSmrg : 91389c9ff80cSmrg else 91396fae4e5dSmrg echo "copying selected object files to avoid basename conflicts..." 91409c9ff80cSmrg gentop="$output_objdir/${outputname}x" 91416fae4e5dSmrg func_append generated " $gentop" 91429c9ff80cSmrg func_mkdir_p "$gentop" 91439c9ff80cSmrg save_oldobjs=$oldobjs 91449c9ff80cSmrg oldobjs= 91459c9ff80cSmrg counter=1 91469c9ff80cSmrg for obj in $save_oldobjs 91479c9ff80cSmrg do 91489c9ff80cSmrg func_basename "$obj" 91499c9ff80cSmrg objbase="$func_basename_result" 91509c9ff80cSmrg case " $oldobjs " in 91519c9ff80cSmrg " ") oldobjs=$obj ;; 91529c9ff80cSmrg *[\ /]"$objbase "*) 91539c9ff80cSmrg while :; do 91549c9ff80cSmrg # Make sure we don't pick an alternate name that also 91559c9ff80cSmrg # overlaps. 91569c9ff80cSmrg newobj=lt$counter-$objbase 91579c9ff80cSmrg func_arith $counter + 1 91589c9ff80cSmrg counter=$func_arith_result 91599c9ff80cSmrg case " $oldobjs " in 91609c9ff80cSmrg *[\ /]"$newobj "*) ;; 91619c9ff80cSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 91629c9ff80cSmrg esac 91639c9ff80cSmrg done 91649c9ff80cSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 91656fae4e5dSmrg func_append oldobjs " $gentop/$newobj" 91669c9ff80cSmrg ;; 91676fae4e5dSmrg *) func_append oldobjs " $obj" ;; 91689c9ff80cSmrg esac 91691f0ac6a5Smrg done 91701f0ac6a5Smrg fi 917189c04b6cSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 917289c04b6cSmrg tool_oldlib=$func_to_tool_file_result 91739c9ff80cSmrg eval cmds=\"$old_archive_cmds\" 91741f0ac6a5Smrg 91759c9ff80cSmrg func_len " $cmds" 91769c9ff80cSmrg len=$func_len_result 91779c9ff80cSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 91789c9ff80cSmrg cmds=$old_archive_cmds 91796fae4e5dSmrg elif test -n "$archiver_list_spec"; then 91806fae4e5dSmrg func_verbose "using command file archive linking..." 91816fae4e5dSmrg for obj in $oldobjs 91826fae4e5dSmrg do 91836fae4e5dSmrg func_to_tool_file "$obj" 91846fae4e5dSmrg $ECHO "$func_to_tool_file_result" 91856fae4e5dSmrg done > $output_objdir/$libname.libcmd 91866fae4e5dSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 91876fae4e5dSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 91886fae4e5dSmrg cmds=$old_archive_cmds 91899c9ff80cSmrg else 91909c9ff80cSmrg # the command line is too long to link in one step, link in parts 91919c9ff80cSmrg func_verbose "using piecewise archive linking..." 91929c9ff80cSmrg save_RANLIB=$RANLIB 91939c9ff80cSmrg RANLIB=: 91949c9ff80cSmrg objlist= 91959c9ff80cSmrg concat_cmds= 91969c9ff80cSmrg save_oldobjs=$oldobjs 91979c9ff80cSmrg oldobjs= 91989c9ff80cSmrg # Is there a better way of finding the last object in the list? 91999c9ff80cSmrg for obj in $save_oldobjs 92009c9ff80cSmrg do 92019c9ff80cSmrg last_oldobj=$obj 92029c9ff80cSmrg done 92039c9ff80cSmrg eval test_cmds=\"$old_archive_cmds\" 92049c9ff80cSmrg func_len " $test_cmds" 92059c9ff80cSmrg len0=$func_len_result 92069c9ff80cSmrg len=$len0 92079c9ff80cSmrg for obj in $save_oldobjs 92089c9ff80cSmrg do 92099c9ff80cSmrg func_len " $obj" 92109c9ff80cSmrg func_arith $len + $func_len_result 92119c9ff80cSmrg len=$func_arith_result 92129c9ff80cSmrg func_append objlist " $obj" 92139c9ff80cSmrg if test "$len" -lt "$max_cmd_len"; then 92149c9ff80cSmrg : 92159c9ff80cSmrg else 92169c9ff80cSmrg # the above command should be used before it gets too long 92179c9ff80cSmrg oldobjs=$objlist 92189c9ff80cSmrg if test "$obj" = "$last_oldobj" ; then 92199c9ff80cSmrg RANLIB=$save_RANLIB 92209c9ff80cSmrg fi 92219c9ff80cSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 92229c9ff80cSmrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 92239c9ff80cSmrg objlist= 92249c9ff80cSmrg len=$len0 92259c9ff80cSmrg fi 92269c9ff80cSmrg done 92279c9ff80cSmrg RANLIB=$save_RANLIB 92289c9ff80cSmrg oldobjs=$objlist 92299c9ff80cSmrg if test "X$oldobjs" = "X" ; then 92309c9ff80cSmrg eval cmds=\"\$concat_cmds\" 92319c9ff80cSmrg else 92329c9ff80cSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 92339c9ff80cSmrg fi 92349c9ff80cSmrg fi 92359c9ff80cSmrg fi 92369c9ff80cSmrg func_execute_cmds "$cmds" 'exit $?' 92371f0ac6a5Smrg done 92381f0ac6a5Smrg 92399c9ff80cSmrg test -n "$generated" && \ 92409c9ff80cSmrg func_show_eval "${RM}r$generated" 92411f0ac6a5Smrg 92429c9ff80cSmrg # Now create the libtool archive. 92439c9ff80cSmrg case $output in 92449c9ff80cSmrg *.la) 92459c9ff80cSmrg old_library= 92469c9ff80cSmrg test "$build_old_libs" = yes && old_library="$libname.$libext" 92479c9ff80cSmrg func_verbose "creating $output" 92481f0ac6a5Smrg 92499c9ff80cSmrg # Preserve any variables that may affect compiler behavior 92509c9ff80cSmrg for var in $variables_saved_for_relink; do 92519c9ff80cSmrg if eval test -z \"\${$var+set}\"; then 92529c9ff80cSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 92539c9ff80cSmrg elif eval var_value=\$$var; test -z "$var_value"; then 92549c9ff80cSmrg relink_command="$var=; export $var; $relink_command" 92551f0ac6a5Smrg else 92569c9ff80cSmrg func_quote_for_eval "$var_value" 92579c9ff80cSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 92581f0ac6a5Smrg fi 92599c9ff80cSmrg done 92609c9ff80cSmrg # Quote the link command for shipping. 92619c9ff80cSmrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 92626fae4e5dSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 92639c9ff80cSmrg if test "$hardcode_automatic" = yes ; then 92649c9ff80cSmrg relink_command= 92659c9ff80cSmrg fi 92661f0ac6a5Smrg 92679c9ff80cSmrg # Only create the output if not a dry run. 92689c9ff80cSmrg $opt_dry_run || { 92699c9ff80cSmrg for installed in no yes; do 92709c9ff80cSmrg if test "$installed" = yes; then 92719c9ff80cSmrg if test -z "$install_libdir"; then 92729c9ff80cSmrg break 92739c9ff80cSmrg fi 92749c9ff80cSmrg output="$output_objdir/$outputname"i 92759c9ff80cSmrg # Replace all uninstalled libtool libraries with the installed ones 92769c9ff80cSmrg newdependency_libs= 92779c9ff80cSmrg for deplib in $dependency_libs; do 92789c9ff80cSmrg case $deplib in 92799c9ff80cSmrg *.la) 92809c9ff80cSmrg func_basename "$deplib" 92819c9ff80cSmrg name="$func_basename_result" 928289c04b6cSmrg func_resolve_sysroot "$deplib" 928389c04b6cSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 92849c9ff80cSmrg test -z "$libdir" && \ 92859c9ff80cSmrg func_fatal_error "\`$deplib' is not a valid libtool archive" 92866fae4e5dSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 92876fae4e5dSmrg ;; 92886fae4e5dSmrg -L*) 92896fae4e5dSmrg func_stripname -L '' "$deplib" 92906fae4e5dSmrg func_replace_sysroot "$func_stripname_result" 92916fae4e5dSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 92929c9ff80cSmrg ;; 92936fae4e5dSmrg -R*) 92946fae4e5dSmrg func_stripname -R '' "$deplib" 92956fae4e5dSmrg func_replace_sysroot "$func_stripname_result" 92966fae4e5dSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 92976fae4e5dSmrg ;; 92986fae4e5dSmrg *) func_append newdependency_libs " $deplib" ;; 92999c9ff80cSmrg esac 93009c9ff80cSmrg done 93019c9ff80cSmrg dependency_libs="$newdependency_libs" 93029c9ff80cSmrg newdlfiles= 93039c9ff80cSmrg 93049c9ff80cSmrg for lib in $dlfiles; do 93059c9ff80cSmrg case $lib in 93069c9ff80cSmrg *.la) 93079c9ff80cSmrg func_basename "$lib" 93089c9ff80cSmrg name="$func_basename_result" 93099c9ff80cSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 93109c9ff80cSmrg test -z "$libdir" && \ 93119c9ff80cSmrg func_fatal_error "\`$lib' is not a valid libtool archive" 93126fae4e5dSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 93139c9ff80cSmrg ;; 93146fae4e5dSmrg *) func_append newdlfiles " $lib" ;; 93159c9ff80cSmrg esac 93169c9ff80cSmrg done 93179c9ff80cSmrg dlfiles="$newdlfiles" 93189c9ff80cSmrg newdlprefiles= 93199c9ff80cSmrg for lib in $dlprefiles; do 93209c9ff80cSmrg case $lib in 93219c9ff80cSmrg *.la) 93229c9ff80cSmrg # Only pass preopened files to the pseudo-archive (for 93239c9ff80cSmrg # eventual linking with the app. that links it) if we 93249c9ff80cSmrg # didn't already link the preopened objects directly into 93259c9ff80cSmrg # the library: 93269c9ff80cSmrg func_basename "$lib" 93279c9ff80cSmrg name="$func_basename_result" 93289c9ff80cSmrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 93299c9ff80cSmrg test -z "$libdir" && \ 93309c9ff80cSmrg func_fatal_error "\`$lib' is not a valid libtool archive" 93316fae4e5dSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 93329c9ff80cSmrg ;; 93339c9ff80cSmrg esac 93349c9ff80cSmrg done 93359c9ff80cSmrg dlprefiles="$newdlprefiles" 93369c9ff80cSmrg else 93379c9ff80cSmrg newdlfiles= 93389c9ff80cSmrg for lib in $dlfiles; do 93399c9ff80cSmrg case $lib in 93409c9ff80cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 93419c9ff80cSmrg *) abs=`pwd`"/$lib" ;; 93429c9ff80cSmrg esac 93436fae4e5dSmrg func_append newdlfiles " $abs" 93449c9ff80cSmrg done 93459c9ff80cSmrg dlfiles="$newdlfiles" 93469c9ff80cSmrg newdlprefiles= 93479c9ff80cSmrg for lib in $dlprefiles; do 93489c9ff80cSmrg case $lib in 93499c9ff80cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 93509c9ff80cSmrg *) abs=`pwd`"/$lib" ;; 93519c9ff80cSmrg esac 93526fae4e5dSmrg func_append newdlprefiles " $abs" 93539c9ff80cSmrg done 93549c9ff80cSmrg dlprefiles="$newdlprefiles" 93559c9ff80cSmrg fi 93569c9ff80cSmrg $RM $output 93579c9ff80cSmrg # place dlname in correct position for cygwin 93586fae4e5dSmrg # In fact, it would be nice if we could use this code for all target 93596fae4e5dSmrg # systems that can't hard-code library paths into their executables 93606fae4e5dSmrg # and that have no shared library path variable independent of PATH, 93616fae4e5dSmrg # but it turns out we can't easily determine that from inspecting 93626fae4e5dSmrg # libtool variables, so we have to hard-code the OSs to which it 93636fae4e5dSmrg # applies here; at the moment, that means platforms that use the PE 93646fae4e5dSmrg # object format with DLL files. See the long comment at the top of 93656fae4e5dSmrg # tests/bindir.at for full details. 93669c9ff80cSmrg tdlname=$dlname 93679c9ff80cSmrg case $host,$output,$installed,$module,$dlname in 93686fae4e5dSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 93696fae4e5dSmrg # If a -bindir argument was supplied, place the dll there. 93706fae4e5dSmrg if test "x$bindir" != x ; 93716fae4e5dSmrg then 93726fae4e5dSmrg func_relative_path "$install_libdir" "$bindir" 93736fae4e5dSmrg tdlname=$func_relative_path_result$dlname 93746fae4e5dSmrg else 93756fae4e5dSmrg # Otherwise fall back on heuristic. 93766fae4e5dSmrg tdlname=../bin/$dlname 93776fae4e5dSmrg fi 93786fae4e5dSmrg ;; 93799c9ff80cSmrg esac 93809c9ff80cSmrg $ECHO > $output "\ 93819c9ff80cSmrg# $outputname - a libtool library file 93829c9ff80cSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 93839c9ff80cSmrg# 93849c9ff80cSmrg# Please DO NOT delete this file! 93859c9ff80cSmrg# It is necessary for linking the library. 93861f0ac6a5Smrg 93879c9ff80cSmrg# The name that we can dlopen(3). 93889c9ff80cSmrgdlname='$tdlname' 93891f0ac6a5Smrg 93909c9ff80cSmrg# Names of this library. 93919c9ff80cSmrglibrary_names='$library_names' 93921f0ac6a5Smrg 93939c9ff80cSmrg# The name of the static archive. 93949c9ff80cSmrgold_library='$old_library' 93951f0ac6a5Smrg 93969c9ff80cSmrg# Linker flags that can not go in dependency_libs. 93979c9ff80cSmrginherited_linker_flags='$new_inherited_linker_flags' 93981f0ac6a5Smrg 93999c9ff80cSmrg# Libraries that this one depends upon. 94009c9ff80cSmrgdependency_libs='$dependency_libs' 94011f0ac6a5Smrg 94029c9ff80cSmrg# Names of additional weak libraries provided by this library 94039c9ff80cSmrgweak_library_names='$weak_libs' 94041f0ac6a5Smrg 94059c9ff80cSmrg# Version information for $libname. 94069c9ff80cSmrgcurrent=$current 94079c9ff80cSmrgage=$age 94089c9ff80cSmrgrevision=$revision 94091f0ac6a5Smrg 94109c9ff80cSmrg# Is this an already installed library? 94119c9ff80cSmrginstalled=$installed 94121f0ac6a5Smrg 94139c9ff80cSmrg# Should we warn about portability when linking against -modules? 94149c9ff80cSmrgshouldnotlink=$module 94151f0ac6a5Smrg 94169c9ff80cSmrg# Files to dlopen/dlpreopen 94179c9ff80cSmrgdlopen='$dlfiles' 94189c9ff80cSmrgdlpreopen='$dlprefiles' 94191f0ac6a5Smrg 94209c9ff80cSmrg# Directory that this library needs to be installed in: 94219c9ff80cSmrglibdir='$install_libdir'" 94229c9ff80cSmrg if test "$installed" = no && test "$need_relink" = yes; then 94239c9ff80cSmrg $ECHO >> $output "\ 94249c9ff80cSmrgrelink_command=\"$relink_command\"" 94259c9ff80cSmrg fi 94269c9ff80cSmrg done 94279c9ff80cSmrg } 94281f0ac6a5Smrg 94299c9ff80cSmrg # Do a symbolic link so that the libtool archive can be found in 94309c9ff80cSmrg # LD_LIBRARY_PATH before the program is installed. 94319c9ff80cSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 94329c9ff80cSmrg ;; 94339c9ff80cSmrg esac 94349c9ff80cSmrg exit $EXIT_SUCCESS 94359c9ff80cSmrg} 94361f0ac6a5Smrg 94376fae4e5dSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 94389c9ff80cSmrg func_mode_link ${1+"$@"} 94391f0ac6a5Smrg 94401f0ac6a5Smrg 94419c9ff80cSmrg# func_mode_uninstall arg... 94429c9ff80cSmrgfunc_mode_uninstall () 94439c9ff80cSmrg{ 94449c9ff80cSmrg $opt_debug 94459c9ff80cSmrg RM="$nonopt" 94461f0ac6a5Smrg files= 94471f0ac6a5Smrg rmforce= 94481f0ac6a5Smrg exit_status=0 94491f0ac6a5Smrg 94501f0ac6a5Smrg # This variable tells wrapper scripts just to set variables rather 94511f0ac6a5Smrg # than running their programs. 94521f0ac6a5Smrg libtool_install_magic="$magic" 94531f0ac6a5Smrg 94541f0ac6a5Smrg for arg 94551f0ac6a5Smrg do 94561f0ac6a5Smrg case $arg in 94576fae4e5dSmrg -f) func_append RM " $arg"; rmforce=yes ;; 94586fae4e5dSmrg -*) func_append RM " $arg" ;; 94596fae4e5dSmrg *) func_append files " $arg" ;; 94601f0ac6a5Smrg esac 94611f0ac6a5Smrg done 94621f0ac6a5Smrg 94639c9ff80cSmrg test -z "$RM" && \ 94649c9ff80cSmrg func_fatal_help "you must specify an RM program" 94651f0ac6a5Smrg 94661f0ac6a5Smrg rmdirs= 94671f0ac6a5Smrg 94681f0ac6a5Smrg for file in $files; do 94699c9ff80cSmrg func_dirname "$file" "" "." 94709c9ff80cSmrg dir="$func_dirname_result" 94719c9ff80cSmrg if test "X$dir" = X.; then 94726fae4e5dSmrg odir="$objdir" 94731f0ac6a5Smrg else 94746fae4e5dSmrg odir="$dir/$objdir" 94751f0ac6a5Smrg fi 94769c9ff80cSmrg func_basename "$file" 94779c9ff80cSmrg name="$func_basename_result" 94786fae4e5dSmrg test "$opt_mode" = uninstall && odir="$dir" 94791f0ac6a5Smrg 94806fae4e5dSmrg # Remember odir for removal later, being careful to avoid duplicates 94816fae4e5dSmrg if test "$opt_mode" = clean; then 94821f0ac6a5Smrg case " $rmdirs " in 94836fae4e5dSmrg *" $odir "*) ;; 94846fae4e5dSmrg *) func_append rmdirs " $odir" ;; 94851f0ac6a5Smrg esac 94861f0ac6a5Smrg fi 94871f0ac6a5Smrg 94881f0ac6a5Smrg # Don't error if the file doesn't exist and rm -f was used. 94899c9ff80cSmrg if { test -L "$file"; } >/dev/null 2>&1 || 94909c9ff80cSmrg { test -h "$file"; } >/dev/null 2>&1 || 94919c9ff80cSmrg test -f "$file"; then 94921f0ac6a5Smrg : 94931f0ac6a5Smrg elif test -d "$file"; then 94941f0ac6a5Smrg exit_status=1 94951f0ac6a5Smrg continue 94961f0ac6a5Smrg elif test "$rmforce" = yes; then 94971f0ac6a5Smrg continue 94981f0ac6a5Smrg fi 94991f0ac6a5Smrg 95001f0ac6a5Smrg rmfiles="$file" 95011f0ac6a5Smrg 95021f0ac6a5Smrg case $name in 95031f0ac6a5Smrg *.la) 95041f0ac6a5Smrg # Possibly a libtool archive, so verify it. 95059c9ff80cSmrg if func_lalib_p "$file"; then 95069c9ff80cSmrg func_source $dir/$name 95071f0ac6a5Smrg 95081f0ac6a5Smrg # Delete the libtool libraries and symlinks. 95091f0ac6a5Smrg for n in $library_names; do 95106fae4e5dSmrg func_append rmfiles " $odir/$n" 95111f0ac6a5Smrg done 95126fae4e5dSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 95131f0ac6a5Smrg 95146fae4e5dSmrg case "$opt_mode" in 95151f0ac6a5Smrg clean) 95166fae4e5dSmrg case " $library_names " in 95171f0ac6a5Smrg *" $dlname "*) ;; 95186fae4e5dSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 95191f0ac6a5Smrg esac 95206fae4e5dSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 95211f0ac6a5Smrg ;; 95221f0ac6a5Smrg uninstall) 95231f0ac6a5Smrg if test -n "$library_names"; then 95241f0ac6a5Smrg # Do each command in the postuninstall commands. 95259c9ff80cSmrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 95261f0ac6a5Smrg fi 95271f0ac6a5Smrg 95281f0ac6a5Smrg if test -n "$old_library"; then 95291f0ac6a5Smrg # Do each command in the old_postuninstall commands. 95309c9ff80cSmrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 95311f0ac6a5Smrg fi 95321f0ac6a5Smrg # FIXME: should reinstall the best remaining shared library. 95331f0ac6a5Smrg ;; 95341f0ac6a5Smrg esac 95351f0ac6a5Smrg fi 95361f0ac6a5Smrg ;; 95371f0ac6a5Smrg 95381f0ac6a5Smrg *.lo) 95391f0ac6a5Smrg # Possibly a libtool object, so verify it. 95409c9ff80cSmrg if func_lalib_p "$file"; then 95411f0ac6a5Smrg 95421f0ac6a5Smrg # Read the .lo file 95439c9ff80cSmrg func_source $dir/$name 95441f0ac6a5Smrg 95451f0ac6a5Smrg # Add PIC object to the list of files to remove. 95469c9ff80cSmrg if test -n "$pic_object" && 95479c9ff80cSmrg test "$pic_object" != none; then 95486fae4e5dSmrg func_append rmfiles " $dir/$pic_object" 95491f0ac6a5Smrg fi 95501f0ac6a5Smrg 95511f0ac6a5Smrg # Add non-PIC object to the list of files to remove. 95529c9ff80cSmrg if test -n "$non_pic_object" && 95539c9ff80cSmrg test "$non_pic_object" != none; then 95546fae4e5dSmrg func_append rmfiles " $dir/$non_pic_object" 95551f0ac6a5Smrg fi 95561f0ac6a5Smrg fi 95571f0ac6a5Smrg ;; 95581f0ac6a5Smrg 95591f0ac6a5Smrg *) 95606fae4e5dSmrg if test "$opt_mode" = clean ; then 95611f0ac6a5Smrg noexename=$name 95621f0ac6a5Smrg case $file in 95631f0ac6a5Smrg *.exe) 95649c9ff80cSmrg func_stripname '' '.exe' "$file" 95659c9ff80cSmrg file=$func_stripname_result 95669c9ff80cSmrg func_stripname '' '.exe' "$name" 95679c9ff80cSmrg noexename=$func_stripname_result 95681f0ac6a5Smrg # $file with .exe has already been added to rmfiles, 95691f0ac6a5Smrg # add $file without .exe 95706fae4e5dSmrg func_append rmfiles " $file" 95711f0ac6a5Smrg ;; 95721f0ac6a5Smrg esac 95731f0ac6a5Smrg # Do a test to see if this is a libtool program. 95749c9ff80cSmrg if func_ltwrapper_p "$file"; then 95759c9ff80cSmrg if func_ltwrapper_executable_p "$file"; then 95769c9ff80cSmrg func_ltwrapper_scriptname "$file" 95779c9ff80cSmrg relink_command= 95789c9ff80cSmrg func_source $func_ltwrapper_scriptname_result 95796fae4e5dSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 95809c9ff80cSmrg else 95819c9ff80cSmrg relink_command= 95829c9ff80cSmrg func_source $dir/$noexename 95839c9ff80cSmrg fi 95841f0ac6a5Smrg 95851f0ac6a5Smrg # note $name still contains .exe if it was in $file originally 95861f0ac6a5Smrg # as does the version of $file that was added into $rmfiles 95876fae4e5dSmrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 95881f0ac6a5Smrg if test "$fast_install" = yes && test -n "$relink_command"; then 95896fae4e5dSmrg func_append rmfiles " $odir/lt-$name" 95901f0ac6a5Smrg fi 95911f0ac6a5Smrg if test "X$noexename" != "X$name" ; then 95926fae4e5dSmrg func_append rmfiles " $odir/lt-${noexename}.c" 95931f0ac6a5Smrg fi 95941f0ac6a5Smrg fi 95951f0ac6a5Smrg fi 95961f0ac6a5Smrg ;; 95971f0ac6a5Smrg esac 95989c9ff80cSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 95991f0ac6a5Smrg done 96001f0ac6a5Smrg 96011f0ac6a5Smrg # Try to remove the ${objdir}s in the directories where we deleted files 96021f0ac6a5Smrg for dir in $rmdirs; do 96031f0ac6a5Smrg if test -d "$dir"; then 96049c9ff80cSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 96051f0ac6a5Smrg fi 96061f0ac6a5Smrg done 96071f0ac6a5Smrg 96081f0ac6a5Smrg exit $exit_status 96099c9ff80cSmrg} 96101f0ac6a5Smrg 96116fae4e5dSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 96129c9ff80cSmrg func_mode_uninstall ${1+"$@"} 96131f0ac6a5Smrg 96146fae4e5dSmrgtest -z "$opt_mode" && { 96159c9ff80cSmrg help="$generic_help" 96169c9ff80cSmrg func_fatal_help "you must specify a MODE" 96179c9ff80cSmrg} 96189c9ff80cSmrg 96199c9ff80cSmrgtest -z "$exec_cmd" && \ 96206fae4e5dSmrg func_fatal_help "invalid operation mode \`$opt_mode'" 96211f0ac6a5Smrg 96221f0ac6a5Smrgif test -n "$exec_cmd"; then 96239c9ff80cSmrg eval exec "$exec_cmd" 96241f0ac6a5Smrg exit $EXIT_FAILURE 96251f0ac6a5Smrgfi 96261f0ac6a5Smrg 96279c9ff80cSmrgexit $exit_status 96281f0ac6a5Smrg 96291f0ac6a5Smrg 96301f0ac6a5Smrg# The TAGs below are defined such that we never get into a situation 96311f0ac6a5Smrg# in which we disable both kinds of libraries. Given conflicting 96321f0ac6a5Smrg# choices, we go for a static library, that is the most portable, 96331f0ac6a5Smrg# since we can't tell whether shared libraries were disabled because 96341f0ac6a5Smrg# the user asked for that or because the platform doesn't support 96351f0ac6a5Smrg# them. This is particularly important on AIX, because we don't 96361f0ac6a5Smrg# support having both static and shared libraries enabled at the same 96371f0ac6a5Smrg# time on that platform, so we default to a shared-only configuration. 96381f0ac6a5Smrg# If a disable-shared tag is given, we'll fallback to a static-only 96391f0ac6a5Smrg# configuration. But we'll never go from static-only to shared-only. 96401f0ac6a5Smrg 96411f0ac6a5Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 96429c9ff80cSmrgbuild_libtool_libs=no 96439c9ff80cSmrgbuild_old_libs=yes 96441f0ac6a5Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 96451f0ac6a5Smrg 96461f0ac6a5Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 96479c9ff80cSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 96481f0ac6a5Smrg# ### END LIBTOOL TAG CONFIG: disable-static 96491f0ac6a5Smrg 96501f0ac6a5Smrg# Local Variables: 96511f0ac6a5Smrg# mode:shell-script 96521f0ac6a5Smrg# sh-indentation:2 96531f0ac6a5Smrg# End: 96549c9ff80cSmrg# vi:sw=2 96559c9ff80cSmrg 9656