ltmain.sh revision 1016ad83
11016ad83Smrg 21016ad83Smrg# libtool (GNU libtool) 2.4.2 31016ad83Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 41016ad83Smrg 51016ad83Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 61016ad83Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 71016ad83Smrg# This is free software; see the source for copying conditions. There is NO 81016ad83Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 91016ad83Smrg 101016ad83Smrg# GNU Libtool is free software; you can redistribute it and/or modify 111016ad83Smrg# it under the terms of the GNU General Public License as published by 121016ad83Smrg# the Free Software Foundation; either version 2 of the License, or 131016ad83Smrg# (at your option) any later version. 141016ad83Smrg# 151016ad83Smrg# As a special exception to the GNU General Public License, 161016ad83Smrg# if you distribute this file as part of a program or library that 171016ad83Smrg# is built using GNU Libtool, you may include this file under the 181016ad83Smrg# same distribution terms that you use for the rest of that program. 191016ad83Smrg# 201016ad83Smrg# GNU Libtool is distributed in the hope that it will be useful, but 211016ad83Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 221016ad83Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 231016ad83Smrg# General Public License for more details. 241016ad83Smrg# 251016ad83Smrg# You should have received a copy of the GNU General Public License 261016ad83Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 271016ad83Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 281016ad83Smrg# or obtained by writing to the Free Software Foundation, Inc., 291016ad83Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 301016ad83Smrg 311016ad83Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 321016ad83Smrg# 331016ad83Smrg# Provide generalized library-building support services. 341016ad83Smrg# 351016ad83Smrg# --config show all configuration variables 361016ad83Smrg# --debug enable verbose shell tracing 371016ad83Smrg# -n, --dry-run display commands without modifying any files 381016ad83Smrg# --features display basic configuration information and exit 391016ad83Smrg# --mode=MODE use operation mode MODE 401016ad83Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 411016ad83Smrg# --quiet, --silent don't print informational messages 421016ad83Smrg# --no-quiet, --no-silent 431016ad83Smrg# print informational messages (default) 441016ad83Smrg# --no-warn don't display warning messages 451016ad83Smrg# --tag=TAG use configuration variables from tag TAG 461016ad83Smrg# -v, --verbose print more informational messages than default 471016ad83Smrg# --no-verbose don't print the extra informational messages 481016ad83Smrg# --version print version information 491016ad83Smrg# -h, --help, --help-all print short, long, or detailed help message 501016ad83Smrg# 511016ad83Smrg# MODE must be one of the following: 521016ad83Smrg# 531016ad83Smrg# clean remove files from the build directory 541016ad83Smrg# compile compile a source file into a libtool object 551016ad83Smrg# execute automatically set library path, then run a program 561016ad83Smrg# finish complete the installation of libtool libraries 571016ad83Smrg# install install libraries or executables 581016ad83Smrg# link create a library or an executable 591016ad83Smrg# uninstall remove libraries from an installed directory 601016ad83Smrg# 611016ad83Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 621016ad83Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 631016ad83Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 641016ad83Smrg# 651016ad83Smrg# When reporting a bug, please describe a test case to reproduce it and 661016ad83Smrg# include the following information: 671016ad83Smrg# 681016ad83Smrg# host-triplet: $host 691016ad83Smrg# shell: $SHELL 701016ad83Smrg# compiler: $LTCC 711016ad83Smrg# compiler flags: $LTCFLAGS 721016ad83Smrg# linker: $LD (gnu? $with_gnu_ld) 731016ad83Smrg# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.3 741016ad83Smrg# automake: $automake_version 751016ad83Smrg# autoconf: $autoconf_version 761016ad83Smrg# 771016ad83Smrg# Report bugs to <bug-libtool@gnu.org>. 781016ad83Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 791016ad83Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 801016ad83Smrg 811016ad83SmrgPROGRAM=libtool 821016ad83SmrgPACKAGE=libtool 831016ad83SmrgVERSION="2.4.2 Debian-2.4.2-1.3" 841016ad83SmrgTIMESTAMP="" 851016ad83Smrgpackage_revision=1.3337 861016ad83Smrg 871016ad83Smrg# Be Bourne compatible 881016ad83Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 891016ad83Smrg emulate sh 901016ad83Smrg NULLCMD=: 911016ad83Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 921016ad83Smrg # is contrary to our usage. Disable this feature. 931016ad83Smrg alias -g '${1+"$@"}'='"$@"' 941016ad83Smrg setopt NO_GLOB_SUBST 951016ad83Smrgelse 961016ad83Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 971016ad83Smrgfi 981016ad83SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 991016ad83SmrgDUALCASE=1; export DUALCASE # for MKS sh 1001016ad83Smrg 1011016ad83Smrg# A function that is used when there is no print builtin or printf. 1021016ad83Smrgfunc_fallback_echo () 1031016ad83Smrg{ 1041016ad83Smrg eval 'cat <<_LTECHO_EOF 1051016ad83Smrg$1 1061016ad83Smrg_LTECHO_EOF' 1071016ad83Smrg} 1081016ad83Smrg 1091016ad83Smrg# NLS nuisances: We save the old values to restore during execute mode. 1101016ad83Smrglt_user_locale= 1111016ad83Smrglt_safe_locale= 1121016ad83Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1131016ad83Smrgdo 1141016ad83Smrg eval "if test \"\${$lt_var+set}\" = set; then 1151016ad83Smrg save_$lt_var=\$$lt_var 1161016ad83Smrg $lt_var=C 1171016ad83Smrg export $lt_var 1181016ad83Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 1191016ad83Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 1201016ad83Smrg fi" 1211016ad83Smrgdone 1221016ad83SmrgLC_ALL=C 1231016ad83SmrgLANGUAGE=C 1241016ad83Smrgexport LANGUAGE LC_ALL 1251016ad83Smrg 1261016ad83Smrg$lt_unset CDPATH 1271016ad83Smrg 1281016ad83Smrg 1291016ad83Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 1301016ad83Smrg# is ksh but when the shell is invoked as "sh" and the current value of 1311016ad83Smrg# the _XPG environment variable is not equal to 1 (one), the special 1321016ad83Smrg# positional parameter $0, within a function call, is the name of the 1331016ad83Smrg# function. 1341016ad83Smrgprogpath="$0" 1351016ad83Smrg 1361016ad83Smrg 1371016ad83Smrg 1381016ad83Smrg: ${CP="cp -f"} 1391016ad83Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 1401016ad83Smrg: ${MAKE="make"} 1411016ad83Smrg: ${MKDIR="mkdir"} 1421016ad83Smrg: ${MV="mv -f"} 1431016ad83Smrg: ${RM="rm -f"} 1441016ad83Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 1451016ad83Smrg: ${Xsed="$SED -e 1s/^X//"} 1461016ad83Smrg 1471016ad83Smrg# Global variables: 1481016ad83SmrgEXIT_SUCCESS=0 1491016ad83SmrgEXIT_FAILURE=1 1501016ad83SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 1511016ad83SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 1521016ad83Smrg 1531016ad83Smrgexit_status=$EXIT_SUCCESS 1541016ad83Smrg 1551016ad83Smrg# Make sure IFS has a sensible default 1561016ad83Smrglt_nl=' 1571016ad83Smrg' 1581016ad83SmrgIFS=" $lt_nl" 1591016ad83Smrg 1601016ad83Smrgdirname="s,/[^/]*$,," 1611016ad83Smrgbasename="s,^.*/,," 1621016ad83Smrg 1631016ad83Smrg# func_dirname file append nondir_replacement 1641016ad83Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 1651016ad83Smrg# otherwise set result to NONDIR_REPLACEMENT. 1661016ad83Smrgfunc_dirname () 1671016ad83Smrg{ 1681016ad83Smrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 1691016ad83Smrg if test "X$func_dirname_result" = "X${1}"; then 1701016ad83Smrg func_dirname_result="${3}" 1711016ad83Smrg else 1721016ad83Smrg func_dirname_result="$func_dirname_result${2}" 1731016ad83Smrg fi 1741016ad83Smrg} # func_dirname may be replaced by extended shell implementation 1751016ad83Smrg 1761016ad83Smrg 1771016ad83Smrg# func_basename file 1781016ad83Smrgfunc_basename () 1791016ad83Smrg{ 1801016ad83Smrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 1811016ad83Smrg} # func_basename may be replaced by extended shell implementation 1821016ad83Smrg 1831016ad83Smrg 1841016ad83Smrg# func_dirname_and_basename file append nondir_replacement 1851016ad83Smrg# perform func_basename and func_dirname in a single function 1861016ad83Smrg# call: 1871016ad83Smrg# dirname: Compute the dirname of FILE. If nonempty, 1881016ad83Smrg# add APPEND to the result, otherwise set result 1891016ad83Smrg# to NONDIR_REPLACEMENT. 1901016ad83Smrg# value returned in "$func_dirname_result" 1911016ad83Smrg# basename: Compute filename of FILE. 1921016ad83Smrg# value retuned in "$func_basename_result" 1931016ad83Smrg# Implementation must be kept synchronized with func_dirname 1941016ad83Smrg# and func_basename. For efficiency, we do not delegate to 1951016ad83Smrg# those functions but instead duplicate the functionality here. 1961016ad83Smrgfunc_dirname_and_basename () 1971016ad83Smrg{ 1981016ad83Smrg # Extract subdirectory from the argument. 1991016ad83Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 2001016ad83Smrg if test "X$func_dirname_result" = "X${1}"; then 2011016ad83Smrg func_dirname_result="${3}" 2021016ad83Smrg else 2031016ad83Smrg func_dirname_result="$func_dirname_result${2}" 2041016ad83Smrg fi 2051016ad83Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 2061016ad83Smrg} # func_dirname_and_basename may be replaced by extended shell implementation 2071016ad83Smrg 2081016ad83Smrg 2091016ad83Smrg# func_stripname prefix suffix name 2101016ad83Smrg# strip PREFIX and SUFFIX off of NAME. 2111016ad83Smrg# PREFIX and SUFFIX must not contain globbing or regex special 2121016ad83Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 2131016ad83Smrg# dot (in which case that matches only a dot). 2141016ad83Smrg# func_strip_suffix prefix name 2151016ad83Smrgfunc_stripname () 2161016ad83Smrg{ 2171016ad83Smrg case ${2} in 2181016ad83Smrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 2191016ad83Smrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 2201016ad83Smrg esac 2211016ad83Smrg} # func_stripname may be replaced by extended shell implementation 2221016ad83Smrg 2231016ad83Smrg 2241016ad83Smrg# These SED scripts presuppose an absolute path with a trailing slash. 2251016ad83Smrgpathcar='s,^/\([^/]*\).*$,\1,' 2261016ad83Smrgpathcdr='s,^/[^/]*,,' 2271016ad83Smrgremovedotparts=':dotsl 2281016ad83Smrg s@/\./@/@g 2291016ad83Smrg t dotsl 2301016ad83Smrg s,/\.$,/,' 2311016ad83Smrgcollapseslashes='s@/\{1,\}@/@g' 2321016ad83Smrgfinalslash='s,/*$,/,' 2331016ad83Smrg 2341016ad83Smrg# func_normal_abspath PATH 2351016ad83Smrg# Remove doubled-up and trailing slashes, "." path components, 2361016ad83Smrg# and cancel out any ".." path components in PATH after making 2371016ad83Smrg# it an absolute path. 2381016ad83Smrg# value returned in "$func_normal_abspath_result" 2391016ad83Smrgfunc_normal_abspath () 2401016ad83Smrg{ 2411016ad83Smrg # Start from root dir and reassemble the path. 2421016ad83Smrg func_normal_abspath_result= 2431016ad83Smrg func_normal_abspath_tpath=$1 2441016ad83Smrg func_normal_abspath_altnamespace= 2451016ad83Smrg case $func_normal_abspath_tpath in 2461016ad83Smrg "") 2471016ad83Smrg # Empty path, that just means $cwd. 2481016ad83Smrg func_stripname '' '/' "`pwd`" 2491016ad83Smrg func_normal_abspath_result=$func_stripname_result 2501016ad83Smrg return 2511016ad83Smrg ;; 2521016ad83Smrg # The next three entries are used to spot a run of precisely 2531016ad83Smrg # two leading slashes without using negated character classes; 2541016ad83Smrg # we take advantage of case's first-match behaviour. 2551016ad83Smrg ///*) 2561016ad83Smrg # Unusual form of absolute path, do nothing. 2571016ad83Smrg ;; 2581016ad83Smrg //*) 2591016ad83Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 2601016ad83Smrg # and for example Cygwin uses it to access remote file shares 2611016ad83Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 2621016ad83Smrg func_normal_abspath_altnamespace=/ 2631016ad83Smrg ;; 2641016ad83Smrg /*) 2651016ad83Smrg # Absolute path, do nothing. 2661016ad83Smrg ;; 2671016ad83Smrg *) 2681016ad83Smrg # Relative path, prepend $cwd. 2691016ad83Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 2701016ad83Smrg ;; 2711016ad83Smrg esac 2721016ad83Smrg # Cancel out all the simple stuff to save iterations. We also want 2731016ad83Smrg # the path to end with a slash for ease of parsing, so make sure 2741016ad83Smrg # there is one (and only one) here. 2751016ad83Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 2761016ad83Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 2771016ad83Smrg while :; do 2781016ad83Smrg # Processed it all yet? 2791016ad83Smrg if test "$func_normal_abspath_tpath" = / ; then 2801016ad83Smrg # If we ascended to the root using ".." the result may be empty now. 2811016ad83Smrg if test -z "$func_normal_abspath_result" ; then 2821016ad83Smrg func_normal_abspath_result=/ 2831016ad83Smrg fi 2841016ad83Smrg break 2851016ad83Smrg fi 2861016ad83Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 2871016ad83Smrg -e "$pathcar"` 2881016ad83Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 2891016ad83Smrg -e "$pathcdr"` 2901016ad83Smrg # Figure out what to do with it 2911016ad83Smrg case $func_normal_abspath_tcomponent in 2921016ad83Smrg "") 2931016ad83Smrg # Trailing empty path component, ignore it. 2941016ad83Smrg ;; 2951016ad83Smrg ..) 2961016ad83Smrg # Parent dir; strip last assembled component from result. 2971016ad83Smrg func_dirname "$func_normal_abspath_result" 2981016ad83Smrg func_normal_abspath_result=$func_dirname_result 2991016ad83Smrg ;; 3001016ad83Smrg *) 3011016ad83Smrg # Actual path component, append it. 3021016ad83Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 3031016ad83Smrg ;; 3041016ad83Smrg esac 3051016ad83Smrg done 3061016ad83Smrg # Restore leading double-slash if one was found on entry. 3071016ad83Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 3081016ad83Smrg} 3091016ad83Smrg 3101016ad83Smrg# func_relative_path SRCDIR DSTDIR 3111016ad83Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 3121016ad83Smrg# slash if non-empty, suitable for immediately appending a filename 3131016ad83Smrg# without needing to append a separator. 3141016ad83Smrg# value returned in "$func_relative_path_result" 3151016ad83Smrgfunc_relative_path () 3161016ad83Smrg{ 3171016ad83Smrg func_relative_path_result= 3181016ad83Smrg func_normal_abspath "$1" 3191016ad83Smrg func_relative_path_tlibdir=$func_normal_abspath_result 3201016ad83Smrg func_normal_abspath "$2" 3211016ad83Smrg func_relative_path_tbindir=$func_normal_abspath_result 3221016ad83Smrg 3231016ad83Smrg # Ascend the tree starting from libdir 3241016ad83Smrg while :; do 3251016ad83Smrg # check if we have found a prefix of bindir 3261016ad83Smrg case $func_relative_path_tbindir in 3271016ad83Smrg $func_relative_path_tlibdir) 3281016ad83Smrg # found an exact match 3291016ad83Smrg func_relative_path_tcancelled= 3301016ad83Smrg break 3311016ad83Smrg ;; 3321016ad83Smrg $func_relative_path_tlibdir*) 3331016ad83Smrg # found a matching prefix 3341016ad83Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 3351016ad83Smrg func_relative_path_tcancelled=$func_stripname_result 3361016ad83Smrg if test -z "$func_relative_path_result"; then 3371016ad83Smrg func_relative_path_result=. 3381016ad83Smrg fi 3391016ad83Smrg break 3401016ad83Smrg ;; 3411016ad83Smrg *) 3421016ad83Smrg func_dirname $func_relative_path_tlibdir 3431016ad83Smrg func_relative_path_tlibdir=${func_dirname_result} 3441016ad83Smrg if test "x$func_relative_path_tlibdir" = x ; then 3451016ad83Smrg # Have to descend all the way to the root! 3461016ad83Smrg func_relative_path_result=../$func_relative_path_result 3471016ad83Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 3481016ad83Smrg break 3491016ad83Smrg fi 3501016ad83Smrg func_relative_path_result=../$func_relative_path_result 3511016ad83Smrg ;; 3521016ad83Smrg esac 3531016ad83Smrg done 3541016ad83Smrg 3551016ad83Smrg # Now calculate path; take care to avoid doubling-up slashes. 3561016ad83Smrg func_stripname '' '/' "$func_relative_path_result" 3571016ad83Smrg func_relative_path_result=$func_stripname_result 3581016ad83Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 3591016ad83Smrg if test "x$func_stripname_result" != x ; then 3601016ad83Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 3611016ad83Smrg fi 3621016ad83Smrg 3631016ad83Smrg # Normalisation. If bindir is libdir, return empty string, 3641016ad83Smrg # else relative path ending with a slash; either way, target 3651016ad83Smrg # file name can be directly appended. 3661016ad83Smrg if test ! -z "$func_relative_path_result"; then 3671016ad83Smrg func_stripname './' '' "$func_relative_path_result/" 3681016ad83Smrg func_relative_path_result=$func_stripname_result 3691016ad83Smrg fi 3701016ad83Smrg} 3711016ad83Smrg 3721016ad83Smrg# The name of this program: 3731016ad83Smrgfunc_dirname_and_basename "$progpath" 3741016ad83Smrgprogname=$func_basename_result 3751016ad83Smrg 3761016ad83Smrg# Make sure we have an absolute path for reexecution: 3771016ad83Smrgcase $progpath in 3781016ad83Smrg [\\/]*|[A-Za-z]:\\*) ;; 3791016ad83Smrg *[\\/]*) 3801016ad83Smrg progdir=$func_dirname_result 3811016ad83Smrg progdir=`cd "$progdir" && pwd` 3821016ad83Smrg progpath="$progdir/$progname" 3831016ad83Smrg ;; 3841016ad83Smrg *) 3851016ad83Smrg save_IFS="$IFS" 3861016ad83Smrg IFS=${PATH_SEPARATOR-:} 3871016ad83Smrg for progdir in $PATH; do 3881016ad83Smrg IFS="$save_IFS" 3891016ad83Smrg test -x "$progdir/$progname" && break 3901016ad83Smrg done 3911016ad83Smrg IFS="$save_IFS" 3921016ad83Smrg test -n "$progdir" || progdir=`pwd` 3931016ad83Smrg progpath="$progdir/$progname" 3941016ad83Smrg ;; 3951016ad83Smrgesac 3961016ad83Smrg 3971016ad83Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3981016ad83Smrg# metacharacters that are still active within double-quoted strings. 3991016ad83SmrgXsed="${SED}"' -e 1s/^X//' 4001016ad83Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 4011016ad83Smrg 4021016ad83Smrg# Same as above, but do not quote variable references. 4031016ad83Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 4041016ad83Smrg 4051016ad83Smrg# Sed substitution that turns a string into a regex matching for the 4061016ad83Smrg# string literally. 4071016ad83Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 4081016ad83Smrg 4091016ad83Smrg# Sed substitution that converts a w32 file name or path 4101016ad83Smrg# which contains forward slashes, into one that contains 4111016ad83Smrg# (escaped) backslashes. A very naive implementation. 4121016ad83Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 4131016ad83Smrg 4141016ad83Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 4151016ad83Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 4161016ad83Smrg# in input to double_quote_subst, that '$' was protected from expansion. 4171016ad83Smrg# Since each input `\' is now two `\'s, look for any number of runs of 4181016ad83Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 4191016ad83Smrgbs='\\' 4201016ad83Smrgbs2='\\\\' 4211016ad83Smrgbs4='\\\\\\\\' 4221016ad83Smrgdollar='\$' 4231016ad83Smrgsed_double_backslash="\ 4241016ad83Smrg s/$bs4/&\\ 4251016ad83Smrg/g 4261016ad83Smrg s/^$bs2$dollar/$bs&/ 4271016ad83Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 4281016ad83Smrg s/\n//g" 4291016ad83Smrg 4301016ad83Smrg# Standard options: 4311016ad83Smrgopt_dry_run=false 4321016ad83Smrgopt_help=false 4331016ad83Smrgopt_quiet=false 4341016ad83Smrgopt_verbose=false 4351016ad83Smrgopt_warning=: 4361016ad83Smrg 4371016ad83Smrg# func_echo arg... 4381016ad83Smrg# Echo program name prefixed message, along with the current mode 4391016ad83Smrg# name if it has been set yet. 4401016ad83Smrgfunc_echo () 4411016ad83Smrg{ 4421016ad83Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 4431016ad83Smrg} 4441016ad83Smrg 4451016ad83Smrg# func_verbose arg... 4461016ad83Smrg# Echo program name prefixed message in verbose mode only. 4471016ad83Smrgfunc_verbose () 4481016ad83Smrg{ 4491016ad83Smrg $opt_verbose && func_echo ${1+"$@"} 4501016ad83Smrg 4511016ad83Smrg # A bug in bash halts the script if the last line of a function 4521016ad83Smrg # fails when set -e is in force, so we need another command to 4531016ad83Smrg # work around that: 4541016ad83Smrg : 4551016ad83Smrg} 4561016ad83Smrg 4571016ad83Smrg# func_echo_all arg... 4581016ad83Smrg# Invoke $ECHO with all args, space-separated. 4591016ad83Smrgfunc_echo_all () 4601016ad83Smrg{ 4611016ad83Smrg $ECHO "$*" 4621016ad83Smrg} 4631016ad83Smrg 4641016ad83Smrg# func_error arg... 4651016ad83Smrg# Echo program name prefixed message to standard error. 4661016ad83Smrgfunc_error () 4671016ad83Smrg{ 4681016ad83Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 4691016ad83Smrg} 4701016ad83Smrg 4711016ad83Smrg# func_warning arg... 4721016ad83Smrg# Echo program name prefixed warning message to standard error. 4731016ad83Smrgfunc_warning () 4741016ad83Smrg{ 4751016ad83Smrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 4761016ad83Smrg 4771016ad83Smrg # bash bug again: 4781016ad83Smrg : 4791016ad83Smrg} 4801016ad83Smrg 4811016ad83Smrg# func_fatal_error arg... 4821016ad83Smrg# Echo program name prefixed message to standard error, and exit. 4831016ad83Smrgfunc_fatal_error () 4841016ad83Smrg{ 4851016ad83Smrg func_error ${1+"$@"} 4861016ad83Smrg exit $EXIT_FAILURE 4871016ad83Smrg} 4881016ad83Smrg 4891016ad83Smrg# func_fatal_help arg... 4901016ad83Smrg# Echo program name prefixed message to standard error, followed by 4911016ad83Smrg# a help hint, and exit. 4921016ad83Smrgfunc_fatal_help () 4931016ad83Smrg{ 4941016ad83Smrg func_error ${1+"$@"} 4951016ad83Smrg func_fatal_error "$help" 4961016ad83Smrg} 4971016ad83Smrghelp="Try \`$progname --help' for more information." ## default 4981016ad83Smrg 4991016ad83Smrg 5001016ad83Smrg# func_grep expression filename 5011016ad83Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 5021016ad83Smrgfunc_grep () 5031016ad83Smrg{ 5041016ad83Smrg $GREP "$1" "$2" >/dev/null 2>&1 5051016ad83Smrg} 5061016ad83Smrg 5071016ad83Smrg 5081016ad83Smrg# func_mkdir_p directory-path 5091016ad83Smrg# Make sure the entire path to DIRECTORY-PATH is available. 5101016ad83Smrgfunc_mkdir_p () 5111016ad83Smrg{ 5121016ad83Smrg my_directory_path="$1" 5131016ad83Smrg my_dir_list= 5141016ad83Smrg 5151016ad83Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 5161016ad83Smrg 5171016ad83Smrg # Protect directory names starting with `-' 5181016ad83Smrg case $my_directory_path in 5191016ad83Smrg -*) my_directory_path="./$my_directory_path" ;; 5201016ad83Smrg esac 5211016ad83Smrg 5221016ad83Smrg # While some portion of DIR does not yet exist... 5231016ad83Smrg while test ! -d "$my_directory_path"; do 5241016ad83Smrg # ...make a list in topmost first order. Use a colon delimited 5251016ad83Smrg # list incase some portion of path contains whitespace. 5261016ad83Smrg my_dir_list="$my_directory_path:$my_dir_list" 5271016ad83Smrg 5281016ad83Smrg # If the last portion added has no slash in it, the list is done 5291016ad83Smrg case $my_directory_path in */*) ;; *) break ;; esac 5301016ad83Smrg 5311016ad83Smrg # ...otherwise throw away the child directory and loop 5321016ad83Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 5331016ad83Smrg done 5341016ad83Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 5351016ad83Smrg 5361016ad83Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 5371016ad83Smrg for my_dir in $my_dir_list; do 5381016ad83Smrg IFS="$save_mkdir_p_IFS" 5391016ad83Smrg # mkdir can fail with a `File exist' error if two processes 5401016ad83Smrg # try to create one of the directories concurrently. Don't 5411016ad83Smrg # stop in that case! 5421016ad83Smrg $MKDIR "$my_dir" 2>/dev/null || : 5431016ad83Smrg done 5441016ad83Smrg IFS="$save_mkdir_p_IFS" 5451016ad83Smrg 5461016ad83Smrg # Bail out if we (or some other process) failed to create a directory. 5471016ad83Smrg test -d "$my_directory_path" || \ 5481016ad83Smrg func_fatal_error "Failed to create \`$1'" 5491016ad83Smrg fi 5501016ad83Smrg} 5511016ad83Smrg 5521016ad83Smrg 5531016ad83Smrg# func_mktempdir [string] 5541016ad83Smrg# Make a temporary directory that won't clash with other running 5551016ad83Smrg# libtool processes, and avoids race conditions if possible. If 5561016ad83Smrg# given, STRING is the basename for that directory. 5571016ad83Smrgfunc_mktempdir () 5581016ad83Smrg{ 5591016ad83Smrg my_template="${TMPDIR-/tmp}/${1-$progname}" 5601016ad83Smrg 5611016ad83Smrg if test "$opt_dry_run" = ":"; then 5621016ad83Smrg # Return a directory name, but don't create it in dry-run mode 5631016ad83Smrg my_tmpdir="${my_template}-$$" 5641016ad83Smrg else 5651016ad83Smrg 5661016ad83Smrg # If mktemp works, use that first and foremost 5671016ad83Smrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 5681016ad83Smrg 5691016ad83Smrg if test ! -d "$my_tmpdir"; then 5701016ad83Smrg # Failing that, at least try and use $RANDOM to avoid a race 5711016ad83Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 5721016ad83Smrg 5731016ad83Smrg save_mktempdir_umask=`umask` 5741016ad83Smrg umask 0077 5751016ad83Smrg $MKDIR "$my_tmpdir" 5761016ad83Smrg umask $save_mktempdir_umask 5771016ad83Smrg fi 5781016ad83Smrg 5791016ad83Smrg # If we're not in dry-run mode, bomb out on failure 5801016ad83Smrg test -d "$my_tmpdir" || \ 5811016ad83Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 5821016ad83Smrg fi 5831016ad83Smrg 5841016ad83Smrg $ECHO "$my_tmpdir" 5851016ad83Smrg} 5861016ad83Smrg 5871016ad83Smrg 5881016ad83Smrg# func_quote_for_eval arg 5891016ad83Smrg# Aesthetically quote ARG to be evaled later. 5901016ad83Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 5911016ad83Smrg# is double-quoted, suitable for a subsequent eval, whereas 5921016ad83Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 5931016ad83Smrg# which are still active within double quotes backslashified. 5941016ad83Smrgfunc_quote_for_eval () 5951016ad83Smrg{ 5961016ad83Smrg case $1 in 5971016ad83Smrg *[\\\`\"\$]*) 5981016ad83Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 5991016ad83Smrg *) 6001016ad83Smrg func_quote_for_eval_unquoted_result="$1" ;; 6011016ad83Smrg esac 6021016ad83Smrg 6031016ad83Smrg case $func_quote_for_eval_unquoted_result in 6041016ad83Smrg # Double-quote args containing shell metacharacters to delay 6051016ad83Smrg # word splitting, command substitution and and variable 6061016ad83Smrg # expansion for a subsequent eval. 6071016ad83Smrg # Many Bourne shells cannot handle close brackets correctly 6081016ad83Smrg # in scan sets, so we specify it separately. 6091016ad83Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 6101016ad83Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 6111016ad83Smrg ;; 6121016ad83Smrg *) 6131016ad83Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 6141016ad83Smrg esac 6151016ad83Smrg} 6161016ad83Smrg 6171016ad83Smrg 6181016ad83Smrg# func_quote_for_expand arg 6191016ad83Smrg# Aesthetically quote ARG to be evaled later; same as above, 6201016ad83Smrg# but do not quote variable references. 6211016ad83Smrgfunc_quote_for_expand () 6221016ad83Smrg{ 6231016ad83Smrg case $1 in 6241016ad83Smrg *[\\\`\"]*) 6251016ad83Smrg my_arg=`$ECHO "$1" | $SED \ 6261016ad83Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 6271016ad83Smrg *) 6281016ad83Smrg my_arg="$1" ;; 6291016ad83Smrg esac 6301016ad83Smrg 6311016ad83Smrg case $my_arg in 6321016ad83Smrg # Double-quote args containing shell metacharacters to delay 6331016ad83Smrg # word splitting and command substitution for a subsequent eval. 6341016ad83Smrg # Many Bourne shells cannot handle close brackets correctly 6351016ad83Smrg # in scan sets, so we specify it separately. 6361016ad83Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 6371016ad83Smrg my_arg="\"$my_arg\"" 6381016ad83Smrg ;; 6391016ad83Smrg esac 6401016ad83Smrg 6411016ad83Smrg func_quote_for_expand_result="$my_arg" 6421016ad83Smrg} 6431016ad83Smrg 6441016ad83Smrg 6451016ad83Smrg# func_show_eval cmd [fail_exp] 6461016ad83Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6471016ad83Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6481016ad83Smrg# is given, then evaluate it. 6491016ad83Smrgfunc_show_eval () 6501016ad83Smrg{ 6511016ad83Smrg my_cmd="$1" 6521016ad83Smrg my_fail_exp="${2-:}" 6531016ad83Smrg 6541016ad83Smrg ${opt_silent-false} || { 6551016ad83Smrg func_quote_for_expand "$my_cmd" 6561016ad83Smrg eval "func_echo $func_quote_for_expand_result" 6571016ad83Smrg } 6581016ad83Smrg 6591016ad83Smrg if ${opt_dry_run-false}; then :; else 6601016ad83Smrg eval "$my_cmd" 6611016ad83Smrg my_status=$? 6621016ad83Smrg if test "$my_status" -eq 0; then :; else 6631016ad83Smrg eval "(exit $my_status); $my_fail_exp" 6641016ad83Smrg fi 6651016ad83Smrg fi 6661016ad83Smrg} 6671016ad83Smrg 6681016ad83Smrg 6691016ad83Smrg# func_show_eval_locale cmd [fail_exp] 6701016ad83Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6711016ad83Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6721016ad83Smrg# is given, then evaluate it. Use the saved locale for evaluation. 6731016ad83Smrgfunc_show_eval_locale () 6741016ad83Smrg{ 6751016ad83Smrg my_cmd="$1" 6761016ad83Smrg my_fail_exp="${2-:}" 6771016ad83Smrg 6781016ad83Smrg ${opt_silent-false} || { 6791016ad83Smrg func_quote_for_expand "$my_cmd" 6801016ad83Smrg eval "func_echo $func_quote_for_expand_result" 6811016ad83Smrg } 6821016ad83Smrg 6831016ad83Smrg if ${opt_dry_run-false}; then :; else 6841016ad83Smrg eval "$lt_user_locale 6851016ad83Smrg $my_cmd" 6861016ad83Smrg my_status=$? 6871016ad83Smrg eval "$lt_safe_locale" 6881016ad83Smrg if test "$my_status" -eq 0; then :; else 6891016ad83Smrg eval "(exit $my_status); $my_fail_exp" 6901016ad83Smrg fi 6911016ad83Smrg fi 6921016ad83Smrg} 6931016ad83Smrg 6941016ad83Smrg# func_tr_sh 6951016ad83Smrg# Turn $1 into a string suitable for a shell variable name. 6961016ad83Smrg# Result is stored in $func_tr_sh_result. All characters 6971016ad83Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 6981016ad83Smrg# if $1 begins with a digit, a '_' is prepended as well. 6991016ad83Smrgfunc_tr_sh () 7001016ad83Smrg{ 7011016ad83Smrg case $1 in 7021016ad83Smrg [0-9]* | *[!a-zA-Z0-9_]*) 7031016ad83Smrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 7041016ad83Smrg ;; 7051016ad83Smrg * ) 7061016ad83Smrg func_tr_sh_result=$1 7071016ad83Smrg ;; 7081016ad83Smrg esac 7091016ad83Smrg} 7101016ad83Smrg 7111016ad83Smrg 7121016ad83Smrg# func_version 7131016ad83Smrg# Echo version message to standard output and exit. 7141016ad83Smrgfunc_version () 7151016ad83Smrg{ 7161016ad83Smrg $opt_debug 7171016ad83Smrg 7181016ad83Smrg $SED -n '/(C)/!b go 7191016ad83Smrg :more 7201016ad83Smrg /\./!{ 7211016ad83Smrg N 7221016ad83Smrg s/\n# / / 7231016ad83Smrg b more 7241016ad83Smrg } 7251016ad83Smrg :go 7261016ad83Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 7271016ad83Smrg s/^# // 7281016ad83Smrg s/^# *$// 7291016ad83Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 7301016ad83Smrg p 7311016ad83Smrg }' < "$progpath" 7321016ad83Smrg exit $? 7331016ad83Smrg} 7341016ad83Smrg 7351016ad83Smrg# func_usage 7361016ad83Smrg# Echo short help message to standard output and exit. 7371016ad83Smrgfunc_usage () 7381016ad83Smrg{ 7391016ad83Smrg $opt_debug 7401016ad83Smrg 7411016ad83Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 7421016ad83Smrg s/^# // 7431016ad83Smrg s/^# *$// 7441016ad83Smrg s/\$progname/'$progname'/ 7451016ad83Smrg p 7461016ad83Smrg }' < "$progpath" 7471016ad83Smrg echo 7481016ad83Smrg $ECHO "run \`$progname --help | more' for full usage" 7491016ad83Smrg exit $? 7501016ad83Smrg} 7511016ad83Smrg 7521016ad83Smrg# func_help [NOEXIT] 7531016ad83Smrg# Echo long help message to standard output and exit, 7541016ad83Smrg# unless 'noexit' is passed as argument. 7551016ad83Smrgfunc_help () 7561016ad83Smrg{ 7571016ad83Smrg $opt_debug 7581016ad83Smrg 7591016ad83Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 7601016ad83Smrg :print 7611016ad83Smrg s/^# // 7621016ad83Smrg s/^# *$// 7631016ad83Smrg s*\$progname*'$progname'* 7641016ad83Smrg s*\$host*'"$host"'* 7651016ad83Smrg s*\$SHELL*'"$SHELL"'* 7661016ad83Smrg s*\$LTCC*'"$LTCC"'* 7671016ad83Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 7681016ad83Smrg s*\$LD*'"$LD"'* 7691016ad83Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 7701016ad83Smrg s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 7711016ad83Smrg s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 7721016ad83Smrg p 7731016ad83Smrg d 7741016ad83Smrg } 7751016ad83Smrg /^# .* home page:/b print 7761016ad83Smrg /^# General help using/b print 7771016ad83Smrg ' < "$progpath" 7781016ad83Smrg ret=$? 7791016ad83Smrg if test -z "$1"; then 7801016ad83Smrg exit $ret 7811016ad83Smrg fi 7821016ad83Smrg} 7831016ad83Smrg 7841016ad83Smrg# func_missing_arg argname 7851016ad83Smrg# Echo program name prefixed message to standard error and set global 7861016ad83Smrg# exit_cmd. 7871016ad83Smrgfunc_missing_arg () 7881016ad83Smrg{ 7891016ad83Smrg $opt_debug 7901016ad83Smrg 7911016ad83Smrg func_error "missing argument for $1." 7921016ad83Smrg exit_cmd=exit 7931016ad83Smrg} 7941016ad83Smrg 7951016ad83Smrg 7961016ad83Smrg# func_split_short_opt shortopt 7971016ad83Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 7981016ad83Smrg# variables after splitting SHORTOPT after the 2nd character. 7991016ad83Smrgfunc_split_short_opt () 8001016ad83Smrg{ 8011016ad83Smrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 8021016ad83Smrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 8031016ad83Smrg 8041016ad83Smrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 8051016ad83Smrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 8061016ad83Smrg} # func_split_short_opt may be replaced by extended shell implementation 8071016ad83Smrg 8081016ad83Smrg 8091016ad83Smrg# func_split_long_opt longopt 8101016ad83Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 8111016ad83Smrg# variables after splitting LONGOPT at the `=' sign. 8121016ad83Smrgfunc_split_long_opt () 8131016ad83Smrg{ 8141016ad83Smrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 8151016ad83Smrg my_sed_long_arg='1s/^--[^=]*=//' 8161016ad83Smrg 8171016ad83Smrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 8181016ad83Smrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 8191016ad83Smrg} # func_split_long_opt may be replaced by extended shell implementation 8201016ad83Smrg 8211016ad83Smrgexit_cmd=: 8221016ad83Smrg 8231016ad83Smrg 8241016ad83Smrg 8251016ad83Smrg 8261016ad83Smrg 8271016ad83Smrgmagic="%%%MAGIC variable%%%" 8281016ad83Smrgmagic_exe="%%%MAGIC EXE variable%%%" 8291016ad83Smrg 8301016ad83Smrg# Global variables. 8311016ad83Smrgnonopt= 8321016ad83Smrgpreserve_args= 8331016ad83Smrglo2o="s/\\.lo\$/.${objext}/" 8341016ad83Smrgo2lo="s/\\.${objext}\$/.lo/" 8351016ad83Smrgextracted_archives= 8361016ad83Smrgextracted_serial=0 8371016ad83Smrg 8381016ad83Smrg# If this variable is set in any of the actions, the command in it 8391016ad83Smrg# will be execed at the end. This prevents here-documents from being 8401016ad83Smrg# left over by shells. 8411016ad83Smrgexec_cmd= 8421016ad83Smrg 8431016ad83Smrg# func_append var value 8441016ad83Smrg# Append VALUE to the end of shell variable VAR. 8451016ad83Smrgfunc_append () 8461016ad83Smrg{ 8471016ad83Smrg eval "${1}=\$${1}\${2}" 8481016ad83Smrg} # func_append may be replaced by extended shell implementation 8491016ad83Smrg 8501016ad83Smrg# func_append_quoted var value 8511016ad83Smrg# Quote VALUE and append to the end of shell variable VAR, separated 8521016ad83Smrg# by a space. 8531016ad83Smrgfunc_append_quoted () 8541016ad83Smrg{ 8551016ad83Smrg func_quote_for_eval "${2}" 8561016ad83Smrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 8571016ad83Smrg} # func_append_quoted may be replaced by extended shell implementation 8581016ad83Smrg 8591016ad83Smrg 8601016ad83Smrg# func_arith arithmetic-term... 8611016ad83Smrgfunc_arith () 8621016ad83Smrg{ 8631016ad83Smrg func_arith_result=`expr "${@}"` 8641016ad83Smrg} # func_arith may be replaced by extended shell implementation 8651016ad83Smrg 8661016ad83Smrg 8671016ad83Smrg# func_len string 8681016ad83Smrg# STRING may not start with a hyphen. 8691016ad83Smrgfunc_len () 8701016ad83Smrg{ 8711016ad83Smrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 8721016ad83Smrg} # func_len may be replaced by extended shell implementation 8731016ad83Smrg 8741016ad83Smrg 8751016ad83Smrg# func_lo2o object 8761016ad83Smrgfunc_lo2o () 8771016ad83Smrg{ 8781016ad83Smrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 8791016ad83Smrg} # func_lo2o may be replaced by extended shell implementation 8801016ad83Smrg 8811016ad83Smrg 8821016ad83Smrg# func_xform libobj-or-source 8831016ad83Smrgfunc_xform () 8841016ad83Smrg{ 8851016ad83Smrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 8861016ad83Smrg} # func_xform may be replaced by extended shell implementation 8871016ad83Smrg 8881016ad83Smrg 8891016ad83Smrg# func_fatal_configuration arg... 8901016ad83Smrg# Echo program name prefixed message to standard error, followed by 8911016ad83Smrg# a configuration failure hint, and exit. 8921016ad83Smrgfunc_fatal_configuration () 8931016ad83Smrg{ 8941016ad83Smrg func_error ${1+"$@"} 8951016ad83Smrg func_error "See the $PACKAGE documentation for more information." 8961016ad83Smrg func_fatal_error "Fatal configuration error." 8971016ad83Smrg} 8981016ad83Smrg 8991016ad83Smrg 9001016ad83Smrg# func_config 9011016ad83Smrg# Display the configuration for all the tags in this script. 9021016ad83Smrgfunc_config () 9031016ad83Smrg{ 9041016ad83Smrg re_begincf='^# ### BEGIN LIBTOOL' 9051016ad83Smrg re_endcf='^# ### END LIBTOOL' 9061016ad83Smrg 9071016ad83Smrg # Default configuration. 9081016ad83Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 9091016ad83Smrg 9101016ad83Smrg # Now print the configurations for the tags. 9111016ad83Smrg for tagname in $taglist; do 9121016ad83Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 9131016ad83Smrg done 9141016ad83Smrg 9151016ad83Smrg exit $? 9161016ad83Smrg} 9171016ad83Smrg 9181016ad83Smrg# func_features 9191016ad83Smrg# Display the features supported by this script. 9201016ad83Smrgfunc_features () 9211016ad83Smrg{ 9221016ad83Smrg echo "host: $host" 9231016ad83Smrg if test "$build_libtool_libs" = yes; then 9241016ad83Smrg echo "enable shared libraries" 9251016ad83Smrg else 9261016ad83Smrg echo "disable shared libraries" 9271016ad83Smrg fi 9281016ad83Smrg if test "$build_old_libs" = yes; then 9291016ad83Smrg echo "enable static libraries" 9301016ad83Smrg else 9311016ad83Smrg echo "disable static libraries" 9321016ad83Smrg fi 9331016ad83Smrg 9341016ad83Smrg exit $? 9351016ad83Smrg} 9361016ad83Smrg 9371016ad83Smrg# func_enable_tag tagname 9381016ad83Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 9391016ad83Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 9401016ad83Smrg# variable here. 9411016ad83Smrgfunc_enable_tag () 9421016ad83Smrg{ 9431016ad83Smrg # Global variable: 9441016ad83Smrg tagname="$1" 9451016ad83Smrg 9461016ad83Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 9471016ad83Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 9481016ad83Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 9491016ad83Smrg 9501016ad83Smrg # Validate tagname. 9511016ad83Smrg case $tagname in 9521016ad83Smrg *[!-_A-Za-z0-9,/]*) 9531016ad83Smrg func_fatal_error "invalid tag name: $tagname" 9541016ad83Smrg ;; 9551016ad83Smrg esac 9561016ad83Smrg 9571016ad83Smrg # Don't test for the "default" C tag, as we know it's 9581016ad83Smrg # there but not specially marked. 9591016ad83Smrg case $tagname in 9601016ad83Smrg CC) ;; 9611016ad83Smrg *) 9621016ad83Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 9631016ad83Smrg taglist="$taglist $tagname" 9641016ad83Smrg 9651016ad83Smrg # Evaluate the configuration. Be careful to quote the path 9661016ad83Smrg # and the sed script, to avoid splitting on whitespace, but 9671016ad83Smrg # also don't use non-portable quotes within backquotes within 9681016ad83Smrg # quotes we have to do it in 2 steps: 9691016ad83Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 9701016ad83Smrg eval "$extractedcf" 9711016ad83Smrg else 9721016ad83Smrg func_error "ignoring unknown tag $tagname" 9731016ad83Smrg fi 9741016ad83Smrg ;; 9751016ad83Smrg esac 9761016ad83Smrg} 9771016ad83Smrg 9781016ad83Smrg# func_check_version_match 9791016ad83Smrg# Ensure that we are using m4 macros, and libtool script from the same 9801016ad83Smrg# release of libtool. 9811016ad83Smrgfunc_check_version_match () 9821016ad83Smrg{ 9831016ad83Smrg if test "$package_revision" != "$macro_revision"; then 9841016ad83Smrg if test "$VERSION" != "$macro_version"; then 9851016ad83Smrg if test -z "$macro_version"; then 9861016ad83Smrg cat >&2 <<_LT_EOF 9871016ad83Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 9881016ad83Smrg$progname: definition of this LT_INIT comes from an older release. 9891016ad83Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 9901016ad83Smrg$progname: and run autoconf again. 9911016ad83Smrg_LT_EOF 9921016ad83Smrg else 9931016ad83Smrg cat >&2 <<_LT_EOF 9941016ad83Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 9951016ad83Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 9961016ad83Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 9971016ad83Smrg$progname: and run autoconf again. 9981016ad83Smrg_LT_EOF 9991016ad83Smrg fi 10001016ad83Smrg else 10011016ad83Smrg cat >&2 <<_LT_EOF 10021016ad83Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 10031016ad83Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 10041016ad83Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 10051016ad83Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 10061016ad83Smrg_LT_EOF 10071016ad83Smrg fi 10081016ad83Smrg 10091016ad83Smrg exit $EXIT_MISMATCH 10101016ad83Smrg fi 10111016ad83Smrg} 10121016ad83Smrg 10131016ad83Smrg 10141016ad83Smrg# Shorthand for --mode=foo, only valid as the first argument 10151016ad83Smrgcase $1 in 10161016ad83Smrgclean|clea|cle|cl) 10171016ad83Smrg shift; set dummy --mode clean ${1+"$@"}; shift 10181016ad83Smrg ;; 10191016ad83Smrgcompile|compil|compi|comp|com|co|c) 10201016ad83Smrg shift; set dummy --mode compile ${1+"$@"}; shift 10211016ad83Smrg ;; 10221016ad83Smrgexecute|execut|execu|exec|exe|ex|e) 10231016ad83Smrg shift; set dummy --mode execute ${1+"$@"}; shift 10241016ad83Smrg ;; 10251016ad83Smrgfinish|finis|fini|fin|fi|f) 10261016ad83Smrg shift; set dummy --mode finish ${1+"$@"}; shift 10271016ad83Smrg ;; 10281016ad83Smrginstall|instal|insta|inst|ins|in|i) 10291016ad83Smrg shift; set dummy --mode install ${1+"$@"}; shift 10301016ad83Smrg ;; 10311016ad83Smrglink|lin|li|l) 10321016ad83Smrg shift; set dummy --mode link ${1+"$@"}; shift 10331016ad83Smrg ;; 10341016ad83Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 10351016ad83Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 10361016ad83Smrg ;; 10371016ad83Smrgesac 10381016ad83Smrg 10391016ad83Smrg 10401016ad83Smrg 10411016ad83Smrg# Option defaults: 10421016ad83Smrgopt_debug=: 10431016ad83Smrgopt_dry_run=false 10441016ad83Smrgopt_config=false 10451016ad83Smrgopt_preserve_dup_deps=false 10461016ad83Smrgopt_features=false 10471016ad83Smrgopt_finish=false 10481016ad83Smrgopt_help=false 10491016ad83Smrgopt_help_all=false 10501016ad83Smrgopt_silent=: 10511016ad83Smrgopt_warning=: 10521016ad83Smrgopt_verbose=: 10531016ad83Smrgopt_silent=false 10541016ad83Smrgopt_verbose=false 10551016ad83Smrg 10561016ad83Smrg 10571016ad83Smrg# Parse options once, thoroughly. This comes as soon as possible in the 10581016ad83Smrg# script to make things like `--version' happen as quickly as we can. 10591016ad83Smrg{ 10601016ad83Smrg # this just eases exit handling 10611016ad83Smrg while test $# -gt 0; do 10621016ad83Smrg opt="$1" 10631016ad83Smrg shift 10641016ad83Smrg case $opt in 10651016ad83Smrg --debug|-x) opt_debug='set -x' 10661016ad83Smrg func_echo "enabling shell trace mode" 10671016ad83Smrg $opt_debug 10681016ad83Smrg ;; 10691016ad83Smrg --dry-run|--dryrun|-n) 10701016ad83Smrg opt_dry_run=: 10711016ad83Smrg ;; 10721016ad83Smrg --config) 10731016ad83Smrg opt_config=: 10741016ad83Smrgfunc_config 10751016ad83Smrg ;; 10761016ad83Smrg --dlopen|-dlopen) 10771016ad83Smrg optarg="$1" 10781016ad83Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 10791016ad83Smrg}$optarg" 10801016ad83Smrg shift 10811016ad83Smrg ;; 10821016ad83Smrg --preserve-dup-deps) 10831016ad83Smrg opt_preserve_dup_deps=: 10841016ad83Smrg ;; 10851016ad83Smrg --features) 10861016ad83Smrg opt_features=: 10871016ad83Smrgfunc_features 10881016ad83Smrg ;; 10891016ad83Smrg --finish) 10901016ad83Smrg opt_finish=: 10911016ad83Smrgset dummy --mode finish ${1+"$@"}; shift 10921016ad83Smrg ;; 10931016ad83Smrg --help) 10941016ad83Smrg opt_help=: 10951016ad83Smrg ;; 10961016ad83Smrg --help-all) 10971016ad83Smrg opt_help_all=: 10981016ad83Smrgopt_help=': help-all' 10991016ad83Smrg ;; 11001016ad83Smrg --mode) 11011016ad83Smrg test $# = 0 && func_missing_arg $opt && break 11021016ad83Smrg optarg="$1" 11031016ad83Smrg opt_mode="$optarg" 11041016ad83Smrgcase $optarg in 11051016ad83Smrg # Valid mode arguments: 11061016ad83Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 11071016ad83Smrg 11081016ad83Smrg # Catch anything else as an error 11091016ad83Smrg *) func_error "invalid argument for $opt" 11101016ad83Smrg exit_cmd=exit 11111016ad83Smrg break 11121016ad83Smrg ;; 11131016ad83Smrgesac 11141016ad83Smrg shift 11151016ad83Smrg ;; 11161016ad83Smrg --no-silent|--no-quiet) 11171016ad83Smrg opt_silent=false 11181016ad83Smrgfunc_append preserve_args " $opt" 11191016ad83Smrg ;; 11201016ad83Smrg --no-warning|--no-warn) 11211016ad83Smrg opt_warning=false 11221016ad83Smrgfunc_append preserve_args " $opt" 11231016ad83Smrg ;; 11241016ad83Smrg --no-verbose) 11251016ad83Smrg opt_verbose=false 11261016ad83Smrgfunc_append preserve_args " $opt" 11271016ad83Smrg ;; 11281016ad83Smrg --silent|--quiet) 11291016ad83Smrg opt_silent=: 11301016ad83Smrgfunc_append preserve_args " $opt" 11311016ad83Smrg opt_verbose=false 11321016ad83Smrg ;; 11331016ad83Smrg --verbose|-v) 11341016ad83Smrg opt_verbose=: 11351016ad83Smrgfunc_append preserve_args " $opt" 11361016ad83Smrgopt_silent=false 11371016ad83Smrg ;; 11381016ad83Smrg --tag) 11391016ad83Smrg test $# = 0 && func_missing_arg $opt && break 11401016ad83Smrg optarg="$1" 11411016ad83Smrg opt_tag="$optarg" 11421016ad83Smrgfunc_append preserve_args " $opt $optarg" 11431016ad83Smrgfunc_enable_tag "$optarg" 11441016ad83Smrg shift 11451016ad83Smrg ;; 11461016ad83Smrg 11471016ad83Smrg -\?|-h) func_usage ;; 11481016ad83Smrg --help) func_help ;; 11491016ad83Smrg --version) func_version ;; 11501016ad83Smrg 11511016ad83Smrg # Separate optargs to long options: 11521016ad83Smrg --*=*) 11531016ad83Smrg func_split_long_opt "$opt" 11541016ad83Smrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 11551016ad83Smrg shift 11561016ad83Smrg ;; 11571016ad83Smrg 11581016ad83Smrg # Separate non-argument short options: 11591016ad83Smrg -\?*|-h*|-n*|-v*) 11601016ad83Smrg func_split_short_opt "$opt" 11611016ad83Smrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 11621016ad83Smrg shift 11631016ad83Smrg ;; 11641016ad83Smrg 11651016ad83Smrg --) break ;; 11661016ad83Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 11671016ad83Smrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 11681016ad83Smrg esac 11691016ad83Smrg done 11701016ad83Smrg 11711016ad83Smrg # Validate options: 11721016ad83Smrg 11731016ad83Smrg # save first non-option argument 11741016ad83Smrg if test "$#" -gt 0; then 11751016ad83Smrg nonopt="$opt" 11761016ad83Smrg shift 11771016ad83Smrg fi 11781016ad83Smrg 11791016ad83Smrg # preserve --debug 11801016ad83Smrg test "$opt_debug" = : || func_append preserve_args " --debug" 11811016ad83Smrg 11821016ad83Smrg case $host in 11831016ad83Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 11841016ad83Smrg # don't eliminate duplications in $postdeps and $predeps 11851016ad83Smrg opt_duplicate_compiler_generated_deps=: 11861016ad83Smrg ;; 11871016ad83Smrg *) 11881016ad83Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 11891016ad83Smrg ;; 11901016ad83Smrg esac 11911016ad83Smrg 11921016ad83Smrg $opt_help || { 11931016ad83Smrg # Sanity checks first: 11941016ad83Smrg func_check_version_match 11951016ad83Smrg 11961016ad83Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 11971016ad83Smrg func_fatal_configuration "not configured to build any kind of library" 11981016ad83Smrg fi 11991016ad83Smrg 12001016ad83Smrg # Darwin sucks 12011016ad83Smrg eval std_shrext=\"$shrext_cmds\" 12021016ad83Smrg 12031016ad83Smrg # Only execute mode is allowed to have -dlopen flags. 12041016ad83Smrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 12051016ad83Smrg func_error "unrecognized option \`-dlopen'" 12061016ad83Smrg $ECHO "$help" 1>&2 12071016ad83Smrg exit $EXIT_FAILURE 12081016ad83Smrg fi 12091016ad83Smrg 12101016ad83Smrg # Change the help message to a mode-specific one. 12111016ad83Smrg generic_help="$help" 12121016ad83Smrg help="Try \`$progname --help --mode=$opt_mode' for more information." 12131016ad83Smrg } 12141016ad83Smrg 12151016ad83Smrg 12161016ad83Smrg # Bail if the options were screwed 12171016ad83Smrg $exit_cmd $EXIT_FAILURE 12181016ad83Smrg} 12191016ad83Smrg 12201016ad83Smrg 12211016ad83Smrg 12221016ad83Smrg 12231016ad83Smrg## ----------- ## 12241016ad83Smrg## Main. ## 12251016ad83Smrg## ----------- ## 12261016ad83Smrg 12271016ad83Smrg# func_lalib_p file 12281016ad83Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 12291016ad83Smrg# This function is only a basic sanity check; it will hardly flush out 12301016ad83Smrg# determined imposters. 12311016ad83Smrgfunc_lalib_p () 12321016ad83Smrg{ 12331016ad83Smrg test -f "$1" && 12341016ad83Smrg $SED -e 4q "$1" 2>/dev/null \ 12351016ad83Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 12361016ad83Smrg} 12371016ad83Smrg 12381016ad83Smrg# func_lalib_unsafe_p file 12391016ad83Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 12401016ad83Smrg# This function implements the same check as func_lalib_p without 12411016ad83Smrg# resorting to external programs. To this end, it redirects stdin and 12421016ad83Smrg# closes it afterwards, without saving the original file descriptor. 12431016ad83Smrg# As a safety measure, use it only where a negative result would be 12441016ad83Smrg# fatal anyway. Works if `file' does not exist. 12451016ad83Smrgfunc_lalib_unsafe_p () 12461016ad83Smrg{ 12471016ad83Smrg lalib_p=no 12481016ad83Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 12491016ad83Smrg for lalib_p_l in 1 2 3 4 12501016ad83Smrg do 12511016ad83Smrg read lalib_p_line 12521016ad83Smrg case "$lalib_p_line" in 12531016ad83Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 12541016ad83Smrg esac 12551016ad83Smrg done 12561016ad83Smrg exec 0<&5 5<&- 12571016ad83Smrg fi 12581016ad83Smrg test "$lalib_p" = yes 12591016ad83Smrg} 12601016ad83Smrg 12611016ad83Smrg# func_ltwrapper_script_p file 12621016ad83Smrg# True iff FILE is a libtool wrapper script 12631016ad83Smrg# This function is only a basic sanity check; it will hardly flush out 12641016ad83Smrg# determined imposters. 12651016ad83Smrgfunc_ltwrapper_script_p () 12661016ad83Smrg{ 12671016ad83Smrg func_lalib_p "$1" 12681016ad83Smrg} 12691016ad83Smrg 12701016ad83Smrg# func_ltwrapper_executable_p file 12711016ad83Smrg# True iff FILE is a libtool wrapper executable 12721016ad83Smrg# This function is only a basic sanity check; it will hardly flush out 12731016ad83Smrg# determined imposters. 12741016ad83Smrgfunc_ltwrapper_executable_p () 12751016ad83Smrg{ 12761016ad83Smrg func_ltwrapper_exec_suffix= 12771016ad83Smrg case $1 in 12781016ad83Smrg *.exe) ;; 12791016ad83Smrg *) func_ltwrapper_exec_suffix=.exe ;; 12801016ad83Smrg esac 12811016ad83Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 12821016ad83Smrg} 12831016ad83Smrg 12841016ad83Smrg# func_ltwrapper_scriptname file 12851016ad83Smrg# Assumes file is an ltwrapper_executable 12861016ad83Smrg# uses $file to determine the appropriate filename for a 12871016ad83Smrg# temporary ltwrapper_script. 12881016ad83Smrgfunc_ltwrapper_scriptname () 12891016ad83Smrg{ 12901016ad83Smrg func_dirname_and_basename "$1" "" "." 12911016ad83Smrg func_stripname '' '.exe' "$func_basename_result" 12921016ad83Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 12931016ad83Smrg} 12941016ad83Smrg 12951016ad83Smrg# func_ltwrapper_p file 12961016ad83Smrg# True iff FILE is a libtool wrapper script or wrapper executable 12971016ad83Smrg# This function is only a basic sanity check; it will hardly flush out 12981016ad83Smrg# determined imposters. 12991016ad83Smrgfunc_ltwrapper_p () 13001016ad83Smrg{ 13011016ad83Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 13021016ad83Smrg} 13031016ad83Smrg 13041016ad83Smrg 13051016ad83Smrg# func_execute_cmds commands fail_cmd 13061016ad83Smrg# Execute tilde-delimited COMMANDS. 13071016ad83Smrg# If FAIL_CMD is given, eval that upon failure. 13081016ad83Smrg# FAIL_CMD may read-access the current command in variable CMD! 13091016ad83Smrgfunc_execute_cmds () 13101016ad83Smrg{ 13111016ad83Smrg $opt_debug 13121016ad83Smrg save_ifs=$IFS; IFS='~' 13131016ad83Smrg for cmd in $1; do 13141016ad83Smrg IFS=$save_ifs 13151016ad83Smrg eval cmd=\"$cmd\" 13161016ad83Smrg func_show_eval "$cmd" "${2-:}" 13171016ad83Smrg done 13181016ad83Smrg IFS=$save_ifs 13191016ad83Smrg} 13201016ad83Smrg 13211016ad83Smrg 13221016ad83Smrg# func_source file 13231016ad83Smrg# Source FILE, adding directory component if necessary. 13241016ad83Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 13251016ad83Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 13261016ad83Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 13271016ad83Smrg# `FILE.' does not work on cygwin managed mounts. 13281016ad83Smrgfunc_source () 13291016ad83Smrg{ 13301016ad83Smrg $opt_debug 13311016ad83Smrg case $1 in 13321016ad83Smrg */* | *\\*) . "$1" ;; 13331016ad83Smrg *) . "./$1" ;; 13341016ad83Smrg esac 13351016ad83Smrg} 13361016ad83Smrg 13371016ad83Smrg 13381016ad83Smrg# func_resolve_sysroot PATH 13391016ad83Smrg# Replace a leading = in PATH with a sysroot. Store the result into 13401016ad83Smrg# func_resolve_sysroot_result 13411016ad83Smrgfunc_resolve_sysroot () 13421016ad83Smrg{ 13431016ad83Smrg func_resolve_sysroot_result=$1 13441016ad83Smrg case $func_resolve_sysroot_result in 13451016ad83Smrg =*) 13461016ad83Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 13471016ad83Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 13481016ad83Smrg ;; 13491016ad83Smrg esac 13501016ad83Smrg} 13511016ad83Smrg 13521016ad83Smrg# func_replace_sysroot PATH 13531016ad83Smrg# If PATH begins with the sysroot, replace it with = and 13541016ad83Smrg# store the result into func_replace_sysroot_result. 13551016ad83Smrgfunc_replace_sysroot () 13561016ad83Smrg{ 13571016ad83Smrg case "$lt_sysroot:$1" in 13581016ad83Smrg ?*:"$lt_sysroot"*) 13591016ad83Smrg func_stripname "$lt_sysroot" '' "$1" 13601016ad83Smrg func_replace_sysroot_result="=$func_stripname_result" 13611016ad83Smrg ;; 13621016ad83Smrg *) 13631016ad83Smrg # Including no sysroot. 13641016ad83Smrg func_replace_sysroot_result=$1 13651016ad83Smrg ;; 13661016ad83Smrg esac 13671016ad83Smrg} 13681016ad83Smrg 13691016ad83Smrg# func_infer_tag arg 13701016ad83Smrg# Infer tagged configuration to use if any are available and 13711016ad83Smrg# if one wasn't chosen via the "--tag" command line option. 13721016ad83Smrg# Only attempt this if the compiler in the base compile 13731016ad83Smrg# command doesn't match the default compiler. 13741016ad83Smrg# arg is usually of the form 'gcc ...' 13751016ad83Smrgfunc_infer_tag () 13761016ad83Smrg{ 13771016ad83Smrg $opt_debug 13781016ad83Smrg if test -n "$available_tags" && test -z "$tagname"; then 13791016ad83Smrg CC_quoted= 13801016ad83Smrg for arg in $CC; do 13811016ad83Smrg func_append_quoted CC_quoted "$arg" 13821016ad83Smrg done 13831016ad83Smrg CC_expanded=`func_echo_all $CC` 13841016ad83Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 13851016ad83Smrg case $@ in 13861016ad83Smrg # Blanks in the command may have been stripped by the calling shell, 13871016ad83Smrg # but not from the CC environment variable when configure was run. 13881016ad83Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 13891016ad83Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 13901016ad83Smrg # Blanks at the start of $base_compile will cause this to fail 13911016ad83Smrg # if we don't check for them as well. 13921016ad83Smrg *) 13931016ad83Smrg for z in $available_tags; do 13941016ad83Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 13951016ad83Smrg # Evaluate the configuration. 13961016ad83Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 13971016ad83Smrg CC_quoted= 13981016ad83Smrg for arg in $CC; do 13991016ad83Smrg # Double-quote args containing other shell metacharacters. 14001016ad83Smrg func_append_quoted CC_quoted "$arg" 14011016ad83Smrg done 14021016ad83Smrg CC_expanded=`func_echo_all $CC` 14031016ad83Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 14041016ad83Smrg case "$@ " in 14051016ad83Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 14061016ad83Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 14071016ad83Smrg # The compiler in the base compile command matches 14081016ad83Smrg # the one in the tagged configuration. 14091016ad83Smrg # Assume this is the tagged configuration we want. 14101016ad83Smrg tagname=$z 14111016ad83Smrg break 14121016ad83Smrg ;; 14131016ad83Smrg esac 14141016ad83Smrg fi 14151016ad83Smrg done 14161016ad83Smrg # If $tagname still isn't set, then no tagged configuration 14171016ad83Smrg # was found and let the user know that the "--tag" command 14181016ad83Smrg # line option must be used. 14191016ad83Smrg if test -z "$tagname"; then 14201016ad83Smrg func_echo "unable to infer tagged configuration" 14211016ad83Smrg func_fatal_error "specify a tag with \`--tag'" 14221016ad83Smrg# else 14231016ad83Smrg# func_verbose "using $tagname tagged configuration" 14241016ad83Smrg fi 14251016ad83Smrg ;; 14261016ad83Smrg esac 14271016ad83Smrg fi 14281016ad83Smrg} 14291016ad83Smrg 14301016ad83Smrg 14311016ad83Smrg 14321016ad83Smrg# func_write_libtool_object output_name pic_name nonpic_name 14331016ad83Smrg# Create a libtool object file (analogous to a ".la" file), 14341016ad83Smrg# but don't create it if we're doing a dry run. 14351016ad83Smrgfunc_write_libtool_object () 14361016ad83Smrg{ 14371016ad83Smrg write_libobj=${1} 14381016ad83Smrg if test "$build_libtool_libs" = yes; then 14391016ad83Smrg write_lobj=\'${2}\' 14401016ad83Smrg else 14411016ad83Smrg write_lobj=none 14421016ad83Smrg fi 14431016ad83Smrg 14441016ad83Smrg if test "$build_old_libs" = yes; then 14451016ad83Smrg write_oldobj=\'${3}\' 14461016ad83Smrg else 14471016ad83Smrg write_oldobj=none 14481016ad83Smrg fi 14491016ad83Smrg 14501016ad83Smrg $opt_dry_run || { 14511016ad83Smrg cat >${write_libobj}T <<EOF 14521016ad83Smrg# $write_libobj - a libtool object file 14531016ad83Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 14541016ad83Smrg# 14551016ad83Smrg# Please DO NOT delete this file! 14561016ad83Smrg# It is necessary for linking the library. 14571016ad83Smrg 14581016ad83Smrg# Name of the PIC object. 14591016ad83Smrgpic_object=$write_lobj 14601016ad83Smrg 14611016ad83Smrg# Name of the non-PIC object 14621016ad83Smrgnon_pic_object=$write_oldobj 14631016ad83Smrg 14641016ad83SmrgEOF 14651016ad83Smrg $MV "${write_libobj}T" "${write_libobj}" 14661016ad83Smrg } 14671016ad83Smrg} 14681016ad83Smrg 14691016ad83Smrg 14701016ad83Smrg################################################## 14711016ad83Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 14721016ad83Smrg################################################## 14731016ad83Smrg 14741016ad83Smrg# func_convert_core_file_wine_to_w32 ARG 14751016ad83Smrg# Helper function used by file name conversion functions when $build is *nix, 14761016ad83Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 14771016ad83Smrg# correctly configured wine environment available, with the winepath program 14781016ad83Smrg# in $build's $PATH. 14791016ad83Smrg# 14801016ad83Smrg# ARG is the $build file name to be converted to w32 format. 14811016ad83Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 14821016ad83Smrg# be empty on error (or when ARG is empty) 14831016ad83Smrgfunc_convert_core_file_wine_to_w32 () 14841016ad83Smrg{ 14851016ad83Smrg $opt_debug 14861016ad83Smrg func_convert_core_file_wine_to_w32_result="$1" 14871016ad83Smrg if test -n "$1"; then 14881016ad83Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 14891016ad83Smrg # are forced to check the contents of stdout. On the other hand, if the 14901016ad83Smrg # command is not found, the shell will set an exit code of 127 and print 14911016ad83Smrg # *an error message* to stdout. So we must check for both error code of 14921016ad83Smrg # zero AND non-empty stdout, which explains the odd construction: 14931016ad83Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 14941016ad83Smrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 14951016ad83Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 14961016ad83Smrg $SED -e "$lt_sed_naive_backslashify"` 14971016ad83Smrg else 14981016ad83Smrg func_convert_core_file_wine_to_w32_result= 14991016ad83Smrg fi 15001016ad83Smrg fi 15011016ad83Smrg} 15021016ad83Smrg# end: func_convert_core_file_wine_to_w32 15031016ad83Smrg 15041016ad83Smrg 15051016ad83Smrg# func_convert_core_path_wine_to_w32 ARG 15061016ad83Smrg# Helper function used by path conversion functions when $build is *nix, and 15071016ad83Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 15081016ad83Smrg# configured wine environment available, with the winepath program in $build's 15091016ad83Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 15101016ad83Smrg# 15111016ad83Smrg# ARG is path to be converted from $build format to win32. 15121016ad83Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 15131016ad83Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 15141016ad83Smrg# are convertible, then the result may be empty. 15151016ad83Smrgfunc_convert_core_path_wine_to_w32 () 15161016ad83Smrg{ 15171016ad83Smrg $opt_debug 15181016ad83Smrg # unfortunately, winepath doesn't convert paths, only file names 15191016ad83Smrg func_convert_core_path_wine_to_w32_result="" 15201016ad83Smrg if test -n "$1"; then 15211016ad83Smrg oldIFS=$IFS 15221016ad83Smrg IFS=: 15231016ad83Smrg for func_convert_core_path_wine_to_w32_f in $1; do 15241016ad83Smrg IFS=$oldIFS 15251016ad83Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 15261016ad83Smrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 15271016ad83Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 15281016ad83Smrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 15291016ad83Smrg else 15301016ad83Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 15311016ad83Smrg fi 15321016ad83Smrg fi 15331016ad83Smrg done 15341016ad83Smrg IFS=$oldIFS 15351016ad83Smrg fi 15361016ad83Smrg} 15371016ad83Smrg# end: func_convert_core_path_wine_to_w32 15381016ad83Smrg 15391016ad83Smrg 15401016ad83Smrg# func_cygpath ARGS... 15411016ad83Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 15421016ad83Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 15431016ad83Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 15441016ad83Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 15451016ad83Smrg# file name or path is assumed to be in w32 format, as previously converted 15461016ad83Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 15471016ad83Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 15481016ad83Smrg# Cygwin format). Returns an empty string on error. 15491016ad83Smrg# 15501016ad83Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 15511016ad83Smrg# be converted. 15521016ad83Smrg# 15531016ad83Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 15541016ad83Smrg# environment variable; do not put it in $PATH. 15551016ad83Smrgfunc_cygpath () 15561016ad83Smrg{ 15571016ad83Smrg $opt_debug 15581016ad83Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 15591016ad83Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 15601016ad83Smrg if test "$?" -ne 0; then 15611016ad83Smrg # on failure, ensure result is empty 15621016ad83Smrg func_cygpath_result= 15631016ad83Smrg fi 15641016ad83Smrg else 15651016ad83Smrg func_cygpath_result= 15661016ad83Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 15671016ad83Smrg fi 15681016ad83Smrg} 15691016ad83Smrg#end: func_cygpath 15701016ad83Smrg 15711016ad83Smrg 15721016ad83Smrg# func_convert_core_msys_to_w32 ARG 15731016ad83Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 15741016ad83Smrg# result in func_convert_core_msys_to_w32_result. 15751016ad83Smrgfunc_convert_core_msys_to_w32 () 15761016ad83Smrg{ 15771016ad83Smrg $opt_debug 15781016ad83Smrg # awkward: cmd appends spaces to result 15791016ad83Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 15801016ad83Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 15811016ad83Smrg} 15821016ad83Smrg#end: func_convert_core_msys_to_w32 15831016ad83Smrg 15841016ad83Smrg 15851016ad83Smrg# func_convert_file_check ARG1 ARG2 15861016ad83Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 15871016ad83Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 15881016ad83Smrg# func_to_host_file_result to ARG1). 15891016ad83Smrgfunc_convert_file_check () 15901016ad83Smrg{ 15911016ad83Smrg $opt_debug 15921016ad83Smrg if test -z "$2" && test -n "$1" ; then 15931016ad83Smrg func_error "Could not determine host file name corresponding to" 15941016ad83Smrg func_error " \`$1'" 15951016ad83Smrg func_error "Continuing, but uninstalled executables may not work." 15961016ad83Smrg # Fallback: 15971016ad83Smrg func_to_host_file_result="$1" 15981016ad83Smrg fi 15991016ad83Smrg} 16001016ad83Smrg# end func_convert_file_check 16011016ad83Smrg 16021016ad83Smrg 16031016ad83Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 16041016ad83Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 16051016ad83Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 16061016ad83Smrg# func_to_host_file_result to a simplistic fallback value (see below). 16071016ad83Smrgfunc_convert_path_check () 16081016ad83Smrg{ 16091016ad83Smrg $opt_debug 16101016ad83Smrg if test -z "$4" && test -n "$3"; then 16111016ad83Smrg func_error "Could not determine the host path corresponding to" 16121016ad83Smrg func_error " \`$3'" 16131016ad83Smrg func_error "Continuing, but uninstalled executables may not work." 16141016ad83Smrg # Fallback. This is a deliberately simplistic "conversion" and 16151016ad83Smrg # should not be "improved". See libtool.info. 16161016ad83Smrg if test "x$1" != "x$2"; then 16171016ad83Smrg lt_replace_pathsep_chars="s|$1|$2|g" 16181016ad83Smrg func_to_host_path_result=`echo "$3" | 16191016ad83Smrg $SED -e "$lt_replace_pathsep_chars"` 16201016ad83Smrg else 16211016ad83Smrg func_to_host_path_result="$3" 16221016ad83Smrg fi 16231016ad83Smrg fi 16241016ad83Smrg} 16251016ad83Smrg# end func_convert_path_check 16261016ad83Smrg 16271016ad83Smrg 16281016ad83Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 16291016ad83Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 16301016ad83Smrg# and appending REPL if ORIG matches BACKPAT. 16311016ad83Smrgfunc_convert_path_front_back_pathsep () 16321016ad83Smrg{ 16331016ad83Smrg $opt_debug 16341016ad83Smrg case $4 in 16351016ad83Smrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 16361016ad83Smrg ;; 16371016ad83Smrg esac 16381016ad83Smrg case $4 in 16391016ad83Smrg $2 ) func_append func_to_host_path_result "$3" 16401016ad83Smrg ;; 16411016ad83Smrg esac 16421016ad83Smrg} 16431016ad83Smrg# end func_convert_path_front_back_pathsep 16441016ad83Smrg 16451016ad83Smrg 16461016ad83Smrg################################################## 16471016ad83Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 16481016ad83Smrg################################################## 16491016ad83Smrg# invoked via `$to_host_file_cmd ARG' 16501016ad83Smrg# 16511016ad83Smrg# In each case, ARG is the path to be converted from $build to $host format. 16521016ad83Smrg# Result will be available in $func_to_host_file_result. 16531016ad83Smrg 16541016ad83Smrg 16551016ad83Smrg# func_to_host_file ARG 16561016ad83Smrg# Converts the file name ARG from $build format to $host format. Return result 16571016ad83Smrg# in func_to_host_file_result. 16581016ad83Smrgfunc_to_host_file () 16591016ad83Smrg{ 16601016ad83Smrg $opt_debug 16611016ad83Smrg $to_host_file_cmd "$1" 16621016ad83Smrg} 16631016ad83Smrg# end func_to_host_file 16641016ad83Smrg 16651016ad83Smrg 16661016ad83Smrg# func_to_tool_file ARG LAZY 16671016ad83Smrg# converts the file name ARG from $build format to toolchain format. Return 16681016ad83Smrg# result in func_to_tool_file_result. If the conversion in use is listed 16691016ad83Smrg# in (the comma separated) LAZY, no conversion takes place. 16701016ad83Smrgfunc_to_tool_file () 16711016ad83Smrg{ 16721016ad83Smrg $opt_debug 16731016ad83Smrg case ,$2, in 16741016ad83Smrg *,"$to_tool_file_cmd",*) 16751016ad83Smrg func_to_tool_file_result=$1 16761016ad83Smrg ;; 16771016ad83Smrg *) 16781016ad83Smrg $to_tool_file_cmd "$1" 16791016ad83Smrg func_to_tool_file_result=$func_to_host_file_result 16801016ad83Smrg ;; 16811016ad83Smrg esac 16821016ad83Smrg} 16831016ad83Smrg# end func_to_tool_file 16841016ad83Smrg 16851016ad83Smrg 16861016ad83Smrg# func_convert_file_noop ARG 16871016ad83Smrg# Copy ARG to func_to_host_file_result. 16881016ad83Smrgfunc_convert_file_noop () 16891016ad83Smrg{ 16901016ad83Smrg func_to_host_file_result="$1" 16911016ad83Smrg} 16921016ad83Smrg# end func_convert_file_noop 16931016ad83Smrg 16941016ad83Smrg 16951016ad83Smrg# func_convert_file_msys_to_w32 ARG 16961016ad83Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 16971016ad83Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 16981016ad83Smrg# func_to_host_file_result. 16991016ad83Smrgfunc_convert_file_msys_to_w32 () 17001016ad83Smrg{ 17011016ad83Smrg $opt_debug 17021016ad83Smrg func_to_host_file_result="$1" 17031016ad83Smrg if test -n "$1"; then 17041016ad83Smrg func_convert_core_msys_to_w32 "$1" 17051016ad83Smrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 17061016ad83Smrg fi 17071016ad83Smrg func_convert_file_check "$1" "$func_to_host_file_result" 17081016ad83Smrg} 17091016ad83Smrg# end func_convert_file_msys_to_w32 17101016ad83Smrg 17111016ad83Smrg 17121016ad83Smrg# func_convert_file_cygwin_to_w32 ARG 17131016ad83Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 17141016ad83Smrg# func_to_host_file_result. 17151016ad83Smrgfunc_convert_file_cygwin_to_w32 () 17161016ad83Smrg{ 17171016ad83Smrg $opt_debug 17181016ad83Smrg func_to_host_file_result="$1" 17191016ad83Smrg if test -n "$1"; then 17201016ad83Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 17211016ad83Smrg # LT_CYGPATH in this case. 17221016ad83Smrg func_to_host_file_result=`cygpath -m "$1"` 17231016ad83Smrg fi 17241016ad83Smrg func_convert_file_check "$1" "$func_to_host_file_result" 17251016ad83Smrg} 17261016ad83Smrg# end func_convert_file_cygwin_to_w32 17271016ad83Smrg 17281016ad83Smrg 17291016ad83Smrg# func_convert_file_nix_to_w32 ARG 17301016ad83Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 17311016ad83Smrg# and a working winepath. Returns result in func_to_host_file_result. 17321016ad83Smrgfunc_convert_file_nix_to_w32 () 17331016ad83Smrg{ 17341016ad83Smrg $opt_debug 17351016ad83Smrg func_to_host_file_result="$1" 17361016ad83Smrg if test -n "$1"; then 17371016ad83Smrg func_convert_core_file_wine_to_w32 "$1" 17381016ad83Smrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 17391016ad83Smrg fi 17401016ad83Smrg func_convert_file_check "$1" "$func_to_host_file_result" 17411016ad83Smrg} 17421016ad83Smrg# end func_convert_file_nix_to_w32 17431016ad83Smrg 17441016ad83Smrg 17451016ad83Smrg# func_convert_file_msys_to_cygwin ARG 17461016ad83Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 17471016ad83Smrg# Returns result in func_to_host_file_result. 17481016ad83Smrgfunc_convert_file_msys_to_cygwin () 17491016ad83Smrg{ 17501016ad83Smrg $opt_debug 17511016ad83Smrg func_to_host_file_result="$1" 17521016ad83Smrg if test -n "$1"; then 17531016ad83Smrg func_convert_core_msys_to_w32 "$1" 17541016ad83Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 17551016ad83Smrg func_to_host_file_result="$func_cygpath_result" 17561016ad83Smrg fi 17571016ad83Smrg func_convert_file_check "$1" "$func_to_host_file_result" 17581016ad83Smrg} 17591016ad83Smrg# end func_convert_file_msys_to_cygwin 17601016ad83Smrg 17611016ad83Smrg 17621016ad83Smrg# func_convert_file_nix_to_cygwin ARG 17631016ad83Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 17641016ad83Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 17651016ad83Smrg# in func_to_host_file_result. 17661016ad83Smrgfunc_convert_file_nix_to_cygwin () 17671016ad83Smrg{ 17681016ad83Smrg $opt_debug 17691016ad83Smrg func_to_host_file_result="$1" 17701016ad83Smrg if test -n "$1"; then 17711016ad83Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 17721016ad83Smrg func_convert_core_file_wine_to_w32 "$1" 17731016ad83Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 17741016ad83Smrg func_to_host_file_result="$func_cygpath_result" 17751016ad83Smrg fi 17761016ad83Smrg func_convert_file_check "$1" "$func_to_host_file_result" 17771016ad83Smrg} 17781016ad83Smrg# end func_convert_file_nix_to_cygwin 17791016ad83Smrg 17801016ad83Smrg 17811016ad83Smrg############################################# 17821016ad83Smrg# $build to $host PATH CONVERSION FUNCTIONS # 17831016ad83Smrg############################################# 17841016ad83Smrg# invoked via `$to_host_path_cmd ARG' 17851016ad83Smrg# 17861016ad83Smrg# In each case, ARG is the path to be converted from $build to $host format. 17871016ad83Smrg# The result will be available in $func_to_host_path_result. 17881016ad83Smrg# 17891016ad83Smrg# Path separators are also converted from $build format to $host format. If 17901016ad83Smrg# ARG begins or ends with a path separator character, it is preserved (but 17911016ad83Smrg# converted to $host format) on output. 17921016ad83Smrg# 17931016ad83Smrg# All path conversion functions are named using the following convention: 17941016ad83Smrg# file name conversion function : func_convert_file_X_to_Y () 17951016ad83Smrg# path conversion function : func_convert_path_X_to_Y () 17961016ad83Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 17971016ad83Smrg# same. If conversion functions are added for new $build/$host combinations, 17981016ad83Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 17991016ad83Smrg# will break. 18001016ad83Smrg 18011016ad83Smrg 18021016ad83Smrg# func_init_to_host_path_cmd 18031016ad83Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 18041016ad83Smrg# appropriate value, based on the value of $to_host_file_cmd. 18051016ad83Smrgto_host_path_cmd= 18061016ad83Smrgfunc_init_to_host_path_cmd () 18071016ad83Smrg{ 18081016ad83Smrg $opt_debug 18091016ad83Smrg if test -z "$to_host_path_cmd"; then 18101016ad83Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 18111016ad83Smrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 18121016ad83Smrg fi 18131016ad83Smrg} 18141016ad83Smrg 18151016ad83Smrg 18161016ad83Smrg# func_to_host_path ARG 18171016ad83Smrg# Converts the path ARG from $build format to $host format. Return result 18181016ad83Smrg# in func_to_host_path_result. 18191016ad83Smrgfunc_to_host_path () 18201016ad83Smrg{ 18211016ad83Smrg $opt_debug 18221016ad83Smrg func_init_to_host_path_cmd 18231016ad83Smrg $to_host_path_cmd "$1" 18241016ad83Smrg} 18251016ad83Smrg# end func_to_host_path 18261016ad83Smrg 18271016ad83Smrg 18281016ad83Smrg# func_convert_path_noop ARG 18291016ad83Smrg# Copy ARG to func_to_host_path_result. 18301016ad83Smrgfunc_convert_path_noop () 18311016ad83Smrg{ 18321016ad83Smrg func_to_host_path_result="$1" 18331016ad83Smrg} 18341016ad83Smrg# end func_convert_path_noop 18351016ad83Smrg 18361016ad83Smrg 18371016ad83Smrg# func_convert_path_msys_to_w32 ARG 18381016ad83Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 18391016ad83Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 18401016ad83Smrg# func_to_host_path_result. 18411016ad83Smrgfunc_convert_path_msys_to_w32 () 18421016ad83Smrg{ 18431016ad83Smrg $opt_debug 18441016ad83Smrg func_to_host_path_result="$1" 18451016ad83Smrg if test -n "$1"; then 18461016ad83Smrg # Remove leading and trailing path separator characters from ARG. MSYS 18471016ad83Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 18481016ad83Smrg # and winepath ignores them completely. 18491016ad83Smrg func_stripname : : "$1" 18501016ad83Smrg func_to_host_path_tmp1=$func_stripname_result 18511016ad83Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 18521016ad83Smrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 18531016ad83Smrg func_convert_path_check : ";" \ 18541016ad83Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 18551016ad83Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 18561016ad83Smrg fi 18571016ad83Smrg} 18581016ad83Smrg# end func_convert_path_msys_to_w32 18591016ad83Smrg 18601016ad83Smrg 18611016ad83Smrg# func_convert_path_cygwin_to_w32 ARG 18621016ad83Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 18631016ad83Smrg# func_to_host_file_result. 18641016ad83Smrgfunc_convert_path_cygwin_to_w32 () 18651016ad83Smrg{ 18661016ad83Smrg $opt_debug 18671016ad83Smrg func_to_host_path_result="$1" 18681016ad83Smrg if test -n "$1"; then 18691016ad83Smrg # See func_convert_path_msys_to_w32: 18701016ad83Smrg func_stripname : : "$1" 18711016ad83Smrg func_to_host_path_tmp1=$func_stripname_result 18721016ad83Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 18731016ad83Smrg func_convert_path_check : ";" \ 18741016ad83Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 18751016ad83Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 18761016ad83Smrg fi 18771016ad83Smrg} 18781016ad83Smrg# end func_convert_path_cygwin_to_w32 18791016ad83Smrg 18801016ad83Smrg 18811016ad83Smrg# func_convert_path_nix_to_w32 ARG 18821016ad83Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 18831016ad83Smrg# a working winepath. Returns result in func_to_host_file_result. 18841016ad83Smrgfunc_convert_path_nix_to_w32 () 18851016ad83Smrg{ 18861016ad83Smrg $opt_debug 18871016ad83Smrg func_to_host_path_result="$1" 18881016ad83Smrg if test -n "$1"; then 18891016ad83Smrg # See func_convert_path_msys_to_w32: 18901016ad83Smrg func_stripname : : "$1" 18911016ad83Smrg func_to_host_path_tmp1=$func_stripname_result 18921016ad83Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 18931016ad83Smrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 18941016ad83Smrg func_convert_path_check : ";" \ 18951016ad83Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 18961016ad83Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 18971016ad83Smrg fi 18981016ad83Smrg} 18991016ad83Smrg# end func_convert_path_nix_to_w32 19001016ad83Smrg 19011016ad83Smrg 19021016ad83Smrg# func_convert_path_msys_to_cygwin ARG 19031016ad83Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 19041016ad83Smrg# Returns result in func_to_host_file_result. 19051016ad83Smrgfunc_convert_path_msys_to_cygwin () 19061016ad83Smrg{ 19071016ad83Smrg $opt_debug 19081016ad83Smrg func_to_host_path_result="$1" 19091016ad83Smrg if test -n "$1"; then 19101016ad83Smrg # See func_convert_path_msys_to_w32: 19111016ad83Smrg func_stripname : : "$1" 19121016ad83Smrg func_to_host_path_tmp1=$func_stripname_result 19131016ad83Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 19141016ad83Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 19151016ad83Smrg func_to_host_path_result="$func_cygpath_result" 19161016ad83Smrg func_convert_path_check : : \ 19171016ad83Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 19181016ad83Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 19191016ad83Smrg fi 19201016ad83Smrg} 19211016ad83Smrg# end func_convert_path_msys_to_cygwin 19221016ad83Smrg 19231016ad83Smrg 19241016ad83Smrg# func_convert_path_nix_to_cygwin ARG 19251016ad83Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 19261016ad83Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 19271016ad83Smrg# func_to_host_file_result. 19281016ad83Smrgfunc_convert_path_nix_to_cygwin () 19291016ad83Smrg{ 19301016ad83Smrg $opt_debug 19311016ad83Smrg func_to_host_path_result="$1" 19321016ad83Smrg if test -n "$1"; then 19331016ad83Smrg # Remove leading and trailing path separator characters from 19341016ad83Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 19351016ad83Smrg # into '.;' and ';.', and winepath ignores them completely. 19361016ad83Smrg func_stripname : : "$1" 19371016ad83Smrg func_to_host_path_tmp1=$func_stripname_result 19381016ad83Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 19391016ad83Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 19401016ad83Smrg func_to_host_path_result="$func_cygpath_result" 19411016ad83Smrg func_convert_path_check : : \ 19421016ad83Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 19431016ad83Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 19441016ad83Smrg fi 19451016ad83Smrg} 19461016ad83Smrg# end func_convert_path_nix_to_cygwin 19471016ad83Smrg 19481016ad83Smrg 19491016ad83Smrg# func_mode_compile arg... 19501016ad83Smrgfunc_mode_compile () 19511016ad83Smrg{ 19521016ad83Smrg $opt_debug 19531016ad83Smrg # Get the compilation command and the source file. 19541016ad83Smrg base_compile= 19551016ad83Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 19561016ad83Smrg suppress_opt=yes 19571016ad83Smrg suppress_output= 19581016ad83Smrg arg_mode=normal 19591016ad83Smrg libobj= 19601016ad83Smrg later= 19611016ad83Smrg pie_flag= 19621016ad83Smrg 19631016ad83Smrg for arg 19641016ad83Smrg do 19651016ad83Smrg case $arg_mode in 19661016ad83Smrg arg ) 19671016ad83Smrg # do not "continue". Instead, add this to base_compile 19681016ad83Smrg lastarg="$arg" 19691016ad83Smrg arg_mode=normal 19701016ad83Smrg ;; 19711016ad83Smrg 19721016ad83Smrg target ) 19731016ad83Smrg libobj="$arg" 19741016ad83Smrg arg_mode=normal 19751016ad83Smrg continue 19761016ad83Smrg ;; 19771016ad83Smrg 19781016ad83Smrg normal ) 19791016ad83Smrg # Accept any command-line options. 19801016ad83Smrg case $arg in 19811016ad83Smrg -o) 19821016ad83Smrg test -n "$libobj" && \ 19831016ad83Smrg func_fatal_error "you cannot specify \`-o' more than once" 19841016ad83Smrg arg_mode=target 19851016ad83Smrg continue 19861016ad83Smrg ;; 19871016ad83Smrg 19881016ad83Smrg -pie | -fpie | -fPIE) 19891016ad83Smrg func_append pie_flag " $arg" 19901016ad83Smrg continue 19911016ad83Smrg ;; 19921016ad83Smrg 19931016ad83Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 19941016ad83Smrg func_append later " $arg" 19951016ad83Smrg continue 19961016ad83Smrg ;; 19971016ad83Smrg 19981016ad83Smrg -no-suppress) 19991016ad83Smrg suppress_opt=no 20001016ad83Smrg continue 20011016ad83Smrg ;; 20021016ad83Smrg 20031016ad83Smrg -Xcompiler) 20041016ad83Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 20051016ad83Smrg continue # The current "srcfile" will either be retained or 20061016ad83Smrg ;; # replaced later. I would guess that would be a bug. 20071016ad83Smrg 20081016ad83Smrg -Wc,*) 20091016ad83Smrg func_stripname '-Wc,' '' "$arg" 20101016ad83Smrg args=$func_stripname_result 20111016ad83Smrg lastarg= 20121016ad83Smrg save_ifs="$IFS"; IFS=',' 20131016ad83Smrg for arg in $args; do 20141016ad83Smrg IFS="$save_ifs" 20151016ad83Smrg func_append_quoted lastarg "$arg" 20161016ad83Smrg done 20171016ad83Smrg IFS="$save_ifs" 20181016ad83Smrg func_stripname ' ' '' "$lastarg" 20191016ad83Smrg lastarg=$func_stripname_result 20201016ad83Smrg 20211016ad83Smrg # Add the arguments to base_compile. 20221016ad83Smrg func_append base_compile " $lastarg" 20231016ad83Smrg continue 20241016ad83Smrg ;; 20251016ad83Smrg 20261016ad83Smrg *) 20271016ad83Smrg # Accept the current argument as the source file. 20281016ad83Smrg # The previous "srcfile" becomes the current argument. 20291016ad83Smrg # 20301016ad83Smrg lastarg="$srcfile" 20311016ad83Smrg srcfile="$arg" 20321016ad83Smrg ;; 20331016ad83Smrg esac # case $arg 20341016ad83Smrg ;; 20351016ad83Smrg esac # case $arg_mode 20361016ad83Smrg 20371016ad83Smrg # Aesthetically quote the previous argument. 20381016ad83Smrg func_append_quoted base_compile "$lastarg" 20391016ad83Smrg done # for arg 20401016ad83Smrg 20411016ad83Smrg case $arg_mode in 20421016ad83Smrg arg) 20431016ad83Smrg func_fatal_error "you must specify an argument for -Xcompile" 20441016ad83Smrg ;; 20451016ad83Smrg target) 20461016ad83Smrg func_fatal_error "you must specify a target with \`-o'" 20471016ad83Smrg ;; 20481016ad83Smrg *) 20491016ad83Smrg # Get the name of the library object. 20501016ad83Smrg test -z "$libobj" && { 20511016ad83Smrg func_basename "$srcfile" 20521016ad83Smrg libobj="$func_basename_result" 20531016ad83Smrg } 20541016ad83Smrg ;; 20551016ad83Smrg esac 20561016ad83Smrg 20571016ad83Smrg # Recognize several different file suffixes. 20581016ad83Smrg # If the user specifies -o file.o, it is replaced with file.lo 20591016ad83Smrg case $libobj in 20601016ad83Smrg *.[cCFSifmso] | \ 20611016ad83Smrg *.ada | *.adb | *.ads | *.asm | \ 20621016ad83Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 20631016ad83Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 20641016ad83Smrg func_xform "$libobj" 20651016ad83Smrg libobj=$func_xform_result 20661016ad83Smrg ;; 20671016ad83Smrg esac 20681016ad83Smrg 20691016ad83Smrg case $libobj in 20701016ad83Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 20711016ad83Smrg *) 20721016ad83Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 20731016ad83Smrg ;; 20741016ad83Smrg esac 20751016ad83Smrg 20761016ad83Smrg func_infer_tag $base_compile 20771016ad83Smrg 20781016ad83Smrg for arg in $later; do 20791016ad83Smrg case $arg in 20801016ad83Smrg -shared) 20811016ad83Smrg test "$build_libtool_libs" != yes && \ 20821016ad83Smrg func_fatal_configuration "can not build a shared library" 20831016ad83Smrg build_old_libs=no 20841016ad83Smrg continue 20851016ad83Smrg ;; 20861016ad83Smrg 20871016ad83Smrg -static) 20881016ad83Smrg build_libtool_libs=no 20891016ad83Smrg build_old_libs=yes 20901016ad83Smrg continue 20911016ad83Smrg ;; 20921016ad83Smrg 20931016ad83Smrg -prefer-pic) 20941016ad83Smrg pic_mode=yes 20951016ad83Smrg continue 20961016ad83Smrg ;; 20971016ad83Smrg 20981016ad83Smrg -prefer-non-pic) 20991016ad83Smrg pic_mode=no 21001016ad83Smrg continue 21011016ad83Smrg ;; 21021016ad83Smrg esac 21031016ad83Smrg done 21041016ad83Smrg 21051016ad83Smrg func_quote_for_eval "$libobj" 21061016ad83Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 21071016ad83Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 21081016ad83Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 21091016ad83Smrg func_dirname_and_basename "$obj" "/" "" 21101016ad83Smrg objname="$func_basename_result" 21111016ad83Smrg xdir="$func_dirname_result" 21121016ad83Smrg lobj=${xdir}$objdir/$objname 21131016ad83Smrg 21141016ad83Smrg test -z "$base_compile" && \ 21151016ad83Smrg func_fatal_help "you must specify a compilation command" 21161016ad83Smrg 21171016ad83Smrg # Delete any leftover library objects. 21181016ad83Smrg if test "$build_old_libs" = yes; then 21191016ad83Smrg removelist="$obj $lobj $libobj ${libobj}T" 21201016ad83Smrg else 21211016ad83Smrg removelist="$lobj $libobj ${libobj}T" 21221016ad83Smrg fi 21231016ad83Smrg 21241016ad83Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 21251016ad83Smrg case $host_os in 21261016ad83Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 21271016ad83Smrg pic_mode=default 21281016ad83Smrg ;; 21291016ad83Smrg esac 21301016ad83Smrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 21311016ad83Smrg # non-PIC code in shared libraries is not supported 21321016ad83Smrg pic_mode=default 21331016ad83Smrg fi 21341016ad83Smrg 21351016ad83Smrg # Calculate the filename of the output object if compiler does 21361016ad83Smrg # not support -o with -c 21371016ad83Smrg if test "$compiler_c_o" = no; then 21381016ad83Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 21391016ad83Smrg lockfile="$output_obj.lock" 21401016ad83Smrg else 21411016ad83Smrg output_obj= 21421016ad83Smrg need_locks=no 21431016ad83Smrg lockfile= 21441016ad83Smrg fi 21451016ad83Smrg 21461016ad83Smrg # Lock this critical section if it is needed 21471016ad83Smrg # We use this script file to make the link, it avoids creating a new file 21481016ad83Smrg if test "$need_locks" = yes; then 21491016ad83Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 21501016ad83Smrg func_echo "Waiting for $lockfile to be removed" 21511016ad83Smrg sleep 2 21521016ad83Smrg done 21531016ad83Smrg elif test "$need_locks" = warn; then 21541016ad83Smrg if test -f "$lockfile"; then 21551016ad83Smrg $ECHO "\ 21561016ad83Smrg*** ERROR, $lockfile exists and contains: 21571016ad83Smrg`cat $lockfile 2>/dev/null` 21581016ad83Smrg 21591016ad83SmrgThis indicates that another process is trying to use the same 21601016ad83Smrgtemporary object file, and libtool could not work around it because 21611016ad83Smrgyour compiler does not support \`-c' and \`-o' together. If you 21621016ad83Smrgrepeat this compilation, it may succeed, by chance, but you had better 21631016ad83Smrgavoid parallel builds (make -j) in this platform, or get a better 21641016ad83Smrgcompiler." 21651016ad83Smrg 21661016ad83Smrg $opt_dry_run || $RM $removelist 21671016ad83Smrg exit $EXIT_FAILURE 21681016ad83Smrg fi 21691016ad83Smrg func_append removelist " $output_obj" 21701016ad83Smrg $ECHO "$srcfile" > "$lockfile" 21711016ad83Smrg fi 21721016ad83Smrg 21731016ad83Smrg $opt_dry_run || $RM $removelist 21741016ad83Smrg func_append removelist " $lockfile" 21751016ad83Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 21761016ad83Smrg 21771016ad83Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 21781016ad83Smrg srcfile=$func_to_tool_file_result 21791016ad83Smrg func_quote_for_eval "$srcfile" 21801016ad83Smrg qsrcfile=$func_quote_for_eval_result 21811016ad83Smrg 21821016ad83Smrg # Only build a PIC object if we are building libtool libraries. 21831016ad83Smrg if test "$build_libtool_libs" = yes; then 21841016ad83Smrg # Without this assignment, base_compile gets emptied. 21851016ad83Smrg fbsd_hideous_sh_bug=$base_compile 21861016ad83Smrg 21871016ad83Smrg if test "$pic_mode" != no; then 21881016ad83Smrg command="$base_compile $qsrcfile $pic_flag" 21891016ad83Smrg else 21901016ad83Smrg # Don't build PIC code 21911016ad83Smrg command="$base_compile $qsrcfile" 21921016ad83Smrg fi 21931016ad83Smrg 21941016ad83Smrg func_mkdir_p "$xdir$objdir" 21951016ad83Smrg 21961016ad83Smrg if test -z "$output_obj"; then 21971016ad83Smrg # Place PIC objects in $objdir 21981016ad83Smrg func_append command " -o $lobj" 21991016ad83Smrg fi 22001016ad83Smrg 22011016ad83Smrg func_show_eval_locale "$command" \ 22021016ad83Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 22031016ad83Smrg 22041016ad83Smrg if test "$need_locks" = warn && 22051016ad83Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 22061016ad83Smrg $ECHO "\ 22071016ad83Smrg*** ERROR, $lockfile contains: 22081016ad83Smrg`cat $lockfile 2>/dev/null` 22091016ad83Smrg 22101016ad83Smrgbut it should contain: 22111016ad83Smrg$srcfile 22121016ad83Smrg 22131016ad83SmrgThis indicates that another process is trying to use the same 22141016ad83Smrgtemporary object file, and libtool could not work around it because 22151016ad83Smrgyour compiler does not support \`-c' and \`-o' together. If you 22161016ad83Smrgrepeat this compilation, it may succeed, by chance, but you had better 22171016ad83Smrgavoid parallel builds (make -j) in this platform, or get a better 22181016ad83Smrgcompiler." 22191016ad83Smrg 22201016ad83Smrg $opt_dry_run || $RM $removelist 22211016ad83Smrg exit $EXIT_FAILURE 22221016ad83Smrg fi 22231016ad83Smrg 22241016ad83Smrg # Just move the object if needed, then go on to compile the next one 22251016ad83Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 22261016ad83Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 22271016ad83Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 22281016ad83Smrg fi 22291016ad83Smrg 22301016ad83Smrg # Allow error messages only from the first compilation. 22311016ad83Smrg if test "$suppress_opt" = yes; then 22321016ad83Smrg suppress_output=' >/dev/null 2>&1' 22331016ad83Smrg fi 22341016ad83Smrg fi 22351016ad83Smrg 22361016ad83Smrg # Only build a position-dependent object if we build old libraries. 22371016ad83Smrg if test "$build_old_libs" = yes; then 22381016ad83Smrg if test "$pic_mode" != yes; then 22391016ad83Smrg # Don't build PIC code 22401016ad83Smrg command="$base_compile $qsrcfile$pie_flag" 22411016ad83Smrg else 22421016ad83Smrg command="$base_compile $qsrcfile $pic_flag" 22431016ad83Smrg fi 22441016ad83Smrg if test "$compiler_c_o" = yes; then 22451016ad83Smrg func_append command " -o $obj" 22461016ad83Smrg fi 22471016ad83Smrg 22481016ad83Smrg # Suppress compiler output if we already did a PIC compilation. 22491016ad83Smrg func_append command "$suppress_output" 22501016ad83Smrg func_show_eval_locale "$command" \ 22511016ad83Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 22521016ad83Smrg 22531016ad83Smrg if test "$need_locks" = warn && 22541016ad83Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 22551016ad83Smrg $ECHO "\ 22561016ad83Smrg*** ERROR, $lockfile contains: 22571016ad83Smrg`cat $lockfile 2>/dev/null` 22581016ad83Smrg 22591016ad83Smrgbut it should contain: 22601016ad83Smrg$srcfile 22611016ad83Smrg 22621016ad83SmrgThis indicates that another process is trying to use the same 22631016ad83Smrgtemporary object file, and libtool could not work around it because 22641016ad83Smrgyour compiler does not support \`-c' and \`-o' together. If you 22651016ad83Smrgrepeat this compilation, it may succeed, by chance, but you had better 22661016ad83Smrgavoid parallel builds (make -j) in this platform, or get a better 22671016ad83Smrgcompiler." 22681016ad83Smrg 22691016ad83Smrg $opt_dry_run || $RM $removelist 22701016ad83Smrg exit $EXIT_FAILURE 22711016ad83Smrg fi 22721016ad83Smrg 22731016ad83Smrg # Just move the object if needed 22741016ad83Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 22751016ad83Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 22761016ad83Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 22771016ad83Smrg fi 22781016ad83Smrg fi 22791016ad83Smrg 22801016ad83Smrg $opt_dry_run || { 22811016ad83Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 22821016ad83Smrg 22831016ad83Smrg # Unlock the critical section if it was locked 22841016ad83Smrg if test "$need_locks" != no; then 22851016ad83Smrg removelist=$lockfile 22861016ad83Smrg $RM "$lockfile" 22871016ad83Smrg fi 22881016ad83Smrg } 22891016ad83Smrg 22901016ad83Smrg exit $EXIT_SUCCESS 22911016ad83Smrg} 22921016ad83Smrg 22931016ad83Smrg$opt_help || { 22941016ad83Smrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 22951016ad83Smrg} 22961016ad83Smrg 22971016ad83Smrgfunc_mode_help () 22981016ad83Smrg{ 22991016ad83Smrg # We need to display help for each of the modes. 23001016ad83Smrg case $opt_mode in 23011016ad83Smrg "") 23021016ad83Smrg # Generic help is extracted from the usage comments 23031016ad83Smrg # at the start of this file. 23041016ad83Smrg func_help 23051016ad83Smrg ;; 23061016ad83Smrg 23071016ad83Smrg clean) 23081016ad83Smrg $ECHO \ 23091016ad83Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 23101016ad83Smrg 23111016ad83SmrgRemove files from the build directory. 23121016ad83Smrg 23131016ad83SmrgRM is the name of the program to use to delete files associated with each FILE 23141016ad83Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 23151016ad83Smrgto RM. 23161016ad83Smrg 23171016ad83SmrgIf FILE is a libtool library, object or program, all the files associated 23181016ad83Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 23191016ad83Smrg ;; 23201016ad83Smrg 23211016ad83Smrg compile) 23221016ad83Smrg $ECHO \ 23231016ad83Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 23241016ad83Smrg 23251016ad83SmrgCompile a source file into a libtool library object. 23261016ad83Smrg 23271016ad83SmrgThis mode accepts the following additional options: 23281016ad83Smrg 23291016ad83Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 23301016ad83Smrg -no-suppress do not suppress compiler output for multiple passes 23311016ad83Smrg -prefer-pic try to build PIC objects only 23321016ad83Smrg -prefer-non-pic try to build non-PIC objects only 23331016ad83Smrg -shared do not build a \`.o' file suitable for static linking 23341016ad83Smrg -static only build a \`.o' file suitable for static linking 23351016ad83Smrg -Wc,FLAG pass FLAG directly to the compiler 23361016ad83Smrg 23371016ad83SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 23381016ad83Smrgfrom the given SOURCEFILE. 23391016ad83Smrg 23401016ad83SmrgThe output file name is determined by removing the directory component from 23411016ad83SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 23421016ad83Smrglibrary object suffix, \`.lo'." 23431016ad83Smrg ;; 23441016ad83Smrg 23451016ad83Smrg execute) 23461016ad83Smrg $ECHO \ 23471016ad83Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 23481016ad83Smrg 23491016ad83SmrgAutomatically set library path, then run a program. 23501016ad83Smrg 23511016ad83SmrgThis mode accepts the following additional options: 23521016ad83Smrg 23531016ad83Smrg -dlopen FILE add the directory containing FILE to the library path 23541016ad83Smrg 23551016ad83SmrgThis mode sets the library path environment variable according to \`-dlopen' 23561016ad83Smrgflags. 23571016ad83Smrg 23581016ad83SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 23591016ad83Smrginto their corresponding uninstalled binary, and any of their required library 23601016ad83Smrgdirectories are added to the library path. 23611016ad83Smrg 23621016ad83SmrgThen, COMMAND is executed, with ARGS as arguments." 23631016ad83Smrg ;; 23641016ad83Smrg 23651016ad83Smrg finish) 23661016ad83Smrg $ECHO \ 23671016ad83Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 23681016ad83Smrg 23691016ad83SmrgComplete the installation of libtool libraries. 23701016ad83Smrg 23711016ad83SmrgEach LIBDIR is a directory that contains libtool libraries. 23721016ad83Smrg 23731016ad83SmrgThe commands that this mode executes may require superuser privileges. Use 23741016ad83Smrgthe \`--dry-run' option if you just want to see what would be executed." 23751016ad83Smrg ;; 23761016ad83Smrg 23771016ad83Smrg install) 23781016ad83Smrg $ECHO \ 23791016ad83Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 23801016ad83Smrg 23811016ad83SmrgInstall executables or libraries. 23821016ad83Smrg 23831016ad83SmrgINSTALL-COMMAND is the installation command. The first component should be 23841016ad83Smrgeither the \`install' or \`cp' program. 23851016ad83Smrg 23861016ad83SmrgThe following components of INSTALL-COMMAND are treated specially: 23871016ad83Smrg 23881016ad83Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 23891016ad83Smrg 23901016ad83SmrgThe rest of the components are interpreted as arguments to that command (only 23911016ad83SmrgBSD-compatible install options are recognized)." 23921016ad83Smrg ;; 23931016ad83Smrg 23941016ad83Smrg link) 23951016ad83Smrg $ECHO \ 23961016ad83Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 23971016ad83Smrg 23981016ad83SmrgLink object files or libraries together to form another library, or to 23991016ad83Smrgcreate an executable program. 24001016ad83Smrg 24011016ad83SmrgLINK-COMMAND is a command using the C compiler that you would use to create 24021016ad83Smrga program from several object files. 24031016ad83Smrg 24041016ad83SmrgThe following components of LINK-COMMAND are treated specially: 24051016ad83Smrg 24061016ad83Smrg -all-static do not do any dynamic linking at all 24071016ad83Smrg -avoid-version do not add a version suffix if possible 24081016ad83Smrg -bindir BINDIR specify path to binaries directory (for systems where 24091016ad83Smrg libraries must be found in the PATH setting at runtime) 24101016ad83Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 24111016ad83Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 24121016ad83Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 24131016ad83Smrg -export-symbols SYMFILE 24141016ad83Smrg try to export only the symbols listed in SYMFILE 24151016ad83Smrg -export-symbols-regex REGEX 24161016ad83Smrg try to export only the symbols matching REGEX 24171016ad83Smrg -LLIBDIR search LIBDIR for required installed libraries 24181016ad83Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 24191016ad83Smrg -module build a library that can dlopened 24201016ad83Smrg -no-fast-install disable the fast-install mode 24211016ad83Smrg -no-install link a not-installable executable 24221016ad83Smrg -no-undefined declare that a library does not refer to external symbols 24231016ad83Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 24241016ad83Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 24251016ad83Smrg -precious-files-regex REGEX 24261016ad83Smrg don't remove output files matching REGEX 24271016ad83Smrg -release RELEASE specify package release information 24281016ad83Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 24291016ad83Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 24301016ad83Smrg -shared only do dynamic linking of libtool libraries 24311016ad83Smrg -shrext SUFFIX override the standard shared library file extension 24321016ad83Smrg -static do not do any dynamic linking of uninstalled libtool libraries 24331016ad83Smrg -static-libtool-libs 24341016ad83Smrg do not do any dynamic linking of libtool libraries 24351016ad83Smrg -version-info CURRENT[:REVISION[:AGE]] 24361016ad83Smrg specify library version info [each variable defaults to 0] 24371016ad83Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 24381016ad83Smrg -Wc,FLAG 24391016ad83Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 24401016ad83Smrg -Wl,FLAG 24411016ad83Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 24421016ad83Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 24431016ad83Smrg 24441016ad83SmrgAll other options (arguments beginning with \`-') are ignored. 24451016ad83Smrg 24461016ad83SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 24471016ad83Smrgtreated as uninstalled libtool libraries, other files are standard or library 24481016ad83Smrgobject files. 24491016ad83Smrg 24501016ad83SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 24511016ad83Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 24521016ad83Smrgrequired, except when creating a convenience library. 24531016ad83Smrg 24541016ad83SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 24551016ad83Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 24561016ad83Smrg 24571016ad83SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 24581016ad83Smrgis created, otherwise an executable program is created." 24591016ad83Smrg ;; 24601016ad83Smrg 24611016ad83Smrg uninstall) 24621016ad83Smrg $ECHO \ 24631016ad83Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 24641016ad83Smrg 24651016ad83SmrgRemove libraries from an installation directory. 24661016ad83Smrg 24671016ad83SmrgRM is the name of the program to use to delete files associated with each FILE 24681016ad83Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 24691016ad83Smrgto RM. 24701016ad83Smrg 24711016ad83SmrgIf FILE is a libtool library, all the files associated with it are deleted. 24721016ad83SmrgOtherwise, only FILE itself is deleted using RM." 24731016ad83Smrg ;; 24741016ad83Smrg 24751016ad83Smrg *) 24761016ad83Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 24771016ad83Smrg ;; 24781016ad83Smrg esac 24791016ad83Smrg 24801016ad83Smrg echo 24811016ad83Smrg $ECHO "Try \`$progname --help' for more information about other modes." 24821016ad83Smrg} 24831016ad83Smrg 24841016ad83Smrg# Now that we've collected a possible --mode arg, show help if necessary 24851016ad83Smrgif $opt_help; then 24861016ad83Smrg if test "$opt_help" = :; then 24871016ad83Smrg func_mode_help 24881016ad83Smrg else 24891016ad83Smrg { 24901016ad83Smrg func_help noexit 24911016ad83Smrg for opt_mode in compile link execute install finish uninstall clean; do 24921016ad83Smrg func_mode_help 24931016ad83Smrg done 24941016ad83Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 24951016ad83Smrg { 24961016ad83Smrg func_help noexit 24971016ad83Smrg for opt_mode in compile link execute install finish uninstall clean; do 24981016ad83Smrg echo 24991016ad83Smrg func_mode_help 25001016ad83Smrg done 25011016ad83Smrg } | 25021016ad83Smrg sed '1d 25031016ad83Smrg /^When reporting/,/^Report/{ 25041016ad83Smrg H 25051016ad83Smrg d 25061016ad83Smrg } 25071016ad83Smrg $x 25081016ad83Smrg /information about other modes/d 25091016ad83Smrg /more detailed .*MODE/d 25101016ad83Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 25111016ad83Smrg fi 25121016ad83Smrg exit $? 25131016ad83Smrgfi 25141016ad83Smrg 25151016ad83Smrg 25161016ad83Smrg# func_mode_execute arg... 25171016ad83Smrgfunc_mode_execute () 25181016ad83Smrg{ 25191016ad83Smrg $opt_debug 25201016ad83Smrg # The first argument is the command name. 25211016ad83Smrg cmd="$nonopt" 25221016ad83Smrg test -z "$cmd" && \ 25231016ad83Smrg func_fatal_help "you must specify a COMMAND" 25241016ad83Smrg 25251016ad83Smrg # Handle -dlopen flags immediately. 25261016ad83Smrg for file in $opt_dlopen; do 25271016ad83Smrg test -f "$file" \ 25281016ad83Smrg || func_fatal_help "\`$file' is not a file" 25291016ad83Smrg 25301016ad83Smrg dir= 25311016ad83Smrg case $file in 25321016ad83Smrg *.la) 25331016ad83Smrg func_resolve_sysroot "$file" 25341016ad83Smrg file=$func_resolve_sysroot_result 25351016ad83Smrg 25361016ad83Smrg # Check to see that this really is a libtool archive. 25371016ad83Smrg func_lalib_unsafe_p "$file" \ 25381016ad83Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 25391016ad83Smrg 25401016ad83Smrg # Read the libtool library. 25411016ad83Smrg dlname= 25421016ad83Smrg library_names= 25431016ad83Smrg func_source "$file" 25441016ad83Smrg 25451016ad83Smrg # Skip this library if it cannot be dlopened. 25461016ad83Smrg if test -z "$dlname"; then 25471016ad83Smrg # Warn if it was a shared library. 25481016ad83Smrg test -n "$library_names" && \ 25491016ad83Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 25501016ad83Smrg continue 25511016ad83Smrg fi 25521016ad83Smrg 25531016ad83Smrg func_dirname "$file" "" "." 25541016ad83Smrg dir="$func_dirname_result" 25551016ad83Smrg 25561016ad83Smrg if test -f "$dir/$objdir/$dlname"; then 25571016ad83Smrg func_append dir "/$objdir" 25581016ad83Smrg else 25591016ad83Smrg if test ! -f "$dir/$dlname"; then 25601016ad83Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 25611016ad83Smrg fi 25621016ad83Smrg fi 25631016ad83Smrg ;; 25641016ad83Smrg 25651016ad83Smrg *.lo) 25661016ad83Smrg # Just add the directory containing the .lo file. 25671016ad83Smrg func_dirname "$file" "" "." 25681016ad83Smrg dir="$func_dirname_result" 25691016ad83Smrg ;; 25701016ad83Smrg 25711016ad83Smrg *) 25721016ad83Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 25731016ad83Smrg continue 25741016ad83Smrg ;; 25751016ad83Smrg esac 25761016ad83Smrg 25771016ad83Smrg # Get the absolute pathname. 25781016ad83Smrg absdir=`cd "$dir" && pwd` 25791016ad83Smrg test -n "$absdir" && dir="$absdir" 25801016ad83Smrg 25811016ad83Smrg # Now add the directory to shlibpath_var. 25821016ad83Smrg if eval "test -z \"\$$shlibpath_var\""; then 25831016ad83Smrg eval "$shlibpath_var=\"\$dir\"" 25841016ad83Smrg else 25851016ad83Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 25861016ad83Smrg fi 25871016ad83Smrg done 25881016ad83Smrg 25891016ad83Smrg # This variable tells wrapper scripts just to set shlibpath_var 25901016ad83Smrg # rather than running their programs. 25911016ad83Smrg libtool_execute_magic="$magic" 25921016ad83Smrg 25931016ad83Smrg # Check if any of the arguments is a wrapper script. 25941016ad83Smrg args= 25951016ad83Smrg for file 25961016ad83Smrg do 25971016ad83Smrg case $file in 25981016ad83Smrg -* | *.la | *.lo ) ;; 25991016ad83Smrg *) 26001016ad83Smrg # Do a test to see if this is really a libtool program. 26011016ad83Smrg if func_ltwrapper_script_p "$file"; then 26021016ad83Smrg func_source "$file" 26031016ad83Smrg # Transform arg to wrapped name. 26041016ad83Smrg file="$progdir/$program" 26051016ad83Smrg elif func_ltwrapper_executable_p "$file"; then 26061016ad83Smrg func_ltwrapper_scriptname "$file" 26071016ad83Smrg func_source "$func_ltwrapper_scriptname_result" 26081016ad83Smrg # Transform arg to wrapped name. 26091016ad83Smrg file="$progdir/$program" 26101016ad83Smrg fi 26111016ad83Smrg ;; 26121016ad83Smrg esac 26131016ad83Smrg # Quote arguments (to preserve shell metacharacters). 26141016ad83Smrg func_append_quoted args "$file" 26151016ad83Smrg done 26161016ad83Smrg 26171016ad83Smrg if test "X$opt_dry_run" = Xfalse; then 26181016ad83Smrg if test -n "$shlibpath_var"; then 26191016ad83Smrg # Export the shlibpath_var. 26201016ad83Smrg eval "export $shlibpath_var" 26211016ad83Smrg fi 26221016ad83Smrg 26231016ad83Smrg # Restore saved environment variables 26241016ad83Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 26251016ad83Smrg do 26261016ad83Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 26271016ad83Smrg $lt_var=\$save_$lt_var; export $lt_var 26281016ad83Smrg else 26291016ad83Smrg $lt_unset $lt_var 26301016ad83Smrg fi" 26311016ad83Smrg done 26321016ad83Smrg 26331016ad83Smrg # Now prepare to actually exec the command. 26341016ad83Smrg exec_cmd="\$cmd$args" 26351016ad83Smrg else 26361016ad83Smrg # Display what would be done. 26371016ad83Smrg if test -n "$shlibpath_var"; then 26381016ad83Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 26391016ad83Smrg echo "export $shlibpath_var" 26401016ad83Smrg fi 26411016ad83Smrg $ECHO "$cmd$args" 26421016ad83Smrg exit $EXIT_SUCCESS 26431016ad83Smrg fi 26441016ad83Smrg} 26451016ad83Smrg 26461016ad83Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 26471016ad83Smrg 26481016ad83Smrg 26491016ad83Smrg# func_mode_finish arg... 26501016ad83Smrgfunc_mode_finish () 26511016ad83Smrg{ 26521016ad83Smrg $opt_debug 26531016ad83Smrg libs= 26541016ad83Smrg libdirs= 26551016ad83Smrg admincmds= 26561016ad83Smrg 26571016ad83Smrg for opt in "$nonopt" ${1+"$@"} 26581016ad83Smrg do 26591016ad83Smrg if test -d "$opt"; then 26601016ad83Smrg func_append libdirs " $opt" 26611016ad83Smrg 26621016ad83Smrg elif test -f "$opt"; then 26631016ad83Smrg if func_lalib_unsafe_p "$opt"; then 26641016ad83Smrg func_append libs " $opt" 26651016ad83Smrg else 26661016ad83Smrg func_warning "\`$opt' is not a valid libtool archive" 26671016ad83Smrg fi 26681016ad83Smrg 26691016ad83Smrg else 26701016ad83Smrg func_fatal_error "invalid argument \`$opt'" 26711016ad83Smrg fi 26721016ad83Smrg done 26731016ad83Smrg 26741016ad83Smrg if test -n "$libs"; then 26751016ad83Smrg if test -n "$lt_sysroot"; then 26761016ad83Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 26771016ad83Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 26781016ad83Smrg else 26791016ad83Smrg sysroot_cmd= 26801016ad83Smrg fi 26811016ad83Smrg 26821016ad83Smrg # Remove sysroot references 26831016ad83Smrg if $opt_dry_run; then 26841016ad83Smrg for lib in $libs; do 26851016ad83Smrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 26861016ad83Smrg done 26871016ad83Smrg else 26881016ad83Smrg tmpdir=`func_mktempdir` 26891016ad83Smrg for lib in $libs; do 26901016ad83Smrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 26911016ad83Smrg > $tmpdir/tmp-la 26921016ad83Smrg mv -f $tmpdir/tmp-la $lib 26931016ad83Smrg done 26941016ad83Smrg ${RM}r "$tmpdir" 26951016ad83Smrg fi 26961016ad83Smrg fi 26971016ad83Smrg 26981016ad83Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 26991016ad83Smrg for libdir in $libdirs; do 27001016ad83Smrg if test -n "$finish_cmds"; then 27011016ad83Smrg # Do each command in the finish commands. 27021016ad83Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 27031016ad83Smrg'"$cmd"'"' 27041016ad83Smrg fi 27051016ad83Smrg if test -n "$finish_eval"; then 27061016ad83Smrg # Do the single finish_eval. 27071016ad83Smrg eval cmds=\"$finish_eval\" 27081016ad83Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 27091016ad83Smrg $cmds" 27101016ad83Smrg fi 27111016ad83Smrg done 27121016ad83Smrg fi 27131016ad83Smrg 27141016ad83Smrg # Exit here if they wanted silent mode. 27151016ad83Smrg $opt_silent && exit $EXIT_SUCCESS 27161016ad83Smrg 27171016ad83Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 27181016ad83Smrg echo "----------------------------------------------------------------------" 27191016ad83Smrg echo "Libraries have been installed in:" 27201016ad83Smrg for libdir in $libdirs; do 27211016ad83Smrg $ECHO " $libdir" 27221016ad83Smrg done 27231016ad83Smrg echo 27241016ad83Smrg echo "If you ever happen to want to link against installed libraries" 27251016ad83Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 27261016ad83Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 27271016ad83Smrg echo "flag during linking and do at least one of the following:" 27281016ad83Smrg if test -n "$shlibpath_var"; then 27291016ad83Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 27301016ad83Smrg echo " during execution" 27311016ad83Smrg fi 27321016ad83Smrg if test -n "$runpath_var"; then 27331016ad83Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 27341016ad83Smrg echo " during linking" 27351016ad83Smrg fi 27361016ad83Smrg if test -n "$hardcode_libdir_flag_spec"; then 27371016ad83Smrg libdir=LIBDIR 27381016ad83Smrg eval flag=\"$hardcode_libdir_flag_spec\" 27391016ad83Smrg 27401016ad83Smrg $ECHO " - use the \`$flag' linker flag" 27411016ad83Smrg fi 27421016ad83Smrg if test -n "$admincmds"; then 27431016ad83Smrg $ECHO " - have your system administrator run these commands:$admincmds" 27441016ad83Smrg fi 27451016ad83Smrg if test -f /etc/ld.so.conf; then 27461016ad83Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 27471016ad83Smrg fi 27481016ad83Smrg echo 27491016ad83Smrg 27501016ad83Smrg echo "See any operating system documentation about shared libraries for" 27511016ad83Smrg case $host in 27521016ad83Smrg solaris2.[6789]|solaris2.1[0-9]) 27531016ad83Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 27541016ad83Smrg echo "pages." 27551016ad83Smrg ;; 27561016ad83Smrg *) 27571016ad83Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 27581016ad83Smrg ;; 27591016ad83Smrg esac 27601016ad83Smrg echo "----------------------------------------------------------------------" 27611016ad83Smrg fi 27621016ad83Smrg exit $EXIT_SUCCESS 27631016ad83Smrg} 27641016ad83Smrg 27651016ad83Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 27661016ad83Smrg 27671016ad83Smrg 27681016ad83Smrg# func_mode_install arg... 27691016ad83Smrgfunc_mode_install () 27701016ad83Smrg{ 27711016ad83Smrg $opt_debug 27721016ad83Smrg # There may be an optional sh(1) argument at the beginning of 27731016ad83Smrg # install_prog (especially on Windows NT). 27741016ad83Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 27751016ad83Smrg # Allow the use of GNU shtool's install command. 27761016ad83Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 27771016ad83Smrg # Aesthetically quote it. 27781016ad83Smrg func_quote_for_eval "$nonopt" 27791016ad83Smrg install_prog="$func_quote_for_eval_result " 27801016ad83Smrg arg=$1 27811016ad83Smrg shift 27821016ad83Smrg else 27831016ad83Smrg install_prog= 27841016ad83Smrg arg=$nonopt 27851016ad83Smrg fi 27861016ad83Smrg 27871016ad83Smrg # The real first argument should be the name of the installation program. 27881016ad83Smrg # Aesthetically quote it. 27891016ad83Smrg func_quote_for_eval "$arg" 27901016ad83Smrg func_append install_prog "$func_quote_for_eval_result" 27911016ad83Smrg install_shared_prog=$install_prog 27921016ad83Smrg case " $install_prog " in 27931016ad83Smrg *[\\\ /]cp\ *) install_cp=: ;; 27941016ad83Smrg *) install_cp=false ;; 27951016ad83Smrg esac 27961016ad83Smrg 27971016ad83Smrg # We need to accept at least all the BSD install flags. 27981016ad83Smrg dest= 27991016ad83Smrg files= 28001016ad83Smrg opts= 28011016ad83Smrg prev= 28021016ad83Smrg install_type= 28031016ad83Smrg isdir=no 28041016ad83Smrg stripme= 28051016ad83Smrg no_mode=: 28061016ad83Smrg for arg 28071016ad83Smrg do 28081016ad83Smrg arg2= 28091016ad83Smrg if test -n "$dest"; then 28101016ad83Smrg func_append files " $dest" 28111016ad83Smrg dest=$arg 28121016ad83Smrg continue 28131016ad83Smrg fi 28141016ad83Smrg 28151016ad83Smrg case $arg in 28161016ad83Smrg -d) isdir=yes ;; 28171016ad83Smrg -f) 28181016ad83Smrg if $install_cp; then :; else 28191016ad83Smrg prev=$arg 28201016ad83Smrg fi 28211016ad83Smrg ;; 28221016ad83Smrg -g | -m | -o) 28231016ad83Smrg prev=$arg 28241016ad83Smrg ;; 28251016ad83Smrg -s) 28261016ad83Smrg stripme=" -s" 28271016ad83Smrg continue 28281016ad83Smrg ;; 28291016ad83Smrg -*) 28301016ad83Smrg ;; 28311016ad83Smrg *) 28321016ad83Smrg # If the previous option needed an argument, then skip it. 28331016ad83Smrg if test -n "$prev"; then 28341016ad83Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 28351016ad83Smrg arg2=$install_override_mode 28361016ad83Smrg no_mode=false 28371016ad83Smrg fi 28381016ad83Smrg prev= 28391016ad83Smrg else 28401016ad83Smrg dest=$arg 28411016ad83Smrg continue 28421016ad83Smrg fi 28431016ad83Smrg ;; 28441016ad83Smrg esac 28451016ad83Smrg 28461016ad83Smrg # Aesthetically quote the argument. 28471016ad83Smrg func_quote_for_eval "$arg" 28481016ad83Smrg func_append install_prog " $func_quote_for_eval_result" 28491016ad83Smrg if test -n "$arg2"; then 28501016ad83Smrg func_quote_for_eval "$arg2" 28511016ad83Smrg fi 28521016ad83Smrg func_append install_shared_prog " $func_quote_for_eval_result" 28531016ad83Smrg done 28541016ad83Smrg 28551016ad83Smrg test -z "$install_prog" && \ 28561016ad83Smrg func_fatal_help "you must specify an install program" 28571016ad83Smrg 28581016ad83Smrg test -n "$prev" && \ 28591016ad83Smrg func_fatal_help "the \`$prev' option requires an argument" 28601016ad83Smrg 28611016ad83Smrg if test -n "$install_override_mode" && $no_mode; then 28621016ad83Smrg if $install_cp; then :; else 28631016ad83Smrg func_quote_for_eval "$install_override_mode" 28641016ad83Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 28651016ad83Smrg fi 28661016ad83Smrg fi 28671016ad83Smrg 28681016ad83Smrg if test -z "$files"; then 28691016ad83Smrg if test -z "$dest"; then 28701016ad83Smrg func_fatal_help "no file or destination specified" 28711016ad83Smrg else 28721016ad83Smrg func_fatal_help "you must specify a destination" 28731016ad83Smrg fi 28741016ad83Smrg fi 28751016ad83Smrg 28761016ad83Smrg # Strip any trailing slash from the destination. 28771016ad83Smrg func_stripname '' '/' "$dest" 28781016ad83Smrg dest=$func_stripname_result 28791016ad83Smrg 28801016ad83Smrg # Check to see that the destination is a directory. 28811016ad83Smrg test -d "$dest" && isdir=yes 28821016ad83Smrg if test "$isdir" = yes; then 28831016ad83Smrg destdir="$dest" 28841016ad83Smrg destname= 28851016ad83Smrg else 28861016ad83Smrg func_dirname_and_basename "$dest" "" "." 28871016ad83Smrg destdir="$func_dirname_result" 28881016ad83Smrg destname="$func_basename_result" 28891016ad83Smrg 28901016ad83Smrg # Not a directory, so check to see that there is only one file specified. 28911016ad83Smrg set dummy $files; shift 28921016ad83Smrg test "$#" -gt 1 && \ 28931016ad83Smrg func_fatal_help "\`$dest' is not a directory" 28941016ad83Smrg fi 28951016ad83Smrg case $destdir in 28961016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 28971016ad83Smrg *) 28981016ad83Smrg for file in $files; do 28991016ad83Smrg case $file in 29001016ad83Smrg *.lo) ;; 29011016ad83Smrg *) 29021016ad83Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 29031016ad83Smrg ;; 29041016ad83Smrg esac 29051016ad83Smrg done 29061016ad83Smrg ;; 29071016ad83Smrg esac 29081016ad83Smrg 29091016ad83Smrg # This variable tells wrapper scripts just to set variables rather 29101016ad83Smrg # than running their programs. 29111016ad83Smrg libtool_install_magic="$magic" 29121016ad83Smrg 29131016ad83Smrg staticlibs= 29141016ad83Smrg future_libdirs= 29151016ad83Smrg current_libdirs= 29161016ad83Smrg for file in $files; do 29171016ad83Smrg 29181016ad83Smrg # Do each installation. 29191016ad83Smrg case $file in 29201016ad83Smrg *.$libext) 29211016ad83Smrg # Do the static libraries later. 29221016ad83Smrg func_append staticlibs " $file" 29231016ad83Smrg ;; 29241016ad83Smrg 29251016ad83Smrg *.la) 29261016ad83Smrg func_resolve_sysroot "$file" 29271016ad83Smrg file=$func_resolve_sysroot_result 29281016ad83Smrg 29291016ad83Smrg # Check to see that this really is a libtool archive. 29301016ad83Smrg func_lalib_unsafe_p "$file" \ 29311016ad83Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 29321016ad83Smrg 29331016ad83Smrg library_names= 29341016ad83Smrg old_library= 29351016ad83Smrg relink_command= 29361016ad83Smrg func_source "$file" 29371016ad83Smrg 29381016ad83Smrg # Add the libdir to current_libdirs if it is the destination. 29391016ad83Smrg if test "X$destdir" = "X$libdir"; then 29401016ad83Smrg case "$current_libdirs " in 29411016ad83Smrg *" $libdir "*) ;; 29421016ad83Smrg *) func_append current_libdirs " $libdir" ;; 29431016ad83Smrg esac 29441016ad83Smrg else 29451016ad83Smrg # Note the libdir as a future libdir. 29461016ad83Smrg case "$future_libdirs " in 29471016ad83Smrg *" $libdir "*) ;; 29481016ad83Smrg *) func_append future_libdirs " $libdir" ;; 29491016ad83Smrg esac 29501016ad83Smrg fi 29511016ad83Smrg 29521016ad83Smrg func_dirname "$file" "/" "" 29531016ad83Smrg dir="$func_dirname_result" 29541016ad83Smrg func_append dir "$objdir" 29551016ad83Smrg 29561016ad83Smrg if test -n "$relink_command"; then 29571016ad83Smrg # Determine the prefix the user has applied to our future dir. 29581016ad83Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 29591016ad83Smrg 29601016ad83Smrg # Don't allow the user to place us outside of our expected 29611016ad83Smrg # location b/c this prevents finding dependent libraries that 29621016ad83Smrg # are installed to the same prefix. 29631016ad83Smrg # At present, this check doesn't affect windows .dll's that 29641016ad83Smrg # are installed into $libdir/../bin (currently, that works fine) 29651016ad83Smrg # but it's something to keep an eye on. 29661016ad83Smrg test "$inst_prefix_dir" = "$destdir" && \ 29671016ad83Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 29681016ad83Smrg 29691016ad83Smrg if test -n "$inst_prefix_dir"; then 29701016ad83Smrg # Stick the inst_prefix_dir data into the link command. 29711016ad83Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 29721016ad83Smrg else 29731016ad83Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 29741016ad83Smrg fi 29751016ad83Smrg 29761016ad83Smrg func_warning "relinking \`$file'" 29771016ad83Smrg func_show_eval "$relink_command" \ 29781016ad83Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 29791016ad83Smrg fi 29801016ad83Smrg 29811016ad83Smrg # See the names of the shared library. 29821016ad83Smrg set dummy $library_names; shift 29831016ad83Smrg if test -n "$1"; then 29841016ad83Smrg realname="$1" 29851016ad83Smrg shift 29861016ad83Smrg 29871016ad83Smrg srcname="$realname" 29881016ad83Smrg test -n "$relink_command" && srcname="$realname"T 29891016ad83Smrg 29901016ad83Smrg # Install the shared library and build the symlinks. 29911016ad83Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 29921016ad83Smrg 'exit $?' 29931016ad83Smrg tstripme="$stripme" 29941016ad83Smrg case $host_os in 29951016ad83Smrg cygwin* | mingw* | pw32* | cegcc*) 29961016ad83Smrg case $realname in 29971016ad83Smrg *.dll.a) 29981016ad83Smrg tstripme="" 29991016ad83Smrg ;; 30001016ad83Smrg esac 30011016ad83Smrg ;; 30021016ad83Smrg esac 30031016ad83Smrg if test -n "$tstripme" && test -n "$striplib"; then 30041016ad83Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 30051016ad83Smrg fi 30061016ad83Smrg 30071016ad83Smrg if test "$#" -gt 0; then 30081016ad83Smrg # Delete the old symlinks, and create new ones. 30091016ad83Smrg # Try `ln -sf' first, because the `ln' binary might depend on 30101016ad83Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 30111016ad83Smrg # so we also need to try rm && ln -s. 30121016ad83Smrg for linkname 30131016ad83Smrg do 30141016ad83Smrg test "$linkname" != "$realname" \ 30151016ad83Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 30161016ad83Smrg done 30171016ad83Smrg fi 30181016ad83Smrg 30191016ad83Smrg # Do each command in the postinstall commands. 30201016ad83Smrg lib="$destdir/$realname" 30211016ad83Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 30221016ad83Smrg fi 30231016ad83Smrg 30241016ad83Smrg # Install the pseudo-library for information purposes. 30251016ad83Smrg func_basename "$file" 30261016ad83Smrg name="$func_basename_result" 30271016ad83Smrg instname="$dir/$name"i 30281016ad83Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 30291016ad83Smrg 30301016ad83Smrg # Maybe install the static library, too. 30311016ad83Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 30321016ad83Smrg ;; 30331016ad83Smrg 30341016ad83Smrg *.lo) 30351016ad83Smrg # Install (i.e. copy) a libtool object. 30361016ad83Smrg 30371016ad83Smrg # Figure out destination file name, if it wasn't already specified. 30381016ad83Smrg if test -n "$destname"; then 30391016ad83Smrg destfile="$destdir/$destname" 30401016ad83Smrg else 30411016ad83Smrg func_basename "$file" 30421016ad83Smrg destfile="$func_basename_result" 30431016ad83Smrg destfile="$destdir/$destfile" 30441016ad83Smrg fi 30451016ad83Smrg 30461016ad83Smrg # Deduce the name of the destination old-style object file. 30471016ad83Smrg case $destfile in 30481016ad83Smrg *.lo) 30491016ad83Smrg func_lo2o "$destfile" 30501016ad83Smrg staticdest=$func_lo2o_result 30511016ad83Smrg ;; 30521016ad83Smrg *.$objext) 30531016ad83Smrg staticdest="$destfile" 30541016ad83Smrg destfile= 30551016ad83Smrg ;; 30561016ad83Smrg *) 30571016ad83Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 30581016ad83Smrg ;; 30591016ad83Smrg esac 30601016ad83Smrg 30611016ad83Smrg # Install the libtool object if requested. 30621016ad83Smrg test -n "$destfile" && \ 30631016ad83Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 30641016ad83Smrg 30651016ad83Smrg # Install the old object if enabled. 30661016ad83Smrg if test "$build_old_libs" = yes; then 30671016ad83Smrg # Deduce the name of the old-style object file. 30681016ad83Smrg func_lo2o "$file" 30691016ad83Smrg staticobj=$func_lo2o_result 30701016ad83Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 30711016ad83Smrg fi 30721016ad83Smrg exit $EXIT_SUCCESS 30731016ad83Smrg ;; 30741016ad83Smrg 30751016ad83Smrg *) 30761016ad83Smrg # Figure out destination file name, if it wasn't already specified. 30771016ad83Smrg if test -n "$destname"; then 30781016ad83Smrg destfile="$destdir/$destname" 30791016ad83Smrg else 30801016ad83Smrg func_basename "$file" 30811016ad83Smrg destfile="$func_basename_result" 30821016ad83Smrg destfile="$destdir/$destfile" 30831016ad83Smrg fi 30841016ad83Smrg 30851016ad83Smrg # If the file is missing, and there is a .exe on the end, strip it 30861016ad83Smrg # because it is most likely a libtool script we actually want to 30871016ad83Smrg # install 30881016ad83Smrg stripped_ext="" 30891016ad83Smrg case $file in 30901016ad83Smrg *.exe) 30911016ad83Smrg if test ! -f "$file"; then 30921016ad83Smrg func_stripname '' '.exe' "$file" 30931016ad83Smrg file=$func_stripname_result 30941016ad83Smrg stripped_ext=".exe" 30951016ad83Smrg fi 30961016ad83Smrg ;; 30971016ad83Smrg esac 30981016ad83Smrg 30991016ad83Smrg # Do a test to see if this is really a libtool program. 31001016ad83Smrg case $host in 31011016ad83Smrg *cygwin* | *mingw*) 31021016ad83Smrg if func_ltwrapper_executable_p "$file"; then 31031016ad83Smrg func_ltwrapper_scriptname "$file" 31041016ad83Smrg wrapper=$func_ltwrapper_scriptname_result 31051016ad83Smrg else 31061016ad83Smrg func_stripname '' '.exe' "$file" 31071016ad83Smrg wrapper=$func_stripname_result 31081016ad83Smrg fi 31091016ad83Smrg ;; 31101016ad83Smrg *) 31111016ad83Smrg wrapper=$file 31121016ad83Smrg ;; 31131016ad83Smrg esac 31141016ad83Smrg if func_ltwrapper_script_p "$wrapper"; then 31151016ad83Smrg notinst_deplibs= 31161016ad83Smrg relink_command= 31171016ad83Smrg 31181016ad83Smrg func_source "$wrapper" 31191016ad83Smrg 31201016ad83Smrg # Check the variables that should have been set. 31211016ad83Smrg test -z "$generated_by_libtool_version" && \ 31221016ad83Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 31231016ad83Smrg 31241016ad83Smrg finalize=yes 31251016ad83Smrg for lib in $notinst_deplibs; do 31261016ad83Smrg # Check to see that each library is installed. 31271016ad83Smrg libdir= 31281016ad83Smrg if test -f "$lib"; then 31291016ad83Smrg func_source "$lib" 31301016ad83Smrg fi 31311016ad83Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 31321016ad83Smrg if test -n "$libdir" && test ! -f "$libfile"; then 31331016ad83Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 31341016ad83Smrg finalize=no 31351016ad83Smrg fi 31361016ad83Smrg done 31371016ad83Smrg 31381016ad83Smrg relink_command= 31391016ad83Smrg func_source "$wrapper" 31401016ad83Smrg 31411016ad83Smrg outputname= 31421016ad83Smrg if test "$fast_install" = no && test -n "$relink_command"; then 31431016ad83Smrg $opt_dry_run || { 31441016ad83Smrg if test "$finalize" = yes; then 31451016ad83Smrg tmpdir=`func_mktempdir` 31461016ad83Smrg func_basename "$file$stripped_ext" 31471016ad83Smrg file="$func_basename_result" 31481016ad83Smrg outputname="$tmpdir/$file" 31491016ad83Smrg # Replace the output file specification. 31501016ad83Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 31511016ad83Smrg 31521016ad83Smrg $opt_silent || { 31531016ad83Smrg func_quote_for_expand "$relink_command" 31541016ad83Smrg eval "func_echo $func_quote_for_expand_result" 31551016ad83Smrg } 31561016ad83Smrg if eval "$relink_command"; then : 31571016ad83Smrg else 31581016ad83Smrg func_error "error: relink \`$file' with the above command before installing it" 31591016ad83Smrg $opt_dry_run || ${RM}r "$tmpdir" 31601016ad83Smrg continue 31611016ad83Smrg fi 31621016ad83Smrg file="$outputname" 31631016ad83Smrg else 31641016ad83Smrg func_warning "cannot relink \`$file'" 31651016ad83Smrg fi 31661016ad83Smrg } 31671016ad83Smrg else 31681016ad83Smrg # Install the binary that we compiled earlier. 31691016ad83Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 31701016ad83Smrg fi 31711016ad83Smrg fi 31721016ad83Smrg 31731016ad83Smrg # remove .exe since cygwin /usr/bin/install will append another 31741016ad83Smrg # one anyway 31751016ad83Smrg case $install_prog,$host in 31761016ad83Smrg */usr/bin/install*,*cygwin*) 31771016ad83Smrg case $file:$destfile in 31781016ad83Smrg *.exe:*.exe) 31791016ad83Smrg # this is ok 31801016ad83Smrg ;; 31811016ad83Smrg *.exe:*) 31821016ad83Smrg destfile=$destfile.exe 31831016ad83Smrg ;; 31841016ad83Smrg *:*.exe) 31851016ad83Smrg func_stripname '' '.exe' "$destfile" 31861016ad83Smrg destfile=$func_stripname_result 31871016ad83Smrg ;; 31881016ad83Smrg esac 31891016ad83Smrg ;; 31901016ad83Smrg esac 31911016ad83Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 31921016ad83Smrg $opt_dry_run || if test -n "$outputname"; then 31931016ad83Smrg ${RM}r "$tmpdir" 31941016ad83Smrg fi 31951016ad83Smrg ;; 31961016ad83Smrg esac 31971016ad83Smrg done 31981016ad83Smrg 31991016ad83Smrg for file in $staticlibs; do 32001016ad83Smrg func_basename "$file" 32011016ad83Smrg name="$func_basename_result" 32021016ad83Smrg 32031016ad83Smrg # Set up the ranlib parameters. 32041016ad83Smrg oldlib="$destdir/$name" 32051016ad83Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 32061016ad83Smrg tool_oldlib=$func_to_tool_file_result 32071016ad83Smrg 32081016ad83Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 32091016ad83Smrg 32101016ad83Smrg if test -n "$stripme" && test -n "$old_striplib"; then 32111016ad83Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 32121016ad83Smrg fi 32131016ad83Smrg 32141016ad83Smrg # Do each command in the postinstall commands. 32151016ad83Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 32161016ad83Smrg done 32171016ad83Smrg 32181016ad83Smrg test -n "$future_libdirs" && \ 32191016ad83Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 32201016ad83Smrg 32211016ad83Smrg if test -n "$current_libdirs"; then 32221016ad83Smrg # Maybe just do a dry run. 32231016ad83Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 32241016ad83Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 32251016ad83Smrg else 32261016ad83Smrg exit $EXIT_SUCCESS 32271016ad83Smrg fi 32281016ad83Smrg} 32291016ad83Smrg 32301016ad83Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 32311016ad83Smrg 32321016ad83Smrg 32331016ad83Smrg# func_generate_dlsyms outputname originator pic_p 32341016ad83Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 32351016ad83Smrg# a dlpreopen symbol table. 32361016ad83Smrgfunc_generate_dlsyms () 32371016ad83Smrg{ 32381016ad83Smrg $opt_debug 32391016ad83Smrg my_outputname="$1" 32401016ad83Smrg my_originator="$2" 32411016ad83Smrg my_pic_p="${3-no}" 32421016ad83Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 32431016ad83Smrg my_dlsyms= 32441016ad83Smrg 32451016ad83Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 32461016ad83Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 32471016ad83Smrg my_dlsyms="${my_outputname}S.c" 32481016ad83Smrg else 32491016ad83Smrg func_error "not configured to extract global symbols from dlpreopened files" 32501016ad83Smrg fi 32511016ad83Smrg fi 32521016ad83Smrg 32531016ad83Smrg if test -n "$my_dlsyms"; then 32541016ad83Smrg case $my_dlsyms in 32551016ad83Smrg "") ;; 32561016ad83Smrg *.c) 32571016ad83Smrg # Discover the nlist of each of the dlfiles. 32581016ad83Smrg nlist="$output_objdir/${my_outputname}.nm" 32591016ad83Smrg 32601016ad83Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 32611016ad83Smrg 32621016ad83Smrg # Parse the name list into a source file. 32631016ad83Smrg func_verbose "creating $output_objdir/$my_dlsyms" 32641016ad83Smrg 32651016ad83Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 32661016ad83Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 32671016ad83Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 32681016ad83Smrg 32691016ad83Smrg#ifdef __cplusplus 32701016ad83Smrgextern \"C\" { 32711016ad83Smrg#endif 32721016ad83Smrg 32731016ad83Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 32741016ad83Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 32751016ad83Smrg#endif 32761016ad83Smrg 32771016ad83Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 32781016ad83Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 32791016ad83Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 32801016ad83Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 32811016ad83Smrg# define LT_DLSYM_CONST 32821016ad83Smrg#elif defined(__osf__) 32831016ad83Smrg/* This system does not cope well with relocations in const data. */ 32841016ad83Smrg# define LT_DLSYM_CONST 32851016ad83Smrg#else 32861016ad83Smrg# define LT_DLSYM_CONST const 32871016ad83Smrg#endif 32881016ad83Smrg 32891016ad83Smrg/* External symbol declarations for the compiler. */\ 32901016ad83Smrg" 32911016ad83Smrg 32921016ad83Smrg if test "$dlself" = yes; then 32931016ad83Smrg func_verbose "generating symbol list for \`$output'" 32941016ad83Smrg 32951016ad83Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 32961016ad83Smrg 32971016ad83Smrg # Add our own program objects to the symbol list. 32981016ad83Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 32991016ad83Smrg for progfile in $progfiles; do 33001016ad83Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 33011016ad83Smrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 33021016ad83Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 33031016ad83Smrg done 33041016ad83Smrg 33051016ad83Smrg if test -n "$exclude_expsyms"; then 33061016ad83Smrg $opt_dry_run || { 33071016ad83Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 33081016ad83Smrg eval '$MV "$nlist"T "$nlist"' 33091016ad83Smrg } 33101016ad83Smrg fi 33111016ad83Smrg 33121016ad83Smrg if test -n "$export_symbols_regex"; then 33131016ad83Smrg $opt_dry_run || { 33141016ad83Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 33151016ad83Smrg eval '$MV "$nlist"T "$nlist"' 33161016ad83Smrg } 33171016ad83Smrg fi 33181016ad83Smrg 33191016ad83Smrg # Prepare the list of exported symbols 33201016ad83Smrg if test -z "$export_symbols"; then 33211016ad83Smrg export_symbols="$output_objdir/$outputname.exp" 33221016ad83Smrg $opt_dry_run || { 33231016ad83Smrg $RM $export_symbols 33241016ad83Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 33251016ad83Smrg case $host in 33261016ad83Smrg *cygwin* | *mingw* | *cegcc* ) 33271016ad83Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 33281016ad83Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 33291016ad83Smrg ;; 33301016ad83Smrg esac 33311016ad83Smrg } 33321016ad83Smrg else 33331016ad83Smrg $opt_dry_run || { 33341016ad83Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 33351016ad83Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 33361016ad83Smrg eval '$MV "$nlist"T "$nlist"' 33371016ad83Smrg case $host in 33381016ad83Smrg *cygwin* | *mingw* | *cegcc* ) 33391016ad83Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 33401016ad83Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 33411016ad83Smrg ;; 33421016ad83Smrg esac 33431016ad83Smrg } 33441016ad83Smrg fi 33451016ad83Smrg fi 33461016ad83Smrg 33471016ad83Smrg for dlprefile in $dlprefiles; do 33481016ad83Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 33491016ad83Smrg func_basename "$dlprefile" 33501016ad83Smrg name="$func_basename_result" 33511016ad83Smrg case $host in 33521016ad83Smrg *cygwin* | *mingw* | *cegcc* ) 33531016ad83Smrg # if an import library, we need to obtain dlname 33541016ad83Smrg if func_win32_import_lib_p "$dlprefile"; then 33551016ad83Smrg func_tr_sh "$dlprefile" 33561016ad83Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 33571016ad83Smrg dlprefile_dlbasename="" 33581016ad83Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 33591016ad83Smrg # Use subshell, to avoid clobbering current variable values 33601016ad83Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 33611016ad83Smrg if test -n "$dlprefile_dlname" ; then 33621016ad83Smrg func_basename "$dlprefile_dlname" 33631016ad83Smrg dlprefile_dlbasename="$func_basename_result" 33641016ad83Smrg else 33651016ad83Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 33661016ad83Smrg $sharedlib_from_linklib_cmd "$dlprefile" 33671016ad83Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 33681016ad83Smrg fi 33691016ad83Smrg fi 33701016ad83Smrg $opt_dry_run || { 33711016ad83Smrg if test -n "$dlprefile_dlbasename" ; then 33721016ad83Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 33731016ad83Smrg else 33741016ad83Smrg func_warning "Could not compute DLL name from $name" 33751016ad83Smrg eval '$ECHO ": $name " >> "$nlist"' 33761016ad83Smrg fi 33771016ad83Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 33781016ad83Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 33791016ad83Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 33801016ad83Smrg } 33811016ad83Smrg else # not an import lib 33821016ad83Smrg $opt_dry_run || { 33831016ad83Smrg eval '$ECHO ": $name " >> "$nlist"' 33841016ad83Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 33851016ad83Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 33861016ad83Smrg } 33871016ad83Smrg fi 33881016ad83Smrg ;; 33891016ad83Smrg *) 33901016ad83Smrg $opt_dry_run || { 33911016ad83Smrg eval '$ECHO ": $name " >> "$nlist"' 33921016ad83Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 33931016ad83Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 33941016ad83Smrg } 33951016ad83Smrg ;; 33961016ad83Smrg esac 33971016ad83Smrg done 33981016ad83Smrg 33991016ad83Smrg $opt_dry_run || { 34001016ad83Smrg # Make sure we have at least an empty file. 34011016ad83Smrg test -f "$nlist" || : > "$nlist" 34021016ad83Smrg 34031016ad83Smrg if test -n "$exclude_expsyms"; then 34041016ad83Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 34051016ad83Smrg $MV "$nlist"T "$nlist" 34061016ad83Smrg fi 34071016ad83Smrg 34081016ad83Smrg # Try sorting and uniquifying the output. 34091016ad83Smrg if $GREP -v "^: " < "$nlist" | 34101016ad83Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 34111016ad83Smrg sort -k 3 34121016ad83Smrg else 34131016ad83Smrg sort +2 34141016ad83Smrg fi | 34151016ad83Smrg uniq > "$nlist"S; then 34161016ad83Smrg : 34171016ad83Smrg else 34181016ad83Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 34191016ad83Smrg fi 34201016ad83Smrg 34211016ad83Smrg if test -f "$nlist"S; then 34221016ad83Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 34231016ad83Smrg else 34241016ad83Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 34251016ad83Smrg fi 34261016ad83Smrg 34271016ad83Smrg echo >> "$output_objdir/$my_dlsyms" "\ 34281016ad83Smrg 34291016ad83Smrg/* The mapping between symbol names and symbols. */ 34301016ad83Smrgtypedef struct { 34311016ad83Smrg const char *name; 34321016ad83Smrg void *address; 34331016ad83Smrg} lt_dlsymlist; 34341016ad83Smrgextern LT_DLSYM_CONST lt_dlsymlist 34351016ad83Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 34361016ad83SmrgLT_DLSYM_CONST lt_dlsymlist 34371016ad83Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 34381016ad83Smrg{\ 34391016ad83Smrg { \"$my_originator\", (void *) 0 }," 34401016ad83Smrg 34411016ad83Smrg case $need_lib_prefix in 34421016ad83Smrg no) 34431016ad83Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 34441016ad83Smrg ;; 34451016ad83Smrg *) 34461016ad83Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 34471016ad83Smrg ;; 34481016ad83Smrg esac 34491016ad83Smrg echo >> "$output_objdir/$my_dlsyms" "\ 34501016ad83Smrg {0, (void *) 0} 34511016ad83Smrg}; 34521016ad83Smrg 34531016ad83Smrg/* This works around a problem in FreeBSD linker */ 34541016ad83Smrg#ifdef FREEBSD_WORKAROUND 34551016ad83Smrgstatic const void *lt_preloaded_setup() { 34561016ad83Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 34571016ad83Smrg} 34581016ad83Smrg#endif 34591016ad83Smrg 34601016ad83Smrg#ifdef __cplusplus 34611016ad83Smrg} 34621016ad83Smrg#endif\ 34631016ad83Smrg" 34641016ad83Smrg } # !$opt_dry_run 34651016ad83Smrg 34661016ad83Smrg pic_flag_for_symtable= 34671016ad83Smrg case "$compile_command " in 34681016ad83Smrg *" -static "*) ;; 34691016ad83Smrg *) 34701016ad83Smrg case $host in 34711016ad83Smrg # compiling the symbol table file with pic_flag works around 34721016ad83Smrg # a FreeBSD bug that causes programs to crash when -lm is 34731016ad83Smrg # linked before any other PIC object. But we must not use 34741016ad83Smrg # pic_flag when linking with -static. The problem exists in 34751016ad83Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 34761016ad83Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 34771016ad83Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 34781016ad83Smrg *-*-hpux*) 34791016ad83Smrg pic_flag_for_symtable=" $pic_flag" ;; 34801016ad83Smrg *) 34811016ad83Smrg if test "X$my_pic_p" != Xno; then 34821016ad83Smrg pic_flag_for_symtable=" $pic_flag" 34831016ad83Smrg fi 34841016ad83Smrg ;; 34851016ad83Smrg esac 34861016ad83Smrg ;; 34871016ad83Smrg esac 34881016ad83Smrg symtab_cflags= 34891016ad83Smrg for arg in $LTCFLAGS; do 34901016ad83Smrg case $arg in 34911016ad83Smrg -pie | -fpie | -fPIE) ;; 34921016ad83Smrg *) func_append symtab_cflags " $arg" ;; 34931016ad83Smrg esac 34941016ad83Smrg done 34951016ad83Smrg 34961016ad83Smrg # Now compile the dynamic symbol file. 34971016ad83Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 34981016ad83Smrg 34991016ad83Smrg # Clean up the generated files. 35001016ad83Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 35011016ad83Smrg 35021016ad83Smrg # Transform the symbol file into the correct name. 35031016ad83Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 35041016ad83Smrg case $host in 35051016ad83Smrg *cygwin* | *mingw* | *cegcc* ) 35061016ad83Smrg if test -f "$output_objdir/$my_outputname.def"; then 35071016ad83Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 35081016ad83Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 35091016ad83Smrg else 35101016ad83Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35111016ad83Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35121016ad83Smrg fi 35131016ad83Smrg ;; 35141016ad83Smrg *) 35151016ad83Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35161016ad83Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35171016ad83Smrg ;; 35181016ad83Smrg esac 35191016ad83Smrg ;; 35201016ad83Smrg *) 35211016ad83Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 35221016ad83Smrg ;; 35231016ad83Smrg esac 35241016ad83Smrg else 35251016ad83Smrg # We keep going just in case the user didn't refer to 35261016ad83Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 35271016ad83Smrg # really was required. 35281016ad83Smrg 35291016ad83Smrg # Nullify the symbol file. 35301016ad83Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 35311016ad83Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 35321016ad83Smrg fi 35331016ad83Smrg} 35341016ad83Smrg 35351016ad83Smrg# func_win32_libid arg 35361016ad83Smrg# return the library type of file 'arg' 35371016ad83Smrg# 35381016ad83Smrg# Need a lot of goo to handle *both* DLLs and import libs 35391016ad83Smrg# Has to be a shell function in order to 'eat' the argument 35401016ad83Smrg# that is supplied when $file_magic_command is called. 35411016ad83Smrg# Despite the name, also deal with 64 bit binaries. 35421016ad83Smrgfunc_win32_libid () 35431016ad83Smrg{ 35441016ad83Smrg $opt_debug 35451016ad83Smrg win32_libid_type="unknown" 35461016ad83Smrg win32_fileres=`file -L $1 2>/dev/null` 35471016ad83Smrg case $win32_fileres in 35481016ad83Smrg *ar\ archive\ import\ library*) # definitely import 35491016ad83Smrg win32_libid_type="x86 archive import" 35501016ad83Smrg ;; 35511016ad83Smrg *ar\ archive*) # could be an import, or static 35521016ad83Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 35531016ad83Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 35541016ad83Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 35551016ad83Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 35561016ad83Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 35571016ad83Smrg $SED -n -e ' 35581016ad83Smrg 1,100{ 35591016ad83Smrg / I /{ 35601016ad83Smrg s,.*,import, 35611016ad83Smrg p 35621016ad83Smrg q 35631016ad83Smrg } 35641016ad83Smrg }'` 35651016ad83Smrg case $win32_nmres in 35661016ad83Smrg import*) win32_libid_type="x86 archive import";; 35671016ad83Smrg *) win32_libid_type="x86 archive static";; 35681016ad83Smrg esac 35691016ad83Smrg fi 35701016ad83Smrg ;; 35711016ad83Smrg *DLL*) 35721016ad83Smrg win32_libid_type="x86 DLL" 35731016ad83Smrg ;; 35741016ad83Smrg *executable*) # but shell scripts are "executable" too... 35751016ad83Smrg case $win32_fileres in 35761016ad83Smrg *MS\ Windows\ PE\ Intel*) 35771016ad83Smrg win32_libid_type="x86 DLL" 35781016ad83Smrg ;; 35791016ad83Smrg esac 35801016ad83Smrg ;; 35811016ad83Smrg esac 35821016ad83Smrg $ECHO "$win32_libid_type" 35831016ad83Smrg} 35841016ad83Smrg 35851016ad83Smrg# func_cygming_dll_for_implib ARG 35861016ad83Smrg# 35871016ad83Smrg# Platform-specific function to extract the 35881016ad83Smrg# name of the DLL associated with the specified 35891016ad83Smrg# import library ARG. 35901016ad83Smrg# Invoked by eval'ing the libtool variable 35911016ad83Smrg# $sharedlib_from_linklib_cmd 35921016ad83Smrg# Result is available in the variable 35931016ad83Smrg# $sharedlib_from_linklib_result 35941016ad83Smrgfunc_cygming_dll_for_implib () 35951016ad83Smrg{ 35961016ad83Smrg $opt_debug 35971016ad83Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 35981016ad83Smrg} 35991016ad83Smrg 36001016ad83Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 36011016ad83Smrg# 36021016ad83Smrg# The is the core of a fallback implementation of a 36031016ad83Smrg# platform-specific function to extract the name of the 36041016ad83Smrg# DLL associated with the specified import library LIBNAME. 36051016ad83Smrg# 36061016ad83Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 36071016ad83Smrg# on the platform and compiler that created the implib. 36081016ad83Smrg# 36091016ad83Smrg# Echos the name of the DLL associated with the 36101016ad83Smrg# specified import library. 36111016ad83Smrgfunc_cygming_dll_for_implib_fallback_core () 36121016ad83Smrg{ 36131016ad83Smrg $opt_debug 36141016ad83Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 36151016ad83Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 36161016ad83Smrg $SED '/^Contents of section '"$match_literal"':/{ 36171016ad83Smrg # Place marker at beginning of archive member dllname section 36181016ad83Smrg s/.*/====MARK====/ 36191016ad83Smrg p 36201016ad83Smrg d 36211016ad83Smrg } 36221016ad83Smrg # These lines can sometimes be longer than 43 characters, but 36231016ad83Smrg # are always uninteresting 36241016ad83Smrg /:[ ]*file format pe[i]\{,1\}-/d 36251016ad83Smrg /^In archive [^:]*:/d 36261016ad83Smrg # Ensure marker is printed 36271016ad83Smrg /^====MARK====/p 36281016ad83Smrg # Remove all lines with less than 43 characters 36291016ad83Smrg /^.\{43\}/!d 36301016ad83Smrg # From remaining lines, remove first 43 characters 36311016ad83Smrg s/^.\{43\}//' | 36321016ad83Smrg $SED -n ' 36331016ad83Smrg # Join marker and all lines until next marker into a single line 36341016ad83Smrg /^====MARK====/ b para 36351016ad83Smrg H 36361016ad83Smrg $ b para 36371016ad83Smrg b 36381016ad83Smrg :para 36391016ad83Smrg x 36401016ad83Smrg s/\n//g 36411016ad83Smrg # Remove the marker 36421016ad83Smrg s/^====MARK====// 36431016ad83Smrg # Remove trailing dots and whitespace 36441016ad83Smrg s/[\. \t]*$// 36451016ad83Smrg # Print 36461016ad83Smrg /./p' | 36471016ad83Smrg # we now have a list, one entry per line, of the stringified 36481016ad83Smrg # contents of the appropriate section of all members of the 36491016ad83Smrg # archive which possess that section. Heuristic: eliminate 36501016ad83Smrg # all those which have a first or second character that is 36511016ad83Smrg # a '.' (that is, objdump's representation of an unprintable 36521016ad83Smrg # character.) This should work for all archives with less than 36531016ad83Smrg # 0x302f exports -- but will fail for DLLs whose name actually 36541016ad83Smrg # begins with a literal '.' or a single character followed by 36551016ad83Smrg # a '.'. 36561016ad83Smrg # 36571016ad83Smrg # Of those that remain, print the first one. 36581016ad83Smrg $SED -e '/^\./d;/^.\./d;q' 36591016ad83Smrg} 36601016ad83Smrg 36611016ad83Smrg# func_cygming_gnu_implib_p ARG 36621016ad83Smrg# This predicate returns with zero status (TRUE) if 36631016ad83Smrg# ARG is a GNU/binutils-style import library. Returns 36641016ad83Smrg# with nonzero status (FALSE) otherwise. 36651016ad83Smrgfunc_cygming_gnu_implib_p () 36661016ad83Smrg{ 36671016ad83Smrg $opt_debug 36681016ad83Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 36691016ad83Smrg 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)$'` 36701016ad83Smrg test -n "$func_cygming_gnu_implib_tmp" 36711016ad83Smrg} 36721016ad83Smrg 36731016ad83Smrg# func_cygming_ms_implib_p ARG 36741016ad83Smrg# This predicate returns with zero status (TRUE) if 36751016ad83Smrg# ARG is an MS-style import library. Returns 36761016ad83Smrg# with nonzero status (FALSE) otherwise. 36771016ad83Smrgfunc_cygming_ms_implib_p () 36781016ad83Smrg{ 36791016ad83Smrg $opt_debug 36801016ad83Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 36811016ad83Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 36821016ad83Smrg test -n "$func_cygming_ms_implib_tmp" 36831016ad83Smrg} 36841016ad83Smrg 36851016ad83Smrg# func_cygming_dll_for_implib_fallback ARG 36861016ad83Smrg# Platform-specific function to extract the 36871016ad83Smrg# name of the DLL associated with the specified 36881016ad83Smrg# import library ARG. 36891016ad83Smrg# 36901016ad83Smrg# This fallback implementation is for use when $DLLTOOL 36911016ad83Smrg# does not support the --identify-strict option. 36921016ad83Smrg# Invoked by eval'ing the libtool variable 36931016ad83Smrg# $sharedlib_from_linklib_cmd 36941016ad83Smrg# Result is available in the variable 36951016ad83Smrg# $sharedlib_from_linklib_result 36961016ad83Smrgfunc_cygming_dll_for_implib_fallback () 36971016ad83Smrg{ 36981016ad83Smrg $opt_debug 36991016ad83Smrg if func_cygming_gnu_implib_p "$1" ; then 37001016ad83Smrg # binutils import library 37011016ad83Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 37021016ad83Smrg elif func_cygming_ms_implib_p "$1" ; then 37031016ad83Smrg # ms-generated import library 37041016ad83Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 37051016ad83Smrg else 37061016ad83Smrg # unknown 37071016ad83Smrg sharedlib_from_linklib_result="" 37081016ad83Smrg fi 37091016ad83Smrg} 37101016ad83Smrg 37111016ad83Smrg 37121016ad83Smrg# func_extract_an_archive dir oldlib 37131016ad83Smrgfunc_extract_an_archive () 37141016ad83Smrg{ 37151016ad83Smrg $opt_debug 37161016ad83Smrg f_ex_an_ar_dir="$1"; shift 37171016ad83Smrg f_ex_an_ar_oldlib="$1" 37181016ad83Smrg if test "$lock_old_archive_extraction" = yes; then 37191016ad83Smrg lockfile=$f_ex_an_ar_oldlib.lock 37201016ad83Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 37211016ad83Smrg func_echo "Waiting for $lockfile to be removed" 37221016ad83Smrg sleep 2 37231016ad83Smrg done 37241016ad83Smrg fi 37251016ad83Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 37261016ad83Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 37271016ad83Smrg if test "$lock_old_archive_extraction" = yes; then 37281016ad83Smrg $opt_dry_run || rm -f "$lockfile" 37291016ad83Smrg fi 37301016ad83Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 37311016ad83Smrg : 37321016ad83Smrg else 37331016ad83Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 37341016ad83Smrg fi 37351016ad83Smrg} 37361016ad83Smrg 37371016ad83Smrg 37381016ad83Smrg# func_extract_archives gentop oldlib ... 37391016ad83Smrgfunc_extract_archives () 37401016ad83Smrg{ 37411016ad83Smrg $opt_debug 37421016ad83Smrg my_gentop="$1"; shift 37431016ad83Smrg my_oldlibs=${1+"$@"} 37441016ad83Smrg my_oldobjs="" 37451016ad83Smrg my_xlib="" 37461016ad83Smrg my_xabs="" 37471016ad83Smrg my_xdir="" 37481016ad83Smrg 37491016ad83Smrg for my_xlib in $my_oldlibs; do 37501016ad83Smrg # Extract the objects. 37511016ad83Smrg case $my_xlib in 37521016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 37531016ad83Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 37541016ad83Smrg esac 37551016ad83Smrg func_basename "$my_xlib" 37561016ad83Smrg my_xlib="$func_basename_result" 37571016ad83Smrg my_xlib_u=$my_xlib 37581016ad83Smrg while :; do 37591016ad83Smrg case " $extracted_archives " in 37601016ad83Smrg *" $my_xlib_u "*) 37611016ad83Smrg func_arith $extracted_serial + 1 37621016ad83Smrg extracted_serial=$func_arith_result 37631016ad83Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 37641016ad83Smrg *) break ;; 37651016ad83Smrg esac 37661016ad83Smrg done 37671016ad83Smrg extracted_archives="$extracted_archives $my_xlib_u" 37681016ad83Smrg my_xdir="$my_gentop/$my_xlib_u" 37691016ad83Smrg 37701016ad83Smrg func_mkdir_p "$my_xdir" 37711016ad83Smrg 37721016ad83Smrg case $host in 37731016ad83Smrg *-darwin*) 37741016ad83Smrg func_verbose "Extracting $my_xabs" 37751016ad83Smrg # Do not bother doing anything if just a dry run 37761016ad83Smrg $opt_dry_run || { 37771016ad83Smrg darwin_orig_dir=`pwd` 37781016ad83Smrg cd $my_xdir || exit $? 37791016ad83Smrg darwin_archive=$my_xabs 37801016ad83Smrg darwin_curdir=`pwd` 37811016ad83Smrg darwin_base_archive=`basename "$darwin_archive"` 37821016ad83Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 37831016ad83Smrg if test -n "$darwin_arches"; then 37841016ad83Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 37851016ad83Smrg darwin_arch= 37861016ad83Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 37871016ad83Smrg for darwin_arch in $darwin_arches ; do 37881016ad83Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 37891016ad83Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 37901016ad83Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 37911016ad83Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 37921016ad83Smrg cd "$darwin_curdir" 37931016ad83Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 37941016ad83Smrg done # $darwin_arches 37951016ad83Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 37961016ad83Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 37971016ad83Smrg darwin_file= 37981016ad83Smrg darwin_files= 37991016ad83Smrg for darwin_file in $darwin_filelist; do 38001016ad83Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 38011016ad83Smrg $LIPO -create -output "$darwin_file" $darwin_files 38021016ad83Smrg done # $darwin_filelist 38031016ad83Smrg $RM -rf unfat-$$ 38041016ad83Smrg cd "$darwin_orig_dir" 38051016ad83Smrg else 38061016ad83Smrg cd $darwin_orig_dir 38071016ad83Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 38081016ad83Smrg fi # $darwin_arches 38091016ad83Smrg } # !$opt_dry_run 38101016ad83Smrg ;; 38111016ad83Smrg *) 38121016ad83Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 38131016ad83Smrg ;; 38141016ad83Smrg esac 38151016ad83Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 38161016ad83Smrg done 38171016ad83Smrg 38181016ad83Smrg func_extract_archives_result="$my_oldobjs" 38191016ad83Smrg} 38201016ad83Smrg 38211016ad83Smrg 38221016ad83Smrg# func_emit_wrapper [arg=no] 38231016ad83Smrg# 38241016ad83Smrg# Emit a libtool wrapper script on stdout. 38251016ad83Smrg# Don't directly open a file because we may want to 38261016ad83Smrg# incorporate the script contents within a cygwin/mingw 38271016ad83Smrg# wrapper executable. Must ONLY be called from within 38281016ad83Smrg# func_mode_link because it depends on a number of variables 38291016ad83Smrg# set therein. 38301016ad83Smrg# 38311016ad83Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 38321016ad83Smrg# variable will take. If 'yes', then the emitted script 38331016ad83Smrg# will assume that the directory in which it is stored is 38341016ad83Smrg# the $objdir directory. This is a cygwin/mingw-specific 38351016ad83Smrg# behavior. 38361016ad83Smrgfunc_emit_wrapper () 38371016ad83Smrg{ 38381016ad83Smrg func_emit_wrapper_arg1=${1-no} 38391016ad83Smrg 38401016ad83Smrg $ECHO "\ 38411016ad83Smrg#! $SHELL 38421016ad83Smrg 38431016ad83Smrg# $output - temporary wrapper script for $objdir/$outputname 38441016ad83Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 38451016ad83Smrg# 38461016ad83Smrg# The $output program cannot be directly executed until all the libtool 38471016ad83Smrg# libraries that it depends on are installed. 38481016ad83Smrg# 38491016ad83Smrg# This wrapper script should never be moved out of the build directory. 38501016ad83Smrg# If it is, it will not operate correctly. 38511016ad83Smrg 38521016ad83Smrg# Sed substitution that helps us do robust quoting. It backslashifies 38531016ad83Smrg# metacharacters that are still active within double-quoted strings. 38541016ad83Smrgsed_quote_subst='$sed_quote_subst' 38551016ad83Smrg 38561016ad83Smrg# Be Bourne compatible 38571016ad83Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 38581016ad83Smrg emulate sh 38591016ad83Smrg NULLCMD=: 38601016ad83Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 38611016ad83Smrg # is contrary to our usage. Disable this feature. 38621016ad83Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 38631016ad83Smrg setopt NO_GLOB_SUBST 38641016ad83Smrgelse 38651016ad83Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 38661016ad83Smrgfi 38671016ad83SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 38681016ad83SmrgDUALCASE=1; export DUALCASE # for MKS sh 38691016ad83Smrg 38701016ad83Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 38711016ad83Smrg# if CDPATH is set. 38721016ad83Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 38731016ad83Smrg 38741016ad83Smrgrelink_command=\"$relink_command\" 38751016ad83Smrg 38761016ad83Smrg# This environment variable determines our operation mode. 38771016ad83Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 38781016ad83Smrg # install mode needs the following variables: 38791016ad83Smrg generated_by_libtool_version='$macro_version' 38801016ad83Smrg notinst_deplibs='$notinst_deplibs' 38811016ad83Smrgelse 38821016ad83Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 38831016ad83Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 38841016ad83Smrg file=\"\$0\"" 38851016ad83Smrg 38861016ad83Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 38871016ad83Smrg $ECHO "\ 38881016ad83Smrg 38891016ad83Smrg# A function that is used when there is no print builtin or printf. 38901016ad83Smrgfunc_fallback_echo () 38911016ad83Smrg{ 38921016ad83Smrg eval 'cat <<_LTECHO_EOF 38931016ad83Smrg\$1 38941016ad83Smrg_LTECHO_EOF' 38951016ad83Smrg} 38961016ad83Smrg ECHO=\"$qECHO\" 38971016ad83Smrg fi 38981016ad83Smrg 38991016ad83Smrg# Very basic option parsing. These options are (a) specific to 39001016ad83Smrg# the libtool wrapper, (b) are identical between the wrapper 39011016ad83Smrg# /script/ and the wrapper /executable/ which is used only on 39021016ad83Smrg# windows platforms, and (c) all begin with the string "--lt-" 39031016ad83Smrg# (application programs are unlikely to have options which match 39041016ad83Smrg# this pattern). 39051016ad83Smrg# 39061016ad83Smrg# There are only two supported options: --lt-debug and 39071016ad83Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 39081016ad83Smrg# 39091016ad83Smrg# The first argument to this parsing function should be the 39101016ad83Smrg# script's $0 value, followed by "$@". 39111016ad83Smrglt_option_debug= 39121016ad83Smrgfunc_parse_lt_options () 39131016ad83Smrg{ 39141016ad83Smrg lt_script_arg0=\$0 39151016ad83Smrg shift 39161016ad83Smrg for lt_opt 39171016ad83Smrg do 39181016ad83Smrg case \"\$lt_opt\" in 39191016ad83Smrg --lt-debug) lt_option_debug=1 ;; 39201016ad83Smrg --lt-dump-script) 39211016ad83Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 39221016ad83Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 39231016ad83Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 39241016ad83Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 39251016ad83Smrg exit 0 39261016ad83Smrg ;; 39271016ad83Smrg --lt-*) 39281016ad83Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 39291016ad83Smrg exit 1 39301016ad83Smrg ;; 39311016ad83Smrg esac 39321016ad83Smrg done 39331016ad83Smrg 39341016ad83Smrg # Print the debug banner immediately: 39351016ad83Smrg if test -n \"\$lt_option_debug\"; then 39361016ad83Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 39371016ad83Smrg fi 39381016ad83Smrg} 39391016ad83Smrg 39401016ad83Smrg# Used when --lt-debug. Prints its arguments to stdout 39411016ad83Smrg# (redirection is the responsibility of the caller) 39421016ad83Smrgfunc_lt_dump_args () 39431016ad83Smrg{ 39441016ad83Smrg lt_dump_args_N=1; 39451016ad83Smrg for lt_arg 39461016ad83Smrg do 39471016ad83Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 39481016ad83Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 39491016ad83Smrg done 39501016ad83Smrg} 39511016ad83Smrg 39521016ad83Smrg# Core function for launching the target application 39531016ad83Smrgfunc_exec_program_core () 39541016ad83Smrg{ 39551016ad83Smrg" 39561016ad83Smrg case $host in 39571016ad83Smrg # Backslashes separate directories on plain windows 39581016ad83Smrg *-*-mingw | *-*-os2* | *-cegcc*) 39591016ad83Smrg $ECHO "\ 39601016ad83Smrg if test -n \"\$lt_option_debug\"; then 39611016ad83Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 39621016ad83Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 39631016ad83Smrg fi 39641016ad83Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 39651016ad83Smrg" 39661016ad83Smrg ;; 39671016ad83Smrg 39681016ad83Smrg *) 39691016ad83Smrg $ECHO "\ 39701016ad83Smrg if test -n \"\$lt_option_debug\"; then 39711016ad83Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 39721016ad83Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 39731016ad83Smrg fi 39741016ad83Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 39751016ad83Smrg" 39761016ad83Smrg ;; 39771016ad83Smrg esac 39781016ad83Smrg $ECHO "\ 39791016ad83Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 39801016ad83Smrg exit 1 39811016ad83Smrg} 39821016ad83Smrg 39831016ad83Smrg# A function to encapsulate launching the target application 39841016ad83Smrg# Strips options in the --lt-* namespace from \$@ and 39851016ad83Smrg# launches target application with the remaining arguments. 39861016ad83Smrgfunc_exec_program () 39871016ad83Smrg{ 39881016ad83Smrg case \" \$* \" in 39891016ad83Smrg *\\ --lt-*) 39901016ad83Smrg for lt_wr_arg 39911016ad83Smrg do 39921016ad83Smrg case \$lt_wr_arg in 39931016ad83Smrg --lt-*) ;; 39941016ad83Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 39951016ad83Smrg esac 39961016ad83Smrg shift 39971016ad83Smrg done ;; 39981016ad83Smrg esac 39991016ad83Smrg func_exec_program_core \${1+\"\$@\"} 40001016ad83Smrg} 40011016ad83Smrg 40021016ad83Smrg # Parse options 40031016ad83Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 40041016ad83Smrg 40051016ad83Smrg # Find the directory that this script lives in. 40061016ad83Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 40071016ad83Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 40081016ad83Smrg 40091016ad83Smrg # Follow symbolic links until we get to the real thisdir. 40101016ad83Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 40111016ad83Smrg while test -n \"\$file\"; do 40121016ad83Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 40131016ad83Smrg 40141016ad83Smrg # If there was a directory component, then change thisdir. 40151016ad83Smrg if test \"x\$destdir\" != \"x\$file\"; then 40161016ad83Smrg case \"\$destdir\" in 40171016ad83Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 40181016ad83Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 40191016ad83Smrg esac 40201016ad83Smrg fi 40211016ad83Smrg 40221016ad83Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 40231016ad83Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 40241016ad83Smrg done 40251016ad83Smrg 40261016ad83Smrg # Usually 'no', except on cygwin/mingw when embedded into 40271016ad83Smrg # the cwrapper. 40281016ad83Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 40291016ad83Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 40301016ad83Smrg # special case for '.' 40311016ad83Smrg if test \"\$thisdir\" = \".\"; then 40321016ad83Smrg thisdir=\`pwd\` 40331016ad83Smrg fi 40341016ad83Smrg # remove .libs from thisdir 40351016ad83Smrg case \"\$thisdir\" in 40361016ad83Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 40371016ad83Smrg $objdir ) thisdir=. ;; 40381016ad83Smrg esac 40391016ad83Smrg fi 40401016ad83Smrg 40411016ad83Smrg # Try to get the absolute directory name. 40421016ad83Smrg absdir=\`cd \"\$thisdir\" && pwd\` 40431016ad83Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 40441016ad83Smrg" 40451016ad83Smrg 40461016ad83Smrg if test "$fast_install" = yes; then 40471016ad83Smrg $ECHO "\ 40481016ad83Smrg program=lt-'$outputname'$exeext 40491016ad83Smrg progdir=\"\$thisdir/$objdir\" 40501016ad83Smrg 40511016ad83Smrg if test ! -f \"\$progdir/\$program\" || 40521016ad83Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 40531016ad83Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 40541016ad83Smrg 40551016ad83Smrg file=\"\$\$-\$program\" 40561016ad83Smrg 40571016ad83Smrg if test ! -d \"\$progdir\"; then 40581016ad83Smrg $MKDIR \"\$progdir\" 40591016ad83Smrg else 40601016ad83Smrg $RM \"\$progdir/\$file\" 40611016ad83Smrg fi" 40621016ad83Smrg 40631016ad83Smrg $ECHO "\ 40641016ad83Smrg 40651016ad83Smrg # relink executable if necessary 40661016ad83Smrg if test -n \"\$relink_command\"; then 40671016ad83Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 40681016ad83Smrg else 40691016ad83Smrg $ECHO \"\$relink_command_output\" >&2 40701016ad83Smrg $RM \"\$progdir/\$file\" 40711016ad83Smrg exit 1 40721016ad83Smrg fi 40731016ad83Smrg fi 40741016ad83Smrg 40751016ad83Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 40761016ad83Smrg { $RM \"\$progdir/\$program\"; 40771016ad83Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 40781016ad83Smrg $RM \"\$progdir/\$file\" 40791016ad83Smrg fi" 40801016ad83Smrg else 40811016ad83Smrg $ECHO "\ 40821016ad83Smrg program='$outputname' 40831016ad83Smrg progdir=\"\$thisdir/$objdir\" 40841016ad83Smrg" 40851016ad83Smrg fi 40861016ad83Smrg 40871016ad83Smrg $ECHO "\ 40881016ad83Smrg 40891016ad83Smrg if test -f \"\$progdir/\$program\"; then" 40901016ad83Smrg 40911016ad83Smrg # fixup the dll searchpath if we need to. 40921016ad83Smrg # 40931016ad83Smrg # Fix the DLL searchpath if we need to. Do this before prepending 40941016ad83Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 40951016ad83Smrg # libraries must come first. 40961016ad83Smrg if test -n "$dllsearchpath"; then 40971016ad83Smrg $ECHO "\ 40981016ad83Smrg # Add the dll search path components to the executable PATH 40991016ad83Smrg PATH=$dllsearchpath:\$PATH 41001016ad83Smrg" 41011016ad83Smrg fi 41021016ad83Smrg 41031016ad83Smrg # Export our shlibpath_var if we have one. 41041016ad83Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 41051016ad83Smrg $ECHO "\ 41061016ad83Smrg # Add our own library path to $shlibpath_var 41071016ad83Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 41081016ad83Smrg 41091016ad83Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 41101016ad83Smrg # The second colon is a workaround for a bug in BeOS R4 sed 41111016ad83Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 41121016ad83Smrg 41131016ad83Smrg export $shlibpath_var 41141016ad83Smrg" 41151016ad83Smrg fi 41161016ad83Smrg 41171016ad83Smrg $ECHO "\ 41181016ad83Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 41191016ad83Smrg # Run the actual program with our arguments. 41201016ad83Smrg func_exec_program \${1+\"\$@\"} 41211016ad83Smrg fi 41221016ad83Smrg else 41231016ad83Smrg # The program doesn't exist. 41241016ad83Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 41251016ad83Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 41261016ad83Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 41271016ad83Smrg exit 1 41281016ad83Smrg fi 41291016ad83Smrgfi\ 41301016ad83Smrg" 41311016ad83Smrg} 41321016ad83Smrg 41331016ad83Smrg 41341016ad83Smrg# func_emit_cwrapperexe_src 41351016ad83Smrg# emit the source code for a wrapper executable on stdout 41361016ad83Smrg# Must ONLY be called from within func_mode_link because 41371016ad83Smrg# it depends on a number of variable set therein. 41381016ad83Smrgfunc_emit_cwrapperexe_src () 41391016ad83Smrg{ 41401016ad83Smrg cat <<EOF 41411016ad83Smrg 41421016ad83Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 41431016ad83Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 41441016ad83Smrg 41451016ad83Smrg The $output program cannot be directly executed until all the libtool 41461016ad83Smrg libraries that it depends on are installed. 41471016ad83Smrg 41481016ad83Smrg This wrapper executable should never be moved out of the build directory. 41491016ad83Smrg If it is, it will not operate correctly. 41501016ad83Smrg*/ 41511016ad83SmrgEOF 41521016ad83Smrg cat <<"EOF" 41531016ad83Smrg#ifdef _MSC_VER 41541016ad83Smrg# define _CRT_SECURE_NO_DEPRECATE 1 41551016ad83Smrg#endif 41561016ad83Smrg#include <stdio.h> 41571016ad83Smrg#include <stdlib.h> 41581016ad83Smrg#ifdef _MSC_VER 41591016ad83Smrg# include <direct.h> 41601016ad83Smrg# include <process.h> 41611016ad83Smrg# include <io.h> 41621016ad83Smrg#else 41631016ad83Smrg# include <unistd.h> 41641016ad83Smrg# include <stdint.h> 41651016ad83Smrg# ifdef __CYGWIN__ 41661016ad83Smrg# include <io.h> 41671016ad83Smrg# endif 41681016ad83Smrg#endif 41691016ad83Smrg#include <malloc.h> 41701016ad83Smrg#include <stdarg.h> 41711016ad83Smrg#include <assert.h> 41721016ad83Smrg#include <string.h> 41731016ad83Smrg#include <ctype.h> 41741016ad83Smrg#include <errno.h> 41751016ad83Smrg#include <fcntl.h> 41761016ad83Smrg#include <sys/stat.h> 41771016ad83Smrg 41781016ad83Smrg/* declarations of non-ANSI functions */ 41791016ad83Smrg#if defined(__MINGW32__) 41801016ad83Smrg# ifdef __STRICT_ANSI__ 41811016ad83Smrgint _putenv (const char *); 41821016ad83Smrg# endif 41831016ad83Smrg#elif defined(__CYGWIN__) 41841016ad83Smrg# ifdef __STRICT_ANSI__ 41851016ad83Smrgchar *realpath (const char *, char *); 41861016ad83Smrgint putenv (char *); 41871016ad83Smrgint setenv (const char *, const char *, int); 41881016ad83Smrg# endif 41891016ad83Smrg/* #elif defined (other platforms) ... */ 41901016ad83Smrg#endif 41911016ad83Smrg 41921016ad83Smrg/* portability defines, excluding path handling macros */ 41931016ad83Smrg#if defined(_MSC_VER) 41941016ad83Smrg# define setmode _setmode 41951016ad83Smrg# define stat _stat 41961016ad83Smrg# define chmod _chmod 41971016ad83Smrg# define getcwd _getcwd 41981016ad83Smrg# define putenv _putenv 41991016ad83Smrg# define S_IXUSR _S_IEXEC 42001016ad83Smrg# ifndef _INTPTR_T_DEFINED 42011016ad83Smrg# define _INTPTR_T_DEFINED 42021016ad83Smrg# define intptr_t int 42031016ad83Smrg# endif 42041016ad83Smrg#elif defined(__MINGW32__) 42051016ad83Smrg# define setmode _setmode 42061016ad83Smrg# define stat _stat 42071016ad83Smrg# define chmod _chmod 42081016ad83Smrg# define getcwd _getcwd 42091016ad83Smrg# define putenv _putenv 42101016ad83Smrg#elif defined(__CYGWIN__) 42111016ad83Smrg# define HAVE_SETENV 42121016ad83Smrg# define FOPEN_WB "wb" 42131016ad83Smrg/* #elif defined (other platforms) ... */ 42141016ad83Smrg#endif 42151016ad83Smrg 42161016ad83Smrg#if defined(PATH_MAX) 42171016ad83Smrg# define LT_PATHMAX PATH_MAX 42181016ad83Smrg#elif defined(MAXPATHLEN) 42191016ad83Smrg# define LT_PATHMAX MAXPATHLEN 42201016ad83Smrg#else 42211016ad83Smrg# define LT_PATHMAX 1024 42221016ad83Smrg#endif 42231016ad83Smrg 42241016ad83Smrg#ifndef S_IXOTH 42251016ad83Smrg# define S_IXOTH 0 42261016ad83Smrg#endif 42271016ad83Smrg#ifndef S_IXGRP 42281016ad83Smrg# define S_IXGRP 0 42291016ad83Smrg#endif 42301016ad83Smrg 42311016ad83Smrg/* path handling portability macros */ 42321016ad83Smrg#ifndef DIR_SEPARATOR 42331016ad83Smrg# define DIR_SEPARATOR '/' 42341016ad83Smrg# define PATH_SEPARATOR ':' 42351016ad83Smrg#endif 42361016ad83Smrg 42371016ad83Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 42381016ad83Smrg defined (__OS2__) 42391016ad83Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 42401016ad83Smrg# define FOPEN_WB "wb" 42411016ad83Smrg# ifndef DIR_SEPARATOR_2 42421016ad83Smrg# define DIR_SEPARATOR_2 '\\' 42431016ad83Smrg# endif 42441016ad83Smrg# ifndef PATH_SEPARATOR_2 42451016ad83Smrg# define PATH_SEPARATOR_2 ';' 42461016ad83Smrg# endif 42471016ad83Smrg#endif 42481016ad83Smrg 42491016ad83Smrg#ifndef DIR_SEPARATOR_2 42501016ad83Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 42511016ad83Smrg#else /* DIR_SEPARATOR_2 */ 42521016ad83Smrg# define IS_DIR_SEPARATOR(ch) \ 42531016ad83Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 42541016ad83Smrg#endif /* DIR_SEPARATOR_2 */ 42551016ad83Smrg 42561016ad83Smrg#ifndef PATH_SEPARATOR_2 42571016ad83Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 42581016ad83Smrg#else /* PATH_SEPARATOR_2 */ 42591016ad83Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 42601016ad83Smrg#endif /* PATH_SEPARATOR_2 */ 42611016ad83Smrg 42621016ad83Smrg#ifndef FOPEN_WB 42631016ad83Smrg# define FOPEN_WB "w" 42641016ad83Smrg#endif 42651016ad83Smrg#ifndef _O_BINARY 42661016ad83Smrg# define _O_BINARY 0 42671016ad83Smrg#endif 42681016ad83Smrg 42691016ad83Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 42701016ad83Smrg#define XFREE(stale) do { \ 42711016ad83Smrg if (stale) { free ((void *) stale); stale = 0; } \ 42721016ad83Smrg} while (0) 42731016ad83Smrg 42741016ad83Smrg#if defined(LT_DEBUGWRAPPER) 42751016ad83Smrgstatic int lt_debug = 1; 42761016ad83Smrg#else 42771016ad83Smrgstatic int lt_debug = 0; 42781016ad83Smrg#endif 42791016ad83Smrg 42801016ad83Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 42811016ad83Smrg 42821016ad83Smrgvoid *xmalloc (size_t num); 42831016ad83Smrgchar *xstrdup (const char *string); 42841016ad83Smrgconst char *base_name (const char *name); 42851016ad83Smrgchar *find_executable (const char *wrapper); 42861016ad83Smrgchar *chase_symlinks (const char *pathspec); 42871016ad83Smrgint make_executable (const char *path); 42881016ad83Smrgint check_executable (const char *path); 42891016ad83Smrgchar *strendzap (char *str, const char *pat); 42901016ad83Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 42911016ad83Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 42921016ad83Smrgstatic const char *nonnull (const char *s); 42931016ad83Smrgstatic const char *nonempty (const char *s); 42941016ad83Smrgvoid lt_setenv (const char *name, const char *value); 42951016ad83Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 42961016ad83Smrgvoid lt_update_exe_path (const char *name, const char *value); 42971016ad83Smrgvoid lt_update_lib_path (const char *name, const char *value); 42981016ad83Smrgchar **prepare_spawn (char **argv); 42991016ad83Smrgvoid lt_dump_script (FILE *f); 43001016ad83SmrgEOF 43011016ad83Smrg 43021016ad83Smrg cat <<EOF 43031016ad83Smrgvolatile const char * MAGIC_EXE = "$magic_exe"; 43041016ad83Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 43051016ad83SmrgEOF 43061016ad83Smrg 43071016ad83Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 43081016ad83Smrg func_to_host_path "$temp_rpath" 43091016ad83Smrg cat <<EOF 43101016ad83Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 43111016ad83SmrgEOF 43121016ad83Smrg else 43131016ad83Smrg cat <<"EOF" 43141016ad83Smrgconst char * LIB_PATH_VALUE = ""; 43151016ad83SmrgEOF 43161016ad83Smrg fi 43171016ad83Smrg 43181016ad83Smrg if test -n "$dllsearchpath"; then 43191016ad83Smrg func_to_host_path "$dllsearchpath:" 43201016ad83Smrg cat <<EOF 43211016ad83Smrgconst char * EXE_PATH_VARNAME = "PATH"; 43221016ad83Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 43231016ad83SmrgEOF 43241016ad83Smrg else 43251016ad83Smrg cat <<"EOF" 43261016ad83Smrgconst char * EXE_PATH_VARNAME = ""; 43271016ad83Smrgconst char * EXE_PATH_VALUE = ""; 43281016ad83SmrgEOF 43291016ad83Smrg fi 43301016ad83Smrg 43311016ad83Smrg if test "$fast_install" = yes; then 43321016ad83Smrg cat <<EOF 43331016ad83Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 43341016ad83SmrgEOF 43351016ad83Smrg else 43361016ad83Smrg cat <<EOF 43371016ad83Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 43381016ad83SmrgEOF 43391016ad83Smrg fi 43401016ad83Smrg 43411016ad83Smrg 43421016ad83Smrg cat <<"EOF" 43431016ad83Smrg 43441016ad83Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 43451016ad83Smrg 43461016ad83Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 43471016ad83Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 43481016ad83Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 43491016ad83Smrg 43501016ad83Smrgint 43511016ad83Smrgmain (int argc, char *argv[]) 43521016ad83Smrg{ 43531016ad83Smrg char **newargz; 43541016ad83Smrg int newargc; 43551016ad83Smrg char *tmp_pathspec; 43561016ad83Smrg char *actual_cwrapper_path; 43571016ad83Smrg char *actual_cwrapper_name; 43581016ad83Smrg char *target_name; 43591016ad83Smrg char *lt_argv_zero; 43601016ad83Smrg intptr_t rval = 127; 43611016ad83Smrg 43621016ad83Smrg int i; 43631016ad83Smrg 43641016ad83Smrg program_name = (char *) xstrdup (base_name (argv[0])); 43651016ad83Smrg newargz = XMALLOC (char *, argc + 1); 43661016ad83Smrg 43671016ad83Smrg /* very simple arg parsing; don't want to rely on getopt 43681016ad83Smrg * also, copy all non cwrapper options to newargz, except 43691016ad83Smrg * argz[0], which is handled differently 43701016ad83Smrg */ 43711016ad83Smrg newargc=0; 43721016ad83Smrg for (i = 1; i < argc; i++) 43731016ad83Smrg { 43741016ad83Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 43751016ad83Smrg { 43761016ad83SmrgEOF 43771016ad83Smrg case "$host" in 43781016ad83Smrg *mingw* | *cygwin* ) 43791016ad83Smrg # make stdout use "unix" line endings 43801016ad83Smrg echo " setmode(1,_O_BINARY);" 43811016ad83Smrg ;; 43821016ad83Smrg esac 43831016ad83Smrg 43841016ad83Smrg cat <<"EOF" 43851016ad83Smrg lt_dump_script (stdout); 43861016ad83Smrg return 0; 43871016ad83Smrg } 43881016ad83Smrg if (strcmp (argv[i], debug_opt) == 0) 43891016ad83Smrg { 43901016ad83Smrg lt_debug = 1; 43911016ad83Smrg continue; 43921016ad83Smrg } 43931016ad83Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 43941016ad83Smrg { 43951016ad83Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 43961016ad83Smrg namespace, but it is not one of the ones we know about and 43971016ad83Smrg have already dealt with, above (inluding dump-script), then 43981016ad83Smrg report an error. Otherwise, targets might begin to believe 43991016ad83Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 44001016ad83Smrg namespace. The first time any user complains about this, we'll 44011016ad83Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 44021016ad83Smrg or a configure.ac-settable value. 44031016ad83Smrg */ 44041016ad83Smrg lt_fatal (__FILE__, __LINE__, 44051016ad83Smrg "unrecognized %s option: '%s'", 44061016ad83Smrg ltwrapper_option_prefix, argv[i]); 44071016ad83Smrg } 44081016ad83Smrg /* otherwise ... */ 44091016ad83Smrg newargz[++newargc] = xstrdup (argv[i]); 44101016ad83Smrg } 44111016ad83Smrg newargz[++newargc] = NULL; 44121016ad83Smrg 44131016ad83SmrgEOF 44141016ad83Smrg cat <<EOF 44151016ad83Smrg /* The GNU banner must be the first non-error debug message */ 44161016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 44171016ad83SmrgEOF 44181016ad83Smrg cat <<"EOF" 44191016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 44201016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 44211016ad83Smrg 44221016ad83Smrg tmp_pathspec = find_executable (argv[0]); 44231016ad83Smrg if (tmp_pathspec == NULL) 44241016ad83Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 44251016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 44261016ad83Smrg "(main) found exe (before symlink chase) at: %s\n", 44271016ad83Smrg tmp_pathspec); 44281016ad83Smrg 44291016ad83Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 44301016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 44311016ad83Smrg "(main) found exe (after symlink chase) at: %s\n", 44321016ad83Smrg actual_cwrapper_path); 44331016ad83Smrg XFREE (tmp_pathspec); 44341016ad83Smrg 44351016ad83Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 44361016ad83Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 44371016ad83Smrg 44381016ad83Smrg /* wrapper name transforms */ 44391016ad83Smrg strendzap (actual_cwrapper_name, ".exe"); 44401016ad83Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 44411016ad83Smrg XFREE (actual_cwrapper_name); 44421016ad83Smrg actual_cwrapper_name = tmp_pathspec; 44431016ad83Smrg tmp_pathspec = 0; 44441016ad83Smrg 44451016ad83Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 44461016ad83Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 44471016ad83Smrg strendzap (target_name, ".exe"); 44481016ad83Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 44491016ad83Smrg XFREE (target_name); 44501016ad83Smrg target_name = tmp_pathspec; 44511016ad83Smrg tmp_pathspec = 0; 44521016ad83Smrg 44531016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 44541016ad83Smrg "(main) libtool target name: %s\n", 44551016ad83Smrg target_name); 44561016ad83SmrgEOF 44571016ad83Smrg 44581016ad83Smrg cat <<EOF 44591016ad83Smrg newargz[0] = 44601016ad83Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 44611016ad83Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 44621016ad83Smrg strcpy (newargz[0], actual_cwrapper_path); 44631016ad83Smrg strcat (newargz[0], "$objdir"); 44641016ad83Smrg strcat (newargz[0], "/"); 44651016ad83SmrgEOF 44661016ad83Smrg 44671016ad83Smrg cat <<"EOF" 44681016ad83Smrg /* stop here, and copy so we don't have to do this twice */ 44691016ad83Smrg tmp_pathspec = xstrdup (newargz[0]); 44701016ad83Smrg 44711016ad83Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 44721016ad83Smrg strcat (newargz[0], actual_cwrapper_name); 44731016ad83Smrg 44741016ad83Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 44751016ad83Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 44761016ad83Smrg XFREE (tmp_pathspec); 44771016ad83Smrg tmp_pathspec = NULL; 44781016ad83SmrgEOF 44791016ad83Smrg 44801016ad83Smrg case $host_os in 44811016ad83Smrg mingw*) 44821016ad83Smrg cat <<"EOF" 44831016ad83Smrg { 44841016ad83Smrg char* p; 44851016ad83Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 44861016ad83Smrg { 44871016ad83Smrg *p = '/'; 44881016ad83Smrg } 44891016ad83Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 44901016ad83Smrg { 44911016ad83Smrg *p = '/'; 44921016ad83Smrg } 44931016ad83Smrg } 44941016ad83SmrgEOF 44951016ad83Smrg ;; 44961016ad83Smrg esac 44971016ad83Smrg 44981016ad83Smrg cat <<"EOF" 44991016ad83Smrg XFREE (target_name); 45001016ad83Smrg XFREE (actual_cwrapper_path); 45011016ad83Smrg XFREE (actual_cwrapper_name); 45021016ad83Smrg 45031016ad83Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 45041016ad83Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 45051016ad83Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 45061016ad83Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 45071016ad83Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 45081016ad83Smrg libraries must come first. */ 45091016ad83Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 45101016ad83Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 45111016ad83Smrg 45121016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 45131016ad83Smrg nonnull (lt_argv_zero)); 45141016ad83Smrg for (i = 0; i < newargc; i++) 45151016ad83Smrg { 45161016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 45171016ad83Smrg i, nonnull (newargz[i])); 45181016ad83Smrg } 45191016ad83Smrg 45201016ad83SmrgEOF 45211016ad83Smrg 45221016ad83Smrg case $host_os in 45231016ad83Smrg mingw*) 45241016ad83Smrg cat <<"EOF" 45251016ad83Smrg /* execv doesn't actually work on mingw as expected on unix */ 45261016ad83Smrg newargz = prepare_spawn (newargz); 45271016ad83Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 45281016ad83Smrg if (rval == -1) 45291016ad83Smrg { 45301016ad83Smrg /* failed to start process */ 45311016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 45321016ad83Smrg "(main) failed to launch target \"%s\": %s\n", 45331016ad83Smrg lt_argv_zero, nonnull (strerror (errno))); 45341016ad83Smrg return 127; 45351016ad83Smrg } 45361016ad83Smrg return rval; 45371016ad83SmrgEOF 45381016ad83Smrg ;; 45391016ad83Smrg *) 45401016ad83Smrg cat <<"EOF" 45411016ad83Smrg execv (lt_argv_zero, newargz); 45421016ad83Smrg return rval; /* =127, but avoids unused variable warning */ 45431016ad83SmrgEOF 45441016ad83Smrg ;; 45451016ad83Smrg esac 45461016ad83Smrg 45471016ad83Smrg cat <<"EOF" 45481016ad83Smrg} 45491016ad83Smrg 45501016ad83Smrgvoid * 45511016ad83Smrgxmalloc (size_t num) 45521016ad83Smrg{ 45531016ad83Smrg void *p = (void *) malloc (num); 45541016ad83Smrg if (!p) 45551016ad83Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 45561016ad83Smrg 45571016ad83Smrg return p; 45581016ad83Smrg} 45591016ad83Smrg 45601016ad83Smrgchar * 45611016ad83Smrgxstrdup (const char *string) 45621016ad83Smrg{ 45631016ad83Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 45641016ad83Smrg string) : NULL; 45651016ad83Smrg} 45661016ad83Smrg 45671016ad83Smrgconst char * 45681016ad83Smrgbase_name (const char *name) 45691016ad83Smrg{ 45701016ad83Smrg const char *base; 45711016ad83Smrg 45721016ad83Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 45731016ad83Smrg /* Skip over the disk name in MSDOS pathnames. */ 45741016ad83Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 45751016ad83Smrg name += 2; 45761016ad83Smrg#endif 45771016ad83Smrg 45781016ad83Smrg for (base = name; *name; name++) 45791016ad83Smrg if (IS_DIR_SEPARATOR (*name)) 45801016ad83Smrg base = name + 1; 45811016ad83Smrg return base; 45821016ad83Smrg} 45831016ad83Smrg 45841016ad83Smrgint 45851016ad83Smrgcheck_executable (const char *path) 45861016ad83Smrg{ 45871016ad83Smrg struct stat st; 45881016ad83Smrg 45891016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 45901016ad83Smrg nonempty (path)); 45911016ad83Smrg if ((!path) || (!*path)) 45921016ad83Smrg return 0; 45931016ad83Smrg 45941016ad83Smrg if ((stat (path, &st) >= 0) 45951016ad83Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 45961016ad83Smrg return 1; 45971016ad83Smrg else 45981016ad83Smrg return 0; 45991016ad83Smrg} 46001016ad83Smrg 46011016ad83Smrgint 46021016ad83Smrgmake_executable (const char *path) 46031016ad83Smrg{ 46041016ad83Smrg int rval = 0; 46051016ad83Smrg struct stat st; 46061016ad83Smrg 46071016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 46081016ad83Smrg nonempty (path)); 46091016ad83Smrg if ((!path) || (!*path)) 46101016ad83Smrg return 0; 46111016ad83Smrg 46121016ad83Smrg if (stat (path, &st) >= 0) 46131016ad83Smrg { 46141016ad83Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 46151016ad83Smrg } 46161016ad83Smrg return rval; 46171016ad83Smrg} 46181016ad83Smrg 46191016ad83Smrg/* Searches for the full path of the wrapper. Returns 46201016ad83Smrg newly allocated full path name if found, NULL otherwise 46211016ad83Smrg Does not chase symlinks, even on platforms that support them. 46221016ad83Smrg*/ 46231016ad83Smrgchar * 46241016ad83Smrgfind_executable (const char *wrapper) 46251016ad83Smrg{ 46261016ad83Smrg int has_slash = 0; 46271016ad83Smrg const char *p; 46281016ad83Smrg const char *p_next; 46291016ad83Smrg /* static buffer for getcwd */ 46301016ad83Smrg char tmp[LT_PATHMAX + 1]; 46311016ad83Smrg int tmp_len; 46321016ad83Smrg char *concat_name; 46331016ad83Smrg 46341016ad83Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 46351016ad83Smrg nonempty (wrapper)); 46361016ad83Smrg 46371016ad83Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 46381016ad83Smrg return NULL; 46391016ad83Smrg 46401016ad83Smrg /* Absolute path? */ 46411016ad83Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 46421016ad83Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 46431016ad83Smrg { 46441016ad83Smrg concat_name = xstrdup (wrapper); 46451016ad83Smrg if (check_executable (concat_name)) 46461016ad83Smrg return concat_name; 46471016ad83Smrg XFREE (concat_name); 46481016ad83Smrg } 46491016ad83Smrg else 46501016ad83Smrg { 46511016ad83Smrg#endif 46521016ad83Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 46531016ad83Smrg { 46541016ad83Smrg concat_name = xstrdup (wrapper); 46551016ad83Smrg if (check_executable (concat_name)) 46561016ad83Smrg return concat_name; 46571016ad83Smrg XFREE (concat_name); 46581016ad83Smrg } 46591016ad83Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 46601016ad83Smrg } 46611016ad83Smrg#endif 46621016ad83Smrg 46631016ad83Smrg for (p = wrapper; *p; p++) 46641016ad83Smrg if (*p == '/') 46651016ad83Smrg { 46661016ad83Smrg has_slash = 1; 46671016ad83Smrg break; 46681016ad83Smrg } 46691016ad83Smrg if (!has_slash) 46701016ad83Smrg { 46711016ad83Smrg /* no slashes; search PATH */ 46721016ad83Smrg const char *path = getenv ("PATH"); 46731016ad83Smrg if (path != NULL) 46741016ad83Smrg { 46751016ad83Smrg for (p = path; *p; p = p_next) 46761016ad83Smrg { 46771016ad83Smrg const char *q; 46781016ad83Smrg size_t p_len; 46791016ad83Smrg for (q = p; *q; q++) 46801016ad83Smrg if (IS_PATH_SEPARATOR (*q)) 46811016ad83Smrg break; 46821016ad83Smrg p_len = q - p; 46831016ad83Smrg p_next = (*q == '\0' ? q : q + 1); 46841016ad83Smrg if (p_len == 0) 46851016ad83Smrg { 46861016ad83Smrg /* empty path: current directory */ 46871016ad83Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 46881016ad83Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 46891016ad83Smrg nonnull (strerror (errno))); 46901016ad83Smrg tmp_len = strlen (tmp); 46911016ad83Smrg concat_name = 46921016ad83Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 46931016ad83Smrg memcpy (concat_name, tmp, tmp_len); 46941016ad83Smrg concat_name[tmp_len] = '/'; 46951016ad83Smrg strcpy (concat_name + tmp_len + 1, wrapper); 46961016ad83Smrg } 46971016ad83Smrg else 46981016ad83Smrg { 46991016ad83Smrg concat_name = 47001016ad83Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 47011016ad83Smrg memcpy (concat_name, p, p_len); 47021016ad83Smrg concat_name[p_len] = '/'; 47031016ad83Smrg strcpy (concat_name + p_len + 1, wrapper); 47041016ad83Smrg } 47051016ad83Smrg if (check_executable (concat_name)) 47061016ad83Smrg return concat_name; 47071016ad83Smrg XFREE (concat_name); 47081016ad83Smrg } 47091016ad83Smrg } 47101016ad83Smrg /* not found in PATH; assume curdir */ 47111016ad83Smrg } 47121016ad83Smrg /* Relative path | not found in path: prepend cwd */ 47131016ad83Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 47141016ad83Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 47151016ad83Smrg nonnull (strerror (errno))); 47161016ad83Smrg tmp_len = strlen (tmp); 47171016ad83Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 47181016ad83Smrg memcpy (concat_name, tmp, tmp_len); 47191016ad83Smrg concat_name[tmp_len] = '/'; 47201016ad83Smrg strcpy (concat_name + tmp_len + 1, wrapper); 47211016ad83Smrg 47221016ad83Smrg if (check_executable (concat_name)) 47231016ad83Smrg return concat_name; 47241016ad83Smrg XFREE (concat_name); 47251016ad83Smrg return NULL; 47261016ad83Smrg} 47271016ad83Smrg 47281016ad83Smrgchar * 47291016ad83Smrgchase_symlinks (const char *pathspec) 47301016ad83Smrg{ 47311016ad83Smrg#ifndef S_ISLNK 47321016ad83Smrg return xstrdup (pathspec); 47331016ad83Smrg#else 47341016ad83Smrg char buf[LT_PATHMAX]; 47351016ad83Smrg struct stat s; 47361016ad83Smrg char *tmp_pathspec = xstrdup (pathspec); 47371016ad83Smrg char *p; 47381016ad83Smrg int has_symlinks = 0; 47391016ad83Smrg while (strlen (tmp_pathspec) && !has_symlinks) 47401016ad83Smrg { 47411016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 47421016ad83Smrg "checking path component for symlinks: %s\n", 47431016ad83Smrg tmp_pathspec); 47441016ad83Smrg if (lstat (tmp_pathspec, &s) == 0) 47451016ad83Smrg { 47461016ad83Smrg if (S_ISLNK (s.st_mode) != 0) 47471016ad83Smrg { 47481016ad83Smrg has_symlinks = 1; 47491016ad83Smrg break; 47501016ad83Smrg } 47511016ad83Smrg 47521016ad83Smrg /* search backwards for last DIR_SEPARATOR */ 47531016ad83Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 47541016ad83Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 47551016ad83Smrg p--; 47561016ad83Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 47571016ad83Smrg { 47581016ad83Smrg /* no more DIR_SEPARATORS left */ 47591016ad83Smrg break; 47601016ad83Smrg } 47611016ad83Smrg *p = '\0'; 47621016ad83Smrg } 47631016ad83Smrg else 47641016ad83Smrg { 47651016ad83Smrg lt_fatal (__FILE__, __LINE__, 47661016ad83Smrg "error accessing file \"%s\": %s", 47671016ad83Smrg tmp_pathspec, nonnull (strerror (errno))); 47681016ad83Smrg } 47691016ad83Smrg } 47701016ad83Smrg XFREE (tmp_pathspec); 47711016ad83Smrg 47721016ad83Smrg if (!has_symlinks) 47731016ad83Smrg { 47741016ad83Smrg return xstrdup (pathspec); 47751016ad83Smrg } 47761016ad83Smrg 47771016ad83Smrg tmp_pathspec = realpath (pathspec, buf); 47781016ad83Smrg if (tmp_pathspec == 0) 47791016ad83Smrg { 47801016ad83Smrg lt_fatal (__FILE__, __LINE__, 47811016ad83Smrg "could not follow symlinks for %s", pathspec); 47821016ad83Smrg } 47831016ad83Smrg return xstrdup (tmp_pathspec); 47841016ad83Smrg#endif 47851016ad83Smrg} 47861016ad83Smrg 47871016ad83Smrgchar * 47881016ad83Smrgstrendzap (char *str, const char *pat) 47891016ad83Smrg{ 47901016ad83Smrg size_t len, patlen; 47911016ad83Smrg 47921016ad83Smrg assert (str != NULL); 47931016ad83Smrg assert (pat != NULL); 47941016ad83Smrg 47951016ad83Smrg len = strlen (str); 47961016ad83Smrg patlen = strlen (pat); 47971016ad83Smrg 47981016ad83Smrg if (patlen <= len) 47991016ad83Smrg { 48001016ad83Smrg str += len - patlen; 48011016ad83Smrg if (strcmp (str, pat) == 0) 48021016ad83Smrg *str = '\0'; 48031016ad83Smrg } 48041016ad83Smrg return str; 48051016ad83Smrg} 48061016ad83Smrg 48071016ad83Smrgvoid 48081016ad83Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 48091016ad83Smrg{ 48101016ad83Smrg va_list args; 48111016ad83Smrg if (lt_debug) 48121016ad83Smrg { 48131016ad83Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 48141016ad83Smrg va_start (args, fmt); 48151016ad83Smrg (void) vfprintf (stderr, fmt, args); 48161016ad83Smrg va_end (args); 48171016ad83Smrg } 48181016ad83Smrg} 48191016ad83Smrg 48201016ad83Smrgstatic void 48211016ad83Smrglt_error_core (int exit_status, const char *file, 48221016ad83Smrg int line, const char *mode, 48231016ad83Smrg const char *message, va_list ap) 48241016ad83Smrg{ 48251016ad83Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 48261016ad83Smrg vfprintf (stderr, message, ap); 48271016ad83Smrg fprintf (stderr, ".\n"); 48281016ad83Smrg 48291016ad83Smrg if (exit_status >= 0) 48301016ad83Smrg exit (exit_status); 48311016ad83Smrg} 48321016ad83Smrg 48331016ad83Smrgvoid 48341016ad83Smrglt_fatal (const char *file, int line, const char *message, ...) 48351016ad83Smrg{ 48361016ad83Smrg va_list ap; 48371016ad83Smrg va_start (ap, message); 48381016ad83Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 48391016ad83Smrg va_end (ap); 48401016ad83Smrg} 48411016ad83Smrg 48421016ad83Smrgstatic const char * 48431016ad83Smrgnonnull (const char *s) 48441016ad83Smrg{ 48451016ad83Smrg return s ? s : "(null)"; 48461016ad83Smrg} 48471016ad83Smrg 48481016ad83Smrgstatic const char * 48491016ad83Smrgnonempty (const char *s) 48501016ad83Smrg{ 48511016ad83Smrg return (s && !*s) ? "(empty)" : nonnull (s); 48521016ad83Smrg} 48531016ad83Smrg 48541016ad83Smrgvoid 48551016ad83Smrglt_setenv (const char *name, const char *value) 48561016ad83Smrg{ 48571016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 48581016ad83Smrg "(lt_setenv) setting '%s' to '%s'\n", 48591016ad83Smrg nonnull (name), nonnull (value)); 48601016ad83Smrg { 48611016ad83Smrg#ifdef HAVE_SETENV 48621016ad83Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 48631016ad83Smrg char *str = xstrdup (value); 48641016ad83Smrg setenv (name, str, 1); 48651016ad83Smrg#else 48661016ad83Smrg int len = strlen (name) + 1 + strlen (value) + 1; 48671016ad83Smrg char *str = XMALLOC (char, len); 48681016ad83Smrg sprintf (str, "%s=%s", name, value); 48691016ad83Smrg if (putenv (str) != EXIT_SUCCESS) 48701016ad83Smrg { 48711016ad83Smrg XFREE (str); 48721016ad83Smrg } 48731016ad83Smrg#endif 48741016ad83Smrg } 48751016ad83Smrg} 48761016ad83Smrg 48771016ad83Smrgchar * 48781016ad83Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 48791016ad83Smrg{ 48801016ad83Smrg char *new_value; 48811016ad83Smrg if (orig_value && *orig_value) 48821016ad83Smrg { 48831016ad83Smrg int orig_value_len = strlen (orig_value); 48841016ad83Smrg int add_len = strlen (add); 48851016ad83Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 48861016ad83Smrg if (to_end) 48871016ad83Smrg { 48881016ad83Smrg strcpy (new_value, orig_value); 48891016ad83Smrg strcpy (new_value + orig_value_len, add); 48901016ad83Smrg } 48911016ad83Smrg else 48921016ad83Smrg { 48931016ad83Smrg strcpy (new_value, add); 48941016ad83Smrg strcpy (new_value + add_len, orig_value); 48951016ad83Smrg } 48961016ad83Smrg } 48971016ad83Smrg else 48981016ad83Smrg { 48991016ad83Smrg new_value = xstrdup (add); 49001016ad83Smrg } 49011016ad83Smrg return new_value; 49021016ad83Smrg} 49031016ad83Smrg 49041016ad83Smrgvoid 49051016ad83Smrglt_update_exe_path (const char *name, const char *value) 49061016ad83Smrg{ 49071016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 49081016ad83Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 49091016ad83Smrg nonnull (name), nonnull (value)); 49101016ad83Smrg 49111016ad83Smrg if (name && *name && value && *value) 49121016ad83Smrg { 49131016ad83Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 49141016ad83Smrg /* some systems can't cope with a ':'-terminated path #' */ 49151016ad83Smrg int len = strlen (new_value); 49161016ad83Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 49171016ad83Smrg { 49181016ad83Smrg new_value[len-1] = '\0'; 49191016ad83Smrg } 49201016ad83Smrg lt_setenv (name, new_value); 49211016ad83Smrg XFREE (new_value); 49221016ad83Smrg } 49231016ad83Smrg} 49241016ad83Smrg 49251016ad83Smrgvoid 49261016ad83Smrglt_update_lib_path (const char *name, const char *value) 49271016ad83Smrg{ 49281016ad83Smrg lt_debugprintf (__FILE__, __LINE__, 49291016ad83Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 49301016ad83Smrg nonnull (name), nonnull (value)); 49311016ad83Smrg 49321016ad83Smrg if (name && *name && value && *value) 49331016ad83Smrg { 49341016ad83Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 49351016ad83Smrg lt_setenv (name, new_value); 49361016ad83Smrg XFREE (new_value); 49371016ad83Smrg } 49381016ad83Smrg} 49391016ad83Smrg 49401016ad83SmrgEOF 49411016ad83Smrg case $host_os in 49421016ad83Smrg mingw*) 49431016ad83Smrg cat <<"EOF" 49441016ad83Smrg 49451016ad83Smrg/* Prepares an argument vector before calling spawn(). 49461016ad83Smrg Note that spawn() does not by itself call the command interpreter 49471016ad83Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 49481016ad83Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 49491016ad83Smrg GetVersionEx(&v); 49501016ad83Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 49511016ad83Smrg }) ? "cmd.exe" : "command.com"). 49521016ad83Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 49531016ad83Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 49541016ad83Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 49551016ad83Smrg special way: 49561016ad83Smrg - Space and tab are interpreted as delimiters. They are not treated as 49571016ad83Smrg delimiters if they are surrounded by double quotes: "...". 49581016ad83Smrg - Unescaped double quotes are removed from the input. Their only effect is 49591016ad83Smrg that within double quotes, space and tab are treated like normal 49601016ad83Smrg characters. 49611016ad83Smrg - Backslashes not followed by double quotes are not special. 49621016ad83Smrg - But 2*n+1 backslashes followed by a double quote become 49631016ad83Smrg n backslashes followed by a double quote (n >= 0): 49641016ad83Smrg \" -> " 49651016ad83Smrg \\\" -> \" 49661016ad83Smrg \\\\\" -> \\" 49671016ad83Smrg */ 49681016ad83Smrg#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" 49691016ad83Smrg#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" 49701016ad83Smrgchar ** 49711016ad83Smrgprepare_spawn (char **argv) 49721016ad83Smrg{ 49731016ad83Smrg size_t argc; 49741016ad83Smrg char **new_argv; 49751016ad83Smrg size_t i; 49761016ad83Smrg 49771016ad83Smrg /* Count number of arguments. */ 49781016ad83Smrg for (argc = 0; argv[argc] != NULL; argc++) 49791016ad83Smrg ; 49801016ad83Smrg 49811016ad83Smrg /* Allocate new argument vector. */ 49821016ad83Smrg new_argv = XMALLOC (char *, argc + 1); 49831016ad83Smrg 49841016ad83Smrg /* Put quoted arguments into the new argument vector. */ 49851016ad83Smrg for (i = 0; i < argc; i++) 49861016ad83Smrg { 49871016ad83Smrg const char *string = argv[i]; 49881016ad83Smrg 49891016ad83Smrg if (string[0] == '\0') 49901016ad83Smrg new_argv[i] = xstrdup ("\"\""); 49911016ad83Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 49921016ad83Smrg { 49931016ad83Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 49941016ad83Smrg size_t length; 49951016ad83Smrg unsigned int backslashes; 49961016ad83Smrg const char *s; 49971016ad83Smrg char *quoted_string; 49981016ad83Smrg char *p; 49991016ad83Smrg 50001016ad83Smrg length = 0; 50011016ad83Smrg backslashes = 0; 50021016ad83Smrg if (quote_around) 50031016ad83Smrg length++; 50041016ad83Smrg for (s = string; *s != '\0'; s++) 50051016ad83Smrg { 50061016ad83Smrg char c = *s; 50071016ad83Smrg if (c == '"') 50081016ad83Smrg length += backslashes + 1; 50091016ad83Smrg length++; 50101016ad83Smrg if (c == '\\') 50111016ad83Smrg backslashes++; 50121016ad83Smrg else 50131016ad83Smrg backslashes = 0; 50141016ad83Smrg } 50151016ad83Smrg if (quote_around) 50161016ad83Smrg length += backslashes + 1; 50171016ad83Smrg 50181016ad83Smrg quoted_string = XMALLOC (char, length + 1); 50191016ad83Smrg 50201016ad83Smrg p = quoted_string; 50211016ad83Smrg backslashes = 0; 50221016ad83Smrg if (quote_around) 50231016ad83Smrg *p++ = '"'; 50241016ad83Smrg for (s = string; *s != '\0'; s++) 50251016ad83Smrg { 50261016ad83Smrg char c = *s; 50271016ad83Smrg if (c == '"') 50281016ad83Smrg { 50291016ad83Smrg unsigned int j; 50301016ad83Smrg for (j = backslashes + 1; j > 0; j--) 50311016ad83Smrg *p++ = '\\'; 50321016ad83Smrg } 50331016ad83Smrg *p++ = c; 50341016ad83Smrg if (c == '\\') 50351016ad83Smrg backslashes++; 50361016ad83Smrg else 50371016ad83Smrg backslashes = 0; 50381016ad83Smrg } 50391016ad83Smrg if (quote_around) 50401016ad83Smrg { 50411016ad83Smrg unsigned int j; 50421016ad83Smrg for (j = backslashes; j > 0; j--) 50431016ad83Smrg *p++ = '\\'; 50441016ad83Smrg *p++ = '"'; 50451016ad83Smrg } 50461016ad83Smrg *p = '\0'; 50471016ad83Smrg 50481016ad83Smrg new_argv[i] = quoted_string; 50491016ad83Smrg } 50501016ad83Smrg else 50511016ad83Smrg new_argv[i] = (char *) string; 50521016ad83Smrg } 50531016ad83Smrg new_argv[argc] = NULL; 50541016ad83Smrg 50551016ad83Smrg return new_argv; 50561016ad83Smrg} 50571016ad83SmrgEOF 50581016ad83Smrg ;; 50591016ad83Smrg esac 50601016ad83Smrg 50611016ad83Smrg cat <<"EOF" 50621016ad83Smrgvoid lt_dump_script (FILE* f) 50631016ad83Smrg{ 50641016ad83SmrgEOF 50651016ad83Smrg func_emit_wrapper yes | 50661016ad83Smrg $SED -n -e ' 50671016ad83Smrgs/^\(.\{79\}\)\(..*\)/\1\ 50681016ad83Smrg\2/ 50691016ad83Smrgh 50701016ad83Smrgs/\([\\"]\)/\\\1/g 50711016ad83Smrgs/$/\\n/ 50721016ad83Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 50731016ad83Smrgg 50741016ad83SmrgD' 50751016ad83Smrg cat <<"EOF" 50761016ad83Smrg} 50771016ad83SmrgEOF 50781016ad83Smrg} 50791016ad83Smrg# end: func_emit_cwrapperexe_src 50801016ad83Smrg 50811016ad83Smrg# func_win32_import_lib_p ARG 50821016ad83Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 50831016ad83Smrgfunc_win32_import_lib_p () 50841016ad83Smrg{ 50851016ad83Smrg $opt_debug 50861016ad83Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 50871016ad83Smrg *import*) : ;; 50881016ad83Smrg *) false ;; 50891016ad83Smrg esac 50901016ad83Smrg} 50911016ad83Smrg 50921016ad83Smrg# func_mode_link arg... 50931016ad83Smrgfunc_mode_link () 50941016ad83Smrg{ 50951016ad83Smrg $opt_debug 50961016ad83Smrg case $host in 50971016ad83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 50981016ad83Smrg # It is impossible to link a dll without this setting, and 50991016ad83Smrg # we shouldn't force the makefile maintainer to figure out 51001016ad83Smrg # which system we are compiling for in order to pass an extra 51011016ad83Smrg # flag for every libtool invocation. 51021016ad83Smrg # allow_undefined=no 51031016ad83Smrg 51041016ad83Smrg # FIXME: Unfortunately, there are problems with the above when trying 51051016ad83Smrg # to make a dll which has undefined symbols, in which case not 51061016ad83Smrg # even a static library is built. For now, we need to specify 51071016ad83Smrg # -no-undefined on the libtool link line when we can be certain 51081016ad83Smrg # that all symbols are satisfied, otherwise we get a static library. 51091016ad83Smrg allow_undefined=yes 51101016ad83Smrg ;; 51111016ad83Smrg *) 51121016ad83Smrg allow_undefined=yes 51131016ad83Smrg ;; 51141016ad83Smrg esac 51151016ad83Smrg libtool_args=$nonopt 51161016ad83Smrg base_compile="$nonopt $@" 51171016ad83Smrg compile_command=$nonopt 51181016ad83Smrg finalize_command=$nonopt 51191016ad83Smrg 51201016ad83Smrg compile_rpath= 51211016ad83Smrg finalize_rpath= 51221016ad83Smrg compile_shlibpath= 51231016ad83Smrg finalize_shlibpath= 51241016ad83Smrg convenience= 51251016ad83Smrg old_convenience= 51261016ad83Smrg deplibs= 51271016ad83Smrg old_deplibs= 51281016ad83Smrg compiler_flags= 51291016ad83Smrg linker_flags= 51301016ad83Smrg dllsearchpath= 51311016ad83Smrg lib_search_path=`pwd` 51321016ad83Smrg inst_prefix_dir= 51331016ad83Smrg new_inherited_linker_flags= 51341016ad83Smrg 51351016ad83Smrg avoid_version=no 51361016ad83Smrg bindir= 51371016ad83Smrg dlfiles= 51381016ad83Smrg dlprefiles= 51391016ad83Smrg dlself=no 51401016ad83Smrg export_dynamic=no 51411016ad83Smrg export_symbols= 51421016ad83Smrg export_symbols_regex= 51431016ad83Smrg generated= 51441016ad83Smrg libobjs= 51451016ad83Smrg ltlibs= 51461016ad83Smrg module=no 51471016ad83Smrg no_install=no 51481016ad83Smrg objs= 51491016ad83Smrg non_pic_objects= 51501016ad83Smrg precious_files_regex= 51511016ad83Smrg prefer_static_libs=no 51521016ad83Smrg preload=no 51531016ad83Smrg prev= 51541016ad83Smrg prevarg= 51551016ad83Smrg release= 51561016ad83Smrg rpath= 51571016ad83Smrg xrpath= 51581016ad83Smrg perm_rpath= 51591016ad83Smrg temp_rpath= 51601016ad83Smrg thread_safe=no 51611016ad83Smrg vinfo= 51621016ad83Smrg vinfo_number=no 51631016ad83Smrg weak_libs= 51641016ad83Smrg single_module="${wl}-single_module" 51651016ad83Smrg func_infer_tag $base_compile 51661016ad83Smrg 51671016ad83Smrg # We need to know -static, to get the right output filenames. 51681016ad83Smrg for arg 51691016ad83Smrg do 51701016ad83Smrg case $arg in 51711016ad83Smrg -shared) 51721016ad83Smrg test "$build_libtool_libs" != yes && \ 51731016ad83Smrg func_fatal_configuration "can not build a shared library" 51741016ad83Smrg build_old_libs=no 51751016ad83Smrg break 51761016ad83Smrg ;; 51771016ad83Smrg -all-static | -static | -static-libtool-libs) 51781016ad83Smrg case $arg in 51791016ad83Smrg -all-static) 51801016ad83Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 51811016ad83Smrg func_warning "complete static linking is impossible in this configuration" 51821016ad83Smrg fi 51831016ad83Smrg if test -n "$link_static_flag"; then 51841016ad83Smrg dlopen_self=$dlopen_self_static 51851016ad83Smrg fi 51861016ad83Smrg prefer_static_libs=yes 51871016ad83Smrg ;; 51881016ad83Smrg -static) 51891016ad83Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 51901016ad83Smrg dlopen_self=$dlopen_self_static 51911016ad83Smrg fi 51921016ad83Smrg prefer_static_libs=built 51931016ad83Smrg ;; 51941016ad83Smrg -static-libtool-libs) 51951016ad83Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 51961016ad83Smrg dlopen_self=$dlopen_self_static 51971016ad83Smrg fi 51981016ad83Smrg prefer_static_libs=yes 51991016ad83Smrg ;; 52001016ad83Smrg esac 52011016ad83Smrg build_libtool_libs=no 52021016ad83Smrg build_old_libs=yes 52031016ad83Smrg break 52041016ad83Smrg ;; 52051016ad83Smrg esac 52061016ad83Smrg done 52071016ad83Smrg 52081016ad83Smrg # See if our shared archives depend on static archives. 52091016ad83Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 52101016ad83Smrg 52111016ad83Smrg # Go through the arguments, transforming them on the way. 52121016ad83Smrg while test "$#" -gt 0; do 52131016ad83Smrg arg="$1" 52141016ad83Smrg shift 52151016ad83Smrg func_quote_for_eval "$arg" 52161016ad83Smrg qarg=$func_quote_for_eval_unquoted_result 52171016ad83Smrg func_append libtool_args " $func_quote_for_eval_result" 52181016ad83Smrg 52191016ad83Smrg # If the previous option needs an argument, assign it. 52201016ad83Smrg if test -n "$prev"; then 52211016ad83Smrg case $prev in 52221016ad83Smrg output) 52231016ad83Smrg func_append compile_command " @OUTPUT@" 52241016ad83Smrg func_append finalize_command " @OUTPUT@" 52251016ad83Smrg ;; 52261016ad83Smrg esac 52271016ad83Smrg 52281016ad83Smrg case $prev in 52291016ad83Smrg bindir) 52301016ad83Smrg bindir="$arg" 52311016ad83Smrg prev= 52321016ad83Smrg continue 52331016ad83Smrg ;; 52341016ad83Smrg dlfiles|dlprefiles) 52351016ad83Smrg if test "$preload" = no; then 52361016ad83Smrg # Add the symbol object into the linking commands. 52371016ad83Smrg func_append compile_command " @SYMFILE@" 52381016ad83Smrg func_append finalize_command " @SYMFILE@" 52391016ad83Smrg preload=yes 52401016ad83Smrg fi 52411016ad83Smrg case $arg in 52421016ad83Smrg *.la | *.lo) ;; # We handle these cases below. 52431016ad83Smrg force) 52441016ad83Smrg if test "$dlself" = no; then 52451016ad83Smrg dlself=needless 52461016ad83Smrg export_dynamic=yes 52471016ad83Smrg fi 52481016ad83Smrg prev= 52491016ad83Smrg continue 52501016ad83Smrg ;; 52511016ad83Smrg self) 52521016ad83Smrg if test "$prev" = dlprefiles; then 52531016ad83Smrg dlself=yes 52541016ad83Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 52551016ad83Smrg dlself=yes 52561016ad83Smrg else 52571016ad83Smrg dlself=needless 52581016ad83Smrg export_dynamic=yes 52591016ad83Smrg fi 52601016ad83Smrg prev= 52611016ad83Smrg continue 52621016ad83Smrg ;; 52631016ad83Smrg *) 52641016ad83Smrg if test "$prev" = dlfiles; then 52651016ad83Smrg func_append dlfiles " $arg" 52661016ad83Smrg else 52671016ad83Smrg func_append dlprefiles " $arg" 52681016ad83Smrg fi 52691016ad83Smrg prev= 52701016ad83Smrg continue 52711016ad83Smrg ;; 52721016ad83Smrg esac 52731016ad83Smrg ;; 52741016ad83Smrg expsyms) 52751016ad83Smrg export_symbols="$arg" 52761016ad83Smrg test -f "$arg" \ 52771016ad83Smrg || func_fatal_error "symbol file \`$arg' does not exist" 52781016ad83Smrg prev= 52791016ad83Smrg continue 52801016ad83Smrg ;; 52811016ad83Smrg expsyms_regex) 52821016ad83Smrg export_symbols_regex="$arg" 52831016ad83Smrg prev= 52841016ad83Smrg continue 52851016ad83Smrg ;; 52861016ad83Smrg framework) 52871016ad83Smrg case $host in 52881016ad83Smrg *-*-darwin*) 52891016ad83Smrg case "$deplibs " in 52901016ad83Smrg *" $qarg.ltframework "*) ;; 52911016ad83Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 52921016ad83Smrg ;; 52931016ad83Smrg esac 52941016ad83Smrg ;; 52951016ad83Smrg esac 52961016ad83Smrg prev= 52971016ad83Smrg continue 52981016ad83Smrg ;; 52991016ad83Smrg inst_prefix) 53001016ad83Smrg inst_prefix_dir="$arg" 53011016ad83Smrg prev= 53021016ad83Smrg continue 53031016ad83Smrg ;; 53041016ad83Smrg objectlist) 53051016ad83Smrg if test -f "$arg"; then 53061016ad83Smrg save_arg=$arg 53071016ad83Smrg moreargs= 53081016ad83Smrg for fil in `cat "$save_arg"` 53091016ad83Smrg do 53101016ad83Smrg# func_append moreargs " $fil" 53111016ad83Smrg arg=$fil 53121016ad83Smrg # A libtool-controlled object. 53131016ad83Smrg 53141016ad83Smrg # Check to see that this really is a libtool object. 53151016ad83Smrg if func_lalib_unsafe_p "$arg"; then 53161016ad83Smrg pic_object= 53171016ad83Smrg non_pic_object= 53181016ad83Smrg 53191016ad83Smrg # Read the .lo file 53201016ad83Smrg func_source "$arg" 53211016ad83Smrg 53221016ad83Smrg if test -z "$pic_object" || 53231016ad83Smrg test -z "$non_pic_object" || 53241016ad83Smrg test "$pic_object" = none && 53251016ad83Smrg test "$non_pic_object" = none; then 53261016ad83Smrg func_fatal_error "cannot find name of object for \`$arg'" 53271016ad83Smrg fi 53281016ad83Smrg 53291016ad83Smrg # Extract subdirectory from the argument. 53301016ad83Smrg func_dirname "$arg" "/" "" 53311016ad83Smrg xdir="$func_dirname_result" 53321016ad83Smrg 53331016ad83Smrg if test "$pic_object" != none; then 53341016ad83Smrg # Prepend the subdirectory the object is found in. 53351016ad83Smrg pic_object="$xdir$pic_object" 53361016ad83Smrg 53371016ad83Smrg if test "$prev" = dlfiles; then 53381016ad83Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 53391016ad83Smrg func_append dlfiles " $pic_object" 53401016ad83Smrg prev= 53411016ad83Smrg continue 53421016ad83Smrg else 53431016ad83Smrg # If libtool objects are unsupported, then we need to preload. 53441016ad83Smrg prev=dlprefiles 53451016ad83Smrg fi 53461016ad83Smrg fi 53471016ad83Smrg 53481016ad83Smrg # CHECK ME: I think I busted this. -Ossama 53491016ad83Smrg if test "$prev" = dlprefiles; then 53501016ad83Smrg # Preload the old-style object. 53511016ad83Smrg func_append dlprefiles " $pic_object" 53521016ad83Smrg prev= 53531016ad83Smrg fi 53541016ad83Smrg 53551016ad83Smrg # A PIC object. 53561016ad83Smrg func_append libobjs " $pic_object" 53571016ad83Smrg arg="$pic_object" 53581016ad83Smrg fi 53591016ad83Smrg 53601016ad83Smrg # Non-PIC object. 53611016ad83Smrg if test "$non_pic_object" != none; then 53621016ad83Smrg # Prepend the subdirectory the object is found in. 53631016ad83Smrg non_pic_object="$xdir$non_pic_object" 53641016ad83Smrg 53651016ad83Smrg # A standard non-PIC object 53661016ad83Smrg func_append non_pic_objects " $non_pic_object" 53671016ad83Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 53681016ad83Smrg arg="$non_pic_object" 53691016ad83Smrg fi 53701016ad83Smrg else 53711016ad83Smrg # If the PIC object exists, use it instead. 53721016ad83Smrg # $xdir was prepended to $pic_object above. 53731016ad83Smrg non_pic_object="$pic_object" 53741016ad83Smrg func_append non_pic_objects " $non_pic_object" 53751016ad83Smrg fi 53761016ad83Smrg else 53771016ad83Smrg # Only an error if not doing a dry-run. 53781016ad83Smrg if $opt_dry_run; then 53791016ad83Smrg # Extract subdirectory from the argument. 53801016ad83Smrg func_dirname "$arg" "/" "" 53811016ad83Smrg xdir="$func_dirname_result" 53821016ad83Smrg 53831016ad83Smrg func_lo2o "$arg" 53841016ad83Smrg pic_object=$xdir$objdir/$func_lo2o_result 53851016ad83Smrg non_pic_object=$xdir$func_lo2o_result 53861016ad83Smrg func_append libobjs " $pic_object" 53871016ad83Smrg func_append non_pic_objects " $non_pic_object" 53881016ad83Smrg else 53891016ad83Smrg func_fatal_error "\`$arg' is not a valid libtool object" 53901016ad83Smrg fi 53911016ad83Smrg fi 53921016ad83Smrg done 53931016ad83Smrg else 53941016ad83Smrg func_fatal_error "link input file \`$arg' does not exist" 53951016ad83Smrg fi 53961016ad83Smrg arg=$save_arg 53971016ad83Smrg prev= 53981016ad83Smrg continue 53991016ad83Smrg ;; 54001016ad83Smrg precious_regex) 54011016ad83Smrg precious_files_regex="$arg" 54021016ad83Smrg prev= 54031016ad83Smrg continue 54041016ad83Smrg ;; 54051016ad83Smrg release) 54061016ad83Smrg release="-$arg" 54071016ad83Smrg prev= 54081016ad83Smrg continue 54091016ad83Smrg ;; 54101016ad83Smrg rpath | xrpath) 54111016ad83Smrg # We need an absolute path. 54121016ad83Smrg case $arg in 54131016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 54141016ad83Smrg *) 54151016ad83Smrg func_fatal_error "only absolute run-paths are allowed" 54161016ad83Smrg ;; 54171016ad83Smrg esac 54181016ad83Smrg if test "$prev" = rpath; then 54191016ad83Smrg case "$rpath " in 54201016ad83Smrg *" $arg "*) ;; 54211016ad83Smrg *) func_append rpath " $arg" ;; 54221016ad83Smrg esac 54231016ad83Smrg else 54241016ad83Smrg case "$xrpath " in 54251016ad83Smrg *" $arg "*) ;; 54261016ad83Smrg *) func_append xrpath " $arg" ;; 54271016ad83Smrg esac 54281016ad83Smrg fi 54291016ad83Smrg prev= 54301016ad83Smrg continue 54311016ad83Smrg ;; 54321016ad83Smrg shrext) 54331016ad83Smrg shrext_cmds="$arg" 54341016ad83Smrg prev= 54351016ad83Smrg continue 54361016ad83Smrg ;; 54371016ad83Smrg weak) 54381016ad83Smrg func_append weak_libs " $arg" 54391016ad83Smrg prev= 54401016ad83Smrg continue 54411016ad83Smrg ;; 54421016ad83Smrg xcclinker) 54431016ad83Smrg func_append linker_flags " $qarg" 54441016ad83Smrg func_append compiler_flags " $qarg" 54451016ad83Smrg prev= 54461016ad83Smrg func_append compile_command " $qarg" 54471016ad83Smrg func_append finalize_command " $qarg" 54481016ad83Smrg continue 54491016ad83Smrg ;; 54501016ad83Smrg xcompiler) 54511016ad83Smrg func_append compiler_flags " $qarg" 54521016ad83Smrg prev= 54531016ad83Smrg func_append compile_command " $qarg" 54541016ad83Smrg func_append finalize_command " $qarg" 54551016ad83Smrg continue 54561016ad83Smrg ;; 54571016ad83Smrg xlinker) 54581016ad83Smrg func_append linker_flags " $qarg" 54591016ad83Smrg func_append compiler_flags " $wl$qarg" 54601016ad83Smrg prev= 54611016ad83Smrg func_append compile_command " $wl$qarg" 54621016ad83Smrg func_append finalize_command " $wl$qarg" 54631016ad83Smrg continue 54641016ad83Smrg ;; 54651016ad83Smrg *) 54661016ad83Smrg eval "$prev=\"\$arg\"" 54671016ad83Smrg prev= 54681016ad83Smrg continue 54691016ad83Smrg ;; 54701016ad83Smrg esac 54711016ad83Smrg fi # test -n "$prev" 54721016ad83Smrg 54731016ad83Smrg prevarg="$arg" 54741016ad83Smrg 54751016ad83Smrg case $arg in 54761016ad83Smrg -all-static) 54771016ad83Smrg if test -n "$link_static_flag"; then 54781016ad83Smrg # See comment for -static flag below, for more details. 54791016ad83Smrg func_append compile_command " $link_static_flag" 54801016ad83Smrg func_append finalize_command " $link_static_flag" 54811016ad83Smrg fi 54821016ad83Smrg continue 54831016ad83Smrg ;; 54841016ad83Smrg 54851016ad83Smrg -allow-undefined) 54861016ad83Smrg # FIXME: remove this flag sometime in the future. 54871016ad83Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 54881016ad83Smrg ;; 54891016ad83Smrg 54901016ad83Smrg -avoid-version) 54911016ad83Smrg avoid_version=yes 54921016ad83Smrg continue 54931016ad83Smrg ;; 54941016ad83Smrg 54951016ad83Smrg -bindir) 54961016ad83Smrg prev=bindir 54971016ad83Smrg continue 54981016ad83Smrg ;; 54991016ad83Smrg 55001016ad83Smrg -dlopen) 55011016ad83Smrg prev=dlfiles 55021016ad83Smrg continue 55031016ad83Smrg ;; 55041016ad83Smrg 55051016ad83Smrg -dlpreopen) 55061016ad83Smrg prev=dlprefiles 55071016ad83Smrg continue 55081016ad83Smrg ;; 55091016ad83Smrg 55101016ad83Smrg -export-dynamic) 55111016ad83Smrg export_dynamic=yes 55121016ad83Smrg continue 55131016ad83Smrg ;; 55141016ad83Smrg 55151016ad83Smrg -export-symbols | -export-symbols-regex) 55161016ad83Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 55171016ad83Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 55181016ad83Smrg fi 55191016ad83Smrg if test "X$arg" = "X-export-symbols"; then 55201016ad83Smrg prev=expsyms 55211016ad83Smrg else 55221016ad83Smrg prev=expsyms_regex 55231016ad83Smrg fi 55241016ad83Smrg continue 55251016ad83Smrg ;; 55261016ad83Smrg 55271016ad83Smrg -framework) 55281016ad83Smrg prev=framework 55291016ad83Smrg continue 55301016ad83Smrg ;; 55311016ad83Smrg 55321016ad83Smrg -inst-prefix-dir) 55331016ad83Smrg prev=inst_prefix 55341016ad83Smrg continue 55351016ad83Smrg ;; 55361016ad83Smrg 55371016ad83Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 55381016ad83Smrg # so, if we see these flags be careful not to treat them like -L 55391016ad83Smrg -L[A-Z][A-Z]*:*) 55401016ad83Smrg case $with_gcc/$host in 55411016ad83Smrg no/*-*-irix* | /*-*-irix*) 55421016ad83Smrg func_append compile_command " $arg" 55431016ad83Smrg func_append finalize_command " $arg" 55441016ad83Smrg ;; 55451016ad83Smrg esac 55461016ad83Smrg continue 55471016ad83Smrg ;; 55481016ad83Smrg 55491016ad83Smrg -L*) 55501016ad83Smrg func_stripname "-L" '' "$arg" 55511016ad83Smrg if test -z "$func_stripname_result"; then 55521016ad83Smrg if test "$#" -gt 0; then 55531016ad83Smrg func_fatal_error "require no space between \`-L' and \`$1'" 55541016ad83Smrg else 55551016ad83Smrg func_fatal_error "need path for \`-L' option" 55561016ad83Smrg fi 55571016ad83Smrg fi 55581016ad83Smrg func_resolve_sysroot "$func_stripname_result" 55591016ad83Smrg dir=$func_resolve_sysroot_result 55601016ad83Smrg # We need an absolute path. 55611016ad83Smrg case $dir in 55621016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 55631016ad83Smrg *) 55641016ad83Smrg absdir=`cd "$dir" && pwd` 55651016ad83Smrg test -z "$absdir" && \ 55661016ad83Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 55671016ad83Smrg dir="$absdir" 55681016ad83Smrg ;; 55691016ad83Smrg esac 55701016ad83Smrg case "$deplibs " in 55711016ad83Smrg *" -L$dir "* | *" $arg "*) 55721016ad83Smrg # Will only happen for absolute or sysroot arguments 55731016ad83Smrg ;; 55741016ad83Smrg *) 55751016ad83Smrg # Preserve sysroot, but never include relative directories 55761016ad83Smrg case $dir in 55771016ad83Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 55781016ad83Smrg *) func_append deplibs " -L$dir" ;; 55791016ad83Smrg esac 55801016ad83Smrg func_append lib_search_path " $dir" 55811016ad83Smrg ;; 55821016ad83Smrg esac 55831016ad83Smrg case $host in 55841016ad83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 55851016ad83Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 55861016ad83Smrg case :$dllsearchpath: in 55871016ad83Smrg *":$dir:"*) ;; 55881016ad83Smrg ::) dllsearchpath=$dir;; 55891016ad83Smrg *) func_append dllsearchpath ":$dir";; 55901016ad83Smrg esac 55911016ad83Smrg case :$dllsearchpath: in 55921016ad83Smrg *":$testbindir:"*) ;; 55931016ad83Smrg ::) dllsearchpath=$testbindir;; 55941016ad83Smrg *) func_append dllsearchpath ":$testbindir";; 55951016ad83Smrg esac 55961016ad83Smrg ;; 55971016ad83Smrg esac 55981016ad83Smrg continue 55991016ad83Smrg ;; 56001016ad83Smrg 56011016ad83Smrg -l*) 56021016ad83Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 56031016ad83Smrg case $host in 56041016ad83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 56051016ad83Smrg # These systems don't actually have a C or math library (as such) 56061016ad83Smrg continue 56071016ad83Smrg ;; 56081016ad83Smrg *-*-os2*) 56091016ad83Smrg # These systems don't actually have a C library (as such) 56101016ad83Smrg test "X$arg" = "X-lc" && continue 56111016ad83Smrg ;; 56121016ad83Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 56131016ad83Smrg # Do not include libc due to us having libc/libc_r. 56141016ad83Smrg test "X$arg" = "X-lc" && continue 56151016ad83Smrg ;; 56161016ad83Smrg *-*-rhapsody* | *-*-darwin1.[012]) 56171016ad83Smrg # Rhapsody C and math libraries are in the System framework 56181016ad83Smrg func_append deplibs " System.ltframework" 56191016ad83Smrg continue 56201016ad83Smrg ;; 56211016ad83Smrg *-*-sco3.2v5* | *-*-sco5v6*) 56221016ad83Smrg # Causes problems with __ctype 56231016ad83Smrg test "X$arg" = "X-lc" && continue 56241016ad83Smrg ;; 56251016ad83Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 56261016ad83Smrg # Compiler inserts libc in the correct place for threads to work 56271016ad83Smrg test "X$arg" = "X-lc" && continue 56281016ad83Smrg ;; 56291016ad83Smrg esac 56301016ad83Smrg elif test "X$arg" = "X-lc_r"; then 56311016ad83Smrg case $host in 56321016ad83Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 56331016ad83Smrg # Do not include libc_r directly, use -pthread flag. 56341016ad83Smrg continue 56351016ad83Smrg ;; 56361016ad83Smrg esac 56371016ad83Smrg fi 56381016ad83Smrg func_append deplibs " $arg" 56391016ad83Smrg continue 56401016ad83Smrg ;; 56411016ad83Smrg 56421016ad83Smrg -module) 56431016ad83Smrg module=yes 56441016ad83Smrg continue 56451016ad83Smrg ;; 56461016ad83Smrg 56471016ad83Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 56481016ad83Smrg # classes, name mangling, and exception handling. 56491016ad83Smrg # Darwin uses the -arch flag to determine output architecture. 56501016ad83Smrg -model|-arch|-isysroot|--sysroot) 56511016ad83Smrg func_append compiler_flags " $arg" 56521016ad83Smrg func_append compile_command " $arg" 56531016ad83Smrg func_append finalize_command " $arg" 56541016ad83Smrg prev=xcompiler 56551016ad83Smrg continue 56561016ad83Smrg ;; 56571016ad83Smrg 56581016ad83Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 56591016ad83Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 56601016ad83Smrg func_append compiler_flags " $arg" 56611016ad83Smrg func_append compile_command " $arg" 56621016ad83Smrg func_append finalize_command " $arg" 56631016ad83Smrg case "$new_inherited_linker_flags " in 56641016ad83Smrg *" $arg "*) ;; 56651016ad83Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 56661016ad83Smrg esac 56671016ad83Smrg continue 56681016ad83Smrg ;; 56691016ad83Smrg 56701016ad83Smrg -multi_module) 56711016ad83Smrg single_module="${wl}-multi_module" 56721016ad83Smrg continue 56731016ad83Smrg ;; 56741016ad83Smrg 56751016ad83Smrg -no-fast-install) 56761016ad83Smrg fast_install=no 56771016ad83Smrg continue 56781016ad83Smrg ;; 56791016ad83Smrg 56801016ad83Smrg -no-install) 56811016ad83Smrg case $host in 56821016ad83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 56831016ad83Smrg # The PATH hackery in wrapper scripts is required on Windows 56841016ad83Smrg # and Darwin in order for the loader to find any dlls it needs. 56851016ad83Smrg func_warning "\`-no-install' is ignored for $host" 56861016ad83Smrg func_warning "assuming \`-no-fast-install' instead" 56871016ad83Smrg fast_install=no 56881016ad83Smrg ;; 56891016ad83Smrg *) no_install=yes ;; 56901016ad83Smrg esac 56911016ad83Smrg continue 56921016ad83Smrg ;; 56931016ad83Smrg 56941016ad83Smrg -no-undefined) 56951016ad83Smrg allow_undefined=no 56961016ad83Smrg continue 56971016ad83Smrg ;; 56981016ad83Smrg 56991016ad83Smrg -objectlist) 57001016ad83Smrg prev=objectlist 57011016ad83Smrg continue 57021016ad83Smrg ;; 57031016ad83Smrg 57041016ad83Smrg -o) prev=output ;; 57051016ad83Smrg 57061016ad83Smrg -precious-files-regex) 57071016ad83Smrg prev=precious_regex 57081016ad83Smrg continue 57091016ad83Smrg ;; 57101016ad83Smrg 57111016ad83Smrg -release) 57121016ad83Smrg prev=release 57131016ad83Smrg continue 57141016ad83Smrg ;; 57151016ad83Smrg 57161016ad83Smrg -rpath) 57171016ad83Smrg prev=rpath 57181016ad83Smrg continue 57191016ad83Smrg ;; 57201016ad83Smrg 57211016ad83Smrg -R) 57221016ad83Smrg prev=xrpath 57231016ad83Smrg continue 57241016ad83Smrg ;; 57251016ad83Smrg 57261016ad83Smrg -R*) 57271016ad83Smrg func_stripname '-R' '' "$arg" 57281016ad83Smrg dir=$func_stripname_result 57291016ad83Smrg # We need an absolute path. 57301016ad83Smrg case $dir in 57311016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 57321016ad83Smrg =*) 57331016ad83Smrg func_stripname '=' '' "$dir" 57341016ad83Smrg dir=$lt_sysroot$func_stripname_result 57351016ad83Smrg ;; 57361016ad83Smrg *) 57371016ad83Smrg func_fatal_error "only absolute run-paths are allowed" 57381016ad83Smrg ;; 57391016ad83Smrg esac 57401016ad83Smrg case "$xrpath " in 57411016ad83Smrg *" $dir "*) ;; 57421016ad83Smrg *) func_append xrpath " $dir" ;; 57431016ad83Smrg esac 57441016ad83Smrg continue 57451016ad83Smrg ;; 57461016ad83Smrg 57471016ad83Smrg -shared) 57481016ad83Smrg # The effects of -shared are defined in a previous loop. 57491016ad83Smrg continue 57501016ad83Smrg ;; 57511016ad83Smrg 57521016ad83Smrg -shrext) 57531016ad83Smrg prev=shrext 57541016ad83Smrg continue 57551016ad83Smrg ;; 57561016ad83Smrg 57571016ad83Smrg -static | -static-libtool-libs) 57581016ad83Smrg # The effects of -static are defined in a previous loop. 57591016ad83Smrg # We used to do the same as -all-static on platforms that 57601016ad83Smrg # didn't have a PIC flag, but the assumption that the effects 57611016ad83Smrg # would be equivalent was wrong. It would break on at least 57621016ad83Smrg # Digital Unix and AIX. 57631016ad83Smrg continue 57641016ad83Smrg ;; 57651016ad83Smrg 57661016ad83Smrg -thread-safe) 57671016ad83Smrg thread_safe=yes 57681016ad83Smrg continue 57691016ad83Smrg ;; 57701016ad83Smrg 57711016ad83Smrg -version-info) 57721016ad83Smrg prev=vinfo 57731016ad83Smrg continue 57741016ad83Smrg ;; 57751016ad83Smrg 57761016ad83Smrg -version-number) 57771016ad83Smrg prev=vinfo 57781016ad83Smrg vinfo_number=yes 57791016ad83Smrg continue 57801016ad83Smrg ;; 57811016ad83Smrg 57821016ad83Smrg -weak) 57831016ad83Smrg prev=weak 57841016ad83Smrg continue 57851016ad83Smrg ;; 57861016ad83Smrg 57871016ad83Smrg -Wc,*) 57881016ad83Smrg func_stripname '-Wc,' '' "$arg" 57891016ad83Smrg args=$func_stripname_result 57901016ad83Smrg arg= 57911016ad83Smrg save_ifs="$IFS"; IFS=',' 57921016ad83Smrg for flag in $args; do 57931016ad83Smrg IFS="$save_ifs" 57941016ad83Smrg func_quote_for_eval "$flag" 57951016ad83Smrg func_append arg " $func_quote_for_eval_result" 57961016ad83Smrg func_append compiler_flags " $func_quote_for_eval_result" 57971016ad83Smrg done 57981016ad83Smrg IFS="$save_ifs" 57991016ad83Smrg func_stripname ' ' '' "$arg" 58001016ad83Smrg arg=$func_stripname_result 58011016ad83Smrg ;; 58021016ad83Smrg 58031016ad83Smrg -Wl,*) 58041016ad83Smrg func_stripname '-Wl,' '' "$arg" 58051016ad83Smrg args=$func_stripname_result 58061016ad83Smrg arg= 58071016ad83Smrg save_ifs="$IFS"; IFS=',' 58081016ad83Smrg for flag in $args; do 58091016ad83Smrg IFS="$save_ifs" 58101016ad83Smrg func_quote_for_eval "$flag" 58111016ad83Smrg func_append arg " $wl$func_quote_for_eval_result" 58121016ad83Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 58131016ad83Smrg func_append linker_flags " $func_quote_for_eval_result" 58141016ad83Smrg done 58151016ad83Smrg IFS="$save_ifs" 58161016ad83Smrg func_stripname ' ' '' "$arg" 58171016ad83Smrg arg=$func_stripname_result 58181016ad83Smrg ;; 58191016ad83Smrg 58201016ad83Smrg -Xcompiler) 58211016ad83Smrg prev=xcompiler 58221016ad83Smrg continue 58231016ad83Smrg ;; 58241016ad83Smrg 58251016ad83Smrg -Xlinker) 58261016ad83Smrg prev=xlinker 58271016ad83Smrg continue 58281016ad83Smrg ;; 58291016ad83Smrg 58301016ad83Smrg -XCClinker) 58311016ad83Smrg prev=xcclinker 58321016ad83Smrg continue 58331016ad83Smrg ;; 58341016ad83Smrg 58351016ad83Smrg # -msg_* for osf cc 58361016ad83Smrg -msg_*) 58371016ad83Smrg func_quote_for_eval "$arg" 58381016ad83Smrg arg="$func_quote_for_eval_result" 58391016ad83Smrg ;; 58401016ad83Smrg 58411016ad83Smrg # Flags to be passed through unchanged, with rationale: 58421016ad83Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 58431016ad83Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 58441016ad83Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 58451016ad83Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 58461016ad83Smrg # -q* compiler args for the IBM compiler 58471016ad83Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 58481016ad83Smrg # -F/path path to uninstalled frameworks, gcc on darwin 58491016ad83Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 58501016ad83Smrg # @file GCC response files 58511016ad83Smrg # -tp=* Portland pgcc target processor selection 58521016ad83Smrg # --sysroot=* for sysroot support 58531016ad83Smrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 58541016ad83Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 58551016ad83Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 58561016ad83Smrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 58571016ad83Smrg func_quote_for_eval "$arg" 58581016ad83Smrg arg="$func_quote_for_eval_result" 58591016ad83Smrg func_append compile_command " $arg" 58601016ad83Smrg func_append finalize_command " $arg" 58611016ad83Smrg func_append compiler_flags " $arg" 58621016ad83Smrg continue 58631016ad83Smrg ;; 58641016ad83Smrg 58651016ad83Smrg # Some other compiler flag. 58661016ad83Smrg -* | +*) 58671016ad83Smrg func_quote_for_eval "$arg" 58681016ad83Smrg arg="$func_quote_for_eval_result" 58691016ad83Smrg ;; 58701016ad83Smrg 58711016ad83Smrg *.$objext) 58721016ad83Smrg # A standard object. 58731016ad83Smrg func_append objs " $arg" 58741016ad83Smrg ;; 58751016ad83Smrg 58761016ad83Smrg *.lo) 58771016ad83Smrg # A libtool-controlled object. 58781016ad83Smrg 58791016ad83Smrg # Check to see that this really is a libtool object. 58801016ad83Smrg if func_lalib_unsafe_p "$arg"; then 58811016ad83Smrg pic_object= 58821016ad83Smrg non_pic_object= 58831016ad83Smrg 58841016ad83Smrg # Read the .lo file 58851016ad83Smrg func_source "$arg" 58861016ad83Smrg 58871016ad83Smrg if test -z "$pic_object" || 58881016ad83Smrg test -z "$non_pic_object" || 58891016ad83Smrg test "$pic_object" = none && 58901016ad83Smrg test "$non_pic_object" = none; then 58911016ad83Smrg func_fatal_error "cannot find name of object for \`$arg'" 58921016ad83Smrg fi 58931016ad83Smrg 58941016ad83Smrg # Extract subdirectory from the argument. 58951016ad83Smrg func_dirname "$arg" "/" "" 58961016ad83Smrg xdir="$func_dirname_result" 58971016ad83Smrg 58981016ad83Smrg if test "$pic_object" != none; then 58991016ad83Smrg # Prepend the subdirectory the object is found in. 59001016ad83Smrg pic_object="$xdir$pic_object" 59011016ad83Smrg 59021016ad83Smrg if test "$prev" = dlfiles; then 59031016ad83Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 59041016ad83Smrg func_append dlfiles " $pic_object" 59051016ad83Smrg prev= 59061016ad83Smrg continue 59071016ad83Smrg else 59081016ad83Smrg # If libtool objects are unsupported, then we need to preload. 59091016ad83Smrg prev=dlprefiles 59101016ad83Smrg fi 59111016ad83Smrg fi 59121016ad83Smrg 59131016ad83Smrg # CHECK ME: I think I busted this. -Ossama 59141016ad83Smrg if test "$prev" = dlprefiles; then 59151016ad83Smrg # Preload the old-style object. 59161016ad83Smrg func_append dlprefiles " $pic_object" 59171016ad83Smrg prev= 59181016ad83Smrg fi 59191016ad83Smrg 59201016ad83Smrg # A PIC object. 59211016ad83Smrg func_append libobjs " $pic_object" 59221016ad83Smrg arg="$pic_object" 59231016ad83Smrg fi 59241016ad83Smrg 59251016ad83Smrg # Non-PIC object. 59261016ad83Smrg if test "$non_pic_object" != none; then 59271016ad83Smrg # Prepend the subdirectory the object is found in. 59281016ad83Smrg non_pic_object="$xdir$non_pic_object" 59291016ad83Smrg 59301016ad83Smrg # A standard non-PIC object 59311016ad83Smrg func_append non_pic_objects " $non_pic_object" 59321016ad83Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 59331016ad83Smrg arg="$non_pic_object" 59341016ad83Smrg fi 59351016ad83Smrg else 59361016ad83Smrg # If the PIC object exists, use it instead. 59371016ad83Smrg # $xdir was prepended to $pic_object above. 59381016ad83Smrg non_pic_object="$pic_object" 59391016ad83Smrg func_append non_pic_objects " $non_pic_object" 59401016ad83Smrg fi 59411016ad83Smrg else 59421016ad83Smrg # Only an error if not doing a dry-run. 59431016ad83Smrg if $opt_dry_run; then 59441016ad83Smrg # Extract subdirectory from the argument. 59451016ad83Smrg func_dirname "$arg" "/" "" 59461016ad83Smrg xdir="$func_dirname_result" 59471016ad83Smrg 59481016ad83Smrg func_lo2o "$arg" 59491016ad83Smrg pic_object=$xdir$objdir/$func_lo2o_result 59501016ad83Smrg non_pic_object=$xdir$func_lo2o_result 59511016ad83Smrg func_append libobjs " $pic_object" 59521016ad83Smrg func_append non_pic_objects " $non_pic_object" 59531016ad83Smrg else 59541016ad83Smrg func_fatal_error "\`$arg' is not a valid libtool object" 59551016ad83Smrg fi 59561016ad83Smrg fi 59571016ad83Smrg ;; 59581016ad83Smrg 59591016ad83Smrg *.$libext) 59601016ad83Smrg # An archive. 59611016ad83Smrg func_append deplibs " $arg" 59621016ad83Smrg func_append old_deplibs " $arg" 59631016ad83Smrg continue 59641016ad83Smrg ;; 59651016ad83Smrg 59661016ad83Smrg *.la) 59671016ad83Smrg # A libtool-controlled library. 59681016ad83Smrg 59691016ad83Smrg func_resolve_sysroot "$arg" 59701016ad83Smrg if test "$prev" = dlfiles; then 59711016ad83Smrg # This library was specified with -dlopen. 59721016ad83Smrg func_append dlfiles " $func_resolve_sysroot_result" 59731016ad83Smrg prev= 59741016ad83Smrg elif test "$prev" = dlprefiles; then 59751016ad83Smrg # The library was specified with -dlpreopen. 59761016ad83Smrg func_append dlprefiles " $func_resolve_sysroot_result" 59771016ad83Smrg prev= 59781016ad83Smrg else 59791016ad83Smrg func_append deplibs " $func_resolve_sysroot_result" 59801016ad83Smrg fi 59811016ad83Smrg continue 59821016ad83Smrg ;; 59831016ad83Smrg 59841016ad83Smrg # Some other compiler argument. 59851016ad83Smrg *) 59861016ad83Smrg # Unknown arguments in both finalize_command and compile_command need 59871016ad83Smrg # to be aesthetically quoted because they are evaled later. 59881016ad83Smrg func_quote_for_eval "$arg" 59891016ad83Smrg arg="$func_quote_for_eval_result" 59901016ad83Smrg ;; 59911016ad83Smrg esac # arg 59921016ad83Smrg 59931016ad83Smrg # Now actually substitute the argument into the commands. 59941016ad83Smrg if test -n "$arg"; then 59951016ad83Smrg func_append compile_command " $arg" 59961016ad83Smrg func_append finalize_command " $arg" 59971016ad83Smrg fi 59981016ad83Smrg done # argument parsing loop 59991016ad83Smrg 60001016ad83Smrg test -n "$prev" && \ 60011016ad83Smrg func_fatal_help "the \`$prevarg' option requires an argument" 60021016ad83Smrg 60031016ad83Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 60041016ad83Smrg eval arg=\"$export_dynamic_flag_spec\" 60051016ad83Smrg func_append compile_command " $arg" 60061016ad83Smrg func_append finalize_command " $arg" 60071016ad83Smrg fi 60081016ad83Smrg 60091016ad83Smrg oldlibs= 60101016ad83Smrg # calculate the name of the file, without its directory 60111016ad83Smrg func_basename "$output" 60121016ad83Smrg outputname="$func_basename_result" 60131016ad83Smrg libobjs_save="$libobjs" 60141016ad83Smrg 60151016ad83Smrg if test -n "$shlibpath_var"; then 60161016ad83Smrg # get the directories listed in $shlibpath_var 60171016ad83Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 60181016ad83Smrg else 60191016ad83Smrg shlib_search_path= 60201016ad83Smrg fi 60211016ad83Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 60221016ad83Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 60231016ad83Smrg 60241016ad83Smrg func_dirname "$output" "/" "" 60251016ad83Smrg output_objdir="$func_dirname_result$objdir" 60261016ad83Smrg func_to_tool_file "$output_objdir/" 60271016ad83Smrg tool_output_objdir=$func_to_tool_file_result 60281016ad83Smrg # Create the object directory. 60291016ad83Smrg func_mkdir_p "$output_objdir" 60301016ad83Smrg 60311016ad83Smrg # Determine the type of output 60321016ad83Smrg case $output in 60331016ad83Smrg "") 60341016ad83Smrg func_fatal_help "you must specify an output file" 60351016ad83Smrg ;; 60361016ad83Smrg *.$libext) linkmode=oldlib ;; 60371016ad83Smrg *.lo | *.$objext) linkmode=obj ;; 60381016ad83Smrg *.la) linkmode=lib ;; 60391016ad83Smrg *) linkmode=prog ;; # Anything else should be a program. 60401016ad83Smrg esac 60411016ad83Smrg 60421016ad83Smrg specialdeplibs= 60431016ad83Smrg 60441016ad83Smrg libs= 60451016ad83Smrg # Find all interdependent deplibs by searching for libraries 60461016ad83Smrg # that are linked more than once (e.g. -la -lb -la) 60471016ad83Smrg for deplib in $deplibs; do 60481016ad83Smrg if $opt_preserve_dup_deps ; then 60491016ad83Smrg case "$libs " in 60501016ad83Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 60511016ad83Smrg esac 60521016ad83Smrg fi 60531016ad83Smrg func_append libs " $deplib" 60541016ad83Smrg done 60551016ad83Smrg 60561016ad83Smrg if test "$linkmode" = lib; then 60571016ad83Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 60581016ad83Smrg 60591016ad83Smrg # Compute libraries that are listed more than once in $predeps 60601016ad83Smrg # $postdeps and mark them as special (i.e., whose duplicates are 60611016ad83Smrg # not to be eliminated). 60621016ad83Smrg pre_post_deps= 60631016ad83Smrg if $opt_duplicate_compiler_generated_deps; then 60641016ad83Smrg for pre_post_dep in $predeps $postdeps; do 60651016ad83Smrg case "$pre_post_deps " in 60661016ad83Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 60671016ad83Smrg esac 60681016ad83Smrg func_append pre_post_deps " $pre_post_dep" 60691016ad83Smrg done 60701016ad83Smrg fi 60711016ad83Smrg pre_post_deps= 60721016ad83Smrg fi 60731016ad83Smrg 60741016ad83Smrg deplibs= 60751016ad83Smrg newdependency_libs= 60761016ad83Smrg newlib_search_path= 60771016ad83Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 60781016ad83Smrg notinst_deplibs= # not-installed libtool libraries 60791016ad83Smrg notinst_path= # paths that contain not-installed libtool libraries 60801016ad83Smrg 60811016ad83Smrg case $linkmode in 60821016ad83Smrg lib) 60831016ad83Smrg passes="conv dlpreopen link" 60841016ad83Smrg for file in $dlfiles $dlprefiles; do 60851016ad83Smrg case $file in 60861016ad83Smrg *.la) ;; 60871016ad83Smrg *) 60881016ad83Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 60891016ad83Smrg ;; 60901016ad83Smrg esac 60911016ad83Smrg done 60921016ad83Smrg ;; 60931016ad83Smrg prog) 60941016ad83Smrg compile_deplibs= 60951016ad83Smrg finalize_deplibs= 60961016ad83Smrg alldeplibs=no 60971016ad83Smrg newdlfiles= 60981016ad83Smrg newdlprefiles= 60991016ad83Smrg passes="conv scan dlopen dlpreopen link" 61001016ad83Smrg ;; 61011016ad83Smrg *) passes="conv" 61021016ad83Smrg ;; 61031016ad83Smrg esac 61041016ad83Smrg 61051016ad83Smrg for pass in $passes; do 61061016ad83Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 61071016ad83Smrg # so that -L comes before libs that need it for instance... 61081016ad83Smrg if test "$linkmode,$pass" = "lib,link"; then 61091016ad83Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 61101016ad83Smrg ## order, and fix it there properly 61111016ad83Smrg tmp_deplibs= 61121016ad83Smrg for deplib in $deplibs; do 61131016ad83Smrg tmp_deplibs="$deplib $tmp_deplibs" 61141016ad83Smrg done 61151016ad83Smrg deplibs="$tmp_deplibs" 61161016ad83Smrg fi 61171016ad83Smrg 61181016ad83Smrg if test "$linkmode,$pass" = "lib,link" || 61191016ad83Smrg test "$linkmode,$pass" = "prog,scan"; then 61201016ad83Smrg libs="$deplibs" 61211016ad83Smrg deplibs= 61221016ad83Smrg fi 61231016ad83Smrg if test "$linkmode" = prog; then 61241016ad83Smrg case $pass in 61251016ad83Smrg dlopen) libs="$dlfiles" ;; 61261016ad83Smrg dlpreopen) libs="$dlprefiles" ;; 61271016ad83Smrg link) 61281016ad83Smrg libs="$deplibs %DEPLIBS%" 61291016ad83Smrg test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" 61301016ad83Smrg ;; 61311016ad83Smrg esac 61321016ad83Smrg fi 61331016ad83Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 61341016ad83Smrg # Collect and forward deplibs of preopened libtool libs 61351016ad83Smrg for lib in $dlprefiles; do 61361016ad83Smrg # Ignore non-libtool-libs 61371016ad83Smrg dependency_libs= 61381016ad83Smrg func_resolve_sysroot "$lib" 61391016ad83Smrg case $lib in 61401016ad83Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 61411016ad83Smrg esac 61421016ad83Smrg 61431016ad83Smrg # Collect preopened libtool deplibs, except any this library 61441016ad83Smrg # has declared as weak libs 61451016ad83Smrg for deplib in $dependency_libs; do 61461016ad83Smrg func_basename "$deplib" 61471016ad83Smrg deplib_base=$func_basename_result 61481016ad83Smrg case " $weak_libs " in 61491016ad83Smrg *" $deplib_base "*) ;; 61501016ad83Smrg *) func_append deplibs " $deplib" ;; 61511016ad83Smrg esac 61521016ad83Smrg done 61531016ad83Smrg done 61541016ad83Smrg libs="$dlprefiles" 61551016ad83Smrg fi 61561016ad83Smrg if test "$pass" = dlopen; then 61571016ad83Smrg # Collect dlpreopened libraries 61581016ad83Smrg save_deplibs="$deplibs" 61591016ad83Smrg deplibs= 61601016ad83Smrg fi 61611016ad83Smrg 61621016ad83Smrg for deplib in $libs; do 61631016ad83Smrg lib= 61641016ad83Smrg found=no 61651016ad83Smrg case $deplib in 61661016ad83Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 61671016ad83Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 61681016ad83Smrg if test "$linkmode,$pass" = "prog,link"; then 61691016ad83Smrg compile_deplibs="$deplib $compile_deplibs" 61701016ad83Smrg finalize_deplibs="$deplib $finalize_deplibs" 61711016ad83Smrg else 61721016ad83Smrg func_append compiler_flags " $deplib" 61731016ad83Smrg if test "$linkmode" = lib ; then 61741016ad83Smrg case "$new_inherited_linker_flags " in 61751016ad83Smrg *" $deplib "*) ;; 61761016ad83Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 61771016ad83Smrg esac 61781016ad83Smrg fi 61791016ad83Smrg fi 61801016ad83Smrg continue 61811016ad83Smrg ;; 61821016ad83Smrg -l*) 61831016ad83Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 61841016ad83Smrg func_warning "\`-l' is ignored for archives/objects" 61851016ad83Smrg continue 61861016ad83Smrg fi 61871016ad83Smrg func_stripname '-l' '' "$deplib" 61881016ad83Smrg name=$func_stripname_result 61891016ad83Smrg if test "$linkmode" = lib; then 61901016ad83Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 61911016ad83Smrg else 61921016ad83Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 61931016ad83Smrg fi 61941016ad83Smrg for searchdir in $searchdirs; do 61951016ad83Smrg for search_ext in .la $std_shrext .so .a; do 61961016ad83Smrg # Search the libtool library 61971016ad83Smrg lib="$searchdir/lib${name}${search_ext}" 61981016ad83Smrg if test -f "$lib"; then 61991016ad83Smrg if test "$search_ext" = ".la"; then 62001016ad83Smrg found=yes 62011016ad83Smrg else 62021016ad83Smrg found=no 62031016ad83Smrg fi 62041016ad83Smrg break 2 62051016ad83Smrg fi 62061016ad83Smrg done 62071016ad83Smrg done 62081016ad83Smrg if test "$found" != yes; then 62091016ad83Smrg # deplib doesn't seem to be a libtool library 62101016ad83Smrg if test "$linkmode,$pass" = "prog,link"; then 62111016ad83Smrg compile_deplibs="$deplib $compile_deplibs" 62121016ad83Smrg finalize_deplibs="$deplib $finalize_deplibs" 62131016ad83Smrg else 62141016ad83Smrg deplibs="$deplib $deplibs" 62151016ad83Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 62161016ad83Smrg fi 62171016ad83Smrg continue 62181016ad83Smrg else # deplib is a libtool library 62191016ad83Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 62201016ad83Smrg # We need to do some special things here, and not later. 62211016ad83Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 62221016ad83Smrg case " $predeps $postdeps " in 62231016ad83Smrg *" $deplib "*) 62241016ad83Smrg if func_lalib_p "$lib"; then 62251016ad83Smrg library_names= 62261016ad83Smrg old_library= 62271016ad83Smrg func_source "$lib" 62281016ad83Smrg for l in $old_library $library_names; do 62291016ad83Smrg ll="$l" 62301016ad83Smrg done 62311016ad83Smrg if test "X$ll" = "X$old_library" ; then # only static version available 62321016ad83Smrg found=no 62331016ad83Smrg func_dirname "$lib" "" "." 62341016ad83Smrg ladir="$func_dirname_result" 62351016ad83Smrg lib=$ladir/$old_library 62361016ad83Smrg if test "$linkmode,$pass" = "prog,link"; then 62371016ad83Smrg compile_deplibs="$deplib $compile_deplibs" 62381016ad83Smrg finalize_deplibs="$deplib $finalize_deplibs" 62391016ad83Smrg else 62401016ad83Smrg deplibs="$deplib $deplibs" 62411016ad83Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 62421016ad83Smrg fi 62431016ad83Smrg continue 62441016ad83Smrg fi 62451016ad83Smrg fi 62461016ad83Smrg ;; 62471016ad83Smrg *) ;; 62481016ad83Smrg esac 62491016ad83Smrg fi 62501016ad83Smrg fi 62511016ad83Smrg ;; # -l 62521016ad83Smrg *.ltframework) 62531016ad83Smrg if test "$linkmode,$pass" = "prog,link"; then 62541016ad83Smrg compile_deplibs="$deplib $compile_deplibs" 62551016ad83Smrg finalize_deplibs="$deplib $finalize_deplibs" 62561016ad83Smrg else 62571016ad83Smrg deplibs="$deplib $deplibs" 62581016ad83Smrg if test "$linkmode" = lib ; then 62591016ad83Smrg case "$new_inherited_linker_flags " in 62601016ad83Smrg *" $deplib "*) ;; 62611016ad83Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 62621016ad83Smrg esac 62631016ad83Smrg fi 62641016ad83Smrg fi 62651016ad83Smrg continue 62661016ad83Smrg ;; 62671016ad83Smrg -L*) 62681016ad83Smrg case $linkmode in 62691016ad83Smrg lib) 62701016ad83Smrg deplibs="$deplib $deplibs" 62711016ad83Smrg test "$pass" = conv && continue 62721016ad83Smrg newdependency_libs="$deplib $newdependency_libs" 62731016ad83Smrg func_stripname '-L' '' "$deplib" 62741016ad83Smrg func_resolve_sysroot "$func_stripname_result" 62751016ad83Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 62761016ad83Smrg ;; 62771016ad83Smrg prog) 62781016ad83Smrg if test "$pass" = conv; then 62791016ad83Smrg deplibs="$deplib $deplibs" 62801016ad83Smrg continue 62811016ad83Smrg fi 62821016ad83Smrg if test "$pass" = scan; then 62831016ad83Smrg deplibs="$deplib $deplibs" 62841016ad83Smrg else 62851016ad83Smrg compile_deplibs="$deplib $compile_deplibs" 62861016ad83Smrg finalize_deplibs="$deplib $finalize_deplibs" 62871016ad83Smrg fi 62881016ad83Smrg func_stripname '-L' '' "$deplib" 62891016ad83Smrg func_resolve_sysroot "$func_stripname_result" 62901016ad83Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 62911016ad83Smrg ;; 62921016ad83Smrg *) 62931016ad83Smrg func_warning "\`-L' is ignored for archives/objects" 62941016ad83Smrg ;; 62951016ad83Smrg esac # linkmode 62961016ad83Smrg continue 62971016ad83Smrg ;; # -L 62981016ad83Smrg -R*) 62991016ad83Smrg if test "$pass" = link; then 63001016ad83Smrg func_stripname '-R' '' "$deplib" 63011016ad83Smrg func_resolve_sysroot "$func_stripname_result" 63021016ad83Smrg dir=$func_resolve_sysroot_result 63031016ad83Smrg # Make sure the xrpath contains only unique directories. 63041016ad83Smrg case "$xrpath " in 63051016ad83Smrg *" $dir "*) ;; 63061016ad83Smrg *) func_append xrpath " $dir" ;; 63071016ad83Smrg esac 63081016ad83Smrg fi 63091016ad83Smrg deplibs="$deplib $deplibs" 63101016ad83Smrg continue 63111016ad83Smrg ;; 63121016ad83Smrg *.la) 63131016ad83Smrg func_resolve_sysroot "$deplib" 63141016ad83Smrg lib=$func_resolve_sysroot_result 63151016ad83Smrg ;; 63161016ad83Smrg *.$libext) 63171016ad83Smrg if test "$pass" = conv; then 63181016ad83Smrg deplibs="$deplib $deplibs" 63191016ad83Smrg continue 63201016ad83Smrg fi 63211016ad83Smrg case $linkmode in 63221016ad83Smrg lib) 63231016ad83Smrg # Linking convenience modules into shared libraries is allowed, 63241016ad83Smrg # but linking other static libraries is non-portable. 63251016ad83Smrg case " $dlpreconveniencelibs " in 63261016ad83Smrg *" $deplib "*) ;; 63271016ad83Smrg *) 63281016ad83Smrg valid_a_lib=no 63291016ad83Smrg case $deplibs_check_method in 63301016ad83Smrg match_pattern*) 63311016ad83Smrg set dummy $deplibs_check_method; shift 63321016ad83Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 63331016ad83Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 63341016ad83Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 63351016ad83Smrg valid_a_lib=yes 63361016ad83Smrg fi 63371016ad83Smrg ;; 63381016ad83Smrg pass_all) 63391016ad83Smrg valid_a_lib=yes 63401016ad83Smrg ;; 63411016ad83Smrg esac 63421016ad83Smrg if test "$valid_a_lib" != yes; then 63431016ad83Smrg echo 63441016ad83Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 63451016ad83Smrg echo "*** I have the capability to make that library automatically link in when" 63461016ad83Smrg echo "*** you link to this library. But I can only do this if you have a" 63471016ad83Smrg echo "*** shared version of the library, which you do not appear to have" 63481016ad83Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 63491016ad83Smrg echo "*** that it is just a static archive that I should not use here." 63501016ad83Smrg else 63511016ad83Smrg echo 63521016ad83Smrg $ECHO "*** Warning: Linking the shared library $output against the" 63531016ad83Smrg $ECHO "*** static library $deplib is not portable!" 63541016ad83Smrg deplibs="$deplib $deplibs" 63551016ad83Smrg fi 63561016ad83Smrg ;; 63571016ad83Smrg esac 63581016ad83Smrg continue 63591016ad83Smrg ;; 63601016ad83Smrg prog) 63611016ad83Smrg if test "$pass" != link; then 63621016ad83Smrg deplibs="$deplib $deplibs" 63631016ad83Smrg else 63641016ad83Smrg compile_deplibs="$deplib $compile_deplibs" 63651016ad83Smrg finalize_deplibs="$deplib $finalize_deplibs" 63661016ad83Smrg fi 63671016ad83Smrg continue 63681016ad83Smrg ;; 63691016ad83Smrg esac # linkmode 63701016ad83Smrg ;; # *.$libext 63711016ad83Smrg *.lo | *.$objext) 63721016ad83Smrg if test "$pass" = conv; then 63731016ad83Smrg deplibs="$deplib $deplibs" 63741016ad83Smrg elif test "$linkmode" = prog; then 63751016ad83Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 63761016ad83Smrg # If there is no dlopen support or we're linking statically, 63771016ad83Smrg # we need to preload. 63781016ad83Smrg func_append newdlprefiles " $deplib" 63791016ad83Smrg compile_deplibs="$deplib $compile_deplibs" 63801016ad83Smrg finalize_deplibs="$deplib $finalize_deplibs" 63811016ad83Smrg else 63821016ad83Smrg func_append newdlfiles " $deplib" 63831016ad83Smrg fi 63841016ad83Smrg fi 63851016ad83Smrg continue 63861016ad83Smrg ;; 63871016ad83Smrg %DEPLIBS%) 63881016ad83Smrg alldeplibs=yes 63891016ad83Smrg continue 63901016ad83Smrg ;; 63911016ad83Smrg esac # case $deplib 63921016ad83Smrg 63931016ad83Smrg if test "$found" = yes || test -f "$lib"; then : 63941016ad83Smrg else 63951016ad83Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 63961016ad83Smrg fi 63971016ad83Smrg 63981016ad83Smrg # Check to see that this really is a libtool archive. 63991016ad83Smrg func_lalib_unsafe_p "$lib" \ 64001016ad83Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 64011016ad83Smrg 64021016ad83Smrg func_dirname "$lib" "" "." 64031016ad83Smrg ladir="$func_dirname_result" 64041016ad83Smrg 64051016ad83Smrg dlname= 64061016ad83Smrg dlopen= 64071016ad83Smrg dlpreopen= 64081016ad83Smrg libdir= 64091016ad83Smrg library_names= 64101016ad83Smrg old_library= 64111016ad83Smrg inherited_linker_flags= 64121016ad83Smrg # If the library was installed with an old release of libtool, 64131016ad83Smrg # it will not redefine variables installed, or shouldnotlink 64141016ad83Smrg installed=yes 64151016ad83Smrg shouldnotlink=no 64161016ad83Smrg avoidtemprpath= 64171016ad83Smrg 64181016ad83Smrg 64191016ad83Smrg # Read the .la file 64201016ad83Smrg func_source "$lib" 64211016ad83Smrg 64221016ad83Smrg # Convert "-framework foo" to "foo.ltframework" 64231016ad83Smrg if test -n "$inherited_linker_flags"; then 64241016ad83Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 64251016ad83Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 64261016ad83Smrg case " $new_inherited_linker_flags " in 64271016ad83Smrg *" $tmp_inherited_linker_flag "*) ;; 64281016ad83Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 64291016ad83Smrg esac 64301016ad83Smrg done 64311016ad83Smrg fi 64321016ad83Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 64331016ad83Smrg if test "$linkmode,$pass" = "lib,link" || 64341016ad83Smrg test "$linkmode,$pass" = "prog,scan" || 64351016ad83Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 64361016ad83Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 64371016ad83Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 64381016ad83Smrg fi 64391016ad83Smrg 64401016ad83Smrg if test "$pass" = conv; then 64411016ad83Smrg # Only check for convenience libraries 64421016ad83Smrg deplibs="$lib $deplibs" 64431016ad83Smrg if test -z "$libdir"; then 64441016ad83Smrg if test -z "$old_library"; then 64451016ad83Smrg func_fatal_error "cannot find name of link library for \`$lib'" 64461016ad83Smrg fi 64471016ad83Smrg # It is a libtool convenience library, so add in its objects. 64481016ad83Smrg func_append convenience " $ladir/$objdir/$old_library" 64491016ad83Smrg func_append old_convenience " $ladir/$objdir/$old_library" 64501016ad83Smrg tmp_libs= 64511016ad83Smrg for deplib in $dependency_libs; do 64521016ad83Smrg deplibs="$deplib $deplibs" 64531016ad83Smrg if $opt_preserve_dup_deps ; then 64541016ad83Smrg case "$tmp_libs " in 64551016ad83Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 64561016ad83Smrg esac 64571016ad83Smrg fi 64581016ad83Smrg func_append tmp_libs " $deplib" 64591016ad83Smrg done 64601016ad83Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 64611016ad83Smrg func_fatal_error "\`$lib' is not a convenience library" 64621016ad83Smrg fi 64631016ad83Smrg continue 64641016ad83Smrg fi # $pass = conv 64651016ad83Smrg 64661016ad83Smrg 64671016ad83Smrg # Get the name of the library we link against. 64681016ad83Smrg linklib= 64691016ad83Smrg if test -n "$old_library" && 64701016ad83Smrg { test "$prefer_static_libs" = yes || 64711016ad83Smrg test "$prefer_static_libs,$installed" = "built,no"; }; then 64721016ad83Smrg linklib=$old_library 64731016ad83Smrg else 64741016ad83Smrg for l in $old_library $library_names; do 64751016ad83Smrg linklib="$l" 64761016ad83Smrg done 64771016ad83Smrg fi 64781016ad83Smrg if test -z "$linklib"; then 64791016ad83Smrg func_fatal_error "cannot find name of link library for \`$lib'" 64801016ad83Smrg fi 64811016ad83Smrg 64821016ad83Smrg # This library was specified with -dlopen. 64831016ad83Smrg if test "$pass" = dlopen; then 64841016ad83Smrg if test -z "$libdir"; then 64851016ad83Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 64861016ad83Smrg fi 64871016ad83Smrg if test -z "$dlname" || 64881016ad83Smrg test "$dlopen_support" != yes || 64891016ad83Smrg test "$build_libtool_libs" = no; then 64901016ad83Smrg # If there is no dlname, no dlopen support or we're linking 64911016ad83Smrg # statically, we need to preload. We also need to preload any 64921016ad83Smrg # dependent libraries so libltdl's deplib preloader doesn't 64931016ad83Smrg # bomb out in the load deplibs phase. 64941016ad83Smrg func_append dlprefiles " $lib $dependency_libs" 64951016ad83Smrg else 64961016ad83Smrg func_append newdlfiles " $lib" 64971016ad83Smrg fi 64981016ad83Smrg continue 64991016ad83Smrg fi # $pass = dlopen 65001016ad83Smrg 65011016ad83Smrg # We need an absolute path. 65021016ad83Smrg case $ladir in 65031016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 65041016ad83Smrg *) 65051016ad83Smrg abs_ladir=`cd "$ladir" && pwd` 65061016ad83Smrg if test -z "$abs_ladir"; then 65071016ad83Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 65081016ad83Smrg func_warning "passing it literally to the linker, although it might fail" 65091016ad83Smrg abs_ladir="$ladir" 65101016ad83Smrg fi 65111016ad83Smrg ;; 65121016ad83Smrg esac 65131016ad83Smrg func_basename "$lib" 65141016ad83Smrg laname="$func_basename_result" 65151016ad83Smrg 65161016ad83Smrg # Find the relevant object directory and library name. 65171016ad83Smrg if test "X$installed" = Xyes; then 65181016ad83Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 65191016ad83Smrg func_warning "library \`$lib' was moved." 65201016ad83Smrg dir="$ladir" 65211016ad83Smrg absdir="$abs_ladir" 65221016ad83Smrg libdir="$abs_ladir" 65231016ad83Smrg else 65241016ad83Smrg dir="$lt_sysroot$libdir" 65251016ad83Smrg absdir="$lt_sysroot$libdir" 65261016ad83Smrg fi 65271016ad83Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 65281016ad83Smrg else 65291016ad83Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 65301016ad83Smrg dir="$ladir" 65311016ad83Smrg absdir="$abs_ladir" 65321016ad83Smrg # Remove this search path later 65331016ad83Smrg func_append notinst_path " $abs_ladir" 65341016ad83Smrg else 65351016ad83Smrg dir="$ladir/$objdir" 65361016ad83Smrg absdir="$abs_ladir/$objdir" 65371016ad83Smrg # Remove this search path later 65381016ad83Smrg func_append notinst_path " $abs_ladir" 65391016ad83Smrg fi 65401016ad83Smrg fi # $installed = yes 65411016ad83Smrg func_stripname 'lib' '.la' "$laname" 65421016ad83Smrg name=$func_stripname_result 65431016ad83Smrg 65441016ad83Smrg # This library was specified with -dlpreopen. 65451016ad83Smrg if test "$pass" = dlpreopen; then 65461016ad83Smrg if test -z "$libdir" && test "$linkmode" = prog; then 65471016ad83Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 65481016ad83Smrg fi 65491016ad83Smrg case "$host" in 65501016ad83Smrg # special handling for platforms with PE-DLLs. 65511016ad83Smrg *cygwin* | *mingw* | *cegcc* ) 65521016ad83Smrg # Linker will automatically link against shared library if both 65531016ad83Smrg # static and shared are present. Therefore, ensure we extract 65541016ad83Smrg # symbols from the import library if a shared library is present 65551016ad83Smrg # (otherwise, the dlopen module name will be incorrect). We do 65561016ad83Smrg # this by putting the import library name into $newdlprefiles. 65571016ad83Smrg # We recover the dlopen module name by 'saving' the la file 65581016ad83Smrg # name in a special purpose variable, and (later) extracting the 65591016ad83Smrg # dlname from the la file. 65601016ad83Smrg if test -n "$dlname"; then 65611016ad83Smrg func_tr_sh "$dir/$linklib" 65621016ad83Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 65631016ad83Smrg func_append newdlprefiles " $dir/$linklib" 65641016ad83Smrg else 65651016ad83Smrg func_append newdlprefiles " $dir/$old_library" 65661016ad83Smrg # Keep a list of preopened convenience libraries to check 65671016ad83Smrg # that they are being used correctly in the link pass. 65681016ad83Smrg test -z "$libdir" && \ 65691016ad83Smrg func_append dlpreconveniencelibs " $dir/$old_library" 65701016ad83Smrg fi 65711016ad83Smrg ;; 65721016ad83Smrg * ) 65731016ad83Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 65741016ad83Smrg # are required to link). 65751016ad83Smrg if test -n "$old_library"; then 65761016ad83Smrg func_append newdlprefiles " $dir/$old_library" 65771016ad83Smrg # Keep a list of preopened convenience libraries to check 65781016ad83Smrg # that they are being used correctly in the link pass. 65791016ad83Smrg test -z "$libdir" && \ 65801016ad83Smrg func_append dlpreconveniencelibs " $dir/$old_library" 65811016ad83Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 65821016ad83Smrg elif test -n "$dlname"; then 65831016ad83Smrg func_append newdlprefiles " $dir/$dlname" 65841016ad83Smrg else 65851016ad83Smrg func_append newdlprefiles " $dir/$linklib" 65861016ad83Smrg fi 65871016ad83Smrg ;; 65881016ad83Smrg esac 65891016ad83Smrg fi # $pass = dlpreopen 65901016ad83Smrg 65911016ad83Smrg if test -z "$libdir"; then 65921016ad83Smrg # Link the convenience library 65931016ad83Smrg if test "$linkmode" = lib; then 65941016ad83Smrg deplibs="$dir/$old_library $deplibs" 65951016ad83Smrg elif test "$linkmode,$pass" = "prog,link"; then 65961016ad83Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 65971016ad83Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 65981016ad83Smrg else 65991016ad83Smrg deplibs="$lib $deplibs" # used for prog,scan pass 66001016ad83Smrg fi 66011016ad83Smrg continue 66021016ad83Smrg fi 66031016ad83Smrg 66041016ad83Smrg 66051016ad83Smrg if test "$linkmode" = prog && test "$pass" != link; then 66061016ad83Smrg func_append newlib_search_path " $ladir" 66071016ad83Smrg deplibs="$lib $deplibs" 66081016ad83Smrg 66091016ad83Smrg linkalldeplibs=no 66101016ad83Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 66111016ad83Smrg test "$build_libtool_libs" = no; then 66121016ad83Smrg linkalldeplibs=yes 66131016ad83Smrg fi 66141016ad83Smrg 66151016ad83Smrg tmp_libs= 66161016ad83Smrg for deplib in $dependency_libs; do 66171016ad83Smrg case $deplib in 66181016ad83Smrg -L*) func_stripname '-L' '' "$deplib" 66191016ad83Smrg func_resolve_sysroot "$func_stripname_result" 66201016ad83Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 66211016ad83Smrg ;; 66221016ad83Smrg esac 66231016ad83Smrg # Need to link against all dependency_libs? 66241016ad83Smrg if test "$linkalldeplibs" = yes; then 66251016ad83Smrg deplibs="$deplib $deplibs" 66261016ad83Smrg else 66271016ad83Smrg # Need to hardcode shared library paths 66281016ad83Smrg # or/and link against static libraries 66291016ad83Smrg newdependency_libs="$deplib $newdependency_libs" 66301016ad83Smrg fi 66311016ad83Smrg if $opt_preserve_dup_deps ; then 66321016ad83Smrg case "$tmp_libs " in 66331016ad83Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 66341016ad83Smrg esac 66351016ad83Smrg fi 66361016ad83Smrg func_append tmp_libs " $deplib" 66371016ad83Smrg done # for deplib 66381016ad83Smrg continue 66391016ad83Smrg fi # $linkmode = prog... 66401016ad83Smrg 66411016ad83Smrg if test "$linkmode,$pass" = "prog,link"; then 66421016ad83Smrg if test -n "$library_names" && 66431016ad83Smrg { { test "$prefer_static_libs" = no || 66441016ad83Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 66451016ad83Smrg test -z "$old_library"; }; then 66461016ad83Smrg # We need to hardcode the library path 66471016ad83Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 66481016ad83Smrg # Make sure the rpath contains only unique directories. 66491016ad83Smrg case "$temp_rpath:" in 66501016ad83Smrg *"$absdir:"*) ;; 66511016ad83Smrg *) func_append temp_rpath "$absdir:" ;; 66521016ad83Smrg esac 66531016ad83Smrg fi 66541016ad83Smrg 66551016ad83Smrg # Hardcode the library path. 66561016ad83Smrg # Skip directories that are in the system default run-time 66571016ad83Smrg # search path. 66581016ad83Smrg case " $sys_lib_dlsearch_path " in 66591016ad83Smrg *" $absdir "*) ;; 66601016ad83Smrg *) 66611016ad83Smrg case "$compile_rpath " in 66621016ad83Smrg *" $absdir "*) ;; 66631016ad83Smrg *) func_append compile_rpath " $absdir" ;; 66641016ad83Smrg esac 66651016ad83Smrg ;; 66661016ad83Smrg esac 66671016ad83Smrg case " $sys_lib_dlsearch_path " in 66681016ad83Smrg *" $libdir "*) ;; 66691016ad83Smrg *) 66701016ad83Smrg case "$finalize_rpath " in 66711016ad83Smrg *" $libdir "*) ;; 66721016ad83Smrg *) func_append finalize_rpath " $libdir" ;; 66731016ad83Smrg esac 66741016ad83Smrg ;; 66751016ad83Smrg esac 66761016ad83Smrg fi # $linkmode,$pass = prog,link... 66771016ad83Smrg 66781016ad83Smrg if test "$alldeplibs" = yes && 66791016ad83Smrg { test "$deplibs_check_method" = pass_all || 66801016ad83Smrg { test "$build_libtool_libs" = yes && 66811016ad83Smrg test -n "$library_names"; }; }; then 66821016ad83Smrg # We only need to search for static libraries 66831016ad83Smrg continue 66841016ad83Smrg fi 66851016ad83Smrg fi 66861016ad83Smrg 66871016ad83Smrg link_static=no # Whether the deplib will be linked statically 66881016ad83Smrg use_static_libs=$prefer_static_libs 66891016ad83Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 66901016ad83Smrg use_static_libs=no 66911016ad83Smrg fi 66921016ad83Smrg if test -n "$library_names" && 66931016ad83Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 66941016ad83Smrg case $host in 66951016ad83Smrg *cygwin* | *mingw* | *cegcc*) 66961016ad83Smrg # No point in relinking DLLs because paths are not encoded 66971016ad83Smrg func_append notinst_deplibs " $lib" 66981016ad83Smrg need_relink=no 66991016ad83Smrg ;; 67001016ad83Smrg *) 67011016ad83Smrg if test "$installed" = no; then 67021016ad83Smrg func_append notinst_deplibs " $lib" 67031016ad83Smrg need_relink=yes 67041016ad83Smrg fi 67051016ad83Smrg ;; 67061016ad83Smrg esac 67071016ad83Smrg # This is a shared library 67081016ad83Smrg 67091016ad83Smrg # Warn about portability, can't link against -module's on some 67101016ad83Smrg # systems (darwin). Don't bleat about dlopened modules though! 67111016ad83Smrg dlopenmodule="" 67121016ad83Smrg for dlpremoduletest in $dlprefiles; do 67131016ad83Smrg if test "X$dlpremoduletest" = "X$lib"; then 67141016ad83Smrg dlopenmodule="$dlpremoduletest" 67151016ad83Smrg break 67161016ad83Smrg fi 67171016ad83Smrg done 67181016ad83Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 67191016ad83Smrg echo 67201016ad83Smrg if test "$linkmode" = prog; then 67211016ad83Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 67221016ad83Smrg else 67231016ad83Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 67241016ad83Smrg fi 67251016ad83Smrg $ECHO "*** $linklib is not portable!" 67261016ad83Smrg fi 67271016ad83Smrg if test "$linkmode" = lib && 67281016ad83Smrg test "$hardcode_into_libs" = yes; then 67291016ad83Smrg # Hardcode the library path. 67301016ad83Smrg # Skip directories that are in the system default run-time 67311016ad83Smrg # search path. 67321016ad83Smrg case " $sys_lib_dlsearch_path " in 67331016ad83Smrg *" $absdir "*) ;; 67341016ad83Smrg *) 67351016ad83Smrg case "$compile_rpath " in 67361016ad83Smrg *" $absdir "*) ;; 67371016ad83Smrg *) func_append compile_rpath " $absdir" ;; 67381016ad83Smrg esac 67391016ad83Smrg ;; 67401016ad83Smrg esac 67411016ad83Smrg case " $sys_lib_dlsearch_path " in 67421016ad83Smrg *" $libdir "*) ;; 67431016ad83Smrg *) 67441016ad83Smrg case "$finalize_rpath " in 67451016ad83Smrg *" $libdir "*) ;; 67461016ad83Smrg *) func_append finalize_rpath " $libdir" ;; 67471016ad83Smrg esac 67481016ad83Smrg ;; 67491016ad83Smrg esac 67501016ad83Smrg fi 67511016ad83Smrg 67521016ad83Smrg if test -n "$old_archive_from_expsyms_cmds"; then 67531016ad83Smrg # figure out the soname 67541016ad83Smrg set dummy $library_names 67551016ad83Smrg shift 67561016ad83Smrg realname="$1" 67571016ad83Smrg shift 67581016ad83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 67591016ad83Smrg # use dlname if we got it. it's perfectly good, no? 67601016ad83Smrg if test -n "$dlname"; then 67611016ad83Smrg soname="$dlname" 67621016ad83Smrg elif test -n "$soname_spec"; then 67631016ad83Smrg # bleh windows 67641016ad83Smrg case $host in 67651016ad83Smrg *cygwin* | mingw* | *cegcc*) 67661016ad83Smrg func_arith $current - $age 67671016ad83Smrg major=$func_arith_result 67681016ad83Smrg versuffix="-$major" 67691016ad83Smrg ;; 67701016ad83Smrg esac 67711016ad83Smrg eval soname=\"$soname_spec\" 67721016ad83Smrg else 67731016ad83Smrg soname="$realname" 67741016ad83Smrg fi 67751016ad83Smrg 67761016ad83Smrg # Make a new name for the extract_expsyms_cmds to use 67771016ad83Smrg soroot="$soname" 67781016ad83Smrg func_basename "$soroot" 67791016ad83Smrg soname="$func_basename_result" 67801016ad83Smrg func_stripname 'lib' '.dll' "$soname" 67811016ad83Smrg newlib=libimp-$func_stripname_result.a 67821016ad83Smrg 67831016ad83Smrg # If the library has no export list, then create one now 67841016ad83Smrg if test -f "$output_objdir/$soname-def"; then : 67851016ad83Smrg else 67861016ad83Smrg func_verbose "extracting exported symbol list from \`$soname'" 67871016ad83Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 67881016ad83Smrg fi 67891016ad83Smrg 67901016ad83Smrg # Create $newlib 67911016ad83Smrg if test -f "$output_objdir/$newlib"; then :; else 67921016ad83Smrg func_verbose "generating import library for \`$soname'" 67931016ad83Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 67941016ad83Smrg fi 67951016ad83Smrg # make sure the library variables are pointing to the new library 67961016ad83Smrg dir=$output_objdir 67971016ad83Smrg linklib=$newlib 67981016ad83Smrg fi # test -n "$old_archive_from_expsyms_cmds" 67991016ad83Smrg 68001016ad83Smrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 68011016ad83Smrg add_shlibpath= 68021016ad83Smrg add_dir= 68031016ad83Smrg add= 68041016ad83Smrg lib_linked=yes 68051016ad83Smrg case $hardcode_action in 68061016ad83Smrg immediate | unsupported) 68071016ad83Smrg if test "$hardcode_direct" = no; then 68081016ad83Smrg add="$dir/$linklib" 68091016ad83Smrg case $host in 68101016ad83Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 68111016ad83Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 68121016ad83Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 68131016ad83Smrg *-*-unixware7*) add_dir="-L$dir" ;; 68141016ad83Smrg *-*-darwin* ) 68151016ad83Smrg # if the lib is a (non-dlopened) module then we can not 68161016ad83Smrg # link against it, someone is ignoring the earlier warnings 68171016ad83Smrg if /usr/bin/file -L $add 2> /dev/null | 68181016ad83Smrg $GREP ": [^:]* bundle" >/dev/null ; then 68191016ad83Smrg if test "X$dlopenmodule" != "X$lib"; then 68201016ad83Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 68211016ad83Smrg if test -z "$old_library" ; then 68221016ad83Smrg echo 68231016ad83Smrg echo "*** And there doesn't seem to be a static archive available" 68241016ad83Smrg echo "*** The link will probably fail, sorry" 68251016ad83Smrg else 68261016ad83Smrg add="$dir/$old_library" 68271016ad83Smrg fi 68281016ad83Smrg elif test -n "$old_library"; then 68291016ad83Smrg add="$dir/$old_library" 68301016ad83Smrg fi 68311016ad83Smrg fi 68321016ad83Smrg esac 68331016ad83Smrg elif test "$hardcode_minus_L" = no; then 68341016ad83Smrg case $host in 68351016ad83Smrg *-*-sunos*) add_shlibpath="$dir" ;; 68361016ad83Smrg esac 68371016ad83Smrg add_dir="-L$dir" 68381016ad83Smrg add="-l$name" 68391016ad83Smrg elif test "$hardcode_shlibpath_var" = no; then 68401016ad83Smrg add_shlibpath="$dir" 68411016ad83Smrg add="-l$name" 68421016ad83Smrg else 68431016ad83Smrg lib_linked=no 68441016ad83Smrg fi 68451016ad83Smrg ;; 68461016ad83Smrg relink) 68471016ad83Smrg if test "$hardcode_direct" = yes && 68481016ad83Smrg test "$hardcode_direct_absolute" = no; then 68491016ad83Smrg add="$dir/$linklib" 68501016ad83Smrg elif test "$hardcode_minus_L" = yes; then 68511016ad83Smrg add_dir="-L$absdir" 68521016ad83Smrg # Try looking first in the location we're being installed to. 68531016ad83Smrg if test -n "$inst_prefix_dir"; then 68541016ad83Smrg case $libdir in 68551016ad83Smrg [\\/]*) 68561016ad83Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 68571016ad83Smrg ;; 68581016ad83Smrg esac 68591016ad83Smrg fi 68601016ad83Smrg add="-l$name" 68611016ad83Smrg elif test "$hardcode_shlibpath_var" = yes; then 68621016ad83Smrg add_shlibpath="$dir" 68631016ad83Smrg add="-l$name" 68641016ad83Smrg else 68651016ad83Smrg lib_linked=no 68661016ad83Smrg fi 68671016ad83Smrg ;; 68681016ad83Smrg *) lib_linked=no ;; 68691016ad83Smrg esac 68701016ad83Smrg 68711016ad83Smrg if test "$lib_linked" != yes; then 68721016ad83Smrg func_fatal_configuration "unsupported hardcode properties" 68731016ad83Smrg fi 68741016ad83Smrg 68751016ad83Smrg if test -n "$add_shlibpath"; then 68761016ad83Smrg case :$compile_shlibpath: in 68771016ad83Smrg *":$add_shlibpath:"*) ;; 68781016ad83Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 68791016ad83Smrg esac 68801016ad83Smrg fi 68811016ad83Smrg if test "$linkmode" = prog; then 68821016ad83Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 68831016ad83Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 68841016ad83Smrg else 68851016ad83Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 68861016ad83Smrg test -n "$add" && deplibs="$add $deplibs" 68871016ad83Smrg if test "$hardcode_direct" != yes && 68881016ad83Smrg test "$hardcode_minus_L" != yes && 68891016ad83Smrg test "$hardcode_shlibpath_var" = yes; then 68901016ad83Smrg case :$finalize_shlibpath: in 68911016ad83Smrg *":$libdir:"*) ;; 68921016ad83Smrg *) func_append finalize_shlibpath "$libdir:" ;; 68931016ad83Smrg esac 68941016ad83Smrg fi 68951016ad83Smrg fi 68961016ad83Smrg fi 68971016ad83Smrg 68981016ad83Smrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 68991016ad83Smrg add_shlibpath= 69001016ad83Smrg add_dir= 69011016ad83Smrg add= 69021016ad83Smrg # Finalize command for both is simple: just hardcode it. 69031016ad83Smrg if test "$hardcode_direct" = yes && 69041016ad83Smrg test "$hardcode_direct_absolute" = no; then 69051016ad83Smrg add="$libdir/$linklib" 69061016ad83Smrg elif test "$hardcode_minus_L" = yes; then 69071016ad83Smrg add_dir="-L$libdir" 69081016ad83Smrg add="-l$name" 69091016ad83Smrg elif test "$hardcode_shlibpath_var" = yes; then 69101016ad83Smrg case :$finalize_shlibpath: in 69111016ad83Smrg *":$libdir:"*) ;; 69121016ad83Smrg *) func_append finalize_shlibpath "$libdir:" ;; 69131016ad83Smrg esac 69141016ad83Smrg add="-l$name" 69151016ad83Smrg elif test "$hardcode_automatic" = yes; then 69161016ad83Smrg if test -n "$inst_prefix_dir" && 69171016ad83Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 69181016ad83Smrg add="$inst_prefix_dir$libdir/$linklib" 69191016ad83Smrg else 69201016ad83Smrg add="$libdir/$linklib" 69211016ad83Smrg fi 69221016ad83Smrg else 69231016ad83Smrg # We cannot seem to hardcode it, guess we'll fake it. 69241016ad83Smrg add_dir="-L$libdir" 69251016ad83Smrg # Try looking first in the location we're being installed to. 69261016ad83Smrg if test -n "$inst_prefix_dir"; then 69271016ad83Smrg case $libdir in 69281016ad83Smrg [\\/]*) 69291016ad83Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 69301016ad83Smrg ;; 69311016ad83Smrg esac 69321016ad83Smrg fi 69331016ad83Smrg add="-l$name" 69341016ad83Smrg fi 69351016ad83Smrg 69361016ad83Smrg if test "$linkmode" = prog; then 69371016ad83Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 69381016ad83Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 69391016ad83Smrg else 69401016ad83Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 69411016ad83Smrg test -n "$add" && deplibs="$add $deplibs" 69421016ad83Smrg fi 69431016ad83Smrg fi 69441016ad83Smrg elif test "$linkmode" = prog; then 69451016ad83Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 69461016ad83Smrg # is not unsupported. This is valid on all known static and 69471016ad83Smrg # shared platforms. 69481016ad83Smrg if test "$hardcode_direct" != unsupported; then 69491016ad83Smrg test -n "$old_library" && linklib="$old_library" 69501016ad83Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 69511016ad83Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 69521016ad83Smrg else 69531016ad83Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 69541016ad83Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 69551016ad83Smrg fi 69561016ad83Smrg elif test "$build_libtool_libs" = yes; then 69571016ad83Smrg # Not a shared library 69581016ad83Smrg if test "$deplibs_check_method" != pass_all; then 69591016ad83Smrg # We're trying link a shared library against a static one 69601016ad83Smrg # but the system doesn't support it. 69611016ad83Smrg 69621016ad83Smrg # Just print a warning and add the library to dependency_libs so 69631016ad83Smrg # that the program can be linked against the static library. 69641016ad83Smrg echo 69651016ad83Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 69661016ad83Smrg echo "*** I have the capability to make that library automatically link in when" 69671016ad83Smrg echo "*** you link to this library. But I can only do this if you have a" 69681016ad83Smrg echo "*** shared version of the library, which you do not appear to have." 69691016ad83Smrg if test "$module" = yes; then 69701016ad83Smrg echo "*** But as you try to build a module library, libtool will still create " 69711016ad83Smrg echo "*** a static module, that should work as long as the dlopening application" 69721016ad83Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 69731016ad83Smrg if test -z "$global_symbol_pipe"; then 69741016ad83Smrg echo 69751016ad83Smrg echo "*** However, this would only work if libtool was able to extract symbol" 69761016ad83Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 69771016ad83Smrg echo "*** not find such a program. So, this module is probably useless." 69781016ad83Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 69791016ad83Smrg fi 69801016ad83Smrg if test "$build_old_libs" = no; then 69811016ad83Smrg build_libtool_libs=module 69821016ad83Smrg build_old_libs=yes 69831016ad83Smrg else 69841016ad83Smrg build_libtool_libs=no 69851016ad83Smrg fi 69861016ad83Smrg fi 69871016ad83Smrg else 69881016ad83Smrg deplibs="$dir/$old_library $deplibs" 69891016ad83Smrg link_static=yes 69901016ad83Smrg fi 69911016ad83Smrg fi # link shared/static library? 69921016ad83Smrg 69931016ad83Smrg if test "$linkmode" = lib; then 69941016ad83Smrg if test -n "$dependency_libs" && 69951016ad83Smrg { test "$hardcode_into_libs" != yes || 69961016ad83Smrg test "$build_old_libs" = yes || 69971016ad83Smrg test "$link_static" = yes; }; then 69981016ad83Smrg # Extract -R from dependency_libs 69991016ad83Smrg temp_deplibs= 70001016ad83Smrg for libdir in $dependency_libs; do 70011016ad83Smrg case $libdir in 70021016ad83Smrg -R*) func_stripname '-R' '' "$libdir" 70031016ad83Smrg temp_xrpath=$func_stripname_result 70041016ad83Smrg case " $xrpath " in 70051016ad83Smrg *" $temp_xrpath "*) ;; 70061016ad83Smrg *) func_append xrpath " $temp_xrpath";; 70071016ad83Smrg esac;; 70081016ad83Smrg *) func_append temp_deplibs " $libdir";; 70091016ad83Smrg esac 70101016ad83Smrg done 70111016ad83Smrg dependency_libs="$temp_deplibs" 70121016ad83Smrg fi 70131016ad83Smrg 70141016ad83Smrg func_append newlib_search_path " $absdir" 70151016ad83Smrg # Link against this library 70161016ad83Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 70171016ad83Smrg # ... and its dependency_libs 70181016ad83Smrg tmp_libs= 70191016ad83Smrg for deplib in $dependency_libs; do 70201016ad83Smrg newdependency_libs="$deplib $newdependency_libs" 70211016ad83Smrg case $deplib in 70221016ad83Smrg -L*) func_stripname '-L' '' "$deplib" 70231016ad83Smrg func_resolve_sysroot "$func_stripname_result";; 70241016ad83Smrg *) func_resolve_sysroot "$deplib" ;; 70251016ad83Smrg esac 70261016ad83Smrg if $opt_preserve_dup_deps ; then 70271016ad83Smrg case "$tmp_libs " in 70281016ad83Smrg *" $func_resolve_sysroot_result "*) 70291016ad83Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 70301016ad83Smrg esac 70311016ad83Smrg fi 70321016ad83Smrg func_append tmp_libs " $func_resolve_sysroot_result" 70331016ad83Smrg done 70341016ad83Smrg 70351016ad83Smrg if test "$link_all_deplibs" != no; then 70361016ad83Smrg # Add the search paths of all dependency libraries 70371016ad83Smrg for deplib in $dependency_libs; do 70381016ad83Smrg path= 70391016ad83Smrg case $deplib in 70401016ad83Smrg -L*) path="$deplib" ;; 70411016ad83Smrg *.la) 70421016ad83Smrg func_resolve_sysroot "$deplib" 70431016ad83Smrg deplib=$func_resolve_sysroot_result 70441016ad83Smrg func_dirname "$deplib" "" "." 70451016ad83Smrg dir=$func_dirname_result 70461016ad83Smrg # We need an absolute path. 70471016ad83Smrg case $dir in 70481016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 70491016ad83Smrg *) 70501016ad83Smrg absdir=`cd "$dir" && pwd` 70511016ad83Smrg if test -z "$absdir"; then 70521016ad83Smrg func_warning "cannot determine absolute directory name of \`$dir'" 70531016ad83Smrg absdir="$dir" 70541016ad83Smrg fi 70551016ad83Smrg ;; 70561016ad83Smrg esac 70571016ad83Smrg if $GREP "^installed=no" $deplib > /dev/null; then 70581016ad83Smrg case $host in 70591016ad83Smrg *-*-darwin*) 70601016ad83Smrg depdepl= 70611016ad83Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 70621016ad83Smrg if test -n "$deplibrary_names" ; then 70631016ad83Smrg for tmp in $deplibrary_names ; do 70641016ad83Smrg depdepl=$tmp 70651016ad83Smrg done 70661016ad83Smrg if test -f "$absdir/$objdir/$depdepl" ; then 70671016ad83Smrg depdepl="$absdir/$objdir/$depdepl" 70681016ad83Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 70691016ad83Smrg if test -z "$darwin_install_name"; then 70701016ad83Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 70711016ad83Smrg fi 70721016ad83Smrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 70731016ad83Smrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 70741016ad83Smrg path= 70751016ad83Smrg fi 70761016ad83Smrg fi 70771016ad83Smrg ;; 70781016ad83Smrg *) 70791016ad83Smrg path="-L$absdir/$objdir" 70801016ad83Smrg ;; 70811016ad83Smrg esac 70821016ad83Smrg else 70831016ad83Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 70841016ad83Smrg test -z "$libdir" && \ 70851016ad83Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 70861016ad83Smrg test "$absdir" != "$libdir" && \ 70871016ad83Smrg func_warning "\`$deplib' seems to be moved" 70881016ad83Smrg 70891016ad83Smrg path="-L$absdir" 70901016ad83Smrg fi 70911016ad83Smrg ;; 70921016ad83Smrg esac 70931016ad83Smrg case " $deplibs " in 70941016ad83Smrg *" $path "*) ;; 70951016ad83Smrg *) deplibs="$path $deplibs" ;; 70961016ad83Smrg esac 70971016ad83Smrg done 70981016ad83Smrg fi # link_all_deplibs != no 70991016ad83Smrg fi # linkmode = lib 71001016ad83Smrg done # for deplib in $libs 71011016ad83Smrg if test "$pass" = link; then 71021016ad83Smrg if test "$linkmode" = "prog"; then 71031016ad83Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 71041016ad83Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 71051016ad83Smrg else 71061016ad83Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 71071016ad83Smrg fi 71081016ad83Smrg fi 71091016ad83Smrg dependency_libs="$newdependency_libs" 71101016ad83Smrg if test "$pass" = dlpreopen; then 71111016ad83Smrg # Link the dlpreopened libraries before other libraries 71121016ad83Smrg for deplib in $save_deplibs; do 71131016ad83Smrg deplibs="$deplib $deplibs" 71141016ad83Smrg done 71151016ad83Smrg fi 71161016ad83Smrg if test "$pass" != dlopen; then 71171016ad83Smrg if test "$pass" != conv; then 71181016ad83Smrg # Make sure lib_search_path contains only unique directories. 71191016ad83Smrg lib_search_path= 71201016ad83Smrg for dir in $newlib_search_path; do 71211016ad83Smrg case "$lib_search_path " in 71221016ad83Smrg *" $dir "*) ;; 71231016ad83Smrg *) func_append lib_search_path " $dir" ;; 71241016ad83Smrg esac 71251016ad83Smrg done 71261016ad83Smrg newlib_search_path= 71271016ad83Smrg fi 71281016ad83Smrg 71291016ad83Smrg if test "$linkmode,$pass" != "prog,link"; then 71301016ad83Smrg vars="deplibs" 71311016ad83Smrg else 71321016ad83Smrg vars="compile_deplibs finalize_deplibs" 71331016ad83Smrg fi 71341016ad83Smrg for var in $vars dependency_libs; do 71351016ad83Smrg # Add libraries to $var in reverse order 71361016ad83Smrg eval tmp_libs=\"\$$var\" 71371016ad83Smrg new_libs= 71381016ad83Smrg for deplib in $tmp_libs; do 71391016ad83Smrg # FIXME: Pedantically, this is the right thing to do, so 71401016ad83Smrg # that some nasty dependency loop isn't accidentally 71411016ad83Smrg # broken: 71421016ad83Smrg #new_libs="$deplib $new_libs" 71431016ad83Smrg # Pragmatically, this seems to cause very few problems in 71441016ad83Smrg # practice: 71451016ad83Smrg case $deplib in 71461016ad83Smrg -L*) new_libs="$deplib $new_libs" ;; 71471016ad83Smrg -R*) ;; 71481016ad83Smrg *) 71491016ad83Smrg # And here is the reason: when a library appears more 71501016ad83Smrg # than once as an explicit dependence of a library, or 71511016ad83Smrg # is implicitly linked in more than once by the 71521016ad83Smrg # compiler, it is considered special, and multiple 71531016ad83Smrg # occurrences thereof are not removed. Compare this 71541016ad83Smrg # with having the same library being listed as a 71551016ad83Smrg # dependency of multiple other libraries: in this case, 71561016ad83Smrg # we know (pedantically, we assume) the library does not 71571016ad83Smrg # need to be listed more than once, so we keep only the 71581016ad83Smrg # last copy. This is not always right, but it is rare 71591016ad83Smrg # enough that we require users that really mean to play 71601016ad83Smrg # such unportable linking tricks to link the library 71611016ad83Smrg # using -Wl,-lname, so that libtool does not consider it 71621016ad83Smrg # for duplicate removal. 71631016ad83Smrg case " $specialdeplibs " in 71641016ad83Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 71651016ad83Smrg *) 71661016ad83Smrg case " $new_libs " in 71671016ad83Smrg *" $deplib "*) ;; 71681016ad83Smrg *) new_libs="$deplib $new_libs" ;; 71691016ad83Smrg esac 71701016ad83Smrg ;; 71711016ad83Smrg esac 71721016ad83Smrg ;; 71731016ad83Smrg esac 71741016ad83Smrg done 71751016ad83Smrg tmp_libs= 71761016ad83Smrg for deplib in $new_libs; do 71771016ad83Smrg case $deplib in 71781016ad83Smrg -L*) 71791016ad83Smrg case " $tmp_libs " in 71801016ad83Smrg *" $deplib "*) ;; 71811016ad83Smrg *) func_append tmp_libs " $deplib" ;; 71821016ad83Smrg esac 71831016ad83Smrg ;; 71841016ad83Smrg *) func_append tmp_libs " $deplib" ;; 71851016ad83Smrg esac 71861016ad83Smrg done 71871016ad83Smrg eval $var=\"$tmp_libs\" 71881016ad83Smrg done # for var 71891016ad83Smrg fi 71901016ad83Smrg # Last step: remove runtime libs from dependency_libs 71911016ad83Smrg # (they stay in deplibs) 71921016ad83Smrg tmp_libs= 71931016ad83Smrg for i in $dependency_libs ; do 71941016ad83Smrg case " $predeps $postdeps $compiler_lib_search_path " in 71951016ad83Smrg *" $i "*) 71961016ad83Smrg i="" 71971016ad83Smrg ;; 71981016ad83Smrg esac 71991016ad83Smrg if test -n "$i" ; then 72001016ad83Smrg func_append tmp_libs " $i" 72011016ad83Smrg fi 72021016ad83Smrg done 72031016ad83Smrg dependency_libs=$tmp_libs 72041016ad83Smrg done # for pass 72051016ad83Smrg if test "$linkmode" = prog; then 72061016ad83Smrg dlfiles="$newdlfiles" 72071016ad83Smrg fi 72081016ad83Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 72091016ad83Smrg dlprefiles="$newdlprefiles" 72101016ad83Smrg fi 72111016ad83Smrg 72121016ad83Smrg case $linkmode in 72131016ad83Smrg oldlib) 72141016ad83Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 72151016ad83Smrg func_warning "\`-dlopen' is ignored for archives" 72161016ad83Smrg fi 72171016ad83Smrg 72181016ad83Smrg case " $deplibs" in 72191016ad83Smrg *\ -l* | *\ -L*) 72201016ad83Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 72211016ad83Smrg esac 72221016ad83Smrg 72231016ad83Smrg test -n "$rpath" && \ 72241016ad83Smrg func_warning "\`-rpath' is ignored for archives" 72251016ad83Smrg 72261016ad83Smrg test -n "$xrpath" && \ 72271016ad83Smrg func_warning "\`-R' is ignored for archives" 72281016ad83Smrg 72291016ad83Smrg test -n "$vinfo" && \ 72301016ad83Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 72311016ad83Smrg 72321016ad83Smrg test -n "$release" && \ 72331016ad83Smrg func_warning "\`-release' is ignored for archives" 72341016ad83Smrg 72351016ad83Smrg test -n "$export_symbols$export_symbols_regex" && \ 72361016ad83Smrg func_warning "\`-export-symbols' is ignored for archives" 72371016ad83Smrg 72381016ad83Smrg # Now set the variables for building old libraries. 72391016ad83Smrg build_libtool_libs=no 72401016ad83Smrg oldlibs="$output" 72411016ad83Smrg func_append objs "$old_deplibs" 72421016ad83Smrg ;; 72431016ad83Smrg 72441016ad83Smrg lib) 72451016ad83Smrg # Make sure we only generate libraries of the form `libNAME.la'. 72461016ad83Smrg case $outputname in 72471016ad83Smrg lib*) 72481016ad83Smrg func_stripname 'lib' '.la' "$outputname" 72491016ad83Smrg name=$func_stripname_result 72501016ad83Smrg eval shared_ext=\"$shrext_cmds\" 72511016ad83Smrg eval libname=\"$libname_spec\" 72521016ad83Smrg ;; 72531016ad83Smrg *) 72541016ad83Smrg test "$module" = no && \ 72551016ad83Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 72561016ad83Smrg 72571016ad83Smrg if test "$need_lib_prefix" != no; then 72581016ad83Smrg # Add the "lib" prefix for modules if required 72591016ad83Smrg func_stripname '' '.la' "$outputname" 72601016ad83Smrg name=$func_stripname_result 72611016ad83Smrg eval shared_ext=\"$shrext_cmds\" 72621016ad83Smrg eval libname=\"$libname_spec\" 72631016ad83Smrg else 72641016ad83Smrg func_stripname '' '.la' "$outputname" 72651016ad83Smrg libname=$func_stripname_result 72661016ad83Smrg fi 72671016ad83Smrg ;; 72681016ad83Smrg esac 72691016ad83Smrg 72701016ad83Smrg if test -n "$objs"; then 72711016ad83Smrg if test "$deplibs_check_method" != pass_all; then 72721016ad83Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 72731016ad83Smrg else 72741016ad83Smrg echo 72751016ad83Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 72761016ad83Smrg $ECHO "*** objects $objs is not portable!" 72771016ad83Smrg func_append libobjs " $objs" 72781016ad83Smrg fi 72791016ad83Smrg fi 72801016ad83Smrg 72811016ad83Smrg test "$dlself" != no && \ 72821016ad83Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 72831016ad83Smrg 72841016ad83Smrg set dummy $rpath 72851016ad83Smrg shift 72861016ad83Smrg test "$#" -gt 1 && \ 72871016ad83Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 72881016ad83Smrg 72891016ad83Smrg install_libdir="$1" 72901016ad83Smrg 72911016ad83Smrg oldlibs= 72921016ad83Smrg if test -z "$rpath"; then 72931016ad83Smrg if test "$build_libtool_libs" = yes; then 72941016ad83Smrg # Building a libtool convenience library. 72951016ad83Smrg # Some compilers have problems with a `.al' extension so 72961016ad83Smrg # convenience libraries should have the same extension an 72971016ad83Smrg # archive normally would. 72981016ad83Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 72991016ad83Smrg build_libtool_libs=convenience 73001016ad83Smrg build_old_libs=yes 73011016ad83Smrg fi 73021016ad83Smrg 73031016ad83Smrg test -n "$vinfo" && \ 73041016ad83Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 73051016ad83Smrg 73061016ad83Smrg test -n "$release" && \ 73071016ad83Smrg func_warning "\`-release' is ignored for convenience libraries" 73081016ad83Smrg else 73091016ad83Smrg 73101016ad83Smrg # Parse the version information argument. 73111016ad83Smrg save_ifs="$IFS"; IFS=':' 73121016ad83Smrg set dummy $vinfo 0 0 0 73131016ad83Smrg shift 73141016ad83Smrg IFS="$save_ifs" 73151016ad83Smrg 73161016ad83Smrg test -n "$7" && \ 73171016ad83Smrg func_fatal_help "too many parameters to \`-version-info'" 73181016ad83Smrg 73191016ad83Smrg # convert absolute version numbers to libtool ages 73201016ad83Smrg # this retains compatibility with .la files and attempts 73211016ad83Smrg # to make the code below a bit more comprehensible 73221016ad83Smrg 73231016ad83Smrg case $vinfo_number in 73241016ad83Smrg yes) 73251016ad83Smrg number_major="$1" 73261016ad83Smrg number_minor="$2" 73271016ad83Smrg number_revision="$3" 73281016ad83Smrg # 73291016ad83Smrg # There are really only two kinds -- those that 73301016ad83Smrg # use the current revision as the major version 73311016ad83Smrg # and those that subtract age and use age as 73321016ad83Smrg # a minor version. But, then there is irix 73331016ad83Smrg # which has an extra 1 added just for fun 73341016ad83Smrg # 73351016ad83Smrg case $version_type in 73361016ad83Smrg # correct linux to gnu/linux during the next big refactor 73371016ad83Smrg darwin|linux|osf|windows|none) 73381016ad83Smrg func_arith $number_major + $number_minor 73391016ad83Smrg current=$func_arith_result 73401016ad83Smrg age="$number_minor" 73411016ad83Smrg revision="$number_revision" 73421016ad83Smrg ;; 73431016ad83Smrg freebsd-aout|freebsd-elf|qnx|sunos) 73441016ad83Smrg current="$number_major" 73451016ad83Smrg revision="$number_minor" 73461016ad83Smrg age="0" 73471016ad83Smrg ;; 73481016ad83Smrg irix|nonstopux) 73491016ad83Smrg func_arith $number_major + $number_minor 73501016ad83Smrg current=$func_arith_result 73511016ad83Smrg age="$number_minor" 73521016ad83Smrg revision="$number_minor" 73531016ad83Smrg lt_irix_increment=no 73541016ad83Smrg ;; 73551016ad83Smrg *) 73561016ad83Smrg func_fatal_configuration "$modename: unknown library version type \`$version_type'" 73571016ad83Smrg ;; 73581016ad83Smrg esac 73591016ad83Smrg ;; 73601016ad83Smrg no) 73611016ad83Smrg current="$1" 73621016ad83Smrg revision="$2" 73631016ad83Smrg age="$3" 73641016ad83Smrg ;; 73651016ad83Smrg esac 73661016ad83Smrg 73671016ad83Smrg # Check that each of the things are valid numbers. 73681016ad83Smrg case $current in 73691016ad83Smrg 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]) ;; 73701016ad83Smrg *) 73711016ad83Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 73721016ad83Smrg func_fatal_error "\`$vinfo' is not valid version information" 73731016ad83Smrg ;; 73741016ad83Smrg esac 73751016ad83Smrg 73761016ad83Smrg case $revision in 73771016ad83Smrg 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]) ;; 73781016ad83Smrg *) 73791016ad83Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 73801016ad83Smrg func_fatal_error "\`$vinfo' is not valid version information" 73811016ad83Smrg ;; 73821016ad83Smrg esac 73831016ad83Smrg 73841016ad83Smrg case $age in 73851016ad83Smrg 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]) ;; 73861016ad83Smrg *) 73871016ad83Smrg func_error "AGE \`$age' must be a nonnegative integer" 73881016ad83Smrg func_fatal_error "\`$vinfo' is not valid version information" 73891016ad83Smrg ;; 73901016ad83Smrg esac 73911016ad83Smrg 73921016ad83Smrg if test "$age" -gt "$current"; then 73931016ad83Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 73941016ad83Smrg func_fatal_error "\`$vinfo' is not valid version information" 73951016ad83Smrg fi 73961016ad83Smrg 73971016ad83Smrg # Calculate the version variables. 73981016ad83Smrg major= 73991016ad83Smrg versuffix= 74001016ad83Smrg verstring= 74011016ad83Smrg case $version_type in 74021016ad83Smrg none) ;; 74031016ad83Smrg 74041016ad83Smrg darwin) 74051016ad83Smrg # Like Linux, but with the current version available in 74061016ad83Smrg # verstring for coding it into the library header 74071016ad83Smrg func_arith $current - $age 74081016ad83Smrg major=.$func_arith_result 74091016ad83Smrg versuffix="$major.$age.$revision" 74101016ad83Smrg # Darwin ld doesn't like 0 for these options... 74111016ad83Smrg func_arith $current + 1 74121016ad83Smrg minor_current=$func_arith_result 74131016ad83Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 74141016ad83Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 74151016ad83Smrg ;; 74161016ad83Smrg 74171016ad83Smrg freebsd-aout) 74181016ad83Smrg major=".$current" 74191016ad83Smrg versuffix=".$current.$revision"; 74201016ad83Smrg ;; 74211016ad83Smrg 74221016ad83Smrg freebsd-elf) 74231016ad83Smrg major=".$current" 74241016ad83Smrg versuffix=".$current" 74251016ad83Smrg ;; 74261016ad83Smrg 74271016ad83Smrg irix | nonstopux) 74281016ad83Smrg if test "X$lt_irix_increment" = "Xno"; then 74291016ad83Smrg func_arith $current - $age 74301016ad83Smrg else 74311016ad83Smrg func_arith $current - $age + 1 74321016ad83Smrg fi 74331016ad83Smrg major=$func_arith_result 74341016ad83Smrg 74351016ad83Smrg case $version_type in 74361016ad83Smrg nonstopux) verstring_prefix=nonstopux ;; 74371016ad83Smrg *) verstring_prefix=sgi ;; 74381016ad83Smrg esac 74391016ad83Smrg verstring="$verstring_prefix$major.$revision" 74401016ad83Smrg 74411016ad83Smrg # Add in all the interfaces that we are compatible with. 74421016ad83Smrg loop=$revision 74431016ad83Smrg while test "$loop" -ne 0; do 74441016ad83Smrg func_arith $revision - $loop 74451016ad83Smrg iface=$func_arith_result 74461016ad83Smrg func_arith $loop - 1 74471016ad83Smrg loop=$func_arith_result 74481016ad83Smrg verstring="$verstring_prefix$major.$iface:$verstring" 74491016ad83Smrg done 74501016ad83Smrg 74511016ad83Smrg # Before this point, $major must not contain `.'. 74521016ad83Smrg major=.$major 74531016ad83Smrg versuffix="$major.$revision" 74541016ad83Smrg ;; 74551016ad83Smrg 74561016ad83Smrg linux) # correct to gnu/linux during the next big refactor 74571016ad83Smrg func_arith $current - $age 74581016ad83Smrg major=.$func_arith_result 74591016ad83Smrg versuffix="$major.$age.$revision" 74601016ad83Smrg ;; 74611016ad83Smrg 74621016ad83Smrg osf) 74631016ad83Smrg func_arith $current - $age 74641016ad83Smrg major=.$func_arith_result 74651016ad83Smrg versuffix=".$current.$age.$revision" 74661016ad83Smrg verstring="$current.$age.$revision" 74671016ad83Smrg 74681016ad83Smrg # Add in all the interfaces that we are compatible with. 74691016ad83Smrg loop=$age 74701016ad83Smrg while test "$loop" -ne 0; do 74711016ad83Smrg func_arith $current - $loop 74721016ad83Smrg iface=$func_arith_result 74731016ad83Smrg func_arith $loop - 1 74741016ad83Smrg loop=$func_arith_result 74751016ad83Smrg verstring="$verstring:${iface}.0" 74761016ad83Smrg done 74771016ad83Smrg 74781016ad83Smrg # Make executables depend on our current version. 74791016ad83Smrg func_append verstring ":${current}.0" 74801016ad83Smrg ;; 74811016ad83Smrg 74821016ad83Smrg qnx) 74831016ad83Smrg major=".$current" 74841016ad83Smrg versuffix=".$current" 74851016ad83Smrg ;; 74861016ad83Smrg 74871016ad83Smrg sunos) 74881016ad83Smrg major=".$current" 74891016ad83Smrg versuffix=".$current.$revision" 74901016ad83Smrg ;; 74911016ad83Smrg 74921016ad83Smrg windows) 74931016ad83Smrg # Use '-' rather than '.', since we only want one 74941016ad83Smrg # extension on DOS 8.3 filesystems. 74951016ad83Smrg func_arith $current - $age 74961016ad83Smrg major=$func_arith_result 74971016ad83Smrg versuffix="-$major" 74981016ad83Smrg ;; 74991016ad83Smrg 75001016ad83Smrg *) 75011016ad83Smrg func_fatal_configuration "unknown library version type \`$version_type'" 75021016ad83Smrg ;; 75031016ad83Smrg esac 75041016ad83Smrg 75051016ad83Smrg # Clear the version info if we defaulted, and they specified a release. 75061016ad83Smrg if test -z "$vinfo" && test -n "$release"; then 75071016ad83Smrg major= 75081016ad83Smrg case $version_type in 75091016ad83Smrg darwin) 75101016ad83Smrg # we can't check for "0.0" in archive_cmds due to quoting 75111016ad83Smrg # problems, so we reset it completely 75121016ad83Smrg verstring= 75131016ad83Smrg ;; 75141016ad83Smrg *) 75151016ad83Smrg verstring="0.0" 75161016ad83Smrg ;; 75171016ad83Smrg esac 75181016ad83Smrg if test "$need_version" = no; then 75191016ad83Smrg versuffix= 75201016ad83Smrg else 75211016ad83Smrg versuffix=".0.0" 75221016ad83Smrg fi 75231016ad83Smrg fi 75241016ad83Smrg 75251016ad83Smrg # Remove version info from name if versioning should be avoided 75261016ad83Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 75271016ad83Smrg major= 75281016ad83Smrg versuffix= 75291016ad83Smrg verstring="" 75301016ad83Smrg fi 75311016ad83Smrg 75321016ad83Smrg # Check to see if the archive will have undefined symbols. 75331016ad83Smrg if test "$allow_undefined" = yes; then 75341016ad83Smrg if test "$allow_undefined_flag" = unsupported; then 75351016ad83Smrg func_warning "undefined symbols not allowed in $host shared libraries" 75361016ad83Smrg build_libtool_libs=no 75371016ad83Smrg build_old_libs=yes 75381016ad83Smrg fi 75391016ad83Smrg else 75401016ad83Smrg # Don't allow undefined symbols. 75411016ad83Smrg allow_undefined_flag="$no_undefined_flag" 75421016ad83Smrg fi 75431016ad83Smrg 75441016ad83Smrg fi 75451016ad83Smrg 75461016ad83Smrg func_generate_dlsyms "$libname" "$libname" "yes" 75471016ad83Smrg func_append libobjs " $symfileobj" 75481016ad83Smrg test "X$libobjs" = "X " && libobjs= 75491016ad83Smrg 75501016ad83Smrg if test "$opt_mode" != relink; then 75511016ad83Smrg # Remove our outputs, but don't remove object files since they 75521016ad83Smrg # may have been created when compiling PIC objects. 75531016ad83Smrg removelist= 75541016ad83Smrg tempremovelist=`$ECHO "$output_objdir/*"` 75551016ad83Smrg for p in $tempremovelist; do 75561016ad83Smrg case $p in 75571016ad83Smrg *.$objext | *.gcno) 75581016ad83Smrg ;; 75591016ad83Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 75601016ad83Smrg if test "X$precious_files_regex" != "X"; then 75611016ad83Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 75621016ad83Smrg then 75631016ad83Smrg continue 75641016ad83Smrg fi 75651016ad83Smrg fi 75661016ad83Smrg func_append removelist " $p" 75671016ad83Smrg ;; 75681016ad83Smrg *) ;; 75691016ad83Smrg esac 75701016ad83Smrg done 75711016ad83Smrg test -n "$removelist" && \ 75721016ad83Smrg func_show_eval "${RM}r \$removelist" 75731016ad83Smrg fi 75741016ad83Smrg 75751016ad83Smrg # Now set the variables for building old libraries. 75761016ad83Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 75771016ad83Smrg func_append oldlibs " $output_objdir/$libname.$libext" 75781016ad83Smrg 75791016ad83Smrg # Transform .lo files to .o files. 75801016ad83Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 75811016ad83Smrg fi 75821016ad83Smrg 75831016ad83Smrg # Eliminate all temporary directories. 75841016ad83Smrg #for path in $notinst_path; do 75851016ad83Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 75861016ad83Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 75871016ad83Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 75881016ad83Smrg #done 75891016ad83Smrg 75901016ad83Smrg if test -n "$xrpath"; then 75911016ad83Smrg # If the user specified any rpath flags, then add them. 75921016ad83Smrg temp_xrpath= 75931016ad83Smrg for libdir in $xrpath; do 75941016ad83Smrg func_replace_sysroot "$libdir" 75951016ad83Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 75961016ad83Smrg case "$finalize_rpath " in 75971016ad83Smrg *" $libdir "*) ;; 75981016ad83Smrg *) func_append finalize_rpath " $libdir" ;; 75991016ad83Smrg esac 76001016ad83Smrg done 76011016ad83Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 76021016ad83Smrg dependency_libs="$temp_xrpath $dependency_libs" 76031016ad83Smrg fi 76041016ad83Smrg fi 76051016ad83Smrg 76061016ad83Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 76071016ad83Smrg old_dlfiles="$dlfiles" 76081016ad83Smrg dlfiles= 76091016ad83Smrg for lib in $old_dlfiles; do 76101016ad83Smrg case " $dlprefiles $dlfiles " in 76111016ad83Smrg *" $lib "*) ;; 76121016ad83Smrg *) func_append dlfiles " $lib" ;; 76131016ad83Smrg esac 76141016ad83Smrg done 76151016ad83Smrg 76161016ad83Smrg # Make sure dlprefiles contains only unique files 76171016ad83Smrg old_dlprefiles="$dlprefiles" 76181016ad83Smrg dlprefiles= 76191016ad83Smrg for lib in $old_dlprefiles; do 76201016ad83Smrg case "$dlprefiles " in 76211016ad83Smrg *" $lib "*) ;; 76221016ad83Smrg *) func_append dlprefiles " $lib" ;; 76231016ad83Smrg esac 76241016ad83Smrg done 76251016ad83Smrg 76261016ad83Smrg if test "$build_libtool_libs" = yes; then 76271016ad83Smrg if test -n "$rpath"; then 76281016ad83Smrg case $host in 76291016ad83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 76301016ad83Smrg # these systems don't actually have a c library (as such)! 76311016ad83Smrg ;; 76321016ad83Smrg *-*-rhapsody* | *-*-darwin1.[012]) 76331016ad83Smrg # Rhapsody C library is in the System framework 76341016ad83Smrg func_append deplibs " System.ltframework" 76351016ad83Smrg ;; 76361016ad83Smrg *-*-netbsd*) 76371016ad83Smrg # Don't link with libc until the a.out ld.so is fixed. 76381016ad83Smrg ;; 76391016ad83Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 76401016ad83Smrg # Do not include libc due to us having libc/libc_r. 76411016ad83Smrg ;; 76421016ad83Smrg *-*-sco3.2v5* | *-*-sco5v6*) 76431016ad83Smrg # Causes problems with __ctype 76441016ad83Smrg ;; 76451016ad83Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 76461016ad83Smrg # Compiler inserts libc in the correct place for threads to work 76471016ad83Smrg ;; 76481016ad83Smrg *) 76491016ad83Smrg # Add libc to deplibs on all other systems if necessary. 76501016ad83Smrg if test "$build_libtool_need_lc" = "yes"; then 76511016ad83Smrg func_append deplibs " -lc" 76521016ad83Smrg fi 76531016ad83Smrg ;; 76541016ad83Smrg esac 76551016ad83Smrg fi 76561016ad83Smrg 76571016ad83Smrg # Transform deplibs into only deplibs that can be linked in shared. 76581016ad83Smrg name_save=$name 76591016ad83Smrg libname_save=$libname 76601016ad83Smrg release_save=$release 76611016ad83Smrg versuffix_save=$versuffix 76621016ad83Smrg major_save=$major 76631016ad83Smrg # I'm not sure if I'm treating the release correctly. I think 76641016ad83Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 76651016ad83Smrg # add it in twice. Is that correct? 76661016ad83Smrg release="" 76671016ad83Smrg versuffix="" 76681016ad83Smrg major="" 76691016ad83Smrg newdeplibs= 76701016ad83Smrg droppeddeps=no 76711016ad83Smrg case $deplibs_check_method in 76721016ad83Smrg pass_all) 76731016ad83Smrg # Don't check for shared/static. Everything works. 76741016ad83Smrg # This might be a little naive. We might want to check 76751016ad83Smrg # whether the library exists or not. But this is on 76761016ad83Smrg # osf3 & osf4 and I'm not really sure... Just 76771016ad83Smrg # implementing what was already the behavior. 76781016ad83Smrg newdeplibs=$deplibs 76791016ad83Smrg ;; 76801016ad83Smrg test_compile) 76811016ad83Smrg # This code stresses the "libraries are programs" paradigm to its 76821016ad83Smrg # limits. Maybe even breaks it. We compile a program, linking it 76831016ad83Smrg # against the deplibs as a proxy for the library. Then we can check 76841016ad83Smrg # whether they linked in statically or dynamically with ldd. 76851016ad83Smrg $opt_dry_run || $RM conftest.c 76861016ad83Smrg cat > conftest.c <<EOF 76871016ad83Smrg int main() { return 0; } 76881016ad83SmrgEOF 76891016ad83Smrg $opt_dry_run || $RM conftest 76901016ad83Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 76911016ad83Smrg ldd_output=`ldd conftest` 76921016ad83Smrg for i in $deplibs; do 76931016ad83Smrg case $i in 76941016ad83Smrg -l*) 76951016ad83Smrg func_stripname -l '' "$i" 76961016ad83Smrg name=$func_stripname_result 76971016ad83Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 76981016ad83Smrg case " $predeps $postdeps " in 76991016ad83Smrg *" $i "*) 77001016ad83Smrg func_append newdeplibs " $i" 77011016ad83Smrg i="" 77021016ad83Smrg ;; 77031016ad83Smrg esac 77041016ad83Smrg fi 77051016ad83Smrg if test -n "$i" ; then 77061016ad83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 77071016ad83Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 77081016ad83Smrg set dummy $deplib_matches; shift 77091016ad83Smrg deplib_match=$1 77101016ad83Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 77111016ad83Smrg func_append newdeplibs " $i" 77121016ad83Smrg else 77131016ad83Smrg droppeddeps=yes 77141016ad83Smrg echo 77151016ad83Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 77161016ad83Smrg echo "*** I have the capability to make that library automatically link in when" 77171016ad83Smrg echo "*** you link to this library. But I can only do this if you have a" 77181016ad83Smrg echo "*** shared version of the library, which I believe you do not have" 77191016ad83Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 77201016ad83Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 77211016ad83Smrg fi 77221016ad83Smrg fi 77231016ad83Smrg ;; 77241016ad83Smrg *) 77251016ad83Smrg func_append newdeplibs " $i" 77261016ad83Smrg ;; 77271016ad83Smrg esac 77281016ad83Smrg done 77291016ad83Smrg else 77301016ad83Smrg # Error occurred in the first compile. Let's try to salvage 77311016ad83Smrg # the situation: Compile a separate program for each library. 77321016ad83Smrg for i in $deplibs; do 77331016ad83Smrg case $i in 77341016ad83Smrg -l*) 77351016ad83Smrg func_stripname -l '' "$i" 77361016ad83Smrg name=$func_stripname_result 77371016ad83Smrg $opt_dry_run || $RM conftest 77381016ad83Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 77391016ad83Smrg ldd_output=`ldd conftest` 77401016ad83Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 77411016ad83Smrg case " $predeps $postdeps " in 77421016ad83Smrg *" $i "*) 77431016ad83Smrg func_append newdeplibs " $i" 77441016ad83Smrg i="" 77451016ad83Smrg ;; 77461016ad83Smrg esac 77471016ad83Smrg fi 77481016ad83Smrg if test -n "$i" ; then 77491016ad83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 77501016ad83Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 77511016ad83Smrg set dummy $deplib_matches; shift 77521016ad83Smrg deplib_match=$1 77531016ad83Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 77541016ad83Smrg func_append newdeplibs " $i" 77551016ad83Smrg else 77561016ad83Smrg droppeddeps=yes 77571016ad83Smrg echo 77581016ad83Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 77591016ad83Smrg echo "*** I have the capability to make that library automatically link in when" 77601016ad83Smrg echo "*** you link to this library. But I can only do this if you have a" 77611016ad83Smrg echo "*** shared version of the library, which you do not appear to have" 77621016ad83Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 77631016ad83Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 77641016ad83Smrg fi 77651016ad83Smrg fi 77661016ad83Smrg else 77671016ad83Smrg droppeddeps=yes 77681016ad83Smrg echo 77691016ad83Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 77701016ad83Smrg echo "*** make it link in! You will probably need to install it or some" 77711016ad83Smrg echo "*** library that it depends on before this library will be fully" 77721016ad83Smrg echo "*** functional. Installing it before continuing would be even better." 77731016ad83Smrg fi 77741016ad83Smrg ;; 77751016ad83Smrg *) 77761016ad83Smrg func_append newdeplibs " $i" 77771016ad83Smrg ;; 77781016ad83Smrg esac 77791016ad83Smrg done 77801016ad83Smrg fi 77811016ad83Smrg ;; 77821016ad83Smrg file_magic*) 77831016ad83Smrg set dummy $deplibs_check_method; shift 77841016ad83Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 77851016ad83Smrg for a_deplib in $deplibs; do 77861016ad83Smrg case $a_deplib in 77871016ad83Smrg -l*) 77881016ad83Smrg func_stripname -l '' "$a_deplib" 77891016ad83Smrg name=$func_stripname_result 77901016ad83Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 77911016ad83Smrg case " $predeps $postdeps " in 77921016ad83Smrg *" $a_deplib "*) 77931016ad83Smrg func_append newdeplibs " $a_deplib" 77941016ad83Smrg a_deplib="" 77951016ad83Smrg ;; 77961016ad83Smrg esac 77971016ad83Smrg fi 77981016ad83Smrg if test -n "$a_deplib" ; then 77991016ad83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 78001016ad83Smrg if test -n "$file_magic_glob"; then 78011016ad83Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 78021016ad83Smrg else 78031016ad83Smrg libnameglob=$libname 78041016ad83Smrg fi 78051016ad83Smrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 78061016ad83Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 78071016ad83Smrg if test "$want_nocaseglob" = yes; then 78081016ad83Smrg shopt -s nocaseglob 78091016ad83Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 78101016ad83Smrg $nocaseglob 78111016ad83Smrg else 78121016ad83Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 78131016ad83Smrg fi 78141016ad83Smrg for potent_lib in $potential_libs; do 78151016ad83Smrg # Follow soft links. 78161016ad83Smrg if ls -lLd "$potent_lib" 2>/dev/null | 78171016ad83Smrg $GREP " -> " >/dev/null; then 78181016ad83Smrg continue 78191016ad83Smrg fi 78201016ad83Smrg # The statement above tries to avoid entering an 78211016ad83Smrg # endless loop below, in case of cyclic links. 78221016ad83Smrg # We might still enter an endless loop, since a link 78231016ad83Smrg # loop can be closed while we follow links, 78241016ad83Smrg # but so what? 78251016ad83Smrg potlib="$potent_lib" 78261016ad83Smrg while test -h "$potlib" 2>/dev/null; do 78271016ad83Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 78281016ad83Smrg case $potliblink in 78291016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 78301016ad83Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 78311016ad83Smrg esac 78321016ad83Smrg done 78331016ad83Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 78341016ad83Smrg $SED -e 10q | 78351016ad83Smrg $EGREP "$file_magic_regex" > /dev/null; then 78361016ad83Smrg func_append newdeplibs " $a_deplib" 78371016ad83Smrg a_deplib="" 78381016ad83Smrg break 2 78391016ad83Smrg fi 78401016ad83Smrg done 78411016ad83Smrg done 78421016ad83Smrg fi 78431016ad83Smrg if test -n "$a_deplib" ; then 78441016ad83Smrg droppeddeps=yes 78451016ad83Smrg echo 78461016ad83Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 78471016ad83Smrg echo "*** I have the capability to make that library automatically link in when" 78481016ad83Smrg echo "*** you link to this library. But I can only do this if you have a" 78491016ad83Smrg echo "*** shared version of the library, which you do not appear to have" 78501016ad83Smrg echo "*** because I did check the linker path looking for a file starting" 78511016ad83Smrg if test -z "$potlib" ; then 78521016ad83Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 78531016ad83Smrg else 78541016ad83Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 78551016ad83Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 78561016ad83Smrg fi 78571016ad83Smrg fi 78581016ad83Smrg ;; 78591016ad83Smrg *) 78601016ad83Smrg # Add a -L argument. 78611016ad83Smrg func_append newdeplibs " $a_deplib" 78621016ad83Smrg ;; 78631016ad83Smrg esac 78641016ad83Smrg done # Gone through all deplibs. 78651016ad83Smrg ;; 78661016ad83Smrg match_pattern*) 78671016ad83Smrg set dummy $deplibs_check_method; shift 78681016ad83Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 78691016ad83Smrg for a_deplib in $deplibs; do 78701016ad83Smrg case $a_deplib in 78711016ad83Smrg -l*) 78721016ad83Smrg func_stripname -l '' "$a_deplib" 78731016ad83Smrg name=$func_stripname_result 78741016ad83Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 78751016ad83Smrg case " $predeps $postdeps " in 78761016ad83Smrg *" $a_deplib "*) 78771016ad83Smrg func_append newdeplibs " $a_deplib" 78781016ad83Smrg a_deplib="" 78791016ad83Smrg ;; 78801016ad83Smrg esac 78811016ad83Smrg fi 78821016ad83Smrg if test -n "$a_deplib" ; then 78831016ad83Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 78841016ad83Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 78851016ad83Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 78861016ad83Smrg for potent_lib in $potential_libs; do 78871016ad83Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 78881016ad83Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 78891016ad83Smrg $EGREP "$match_pattern_regex" > /dev/null; then 78901016ad83Smrg func_append newdeplibs " $a_deplib" 78911016ad83Smrg a_deplib="" 78921016ad83Smrg break 2 78931016ad83Smrg fi 78941016ad83Smrg done 78951016ad83Smrg done 78961016ad83Smrg fi 78971016ad83Smrg if test -n "$a_deplib" ; then 78981016ad83Smrg droppeddeps=yes 78991016ad83Smrg echo 79001016ad83Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 79011016ad83Smrg echo "*** I have the capability to make that library automatically link in when" 79021016ad83Smrg echo "*** you link to this library. But I can only do this if you have a" 79031016ad83Smrg echo "*** shared version of the library, which you do not appear to have" 79041016ad83Smrg echo "*** because I did check the linker path looking for a file starting" 79051016ad83Smrg if test -z "$potlib" ; then 79061016ad83Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 79071016ad83Smrg else 79081016ad83Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 79091016ad83Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 79101016ad83Smrg fi 79111016ad83Smrg fi 79121016ad83Smrg ;; 79131016ad83Smrg *) 79141016ad83Smrg # Add a -L argument. 79151016ad83Smrg func_append newdeplibs " $a_deplib" 79161016ad83Smrg ;; 79171016ad83Smrg esac 79181016ad83Smrg done # Gone through all deplibs. 79191016ad83Smrg ;; 79201016ad83Smrg none | unknown | *) 79211016ad83Smrg newdeplibs="" 79221016ad83Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 79231016ad83Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 79241016ad83Smrg for i in $predeps $postdeps ; do 79251016ad83Smrg # can't use Xsed below, because $i might contain '/' 79261016ad83Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 79271016ad83Smrg done 79281016ad83Smrg fi 79291016ad83Smrg case $tmp_deplibs in 79301016ad83Smrg *[!\ \ ]*) 79311016ad83Smrg echo 79321016ad83Smrg if test "X$deplibs_check_method" = "Xnone"; then 79331016ad83Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 79341016ad83Smrg else 79351016ad83Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 79361016ad83Smrg fi 79371016ad83Smrg echo "*** All declared inter-library dependencies are being dropped." 79381016ad83Smrg droppeddeps=yes 79391016ad83Smrg ;; 79401016ad83Smrg esac 79411016ad83Smrg ;; 79421016ad83Smrg esac 79431016ad83Smrg versuffix=$versuffix_save 79441016ad83Smrg major=$major_save 79451016ad83Smrg release=$release_save 79461016ad83Smrg libname=$libname_save 79471016ad83Smrg name=$name_save 79481016ad83Smrg 79491016ad83Smrg case $host in 79501016ad83Smrg *-*-rhapsody* | *-*-darwin1.[012]) 79511016ad83Smrg # On Rhapsody replace the C library with the System framework 79521016ad83Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 79531016ad83Smrg ;; 79541016ad83Smrg esac 79551016ad83Smrg 79561016ad83Smrg if test "$droppeddeps" = yes; then 79571016ad83Smrg if test "$module" = yes; then 79581016ad83Smrg echo 79591016ad83Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 79601016ad83Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 79611016ad83Smrg echo "*** a static module, that should work as long as the dlopening" 79621016ad83Smrg echo "*** application is linked with the -dlopen flag." 79631016ad83Smrg if test -z "$global_symbol_pipe"; then 79641016ad83Smrg echo 79651016ad83Smrg echo "*** However, this would only work if libtool was able to extract symbol" 79661016ad83Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 79671016ad83Smrg echo "*** not find such a program. So, this module is probably useless." 79681016ad83Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 79691016ad83Smrg fi 79701016ad83Smrg if test "$build_old_libs" = no; then 79711016ad83Smrg oldlibs="$output_objdir/$libname.$libext" 79721016ad83Smrg build_libtool_libs=module 79731016ad83Smrg build_old_libs=yes 79741016ad83Smrg else 79751016ad83Smrg build_libtool_libs=no 79761016ad83Smrg fi 79771016ad83Smrg else 79781016ad83Smrg echo "*** The inter-library dependencies that have been dropped here will be" 79791016ad83Smrg echo "*** automatically added whenever a program is linked with this library" 79801016ad83Smrg echo "*** or is declared to -dlopen it." 79811016ad83Smrg 79821016ad83Smrg if test "$allow_undefined" = no; then 79831016ad83Smrg echo 79841016ad83Smrg echo "*** Since this library must not contain undefined symbols," 79851016ad83Smrg echo "*** because either the platform does not support them or" 79861016ad83Smrg echo "*** it was explicitly requested with -no-undefined," 79871016ad83Smrg echo "*** libtool will only create a static version of it." 79881016ad83Smrg if test "$build_old_libs" = no; then 79891016ad83Smrg oldlibs="$output_objdir/$libname.$libext" 79901016ad83Smrg build_libtool_libs=module 79911016ad83Smrg build_old_libs=yes 79921016ad83Smrg else 79931016ad83Smrg build_libtool_libs=no 79941016ad83Smrg fi 79951016ad83Smrg fi 79961016ad83Smrg fi 79971016ad83Smrg fi 79981016ad83Smrg # Done checking deplibs! 79991016ad83Smrg deplibs=$newdeplibs 80001016ad83Smrg fi 80011016ad83Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 80021016ad83Smrg case $host in 80031016ad83Smrg *-*-darwin*) 80041016ad83Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 80051016ad83Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 80061016ad83Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 80071016ad83Smrg ;; 80081016ad83Smrg esac 80091016ad83Smrg 80101016ad83Smrg # move library search paths that coincide with paths to not yet 80111016ad83Smrg # installed libraries to the beginning of the library search list 80121016ad83Smrg new_libs= 80131016ad83Smrg for path in $notinst_path; do 80141016ad83Smrg case " $new_libs " in 80151016ad83Smrg *" -L$path/$objdir "*) ;; 80161016ad83Smrg *) 80171016ad83Smrg case " $deplibs " in 80181016ad83Smrg *" -L$path/$objdir "*) 80191016ad83Smrg func_append new_libs " -L$path/$objdir" ;; 80201016ad83Smrg esac 80211016ad83Smrg ;; 80221016ad83Smrg esac 80231016ad83Smrg done 80241016ad83Smrg for deplib in $deplibs; do 80251016ad83Smrg case $deplib in 80261016ad83Smrg -L*) 80271016ad83Smrg case " $new_libs " in 80281016ad83Smrg *" $deplib "*) ;; 80291016ad83Smrg *) func_append new_libs " $deplib" ;; 80301016ad83Smrg esac 80311016ad83Smrg ;; 80321016ad83Smrg *) func_append new_libs " $deplib" ;; 80331016ad83Smrg esac 80341016ad83Smrg done 80351016ad83Smrg deplibs="$new_libs" 80361016ad83Smrg 80371016ad83Smrg # All the library-specific variables (install_libdir is set above). 80381016ad83Smrg library_names= 80391016ad83Smrg old_library= 80401016ad83Smrg dlname= 80411016ad83Smrg 80421016ad83Smrg # Test again, we may have decided not to build it any more 80431016ad83Smrg if test "$build_libtool_libs" = yes; then 80441016ad83Smrg # Remove ${wl} instances when linking with ld. 80451016ad83Smrg # FIXME: should test the right _cmds variable. 80461016ad83Smrg case $archive_cmds in 80471016ad83Smrg *\$LD\ *) wl= ;; 80481016ad83Smrg esac 80491016ad83Smrg if test "$hardcode_into_libs" = yes; then 80501016ad83Smrg # Hardcode the library paths 80511016ad83Smrg hardcode_libdirs= 80521016ad83Smrg dep_rpath= 80531016ad83Smrg rpath="$finalize_rpath" 80541016ad83Smrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 80551016ad83Smrg for libdir in $rpath; do 80561016ad83Smrg if test -n "$hardcode_libdir_flag_spec"; then 80571016ad83Smrg if test -n "$hardcode_libdir_separator"; then 80581016ad83Smrg func_replace_sysroot "$libdir" 80591016ad83Smrg libdir=$func_replace_sysroot_result 80601016ad83Smrg if test -z "$hardcode_libdirs"; then 80611016ad83Smrg hardcode_libdirs="$libdir" 80621016ad83Smrg else 80631016ad83Smrg # Just accumulate the unique libdirs. 80641016ad83Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 80651016ad83Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 80661016ad83Smrg ;; 80671016ad83Smrg *) 80681016ad83Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 80691016ad83Smrg ;; 80701016ad83Smrg esac 80711016ad83Smrg fi 80721016ad83Smrg else 80731016ad83Smrg eval flag=\"$hardcode_libdir_flag_spec\" 80741016ad83Smrg func_append dep_rpath " $flag" 80751016ad83Smrg fi 80761016ad83Smrg elif test -n "$runpath_var"; then 80771016ad83Smrg case "$perm_rpath " in 80781016ad83Smrg *" $libdir "*) ;; 80791016ad83Smrg *) func_append perm_rpath " $libdir" ;; 80801016ad83Smrg esac 80811016ad83Smrg fi 80821016ad83Smrg done 80831016ad83Smrg # Substitute the hardcoded libdirs into the rpath. 80841016ad83Smrg if test -n "$hardcode_libdir_separator" && 80851016ad83Smrg test -n "$hardcode_libdirs"; then 80861016ad83Smrg libdir="$hardcode_libdirs" 80871016ad83Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 80881016ad83Smrg fi 80891016ad83Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 80901016ad83Smrg # We should set the runpath_var. 80911016ad83Smrg rpath= 80921016ad83Smrg for dir in $perm_rpath; do 80931016ad83Smrg func_append rpath "$dir:" 80941016ad83Smrg done 80951016ad83Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 80961016ad83Smrg fi 80971016ad83Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 80981016ad83Smrg fi 80991016ad83Smrg 81001016ad83Smrg shlibpath="$finalize_shlibpath" 81011016ad83Smrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 81021016ad83Smrg if test -n "$shlibpath"; then 81031016ad83Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 81041016ad83Smrg fi 81051016ad83Smrg 81061016ad83Smrg # Get the real and link names of the library. 81071016ad83Smrg eval shared_ext=\"$shrext_cmds\" 81081016ad83Smrg eval library_names=\"$library_names_spec\" 81091016ad83Smrg set dummy $library_names 81101016ad83Smrg shift 81111016ad83Smrg realname="$1" 81121016ad83Smrg shift 81131016ad83Smrg 81141016ad83Smrg if test -n "$soname_spec"; then 81151016ad83Smrg eval soname=\"$soname_spec\" 81161016ad83Smrg else 81171016ad83Smrg soname="$realname" 81181016ad83Smrg fi 81191016ad83Smrg if test -z "$dlname"; then 81201016ad83Smrg dlname=$soname 81211016ad83Smrg fi 81221016ad83Smrg 81231016ad83Smrg lib="$output_objdir/$realname" 81241016ad83Smrg linknames= 81251016ad83Smrg for link 81261016ad83Smrg do 81271016ad83Smrg func_append linknames " $link" 81281016ad83Smrg done 81291016ad83Smrg 81301016ad83Smrg # Use standard objects if they are pic 81311016ad83Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 81321016ad83Smrg test "X$libobjs" = "X " && libobjs= 81331016ad83Smrg 81341016ad83Smrg delfiles= 81351016ad83Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 81361016ad83Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 81371016ad83Smrg export_symbols="$output_objdir/$libname.uexp" 81381016ad83Smrg func_append delfiles " $export_symbols" 81391016ad83Smrg fi 81401016ad83Smrg 81411016ad83Smrg orig_export_symbols= 81421016ad83Smrg case $host_os in 81431016ad83Smrg cygwin* | mingw* | cegcc*) 81441016ad83Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 81451016ad83Smrg # exporting using user supplied symfile 81461016ad83Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 81471016ad83Smrg # and it's NOT already a .def file. Must figure out 81481016ad83Smrg # which of the given symbols are data symbols and tag 81491016ad83Smrg # them as such. So, trigger use of export_symbols_cmds. 81501016ad83Smrg # export_symbols gets reassigned inside the "prepare 81511016ad83Smrg # the list of exported symbols" if statement, so the 81521016ad83Smrg # include_expsyms logic still works. 81531016ad83Smrg orig_export_symbols="$export_symbols" 81541016ad83Smrg export_symbols= 81551016ad83Smrg always_export_symbols=yes 81561016ad83Smrg fi 81571016ad83Smrg fi 81581016ad83Smrg ;; 81591016ad83Smrg esac 81601016ad83Smrg 81611016ad83Smrg # Prepare the list of exported symbols 81621016ad83Smrg if test -z "$export_symbols"; then 81631016ad83Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 81641016ad83Smrg func_verbose "generating symbol list for \`$libname.la'" 81651016ad83Smrg export_symbols="$output_objdir/$libname.exp" 81661016ad83Smrg $opt_dry_run || $RM $export_symbols 81671016ad83Smrg cmds=$export_symbols_cmds 81681016ad83Smrg save_ifs="$IFS"; IFS='~' 81691016ad83Smrg for cmd1 in $cmds; do 81701016ad83Smrg IFS="$save_ifs" 81711016ad83Smrg # Take the normal branch if the nm_file_list_spec branch 81721016ad83Smrg # doesn't work or if tool conversion is not needed. 81731016ad83Smrg case $nm_file_list_spec~$to_tool_file_cmd in 81741016ad83Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 81751016ad83Smrg try_normal_branch=yes 81761016ad83Smrg eval cmd=\"$cmd1\" 81771016ad83Smrg func_len " $cmd" 81781016ad83Smrg len=$func_len_result 81791016ad83Smrg ;; 81801016ad83Smrg *) 81811016ad83Smrg try_normal_branch=no 81821016ad83Smrg ;; 81831016ad83Smrg esac 81841016ad83Smrg if test "$try_normal_branch" = yes \ 81851016ad83Smrg && { test "$len" -lt "$max_cmd_len" \ 81861016ad83Smrg || test "$max_cmd_len" -le -1; } 81871016ad83Smrg then 81881016ad83Smrg func_show_eval "$cmd" 'exit $?' 81891016ad83Smrg skipped_export=false 81901016ad83Smrg elif test -n "$nm_file_list_spec"; then 81911016ad83Smrg func_basename "$output" 81921016ad83Smrg output_la=$func_basename_result 81931016ad83Smrg save_libobjs=$libobjs 81941016ad83Smrg save_output=$output 81951016ad83Smrg output=${output_objdir}/${output_la}.nm 81961016ad83Smrg func_to_tool_file "$output" 81971016ad83Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 81981016ad83Smrg func_append delfiles " $output" 81991016ad83Smrg func_verbose "creating $NM input file list: $output" 82001016ad83Smrg for obj in $save_libobjs; do 82011016ad83Smrg func_to_tool_file "$obj" 82021016ad83Smrg $ECHO "$func_to_tool_file_result" 82031016ad83Smrg done > "$output" 82041016ad83Smrg eval cmd=\"$cmd1\" 82051016ad83Smrg func_show_eval "$cmd" 'exit $?' 82061016ad83Smrg output=$save_output 82071016ad83Smrg libobjs=$save_libobjs 82081016ad83Smrg skipped_export=false 82091016ad83Smrg else 82101016ad83Smrg # The command line is too long to execute in one step. 82111016ad83Smrg func_verbose "using reloadable object file for export list..." 82121016ad83Smrg skipped_export=: 82131016ad83Smrg # Break out early, otherwise skipped_export may be 82141016ad83Smrg # set to false by a later but shorter cmd. 82151016ad83Smrg break 82161016ad83Smrg fi 82171016ad83Smrg done 82181016ad83Smrg IFS="$save_ifs" 82191016ad83Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 82201016ad83Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 82211016ad83Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 82221016ad83Smrg fi 82231016ad83Smrg fi 82241016ad83Smrg fi 82251016ad83Smrg 82261016ad83Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 82271016ad83Smrg tmp_export_symbols="$export_symbols" 82281016ad83Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 82291016ad83Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 82301016ad83Smrg fi 82311016ad83Smrg 82321016ad83Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 82331016ad83Smrg # The given exports_symbols file has to be filtered, so filter it. 82341016ad83Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 82351016ad83Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 82361016ad83Smrg # 's' commands which not all seds can handle. GNU sed should be fine 82371016ad83Smrg # though. Also, the filter scales superlinearly with the number of 82381016ad83Smrg # global variables. join(1) would be nice here, but unfortunately 82391016ad83Smrg # isn't a blessed tool. 82401016ad83Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 82411016ad83Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 82421016ad83Smrg export_symbols=$output_objdir/$libname.def 82431016ad83Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 82441016ad83Smrg fi 82451016ad83Smrg 82461016ad83Smrg tmp_deplibs= 82471016ad83Smrg for test_deplib in $deplibs; do 82481016ad83Smrg case " $convenience " in 82491016ad83Smrg *" $test_deplib "*) ;; 82501016ad83Smrg *) 82511016ad83Smrg func_append tmp_deplibs " $test_deplib" 82521016ad83Smrg ;; 82531016ad83Smrg esac 82541016ad83Smrg done 82551016ad83Smrg deplibs="$tmp_deplibs" 82561016ad83Smrg 82571016ad83Smrg if test -n "$convenience"; then 82581016ad83Smrg if test -n "$whole_archive_flag_spec" && 82591016ad83Smrg test "$compiler_needs_object" = yes && 82601016ad83Smrg test -z "$libobjs"; then 82611016ad83Smrg # extract the archives, so we have objects to list. 82621016ad83Smrg # TODO: could optimize this to just extract one archive. 82631016ad83Smrg whole_archive_flag_spec= 82641016ad83Smrg fi 82651016ad83Smrg if test -n "$whole_archive_flag_spec"; then 82661016ad83Smrg save_libobjs=$libobjs 82671016ad83Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 82681016ad83Smrg test "X$libobjs" = "X " && libobjs= 82691016ad83Smrg else 82701016ad83Smrg gentop="$output_objdir/${outputname}x" 82711016ad83Smrg func_append generated " $gentop" 82721016ad83Smrg 82731016ad83Smrg func_extract_archives $gentop $convenience 82741016ad83Smrg func_append libobjs " $func_extract_archives_result" 82751016ad83Smrg test "X$libobjs" = "X " && libobjs= 82761016ad83Smrg fi 82771016ad83Smrg fi 82781016ad83Smrg 82791016ad83Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 82801016ad83Smrg eval flag=\"$thread_safe_flag_spec\" 82811016ad83Smrg func_append linker_flags " $flag" 82821016ad83Smrg fi 82831016ad83Smrg 82841016ad83Smrg # Make a backup of the uninstalled library when relinking 82851016ad83Smrg if test "$opt_mode" = relink; then 82861016ad83Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 82871016ad83Smrg fi 82881016ad83Smrg 82891016ad83Smrg # Do each of the archive commands. 82901016ad83Smrg if test "$module" = yes && test -n "$module_cmds" ; then 82911016ad83Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 82921016ad83Smrg eval test_cmds=\"$module_expsym_cmds\" 82931016ad83Smrg cmds=$module_expsym_cmds 82941016ad83Smrg else 82951016ad83Smrg eval test_cmds=\"$module_cmds\" 82961016ad83Smrg cmds=$module_cmds 82971016ad83Smrg fi 82981016ad83Smrg else 82991016ad83Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 83001016ad83Smrg eval test_cmds=\"$archive_expsym_cmds\" 83011016ad83Smrg cmds=$archive_expsym_cmds 83021016ad83Smrg else 83031016ad83Smrg eval test_cmds=\"$archive_cmds\" 83041016ad83Smrg cmds=$archive_cmds 83051016ad83Smrg fi 83061016ad83Smrg fi 83071016ad83Smrg 83081016ad83Smrg if test "X$skipped_export" != "X:" && 83091016ad83Smrg func_len " $test_cmds" && 83101016ad83Smrg len=$func_len_result && 83111016ad83Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 83121016ad83Smrg : 83131016ad83Smrg else 83141016ad83Smrg # The command line is too long to link in one step, link piecewise 83151016ad83Smrg # or, if using GNU ld and skipped_export is not :, use a linker 83161016ad83Smrg # script. 83171016ad83Smrg 83181016ad83Smrg # Save the value of $output and $libobjs because we want to 83191016ad83Smrg # use them later. If we have whole_archive_flag_spec, we 83201016ad83Smrg # want to use save_libobjs as it was before 83211016ad83Smrg # whole_archive_flag_spec was expanded, because we can't 83221016ad83Smrg # assume the linker understands whole_archive_flag_spec. 83231016ad83Smrg # This may have to be revisited, in case too many 83241016ad83Smrg # convenience libraries get linked in and end up exceeding 83251016ad83Smrg # the spec. 83261016ad83Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 83271016ad83Smrg save_libobjs=$libobjs 83281016ad83Smrg fi 83291016ad83Smrg save_output=$output 83301016ad83Smrg func_basename "$output" 83311016ad83Smrg output_la=$func_basename_result 83321016ad83Smrg 83331016ad83Smrg # Clear the reloadable object creation command queue and 83341016ad83Smrg # initialize k to one. 83351016ad83Smrg test_cmds= 83361016ad83Smrg concat_cmds= 83371016ad83Smrg objlist= 83381016ad83Smrg last_robj= 83391016ad83Smrg k=1 83401016ad83Smrg 83411016ad83Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 83421016ad83Smrg output=${output_objdir}/${output_la}.lnkscript 83431016ad83Smrg func_verbose "creating GNU ld script: $output" 83441016ad83Smrg echo 'INPUT (' > $output 83451016ad83Smrg for obj in $save_libobjs 83461016ad83Smrg do 83471016ad83Smrg func_to_tool_file "$obj" 83481016ad83Smrg $ECHO "$func_to_tool_file_result" >> $output 83491016ad83Smrg done 83501016ad83Smrg echo ')' >> $output 83511016ad83Smrg func_append delfiles " $output" 83521016ad83Smrg func_to_tool_file "$output" 83531016ad83Smrg output=$func_to_tool_file_result 83541016ad83Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 83551016ad83Smrg output=${output_objdir}/${output_la}.lnk 83561016ad83Smrg func_verbose "creating linker input file list: $output" 83571016ad83Smrg : > $output 83581016ad83Smrg set x $save_libobjs 83591016ad83Smrg shift 83601016ad83Smrg firstobj= 83611016ad83Smrg if test "$compiler_needs_object" = yes; then 83621016ad83Smrg firstobj="$1 " 83631016ad83Smrg shift 83641016ad83Smrg fi 83651016ad83Smrg for obj 83661016ad83Smrg do 83671016ad83Smrg func_to_tool_file "$obj" 83681016ad83Smrg $ECHO "$func_to_tool_file_result" >> $output 83691016ad83Smrg done 83701016ad83Smrg func_append delfiles " $output" 83711016ad83Smrg func_to_tool_file "$output" 83721016ad83Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 83731016ad83Smrg else 83741016ad83Smrg if test -n "$save_libobjs"; then 83751016ad83Smrg func_verbose "creating reloadable object files..." 83761016ad83Smrg output=$output_objdir/$output_la-${k}.$objext 83771016ad83Smrg eval test_cmds=\"$reload_cmds\" 83781016ad83Smrg func_len " $test_cmds" 83791016ad83Smrg len0=$func_len_result 83801016ad83Smrg len=$len0 83811016ad83Smrg 83821016ad83Smrg # Loop over the list of objects to be linked. 83831016ad83Smrg for obj in $save_libobjs 83841016ad83Smrg do 83851016ad83Smrg func_len " $obj" 83861016ad83Smrg func_arith $len + $func_len_result 83871016ad83Smrg len=$func_arith_result 83881016ad83Smrg if test "X$objlist" = X || 83891016ad83Smrg test "$len" -lt "$max_cmd_len"; then 83901016ad83Smrg func_append objlist " $obj" 83911016ad83Smrg else 83921016ad83Smrg # The command $test_cmds is almost too long, add a 83931016ad83Smrg # command to the queue. 83941016ad83Smrg if test "$k" -eq 1 ; then 83951016ad83Smrg # The first file doesn't have a previous command to add. 83961016ad83Smrg reload_objs=$objlist 83971016ad83Smrg eval concat_cmds=\"$reload_cmds\" 83981016ad83Smrg else 83991016ad83Smrg # All subsequent reloadable object files will link in 84001016ad83Smrg # the last one created. 84011016ad83Smrg reload_objs="$objlist $last_robj" 84021016ad83Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 84031016ad83Smrg fi 84041016ad83Smrg last_robj=$output_objdir/$output_la-${k}.$objext 84051016ad83Smrg func_arith $k + 1 84061016ad83Smrg k=$func_arith_result 84071016ad83Smrg output=$output_objdir/$output_la-${k}.$objext 84081016ad83Smrg objlist=" $obj" 84091016ad83Smrg func_len " $last_robj" 84101016ad83Smrg func_arith $len0 + $func_len_result 84111016ad83Smrg len=$func_arith_result 84121016ad83Smrg fi 84131016ad83Smrg done 84141016ad83Smrg # Handle the remaining objects by creating one last 84151016ad83Smrg # reloadable object file. All subsequent reloadable object 84161016ad83Smrg # files will link in the last one created. 84171016ad83Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 84181016ad83Smrg reload_objs="$objlist $last_robj" 84191016ad83Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 84201016ad83Smrg if test -n "$last_robj"; then 84211016ad83Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 84221016ad83Smrg fi 84231016ad83Smrg func_append delfiles " $output" 84241016ad83Smrg 84251016ad83Smrg else 84261016ad83Smrg output= 84271016ad83Smrg fi 84281016ad83Smrg 84291016ad83Smrg if ${skipped_export-false}; then 84301016ad83Smrg func_verbose "generating symbol list for \`$libname.la'" 84311016ad83Smrg export_symbols="$output_objdir/$libname.exp" 84321016ad83Smrg $opt_dry_run || $RM $export_symbols 84331016ad83Smrg libobjs=$output 84341016ad83Smrg # Append the command to create the export file. 84351016ad83Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 84361016ad83Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 84371016ad83Smrg if test -n "$last_robj"; then 84381016ad83Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 84391016ad83Smrg fi 84401016ad83Smrg fi 84411016ad83Smrg 84421016ad83Smrg test -n "$save_libobjs" && 84431016ad83Smrg func_verbose "creating a temporary reloadable object file: $output" 84441016ad83Smrg 84451016ad83Smrg # Loop through the commands generated above and execute them. 84461016ad83Smrg save_ifs="$IFS"; IFS='~' 84471016ad83Smrg for cmd in $concat_cmds; do 84481016ad83Smrg IFS="$save_ifs" 84491016ad83Smrg $opt_silent || { 84501016ad83Smrg func_quote_for_expand "$cmd" 84511016ad83Smrg eval "func_echo $func_quote_for_expand_result" 84521016ad83Smrg } 84531016ad83Smrg $opt_dry_run || eval "$cmd" || { 84541016ad83Smrg lt_exit=$? 84551016ad83Smrg 84561016ad83Smrg # Restore the uninstalled library and exit 84571016ad83Smrg if test "$opt_mode" = relink; then 84581016ad83Smrg ( cd "$output_objdir" && \ 84591016ad83Smrg $RM "${realname}T" && \ 84601016ad83Smrg $MV "${realname}U" "$realname" ) 84611016ad83Smrg fi 84621016ad83Smrg 84631016ad83Smrg exit $lt_exit 84641016ad83Smrg } 84651016ad83Smrg done 84661016ad83Smrg IFS="$save_ifs" 84671016ad83Smrg 84681016ad83Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 84691016ad83Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 84701016ad83Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 84711016ad83Smrg fi 84721016ad83Smrg fi 84731016ad83Smrg 84741016ad83Smrg if ${skipped_export-false}; then 84751016ad83Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 84761016ad83Smrg tmp_export_symbols="$export_symbols" 84771016ad83Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 84781016ad83Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 84791016ad83Smrg fi 84801016ad83Smrg 84811016ad83Smrg if test -n "$orig_export_symbols"; then 84821016ad83Smrg # The given exports_symbols file has to be filtered, so filter it. 84831016ad83Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 84841016ad83Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 84851016ad83Smrg # 's' commands which not all seds can handle. GNU sed should be fine 84861016ad83Smrg # though. Also, the filter scales superlinearly with the number of 84871016ad83Smrg # global variables. join(1) would be nice here, but unfortunately 84881016ad83Smrg # isn't a blessed tool. 84891016ad83Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 84901016ad83Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 84911016ad83Smrg export_symbols=$output_objdir/$libname.def 84921016ad83Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 84931016ad83Smrg fi 84941016ad83Smrg fi 84951016ad83Smrg 84961016ad83Smrg libobjs=$output 84971016ad83Smrg # Restore the value of output. 84981016ad83Smrg output=$save_output 84991016ad83Smrg 85001016ad83Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 85011016ad83Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 85021016ad83Smrg test "X$libobjs" = "X " && libobjs= 85031016ad83Smrg fi 85041016ad83Smrg # Expand the library linking commands again to reset the 85051016ad83Smrg # value of $libobjs for piecewise linking. 85061016ad83Smrg 85071016ad83Smrg # Do each of the archive commands. 85081016ad83Smrg if test "$module" = yes && test -n "$module_cmds" ; then 85091016ad83Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 85101016ad83Smrg cmds=$module_expsym_cmds 85111016ad83Smrg else 85121016ad83Smrg cmds=$module_cmds 85131016ad83Smrg fi 85141016ad83Smrg else 85151016ad83Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 85161016ad83Smrg cmds=$archive_expsym_cmds 85171016ad83Smrg else 85181016ad83Smrg cmds=$archive_cmds 85191016ad83Smrg fi 85201016ad83Smrg fi 85211016ad83Smrg fi 85221016ad83Smrg 85231016ad83Smrg if test -n "$delfiles"; then 85241016ad83Smrg # Append the command to remove temporary files to $cmds. 85251016ad83Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 85261016ad83Smrg fi 85271016ad83Smrg 85281016ad83Smrg # Add any objects from preloaded convenience libraries 85291016ad83Smrg if test -n "$dlprefiles"; then 85301016ad83Smrg gentop="$output_objdir/${outputname}x" 85311016ad83Smrg func_append generated " $gentop" 85321016ad83Smrg 85331016ad83Smrg func_extract_archives $gentop $dlprefiles 85341016ad83Smrg func_append libobjs " $func_extract_archives_result" 85351016ad83Smrg test "X$libobjs" = "X " && libobjs= 85361016ad83Smrg fi 85371016ad83Smrg 85381016ad83Smrg save_ifs="$IFS"; IFS='~' 85391016ad83Smrg for cmd in $cmds; do 85401016ad83Smrg IFS="$save_ifs" 85411016ad83Smrg eval cmd=\"$cmd\" 85421016ad83Smrg $opt_silent || { 85431016ad83Smrg func_quote_for_expand "$cmd" 85441016ad83Smrg eval "func_echo $func_quote_for_expand_result" 85451016ad83Smrg } 85461016ad83Smrg $opt_dry_run || eval "$cmd" || { 85471016ad83Smrg lt_exit=$? 85481016ad83Smrg 85491016ad83Smrg # Restore the uninstalled library and exit 85501016ad83Smrg if test "$opt_mode" = relink; then 85511016ad83Smrg ( cd "$output_objdir" && \ 85521016ad83Smrg $RM "${realname}T" && \ 85531016ad83Smrg $MV "${realname}U" "$realname" ) 85541016ad83Smrg fi 85551016ad83Smrg 85561016ad83Smrg exit $lt_exit 85571016ad83Smrg } 85581016ad83Smrg done 85591016ad83Smrg IFS="$save_ifs" 85601016ad83Smrg 85611016ad83Smrg # Restore the uninstalled library and exit 85621016ad83Smrg if test "$opt_mode" = relink; then 85631016ad83Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 85641016ad83Smrg 85651016ad83Smrg if test -n "$convenience"; then 85661016ad83Smrg if test -z "$whole_archive_flag_spec"; then 85671016ad83Smrg func_show_eval '${RM}r "$gentop"' 85681016ad83Smrg fi 85691016ad83Smrg fi 85701016ad83Smrg 85711016ad83Smrg exit $EXIT_SUCCESS 85721016ad83Smrg fi 85731016ad83Smrg 85741016ad83Smrg # Create links to the real library. 85751016ad83Smrg for linkname in $linknames; do 85761016ad83Smrg if test "$realname" != "$linkname"; then 85771016ad83Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 85781016ad83Smrg fi 85791016ad83Smrg done 85801016ad83Smrg 85811016ad83Smrg # If -module or -export-dynamic was specified, set the dlname. 85821016ad83Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 85831016ad83Smrg # On all known operating systems, these are identical. 85841016ad83Smrg dlname="$soname" 85851016ad83Smrg fi 85861016ad83Smrg fi 85871016ad83Smrg ;; 85881016ad83Smrg 85891016ad83Smrg obj) 85901016ad83Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 85911016ad83Smrg func_warning "\`-dlopen' is ignored for objects" 85921016ad83Smrg fi 85931016ad83Smrg 85941016ad83Smrg case " $deplibs" in 85951016ad83Smrg *\ -l* | *\ -L*) 85961016ad83Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 85971016ad83Smrg esac 85981016ad83Smrg 85991016ad83Smrg test -n "$rpath" && \ 86001016ad83Smrg func_warning "\`-rpath' is ignored for objects" 86011016ad83Smrg 86021016ad83Smrg test -n "$xrpath" && \ 86031016ad83Smrg func_warning "\`-R' is ignored for objects" 86041016ad83Smrg 86051016ad83Smrg test -n "$vinfo" && \ 86061016ad83Smrg func_warning "\`-version-info' is ignored for objects" 86071016ad83Smrg 86081016ad83Smrg test -n "$release" && \ 86091016ad83Smrg func_warning "\`-release' is ignored for objects" 86101016ad83Smrg 86111016ad83Smrg case $output in 86121016ad83Smrg *.lo) 86131016ad83Smrg test -n "$objs$old_deplibs" && \ 86141016ad83Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 86151016ad83Smrg 86161016ad83Smrg libobj=$output 86171016ad83Smrg func_lo2o "$libobj" 86181016ad83Smrg obj=$func_lo2o_result 86191016ad83Smrg ;; 86201016ad83Smrg *) 86211016ad83Smrg libobj= 86221016ad83Smrg obj="$output" 86231016ad83Smrg ;; 86241016ad83Smrg esac 86251016ad83Smrg 86261016ad83Smrg # Delete the old objects. 86271016ad83Smrg $opt_dry_run || $RM $obj $libobj 86281016ad83Smrg 86291016ad83Smrg # Objects from convenience libraries. This assumes 86301016ad83Smrg # single-version convenience libraries. Whenever we create 86311016ad83Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 86321016ad83Smrg # the extraction. 86331016ad83Smrg reload_conv_objs= 86341016ad83Smrg gentop= 86351016ad83Smrg # reload_cmds runs $LD directly, so let us get rid of 86361016ad83Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 86371016ad83Smrg # turning comma into space.. 86381016ad83Smrg wl= 86391016ad83Smrg 86401016ad83Smrg if test -n "$convenience"; then 86411016ad83Smrg if test -n "$whole_archive_flag_spec"; then 86421016ad83Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 86431016ad83Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 86441016ad83Smrg else 86451016ad83Smrg gentop="$output_objdir/${obj}x" 86461016ad83Smrg func_append generated " $gentop" 86471016ad83Smrg 86481016ad83Smrg func_extract_archives $gentop $convenience 86491016ad83Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 86501016ad83Smrg fi 86511016ad83Smrg fi 86521016ad83Smrg 86531016ad83Smrg # If we're not building shared, we need to use non_pic_objs 86541016ad83Smrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 86551016ad83Smrg 86561016ad83Smrg # Create the old-style object. 86571016ad83Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 86581016ad83Smrg 86591016ad83Smrg output="$obj" 86601016ad83Smrg func_execute_cmds "$reload_cmds" 'exit $?' 86611016ad83Smrg 86621016ad83Smrg # Exit if we aren't doing a library object file. 86631016ad83Smrg if test -z "$libobj"; then 86641016ad83Smrg if test -n "$gentop"; then 86651016ad83Smrg func_show_eval '${RM}r "$gentop"' 86661016ad83Smrg fi 86671016ad83Smrg 86681016ad83Smrg exit $EXIT_SUCCESS 86691016ad83Smrg fi 86701016ad83Smrg 86711016ad83Smrg if test "$build_libtool_libs" != yes; then 86721016ad83Smrg if test -n "$gentop"; then 86731016ad83Smrg func_show_eval '${RM}r "$gentop"' 86741016ad83Smrg fi 86751016ad83Smrg 86761016ad83Smrg # Create an invalid libtool object if no PIC, so that we don't 86771016ad83Smrg # accidentally link it into a program. 86781016ad83Smrg # $show "echo timestamp > $libobj" 86791016ad83Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 86801016ad83Smrg exit $EXIT_SUCCESS 86811016ad83Smrg fi 86821016ad83Smrg 86831016ad83Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 86841016ad83Smrg # Only do commands if we really have different PIC objects. 86851016ad83Smrg reload_objs="$libobjs $reload_conv_objs" 86861016ad83Smrg output="$libobj" 86871016ad83Smrg func_execute_cmds "$reload_cmds" 'exit $?' 86881016ad83Smrg fi 86891016ad83Smrg 86901016ad83Smrg if test -n "$gentop"; then 86911016ad83Smrg func_show_eval '${RM}r "$gentop"' 86921016ad83Smrg fi 86931016ad83Smrg 86941016ad83Smrg exit $EXIT_SUCCESS 86951016ad83Smrg ;; 86961016ad83Smrg 86971016ad83Smrg prog) 86981016ad83Smrg case $host in 86991016ad83Smrg *cygwin*) func_stripname '' '.exe' "$output" 87001016ad83Smrg output=$func_stripname_result.exe;; 87011016ad83Smrg esac 87021016ad83Smrg test -n "$vinfo" && \ 87031016ad83Smrg func_warning "\`-version-info' is ignored for programs" 87041016ad83Smrg 87051016ad83Smrg test -n "$release" && \ 87061016ad83Smrg func_warning "\`-release' is ignored for programs" 87071016ad83Smrg 87081016ad83Smrg test "$preload" = yes \ 87091016ad83Smrg && test "$dlopen_support" = unknown \ 87101016ad83Smrg && test "$dlopen_self" = unknown \ 87111016ad83Smrg && test "$dlopen_self_static" = unknown && \ 87121016ad83Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 87131016ad83Smrg 87141016ad83Smrg case $host in 87151016ad83Smrg *-*-rhapsody* | *-*-darwin1.[012]) 87161016ad83Smrg # On Rhapsody replace the C library is the System framework 87171016ad83Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 87181016ad83Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 87191016ad83Smrg ;; 87201016ad83Smrg esac 87211016ad83Smrg 87221016ad83Smrg case $host in 87231016ad83Smrg *-*-darwin*) 87241016ad83Smrg # Don't allow lazy linking, it breaks C++ global constructors 87251016ad83Smrg # But is supposedly fixed on 10.4 or later (yay!). 87261016ad83Smrg if test "$tagname" = CXX ; then 87271016ad83Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 87281016ad83Smrg 10.[0123]) 87291016ad83Smrg func_append compile_command " ${wl}-bind_at_load" 87301016ad83Smrg func_append finalize_command " ${wl}-bind_at_load" 87311016ad83Smrg ;; 87321016ad83Smrg esac 87331016ad83Smrg fi 87341016ad83Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 87351016ad83Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 87361016ad83Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 87371016ad83Smrg ;; 87381016ad83Smrg esac 87391016ad83Smrg 87401016ad83Smrg 87411016ad83Smrg # move library search paths that coincide with paths to not yet 87421016ad83Smrg # installed libraries to the beginning of the library search list 87431016ad83Smrg new_libs= 87441016ad83Smrg for path in $notinst_path; do 87451016ad83Smrg case " $new_libs " in 87461016ad83Smrg *" -L$path/$objdir "*) ;; 87471016ad83Smrg *) 87481016ad83Smrg case " $compile_deplibs " in 87491016ad83Smrg *" -L$path/$objdir "*) 87501016ad83Smrg func_append new_libs " -L$path/$objdir" ;; 87511016ad83Smrg esac 87521016ad83Smrg ;; 87531016ad83Smrg esac 87541016ad83Smrg done 87551016ad83Smrg for deplib in $compile_deplibs; do 87561016ad83Smrg case $deplib in 87571016ad83Smrg -L*) 87581016ad83Smrg case " $new_libs " in 87591016ad83Smrg *" $deplib "*) ;; 87601016ad83Smrg *) func_append new_libs " $deplib" ;; 87611016ad83Smrg esac 87621016ad83Smrg ;; 87631016ad83Smrg *) func_append new_libs " $deplib" ;; 87641016ad83Smrg esac 87651016ad83Smrg done 87661016ad83Smrg compile_deplibs="$new_libs" 87671016ad83Smrg 87681016ad83Smrg 87691016ad83Smrg func_append compile_command " $compile_deplibs" 87701016ad83Smrg func_append finalize_command " $finalize_deplibs" 87711016ad83Smrg 87721016ad83Smrg if test -n "$rpath$xrpath"; then 87731016ad83Smrg # If the user specified any rpath flags, then add them. 87741016ad83Smrg for libdir in $rpath $xrpath; do 87751016ad83Smrg # This is the magic to use -rpath. 87761016ad83Smrg case "$finalize_rpath " in 87771016ad83Smrg *" $libdir "*) ;; 87781016ad83Smrg *) func_append finalize_rpath " $libdir" ;; 87791016ad83Smrg esac 87801016ad83Smrg done 87811016ad83Smrg fi 87821016ad83Smrg 87831016ad83Smrg # Now hardcode the library paths 87841016ad83Smrg rpath= 87851016ad83Smrg hardcode_libdirs= 87861016ad83Smrg for libdir in $compile_rpath $finalize_rpath; do 87871016ad83Smrg if test -n "$hardcode_libdir_flag_spec"; then 87881016ad83Smrg if test -n "$hardcode_libdir_separator"; then 87891016ad83Smrg if test -z "$hardcode_libdirs"; then 87901016ad83Smrg hardcode_libdirs="$libdir" 87911016ad83Smrg else 87921016ad83Smrg # Just accumulate the unique libdirs. 87931016ad83Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 87941016ad83Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 87951016ad83Smrg ;; 87961016ad83Smrg *) 87971016ad83Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 87981016ad83Smrg ;; 87991016ad83Smrg esac 88001016ad83Smrg fi 88011016ad83Smrg else 88021016ad83Smrg eval flag=\"$hardcode_libdir_flag_spec\" 88031016ad83Smrg func_append rpath " $flag" 88041016ad83Smrg fi 88051016ad83Smrg elif test -n "$runpath_var"; then 88061016ad83Smrg case "$perm_rpath " in 88071016ad83Smrg *" $libdir "*) ;; 88081016ad83Smrg *) func_append perm_rpath " $libdir" ;; 88091016ad83Smrg esac 88101016ad83Smrg fi 88111016ad83Smrg case $host in 88121016ad83Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 88131016ad83Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 88141016ad83Smrg case :$dllsearchpath: in 88151016ad83Smrg *":$libdir:"*) ;; 88161016ad83Smrg ::) dllsearchpath=$libdir;; 88171016ad83Smrg *) func_append dllsearchpath ":$libdir";; 88181016ad83Smrg esac 88191016ad83Smrg case :$dllsearchpath: in 88201016ad83Smrg *":$testbindir:"*) ;; 88211016ad83Smrg ::) dllsearchpath=$testbindir;; 88221016ad83Smrg *) func_append dllsearchpath ":$testbindir";; 88231016ad83Smrg esac 88241016ad83Smrg ;; 88251016ad83Smrg esac 88261016ad83Smrg done 88271016ad83Smrg # Substitute the hardcoded libdirs into the rpath. 88281016ad83Smrg if test -n "$hardcode_libdir_separator" && 88291016ad83Smrg test -n "$hardcode_libdirs"; then 88301016ad83Smrg libdir="$hardcode_libdirs" 88311016ad83Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 88321016ad83Smrg fi 88331016ad83Smrg compile_rpath="$rpath" 88341016ad83Smrg 88351016ad83Smrg rpath= 88361016ad83Smrg hardcode_libdirs= 88371016ad83Smrg for libdir in $finalize_rpath; do 88381016ad83Smrg if test -n "$hardcode_libdir_flag_spec"; then 88391016ad83Smrg if test -n "$hardcode_libdir_separator"; then 88401016ad83Smrg if test -z "$hardcode_libdirs"; then 88411016ad83Smrg hardcode_libdirs="$libdir" 88421016ad83Smrg else 88431016ad83Smrg # Just accumulate the unique libdirs. 88441016ad83Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 88451016ad83Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 88461016ad83Smrg ;; 88471016ad83Smrg *) 88481016ad83Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 88491016ad83Smrg ;; 88501016ad83Smrg esac 88511016ad83Smrg fi 88521016ad83Smrg else 88531016ad83Smrg eval flag=\"$hardcode_libdir_flag_spec\" 88541016ad83Smrg func_append rpath " $flag" 88551016ad83Smrg fi 88561016ad83Smrg elif test -n "$runpath_var"; then 88571016ad83Smrg case "$finalize_perm_rpath " in 88581016ad83Smrg *" $libdir "*) ;; 88591016ad83Smrg *) func_append finalize_perm_rpath " $libdir" ;; 88601016ad83Smrg esac 88611016ad83Smrg fi 88621016ad83Smrg done 88631016ad83Smrg # Substitute the hardcoded libdirs into the rpath. 88641016ad83Smrg if test -n "$hardcode_libdir_separator" && 88651016ad83Smrg test -n "$hardcode_libdirs"; then 88661016ad83Smrg libdir="$hardcode_libdirs" 88671016ad83Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 88681016ad83Smrg fi 88691016ad83Smrg finalize_rpath="$rpath" 88701016ad83Smrg 88711016ad83Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 88721016ad83Smrg # Transform all the library objects into standard objects. 88731016ad83Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 88741016ad83Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 88751016ad83Smrg fi 88761016ad83Smrg 88771016ad83Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 88781016ad83Smrg 88791016ad83Smrg # template prelinking step 88801016ad83Smrg if test -n "$prelink_cmds"; then 88811016ad83Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 88821016ad83Smrg fi 88831016ad83Smrg 88841016ad83Smrg wrappers_required=yes 88851016ad83Smrg case $host in 88861016ad83Smrg *cegcc* | *mingw32ce*) 88871016ad83Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 88881016ad83Smrg wrappers_required=no 88891016ad83Smrg ;; 88901016ad83Smrg *cygwin* | *mingw* ) 88911016ad83Smrg if test "$build_libtool_libs" != yes; then 88921016ad83Smrg wrappers_required=no 88931016ad83Smrg fi 88941016ad83Smrg ;; 88951016ad83Smrg *) 88961016ad83Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 88971016ad83Smrg wrappers_required=no 88981016ad83Smrg fi 88991016ad83Smrg ;; 89001016ad83Smrg esac 89011016ad83Smrg if test "$wrappers_required" = no; then 89021016ad83Smrg # Replace the output file specification. 89031016ad83Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 89041016ad83Smrg link_command="$compile_command$compile_rpath" 89051016ad83Smrg 89061016ad83Smrg # We have no uninstalled library dependencies, so finalize right now. 89071016ad83Smrg exit_status=0 89081016ad83Smrg func_show_eval "$link_command" 'exit_status=$?' 89091016ad83Smrg 89101016ad83Smrg if test -n "$postlink_cmds"; then 89111016ad83Smrg func_to_tool_file "$output" 89121016ad83Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 89131016ad83Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 89141016ad83Smrg fi 89151016ad83Smrg 89161016ad83Smrg # Delete the generated files. 89171016ad83Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 89181016ad83Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 89191016ad83Smrg fi 89201016ad83Smrg 89211016ad83Smrg exit $exit_status 89221016ad83Smrg fi 89231016ad83Smrg 89241016ad83Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 89251016ad83Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 89261016ad83Smrg fi 89271016ad83Smrg if test -n "$finalize_shlibpath"; then 89281016ad83Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 89291016ad83Smrg fi 89301016ad83Smrg 89311016ad83Smrg compile_var= 89321016ad83Smrg finalize_var= 89331016ad83Smrg if test -n "$runpath_var"; then 89341016ad83Smrg if test -n "$perm_rpath"; then 89351016ad83Smrg # We should set the runpath_var. 89361016ad83Smrg rpath= 89371016ad83Smrg for dir in $perm_rpath; do 89381016ad83Smrg func_append rpath "$dir:" 89391016ad83Smrg done 89401016ad83Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 89411016ad83Smrg fi 89421016ad83Smrg if test -n "$finalize_perm_rpath"; then 89431016ad83Smrg # We should set the runpath_var. 89441016ad83Smrg rpath= 89451016ad83Smrg for dir in $finalize_perm_rpath; do 89461016ad83Smrg func_append rpath "$dir:" 89471016ad83Smrg done 89481016ad83Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 89491016ad83Smrg fi 89501016ad83Smrg fi 89511016ad83Smrg 89521016ad83Smrg if test "$no_install" = yes; then 89531016ad83Smrg # We don't need to create a wrapper script. 89541016ad83Smrg link_command="$compile_var$compile_command$compile_rpath" 89551016ad83Smrg # Replace the output file specification. 89561016ad83Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 89571016ad83Smrg # Delete the old output file. 89581016ad83Smrg $opt_dry_run || $RM $output 89591016ad83Smrg # Link the executable and exit 89601016ad83Smrg func_show_eval "$link_command" 'exit $?' 89611016ad83Smrg 89621016ad83Smrg if test -n "$postlink_cmds"; then 89631016ad83Smrg func_to_tool_file "$output" 89641016ad83Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 89651016ad83Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 89661016ad83Smrg fi 89671016ad83Smrg 89681016ad83Smrg exit $EXIT_SUCCESS 89691016ad83Smrg fi 89701016ad83Smrg 89711016ad83Smrg if test "$hardcode_action" = relink; then 89721016ad83Smrg # Fast installation is not supported 89731016ad83Smrg link_command="$compile_var$compile_command$compile_rpath" 89741016ad83Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 89751016ad83Smrg 89761016ad83Smrg func_warning "this platform does not like uninstalled shared libraries" 89771016ad83Smrg func_warning "\`$output' will be relinked during installation" 89781016ad83Smrg else 89791016ad83Smrg if test "$fast_install" != no; then 89801016ad83Smrg link_command="$finalize_var$compile_command$finalize_rpath" 89811016ad83Smrg if test "$fast_install" = yes; then 89821016ad83Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 89831016ad83Smrg else 89841016ad83Smrg # fast_install is set to needless 89851016ad83Smrg relink_command= 89861016ad83Smrg fi 89871016ad83Smrg else 89881016ad83Smrg link_command="$compile_var$compile_command$compile_rpath" 89891016ad83Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 89901016ad83Smrg fi 89911016ad83Smrg fi 89921016ad83Smrg 89931016ad83Smrg # Replace the output file specification. 89941016ad83Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 89951016ad83Smrg 89961016ad83Smrg # Delete the old output files. 89971016ad83Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 89981016ad83Smrg 89991016ad83Smrg func_show_eval "$link_command" 'exit $?' 90001016ad83Smrg 90011016ad83Smrg if test -n "$postlink_cmds"; then 90021016ad83Smrg func_to_tool_file "$output_objdir/$outputname" 90031016ad83Smrg 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'` 90041016ad83Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 90051016ad83Smrg fi 90061016ad83Smrg 90071016ad83Smrg # Now create the wrapper script. 90081016ad83Smrg func_verbose "creating $output" 90091016ad83Smrg 90101016ad83Smrg # Quote the relink command for shipping. 90111016ad83Smrg if test -n "$relink_command"; then 90121016ad83Smrg # Preserve any variables that may affect compiler behavior 90131016ad83Smrg for var in $variables_saved_for_relink; do 90141016ad83Smrg if eval test -z \"\${$var+set}\"; then 90151016ad83Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 90161016ad83Smrg elif eval var_value=\$$var; test -z "$var_value"; then 90171016ad83Smrg relink_command="$var=; export $var; $relink_command" 90181016ad83Smrg else 90191016ad83Smrg func_quote_for_eval "$var_value" 90201016ad83Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 90211016ad83Smrg fi 90221016ad83Smrg done 90231016ad83Smrg relink_command="(cd `pwd`; $relink_command)" 90241016ad83Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 90251016ad83Smrg fi 90261016ad83Smrg 90271016ad83Smrg # Only actually do things if not in dry run mode. 90281016ad83Smrg $opt_dry_run || { 90291016ad83Smrg # win32 will think the script is a binary if it has 90301016ad83Smrg # a .exe suffix, so we strip it off here. 90311016ad83Smrg case $output in 90321016ad83Smrg *.exe) func_stripname '' '.exe' "$output" 90331016ad83Smrg output=$func_stripname_result ;; 90341016ad83Smrg esac 90351016ad83Smrg # test for cygwin because mv fails w/o .exe extensions 90361016ad83Smrg case $host in 90371016ad83Smrg *cygwin*) 90381016ad83Smrg exeext=.exe 90391016ad83Smrg func_stripname '' '.exe' "$outputname" 90401016ad83Smrg outputname=$func_stripname_result ;; 90411016ad83Smrg *) exeext= ;; 90421016ad83Smrg esac 90431016ad83Smrg case $host in 90441016ad83Smrg *cygwin* | *mingw* ) 90451016ad83Smrg func_dirname_and_basename "$output" "" "." 90461016ad83Smrg output_name=$func_basename_result 90471016ad83Smrg output_path=$func_dirname_result 90481016ad83Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 90491016ad83Smrg cwrapper="$output_path/$output_name.exe" 90501016ad83Smrg $RM $cwrappersource $cwrapper 90511016ad83Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 90521016ad83Smrg 90531016ad83Smrg func_emit_cwrapperexe_src > $cwrappersource 90541016ad83Smrg 90551016ad83Smrg # The wrapper executable is built using the $host compiler, 90561016ad83Smrg # because it contains $host paths and files. If cross- 90571016ad83Smrg # compiling, it, like the target executable, must be 90581016ad83Smrg # executed on the $host or under an emulation environment. 90591016ad83Smrg $opt_dry_run || { 90601016ad83Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 90611016ad83Smrg $STRIP $cwrapper 90621016ad83Smrg } 90631016ad83Smrg 90641016ad83Smrg # Now, create the wrapper script for func_source use: 90651016ad83Smrg func_ltwrapper_scriptname $cwrapper 90661016ad83Smrg $RM $func_ltwrapper_scriptname_result 90671016ad83Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 90681016ad83Smrg $opt_dry_run || { 90691016ad83Smrg # note: this script will not be executed, so do not chmod. 90701016ad83Smrg if test "x$build" = "x$host" ; then 90711016ad83Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 90721016ad83Smrg else 90731016ad83Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 90741016ad83Smrg fi 90751016ad83Smrg } 90761016ad83Smrg ;; 90771016ad83Smrg * ) 90781016ad83Smrg $RM $output 90791016ad83Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 90801016ad83Smrg 90811016ad83Smrg func_emit_wrapper no > $output 90821016ad83Smrg chmod +x $output 90831016ad83Smrg ;; 90841016ad83Smrg esac 90851016ad83Smrg } 90861016ad83Smrg exit $EXIT_SUCCESS 90871016ad83Smrg ;; 90881016ad83Smrg esac 90891016ad83Smrg 90901016ad83Smrg # See if we need to build an old-fashioned archive. 90911016ad83Smrg for oldlib in $oldlibs; do 90921016ad83Smrg 90931016ad83Smrg if test "$build_libtool_libs" = convenience; then 90941016ad83Smrg oldobjs="$libobjs_save $symfileobj" 90951016ad83Smrg addlibs="$convenience" 90961016ad83Smrg build_libtool_libs=no 90971016ad83Smrg else 90981016ad83Smrg if test "$build_libtool_libs" = module; then 90991016ad83Smrg oldobjs="$libobjs_save" 91001016ad83Smrg build_libtool_libs=no 91011016ad83Smrg else 91021016ad83Smrg oldobjs="$old_deplibs $non_pic_objects" 91031016ad83Smrg if test "$preload" = yes && test -f "$symfileobj"; then 91041016ad83Smrg func_append oldobjs " $symfileobj" 91051016ad83Smrg fi 91061016ad83Smrg fi 91071016ad83Smrg addlibs="$old_convenience" 91081016ad83Smrg fi 91091016ad83Smrg 91101016ad83Smrg if test -n "$addlibs"; then 91111016ad83Smrg gentop="$output_objdir/${outputname}x" 91121016ad83Smrg func_append generated " $gentop" 91131016ad83Smrg 91141016ad83Smrg func_extract_archives $gentop $addlibs 91151016ad83Smrg func_append oldobjs " $func_extract_archives_result" 91161016ad83Smrg fi 91171016ad83Smrg 91181016ad83Smrg # Do each command in the archive commands. 91191016ad83Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 91201016ad83Smrg cmds=$old_archive_from_new_cmds 91211016ad83Smrg else 91221016ad83Smrg 91231016ad83Smrg # Add any objects from preloaded convenience libraries 91241016ad83Smrg if test -n "$dlprefiles"; then 91251016ad83Smrg gentop="$output_objdir/${outputname}x" 91261016ad83Smrg func_append generated " $gentop" 91271016ad83Smrg 91281016ad83Smrg func_extract_archives $gentop $dlprefiles 91291016ad83Smrg func_append oldobjs " $func_extract_archives_result" 91301016ad83Smrg fi 91311016ad83Smrg 91321016ad83Smrg # POSIX demands no paths to be encoded in archives. We have 91331016ad83Smrg # to avoid creating archives with duplicate basenames if we 91341016ad83Smrg # might have to extract them afterwards, e.g., when creating a 91351016ad83Smrg # static archive out of a convenience library, or when linking 91361016ad83Smrg # the entirety of a libtool archive into another (currently 91371016ad83Smrg # not supported by libtool). 91381016ad83Smrg if (for obj in $oldobjs 91391016ad83Smrg do 91401016ad83Smrg func_basename "$obj" 91411016ad83Smrg $ECHO "$func_basename_result" 91421016ad83Smrg done | sort | sort -uc >/dev/null 2>&1); then 91431016ad83Smrg : 91441016ad83Smrg else 91451016ad83Smrg echo "copying selected object files to avoid basename conflicts..." 91461016ad83Smrg gentop="$output_objdir/${outputname}x" 91471016ad83Smrg func_append generated " $gentop" 91481016ad83Smrg func_mkdir_p "$gentop" 91491016ad83Smrg save_oldobjs=$oldobjs 91501016ad83Smrg oldobjs= 91511016ad83Smrg counter=1 91521016ad83Smrg for obj in $save_oldobjs 91531016ad83Smrg do 91541016ad83Smrg func_basename "$obj" 91551016ad83Smrg objbase="$func_basename_result" 91561016ad83Smrg case " $oldobjs " in 91571016ad83Smrg " ") oldobjs=$obj ;; 91581016ad83Smrg *[\ /]"$objbase "*) 91591016ad83Smrg while :; do 91601016ad83Smrg # Make sure we don't pick an alternate name that also 91611016ad83Smrg # overlaps. 91621016ad83Smrg newobj=lt$counter-$objbase 91631016ad83Smrg func_arith $counter + 1 91641016ad83Smrg counter=$func_arith_result 91651016ad83Smrg case " $oldobjs " in 91661016ad83Smrg *[\ /]"$newobj "*) ;; 91671016ad83Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 91681016ad83Smrg esac 91691016ad83Smrg done 91701016ad83Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 91711016ad83Smrg func_append oldobjs " $gentop/$newobj" 91721016ad83Smrg ;; 91731016ad83Smrg *) func_append oldobjs " $obj" ;; 91741016ad83Smrg esac 91751016ad83Smrg done 91761016ad83Smrg fi 91771016ad83Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 91781016ad83Smrg tool_oldlib=$func_to_tool_file_result 91791016ad83Smrg eval cmds=\"$old_archive_cmds\" 91801016ad83Smrg 91811016ad83Smrg func_len " $cmds" 91821016ad83Smrg len=$func_len_result 91831016ad83Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 91841016ad83Smrg cmds=$old_archive_cmds 91851016ad83Smrg elif test -n "$archiver_list_spec"; then 91861016ad83Smrg func_verbose "using command file archive linking..." 91871016ad83Smrg for obj in $oldobjs 91881016ad83Smrg do 91891016ad83Smrg func_to_tool_file "$obj" 91901016ad83Smrg $ECHO "$func_to_tool_file_result" 91911016ad83Smrg done > $output_objdir/$libname.libcmd 91921016ad83Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 91931016ad83Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 91941016ad83Smrg cmds=$old_archive_cmds 91951016ad83Smrg else 91961016ad83Smrg # the command line is too long to link in one step, link in parts 91971016ad83Smrg func_verbose "using piecewise archive linking..." 91981016ad83Smrg save_RANLIB=$RANLIB 91991016ad83Smrg RANLIB=: 92001016ad83Smrg objlist= 92011016ad83Smrg concat_cmds= 92021016ad83Smrg save_oldobjs=$oldobjs 92031016ad83Smrg oldobjs= 92041016ad83Smrg # Is there a better way of finding the last object in the list? 92051016ad83Smrg for obj in $save_oldobjs 92061016ad83Smrg do 92071016ad83Smrg last_oldobj=$obj 92081016ad83Smrg done 92091016ad83Smrg eval test_cmds=\"$old_archive_cmds\" 92101016ad83Smrg func_len " $test_cmds" 92111016ad83Smrg len0=$func_len_result 92121016ad83Smrg len=$len0 92131016ad83Smrg for obj in $save_oldobjs 92141016ad83Smrg do 92151016ad83Smrg func_len " $obj" 92161016ad83Smrg func_arith $len + $func_len_result 92171016ad83Smrg len=$func_arith_result 92181016ad83Smrg func_append objlist " $obj" 92191016ad83Smrg if test "$len" -lt "$max_cmd_len"; then 92201016ad83Smrg : 92211016ad83Smrg else 92221016ad83Smrg # the above command should be used before it gets too long 92231016ad83Smrg oldobjs=$objlist 92241016ad83Smrg if test "$obj" = "$last_oldobj" ; then 92251016ad83Smrg RANLIB=$save_RANLIB 92261016ad83Smrg fi 92271016ad83Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 92281016ad83Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 92291016ad83Smrg objlist= 92301016ad83Smrg len=$len0 92311016ad83Smrg fi 92321016ad83Smrg done 92331016ad83Smrg RANLIB=$save_RANLIB 92341016ad83Smrg oldobjs=$objlist 92351016ad83Smrg if test "X$oldobjs" = "X" ; then 92361016ad83Smrg eval cmds=\"\$concat_cmds\" 92371016ad83Smrg else 92381016ad83Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 92391016ad83Smrg fi 92401016ad83Smrg fi 92411016ad83Smrg fi 92421016ad83Smrg func_execute_cmds "$cmds" 'exit $?' 92431016ad83Smrg done 92441016ad83Smrg 92451016ad83Smrg test -n "$generated" && \ 92461016ad83Smrg func_show_eval "${RM}r$generated" 92471016ad83Smrg 92481016ad83Smrg # Now create the libtool archive. 92491016ad83Smrg case $output in 92501016ad83Smrg *.la) 92511016ad83Smrg old_library= 92521016ad83Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 92531016ad83Smrg func_verbose "creating $output" 92541016ad83Smrg 92551016ad83Smrg # Preserve any variables that may affect compiler behavior 92561016ad83Smrg for var in $variables_saved_for_relink; do 92571016ad83Smrg if eval test -z \"\${$var+set}\"; then 92581016ad83Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 92591016ad83Smrg elif eval var_value=\$$var; test -z "$var_value"; then 92601016ad83Smrg relink_command="$var=; export $var; $relink_command" 92611016ad83Smrg else 92621016ad83Smrg func_quote_for_eval "$var_value" 92631016ad83Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 92641016ad83Smrg fi 92651016ad83Smrg done 92661016ad83Smrg # Quote the link command for shipping. 92671016ad83Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 92681016ad83Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 92691016ad83Smrg if test "$hardcode_automatic" = yes ; then 92701016ad83Smrg relink_command= 92711016ad83Smrg fi 92721016ad83Smrg 92731016ad83Smrg # Only create the output if not a dry run. 92741016ad83Smrg $opt_dry_run || { 92751016ad83Smrg for installed in no yes; do 92761016ad83Smrg if test "$installed" = yes; then 92771016ad83Smrg if test -z "$install_libdir"; then 92781016ad83Smrg break 92791016ad83Smrg fi 92801016ad83Smrg output="$output_objdir/$outputname"i 92811016ad83Smrg # Replace all uninstalled libtool libraries with the installed ones 92821016ad83Smrg newdependency_libs= 92831016ad83Smrg for deplib in $dependency_libs; do 92841016ad83Smrg case $deplib in 92851016ad83Smrg *.la) 92861016ad83Smrg func_basename "$deplib" 92871016ad83Smrg name="$func_basename_result" 92881016ad83Smrg func_resolve_sysroot "$deplib" 92891016ad83Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 92901016ad83Smrg test -z "$libdir" && \ 92911016ad83Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 92921016ad83Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 92931016ad83Smrg ;; 92941016ad83Smrg -L*) 92951016ad83Smrg func_stripname -L '' "$deplib" 92961016ad83Smrg func_replace_sysroot "$func_stripname_result" 92971016ad83Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 92981016ad83Smrg ;; 92991016ad83Smrg -R*) 93001016ad83Smrg func_stripname -R '' "$deplib" 93011016ad83Smrg func_replace_sysroot "$func_stripname_result" 93021016ad83Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 93031016ad83Smrg ;; 93041016ad83Smrg *) func_append newdependency_libs " $deplib" ;; 93051016ad83Smrg esac 93061016ad83Smrg done 93071016ad83Smrg dependency_libs="$newdependency_libs" 93081016ad83Smrg newdlfiles= 93091016ad83Smrg 93101016ad83Smrg for lib in $dlfiles; do 93111016ad83Smrg case $lib in 93121016ad83Smrg *.la) 93131016ad83Smrg func_basename "$lib" 93141016ad83Smrg name="$func_basename_result" 93151016ad83Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 93161016ad83Smrg test -z "$libdir" && \ 93171016ad83Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 93181016ad83Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 93191016ad83Smrg ;; 93201016ad83Smrg *) func_append newdlfiles " $lib" ;; 93211016ad83Smrg esac 93221016ad83Smrg done 93231016ad83Smrg dlfiles="$newdlfiles" 93241016ad83Smrg newdlprefiles= 93251016ad83Smrg for lib in $dlprefiles; do 93261016ad83Smrg case $lib in 93271016ad83Smrg *.la) 93281016ad83Smrg # Only pass preopened files to the pseudo-archive (for 93291016ad83Smrg # eventual linking with the app. that links it) if we 93301016ad83Smrg # didn't already link the preopened objects directly into 93311016ad83Smrg # the library: 93321016ad83Smrg func_basename "$lib" 93331016ad83Smrg name="$func_basename_result" 93341016ad83Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 93351016ad83Smrg test -z "$libdir" && \ 93361016ad83Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 93371016ad83Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 93381016ad83Smrg ;; 93391016ad83Smrg esac 93401016ad83Smrg done 93411016ad83Smrg dlprefiles="$newdlprefiles" 93421016ad83Smrg else 93431016ad83Smrg newdlfiles= 93441016ad83Smrg for lib in $dlfiles; do 93451016ad83Smrg case $lib in 93461016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 93471016ad83Smrg *) abs=`pwd`"/$lib" ;; 93481016ad83Smrg esac 93491016ad83Smrg func_append newdlfiles " $abs" 93501016ad83Smrg done 93511016ad83Smrg dlfiles="$newdlfiles" 93521016ad83Smrg newdlprefiles= 93531016ad83Smrg for lib in $dlprefiles; do 93541016ad83Smrg case $lib in 93551016ad83Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 93561016ad83Smrg *) abs=`pwd`"/$lib" ;; 93571016ad83Smrg esac 93581016ad83Smrg func_append newdlprefiles " $abs" 93591016ad83Smrg done 93601016ad83Smrg dlprefiles="$newdlprefiles" 93611016ad83Smrg fi 93621016ad83Smrg $RM $output 93631016ad83Smrg # place dlname in correct position for cygwin 93641016ad83Smrg # In fact, it would be nice if we could use this code for all target 93651016ad83Smrg # systems that can't hard-code library paths into their executables 93661016ad83Smrg # and that have no shared library path variable independent of PATH, 93671016ad83Smrg # but it turns out we can't easily determine that from inspecting 93681016ad83Smrg # libtool variables, so we have to hard-code the OSs to which it 93691016ad83Smrg # applies here; at the moment, that means platforms that use the PE 93701016ad83Smrg # object format with DLL files. See the long comment at the top of 93711016ad83Smrg # tests/bindir.at for full details. 93721016ad83Smrg tdlname=$dlname 93731016ad83Smrg case $host,$output,$installed,$module,$dlname in 93741016ad83Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 93751016ad83Smrg # If a -bindir argument was supplied, place the dll there. 93761016ad83Smrg if test "x$bindir" != x ; 93771016ad83Smrg then 93781016ad83Smrg func_relative_path "$install_libdir" "$bindir" 93791016ad83Smrg tdlname=$func_relative_path_result$dlname 93801016ad83Smrg else 93811016ad83Smrg # Otherwise fall back on heuristic. 93821016ad83Smrg tdlname=../bin/$dlname 93831016ad83Smrg fi 93841016ad83Smrg ;; 93851016ad83Smrg esac 93861016ad83Smrg $ECHO > $output "\ 93871016ad83Smrg# $outputname - a libtool library file 93881016ad83Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 93891016ad83Smrg# 93901016ad83Smrg# Please DO NOT delete this file! 93911016ad83Smrg# It is necessary for linking the library. 93921016ad83Smrg 93931016ad83Smrg# The name that we can dlopen(3). 93941016ad83Smrgdlname='$tdlname' 93951016ad83Smrg 93961016ad83Smrg# Names of this library. 93971016ad83Smrglibrary_names='$library_names' 93981016ad83Smrg 93991016ad83Smrg# The name of the static archive. 94001016ad83Smrgold_library='$old_library' 94011016ad83Smrg 94021016ad83Smrg# Linker flags that can not go in dependency_libs. 94031016ad83Smrginherited_linker_flags='$new_inherited_linker_flags' 94041016ad83Smrg 94051016ad83Smrg# Libraries that this one depends upon. 94061016ad83Smrgdependency_libs='$dependency_libs' 94071016ad83Smrg 94081016ad83Smrg# Names of additional weak libraries provided by this library 94091016ad83Smrgweak_library_names='$weak_libs' 94101016ad83Smrg 94111016ad83Smrg# Version information for $libname. 94121016ad83Smrgcurrent=$current 94131016ad83Smrgage=$age 94141016ad83Smrgrevision=$revision 94151016ad83Smrg 94161016ad83Smrg# Is this an already installed library? 94171016ad83Smrginstalled=$installed 94181016ad83Smrg 94191016ad83Smrg# Should we warn about portability when linking against -modules? 94201016ad83Smrgshouldnotlink=$module 94211016ad83Smrg 94221016ad83Smrg# Files to dlopen/dlpreopen 94231016ad83Smrgdlopen='$dlfiles' 94241016ad83Smrgdlpreopen='$dlprefiles' 94251016ad83Smrg 94261016ad83Smrg# Directory that this library needs to be installed in: 94271016ad83Smrglibdir='$install_libdir'" 94281016ad83Smrg if test "$installed" = no && test "$need_relink" = yes; then 94291016ad83Smrg $ECHO >> $output "\ 94301016ad83Smrgrelink_command=\"$relink_command\"" 94311016ad83Smrg fi 94321016ad83Smrg done 94331016ad83Smrg } 94341016ad83Smrg 94351016ad83Smrg # Do a symbolic link so that the libtool archive can be found in 94361016ad83Smrg # LD_LIBRARY_PATH before the program is installed. 94371016ad83Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 94381016ad83Smrg ;; 94391016ad83Smrg esac 94401016ad83Smrg exit $EXIT_SUCCESS 94411016ad83Smrg} 94421016ad83Smrg 94431016ad83Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 94441016ad83Smrg func_mode_link ${1+"$@"} 94451016ad83Smrg 94461016ad83Smrg 94471016ad83Smrg# func_mode_uninstall arg... 94481016ad83Smrgfunc_mode_uninstall () 94491016ad83Smrg{ 94501016ad83Smrg $opt_debug 94511016ad83Smrg RM="$nonopt" 94521016ad83Smrg files= 94531016ad83Smrg rmforce= 94541016ad83Smrg exit_status=0 94551016ad83Smrg 94561016ad83Smrg # This variable tells wrapper scripts just to set variables rather 94571016ad83Smrg # than running their programs. 94581016ad83Smrg libtool_install_magic="$magic" 94591016ad83Smrg 94601016ad83Smrg for arg 94611016ad83Smrg do 94621016ad83Smrg case $arg in 94631016ad83Smrg -f) func_append RM " $arg"; rmforce=yes ;; 94641016ad83Smrg -*) func_append RM " $arg" ;; 94651016ad83Smrg *) func_append files " $arg" ;; 94661016ad83Smrg esac 94671016ad83Smrg done 94681016ad83Smrg 94691016ad83Smrg test -z "$RM" && \ 94701016ad83Smrg func_fatal_help "you must specify an RM program" 94711016ad83Smrg 94721016ad83Smrg rmdirs= 94731016ad83Smrg 94741016ad83Smrg for file in $files; do 94751016ad83Smrg func_dirname "$file" "" "." 94761016ad83Smrg dir="$func_dirname_result" 94771016ad83Smrg if test "X$dir" = X.; then 94781016ad83Smrg odir="$objdir" 94791016ad83Smrg else 94801016ad83Smrg odir="$dir/$objdir" 94811016ad83Smrg fi 94821016ad83Smrg func_basename "$file" 94831016ad83Smrg name="$func_basename_result" 94841016ad83Smrg test "$opt_mode" = uninstall && odir="$dir" 94851016ad83Smrg 94861016ad83Smrg # Remember odir for removal later, being careful to avoid duplicates 94871016ad83Smrg if test "$opt_mode" = clean; then 94881016ad83Smrg case " $rmdirs " in 94891016ad83Smrg *" $odir "*) ;; 94901016ad83Smrg *) func_append rmdirs " $odir" ;; 94911016ad83Smrg esac 94921016ad83Smrg fi 94931016ad83Smrg 94941016ad83Smrg # Don't error if the file doesn't exist and rm -f was used. 94951016ad83Smrg if { test -L "$file"; } >/dev/null 2>&1 || 94961016ad83Smrg { test -h "$file"; } >/dev/null 2>&1 || 94971016ad83Smrg test -f "$file"; then 94981016ad83Smrg : 94991016ad83Smrg elif test -d "$file"; then 95001016ad83Smrg exit_status=1 95011016ad83Smrg continue 95021016ad83Smrg elif test "$rmforce" = yes; then 95031016ad83Smrg continue 95041016ad83Smrg fi 95051016ad83Smrg 95061016ad83Smrg rmfiles="$file" 95071016ad83Smrg 95081016ad83Smrg case $name in 95091016ad83Smrg *.la) 95101016ad83Smrg # Possibly a libtool archive, so verify it. 95111016ad83Smrg if func_lalib_p "$file"; then 95121016ad83Smrg func_source $dir/$name 95131016ad83Smrg 95141016ad83Smrg # Delete the libtool libraries and symlinks. 95151016ad83Smrg for n in $library_names; do 95161016ad83Smrg func_append rmfiles " $odir/$n" 95171016ad83Smrg done 95181016ad83Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 95191016ad83Smrg 95201016ad83Smrg case "$opt_mode" in 95211016ad83Smrg clean) 95221016ad83Smrg case " $library_names " in 95231016ad83Smrg *" $dlname "*) ;; 95241016ad83Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 95251016ad83Smrg esac 95261016ad83Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 95271016ad83Smrg ;; 95281016ad83Smrg uninstall) 95291016ad83Smrg if test -n "$library_names"; then 95301016ad83Smrg # Do each command in the postuninstall commands. 95311016ad83Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 95321016ad83Smrg fi 95331016ad83Smrg 95341016ad83Smrg if test -n "$old_library"; then 95351016ad83Smrg # Do each command in the old_postuninstall commands. 95361016ad83Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 95371016ad83Smrg fi 95381016ad83Smrg # FIXME: should reinstall the best remaining shared library. 95391016ad83Smrg ;; 95401016ad83Smrg esac 95411016ad83Smrg fi 95421016ad83Smrg ;; 95431016ad83Smrg 95441016ad83Smrg *.lo) 95451016ad83Smrg # Possibly a libtool object, so verify it. 95461016ad83Smrg if func_lalib_p "$file"; then 95471016ad83Smrg 95481016ad83Smrg # Read the .lo file 95491016ad83Smrg func_source $dir/$name 95501016ad83Smrg 95511016ad83Smrg # Add PIC object to the list of files to remove. 95521016ad83Smrg if test -n "$pic_object" && 95531016ad83Smrg test "$pic_object" != none; then 95541016ad83Smrg func_append rmfiles " $dir/$pic_object" 95551016ad83Smrg fi 95561016ad83Smrg 95571016ad83Smrg # Add non-PIC object to the list of files to remove. 95581016ad83Smrg if test -n "$non_pic_object" && 95591016ad83Smrg test "$non_pic_object" != none; then 95601016ad83Smrg func_append rmfiles " $dir/$non_pic_object" 95611016ad83Smrg fi 95621016ad83Smrg fi 95631016ad83Smrg ;; 95641016ad83Smrg 95651016ad83Smrg *) 95661016ad83Smrg if test "$opt_mode" = clean ; then 95671016ad83Smrg noexename=$name 95681016ad83Smrg case $file in 95691016ad83Smrg *.exe) 95701016ad83Smrg func_stripname '' '.exe' "$file" 95711016ad83Smrg file=$func_stripname_result 95721016ad83Smrg func_stripname '' '.exe' "$name" 95731016ad83Smrg noexename=$func_stripname_result 95741016ad83Smrg # $file with .exe has already been added to rmfiles, 95751016ad83Smrg # add $file without .exe 95761016ad83Smrg func_append rmfiles " $file" 95771016ad83Smrg ;; 95781016ad83Smrg esac 95791016ad83Smrg # Do a test to see if this is a libtool program. 95801016ad83Smrg if func_ltwrapper_p "$file"; then 95811016ad83Smrg if func_ltwrapper_executable_p "$file"; then 95821016ad83Smrg func_ltwrapper_scriptname "$file" 95831016ad83Smrg relink_command= 95841016ad83Smrg func_source $func_ltwrapper_scriptname_result 95851016ad83Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 95861016ad83Smrg else 95871016ad83Smrg relink_command= 95881016ad83Smrg func_source $dir/$noexename 95891016ad83Smrg fi 95901016ad83Smrg 95911016ad83Smrg # note $name still contains .exe if it was in $file originally 95921016ad83Smrg # as does the version of $file that was added into $rmfiles 95931016ad83Smrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 95941016ad83Smrg if test "$fast_install" = yes && test -n "$relink_command"; then 95951016ad83Smrg func_append rmfiles " $odir/lt-$name" 95961016ad83Smrg fi 95971016ad83Smrg if test "X$noexename" != "X$name" ; then 95981016ad83Smrg func_append rmfiles " $odir/lt-${noexename}.c" 95991016ad83Smrg fi 96001016ad83Smrg fi 96011016ad83Smrg fi 96021016ad83Smrg ;; 96031016ad83Smrg esac 96041016ad83Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 96051016ad83Smrg done 96061016ad83Smrg 96071016ad83Smrg # Try to remove the ${objdir}s in the directories where we deleted files 96081016ad83Smrg for dir in $rmdirs; do 96091016ad83Smrg if test -d "$dir"; then 96101016ad83Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 96111016ad83Smrg fi 96121016ad83Smrg done 96131016ad83Smrg 96141016ad83Smrg exit $exit_status 96151016ad83Smrg} 96161016ad83Smrg 96171016ad83Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 96181016ad83Smrg func_mode_uninstall ${1+"$@"} 96191016ad83Smrg 96201016ad83Smrgtest -z "$opt_mode" && { 96211016ad83Smrg help="$generic_help" 96221016ad83Smrg func_fatal_help "you must specify a MODE" 96231016ad83Smrg} 96241016ad83Smrg 96251016ad83Smrgtest -z "$exec_cmd" && \ 96261016ad83Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 96271016ad83Smrg 96281016ad83Smrgif test -n "$exec_cmd"; then 96291016ad83Smrg eval exec "$exec_cmd" 96301016ad83Smrg exit $EXIT_FAILURE 96311016ad83Smrgfi 96321016ad83Smrg 96331016ad83Smrgexit $exit_status 96341016ad83Smrg 96351016ad83Smrg 96361016ad83Smrg# The TAGs below are defined such that we never get into a situation 96371016ad83Smrg# in which we disable both kinds of libraries. Given conflicting 96381016ad83Smrg# choices, we go for a static library, that is the most portable, 96391016ad83Smrg# since we can't tell whether shared libraries were disabled because 96401016ad83Smrg# the user asked for that or because the platform doesn't support 96411016ad83Smrg# them. This is particularly important on AIX, because we don't 96421016ad83Smrg# support having both static and shared libraries enabled at the same 96431016ad83Smrg# time on that platform, so we default to a shared-only configuration. 96441016ad83Smrg# If a disable-shared tag is given, we'll fallback to a static-only 96451016ad83Smrg# configuration. But we'll never go from static-only to shared-only. 96461016ad83Smrg 96471016ad83Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 96481016ad83Smrgbuild_libtool_libs=no 96491016ad83Smrgbuild_old_libs=yes 96501016ad83Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 96511016ad83Smrg 96521016ad83Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 96531016ad83Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 96541016ad83Smrg# ### END LIBTOOL TAG CONFIG: disable-static 96551016ad83Smrg 96561016ad83Smrg# Local Variables: 96571016ad83Smrg# mode:shell-script 96581016ad83Smrg# sh-indentation:2 96591016ad83Smrg# End: 96601016ad83Smrg# vi:sw=2 96611016ad83Smrg 9662