ltmain.sh revision aa9e3350
16aec45a7Smrg 2aa9e3350Smrg# libtool (GNU libtool) 2.4.2 36aec45a7Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 46aec45a7Smrg 55c42550eSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 6aa9e3350Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 76aec45a7Smrg# This is free software; see the source for copying conditions. There is NO 86aec45a7Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 96aec45a7Smrg 106aec45a7Smrg# GNU Libtool is free software; you can redistribute it and/or modify 11ab47cfaaSmrg# it under the terms of the GNU General Public License as published by 12ab47cfaaSmrg# the Free Software Foundation; either version 2 of the License, or 13ab47cfaaSmrg# (at your option) any later version. 14ab47cfaaSmrg# 156aec45a7Smrg# As a special exception to the GNU General Public License, 166aec45a7Smrg# if you distribute this file as part of a program or library that 176aec45a7Smrg# is built using GNU Libtool, you may include this file under the 186aec45a7Smrg# same distribution terms that you use for the rest of that program. 196aec45a7Smrg# 206aec45a7Smrg# GNU Libtool is distributed in the hope that it will be useful, but 21ab47cfaaSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 22ab47cfaaSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23ab47cfaaSmrg# General Public License for more details. 24ab47cfaaSmrg# 25ab47cfaaSmrg# You should have received a copy of the GNU General Public License 266aec45a7Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 276aec45a7Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 286aec45a7Smrg# or obtained by writing to the Free Software Foundation, Inc., 296aec45a7Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 305c42550eSmrg 316aec45a7Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 326aec45a7Smrg# 336aec45a7Smrg# Provide generalized library-building support services. 346aec45a7Smrg# 356aec45a7Smrg# --config show all configuration variables 366aec45a7Smrg# --debug enable verbose shell tracing 376aec45a7Smrg# -n, --dry-run display commands without modifying any files 386aec45a7Smrg# --features display basic configuration information and exit 396aec45a7Smrg# --mode=MODE use operation mode MODE 406aec45a7Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 416aec45a7Smrg# --quiet, --silent don't print informational messages 426aec45a7Smrg# --no-quiet, --no-silent 436aec45a7Smrg# print informational messages (default) 44aa9e3350Smrg# --no-warn don't display warning messages 456aec45a7Smrg# --tag=TAG use configuration variables from tag TAG 466aec45a7Smrg# -v, --verbose print more informational messages than default 476aec45a7Smrg# --no-verbose don't print the extra informational messages 486aec45a7Smrg# --version print version information 496aec45a7Smrg# -h, --help, --help-all print short, long, or detailed help message 506aec45a7Smrg# 516aec45a7Smrg# MODE must be one of the following: 526aec45a7Smrg# 536aec45a7Smrg# clean remove files from the build directory 546aec45a7Smrg# compile compile a source file into a libtool object 556aec45a7Smrg# execute automatically set library path, then run a program 566aec45a7Smrg# finish complete the installation of libtool libraries 576aec45a7Smrg# install install libraries or executables 586aec45a7Smrg# link create a library or an executable 596aec45a7Smrg# uninstall remove libraries from an installed directory 606aec45a7Smrg# 616aec45a7Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 626aec45a7Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 636aec45a7Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 646aec45a7Smrg# 656aec45a7Smrg# When reporting a bug, please describe a test case to reproduce it and 666aec45a7Smrg# include the following information: 676aec45a7Smrg# 686aec45a7Smrg# host-triplet: $host 696aec45a7Smrg# shell: $SHELL 706aec45a7Smrg# compiler: $LTCC 716aec45a7Smrg# compiler flags: $LTCFLAGS 726aec45a7Smrg# linker: $LD (gnu? $with_gnu_ld) 73aa9e3350Smrg# $progname: (GNU libtool) 2.4.2 746aec45a7Smrg# automake: $automake_version 756aec45a7Smrg# autoconf: $autoconf_version 766aec45a7Smrg# 776aec45a7Smrg# Report bugs to <bug-libtool@gnu.org>. 78aa9e3350Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 79aa9e3350Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 80ab47cfaaSmrg 816aec45a7SmrgPROGRAM=libtool 82ab47cfaaSmrgPACKAGE=libtool 83aa9e3350SmrgVERSION=2.4.2 846aec45a7SmrgTIMESTAMP="" 85aa9e3350Smrgpackage_revision=1.3337 868697ee19Smrg 876aec45a7Smrg# Be Bourne compatible 888697ee19Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 898697ee19Smrg emulate sh 908697ee19Smrg NULLCMD=: 918697ee19Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 928697ee19Smrg # is contrary to our usage. Disable this feature. 938697ee19Smrg alias -g '${1+"$@"}'='"$@"' 94ab47cfaaSmrg setopt NO_GLOB_SUBST 958697ee19Smrgelse 968697ee19Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 97ab47cfaaSmrgfi 988697ee19SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 998697ee19SmrgDUALCASE=1; export DUALCASE # for MKS sh 100ab47cfaaSmrg 1016aec45a7Smrg# A function that is used when there is no print builtin or printf. 1026aec45a7Smrgfunc_fallback_echo () 1036aec45a7Smrg{ 1046aec45a7Smrg eval 'cat <<_LTECHO_EOF 1056aec45a7Smrg$1 1066aec45a7Smrg_LTECHO_EOF' 1076aec45a7Smrg} 1085c42550eSmrg 1096aec45a7Smrg# NLS nuisances: We save the old values to restore during execute mode. 1106aec45a7Smrglt_user_locale= 1116aec45a7Smrglt_safe_locale= 1121473d951Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1138697ee19Smrgdo 1148697ee19Smrg eval "if test \"\${$lt_var+set}\" = set; then 1156aec45a7Smrg save_$lt_var=\$$lt_var 1166aec45a7Smrg $lt_var=C 1178697ee19Smrg export $lt_var 1186aec45a7Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 1196aec45a7Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 1208697ee19Smrg fi" 1218697ee19Smrgdone 1226aec45a7SmrgLC_ALL=C 1236aec45a7SmrgLANGUAGE=C 1246aec45a7Smrgexport LANGUAGE LC_ALL 125ab47cfaaSmrg 1266aec45a7Smrg$lt_unset CDPATH 1276aec45a7Smrg 1286aec45a7Smrg 1296aec45a7Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 1306aec45a7Smrg# is ksh but when the shell is invoked as "sh" and the current value of 1316aec45a7Smrg# the _XPG environment variable is not equal to 1 (one), the special 1326aec45a7Smrg# positional parameter $0, within a function call, is the name of the 1336aec45a7Smrg# function. 1346aec45a7Smrgprogpath="$0" 1356aec45a7Smrg 1366aec45a7Smrg 1376aec45a7Smrg 1386aec45a7Smrg: ${CP="cp -f"} 1396aec45a7Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 1406aec45a7Smrg: ${MAKE="make"} 1416aec45a7Smrg: ${MKDIR="mkdir"} 1426aec45a7Smrg: ${MV="mv -f"} 1436aec45a7Smrg: ${RM="rm -f"} 1446aec45a7Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 1456aec45a7Smrg: ${Xsed="$SED -e 1s/^X//"} 1466aec45a7Smrg 1476aec45a7Smrg# Global variables: 1486aec45a7SmrgEXIT_SUCCESS=0 1496aec45a7SmrgEXIT_FAILURE=1 1506aec45a7SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 1516aec45a7SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 1526aec45a7Smrg 1536aec45a7Smrgexit_status=$EXIT_SUCCESS 1541473d951Smrg 155ab47cfaaSmrg# Make sure IFS has a sensible default 156ab47cfaaSmrglt_nl=' 157ab47cfaaSmrg' 158ab47cfaaSmrgIFS=" $lt_nl" 159ab47cfaaSmrg 1606aec45a7Smrgdirname="s,/[^/]*$,," 1616aec45a7Smrgbasename="s,^.*/,," 1626aec45a7Smrg 163aa9e3350Smrg# func_dirname file append nondir_replacement 164aa9e3350Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 165aa9e3350Smrg# otherwise set result to NONDIR_REPLACEMENT. 166aa9e3350Smrgfunc_dirname () 167aa9e3350Smrg{ 168aa9e3350Smrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 169aa9e3350Smrg if test "X$func_dirname_result" = "X${1}"; then 170aa9e3350Smrg func_dirname_result="${3}" 171aa9e3350Smrg else 172aa9e3350Smrg func_dirname_result="$func_dirname_result${2}" 173aa9e3350Smrg fi 174aa9e3350Smrg} # func_dirname may be replaced by extended shell implementation 175aa9e3350Smrg 176aa9e3350Smrg 177aa9e3350Smrg# func_basename file 178aa9e3350Smrgfunc_basename () 179aa9e3350Smrg{ 180aa9e3350Smrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 181aa9e3350Smrg} # func_basename may be replaced by extended shell implementation 182aa9e3350Smrg 183aa9e3350Smrg 1846aec45a7Smrg# func_dirname_and_basename file append nondir_replacement 1856aec45a7Smrg# perform func_basename and func_dirname in a single function 1866aec45a7Smrg# call: 1876aec45a7Smrg# dirname: Compute the dirname of FILE. If nonempty, 1886aec45a7Smrg# add APPEND to the result, otherwise set result 1896aec45a7Smrg# to NONDIR_REPLACEMENT. 1906aec45a7Smrg# value returned in "$func_dirname_result" 1916aec45a7Smrg# basename: Compute filename of FILE. 1926aec45a7Smrg# value retuned in "$func_basename_result" 1936aec45a7Smrg# Implementation must be kept synchronized with func_dirname 1946aec45a7Smrg# and func_basename. For efficiency, we do not delegate to 1956aec45a7Smrg# those functions but instead duplicate the functionality here. 1966aec45a7Smrgfunc_dirname_and_basename () 1976aec45a7Smrg{ 198aa9e3350Smrg # Extract subdirectory from the argument. 199aa9e3350Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 200aa9e3350Smrg if test "X$func_dirname_result" = "X${1}"; then 201aa9e3350Smrg func_dirname_result="${3}" 202aa9e3350Smrg else 203aa9e3350Smrg func_dirname_result="$func_dirname_result${2}" 204aa9e3350Smrg fi 205aa9e3350Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 206aa9e3350Smrg} # func_dirname_and_basename may be replaced by extended shell implementation 207aa9e3350Smrg 208aa9e3350Smrg 209aa9e3350Smrg# func_stripname prefix suffix name 210aa9e3350Smrg# strip PREFIX and SUFFIX off of NAME. 211aa9e3350Smrg# PREFIX and SUFFIX must not contain globbing or regex special 212aa9e3350Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 213aa9e3350Smrg# dot (in which case that matches only a dot). 214aa9e3350Smrg# func_strip_suffix prefix name 215aa9e3350Smrgfunc_stripname () 216aa9e3350Smrg{ 217aa9e3350Smrg case ${2} in 218aa9e3350Smrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 219aa9e3350Smrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 220aa9e3350Smrg esac 221aa9e3350Smrg} # func_stripname may be replaced by extended shell implementation 2221473d951Smrg 2236aec45a7Smrg 2246aec45a7Smrg# These SED scripts presuppose an absolute path with a trailing slash. 2256aec45a7Smrgpathcar='s,^/\([^/]*\).*$,\1,' 2266aec45a7Smrgpathcdr='s,^/[^/]*,,' 2276aec45a7Smrgremovedotparts=':dotsl 2286aec45a7Smrg s@/\./@/@g 2296aec45a7Smrg t dotsl 2306aec45a7Smrg s,/\.$,/,' 2316aec45a7Smrgcollapseslashes='s@/\{1,\}@/@g' 2326aec45a7Smrgfinalslash='s,/*$,/,' 2336aec45a7Smrg 2346aec45a7Smrg# func_normal_abspath PATH 2356aec45a7Smrg# Remove doubled-up and trailing slashes, "." path components, 2366aec45a7Smrg# and cancel out any ".." path components in PATH after making 2376aec45a7Smrg# it an absolute path. 2386aec45a7Smrg# value returned in "$func_normal_abspath_result" 2396aec45a7Smrgfunc_normal_abspath () 2406aec45a7Smrg{ 2416aec45a7Smrg # Start from root dir and reassemble the path. 2426aec45a7Smrg func_normal_abspath_result= 2436aec45a7Smrg func_normal_abspath_tpath=$1 2446aec45a7Smrg func_normal_abspath_altnamespace= 2456aec45a7Smrg case $func_normal_abspath_tpath in 2466aec45a7Smrg "") 2476aec45a7Smrg # Empty path, that just means $cwd. 2486aec45a7Smrg func_stripname '' '/' "`pwd`" 2496aec45a7Smrg func_normal_abspath_result=$func_stripname_result 2506aec45a7Smrg return 2516aec45a7Smrg ;; 2526aec45a7Smrg # The next three entries are used to spot a run of precisely 2536aec45a7Smrg # two leading slashes without using negated character classes; 2546aec45a7Smrg # we take advantage of case's first-match behaviour. 2556aec45a7Smrg ///*) 2566aec45a7Smrg # Unusual form of absolute path, do nothing. 2576aec45a7Smrg ;; 2586aec45a7Smrg //*) 2596aec45a7Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 2606aec45a7Smrg # and for example Cygwin uses it to access remote file shares 2616aec45a7Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 2626aec45a7Smrg func_normal_abspath_altnamespace=/ 2636aec45a7Smrg ;; 2646aec45a7Smrg /*) 2656aec45a7Smrg # Absolute path, do nothing. 2666aec45a7Smrg ;; 2676aec45a7Smrg *) 2686aec45a7Smrg # Relative path, prepend $cwd. 2696aec45a7Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 2706aec45a7Smrg ;; 2716aec45a7Smrg esac 2726aec45a7Smrg # Cancel out all the simple stuff to save iterations. We also want 2736aec45a7Smrg # the path to end with a slash for ease of parsing, so make sure 2746aec45a7Smrg # there is one (and only one) here. 2756aec45a7Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 2766aec45a7Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 2776aec45a7Smrg while :; do 2786aec45a7Smrg # Processed it all yet? 2796aec45a7Smrg if test "$func_normal_abspath_tpath" = / ; then 2806aec45a7Smrg # If we ascended to the root using ".." the result may be empty now. 2816aec45a7Smrg if test -z "$func_normal_abspath_result" ; then 2826aec45a7Smrg func_normal_abspath_result=/ 2836aec45a7Smrg fi 2846aec45a7Smrg break 2856aec45a7Smrg fi 2866aec45a7Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 2876aec45a7Smrg -e "$pathcar"` 2886aec45a7Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 2896aec45a7Smrg -e "$pathcdr"` 2906aec45a7Smrg # Figure out what to do with it 2916aec45a7Smrg case $func_normal_abspath_tcomponent in 2926aec45a7Smrg "") 2936aec45a7Smrg # Trailing empty path component, ignore it. 2946aec45a7Smrg ;; 2956aec45a7Smrg ..) 2966aec45a7Smrg # Parent dir; strip last assembled component from result. 2976aec45a7Smrg func_dirname "$func_normal_abspath_result" 2986aec45a7Smrg func_normal_abspath_result=$func_dirname_result 2996aec45a7Smrg ;; 3006aec45a7Smrg *) 3016aec45a7Smrg # Actual path component, append it. 3026aec45a7Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 3036aec45a7Smrg ;; 3046aec45a7Smrg esac 3056aec45a7Smrg done 3066aec45a7Smrg # Restore leading double-slash if one was found on entry. 3076aec45a7Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 3086aec45a7Smrg} 3096aec45a7Smrg 3106aec45a7Smrg# func_relative_path SRCDIR DSTDIR 3116aec45a7Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 3126aec45a7Smrg# slash if non-empty, suitable for immediately appending a filename 3136aec45a7Smrg# without needing to append a separator. 3146aec45a7Smrg# value returned in "$func_relative_path_result" 3156aec45a7Smrgfunc_relative_path () 3166aec45a7Smrg{ 3176aec45a7Smrg func_relative_path_result= 3186aec45a7Smrg func_normal_abspath "$1" 3196aec45a7Smrg func_relative_path_tlibdir=$func_normal_abspath_result 3206aec45a7Smrg func_normal_abspath "$2" 3216aec45a7Smrg func_relative_path_tbindir=$func_normal_abspath_result 3226aec45a7Smrg 3236aec45a7Smrg # Ascend the tree starting from libdir 3246aec45a7Smrg while :; do 3256aec45a7Smrg # check if we have found a prefix of bindir 3266aec45a7Smrg case $func_relative_path_tbindir in 3276aec45a7Smrg $func_relative_path_tlibdir) 3286aec45a7Smrg # found an exact match 3296aec45a7Smrg func_relative_path_tcancelled= 3306aec45a7Smrg break 3316aec45a7Smrg ;; 3326aec45a7Smrg $func_relative_path_tlibdir*) 3336aec45a7Smrg # found a matching prefix 3346aec45a7Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 3356aec45a7Smrg func_relative_path_tcancelled=$func_stripname_result 3366aec45a7Smrg if test -z "$func_relative_path_result"; then 3376aec45a7Smrg func_relative_path_result=. 3386aec45a7Smrg fi 3396aec45a7Smrg break 3406aec45a7Smrg ;; 3416aec45a7Smrg *) 3426aec45a7Smrg func_dirname $func_relative_path_tlibdir 3436aec45a7Smrg func_relative_path_tlibdir=${func_dirname_result} 3446aec45a7Smrg if test "x$func_relative_path_tlibdir" = x ; then 3456aec45a7Smrg # Have to descend all the way to the root! 3466aec45a7Smrg func_relative_path_result=../$func_relative_path_result 3476aec45a7Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 3486aec45a7Smrg break 3496aec45a7Smrg fi 3506aec45a7Smrg func_relative_path_result=../$func_relative_path_result 3516aec45a7Smrg ;; 3526aec45a7Smrg esac 3536aec45a7Smrg done 3546aec45a7Smrg 3556aec45a7Smrg # Now calculate path; take care to avoid doubling-up slashes. 3566aec45a7Smrg func_stripname '' '/' "$func_relative_path_result" 3576aec45a7Smrg func_relative_path_result=$func_stripname_result 3586aec45a7Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 3596aec45a7Smrg if test "x$func_stripname_result" != x ; then 3606aec45a7Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 3616aec45a7Smrg fi 3626aec45a7Smrg 3636aec45a7Smrg # Normalisation. If bindir is libdir, return empty string, 3646aec45a7Smrg # else relative path ending with a slash; either way, target 3656aec45a7Smrg # file name can be directly appended. 3666aec45a7Smrg if test ! -z "$func_relative_path_result"; then 3676aec45a7Smrg func_stripname './' '' "$func_relative_path_result/" 3686aec45a7Smrg func_relative_path_result=$func_stripname_result 3696aec45a7Smrg fi 3706aec45a7Smrg} 3716aec45a7Smrg 3726aec45a7Smrg# The name of this program: 3736aec45a7Smrgfunc_dirname_and_basename "$progpath" 3746aec45a7Smrgprogname=$func_basename_result 3756aec45a7Smrg 3766aec45a7Smrg# Make sure we have an absolute path for reexecution: 3776aec45a7Smrgcase $progpath in 3786aec45a7Smrg [\\/]*|[A-Za-z]:\\*) ;; 3796aec45a7Smrg *[\\/]*) 3806aec45a7Smrg progdir=$func_dirname_result 3816aec45a7Smrg progdir=`cd "$progdir" && pwd` 3826aec45a7Smrg progpath="$progdir/$progname" 3836aec45a7Smrg ;; 3846aec45a7Smrg *) 3856aec45a7Smrg save_IFS="$IFS" 386aa9e3350Smrg IFS=${PATH_SEPARATOR-:} 3876aec45a7Smrg for progdir in $PATH; do 3886aec45a7Smrg IFS="$save_IFS" 3896aec45a7Smrg test -x "$progdir/$progname" && break 3906aec45a7Smrg done 3916aec45a7Smrg IFS="$save_IFS" 3926aec45a7Smrg test -n "$progdir" || progdir=`pwd` 3936aec45a7Smrg progpath="$progdir/$progname" 3946aec45a7Smrg ;; 3956aec45a7Smrgesac 3966aec45a7Smrg 3976aec45a7Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3986aec45a7Smrg# metacharacters that are still active within double-quoted strings. 3996aec45a7SmrgXsed="${SED}"' -e 1s/^X//' 4006aec45a7Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 4016aec45a7Smrg 4026aec45a7Smrg# Same as above, but do not quote variable references. 4036aec45a7Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 4046aec45a7Smrg 405aa9e3350Smrg# Sed substitution that turns a string into a regex matching for the 406aa9e3350Smrg# string literally. 407aa9e3350Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 408aa9e3350Smrg 409aa9e3350Smrg# Sed substitution that converts a w32 file name or path 410aa9e3350Smrg# which contains forward slashes, into one that contains 411aa9e3350Smrg# (escaped) backslashes. A very naive implementation. 412aa9e3350Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 413aa9e3350Smrg 4146aec45a7Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 4156aec45a7Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 4166aec45a7Smrg# in input to double_quote_subst, that '$' was protected from expansion. 4176aec45a7Smrg# Since each input `\' is now two `\'s, look for any number of runs of 4186aec45a7Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 4196aec45a7Smrgbs='\\' 4206aec45a7Smrgbs2='\\\\' 4216aec45a7Smrgbs4='\\\\\\\\' 4226aec45a7Smrgdollar='\$' 4236aec45a7Smrgsed_double_backslash="\ 4246aec45a7Smrg s/$bs4/&\\ 4256aec45a7Smrg/g 4266aec45a7Smrg s/^$bs2$dollar/$bs&/ 4276aec45a7Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 4286aec45a7Smrg s/\n//g" 4296aec45a7Smrg 4306aec45a7Smrg# Standard options: 4316aec45a7Smrgopt_dry_run=false 4326aec45a7Smrgopt_help=false 4336aec45a7Smrgopt_quiet=false 4346aec45a7Smrgopt_verbose=false 4356aec45a7Smrgopt_warning=: 4366aec45a7Smrg 4376aec45a7Smrg# func_echo arg... 4386aec45a7Smrg# Echo program name prefixed message, along with the current mode 4396aec45a7Smrg# name if it has been set yet. 4406aec45a7Smrgfunc_echo () 4416aec45a7Smrg{ 442aa9e3350Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 4436aec45a7Smrg} 4446aec45a7Smrg 4456aec45a7Smrg# func_verbose arg... 4466aec45a7Smrg# Echo program name prefixed message in verbose mode only. 4476aec45a7Smrgfunc_verbose () 4486aec45a7Smrg{ 4496aec45a7Smrg $opt_verbose && func_echo ${1+"$@"} 4506aec45a7Smrg 4516aec45a7Smrg # A bug in bash halts the script if the last line of a function 4526aec45a7Smrg # fails when set -e is in force, so we need another command to 4536aec45a7Smrg # work around that: 4546aec45a7Smrg : 4556aec45a7Smrg} 4566aec45a7Smrg 4576aec45a7Smrg# func_echo_all arg... 4586aec45a7Smrg# Invoke $ECHO with all args, space-separated. 4596aec45a7Smrgfunc_echo_all () 4606aec45a7Smrg{ 4616aec45a7Smrg $ECHO "$*" 4626aec45a7Smrg} 4636aec45a7Smrg 4646aec45a7Smrg# func_error arg... 4656aec45a7Smrg# Echo program name prefixed message to standard error. 4666aec45a7Smrgfunc_error () 4676aec45a7Smrg{ 468aa9e3350Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 4696aec45a7Smrg} 4706aec45a7Smrg 4716aec45a7Smrg# func_warning arg... 4726aec45a7Smrg# Echo program name prefixed warning message to standard error. 4736aec45a7Smrgfunc_warning () 4746aec45a7Smrg{ 475aa9e3350Smrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 4766aec45a7Smrg 4776aec45a7Smrg # bash bug again: 4786aec45a7Smrg : 4796aec45a7Smrg} 4806aec45a7Smrg 4816aec45a7Smrg# func_fatal_error arg... 4826aec45a7Smrg# Echo program name prefixed message to standard error, and exit. 4836aec45a7Smrgfunc_fatal_error () 4846aec45a7Smrg{ 4856aec45a7Smrg func_error ${1+"$@"} 4866aec45a7Smrg exit $EXIT_FAILURE 4876aec45a7Smrg} 4886aec45a7Smrg 4896aec45a7Smrg# func_fatal_help arg... 4906aec45a7Smrg# Echo program name prefixed message to standard error, followed by 4916aec45a7Smrg# a help hint, and exit. 4926aec45a7Smrgfunc_fatal_help () 4936aec45a7Smrg{ 4946aec45a7Smrg func_error ${1+"$@"} 4956aec45a7Smrg func_fatal_error "$help" 4966aec45a7Smrg} 4976aec45a7Smrghelp="Try \`$progname --help' for more information." ## default 4986aec45a7Smrg 4996aec45a7Smrg 5006aec45a7Smrg# func_grep expression filename 5016aec45a7Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 5026aec45a7Smrgfunc_grep () 5036aec45a7Smrg{ 5046aec45a7Smrg $GREP "$1" "$2" >/dev/null 2>&1 5056aec45a7Smrg} 5066aec45a7Smrg 5076aec45a7Smrg 5086aec45a7Smrg# func_mkdir_p directory-path 5096aec45a7Smrg# Make sure the entire path to DIRECTORY-PATH is available. 5106aec45a7Smrgfunc_mkdir_p () 5116aec45a7Smrg{ 5126aec45a7Smrg my_directory_path="$1" 5136aec45a7Smrg my_dir_list= 5146aec45a7Smrg 5156aec45a7Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 5166aec45a7Smrg 5176aec45a7Smrg # Protect directory names starting with `-' 5186aec45a7Smrg case $my_directory_path in 5196aec45a7Smrg -*) my_directory_path="./$my_directory_path" ;; 5206aec45a7Smrg esac 5216aec45a7Smrg 5226aec45a7Smrg # While some portion of DIR does not yet exist... 5236aec45a7Smrg while test ! -d "$my_directory_path"; do 5246aec45a7Smrg # ...make a list in topmost first order. Use a colon delimited 5256aec45a7Smrg # list incase some portion of path contains whitespace. 5266aec45a7Smrg my_dir_list="$my_directory_path:$my_dir_list" 5276aec45a7Smrg 5286aec45a7Smrg # If the last portion added has no slash in it, the list is done 5296aec45a7Smrg case $my_directory_path in */*) ;; *) break ;; esac 5306aec45a7Smrg 5316aec45a7Smrg # ...otherwise throw away the child directory and loop 5326aec45a7Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 5336aec45a7Smrg done 5346aec45a7Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 5356aec45a7Smrg 5366aec45a7Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 5376aec45a7Smrg for my_dir in $my_dir_list; do 5386aec45a7Smrg IFS="$save_mkdir_p_IFS" 5396aec45a7Smrg # mkdir can fail with a `File exist' error if two processes 5406aec45a7Smrg # try to create one of the directories concurrently. Don't 5416aec45a7Smrg # stop in that case! 5426aec45a7Smrg $MKDIR "$my_dir" 2>/dev/null || : 5436aec45a7Smrg done 5446aec45a7Smrg IFS="$save_mkdir_p_IFS" 5456aec45a7Smrg 5466aec45a7Smrg # Bail out if we (or some other process) failed to create a directory. 5476aec45a7Smrg test -d "$my_directory_path" || \ 5486aec45a7Smrg func_fatal_error "Failed to create \`$1'" 5496aec45a7Smrg fi 5506aec45a7Smrg} 551ab47cfaaSmrg 552ab47cfaaSmrg 553ab47cfaaSmrg# func_mktempdir [string] 554ab47cfaaSmrg# Make a temporary directory that won't clash with other running 555ab47cfaaSmrg# libtool processes, and avoids race conditions if possible. If 556ab47cfaaSmrg# given, STRING is the basename for that directory. 557ab47cfaaSmrgfunc_mktempdir () 558ab47cfaaSmrg{ 559ab47cfaaSmrg my_template="${TMPDIR-/tmp}/${1-$progname}" 560ab47cfaaSmrg 5616aec45a7Smrg if test "$opt_dry_run" = ":"; then 562ab47cfaaSmrg # Return a directory name, but don't create it in dry-run mode 563ab47cfaaSmrg my_tmpdir="${my_template}-$$" 564ab47cfaaSmrg else 565ab47cfaaSmrg 566ab47cfaaSmrg # If mktemp works, use that first and foremost 567ab47cfaaSmrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 568ab47cfaaSmrg 569ab47cfaaSmrg if test ! -d "$my_tmpdir"; then 5706aec45a7Smrg # Failing that, at least try and use $RANDOM to avoid a race 5716aec45a7Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 572ab47cfaaSmrg 5736aec45a7Smrg save_mktempdir_umask=`umask` 5746aec45a7Smrg umask 0077 5756aec45a7Smrg $MKDIR "$my_tmpdir" 5766aec45a7Smrg umask $save_mktempdir_umask 577ab47cfaaSmrg fi 578ab47cfaaSmrg 579ab47cfaaSmrg # If we're not in dry-run mode, bomb out on failure 5806aec45a7Smrg test -d "$my_tmpdir" || \ 5816aec45a7Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 582ab47cfaaSmrg fi 583ab47cfaaSmrg 5846aec45a7Smrg $ECHO "$my_tmpdir" 585ab47cfaaSmrg} 586ab47cfaaSmrg 587ab47cfaaSmrg 5886aec45a7Smrg# func_quote_for_eval arg 5896aec45a7Smrg# Aesthetically quote ARG to be evaled later. 5906aec45a7Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 5916aec45a7Smrg# is double-quoted, suitable for a subsequent eval, whereas 5926aec45a7Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 5936aec45a7Smrg# which are still active within double quotes backslashified. 5946aec45a7Smrgfunc_quote_for_eval () 595ab47cfaaSmrg{ 5966aec45a7Smrg case $1 in 5976aec45a7Smrg *[\\\`\"\$]*) 5986aec45a7Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 5996aec45a7Smrg *) 6006aec45a7Smrg func_quote_for_eval_unquoted_result="$1" ;; 6016aec45a7Smrg esac 6026aec45a7Smrg 6036aec45a7Smrg case $func_quote_for_eval_unquoted_result in 6046aec45a7Smrg # Double-quote args containing shell metacharacters to delay 6056aec45a7Smrg # word splitting, command substitution and and variable 6066aec45a7Smrg # expansion for a subsequent eval. 6076aec45a7Smrg # Many Bourne shells cannot handle close brackets correctly 6086aec45a7Smrg # in scan sets, so we specify it separately. 6096aec45a7Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 6106aec45a7Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 6116aec45a7Smrg ;; 6126aec45a7Smrg *) 6136aec45a7Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 614ab47cfaaSmrg esac 615ab47cfaaSmrg} 616ab47cfaaSmrg 617ab47cfaaSmrg 6186aec45a7Smrg# func_quote_for_expand arg 6196aec45a7Smrg# Aesthetically quote ARG to be evaled later; same as above, 6206aec45a7Smrg# but do not quote variable references. 6216aec45a7Smrgfunc_quote_for_expand () 622ab47cfaaSmrg{ 6236aec45a7Smrg case $1 in 6246aec45a7Smrg *[\\\`\"]*) 6256aec45a7Smrg my_arg=`$ECHO "$1" | $SED \ 6266aec45a7Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 627ab47cfaaSmrg *) 6286aec45a7Smrg my_arg="$1" ;; 6296aec45a7Smrg esac 6306aec45a7Smrg 6316aec45a7Smrg case $my_arg in 6326aec45a7Smrg # Double-quote args containing shell metacharacters to delay 6336aec45a7Smrg # word splitting and command substitution for a subsequent eval. 6346aec45a7Smrg # Many Bourne shells cannot handle close brackets correctly 6356aec45a7Smrg # in scan sets, so we specify it separately. 6366aec45a7Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 6376aec45a7Smrg my_arg="\"$my_arg\"" 6386aec45a7Smrg ;; 6396aec45a7Smrg esac 6406aec45a7Smrg 6416aec45a7Smrg func_quote_for_expand_result="$my_arg" 642ab47cfaaSmrg} 643ab47cfaaSmrg 644ab47cfaaSmrg 6456aec45a7Smrg# func_show_eval cmd [fail_exp] 6466aec45a7Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6476aec45a7Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6486aec45a7Smrg# is given, then evaluate it. 6496aec45a7Smrgfunc_show_eval () 650ab47cfaaSmrg{ 6516aec45a7Smrg my_cmd="$1" 6526aec45a7Smrg my_fail_exp="${2-:}" 6531473d951Smrg 6546aec45a7Smrg ${opt_silent-false} || { 6556aec45a7Smrg func_quote_for_expand "$my_cmd" 6566aec45a7Smrg eval "func_echo $func_quote_for_expand_result" 6576aec45a7Smrg } 6586aec45a7Smrg 6596aec45a7Smrg if ${opt_dry_run-false}; then :; else 6606aec45a7Smrg eval "$my_cmd" 6616aec45a7Smrg my_status=$? 6626aec45a7Smrg if test "$my_status" -eq 0; then :; else 6636aec45a7Smrg eval "(exit $my_status); $my_fail_exp" 6646aec45a7Smrg fi 665ab47cfaaSmrg fi 666ab47cfaaSmrg} 667ab47cfaaSmrg 6686aec45a7Smrg 6696aec45a7Smrg# func_show_eval_locale cmd [fail_exp] 6706aec45a7Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 6716aec45a7Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 6726aec45a7Smrg# is given, then evaluate it. Use the saved locale for evaluation. 6736aec45a7Smrgfunc_show_eval_locale () 674ab47cfaaSmrg{ 6756aec45a7Smrg my_cmd="$1" 6766aec45a7Smrg my_fail_exp="${2-:}" 677ab47cfaaSmrg 6786aec45a7Smrg ${opt_silent-false} || { 6796aec45a7Smrg func_quote_for_expand "$my_cmd" 6806aec45a7Smrg eval "func_echo $func_quote_for_expand_result" 6816aec45a7Smrg } 6821473d951Smrg 6836aec45a7Smrg if ${opt_dry_run-false}; then :; else 6846aec45a7Smrg eval "$lt_user_locale 6856aec45a7Smrg $my_cmd" 6866aec45a7Smrg my_status=$? 6876aec45a7Smrg eval "$lt_safe_locale" 6886aec45a7Smrg if test "$my_status" -eq 0; then :; else 6896aec45a7Smrg eval "(exit $my_status); $my_fail_exp" 6905c42550eSmrg fi 6916aec45a7Smrg fi 692ab47cfaaSmrg} 693ab47cfaaSmrg 694aa9e3350Smrg# func_tr_sh 695aa9e3350Smrg# Turn $1 into a string suitable for a shell variable name. 696aa9e3350Smrg# Result is stored in $func_tr_sh_result. All characters 697aa9e3350Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 698aa9e3350Smrg# if $1 begins with a digit, a '_' is prepended as well. 699aa9e3350Smrgfunc_tr_sh () 700aa9e3350Smrg{ 701aa9e3350Smrg case $1 in 702aa9e3350Smrg [0-9]* | *[!a-zA-Z0-9_]*) 703aa9e3350Smrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 704aa9e3350Smrg ;; 705aa9e3350Smrg * ) 706aa9e3350Smrg func_tr_sh_result=$1 707aa9e3350Smrg ;; 708aa9e3350Smrg esac 709aa9e3350Smrg} 710aa9e3350Smrg 7111473d951Smrg 7126aec45a7Smrg# func_version 7136aec45a7Smrg# Echo version message to standard output and exit. 7146aec45a7Smrgfunc_version () 7156aec45a7Smrg{ 716aa9e3350Smrg $opt_debug 717aa9e3350Smrg 7186aec45a7Smrg $SED -n '/(C)/!b go 7196aec45a7Smrg :more 7206aec45a7Smrg /\./!{ 7216aec45a7Smrg N 7226aec45a7Smrg s/\n# / / 7236aec45a7Smrg b more 7246aec45a7Smrg } 7256aec45a7Smrg :go 7266aec45a7Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 7276aec45a7Smrg s/^# // 7286aec45a7Smrg s/^# *$// 7296aec45a7Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 7306aec45a7Smrg p 7316aec45a7Smrg }' < "$progpath" 7326aec45a7Smrg exit $? 7336aec45a7Smrg} 7341473d951Smrg 7356aec45a7Smrg# func_usage 7366aec45a7Smrg# Echo short help message to standard output and exit. 7376aec45a7Smrgfunc_usage () 7386aec45a7Smrg{ 739aa9e3350Smrg $opt_debug 740aa9e3350Smrg 7416aec45a7Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 7426aec45a7Smrg s/^# // 7436aec45a7Smrg s/^# *$// 7446aec45a7Smrg s/\$progname/'$progname'/ 7456aec45a7Smrg p 7466aec45a7Smrg }' < "$progpath" 7476aec45a7Smrg echo 7486aec45a7Smrg $ECHO "run \`$progname --help | more' for full usage" 7496aec45a7Smrg exit $? 7506aec45a7Smrg} 751ab47cfaaSmrg 7526aec45a7Smrg# func_help [NOEXIT] 7536aec45a7Smrg# Echo long help message to standard output and exit, 7546aec45a7Smrg# unless 'noexit' is passed as argument. 7556aec45a7Smrgfunc_help () 7566aec45a7Smrg{ 757aa9e3350Smrg $opt_debug 758aa9e3350Smrg 7596aec45a7Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 760aa9e3350Smrg :print 7616aec45a7Smrg s/^# // 7626aec45a7Smrg s/^# *$// 7636aec45a7Smrg s*\$progname*'$progname'* 7646aec45a7Smrg s*\$host*'"$host"'* 7656aec45a7Smrg s*\$SHELL*'"$SHELL"'* 7666aec45a7Smrg s*\$LTCC*'"$LTCC"'* 7676aec45a7Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 7686aec45a7Smrg s*\$LD*'"$LD"'* 7696aec45a7Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 770aa9e3350Smrg s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 771aa9e3350Smrg s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 7726aec45a7Smrg p 773aa9e3350Smrg d 774aa9e3350Smrg } 775aa9e3350Smrg /^# .* home page:/b print 776aa9e3350Smrg /^# General help using/b print 777aa9e3350Smrg ' < "$progpath" 7786aec45a7Smrg ret=$? 7796aec45a7Smrg if test -z "$1"; then 7806aec45a7Smrg exit $ret 7816aec45a7Smrg fi 7826aec45a7Smrg} 783ab47cfaaSmrg 7846aec45a7Smrg# func_missing_arg argname 7856aec45a7Smrg# Echo program name prefixed message to standard error and set global 7866aec45a7Smrg# exit_cmd. 7876aec45a7Smrgfunc_missing_arg () 7886aec45a7Smrg{ 789aa9e3350Smrg $opt_debug 790aa9e3350Smrg 7916aec45a7Smrg func_error "missing argument for $1." 7926aec45a7Smrg exit_cmd=exit 7936aec45a7Smrg} 794ab47cfaaSmrg 7951473d951Smrg 796aa9e3350Smrg# func_split_short_opt shortopt 797aa9e3350Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 798aa9e3350Smrg# variables after splitting SHORTOPT after the 2nd character. 799aa9e3350Smrgfunc_split_short_opt () 800aa9e3350Smrg{ 801aa9e3350Smrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 802aa9e3350Smrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 803aa9e3350Smrg 804aa9e3350Smrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 805aa9e3350Smrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 806aa9e3350Smrg} # func_split_short_opt may be replaced by extended shell implementation 807aa9e3350Smrg 808aa9e3350Smrg 809aa9e3350Smrg# func_split_long_opt longopt 810aa9e3350Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 811aa9e3350Smrg# variables after splitting LONGOPT at the `=' sign. 812aa9e3350Smrgfunc_split_long_opt () 813aa9e3350Smrg{ 814aa9e3350Smrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 815aa9e3350Smrg my_sed_long_arg='1s/^--[^=]*=//' 816aa9e3350Smrg 817aa9e3350Smrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 818aa9e3350Smrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 819aa9e3350Smrg} # func_split_long_opt may be replaced by extended shell implementation 820aa9e3350Smrg 821aa9e3350Smrgexit_cmd=: 822ab47cfaaSmrg 8238697ee19Smrg 8241473d951Smrg 825ab47cfaaSmrg 8266aec45a7Smrg 8276aec45a7Smrgmagic="%%%MAGIC variable%%%" 8286aec45a7Smrgmagic_exe="%%%MAGIC EXE variable%%%" 8296aec45a7Smrg 8306aec45a7Smrg# Global variables. 8316aec45a7Smrgnonopt= 8326aec45a7Smrgpreserve_args= 8336aec45a7Smrglo2o="s/\\.lo\$/.${objext}/" 8346aec45a7Smrgo2lo="s/\\.${objext}\$/.lo/" 8356aec45a7Smrgextracted_archives= 8366aec45a7Smrgextracted_serial=0 8376aec45a7Smrg 8386aec45a7Smrg# If this variable is set in any of the actions, the command in it 8396aec45a7Smrg# will be execed at the end. This prevents here-documents from being 8406aec45a7Smrg# left over by shells. 8416aec45a7Smrgexec_cmd= 8426aec45a7Smrg 843aa9e3350Smrg# func_append var value 844aa9e3350Smrg# Append VALUE to the end of shell variable VAR. 845aa9e3350Smrgfunc_append () 846aa9e3350Smrg{ 847aa9e3350Smrg eval "${1}=\$${1}\${2}" 848aa9e3350Smrg} # func_append may be replaced by extended shell implementation 849aa9e3350Smrg 850aa9e3350Smrg# func_append_quoted var value 851aa9e3350Smrg# Quote VALUE and append to the end of shell variable VAR, separated 852aa9e3350Smrg# by a space. 853aa9e3350Smrgfunc_append_quoted () 854aa9e3350Smrg{ 855aa9e3350Smrg func_quote_for_eval "${2}" 856aa9e3350Smrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 857aa9e3350Smrg} # func_append_quoted may be replaced by extended shell implementation 858aa9e3350Smrg 859aa9e3350Smrg 860aa9e3350Smrg# func_arith arithmetic-term... 861aa9e3350Smrgfunc_arith () 862aa9e3350Smrg{ 863aa9e3350Smrg func_arith_result=`expr "${@}"` 864aa9e3350Smrg} # func_arith may be replaced by extended shell implementation 865aa9e3350Smrg 866aa9e3350Smrg 867aa9e3350Smrg# func_len string 868aa9e3350Smrg# STRING may not start with a hyphen. 869aa9e3350Smrgfunc_len () 870aa9e3350Smrg{ 871aa9e3350Smrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 872aa9e3350Smrg} # func_len may be replaced by extended shell implementation 873aa9e3350Smrg 874aa9e3350Smrg 875aa9e3350Smrg# func_lo2o object 876aa9e3350Smrgfunc_lo2o () 877aa9e3350Smrg{ 878aa9e3350Smrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 879aa9e3350Smrg} # func_lo2o may be replaced by extended shell implementation 880aa9e3350Smrg 881aa9e3350Smrg 882aa9e3350Smrg# func_xform libobj-or-source 883aa9e3350Smrgfunc_xform () 884aa9e3350Smrg{ 885aa9e3350Smrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 886aa9e3350Smrg} # func_xform may be replaced by extended shell implementation 887aa9e3350Smrg 888aa9e3350Smrg 8896aec45a7Smrg# func_fatal_configuration arg... 8906aec45a7Smrg# Echo program name prefixed message to standard error, followed by 8916aec45a7Smrg# a configuration failure hint, and exit. 8926aec45a7Smrgfunc_fatal_configuration () 8936aec45a7Smrg{ 8946aec45a7Smrg func_error ${1+"$@"} 8956aec45a7Smrg func_error "See the $PACKAGE documentation for more information." 8966aec45a7Smrg func_fatal_error "Fatal configuration error." 8976aec45a7Smrg} 8986aec45a7Smrg 8996aec45a7Smrg 9006aec45a7Smrg# func_config 9016aec45a7Smrg# Display the configuration for all the tags in this script. 9026aec45a7Smrgfunc_config () 9036aec45a7Smrg{ 9046aec45a7Smrg re_begincf='^# ### BEGIN LIBTOOL' 9056aec45a7Smrg re_endcf='^# ### END LIBTOOL' 9066aec45a7Smrg 9076aec45a7Smrg # Default configuration. 9086aec45a7Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 9096aec45a7Smrg 910ab47cfaaSmrg # Now print the configurations for the tags. 911ab47cfaaSmrg for tagname in $taglist; do 9126aec45a7Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 913ab47cfaaSmrg done 9145c42550eSmrg 9156aec45a7Smrg exit $? 9166aec45a7Smrg} 9175c42550eSmrg 9186aec45a7Smrg# func_features 9196aec45a7Smrg# Display the features supported by this script. 9206aec45a7Smrgfunc_features () 9216aec45a7Smrg{ 9226aec45a7Smrg echo "host: $host" 923ab47cfaaSmrg if test "$build_libtool_libs" = yes; then 9246aec45a7Smrg echo "enable shared libraries" 925ab47cfaaSmrg else 9266aec45a7Smrg echo "disable shared libraries" 927ab47cfaaSmrg fi 928ab47cfaaSmrg if test "$build_old_libs" = yes; then 9296aec45a7Smrg echo "enable static libraries" 930ab47cfaaSmrg else 9316aec45a7Smrg echo "disable static libraries" 932ab47cfaaSmrg fi 9336aec45a7Smrg 934ab47cfaaSmrg exit $? 9356aec45a7Smrg} 936ab47cfaaSmrg 9376aec45a7Smrg# func_enable_tag tagname 9386aec45a7Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 9396aec45a7Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 9406aec45a7Smrg# variable here. 9416aec45a7Smrgfunc_enable_tag () 9426aec45a7Smrg{ 9436aec45a7Smrg # Global variable: 9446aec45a7Smrg tagname="$1" 945ab47cfaaSmrg 9466aec45a7Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 9476aec45a7Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 9486aec45a7Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 9491473d951Smrg 9506aec45a7Smrg # Validate tagname. 9516aec45a7Smrg case $tagname in 9526aec45a7Smrg *[!-_A-Za-z0-9,/]*) 9536aec45a7Smrg func_fatal_error "invalid tag name: $tagname" 9546aec45a7Smrg ;; 9556aec45a7Smrg esac 956ab47cfaaSmrg 9576aec45a7Smrg # Don't test for the "default" C tag, as we know it's 9586aec45a7Smrg # there but not specially marked. 9596aec45a7Smrg case $tagname in 9606aec45a7Smrg CC) ;; 9616aec45a7Smrg *) 9626aec45a7Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 9636aec45a7Smrg taglist="$taglist $tagname" 9646aec45a7Smrg 9656aec45a7Smrg # Evaluate the configuration. Be careful to quote the path 9666aec45a7Smrg # and the sed script, to avoid splitting on whitespace, but 9676aec45a7Smrg # also don't use non-portable quotes within backquotes within 9686aec45a7Smrg # quotes we have to do it in 2 steps: 9696aec45a7Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 9706aec45a7Smrg eval "$extractedcf" 9716aec45a7Smrg else 9726aec45a7Smrg func_error "ignoring unknown tag $tagname" 9736aec45a7Smrg fi 9746aec45a7Smrg ;; 9756aec45a7Smrg esac 9766aec45a7Smrg} 9776aec45a7Smrg 978aa9e3350Smrg# func_check_version_match 979aa9e3350Smrg# Ensure that we are using m4 macros, and libtool script from the same 980aa9e3350Smrg# release of libtool. 981aa9e3350Smrgfunc_check_version_match () 9826aec45a7Smrg{ 983aa9e3350Smrg if test "$package_revision" != "$macro_revision"; then 984aa9e3350Smrg if test "$VERSION" != "$macro_version"; then 985aa9e3350Smrg if test -z "$macro_version"; then 986aa9e3350Smrg cat >&2 <<_LT_EOF 987aa9e3350Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 988aa9e3350Smrg$progname: definition of this LT_INIT comes from an older release. 989aa9e3350Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 990aa9e3350Smrg$progname: and run autoconf again. 991aa9e3350Smrg_LT_EOF 992aa9e3350Smrg else 993aa9e3350Smrg cat >&2 <<_LT_EOF 994aa9e3350Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 995aa9e3350Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 996aa9e3350Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 997aa9e3350Smrg$progname: and run autoconf again. 998aa9e3350Smrg_LT_EOF 999aa9e3350Smrg fi 1000aa9e3350Smrg else 1001aa9e3350Smrg cat >&2 <<_LT_EOF 1002aa9e3350Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 1003aa9e3350Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 1004aa9e3350Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 1005aa9e3350Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 1006aa9e3350Smrg_LT_EOF 1007aa9e3350Smrg fi 1008aa9e3350Smrg 1009aa9e3350Smrg exit $EXIT_MISMATCH 1010aa9e3350Smrg fi 1011aa9e3350Smrg} 1012aa9e3350Smrg 1013aa9e3350Smrg 1014aa9e3350Smrg# Shorthand for --mode=foo, only valid as the first argument 1015aa9e3350Smrgcase $1 in 1016aa9e3350Smrgclean|clea|cle|cl) 1017aa9e3350Smrg shift; set dummy --mode clean ${1+"$@"}; shift 1018aa9e3350Smrg ;; 1019aa9e3350Smrgcompile|compil|compi|comp|com|co|c) 1020aa9e3350Smrg shift; set dummy --mode compile ${1+"$@"}; shift 1021aa9e3350Smrg ;; 1022aa9e3350Smrgexecute|execut|execu|exec|exe|ex|e) 1023aa9e3350Smrg shift; set dummy --mode execute ${1+"$@"}; shift 1024aa9e3350Smrg ;; 1025aa9e3350Smrgfinish|finis|fini|fin|fi|f) 1026aa9e3350Smrg shift; set dummy --mode finish ${1+"$@"}; shift 1027aa9e3350Smrg ;; 1028aa9e3350Smrginstall|instal|insta|inst|ins|in|i) 1029aa9e3350Smrg shift; set dummy --mode install ${1+"$@"}; shift 1030aa9e3350Smrg ;; 1031aa9e3350Smrglink|lin|li|l) 1032aa9e3350Smrg shift; set dummy --mode link ${1+"$@"}; shift 1033aa9e3350Smrg ;; 1034aa9e3350Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 1035aa9e3350Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 1036aa9e3350Smrg ;; 1037aa9e3350Smrgesac 1038aa9e3350Smrg 1039aa9e3350Smrg 1040aa9e3350Smrg 1041aa9e3350Smrg# Option defaults: 1042aa9e3350Smrgopt_debug=: 1043aa9e3350Smrgopt_dry_run=false 1044aa9e3350Smrgopt_config=false 1045aa9e3350Smrgopt_preserve_dup_deps=false 1046aa9e3350Smrgopt_features=false 1047aa9e3350Smrgopt_finish=false 1048aa9e3350Smrgopt_help=false 1049aa9e3350Smrgopt_help_all=false 1050aa9e3350Smrgopt_silent=: 1051aa9e3350Smrgopt_warning=: 1052aa9e3350Smrgopt_verbose=: 1053aa9e3350Smrgopt_silent=false 1054aa9e3350Smrgopt_verbose=false 10555c42550eSmrg 1056ab47cfaaSmrg 1057aa9e3350Smrg# Parse options once, thoroughly. This comes as soon as possible in the 1058aa9e3350Smrg# script to make things like `--version' happen as quickly as we can. 1059aa9e3350Smrg{ 1060aa9e3350Smrg # this just eases exit handling 1061aa9e3350Smrg while test $# -gt 0; do 10626aec45a7Smrg opt="$1" 10636aec45a7Smrg shift 10646aec45a7Smrg case $opt in 1065aa9e3350Smrg --debug|-x) opt_debug='set -x' 10666aec45a7Smrg func_echo "enabling shell trace mode" 10676aec45a7Smrg $opt_debug 10686aec45a7Smrg ;; 1069aa9e3350Smrg --dry-run|--dryrun|-n) 1070aa9e3350Smrg opt_dry_run=: 10716aec45a7Smrg ;; 1072aa9e3350Smrg --config) 1073aa9e3350Smrg opt_config=: 1074aa9e3350Smrgfunc_config 1075aa9e3350Smrg ;; 1076aa9e3350Smrg --dlopen|-dlopen) 1077aa9e3350Smrg optarg="$1" 1078aa9e3350Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 1079aa9e3350Smrg}$optarg" 10806aec45a7Smrg shift 10816aec45a7Smrg ;; 10826aec45a7Smrg --preserve-dup-deps) 1083aa9e3350Smrg opt_preserve_dup_deps=: 10846aec45a7Smrg ;; 1085aa9e3350Smrg --features) 1086aa9e3350Smrg opt_features=: 1087aa9e3350Smrgfunc_features 10886aec45a7Smrg ;; 1089aa9e3350Smrg --finish) 1090aa9e3350Smrg opt_finish=: 1091aa9e3350Smrgset dummy --mode finish ${1+"$@"}; shift 1092aa9e3350Smrg ;; 1093aa9e3350Smrg --help) 1094aa9e3350Smrg opt_help=: 1095aa9e3350Smrg ;; 1096aa9e3350Smrg --help-all) 1097aa9e3350Smrg opt_help_all=: 1098aa9e3350Smrgopt_help=': help-all' 1099aa9e3350Smrg ;; 1100aa9e3350Smrg --mode) 1101aa9e3350Smrg test $# = 0 && func_missing_arg $opt && break 1102aa9e3350Smrg optarg="$1" 1103aa9e3350Smrg opt_mode="$optarg" 1104aa9e3350Smrgcase $optarg in 1105aa9e3350Smrg # Valid mode arguments: 1106aa9e3350Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 1107aa9e3350Smrg 1108aa9e3350Smrg # Catch anything else as an error 1109aa9e3350Smrg *) func_error "invalid argument for $opt" 1110aa9e3350Smrg exit_cmd=exit 1111aa9e3350Smrg break 1112aa9e3350Smrg ;; 1113aa9e3350Smrgesac 1114aa9e3350Smrg shift 1115aa9e3350Smrg ;; 1116aa9e3350Smrg --no-silent|--no-quiet) 11176aec45a7Smrg opt_silent=false 1118aa9e3350Smrgfunc_append preserve_args " $opt" 11196aec45a7Smrg ;; 1120aa9e3350Smrg --no-warning|--no-warn) 1121aa9e3350Smrg opt_warning=false 1122aa9e3350Smrgfunc_append preserve_args " $opt" 1123aa9e3350Smrg ;; 1124aa9e3350Smrg --no-verbose) 11256aec45a7Smrg opt_verbose=false 1126aa9e3350Smrgfunc_append preserve_args " $opt" 11276aec45a7Smrg ;; 1128aa9e3350Smrg --silent|--quiet) 1129aa9e3350Smrg opt_silent=: 1130aa9e3350Smrgfunc_append preserve_args " $opt" 1131aa9e3350Smrg opt_verbose=false 1132aa9e3350Smrg ;; 1133aa9e3350Smrg --verbose|-v) 1134aa9e3350Smrg opt_verbose=: 1135aa9e3350Smrgfunc_append preserve_args " $opt" 1136aa9e3350Smrgopt_silent=false 1137aa9e3350Smrg ;; 1138aa9e3350Smrg --tag) 1139aa9e3350Smrg test $# = 0 && func_missing_arg $opt && break 1140aa9e3350Smrg optarg="$1" 1141aa9e3350Smrg opt_tag="$optarg" 1142aa9e3350Smrgfunc_append preserve_args " $opt $optarg" 1143aa9e3350Smrgfunc_enable_tag "$optarg" 11446aec45a7Smrg shift 11456aec45a7Smrg ;; 11466aec45a7Smrg 1147aa9e3350Smrg -\?|-h) func_usage ;; 1148aa9e3350Smrg --help) func_help ;; 1149aa9e3350Smrg --version) func_version ;; 1150aa9e3350Smrg 11516aec45a7Smrg # Separate optargs to long options: 1152aa9e3350Smrg --*=*) 1153aa9e3350Smrg func_split_long_opt "$opt" 1154aa9e3350Smrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 11556aec45a7Smrg shift 11566aec45a7Smrg ;; 11576aec45a7Smrg 1158aa9e3350Smrg # Separate non-argument short options: 1159aa9e3350Smrg -\?*|-h*|-n*|-v*) 1160aa9e3350Smrg func_split_short_opt "$opt" 1161aa9e3350Smrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 1162aa9e3350Smrg shift 11636aec45a7Smrg ;; 1164aa9e3350Smrg 1165aa9e3350Smrg --) break ;; 1166aa9e3350Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 1167aa9e3350Smrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 11686aec45a7Smrg esac 11696aec45a7Smrg done 11706aec45a7Smrg 1171aa9e3350Smrg # Validate options: 1172aa9e3350Smrg 1173aa9e3350Smrg # save first non-option argument 1174aa9e3350Smrg if test "$#" -gt 0; then 1175aa9e3350Smrg nonopt="$opt" 1176aa9e3350Smrg shift 1177aa9e3350Smrg fi 1178aa9e3350Smrg 1179aa9e3350Smrg # preserve --debug 1180aa9e3350Smrg test "$opt_debug" = : || func_append preserve_args " --debug" 11816aec45a7Smrg 11826aec45a7Smrg case $host in 11836aec45a7Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 11846aec45a7Smrg # don't eliminate duplications in $postdeps and $predeps 11856aec45a7Smrg opt_duplicate_compiler_generated_deps=: 11865c42550eSmrg ;; 11875c42550eSmrg *) 1188aa9e3350Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 11896aec45a7Smrg ;; 11906aec45a7Smrg esac 11911473d951Smrg 1192aa9e3350Smrg $opt_help || { 1193aa9e3350Smrg # Sanity checks first: 1194aa9e3350Smrg func_check_version_match 11956aec45a7Smrg 1196aa9e3350Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 1197aa9e3350Smrg func_fatal_configuration "not configured to build any kind of library" 11986aec45a7Smrg fi 11996aec45a7Smrg 1200aa9e3350Smrg # Darwin sucks 1201aa9e3350Smrg eval std_shrext=\"$shrext_cmds\" 12026aec45a7Smrg 1203aa9e3350Smrg # Only execute mode is allowed to have -dlopen flags. 1204aa9e3350Smrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 1205aa9e3350Smrg func_error "unrecognized option \`-dlopen'" 1206aa9e3350Smrg $ECHO "$help" 1>&2 1207aa9e3350Smrg exit $EXIT_FAILURE 1208aa9e3350Smrg fi 12096aec45a7Smrg 1210aa9e3350Smrg # Change the help message to a mode-specific one. 1211aa9e3350Smrg generic_help="$help" 1212aa9e3350Smrg help="Try \`$progname --help --mode=$opt_mode' for more information." 1213aa9e3350Smrg } 12146aec45a7Smrg 12156aec45a7Smrg 1216aa9e3350Smrg # Bail if the options were screwed 1217aa9e3350Smrg $exit_cmd $EXIT_FAILURE 1218aa9e3350Smrg} 12196aec45a7Smrg 12206aec45a7Smrg 1221ab47cfaaSmrg 1222ab47cfaaSmrg 1223aa9e3350Smrg## ----------- ## 1224aa9e3350Smrg## Main. ## 1225aa9e3350Smrg## ----------- ## 1226ab47cfaaSmrg 12276aec45a7Smrg# func_lalib_p file 12286aec45a7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 12296aec45a7Smrg# This function is only a basic sanity check; it will hardly flush out 12306aec45a7Smrg# determined imposters. 12316aec45a7Smrgfunc_lalib_p () 12326aec45a7Smrg{ 12336aec45a7Smrg test -f "$1" && 12346aec45a7Smrg $SED -e 4q "$1" 2>/dev/null \ 12356aec45a7Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 12366aec45a7Smrg} 1237ab47cfaaSmrg 12386aec45a7Smrg# func_lalib_unsafe_p file 12396aec45a7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 12406aec45a7Smrg# This function implements the same check as func_lalib_p without 12416aec45a7Smrg# resorting to external programs. To this end, it redirects stdin and 12426aec45a7Smrg# closes it afterwards, without saving the original file descriptor. 12436aec45a7Smrg# As a safety measure, use it only where a negative result would be 12446aec45a7Smrg# fatal anyway. Works if `file' does not exist. 12456aec45a7Smrgfunc_lalib_unsafe_p () 12466aec45a7Smrg{ 12476aec45a7Smrg lalib_p=no 12486aec45a7Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 12496aec45a7Smrg for lalib_p_l in 1 2 3 4 12506aec45a7Smrg do 12516aec45a7Smrg read lalib_p_line 12526aec45a7Smrg case "$lalib_p_line" in 12536aec45a7Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 12546aec45a7Smrg esac 12556aec45a7Smrg done 12566aec45a7Smrg exec 0<&5 5<&- 12576aec45a7Smrg fi 12586aec45a7Smrg test "$lalib_p" = yes 12596aec45a7Smrg} 1260ab47cfaaSmrg 12616aec45a7Smrg# func_ltwrapper_script_p file 12626aec45a7Smrg# True iff FILE is a libtool wrapper script 12636aec45a7Smrg# This function is only a basic sanity check; it will hardly flush out 12646aec45a7Smrg# determined imposters. 12656aec45a7Smrgfunc_ltwrapper_script_p () 12666aec45a7Smrg{ 12676aec45a7Smrg func_lalib_p "$1" 12686aec45a7Smrg} 1269ab47cfaaSmrg 12706aec45a7Smrg# func_ltwrapper_executable_p file 12716aec45a7Smrg# True iff FILE is a libtool wrapper executable 12726aec45a7Smrg# This function is only a basic sanity check; it will hardly flush out 12736aec45a7Smrg# determined imposters. 12746aec45a7Smrgfunc_ltwrapper_executable_p () 12756aec45a7Smrg{ 12766aec45a7Smrg func_ltwrapper_exec_suffix= 12776aec45a7Smrg case $1 in 12786aec45a7Smrg *.exe) ;; 12796aec45a7Smrg *) func_ltwrapper_exec_suffix=.exe ;; 12806aec45a7Smrg esac 12816aec45a7Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 12826aec45a7Smrg} 12836aec45a7Smrg 12846aec45a7Smrg# func_ltwrapper_scriptname file 12856aec45a7Smrg# Assumes file is an ltwrapper_executable 12866aec45a7Smrg# uses $file to determine the appropriate filename for a 12876aec45a7Smrg# temporary ltwrapper_script. 12886aec45a7Smrgfunc_ltwrapper_scriptname () 12896aec45a7Smrg{ 1290aa9e3350Smrg func_dirname_and_basename "$1" "" "." 1291aa9e3350Smrg func_stripname '' '.exe' "$func_basename_result" 1292aa9e3350Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 12936aec45a7Smrg} 12946aec45a7Smrg 12956aec45a7Smrg# func_ltwrapper_p file 12966aec45a7Smrg# True iff FILE is a libtool wrapper script or wrapper executable 12976aec45a7Smrg# This function is only a basic sanity check; it will hardly flush out 12986aec45a7Smrg# determined imposters. 12996aec45a7Smrgfunc_ltwrapper_p () 13006aec45a7Smrg{ 13016aec45a7Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 13026aec45a7Smrg} 13036aec45a7Smrg 13046aec45a7Smrg 13056aec45a7Smrg# func_execute_cmds commands fail_cmd 13066aec45a7Smrg# Execute tilde-delimited COMMANDS. 13076aec45a7Smrg# If FAIL_CMD is given, eval that upon failure. 13086aec45a7Smrg# FAIL_CMD may read-access the current command in variable CMD! 13096aec45a7Smrgfunc_execute_cmds () 13106aec45a7Smrg{ 13116aec45a7Smrg $opt_debug 13126aec45a7Smrg save_ifs=$IFS; IFS='~' 13136aec45a7Smrg for cmd in $1; do 13146aec45a7Smrg IFS=$save_ifs 13156aec45a7Smrg eval cmd=\"$cmd\" 13166aec45a7Smrg func_show_eval "$cmd" "${2-:}" 13176aec45a7Smrg done 13186aec45a7Smrg IFS=$save_ifs 13196aec45a7Smrg} 13206aec45a7Smrg 13216aec45a7Smrg 13226aec45a7Smrg# func_source file 13236aec45a7Smrg# Source FILE, adding directory component if necessary. 13246aec45a7Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 13256aec45a7Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 13266aec45a7Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 13276aec45a7Smrg# `FILE.' does not work on cygwin managed mounts. 13286aec45a7Smrgfunc_source () 13296aec45a7Smrg{ 13306aec45a7Smrg $opt_debug 13316aec45a7Smrg case $1 in 13326aec45a7Smrg */* | *\\*) . "$1" ;; 13336aec45a7Smrg *) . "./$1" ;; 13346aec45a7Smrg esac 13356aec45a7Smrg} 13366aec45a7Smrg 13376aec45a7Smrg 1338aa9e3350Smrg# func_resolve_sysroot PATH 1339aa9e3350Smrg# Replace a leading = in PATH with a sysroot. Store the result into 1340aa9e3350Smrg# func_resolve_sysroot_result 1341aa9e3350Smrgfunc_resolve_sysroot () 1342aa9e3350Smrg{ 1343aa9e3350Smrg func_resolve_sysroot_result=$1 1344aa9e3350Smrg case $func_resolve_sysroot_result in 1345aa9e3350Smrg =*) 1346aa9e3350Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 1347aa9e3350Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 1348aa9e3350Smrg ;; 1349aa9e3350Smrg esac 1350aa9e3350Smrg} 1351aa9e3350Smrg 1352aa9e3350Smrg# func_replace_sysroot PATH 1353aa9e3350Smrg# If PATH begins with the sysroot, replace it with = and 1354aa9e3350Smrg# store the result into func_replace_sysroot_result. 1355aa9e3350Smrgfunc_replace_sysroot () 1356aa9e3350Smrg{ 1357aa9e3350Smrg case "$lt_sysroot:$1" in 1358aa9e3350Smrg ?*:"$lt_sysroot"*) 1359aa9e3350Smrg func_stripname "$lt_sysroot" '' "$1" 1360aa9e3350Smrg func_replace_sysroot_result="=$func_stripname_result" 1361aa9e3350Smrg ;; 1362aa9e3350Smrg *) 1363aa9e3350Smrg # Including no sysroot. 1364aa9e3350Smrg func_replace_sysroot_result=$1 1365aa9e3350Smrg ;; 1366aa9e3350Smrg esac 1367aa9e3350Smrg} 1368aa9e3350Smrg 13696aec45a7Smrg# func_infer_tag arg 13706aec45a7Smrg# Infer tagged configuration to use if any are available and 13716aec45a7Smrg# if one wasn't chosen via the "--tag" command line option. 13726aec45a7Smrg# Only attempt this if the compiler in the base compile 13736aec45a7Smrg# command doesn't match the default compiler. 13746aec45a7Smrg# arg is usually of the form 'gcc ...' 13756aec45a7Smrgfunc_infer_tag () 13766aec45a7Smrg{ 13776aec45a7Smrg $opt_debug 13786aec45a7Smrg if test -n "$available_tags" && test -z "$tagname"; then 13796aec45a7Smrg CC_quoted= 13806aec45a7Smrg for arg in $CC; do 1381aa9e3350Smrg func_append_quoted CC_quoted "$arg" 13826aec45a7Smrg done 13836aec45a7Smrg CC_expanded=`func_echo_all $CC` 13846aec45a7Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 13856aec45a7Smrg case $@ in 13866aec45a7Smrg # Blanks in the command may have been stripped by the calling shell, 13876aec45a7Smrg # but not from the CC environment variable when configure was run. 13886aec45a7Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 13896aec45a7Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 13906aec45a7Smrg # Blanks at the start of $base_compile will cause this to fail 13916aec45a7Smrg # if we don't check for them as well. 13926aec45a7Smrg *) 13936aec45a7Smrg for z in $available_tags; do 13946aec45a7Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 13956aec45a7Smrg # Evaluate the configuration. 13966aec45a7Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 13976aec45a7Smrg CC_quoted= 13986aec45a7Smrg for arg in $CC; do 13996aec45a7Smrg # Double-quote args containing other shell metacharacters. 1400aa9e3350Smrg func_append_quoted CC_quoted "$arg" 14016aec45a7Smrg done 14026aec45a7Smrg CC_expanded=`func_echo_all $CC` 14036aec45a7Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 14046aec45a7Smrg case "$@ " in 14056aec45a7Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 14066aec45a7Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 14076aec45a7Smrg # The compiler in the base compile command matches 14086aec45a7Smrg # the one in the tagged configuration. 14096aec45a7Smrg # Assume this is the tagged configuration we want. 14106aec45a7Smrg tagname=$z 14116aec45a7Smrg break 14126aec45a7Smrg ;; 14136aec45a7Smrg esac 14146aec45a7Smrg fi 14156aec45a7Smrg done 14166aec45a7Smrg # If $tagname still isn't set, then no tagged configuration 14176aec45a7Smrg # was found and let the user know that the "--tag" command 14186aec45a7Smrg # line option must be used. 14196aec45a7Smrg if test -z "$tagname"; then 14206aec45a7Smrg func_echo "unable to infer tagged configuration" 14216aec45a7Smrg func_fatal_error "specify a tag with \`--tag'" 14226aec45a7Smrg# else 14236aec45a7Smrg# func_verbose "using $tagname tagged configuration" 14246aec45a7Smrg fi 14256aec45a7Smrg ;; 14266aec45a7Smrg esac 14276aec45a7Smrg fi 14286aec45a7Smrg} 14296aec45a7Smrg 14306aec45a7Smrg 1431aa9e3350Smrg 1432aa9e3350Smrg# func_write_libtool_object output_name pic_name nonpic_name 1433aa9e3350Smrg# Create a libtool object file (analogous to a ".la" file), 1434aa9e3350Smrg# but don't create it if we're doing a dry run. 1435aa9e3350Smrgfunc_write_libtool_object () 1436aa9e3350Smrg{ 1437aa9e3350Smrg write_libobj=${1} 1438aa9e3350Smrg if test "$build_libtool_libs" = yes; then 1439aa9e3350Smrg write_lobj=\'${2}\' 1440aa9e3350Smrg else 1441aa9e3350Smrg write_lobj=none 1442aa9e3350Smrg fi 1443aa9e3350Smrg 1444aa9e3350Smrg if test "$build_old_libs" = yes; then 1445aa9e3350Smrg write_oldobj=\'${3}\' 1446aa9e3350Smrg else 1447aa9e3350Smrg write_oldobj=none 1448aa9e3350Smrg fi 1449aa9e3350Smrg 1450aa9e3350Smrg $opt_dry_run || { 1451aa9e3350Smrg cat >${write_libobj}T <<EOF 1452aa9e3350Smrg# $write_libobj - a libtool object file 1453aa9e3350Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1454aa9e3350Smrg# 1455aa9e3350Smrg# Please DO NOT delete this file! 1456aa9e3350Smrg# It is necessary for linking the library. 1457aa9e3350Smrg 1458aa9e3350Smrg# Name of the PIC object. 1459aa9e3350Smrgpic_object=$write_lobj 1460aa9e3350Smrg 1461aa9e3350Smrg# Name of the non-PIC object 1462aa9e3350Smrgnon_pic_object=$write_oldobj 1463aa9e3350Smrg 1464aa9e3350SmrgEOF 1465aa9e3350Smrg $MV "${write_libobj}T" "${write_libobj}" 1466aa9e3350Smrg } 1467aa9e3350Smrg} 1468aa9e3350Smrg 1469aa9e3350Smrg 1470aa9e3350Smrg################################################## 1471aa9e3350Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 1472aa9e3350Smrg################################################## 1473aa9e3350Smrg 1474aa9e3350Smrg# func_convert_core_file_wine_to_w32 ARG 1475aa9e3350Smrg# Helper function used by file name conversion functions when $build is *nix, 1476aa9e3350Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 1477aa9e3350Smrg# correctly configured wine environment available, with the winepath program 1478aa9e3350Smrg# in $build's $PATH. 1479aa9e3350Smrg# 1480aa9e3350Smrg# ARG is the $build file name to be converted to w32 format. 1481aa9e3350Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 1482aa9e3350Smrg# be empty on error (or when ARG is empty) 1483aa9e3350Smrgfunc_convert_core_file_wine_to_w32 () 1484aa9e3350Smrg{ 1485aa9e3350Smrg $opt_debug 1486aa9e3350Smrg func_convert_core_file_wine_to_w32_result="$1" 1487aa9e3350Smrg if test -n "$1"; then 1488aa9e3350Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 1489aa9e3350Smrg # are forced to check the contents of stdout. On the other hand, if the 1490aa9e3350Smrg # command is not found, the shell will set an exit code of 127 and print 1491aa9e3350Smrg # *an error message* to stdout. So we must check for both error code of 1492aa9e3350Smrg # zero AND non-empty stdout, which explains the odd construction: 1493aa9e3350Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 1494aa9e3350Smrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 1495aa9e3350Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 1496aa9e3350Smrg $SED -e "$lt_sed_naive_backslashify"` 1497aa9e3350Smrg else 1498aa9e3350Smrg func_convert_core_file_wine_to_w32_result= 1499aa9e3350Smrg fi 1500aa9e3350Smrg fi 1501aa9e3350Smrg} 1502aa9e3350Smrg# end: func_convert_core_file_wine_to_w32 1503aa9e3350Smrg 1504aa9e3350Smrg 1505aa9e3350Smrg# func_convert_core_path_wine_to_w32 ARG 1506aa9e3350Smrg# Helper function used by path conversion functions when $build is *nix, and 1507aa9e3350Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 1508aa9e3350Smrg# configured wine environment available, with the winepath program in $build's 1509aa9e3350Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 1510aa9e3350Smrg# 1511aa9e3350Smrg# ARG is path to be converted from $build format to win32. 1512aa9e3350Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 1513aa9e3350Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 1514aa9e3350Smrg# are convertible, then the result may be empty. 1515aa9e3350Smrgfunc_convert_core_path_wine_to_w32 () 1516aa9e3350Smrg{ 1517aa9e3350Smrg $opt_debug 1518aa9e3350Smrg # unfortunately, winepath doesn't convert paths, only file names 1519aa9e3350Smrg func_convert_core_path_wine_to_w32_result="" 1520aa9e3350Smrg if test -n "$1"; then 1521aa9e3350Smrg oldIFS=$IFS 1522aa9e3350Smrg IFS=: 1523aa9e3350Smrg for func_convert_core_path_wine_to_w32_f in $1; do 1524aa9e3350Smrg IFS=$oldIFS 1525aa9e3350Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 1526aa9e3350Smrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 1527aa9e3350Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 1528aa9e3350Smrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 1529aa9e3350Smrg else 1530aa9e3350Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 1531aa9e3350Smrg fi 1532aa9e3350Smrg fi 1533aa9e3350Smrg done 1534aa9e3350Smrg IFS=$oldIFS 1535aa9e3350Smrg fi 1536aa9e3350Smrg} 1537aa9e3350Smrg# end: func_convert_core_path_wine_to_w32 1538aa9e3350Smrg 1539aa9e3350Smrg 1540aa9e3350Smrg# func_cygpath ARGS... 1541aa9e3350Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 1542aa9e3350Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 1543aa9e3350Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 1544aa9e3350Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 1545aa9e3350Smrg# file name or path is assumed to be in w32 format, as previously converted 1546aa9e3350Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 1547aa9e3350Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 1548aa9e3350Smrg# Cygwin format). Returns an empty string on error. 1549aa9e3350Smrg# 1550aa9e3350Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 1551aa9e3350Smrg# be converted. 1552aa9e3350Smrg# 1553aa9e3350Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 1554aa9e3350Smrg# environment variable; do not put it in $PATH. 1555aa9e3350Smrgfunc_cygpath () 1556aa9e3350Smrg{ 1557aa9e3350Smrg $opt_debug 1558aa9e3350Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 1559aa9e3350Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 1560aa9e3350Smrg if test "$?" -ne 0; then 1561aa9e3350Smrg # on failure, ensure result is empty 1562aa9e3350Smrg func_cygpath_result= 1563aa9e3350Smrg fi 1564aa9e3350Smrg else 1565aa9e3350Smrg func_cygpath_result= 1566aa9e3350Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 1567aa9e3350Smrg fi 1568aa9e3350Smrg} 1569aa9e3350Smrg#end: func_cygpath 1570aa9e3350Smrg 1571aa9e3350Smrg 1572aa9e3350Smrg# func_convert_core_msys_to_w32 ARG 1573aa9e3350Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 1574aa9e3350Smrg# result in func_convert_core_msys_to_w32_result. 1575aa9e3350Smrgfunc_convert_core_msys_to_w32 () 1576aa9e3350Smrg{ 1577aa9e3350Smrg $opt_debug 1578aa9e3350Smrg # awkward: cmd appends spaces to result 1579aa9e3350Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 1580aa9e3350Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 1581aa9e3350Smrg} 1582aa9e3350Smrg#end: func_convert_core_msys_to_w32 1583aa9e3350Smrg 1584aa9e3350Smrg 1585aa9e3350Smrg# func_convert_file_check ARG1 ARG2 1586aa9e3350Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 1587aa9e3350Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 1588aa9e3350Smrg# func_to_host_file_result to ARG1). 1589aa9e3350Smrgfunc_convert_file_check () 1590aa9e3350Smrg{ 1591aa9e3350Smrg $opt_debug 1592aa9e3350Smrg if test -z "$2" && test -n "$1" ; then 1593aa9e3350Smrg func_error "Could not determine host file name corresponding to" 1594aa9e3350Smrg func_error " \`$1'" 1595aa9e3350Smrg func_error "Continuing, but uninstalled executables may not work." 1596aa9e3350Smrg # Fallback: 1597aa9e3350Smrg func_to_host_file_result="$1" 1598aa9e3350Smrg fi 1599aa9e3350Smrg} 1600aa9e3350Smrg# end func_convert_file_check 1601aa9e3350Smrg 1602aa9e3350Smrg 1603aa9e3350Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 1604aa9e3350Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 1605aa9e3350Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 1606aa9e3350Smrg# func_to_host_file_result to a simplistic fallback value (see below). 1607aa9e3350Smrgfunc_convert_path_check () 1608aa9e3350Smrg{ 1609aa9e3350Smrg $opt_debug 1610aa9e3350Smrg if test -z "$4" && test -n "$3"; then 1611aa9e3350Smrg func_error "Could not determine the host path corresponding to" 1612aa9e3350Smrg func_error " \`$3'" 1613aa9e3350Smrg func_error "Continuing, but uninstalled executables may not work." 1614aa9e3350Smrg # Fallback. This is a deliberately simplistic "conversion" and 1615aa9e3350Smrg # should not be "improved". See libtool.info. 1616aa9e3350Smrg if test "x$1" != "x$2"; then 1617aa9e3350Smrg lt_replace_pathsep_chars="s|$1|$2|g" 1618aa9e3350Smrg func_to_host_path_result=`echo "$3" | 1619aa9e3350Smrg $SED -e "$lt_replace_pathsep_chars"` 1620aa9e3350Smrg else 1621aa9e3350Smrg func_to_host_path_result="$3" 1622aa9e3350Smrg fi 1623aa9e3350Smrg fi 1624aa9e3350Smrg} 1625aa9e3350Smrg# end func_convert_path_check 1626aa9e3350Smrg 1627aa9e3350Smrg 1628aa9e3350Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 1629aa9e3350Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 1630aa9e3350Smrg# and appending REPL if ORIG matches BACKPAT. 1631aa9e3350Smrgfunc_convert_path_front_back_pathsep () 1632aa9e3350Smrg{ 1633aa9e3350Smrg $opt_debug 1634aa9e3350Smrg case $4 in 1635aa9e3350Smrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 1636aa9e3350Smrg ;; 1637aa9e3350Smrg esac 1638aa9e3350Smrg case $4 in 1639aa9e3350Smrg $2 ) func_append func_to_host_path_result "$3" 1640aa9e3350Smrg ;; 1641aa9e3350Smrg esac 1642aa9e3350Smrg} 1643aa9e3350Smrg# end func_convert_path_front_back_pathsep 1644aa9e3350Smrg 1645aa9e3350Smrg 1646aa9e3350Smrg################################################## 1647aa9e3350Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 1648aa9e3350Smrg################################################## 1649aa9e3350Smrg# invoked via `$to_host_file_cmd ARG' 1650aa9e3350Smrg# 1651aa9e3350Smrg# In each case, ARG is the path to be converted from $build to $host format. 1652aa9e3350Smrg# Result will be available in $func_to_host_file_result. 1653aa9e3350Smrg 1654aa9e3350Smrg 1655aa9e3350Smrg# func_to_host_file ARG 1656aa9e3350Smrg# Converts the file name ARG from $build format to $host format. Return result 1657aa9e3350Smrg# in func_to_host_file_result. 1658aa9e3350Smrgfunc_to_host_file () 1659aa9e3350Smrg{ 1660aa9e3350Smrg $opt_debug 1661aa9e3350Smrg $to_host_file_cmd "$1" 1662aa9e3350Smrg} 1663aa9e3350Smrg# end func_to_host_file 1664aa9e3350Smrg 1665aa9e3350Smrg 1666aa9e3350Smrg# func_to_tool_file ARG LAZY 1667aa9e3350Smrg# converts the file name ARG from $build format to toolchain format. Return 1668aa9e3350Smrg# result in func_to_tool_file_result. If the conversion in use is listed 1669aa9e3350Smrg# in (the comma separated) LAZY, no conversion takes place. 1670aa9e3350Smrgfunc_to_tool_file () 1671aa9e3350Smrg{ 1672aa9e3350Smrg $opt_debug 1673aa9e3350Smrg case ,$2, in 1674aa9e3350Smrg *,"$to_tool_file_cmd",*) 1675aa9e3350Smrg func_to_tool_file_result=$1 1676aa9e3350Smrg ;; 1677aa9e3350Smrg *) 1678aa9e3350Smrg $to_tool_file_cmd "$1" 1679aa9e3350Smrg func_to_tool_file_result=$func_to_host_file_result 1680aa9e3350Smrg ;; 1681aa9e3350Smrg esac 1682aa9e3350Smrg} 1683aa9e3350Smrg# end func_to_tool_file 1684aa9e3350Smrg 1685aa9e3350Smrg 1686aa9e3350Smrg# func_convert_file_noop ARG 1687aa9e3350Smrg# Copy ARG to func_to_host_file_result. 1688aa9e3350Smrgfunc_convert_file_noop () 1689aa9e3350Smrg{ 1690aa9e3350Smrg func_to_host_file_result="$1" 1691aa9e3350Smrg} 1692aa9e3350Smrg# end func_convert_file_noop 1693aa9e3350Smrg 1694aa9e3350Smrg 1695aa9e3350Smrg# func_convert_file_msys_to_w32 ARG 1696aa9e3350Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 1697aa9e3350Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 1698aa9e3350Smrg# func_to_host_file_result. 1699aa9e3350Smrgfunc_convert_file_msys_to_w32 () 1700aa9e3350Smrg{ 1701aa9e3350Smrg $opt_debug 1702aa9e3350Smrg func_to_host_file_result="$1" 1703aa9e3350Smrg if test -n "$1"; then 1704aa9e3350Smrg func_convert_core_msys_to_w32 "$1" 1705aa9e3350Smrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 1706aa9e3350Smrg fi 1707aa9e3350Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1708aa9e3350Smrg} 1709aa9e3350Smrg# end func_convert_file_msys_to_w32 1710aa9e3350Smrg 1711aa9e3350Smrg 1712aa9e3350Smrg# func_convert_file_cygwin_to_w32 ARG 1713aa9e3350Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 1714aa9e3350Smrg# func_to_host_file_result. 1715aa9e3350Smrgfunc_convert_file_cygwin_to_w32 () 1716aa9e3350Smrg{ 1717aa9e3350Smrg $opt_debug 1718aa9e3350Smrg func_to_host_file_result="$1" 1719aa9e3350Smrg if test -n "$1"; then 1720aa9e3350Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 1721aa9e3350Smrg # LT_CYGPATH in this case. 1722aa9e3350Smrg func_to_host_file_result=`cygpath -m "$1"` 1723aa9e3350Smrg fi 1724aa9e3350Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1725aa9e3350Smrg} 1726aa9e3350Smrg# end func_convert_file_cygwin_to_w32 1727aa9e3350Smrg 1728aa9e3350Smrg 1729aa9e3350Smrg# func_convert_file_nix_to_w32 ARG 1730aa9e3350Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 1731aa9e3350Smrg# and a working winepath. Returns result in func_to_host_file_result. 1732aa9e3350Smrgfunc_convert_file_nix_to_w32 () 1733aa9e3350Smrg{ 1734aa9e3350Smrg $opt_debug 1735aa9e3350Smrg func_to_host_file_result="$1" 1736aa9e3350Smrg if test -n "$1"; then 1737aa9e3350Smrg func_convert_core_file_wine_to_w32 "$1" 1738aa9e3350Smrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 1739aa9e3350Smrg fi 1740aa9e3350Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1741aa9e3350Smrg} 1742aa9e3350Smrg# end func_convert_file_nix_to_w32 1743aa9e3350Smrg 1744aa9e3350Smrg 1745aa9e3350Smrg# func_convert_file_msys_to_cygwin ARG 1746aa9e3350Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1747aa9e3350Smrg# Returns result in func_to_host_file_result. 1748aa9e3350Smrgfunc_convert_file_msys_to_cygwin () 1749aa9e3350Smrg{ 1750aa9e3350Smrg $opt_debug 1751aa9e3350Smrg func_to_host_file_result="$1" 1752aa9e3350Smrg if test -n "$1"; then 1753aa9e3350Smrg func_convert_core_msys_to_w32 "$1" 1754aa9e3350Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 1755aa9e3350Smrg func_to_host_file_result="$func_cygpath_result" 1756aa9e3350Smrg fi 1757aa9e3350Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1758aa9e3350Smrg} 1759aa9e3350Smrg# end func_convert_file_msys_to_cygwin 1760aa9e3350Smrg 1761aa9e3350Smrg 1762aa9e3350Smrg# func_convert_file_nix_to_cygwin ARG 1763aa9e3350Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 1764aa9e3350Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 1765aa9e3350Smrg# in func_to_host_file_result. 1766aa9e3350Smrgfunc_convert_file_nix_to_cygwin () 1767aa9e3350Smrg{ 1768aa9e3350Smrg $opt_debug 1769aa9e3350Smrg func_to_host_file_result="$1" 1770aa9e3350Smrg if test -n "$1"; then 1771aa9e3350Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 1772aa9e3350Smrg func_convert_core_file_wine_to_w32 "$1" 1773aa9e3350Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 1774aa9e3350Smrg func_to_host_file_result="$func_cygpath_result" 1775aa9e3350Smrg fi 1776aa9e3350Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1777aa9e3350Smrg} 1778aa9e3350Smrg# end func_convert_file_nix_to_cygwin 1779aa9e3350Smrg 1780aa9e3350Smrg 1781aa9e3350Smrg############################################# 1782aa9e3350Smrg# $build to $host PATH CONVERSION FUNCTIONS # 1783aa9e3350Smrg############################################# 1784aa9e3350Smrg# invoked via `$to_host_path_cmd ARG' 1785aa9e3350Smrg# 1786aa9e3350Smrg# In each case, ARG is the path to be converted from $build to $host format. 1787aa9e3350Smrg# The result will be available in $func_to_host_path_result. 1788aa9e3350Smrg# 1789aa9e3350Smrg# Path separators are also converted from $build format to $host format. If 1790aa9e3350Smrg# ARG begins or ends with a path separator character, it is preserved (but 1791aa9e3350Smrg# converted to $host format) on output. 1792aa9e3350Smrg# 1793aa9e3350Smrg# All path conversion functions are named using the following convention: 1794aa9e3350Smrg# file name conversion function : func_convert_file_X_to_Y () 1795aa9e3350Smrg# path conversion function : func_convert_path_X_to_Y () 1796aa9e3350Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 1797aa9e3350Smrg# same. If conversion functions are added for new $build/$host combinations, 1798aa9e3350Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 1799aa9e3350Smrg# will break. 1800aa9e3350Smrg 1801aa9e3350Smrg 1802aa9e3350Smrg# func_init_to_host_path_cmd 1803aa9e3350Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 1804aa9e3350Smrg# appropriate value, based on the value of $to_host_file_cmd. 1805aa9e3350Smrgto_host_path_cmd= 1806aa9e3350Smrgfunc_init_to_host_path_cmd () 1807aa9e3350Smrg{ 1808aa9e3350Smrg $opt_debug 1809aa9e3350Smrg if test -z "$to_host_path_cmd"; then 1810aa9e3350Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 1811aa9e3350Smrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 1812aa9e3350Smrg fi 1813aa9e3350Smrg} 1814aa9e3350Smrg 1815aa9e3350Smrg 1816aa9e3350Smrg# func_to_host_path ARG 1817aa9e3350Smrg# Converts the path ARG from $build format to $host format. Return result 1818aa9e3350Smrg# in func_to_host_path_result. 1819aa9e3350Smrgfunc_to_host_path () 1820aa9e3350Smrg{ 1821aa9e3350Smrg $opt_debug 1822aa9e3350Smrg func_init_to_host_path_cmd 1823aa9e3350Smrg $to_host_path_cmd "$1" 1824aa9e3350Smrg} 1825aa9e3350Smrg# end func_to_host_path 1826aa9e3350Smrg 1827aa9e3350Smrg 1828aa9e3350Smrg# func_convert_path_noop ARG 1829aa9e3350Smrg# Copy ARG to func_to_host_path_result. 1830aa9e3350Smrgfunc_convert_path_noop () 1831aa9e3350Smrg{ 1832aa9e3350Smrg func_to_host_path_result="$1" 1833aa9e3350Smrg} 1834aa9e3350Smrg# end func_convert_path_noop 1835aa9e3350Smrg 1836aa9e3350Smrg 1837aa9e3350Smrg# func_convert_path_msys_to_w32 ARG 1838aa9e3350Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 1839aa9e3350Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 1840aa9e3350Smrg# func_to_host_path_result. 1841aa9e3350Smrgfunc_convert_path_msys_to_w32 () 1842aa9e3350Smrg{ 1843aa9e3350Smrg $opt_debug 1844aa9e3350Smrg func_to_host_path_result="$1" 1845aa9e3350Smrg if test -n "$1"; then 1846aa9e3350Smrg # Remove leading and trailing path separator characters from ARG. MSYS 1847aa9e3350Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 1848aa9e3350Smrg # and winepath ignores them completely. 1849aa9e3350Smrg func_stripname : : "$1" 1850aa9e3350Smrg func_to_host_path_tmp1=$func_stripname_result 1851aa9e3350Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1852aa9e3350Smrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 1853aa9e3350Smrg func_convert_path_check : ";" \ 1854aa9e3350Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1855aa9e3350Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1856aa9e3350Smrg fi 1857aa9e3350Smrg} 1858aa9e3350Smrg# end func_convert_path_msys_to_w32 1859aa9e3350Smrg 1860aa9e3350Smrg 1861aa9e3350Smrg# func_convert_path_cygwin_to_w32 ARG 1862aa9e3350Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 1863aa9e3350Smrg# func_to_host_file_result. 1864aa9e3350Smrgfunc_convert_path_cygwin_to_w32 () 1865aa9e3350Smrg{ 1866aa9e3350Smrg $opt_debug 1867aa9e3350Smrg func_to_host_path_result="$1" 1868aa9e3350Smrg if test -n "$1"; then 1869aa9e3350Smrg # See func_convert_path_msys_to_w32: 1870aa9e3350Smrg func_stripname : : "$1" 1871aa9e3350Smrg func_to_host_path_tmp1=$func_stripname_result 1872aa9e3350Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 1873aa9e3350Smrg func_convert_path_check : ";" \ 1874aa9e3350Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1875aa9e3350Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1876aa9e3350Smrg fi 1877aa9e3350Smrg} 1878aa9e3350Smrg# end func_convert_path_cygwin_to_w32 1879aa9e3350Smrg 1880aa9e3350Smrg 1881aa9e3350Smrg# func_convert_path_nix_to_w32 ARG 1882aa9e3350Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 1883aa9e3350Smrg# a working winepath. Returns result in func_to_host_file_result. 1884aa9e3350Smrgfunc_convert_path_nix_to_w32 () 18856aec45a7Smrg{ 1886aa9e3350Smrg $opt_debug 1887aa9e3350Smrg func_to_host_path_result="$1" 1888aa9e3350Smrg if test -n "$1"; then 1889aa9e3350Smrg # See func_convert_path_msys_to_w32: 1890aa9e3350Smrg func_stripname : : "$1" 1891aa9e3350Smrg func_to_host_path_tmp1=$func_stripname_result 1892aa9e3350Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1893aa9e3350Smrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 1894aa9e3350Smrg func_convert_path_check : ";" \ 1895aa9e3350Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1896aa9e3350Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1897aa9e3350Smrg fi 1898aa9e3350Smrg} 1899aa9e3350Smrg# end func_convert_path_nix_to_w32 19006aec45a7Smrg 19016aec45a7Smrg 1902aa9e3350Smrg# func_convert_path_msys_to_cygwin ARG 1903aa9e3350Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1904aa9e3350Smrg# Returns result in func_to_host_file_result. 1905aa9e3350Smrgfunc_convert_path_msys_to_cygwin () 1906aa9e3350Smrg{ 1907aa9e3350Smrg $opt_debug 1908aa9e3350Smrg func_to_host_path_result="$1" 1909aa9e3350Smrg if test -n "$1"; then 1910aa9e3350Smrg # See func_convert_path_msys_to_w32: 1911aa9e3350Smrg func_stripname : : "$1" 1912aa9e3350Smrg func_to_host_path_tmp1=$func_stripname_result 1913aa9e3350Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1914aa9e3350Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 1915aa9e3350Smrg func_to_host_path_result="$func_cygpath_result" 1916aa9e3350Smrg func_convert_path_check : : \ 1917aa9e3350Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1918aa9e3350Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1919aa9e3350Smrg fi 1920aa9e3350Smrg} 1921aa9e3350Smrg# end func_convert_path_msys_to_cygwin 19226aec45a7Smrg 19236aec45a7Smrg 1924aa9e3350Smrg# func_convert_path_nix_to_cygwin ARG 1925aa9e3350Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 1926aa9e3350Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 1927aa9e3350Smrg# func_to_host_file_result. 1928aa9e3350Smrgfunc_convert_path_nix_to_cygwin () 1929aa9e3350Smrg{ 1930aa9e3350Smrg $opt_debug 1931aa9e3350Smrg func_to_host_path_result="$1" 1932aa9e3350Smrg if test -n "$1"; then 1933aa9e3350Smrg # Remove leading and trailing path separator characters from 1934aa9e3350Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 1935aa9e3350Smrg # into '.;' and ';.', and winepath ignores them completely. 1936aa9e3350Smrg func_stripname : : "$1" 1937aa9e3350Smrg func_to_host_path_tmp1=$func_stripname_result 1938aa9e3350Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1939aa9e3350Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 1940aa9e3350Smrg func_to_host_path_result="$func_cygpath_result" 1941aa9e3350Smrg func_convert_path_check : : \ 1942aa9e3350Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1943aa9e3350Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1944aa9e3350Smrg fi 19456aec45a7Smrg} 1946aa9e3350Smrg# end func_convert_path_nix_to_cygwin 1947aa9e3350Smrg 19486aec45a7Smrg 19496aec45a7Smrg# func_mode_compile arg... 19506aec45a7Smrgfunc_mode_compile () 19516aec45a7Smrg{ 19526aec45a7Smrg $opt_debug 19536aec45a7Smrg # Get the compilation command and the source file. 19546aec45a7Smrg base_compile= 19556aec45a7Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 19566aec45a7Smrg suppress_opt=yes 19576aec45a7Smrg suppress_output= 19586aec45a7Smrg arg_mode=normal 19596aec45a7Smrg libobj= 19606aec45a7Smrg later= 19616aec45a7Smrg pie_flag= 19626aec45a7Smrg 19636aec45a7Smrg for arg 19646aec45a7Smrg do 19656aec45a7Smrg case $arg_mode in 19666aec45a7Smrg arg ) 19676aec45a7Smrg # do not "continue". Instead, add this to base_compile 19686aec45a7Smrg lastarg="$arg" 19696aec45a7Smrg arg_mode=normal 19706aec45a7Smrg ;; 19716aec45a7Smrg 19726aec45a7Smrg target ) 19736aec45a7Smrg libobj="$arg" 19746aec45a7Smrg arg_mode=normal 19756aec45a7Smrg continue 19766aec45a7Smrg ;; 19776aec45a7Smrg 19786aec45a7Smrg normal ) 19796aec45a7Smrg # Accept any command-line options. 19806aec45a7Smrg case $arg in 19816aec45a7Smrg -o) 19826aec45a7Smrg test -n "$libobj" && \ 19836aec45a7Smrg func_fatal_error "you cannot specify \`-o' more than once" 19846aec45a7Smrg arg_mode=target 19856aec45a7Smrg continue 19866aec45a7Smrg ;; 19876aec45a7Smrg 19886aec45a7Smrg -pie | -fpie | -fPIE) 1989aa9e3350Smrg func_append pie_flag " $arg" 19906aec45a7Smrg continue 19916aec45a7Smrg ;; 19926aec45a7Smrg 19936aec45a7Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 1994aa9e3350Smrg func_append later " $arg" 19956aec45a7Smrg continue 19966aec45a7Smrg ;; 19971473d951Smrg 19981473d951Smrg -no-suppress) 1999ab47cfaaSmrg suppress_opt=no 2000ab47cfaaSmrg continue 2001ab47cfaaSmrg ;; 2002ab47cfaaSmrg 2003ab47cfaaSmrg -Xcompiler) 2004ab47cfaaSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 2005ab47cfaaSmrg continue # The current "srcfile" will either be retained or 2006ab47cfaaSmrg ;; # replaced later. I would guess that would be a bug. 2007ab47cfaaSmrg 2008ab47cfaaSmrg -Wc,*) 20096aec45a7Smrg func_stripname '-Wc,' '' "$arg" 20106aec45a7Smrg args=$func_stripname_result 2011ab47cfaaSmrg lastarg= 2012ab47cfaaSmrg save_ifs="$IFS"; IFS=',' 20136aec45a7Smrg for arg in $args; do 2014ab47cfaaSmrg IFS="$save_ifs" 2015aa9e3350Smrg func_append_quoted lastarg "$arg" 2016ab47cfaaSmrg done 2017ab47cfaaSmrg IFS="$save_ifs" 20186aec45a7Smrg func_stripname ' ' '' "$lastarg" 20196aec45a7Smrg lastarg=$func_stripname_result 2020ab47cfaaSmrg 2021ab47cfaaSmrg # Add the arguments to base_compile. 2022aa9e3350Smrg func_append base_compile " $lastarg" 2023ab47cfaaSmrg continue 2024ab47cfaaSmrg ;; 2025ab47cfaaSmrg 20266aec45a7Smrg *) 2027ab47cfaaSmrg # Accept the current argument as the source file. 2028ab47cfaaSmrg # The previous "srcfile" becomes the current argument. 2029ab47cfaaSmrg # 2030ab47cfaaSmrg lastarg="$srcfile" 2031ab47cfaaSmrg srcfile="$arg" 2032ab47cfaaSmrg ;; 2033ab47cfaaSmrg esac # case $arg 2034ab47cfaaSmrg ;; 2035ab47cfaaSmrg esac # case $arg_mode 2036ab47cfaaSmrg 2037ab47cfaaSmrg # Aesthetically quote the previous argument. 2038aa9e3350Smrg func_append_quoted base_compile "$lastarg" 2039ab47cfaaSmrg done # for arg 2040ab47cfaaSmrg 2041ab47cfaaSmrg case $arg_mode in 2042ab47cfaaSmrg arg) 20436aec45a7Smrg func_fatal_error "you must specify an argument for -Xcompile" 2044ab47cfaaSmrg ;; 2045ab47cfaaSmrg target) 20466aec45a7Smrg func_fatal_error "you must specify a target with \`-o'" 2047ab47cfaaSmrg ;; 2048ab47cfaaSmrg *) 2049ab47cfaaSmrg # Get the name of the library object. 20506aec45a7Smrg test -z "$libobj" && { 20516aec45a7Smrg func_basename "$srcfile" 20526aec45a7Smrg libobj="$func_basename_result" 20536aec45a7Smrg } 2054ab47cfaaSmrg ;; 2055ab47cfaaSmrg esac 2056ab47cfaaSmrg 2057ab47cfaaSmrg # Recognize several different file suffixes. 2058ab47cfaaSmrg # If the user specifies -o file.o, it is replaced with file.lo 2059ab47cfaaSmrg case $libobj in 20606aec45a7Smrg *.[cCFSifmso] | \ 20616aec45a7Smrg *.ada | *.adb | *.ads | *.asm | \ 20626aec45a7Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 2063aa9e3350Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 20646aec45a7Smrg func_xform "$libobj" 20656aec45a7Smrg libobj=$func_xform_result 20666aec45a7Smrg ;; 2067ab47cfaaSmrg esac 2068ab47cfaaSmrg 2069ab47cfaaSmrg case $libobj in 20706aec45a7Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2071ab47cfaaSmrg *) 20726aec45a7Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 2073ab47cfaaSmrg ;; 2074ab47cfaaSmrg esac 2075ab47cfaaSmrg 2076ab47cfaaSmrg func_infer_tag $base_compile 2077ab47cfaaSmrg 2078ab47cfaaSmrg for arg in $later; do 2079ab47cfaaSmrg case $arg in 20806aec45a7Smrg -shared) 20816aec45a7Smrg test "$build_libtool_libs" != yes && \ 20826aec45a7Smrg func_fatal_configuration "can not build a shared library" 20836aec45a7Smrg build_old_libs=no 20846aec45a7Smrg continue 20856aec45a7Smrg ;; 20866aec45a7Smrg 2087ab47cfaaSmrg -static) 20886aec45a7Smrg build_libtool_libs=no 2089ab47cfaaSmrg build_old_libs=yes 2090ab47cfaaSmrg continue 2091ab47cfaaSmrg ;; 2092ab47cfaaSmrg 2093ab47cfaaSmrg -prefer-pic) 2094ab47cfaaSmrg pic_mode=yes 2095ab47cfaaSmrg continue 2096ab47cfaaSmrg ;; 2097ab47cfaaSmrg 2098ab47cfaaSmrg -prefer-non-pic) 2099ab47cfaaSmrg pic_mode=no 2100ab47cfaaSmrg continue 2101ab47cfaaSmrg ;; 2102ab47cfaaSmrg esac 2103ab47cfaaSmrg done 2104ab47cfaaSmrg 21056aec45a7Smrg func_quote_for_eval "$libobj" 21066aec45a7Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 21076aec45a7Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 21086aec45a7Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 21096aec45a7Smrg func_dirname_and_basename "$obj" "/" "" 21106aec45a7Smrg objname="$func_basename_result" 21116aec45a7Smrg xdir="$func_dirname_result" 2112ab47cfaaSmrg lobj=${xdir}$objdir/$objname 2113ab47cfaaSmrg 21146aec45a7Smrg test -z "$base_compile" && \ 21156aec45a7Smrg func_fatal_help "you must specify a compilation command" 2116ab47cfaaSmrg 2117ab47cfaaSmrg # Delete any leftover library objects. 2118ab47cfaaSmrg if test "$build_old_libs" = yes; then 2119ab47cfaaSmrg removelist="$obj $lobj $libobj ${libobj}T" 2120ab47cfaaSmrg else 2121ab47cfaaSmrg removelist="$lobj $libobj ${libobj}T" 2122ab47cfaaSmrg fi 2123ab47cfaaSmrg 2124ab47cfaaSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 2125ab47cfaaSmrg case $host_os in 21266aec45a7Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 2127ab47cfaaSmrg pic_mode=default 2128ab47cfaaSmrg ;; 2129ab47cfaaSmrg esac 2130ab47cfaaSmrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2131ab47cfaaSmrg # non-PIC code in shared libraries is not supported 2132ab47cfaaSmrg pic_mode=default 2133ab47cfaaSmrg fi 2134ab47cfaaSmrg 2135ab47cfaaSmrg # Calculate the filename of the output object if compiler does 2136ab47cfaaSmrg # not support -o with -c 2137ab47cfaaSmrg if test "$compiler_c_o" = no; then 21386aec45a7Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2139ab47cfaaSmrg lockfile="$output_obj.lock" 2140ab47cfaaSmrg else 2141ab47cfaaSmrg output_obj= 2142ab47cfaaSmrg need_locks=no 2143ab47cfaaSmrg lockfile= 2144ab47cfaaSmrg fi 2145ab47cfaaSmrg 2146ab47cfaaSmrg # Lock this critical section if it is needed 2147ab47cfaaSmrg # We use this script file to make the link, it avoids creating a new file 2148ab47cfaaSmrg if test "$need_locks" = yes; then 21496aec45a7Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 21506aec45a7Smrg func_echo "Waiting for $lockfile to be removed" 2151ab47cfaaSmrg sleep 2 2152ab47cfaaSmrg done 2153ab47cfaaSmrg elif test "$need_locks" = warn; then 2154ab47cfaaSmrg if test -f "$lockfile"; then 21556aec45a7Smrg $ECHO "\ 2156ab47cfaaSmrg*** ERROR, $lockfile exists and contains: 2157ab47cfaaSmrg`cat $lockfile 2>/dev/null` 2158ab47cfaaSmrg 2159ab47cfaaSmrgThis indicates that another process is trying to use the same 2160ab47cfaaSmrgtemporary object file, and libtool could not work around it because 2161ab47cfaaSmrgyour compiler does not support \`-c' and \`-o' together. If you 2162ab47cfaaSmrgrepeat this compilation, it may succeed, by chance, but you had better 2163ab47cfaaSmrgavoid parallel builds (make -j) in this platform, or get a better 2164ab47cfaaSmrgcompiler." 2165ab47cfaaSmrg 21666aec45a7Smrg $opt_dry_run || $RM $removelist 2167ab47cfaaSmrg exit $EXIT_FAILURE 2168ab47cfaaSmrg fi 2169aa9e3350Smrg func_append removelist " $output_obj" 21706aec45a7Smrg $ECHO "$srcfile" > "$lockfile" 2171ab47cfaaSmrg fi 2172ab47cfaaSmrg 21736aec45a7Smrg $opt_dry_run || $RM $removelist 2174aa9e3350Smrg func_append removelist " $lockfile" 21756aec45a7Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 21766aec45a7Smrg 2177aa9e3350Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 2178aa9e3350Smrg srcfile=$func_to_tool_file_result 21796aec45a7Smrg func_quote_for_eval "$srcfile" 21806aec45a7Smrg qsrcfile=$func_quote_for_eval_result 2181ab47cfaaSmrg 2182ab47cfaaSmrg # Only build a PIC object if we are building libtool libraries. 2183ab47cfaaSmrg if test "$build_libtool_libs" = yes; then 2184ab47cfaaSmrg # Without this assignment, base_compile gets emptied. 2185ab47cfaaSmrg fbsd_hideous_sh_bug=$base_compile 2186ab47cfaaSmrg 2187ab47cfaaSmrg if test "$pic_mode" != no; then 2188ab47cfaaSmrg command="$base_compile $qsrcfile $pic_flag" 2189ab47cfaaSmrg else 2190ab47cfaaSmrg # Don't build PIC code 2191ab47cfaaSmrg command="$base_compile $qsrcfile" 2192ab47cfaaSmrg fi 2193ab47cfaaSmrg 21946aec45a7Smrg func_mkdir_p "$xdir$objdir" 2195ab47cfaaSmrg 2196ab47cfaaSmrg if test -z "$output_obj"; then 2197ab47cfaaSmrg # Place PIC objects in $objdir 2198aa9e3350Smrg func_append command " -o $lobj" 2199ab47cfaaSmrg fi 2200ab47cfaaSmrg 22016aec45a7Smrg func_show_eval_locale "$command" \ 22026aec45a7Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2203ab47cfaaSmrg 2204ab47cfaaSmrg if test "$need_locks" = warn && 2205ab47cfaaSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 22066aec45a7Smrg $ECHO "\ 2207ab47cfaaSmrg*** ERROR, $lockfile contains: 2208ab47cfaaSmrg`cat $lockfile 2>/dev/null` 2209ab47cfaaSmrg 2210ab47cfaaSmrgbut it should contain: 2211ab47cfaaSmrg$srcfile 2212ab47cfaaSmrg 2213ab47cfaaSmrgThis indicates that another process is trying to use the same 2214ab47cfaaSmrgtemporary object file, and libtool could not work around it because 2215ab47cfaaSmrgyour compiler does not support \`-c' and \`-o' together. If you 2216ab47cfaaSmrgrepeat this compilation, it may succeed, by chance, but you had better 2217ab47cfaaSmrgavoid parallel builds (make -j) in this platform, or get a better 2218ab47cfaaSmrgcompiler." 2219ab47cfaaSmrg 22206aec45a7Smrg $opt_dry_run || $RM $removelist 2221ab47cfaaSmrg exit $EXIT_FAILURE 2222ab47cfaaSmrg fi 2223ab47cfaaSmrg 2224ab47cfaaSmrg # Just move the object if needed, then go on to compile the next one 2225ab47cfaaSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 22266aec45a7Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 22276aec45a7Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2228ab47cfaaSmrg fi 2229ab47cfaaSmrg 2230ab47cfaaSmrg # Allow error messages only from the first compilation. 2231ab47cfaaSmrg if test "$suppress_opt" = yes; then 22326aec45a7Smrg suppress_output=' >/dev/null 2>&1' 2233ab47cfaaSmrg fi 2234ab47cfaaSmrg fi 2235ab47cfaaSmrg 2236ab47cfaaSmrg # Only build a position-dependent object if we build old libraries. 2237ab47cfaaSmrg if test "$build_old_libs" = yes; then 2238ab47cfaaSmrg if test "$pic_mode" != yes; then 2239ab47cfaaSmrg # Don't build PIC code 22406aec45a7Smrg command="$base_compile $qsrcfile$pie_flag" 2241ab47cfaaSmrg else 2242ab47cfaaSmrg command="$base_compile $qsrcfile $pic_flag" 2243ab47cfaaSmrg fi 2244ab47cfaaSmrg if test "$compiler_c_o" = yes; then 2245aa9e3350Smrg func_append command " -o $obj" 2246ab47cfaaSmrg fi 2247ab47cfaaSmrg 2248ab47cfaaSmrg # Suppress compiler output if we already did a PIC compilation. 2249aa9e3350Smrg func_append command "$suppress_output" 22506aec45a7Smrg func_show_eval_locale "$command" \ 22516aec45a7Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2252ab47cfaaSmrg 2253ab47cfaaSmrg if test "$need_locks" = warn && 2254ab47cfaaSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 22556aec45a7Smrg $ECHO "\ 2256ab47cfaaSmrg*** ERROR, $lockfile contains: 2257ab47cfaaSmrg`cat $lockfile 2>/dev/null` 2258ab47cfaaSmrg 2259ab47cfaaSmrgbut it should contain: 2260ab47cfaaSmrg$srcfile 2261ab47cfaaSmrg 2262ab47cfaaSmrgThis indicates that another process is trying to use the same 2263ab47cfaaSmrgtemporary object file, and libtool could not work around it because 2264ab47cfaaSmrgyour compiler does not support \`-c' and \`-o' together. If you 2265ab47cfaaSmrgrepeat this compilation, it may succeed, by chance, but you had better 2266ab47cfaaSmrgavoid parallel builds (make -j) in this platform, or get a better 2267ab47cfaaSmrgcompiler." 2268ab47cfaaSmrg 22696aec45a7Smrg $opt_dry_run || $RM $removelist 2270ab47cfaaSmrg exit $EXIT_FAILURE 2271ab47cfaaSmrg fi 2272ab47cfaaSmrg 2273ab47cfaaSmrg # Just move the object if needed 2274ab47cfaaSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 22756aec45a7Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 22766aec45a7Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2277ab47cfaaSmrg fi 2278ab47cfaaSmrg fi 2279ab47cfaaSmrg 22806aec45a7Smrg $opt_dry_run || { 22816aec45a7Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2282ab47cfaaSmrg 22836aec45a7Smrg # Unlock the critical section if it was locked 22846aec45a7Smrg if test "$need_locks" != no; then 22856aec45a7Smrg removelist=$lockfile 22866aec45a7Smrg $RM "$lockfile" 22876aec45a7Smrg fi 22886aec45a7Smrg } 2289ab47cfaaSmrg 2290ab47cfaaSmrg exit $EXIT_SUCCESS 22916aec45a7Smrg} 2292ab47cfaaSmrg 22936aec45a7Smrg$opt_help || { 2294aa9e3350Smrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 22956aec45a7Smrg} 2296ab47cfaaSmrg 22976aec45a7Smrgfunc_mode_help () 22986aec45a7Smrg{ 22996aec45a7Smrg # We need to display help for each of the modes. 2300aa9e3350Smrg case $opt_mode in 23016aec45a7Smrg "") 23026aec45a7Smrg # Generic help is extracted from the usage comments 23036aec45a7Smrg # at the start of this file. 23046aec45a7Smrg func_help 23056aec45a7Smrg ;; 2306ab47cfaaSmrg 23076aec45a7Smrg clean) 23086aec45a7Smrg $ECHO \ 23096aec45a7Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2310ab47cfaaSmrg 23116aec45a7SmrgRemove files from the build directory. 2312ab47cfaaSmrg 23136aec45a7SmrgRM is the name of the program to use to delete files associated with each FILE 23146aec45a7Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 23156aec45a7Smrgto RM. 2316ab47cfaaSmrg 23176aec45a7SmrgIf FILE is a libtool library, object or program, all the files associated 23186aec45a7Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 23196aec45a7Smrg ;; 2320ab47cfaaSmrg 23216aec45a7Smrg compile) 23226aec45a7Smrg $ECHO \ 23236aec45a7Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2324ab47cfaaSmrg 23256aec45a7SmrgCompile a source file into a libtool library object. 2326ab47cfaaSmrg 23276aec45a7SmrgThis mode accepts the following additional options: 2328ab47cfaaSmrg 23296aec45a7Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 23306aec45a7Smrg -no-suppress do not suppress compiler output for multiple passes 23316aec45a7Smrg -prefer-pic try to build PIC objects only 23326aec45a7Smrg -prefer-non-pic try to build non-PIC objects only 23336aec45a7Smrg -shared do not build a \`.o' file suitable for static linking 23346aec45a7Smrg -static only build a \`.o' file suitable for static linking 23356aec45a7Smrg -Wc,FLAG pass FLAG directly to the compiler 2336ab47cfaaSmrg 23376aec45a7SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 23386aec45a7Smrgfrom the given SOURCEFILE. 2339ab47cfaaSmrg 23406aec45a7SmrgThe output file name is determined by removing the directory component from 23416aec45a7SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 23426aec45a7Smrglibrary object suffix, \`.lo'." 23436aec45a7Smrg ;; 2344ab47cfaaSmrg 23456aec45a7Smrg execute) 23466aec45a7Smrg $ECHO \ 23476aec45a7Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2348ab47cfaaSmrg 23496aec45a7SmrgAutomatically set library path, then run a program. 2350ab47cfaaSmrg 23516aec45a7SmrgThis mode accepts the following additional options: 2352ab47cfaaSmrg 23536aec45a7Smrg -dlopen FILE add the directory containing FILE to the library path 2354ab47cfaaSmrg 23556aec45a7SmrgThis mode sets the library path environment variable according to \`-dlopen' 23566aec45a7Smrgflags. 2357ab47cfaaSmrg 23586aec45a7SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 23596aec45a7Smrginto their corresponding uninstalled binary, and any of their required library 23606aec45a7Smrgdirectories are added to the library path. 2361ab47cfaaSmrg 23626aec45a7SmrgThen, COMMAND is executed, with ARGS as arguments." 23636aec45a7Smrg ;; 2364ab47cfaaSmrg 23656aec45a7Smrg finish) 23666aec45a7Smrg $ECHO \ 23676aec45a7Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2368ab47cfaaSmrg 23696aec45a7SmrgComplete the installation of libtool libraries. 2370ab47cfaaSmrg 23716aec45a7SmrgEach LIBDIR is a directory that contains libtool libraries. 2372ab47cfaaSmrg 23736aec45a7SmrgThe commands that this mode executes may require superuser privileges. Use 23746aec45a7Smrgthe \`--dry-run' option if you just want to see what would be executed." 23756aec45a7Smrg ;; 2376ab47cfaaSmrg 23776aec45a7Smrg install) 23786aec45a7Smrg $ECHO \ 23796aec45a7Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2380ab47cfaaSmrg 23816aec45a7SmrgInstall executables or libraries. 2382ab47cfaaSmrg 23836aec45a7SmrgINSTALL-COMMAND is the installation command. The first component should be 23846aec45a7Smrgeither the \`install' or \`cp' program. 2385ab47cfaaSmrg 23866aec45a7SmrgThe following components of INSTALL-COMMAND are treated specially: 2387ab47cfaaSmrg 23886aec45a7Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2389ab47cfaaSmrg 23906aec45a7SmrgThe rest of the components are interpreted as arguments to that command (only 23916aec45a7SmrgBSD-compatible install options are recognized)." 23926aec45a7Smrg ;; 2393ab47cfaaSmrg 23946aec45a7Smrg link) 23956aec45a7Smrg $ECHO \ 23966aec45a7Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2397ab47cfaaSmrg 23986aec45a7SmrgLink object files or libraries together to form another library, or to 23996aec45a7Smrgcreate an executable program. 2400ab47cfaaSmrg 24016aec45a7SmrgLINK-COMMAND is a command using the C compiler that you would use to create 24026aec45a7Smrga program from several object files. 2403ab47cfaaSmrg 24046aec45a7SmrgThe following components of LINK-COMMAND are treated specially: 2405ab47cfaaSmrg 24066aec45a7Smrg -all-static do not do any dynamic linking at all 24076aec45a7Smrg -avoid-version do not add a version suffix if possible 24086aec45a7Smrg -bindir BINDIR specify path to binaries directory (for systems where 24096aec45a7Smrg libraries must be found in the PATH setting at runtime) 24106aec45a7Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 24116aec45a7Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 24126aec45a7Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 24136aec45a7Smrg -export-symbols SYMFILE 24146aec45a7Smrg try to export only the symbols listed in SYMFILE 24156aec45a7Smrg -export-symbols-regex REGEX 24166aec45a7Smrg try to export only the symbols matching REGEX 24176aec45a7Smrg -LLIBDIR search LIBDIR for required installed libraries 24186aec45a7Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 24196aec45a7Smrg -module build a library that can dlopened 24206aec45a7Smrg -no-fast-install disable the fast-install mode 24216aec45a7Smrg -no-install link a not-installable executable 24226aec45a7Smrg -no-undefined declare that a library does not refer to external symbols 24236aec45a7Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 24246aec45a7Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 24256aec45a7Smrg -precious-files-regex REGEX 24266aec45a7Smrg don't remove output files matching REGEX 24276aec45a7Smrg -release RELEASE specify package release information 24286aec45a7Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 24296aec45a7Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 24306aec45a7Smrg -shared only do dynamic linking of libtool libraries 24316aec45a7Smrg -shrext SUFFIX override the standard shared library file extension 24326aec45a7Smrg -static do not do any dynamic linking of uninstalled libtool libraries 24336aec45a7Smrg -static-libtool-libs 24346aec45a7Smrg do not do any dynamic linking of libtool libraries 24356aec45a7Smrg -version-info CURRENT[:REVISION[:AGE]] 24366aec45a7Smrg specify library version info [each variable defaults to 0] 24376aec45a7Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 24386aec45a7Smrg -Wc,FLAG 24396aec45a7Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 24406aec45a7Smrg -Wl,FLAG 24416aec45a7Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 24426aec45a7Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2443ab47cfaaSmrg 24446aec45a7SmrgAll other options (arguments beginning with \`-') are ignored. 2445ab47cfaaSmrg 24466aec45a7SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 24476aec45a7Smrgtreated as uninstalled libtool libraries, other files are standard or library 24486aec45a7Smrgobject files. 2449ab47cfaaSmrg 24506aec45a7SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 24516aec45a7Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 24526aec45a7Smrgrequired, except when creating a convenience library. 2453ab47cfaaSmrg 24546aec45a7SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 24556aec45a7Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 2456ab47cfaaSmrg 24576aec45a7SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 24586aec45a7Smrgis created, otherwise an executable program is created." 24596aec45a7Smrg ;; 2460ab47cfaaSmrg 24616aec45a7Smrg uninstall) 24626aec45a7Smrg $ECHO \ 24636aec45a7Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2464ab47cfaaSmrg 24656aec45a7SmrgRemove libraries from an installation directory. 2466ab47cfaaSmrg 24676aec45a7SmrgRM is the name of the program to use to delete files associated with each FILE 24686aec45a7Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 24696aec45a7Smrgto RM. 2470ab47cfaaSmrg 24716aec45a7SmrgIf FILE is a libtool library, all the files associated with it are deleted. 24726aec45a7SmrgOtherwise, only FILE itself is deleted using RM." 24736aec45a7Smrg ;; 2474ab47cfaaSmrg 24756aec45a7Smrg *) 2476aa9e3350Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 24776aec45a7Smrg ;; 24786aec45a7Smrg esac 2479ab47cfaaSmrg 24806aec45a7Smrg echo 24816aec45a7Smrg $ECHO "Try \`$progname --help' for more information about other modes." 24826aec45a7Smrg} 24831473d951Smrg 24846aec45a7Smrg# Now that we've collected a possible --mode arg, show help if necessary 24856aec45a7Smrgif $opt_help; then 24866aec45a7Smrg if test "$opt_help" = :; then 24876aec45a7Smrg func_mode_help 24886aec45a7Smrg else 24896aec45a7Smrg { 24906aec45a7Smrg func_help noexit 2491aa9e3350Smrg for opt_mode in compile link execute install finish uninstall clean; do 24926aec45a7Smrg func_mode_help 24936aec45a7Smrg done 24946aec45a7Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 24956aec45a7Smrg { 24966aec45a7Smrg func_help noexit 2497aa9e3350Smrg for opt_mode in compile link execute install finish uninstall clean; do 24986aec45a7Smrg echo 24996aec45a7Smrg func_mode_help 25006aec45a7Smrg done 25016aec45a7Smrg } | 25026aec45a7Smrg sed '1d 25036aec45a7Smrg /^When reporting/,/^Report/{ 25046aec45a7Smrg H 25056aec45a7Smrg d 25066aec45a7Smrg } 25076aec45a7Smrg $x 25086aec45a7Smrg /information about other modes/d 25096aec45a7Smrg /more detailed .*MODE/d 25106aec45a7Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 25116aec45a7Smrg fi 25126aec45a7Smrg exit $? 25136aec45a7Smrgfi 25141473d951Smrg 25151473d951Smrg 25166aec45a7Smrg# func_mode_execute arg... 25176aec45a7Smrgfunc_mode_execute () 25186aec45a7Smrg{ 25196aec45a7Smrg $opt_debug 25206aec45a7Smrg # The first argument is the command name. 25216aec45a7Smrg cmd="$nonopt" 25226aec45a7Smrg test -z "$cmd" && \ 25236aec45a7Smrg func_fatal_help "you must specify a COMMAND" 25241473d951Smrg 25256aec45a7Smrg # Handle -dlopen flags immediately. 2526aa9e3350Smrg for file in $opt_dlopen; do 25276aec45a7Smrg test -f "$file" \ 25286aec45a7Smrg || func_fatal_help "\`$file' is not a file" 25291473d951Smrg 25306aec45a7Smrg dir= 25316aec45a7Smrg case $file in 25326aec45a7Smrg *.la) 2533aa9e3350Smrg func_resolve_sysroot "$file" 2534aa9e3350Smrg file=$func_resolve_sysroot_result 2535aa9e3350Smrg 25366aec45a7Smrg # Check to see that this really is a libtool archive. 25376aec45a7Smrg func_lalib_unsafe_p "$file" \ 25386aec45a7Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 25391473d951Smrg 25406aec45a7Smrg # Read the libtool library. 25416aec45a7Smrg dlname= 25426aec45a7Smrg library_names= 25436aec45a7Smrg func_source "$file" 25441473d951Smrg 25456aec45a7Smrg # Skip this library if it cannot be dlopened. 25466aec45a7Smrg if test -z "$dlname"; then 25476aec45a7Smrg # Warn if it was a shared library. 25486aec45a7Smrg test -n "$library_names" && \ 25496aec45a7Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 25506aec45a7Smrg continue 25516aec45a7Smrg fi 25525c42550eSmrg 25536aec45a7Smrg func_dirname "$file" "" "." 25546aec45a7Smrg dir="$func_dirname_result" 25555c42550eSmrg 25566aec45a7Smrg if test -f "$dir/$objdir/$dlname"; then 2557aa9e3350Smrg func_append dir "/$objdir" 25586aec45a7Smrg else 25596aec45a7Smrg if test ! -f "$dir/$dlname"; then 25606aec45a7Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 25616aec45a7Smrg fi 25626aec45a7Smrg fi 25631473d951Smrg ;; 25645c42550eSmrg 25656aec45a7Smrg *.lo) 25666aec45a7Smrg # Just add the directory containing the .lo file. 25676aec45a7Smrg func_dirname "$file" "" "." 25686aec45a7Smrg dir="$func_dirname_result" 25691473d951Smrg ;; 25706aec45a7Smrg 25716aec45a7Smrg *) 25726aec45a7Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 25735c42550eSmrg continue 2574ab47cfaaSmrg ;; 25756aec45a7Smrg esac 2576ab47cfaaSmrg 25776aec45a7Smrg # Get the absolute pathname. 25786aec45a7Smrg absdir=`cd "$dir" && pwd` 25796aec45a7Smrg test -n "$absdir" && dir="$absdir" 2580ab47cfaaSmrg 25816aec45a7Smrg # Now add the directory to shlibpath_var. 25826aec45a7Smrg if eval "test -z \"\$$shlibpath_var\""; then 25836aec45a7Smrg eval "$shlibpath_var=\"\$dir\"" 25846aec45a7Smrg else 25856aec45a7Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 25866aec45a7Smrg fi 25876aec45a7Smrg done 2588ab47cfaaSmrg 25896aec45a7Smrg # This variable tells wrapper scripts just to set shlibpath_var 25906aec45a7Smrg # rather than running their programs. 25916aec45a7Smrg libtool_execute_magic="$magic" 2592ab47cfaaSmrg 25936aec45a7Smrg # Check if any of the arguments is a wrapper script. 25946aec45a7Smrg args= 25956aec45a7Smrg for file 25966aec45a7Smrg do 25976aec45a7Smrg case $file in 25986aec45a7Smrg -* | *.la | *.lo ) ;; 25996aec45a7Smrg *) 26006aec45a7Smrg # Do a test to see if this is really a libtool program. 26016aec45a7Smrg if func_ltwrapper_script_p "$file"; then 26026aec45a7Smrg func_source "$file" 26036aec45a7Smrg # Transform arg to wrapped name. 26046aec45a7Smrg file="$progdir/$program" 26056aec45a7Smrg elif func_ltwrapper_executable_p "$file"; then 26066aec45a7Smrg func_ltwrapper_scriptname "$file" 26076aec45a7Smrg func_source "$func_ltwrapper_scriptname_result" 26086aec45a7Smrg # Transform arg to wrapped name. 26096aec45a7Smrg file="$progdir/$program" 26106aec45a7Smrg fi 26115c42550eSmrg ;; 26126aec45a7Smrg esac 26136aec45a7Smrg # Quote arguments (to preserve shell metacharacters). 2614aa9e3350Smrg func_append_quoted args "$file" 26156aec45a7Smrg done 2616ab47cfaaSmrg 26176aec45a7Smrg if test "X$opt_dry_run" = Xfalse; then 26186aec45a7Smrg if test -n "$shlibpath_var"; then 26196aec45a7Smrg # Export the shlibpath_var. 26206aec45a7Smrg eval "export $shlibpath_var" 26216aec45a7Smrg fi 2622ab47cfaaSmrg 26236aec45a7Smrg # Restore saved environment variables 26246aec45a7Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 26256aec45a7Smrg do 26266aec45a7Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 26276aec45a7Smrg $lt_var=\$save_$lt_var; export $lt_var 26286aec45a7Smrg else 26296aec45a7Smrg $lt_unset $lt_var 26306aec45a7Smrg fi" 26316aec45a7Smrg done 2632ab47cfaaSmrg 26336aec45a7Smrg # Now prepare to actually exec the command. 26346aec45a7Smrg exec_cmd="\$cmd$args" 26356aec45a7Smrg else 26366aec45a7Smrg # Display what would be done. 26376aec45a7Smrg if test -n "$shlibpath_var"; then 26386aec45a7Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 26396aec45a7Smrg echo "export $shlibpath_var" 26406aec45a7Smrg fi 26416aec45a7Smrg $ECHO "$cmd$args" 26426aec45a7Smrg exit $EXIT_SUCCESS 26436aec45a7Smrg fi 26446aec45a7Smrg} 26451473d951Smrg 2646aa9e3350Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 26471473d951Smrg 26481473d951Smrg 26496aec45a7Smrg# func_mode_finish arg... 26506aec45a7Smrgfunc_mode_finish () 26516aec45a7Smrg{ 26526aec45a7Smrg $opt_debug 2653aa9e3350Smrg libs= 2654aa9e3350Smrg libdirs= 26556aec45a7Smrg admincmds= 26561473d951Smrg 2657aa9e3350Smrg for opt in "$nonopt" ${1+"$@"} 2658aa9e3350Smrg do 2659aa9e3350Smrg if test -d "$opt"; then 2660aa9e3350Smrg func_append libdirs " $opt" 2661aa9e3350Smrg 2662aa9e3350Smrg elif test -f "$opt"; then 2663aa9e3350Smrg if func_lalib_unsafe_p "$opt"; then 2664aa9e3350Smrg func_append libs " $opt" 2665aa9e3350Smrg else 2666aa9e3350Smrg func_warning "\`$opt' is not a valid libtool archive" 2667aa9e3350Smrg fi 2668aa9e3350Smrg 2669aa9e3350Smrg else 2670aa9e3350Smrg func_fatal_error "invalid argument \`$opt'" 2671aa9e3350Smrg fi 2672aa9e3350Smrg done 2673aa9e3350Smrg 2674aa9e3350Smrg if test -n "$libs"; then 2675aa9e3350Smrg if test -n "$lt_sysroot"; then 2676aa9e3350Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 2677aa9e3350Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 2678aa9e3350Smrg else 2679aa9e3350Smrg sysroot_cmd= 2680aa9e3350Smrg fi 2681aa9e3350Smrg 2682aa9e3350Smrg # Remove sysroot references 2683aa9e3350Smrg if $opt_dry_run; then 2684aa9e3350Smrg for lib in $libs; do 2685aa9e3350Smrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 2686aa9e3350Smrg done 2687aa9e3350Smrg else 2688aa9e3350Smrg tmpdir=`func_mktempdir` 2689aa9e3350Smrg for lib in $libs; do 2690aa9e3350Smrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 2691aa9e3350Smrg > $tmpdir/tmp-la 2692aa9e3350Smrg mv -f $tmpdir/tmp-la $lib 2693aa9e3350Smrg done 2694aa9e3350Smrg ${RM}r "$tmpdir" 2695aa9e3350Smrg fi 2696aa9e3350Smrg fi 26971473d951Smrg 2698aa9e3350Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 26996aec45a7Smrg for libdir in $libdirs; do 27006aec45a7Smrg if test -n "$finish_cmds"; then 27016aec45a7Smrg # Do each command in the finish commands. 27026aec45a7Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 27036aec45a7Smrg'"$cmd"'"' 27046aec45a7Smrg fi 27056aec45a7Smrg if test -n "$finish_eval"; then 27066aec45a7Smrg # Do the single finish_eval. 27076aec45a7Smrg eval cmds=\"$finish_eval\" 2708aa9e3350Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 27096aec45a7Smrg $cmds" 27106aec45a7Smrg fi 27116aec45a7Smrg done 27126aec45a7Smrg fi 27131473d951Smrg 27146aec45a7Smrg # Exit here if they wanted silent mode. 27156aec45a7Smrg $opt_silent && exit $EXIT_SUCCESS 27161473d951Smrg 2717aa9e3350Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2718aa9e3350Smrg echo "----------------------------------------------------------------------" 2719aa9e3350Smrg echo "Libraries have been installed in:" 2720aa9e3350Smrg for libdir in $libdirs; do 2721aa9e3350Smrg $ECHO " $libdir" 2722aa9e3350Smrg done 2723aa9e3350Smrg echo 2724aa9e3350Smrg echo "If you ever happen to want to link against installed libraries" 2725aa9e3350Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 2726aa9e3350Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 2727aa9e3350Smrg echo "flag during linking and do at least one of the following:" 2728aa9e3350Smrg if test -n "$shlibpath_var"; then 2729aa9e3350Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 2730aa9e3350Smrg echo " during execution" 2731aa9e3350Smrg fi 2732aa9e3350Smrg if test -n "$runpath_var"; then 2733aa9e3350Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 2734aa9e3350Smrg echo " during linking" 2735aa9e3350Smrg fi 2736aa9e3350Smrg if test -n "$hardcode_libdir_flag_spec"; then 2737aa9e3350Smrg libdir=LIBDIR 2738aa9e3350Smrg eval flag=\"$hardcode_libdir_flag_spec\" 27391473d951Smrg 2740aa9e3350Smrg $ECHO " - use the \`$flag' linker flag" 2741aa9e3350Smrg fi 2742aa9e3350Smrg if test -n "$admincmds"; then 2743aa9e3350Smrg $ECHO " - have your system administrator run these commands:$admincmds" 2744aa9e3350Smrg fi 2745aa9e3350Smrg if test -f /etc/ld.so.conf; then 2746aa9e3350Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 2747aa9e3350Smrg fi 2748aa9e3350Smrg echo 27491473d951Smrg 2750aa9e3350Smrg echo "See any operating system documentation about shared libraries for" 2751aa9e3350Smrg case $host in 2752aa9e3350Smrg solaris2.[6789]|solaris2.1[0-9]) 2753aa9e3350Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 2754aa9e3350Smrg echo "pages." 2755aa9e3350Smrg ;; 2756aa9e3350Smrg *) 2757aa9e3350Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 2758aa9e3350Smrg ;; 2759aa9e3350Smrg esac 2760aa9e3350Smrg echo "----------------------------------------------------------------------" 2761aa9e3350Smrg fi 27626aec45a7Smrg exit $EXIT_SUCCESS 27636aec45a7Smrg} 27641473d951Smrg 2765aa9e3350Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 27665c42550eSmrg 2767ab47cfaaSmrg 27686aec45a7Smrg# func_mode_install arg... 27696aec45a7Smrgfunc_mode_install () 27706aec45a7Smrg{ 27716aec45a7Smrg $opt_debug 27726aec45a7Smrg # There may be an optional sh(1) argument at the beginning of 27736aec45a7Smrg # install_prog (especially on Windows NT). 27746aec45a7Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 27756aec45a7Smrg # Allow the use of GNU shtool's install command. 27766aec45a7Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 27776aec45a7Smrg # Aesthetically quote it. 27786aec45a7Smrg func_quote_for_eval "$nonopt" 27796aec45a7Smrg install_prog="$func_quote_for_eval_result " 27806aec45a7Smrg arg=$1 27816aec45a7Smrg shift 27826aec45a7Smrg else 27836aec45a7Smrg install_prog= 27846aec45a7Smrg arg=$nonopt 27856aec45a7Smrg fi 2786ab47cfaaSmrg 27876aec45a7Smrg # The real first argument should be the name of the installation program. 27886aec45a7Smrg # Aesthetically quote it. 27896aec45a7Smrg func_quote_for_eval "$arg" 2790aa9e3350Smrg func_append install_prog "$func_quote_for_eval_result" 27916aec45a7Smrg install_shared_prog=$install_prog 27926aec45a7Smrg case " $install_prog " in 27936aec45a7Smrg *[\\\ /]cp\ *) install_cp=: ;; 27946aec45a7Smrg *) install_cp=false ;; 27956aec45a7Smrg esac 2796ab47cfaaSmrg 27976aec45a7Smrg # We need to accept at least all the BSD install flags. 27986aec45a7Smrg dest= 27996aec45a7Smrg files= 28006aec45a7Smrg opts= 28016aec45a7Smrg prev= 28026aec45a7Smrg install_type= 28036aec45a7Smrg isdir=no 28046aec45a7Smrg stripme= 28056aec45a7Smrg no_mode=: 28066aec45a7Smrg for arg 28076aec45a7Smrg do 28086aec45a7Smrg arg2= 28096aec45a7Smrg if test -n "$dest"; then 2810aa9e3350Smrg func_append files " $dest" 28116aec45a7Smrg dest=$arg 28125c42550eSmrg continue 28136aec45a7Smrg fi 2814ab47cfaaSmrg 28156aec45a7Smrg case $arg in 28166aec45a7Smrg -d) isdir=yes ;; 28176aec45a7Smrg -f) 28186aec45a7Smrg if $install_cp; then :; else 28196aec45a7Smrg prev=$arg 2820ab47cfaaSmrg fi 28216aec45a7Smrg ;; 28226aec45a7Smrg -g | -m | -o) 28236aec45a7Smrg prev=$arg 28246aec45a7Smrg ;; 28256aec45a7Smrg -s) 28266aec45a7Smrg stripme=" -s" 28275c42550eSmrg continue 28285c42550eSmrg ;; 28296aec45a7Smrg -*) 28306aec45a7Smrg ;; 28315c42550eSmrg *) 28326aec45a7Smrg # If the previous option needed an argument, then skip it. 28336aec45a7Smrg if test -n "$prev"; then 28346aec45a7Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 28356aec45a7Smrg arg2=$install_override_mode 28366aec45a7Smrg no_mode=false 28376aec45a7Smrg fi 28386aec45a7Smrg prev= 28396aec45a7Smrg else 28406aec45a7Smrg dest=$arg 28416aec45a7Smrg continue 28426aec45a7Smrg fi 28431473d951Smrg ;; 28446aec45a7Smrg esac 2845ab47cfaaSmrg 28466aec45a7Smrg # Aesthetically quote the argument. 28476aec45a7Smrg func_quote_for_eval "$arg" 2848aa9e3350Smrg func_append install_prog " $func_quote_for_eval_result" 28496aec45a7Smrg if test -n "$arg2"; then 28506aec45a7Smrg func_quote_for_eval "$arg2" 28515c42550eSmrg fi 2852aa9e3350Smrg func_append install_shared_prog " $func_quote_for_eval_result" 28536aec45a7Smrg done 28541473d951Smrg 28556aec45a7Smrg test -z "$install_prog" && \ 28566aec45a7Smrg func_fatal_help "you must specify an install program" 28571473d951Smrg 28586aec45a7Smrg test -n "$prev" && \ 28596aec45a7Smrg func_fatal_help "the \`$prev' option requires an argument" 28601473d951Smrg 28616aec45a7Smrg if test -n "$install_override_mode" && $no_mode; then 28626aec45a7Smrg if $install_cp; then :; else 28636aec45a7Smrg func_quote_for_eval "$install_override_mode" 2864aa9e3350Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 28656aec45a7Smrg fi 28665c42550eSmrg fi 28671473d951Smrg 28686aec45a7Smrg if test -z "$files"; then 28696aec45a7Smrg if test -z "$dest"; then 28706aec45a7Smrg func_fatal_help "no file or destination specified" 28716aec45a7Smrg else 28726aec45a7Smrg func_fatal_help "you must specify a destination" 28731473d951Smrg fi 28741473d951Smrg fi 28751473d951Smrg 28766aec45a7Smrg # Strip any trailing slash from the destination. 28776aec45a7Smrg func_stripname '' '/' "$dest" 28786aec45a7Smrg dest=$func_stripname_result 2879ab47cfaaSmrg 28806aec45a7Smrg # Check to see that the destination is a directory. 28816aec45a7Smrg test -d "$dest" && isdir=yes 28826aec45a7Smrg if test "$isdir" = yes; then 28836aec45a7Smrg destdir="$dest" 28846aec45a7Smrg destname= 28856aec45a7Smrg else 28866aec45a7Smrg func_dirname_and_basename "$dest" "" "." 28876aec45a7Smrg destdir="$func_dirname_result" 28886aec45a7Smrg destname="$func_basename_result" 28896aec45a7Smrg 28906aec45a7Smrg # Not a directory, so check to see that there is only one file specified. 28916aec45a7Smrg set dummy $files; shift 28926aec45a7Smrg test "$#" -gt 1 && \ 28936aec45a7Smrg func_fatal_help "\`$dest' is not a directory" 28946aec45a7Smrg fi 28956aec45a7Smrg case $destdir in 28966aec45a7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 28975c42550eSmrg *) 28986aec45a7Smrg for file in $files; do 28996aec45a7Smrg case $file in 29006aec45a7Smrg *.lo) ;; 29016aec45a7Smrg *) 29026aec45a7Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 29036aec45a7Smrg ;; 29046aec45a7Smrg esac 29056aec45a7Smrg done 29065c42550eSmrg ;; 29075c42550eSmrg esac 2908ab47cfaaSmrg 29096aec45a7Smrg # This variable tells wrapper scripts just to set variables rather 29106aec45a7Smrg # than running their programs. 29116aec45a7Smrg libtool_install_magic="$magic" 2912ab47cfaaSmrg 29136aec45a7Smrg staticlibs= 29146aec45a7Smrg future_libdirs= 29156aec45a7Smrg current_libdirs= 29166aec45a7Smrg for file in $files; do 2917ab47cfaaSmrg 29186aec45a7Smrg # Do each installation. 29196aec45a7Smrg case $file in 29206aec45a7Smrg *.$libext) 29216aec45a7Smrg # Do the static libraries later. 2922aa9e3350Smrg func_append staticlibs " $file" 29236aec45a7Smrg ;; 29246aec45a7Smrg 29256aec45a7Smrg *.la) 2926aa9e3350Smrg func_resolve_sysroot "$file" 2927aa9e3350Smrg file=$func_resolve_sysroot_result 2928aa9e3350Smrg 29296aec45a7Smrg # Check to see that this really is a libtool archive. 29306aec45a7Smrg func_lalib_unsafe_p "$file" \ 29316aec45a7Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 29326aec45a7Smrg 29336aec45a7Smrg library_names= 29346aec45a7Smrg old_library= 29356aec45a7Smrg relink_command= 29366aec45a7Smrg func_source "$file" 29376aec45a7Smrg 29386aec45a7Smrg # Add the libdir to current_libdirs if it is the destination. 29396aec45a7Smrg if test "X$destdir" = "X$libdir"; then 29406aec45a7Smrg case "$current_libdirs " in 29416aec45a7Smrg *" $libdir "*) ;; 2942aa9e3350Smrg *) func_append current_libdirs " $libdir" ;; 29431473d951Smrg esac 29446aec45a7Smrg else 29456aec45a7Smrg # Note the libdir as a future libdir. 29466aec45a7Smrg case "$future_libdirs " in 29476aec45a7Smrg *" $libdir "*) ;; 2948aa9e3350Smrg *) func_append future_libdirs " $libdir" ;; 29496aec45a7Smrg esac 29506aec45a7Smrg fi 2951ab47cfaaSmrg 29526aec45a7Smrg func_dirname "$file" "/" "" 29536aec45a7Smrg dir="$func_dirname_result" 2954aa9e3350Smrg func_append dir "$objdir" 29556aec45a7Smrg 29566aec45a7Smrg if test -n "$relink_command"; then 29576aec45a7Smrg # Determine the prefix the user has applied to our future dir. 29586aec45a7Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 29596aec45a7Smrg 29606aec45a7Smrg # Don't allow the user to place us outside of our expected 29616aec45a7Smrg # location b/c this prevents finding dependent libraries that 29626aec45a7Smrg # are installed to the same prefix. 29636aec45a7Smrg # At present, this check doesn't affect windows .dll's that 29646aec45a7Smrg # are installed into $libdir/../bin (currently, that works fine) 29656aec45a7Smrg # but it's something to keep an eye on. 29666aec45a7Smrg test "$inst_prefix_dir" = "$destdir" && \ 29676aec45a7Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 29686aec45a7Smrg 29696aec45a7Smrg if test -n "$inst_prefix_dir"; then 29706aec45a7Smrg # Stick the inst_prefix_dir data into the link command. 29716aec45a7Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 29726aec45a7Smrg else 29736aec45a7Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 29746aec45a7Smrg fi 29756aec45a7Smrg 29766aec45a7Smrg func_warning "relinking \`$file'" 29776aec45a7Smrg func_show_eval "$relink_command" \ 29786aec45a7Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 29796aec45a7Smrg fi 29806aec45a7Smrg 29816aec45a7Smrg # See the names of the shared library. 29826aec45a7Smrg set dummy $library_names; shift 29836aec45a7Smrg if test -n "$1"; then 29846aec45a7Smrg realname="$1" 29856aec45a7Smrg shift 29866aec45a7Smrg 29876aec45a7Smrg srcname="$realname" 29886aec45a7Smrg test -n "$relink_command" && srcname="$realname"T 29896aec45a7Smrg 29906aec45a7Smrg # Install the shared library and build the symlinks. 29916aec45a7Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 29926aec45a7Smrg 'exit $?' 29936aec45a7Smrg tstripme="$stripme" 29946aec45a7Smrg case $host_os in 29956aec45a7Smrg cygwin* | mingw* | pw32* | cegcc*) 29966aec45a7Smrg case $realname in 29976aec45a7Smrg *.dll.a) 29986aec45a7Smrg tstripme="" 29996aec45a7Smrg ;; 30006aec45a7Smrg esac 30011473d951Smrg ;; 30021473d951Smrg esac 30036aec45a7Smrg if test -n "$tstripme" && test -n "$striplib"; then 30046aec45a7Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 30056aec45a7Smrg fi 30066aec45a7Smrg 30076aec45a7Smrg if test "$#" -gt 0; then 30086aec45a7Smrg # Delete the old symlinks, and create new ones. 30096aec45a7Smrg # Try `ln -sf' first, because the `ln' binary might depend on 30106aec45a7Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 30116aec45a7Smrg # so we also need to try rm && ln -s. 30126aec45a7Smrg for linkname 30136aec45a7Smrg do 30146aec45a7Smrg test "$linkname" != "$realname" \ 30156aec45a7Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 30166aec45a7Smrg done 30176aec45a7Smrg fi 30186aec45a7Smrg 30196aec45a7Smrg # Do each command in the postinstall commands. 30206aec45a7Smrg lib="$destdir/$realname" 30216aec45a7Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 30226aec45a7Smrg fi 30236aec45a7Smrg 30246aec45a7Smrg # Install the pseudo-library for information purposes. 30256aec45a7Smrg func_basename "$file" 30266aec45a7Smrg name="$func_basename_result" 30276aec45a7Smrg instname="$dir/$name"i 30286aec45a7Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 30296aec45a7Smrg 30306aec45a7Smrg # Maybe install the static library, too. 3031aa9e3350Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 30321473d951Smrg ;; 30336aec45a7Smrg 30346aec45a7Smrg *.lo) 30356aec45a7Smrg # Install (i.e. copy) a libtool object. 30366aec45a7Smrg 30376aec45a7Smrg # Figure out destination file name, if it wasn't already specified. 30386aec45a7Smrg if test -n "$destname"; then 30396aec45a7Smrg destfile="$destdir/$destname" 30406aec45a7Smrg else 30416aec45a7Smrg func_basename "$file" 30426aec45a7Smrg destfile="$func_basename_result" 30436aec45a7Smrg destfile="$destdir/$destfile" 30446aec45a7Smrg fi 30456aec45a7Smrg 30466aec45a7Smrg # Deduce the name of the destination old-style object file. 30476aec45a7Smrg case $destfile in 30486aec45a7Smrg *.lo) 30496aec45a7Smrg func_lo2o "$destfile" 30506aec45a7Smrg staticdest=$func_lo2o_result 30515c42550eSmrg ;; 30526aec45a7Smrg *.$objext) 30536aec45a7Smrg staticdest="$destfile" 30546aec45a7Smrg destfile= 30555c42550eSmrg ;; 30566aec45a7Smrg *) 30576aec45a7Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 30585c42550eSmrg ;; 30596aec45a7Smrg esac 30606aec45a7Smrg 30616aec45a7Smrg # Install the libtool object if requested. 30626aec45a7Smrg test -n "$destfile" && \ 30636aec45a7Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 30646aec45a7Smrg 30656aec45a7Smrg # Install the old object if enabled. 30666aec45a7Smrg if test "$build_old_libs" = yes; then 30676aec45a7Smrg # Deduce the name of the old-style object file. 30686aec45a7Smrg func_lo2o "$file" 30696aec45a7Smrg staticobj=$func_lo2o_result 30706aec45a7Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 30715c42550eSmrg fi 30726aec45a7Smrg exit $EXIT_SUCCESS 30736aec45a7Smrg ;; 3074ab47cfaaSmrg 30756aec45a7Smrg *) 30766aec45a7Smrg # Figure out destination file name, if it wasn't already specified. 30776aec45a7Smrg if test -n "$destname"; then 30786aec45a7Smrg destfile="$destdir/$destname" 30795c42550eSmrg else 30806aec45a7Smrg func_basename "$file" 30816aec45a7Smrg destfile="$func_basename_result" 30826aec45a7Smrg destfile="$destdir/$destfile" 30835c42550eSmrg fi 3084ab47cfaaSmrg 30856aec45a7Smrg # If the file is missing, and there is a .exe on the end, strip it 30866aec45a7Smrg # because it is most likely a libtool script we actually want to 30876aec45a7Smrg # install 30886aec45a7Smrg stripped_ext="" 30896aec45a7Smrg case $file in 30906aec45a7Smrg *.exe) 30916aec45a7Smrg if test ! -f "$file"; then 30926aec45a7Smrg func_stripname '' '.exe' "$file" 30936aec45a7Smrg file=$func_stripname_result 30946aec45a7Smrg stripped_ext=".exe" 30956aec45a7Smrg fi 30966aec45a7Smrg ;; 30976aec45a7Smrg esac 3098ab47cfaaSmrg 30996aec45a7Smrg # Do a test to see if this is really a libtool program. 31006aec45a7Smrg case $host in 31016aec45a7Smrg *cygwin* | *mingw*) 31026aec45a7Smrg if func_ltwrapper_executable_p "$file"; then 31036aec45a7Smrg func_ltwrapper_scriptname "$file" 31046aec45a7Smrg wrapper=$func_ltwrapper_scriptname_result 31056aec45a7Smrg else 31066aec45a7Smrg func_stripname '' '.exe' "$file" 31076aec45a7Smrg wrapper=$func_stripname_result 31086aec45a7Smrg fi 31096aec45a7Smrg ;; 31106aec45a7Smrg *) 31116aec45a7Smrg wrapper=$file 31126aec45a7Smrg ;; 31136aec45a7Smrg esac 31146aec45a7Smrg if func_ltwrapper_script_p "$wrapper"; then 31156aec45a7Smrg notinst_deplibs= 31166aec45a7Smrg relink_command= 3117ab47cfaaSmrg 31186aec45a7Smrg func_source "$wrapper" 3119ab47cfaaSmrg 31206aec45a7Smrg # Check the variables that should have been set. 31216aec45a7Smrg test -z "$generated_by_libtool_version" && \ 31226aec45a7Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3123ab47cfaaSmrg 31246aec45a7Smrg finalize=yes 31256aec45a7Smrg for lib in $notinst_deplibs; do 31266aec45a7Smrg # Check to see that each library is installed. 31276aec45a7Smrg libdir= 31286aec45a7Smrg if test -f "$lib"; then 31296aec45a7Smrg func_source "$lib" 31305c42550eSmrg fi 31316aec45a7Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 31326aec45a7Smrg if test -n "$libdir" && test ! -f "$libfile"; then 31336aec45a7Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 31346aec45a7Smrg finalize=no 31356aec45a7Smrg fi 31366aec45a7Smrg done 3137ab47cfaaSmrg 31386aec45a7Smrg relink_command= 31396aec45a7Smrg func_source "$wrapper" 3140ab47cfaaSmrg 31416aec45a7Smrg outputname= 31426aec45a7Smrg if test "$fast_install" = no && test -n "$relink_command"; then 31436aec45a7Smrg $opt_dry_run || { 31446aec45a7Smrg if test "$finalize" = yes; then 31456aec45a7Smrg tmpdir=`func_mktempdir` 31466aec45a7Smrg func_basename "$file$stripped_ext" 31476aec45a7Smrg file="$func_basename_result" 31486aec45a7Smrg outputname="$tmpdir/$file" 31496aec45a7Smrg # Replace the output file specification. 31506aec45a7Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 31516aec45a7Smrg 31526aec45a7Smrg $opt_silent || { 31536aec45a7Smrg func_quote_for_expand "$relink_command" 31546aec45a7Smrg eval "func_echo $func_quote_for_expand_result" 31556aec45a7Smrg } 31566aec45a7Smrg if eval "$relink_command"; then : 31576aec45a7Smrg else 31586aec45a7Smrg func_error "error: relink \`$file' with the above command before installing it" 31596aec45a7Smrg $opt_dry_run || ${RM}r "$tmpdir" 31606aec45a7Smrg continue 31616aec45a7Smrg fi 31626aec45a7Smrg file="$outputname" 31636aec45a7Smrg else 31646aec45a7Smrg func_warning "cannot relink \`$file'" 31656aec45a7Smrg fi 31666aec45a7Smrg } 31675c42550eSmrg else 31686aec45a7Smrg # Install the binary that we compiled earlier. 31696aec45a7Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 31705c42550eSmrg fi 31716aec45a7Smrg fi 3172ab47cfaaSmrg 31736aec45a7Smrg # remove .exe since cygwin /usr/bin/install will append another 31746aec45a7Smrg # one anyway 31756aec45a7Smrg case $install_prog,$host in 31766aec45a7Smrg */usr/bin/install*,*cygwin*) 31776aec45a7Smrg case $file:$destfile in 31786aec45a7Smrg *.exe:*.exe) 31796aec45a7Smrg # this is ok 31806aec45a7Smrg ;; 31816aec45a7Smrg *.exe:*) 31826aec45a7Smrg destfile=$destfile.exe 31836aec45a7Smrg ;; 31846aec45a7Smrg *:*.exe) 31856aec45a7Smrg func_stripname '' '.exe' "$destfile" 31866aec45a7Smrg destfile=$func_stripname_result 31876aec45a7Smrg ;; 31886aec45a7Smrg esac 31895c42550eSmrg ;; 31905c42550eSmrg esac 31916aec45a7Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 31926aec45a7Smrg $opt_dry_run || if test -n "$outputname"; then 31936aec45a7Smrg ${RM}r "$tmpdir" 31946aec45a7Smrg fi 31956aec45a7Smrg ;; 31966aec45a7Smrg esac 31976aec45a7Smrg done 3198ab47cfaaSmrg 31996aec45a7Smrg for file in $staticlibs; do 32006aec45a7Smrg func_basename "$file" 32016aec45a7Smrg name="$func_basename_result" 32026aec45a7Smrg 32036aec45a7Smrg # Set up the ranlib parameters. 32046aec45a7Smrg oldlib="$destdir/$name" 3205aa9e3350Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 3206aa9e3350Smrg tool_oldlib=$func_to_tool_file_result 32076aec45a7Smrg 32086aec45a7Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 32096aec45a7Smrg 32106aec45a7Smrg if test -n "$stripme" && test -n "$old_striplib"; then 3211aa9e3350Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 32126aec45a7Smrg fi 32136aec45a7Smrg 32146aec45a7Smrg # Do each command in the postinstall commands. 32156aec45a7Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 32166aec45a7Smrg done 32176aec45a7Smrg 32186aec45a7Smrg test -n "$future_libdirs" && \ 32196aec45a7Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 32206aec45a7Smrg 32216aec45a7Smrg if test -n "$current_libdirs"; then 32226aec45a7Smrg # Maybe just do a dry run. 32236aec45a7Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 32246aec45a7Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 32256aec45a7Smrg else 32266aec45a7Smrg exit $EXIT_SUCCESS 32276aec45a7Smrg fi 32286aec45a7Smrg} 32296aec45a7Smrg 3230aa9e3350Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 32316aec45a7Smrg 32326aec45a7Smrg 32336aec45a7Smrg# func_generate_dlsyms outputname originator pic_p 32346aec45a7Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 32356aec45a7Smrg# a dlpreopen symbol table. 32366aec45a7Smrgfunc_generate_dlsyms () 32376aec45a7Smrg{ 32386aec45a7Smrg $opt_debug 32396aec45a7Smrg my_outputname="$1" 32406aec45a7Smrg my_originator="$2" 32416aec45a7Smrg my_pic_p="${3-no}" 32426aec45a7Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 32436aec45a7Smrg my_dlsyms= 32446aec45a7Smrg 32456aec45a7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 32466aec45a7Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 32476aec45a7Smrg my_dlsyms="${my_outputname}S.c" 32486aec45a7Smrg else 32496aec45a7Smrg func_error "not configured to extract global symbols from dlpreopened files" 32506aec45a7Smrg fi 32516aec45a7Smrg fi 32526aec45a7Smrg 32536aec45a7Smrg if test -n "$my_dlsyms"; then 32546aec45a7Smrg case $my_dlsyms in 32556aec45a7Smrg "") ;; 32566aec45a7Smrg *.c) 32576aec45a7Smrg # Discover the nlist of each of the dlfiles. 32586aec45a7Smrg nlist="$output_objdir/${my_outputname}.nm" 32596aec45a7Smrg 32606aec45a7Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 32616aec45a7Smrg 32626aec45a7Smrg # Parse the name list into a source file. 32636aec45a7Smrg func_verbose "creating $output_objdir/$my_dlsyms" 32646aec45a7Smrg 32656aec45a7Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 32666aec45a7Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 32676aec45a7Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 32686aec45a7Smrg 32696aec45a7Smrg#ifdef __cplusplus 32706aec45a7Smrgextern \"C\" { 32716aec45a7Smrg#endif 32726aec45a7Smrg 32736aec45a7Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 32746aec45a7Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 32756aec45a7Smrg#endif 32766aec45a7Smrg 3277aa9e3350Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 3278aa9e3350Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 3279aa9e3350Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 3280aa9e3350Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 3281aa9e3350Smrg# define LT_DLSYM_CONST 3282aa9e3350Smrg#elif defined(__osf__) 3283aa9e3350Smrg/* This system does not cope well with relocations in const data. */ 3284aa9e3350Smrg# define LT_DLSYM_CONST 3285aa9e3350Smrg#else 3286aa9e3350Smrg# define LT_DLSYM_CONST const 3287aa9e3350Smrg#endif 3288aa9e3350Smrg 32896aec45a7Smrg/* External symbol declarations for the compiler. */\ 32906aec45a7Smrg" 32916aec45a7Smrg 32926aec45a7Smrg if test "$dlself" = yes; then 32936aec45a7Smrg func_verbose "generating symbol list for \`$output'" 32946aec45a7Smrg 32956aec45a7Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 32966aec45a7Smrg 32976aec45a7Smrg # Add our own program objects to the symbol list. 32986aec45a7Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 32996aec45a7Smrg for progfile in $progfiles; do 3300aa9e3350Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 3301aa9e3350Smrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 3302aa9e3350Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 33036aec45a7Smrg done 33046aec45a7Smrg 33056aec45a7Smrg if test -n "$exclude_expsyms"; then 33066aec45a7Smrg $opt_dry_run || { 33076aec45a7Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 33086aec45a7Smrg eval '$MV "$nlist"T "$nlist"' 33096aec45a7Smrg } 33105c42550eSmrg fi 33116aec45a7Smrg 33126aec45a7Smrg if test -n "$export_symbols_regex"; then 33136aec45a7Smrg $opt_dry_run || { 33146aec45a7Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 33156aec45a7Smrg eval '$MV "$nlist"T "$nlist"' 33166aec45a7Smrg } 33176aec45a7Smrg fi 33186aec45a7Smrg 33196aec45a7Smrg # Prepare the list of exported symbols 33206aec45a7Smrg if test -z "$export_symbols"; then 33216aec45a7Smrg export_symbols="$output_objdir/$outputname.exp" 33226aec45a7Smrg $opt_dry_run || { 33236aec45a7Smrg $RM $export_symbols 33246aec45a7Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 33256aec45a7Smrg case $host in 33266aec45a7Smrg *cygwin* | *mingw* | *cegcc* ) 33276aec45a7Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 33286aec45a7Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 33296aec45a7Smrg ;; 33306aec45a7Smrg esac 33316aec45a7Smrg } 33325c42550eSmrg else 33336aec45a7Smrg $opt_dry_run || { 33346aec45a7Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 33356aec45a7Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 33366aec45a7Smrg eval '$MV "$nlist"T "$nlist"' 33376aec45a7Smrg case $host in 33386aec45a7Smrg *cygwin* | *mingw* | *cegcc* ) 33396aec45a7Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 33406aec45a7Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 33416aec45a7Smrg ;; 33426aec45a7Smrg esac 33436aec45a7Smrg } 33445c42550eSmrg fi 33456aec45a7Smrg fi 3346ab47cfaaSmrg 33476aec45a7Smrg for dlprefile in $dlprefiles; do 33486aec45a7Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 33496aec45a7Smrg func_basename "$dlprefile" 33506aec45a7Smrg name="$func_basename_result" 3351aa9e3350Smrg case $host in 3352aa9e3350Smrg *cygwin* | *mingw* | *cegcc* ) 3353aa9e3350Smrg # if an import library, we need to obtain dlname 3354aa9e3350Smrg if func_win32_import_lib_p "$dlprefile"; then 3355aa9e3350Smrg func_tr_sh "$dlprefile" 3356aa9e3350Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 3357aa9e3350Smrg dlprefile_dlbasename="" 3358aa9e3350Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 3359aa9e3350Smrg # Use subshell, to avoid clobbering current variable values 3360aa9e3350Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 3361aa9e3350Smrg if test -n "$dlprefile_dlname" ; then 3362aa9e3350Smrg func_basename "$dlprefile_dlname" 3363aa9e3350Smrg dlprefile_dlbasename="$func_basename_result" 3364aa9e3350Smrg else 3365aa9e3350Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 3366aa9e3350Smrg $sharedlib_from_linklib_cmd "$dlprefile" 3367aa9e3350Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 3368aa9e3350Smrg fi 3369aa9e3350Smrg fi 3370aa9e3350Smrg $opt_dry_run || { 3371aa9e3350Smrg if test -n "$dlprefile_dlbasename" ; then 3372aa9e3350Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 3373aa9e3350Smrg else 3374aa9e3350Smrg func_warning "Could not compute DLL name from $name" 3375aa9e3350Smrg eval '$ECHO ": $name " >> "$nlist"' 3376aa9e3350Smrg fi 3377aa9e3350Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3378aa9e3350Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 3379aa9e3350Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 3380aa9e3350Smrg } 3381aa9e3350Smrg else # not an import lib 3382aa9e3350Smrg $opt_dry_run || { 3383aa9e3350Smrg eval '$ECHO ": $name " >> "$nlist"' 3384aa9e3350Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3385aa9e3350Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3386aa9e3350Smrg } 3387aa9e3350Smrg fi 3388aa9e3350Smrg ;; 3389aa9e3350Smrg *) 3390aa9e3350Smrg $opt_dry_run || { 3391aa9e3350Smrg eval '$ECHO ": $name " >> "$nlist"' 3392aa9e3350Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3393aa9e3350Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3394aa9e3350Smrg } 3395aa9e3350Smrg ;; 3396aa9e3350Smrg esac 33976aec45a7Smrg done 33986aec45a7Smrg 33996aec45a7Smrg $opt_dry_run || { 34006aec45a7Smrg # Make sure we have at least an empty file. 34016aec45a7Smrg test -f "$nlist" || : > "$nlist" 34026aec45a7Smrg 34036aec45a7Smrg if test -n "$exclude_expsyms"; then 34046aec45a7Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 34056aec45a7Smrg $MV "$nlist"T "$nlist" 34065c42550eSmrg fi 34076aec45a7Smrg 34086aec45a7Smrg # Try sorting and uniquifying the output. 34096aec45a7Smrg if $GREP -v "^: " < "$nlist" | 34106aec45a7Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 34116aec45a7Smrg sort -k 3 34126aec45a7Smrg else 34136aec45a7Smrg sort +2 34146aec45a7Smrg fi | 34156aec45a7Smrg uniq > "$nlist"S; then 34166aec45a7Smrg : 34175c42550eSmrg else 34186aec45a7Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 34195c42550eSmrg fi 3420ab47cfaaSmrg 34216aec45a7Smrg if test -f "$nlist"S; then 34226aec45a7Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 34235c42550eSmrg else 34246aec45a7Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 34255c42550eSmrg fi 3426ab47cfaaSmrg 34276aec45a7Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3428ab47cfaaSmrg 34296aec45a7Smrg/* The mapping between symbol names and symbols. */ 34306aec45a7Smrgtypedef struct { 34316aec45a7Smrg const char *name; 34326aec45a7Smrg void *address; 34336aec45a7Smrg} lt_dlsymlist; 3434aa9e3350Smrgextern LT_DLSYM_CONST lt_dlsymlist 34356aec45a7Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 3436aa9e3350SmrgLT_DLSYM_CONST lt_dlsymlist 34376aec45a7Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 34386aec45a7Smrg{\ 34396aec45a7Smrg { \"$my_originator\", (void *) 0 }," 3440ab47cfaaSmrg 34416aec45a7Smrg case $need_lib_prefix in 34426aec45a7Smrg no) 34436aec45a7Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 34446aec45a7Smrg ;; 34456aec45a7Smrg *) 34466aec45a7Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 34476aec45a7Smrg ;; 34486aec45a7Smrg esac 34496aec45a7Smrg echo >> "$output_objdir/$my_dlsyms" "\ 34506aec45a7Smrg {0, (void *) 0} 34516aec45a7Smrg}; 34521473d951Smrg 34536aec45a7Smrg/* This works around a problem in FreeBSD linker */ 34546aec45a7Smrg#ifdef FREEBSD_WORKAROUND 34556aec45a7Smrgstatic const void *lt_preloaded_setup() { 34566aec45a7Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 34576aec45a7Smrg} 34586aec45a7Smrg#endif 3459ab47cfaaSmrg 34606aec45a7Smrg#ifdef __cplusplus 34616aec45a7Smrg} 34626aec45a7Smrg#endif\ 34636aec45a7Smrg" 34646aec45a7Smrg } # !$opt_dry_run 34651473d951Smrg 34666aec45a7Smrg pic_flag_for_symtable= 34676aec45a7Smrg case "$compile_command " in 34686aec45a7Smrg *" -static "*) ;; 34696aec45a7Smrg *) 34706aec45a7Smrg case $host in 34716aec45a7Smrg # compiling the symbol table file with pic_flag works around 34726aec45a7Smrg # a FreeBSD bug that causes programs to crash when -lm is 34736aec45a7Smrg # linked before any other PIC object. But we must not use 34746aec45a7Smrg # pic_flag when linking with -static. The problem exists in 34756aec45a7Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 3476aa9e3350Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 34776aec45a7Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 34786aec45a7Smrg *-*-hpux*) 34796aec45a7Smrg pic_flag_for_symtable=" $pic_flag" ;; 34806aec45a7Smrg *) 34816aec45a7Smrg if test "X$my_pic_p" != Xno; then 34826aec45a7Smrg pic_flag_for_symtable=" $pic_flag" 34836aec45a7Smrg fi 34846aec45a7Smrg ;; 34856aec45a7Smrg esac 34866aec45a7Smrg ;; 34876aec45a7Smrg esac 34886aec45a7Smrg symtab_cflags= 34896aec45a7Smrg for arg in $LTCFLAGS; do 34906aec45a7Smrg case $arg in 34916aec45a7Smrg -pie | -fpie | -fPIE) ;; 3492aa9e3350Smrg *) func_append symtab_cflags " $arg" ;; 34936aec45a7Smrg esac 34946aec45a7Smrg done 3495ab47cfaaSmrg 34966aec45a7Smrg # Now compile the dynamic symbol file. 34976aec45a7Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3498ab47cfaaSmrg 34996aec45a7Smrg # Clean up the generated files. 35006aec45a7Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 35011473d951Smrg 35026aec45a7Smrg # Transform the symbol file into the correct name. 35036aec45a7Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 35046aec45a7Smrg case $host in 35056aec45a7Smrg *cygwin* | *mingw* | *cegcc* ) 35066aec45a7Smrg if test -f "$output_objdir/$my_outputname.def"; then 35076aec45a7Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 35086aec45a7Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 35096aec45a7Smrg else 35106aec45a7Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35116aec45a7Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35126aec45a7Smrg fi 35136aec45a7Smrg ;; 35146aec45a7Smrg *) 35156aec45a7Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35166aec45a7Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 35176aec45a7Smrg ;; 35186aec45a7Smrg esac 35196aec45a7Smrg ;; 35206aec45a7Smrg *) 35216aec45a7Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 35226aec45a7Smrg ;; 35236aec45a7Smrg esac 35246aec45a7Smrg else 35256aec45a7Smrg # We keep going just in case the user didn't refer to 35266aec45a7Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 35276aec45a7Smrg # really was required. 35281473d951Smrg 35296aec45a7Smrg # Nullify the symbol file. 35306aec45a7Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 35316aec45a7Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 35326aec45a7Smrg fi 35336aec45a7Smrg} 35341473d951Smrg 35356aec45a7Smrg# func_win32_libid arg 35366aec45a7Smrg# return the library type of file 'arg' 35376aec45a7Smrg# 35386aec45a7Smrg# Need a lot of goo to handle *both* DLLs and import libs 35396aec45a7Smrg# Has to be a shell function in order to 'eat' the argument 35406aec45a7Smrg# that is supplied when $file_magic_command is called. 35416aec45a7Smrg# Despite the name, also deal with 64 bit binaries. 35426aec45a7Smrgfunc_win32_libid () 35436aec45a7Smrg{ 35446aec45a7Smrg $opt_debug 35456aec45a7Smrg win32_libid_type="unknown" 35466aec45a7Smrg win32_fileres=`file -L $1 2>/dev/null` 35476aec45a7Smrg case $win32_fileres in 35486aec45a7Smrg *ar\ archive\ import\ library*) # definitely import 35496aec45a7Smrg win32_libid_type="x86 archive import" 35506aec45a7Smrg ;; 35516aec45a7Smrg *ar\ archive*) # could be an import, or static 35526aec45a7Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 35536aec45a7Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 35546aec45a7Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 3555aa9e3350Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3556aa9e3350Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 35576aec45a7Smrg $SED -n -e ' 35586aec45a7Smrg 1,100{ 35596aec45a7Smrg / I /{ 35606aec45a7Smrg s,.*,import, 35616aec45a7Smrg p 35626aec45a7Smrg q 35636aec45a7Smrg } 35646aec45a7Smrg }'` 35656aec45a7Smrg case $win32_nmres in 35666aec45a7Smrg import*) win32_libid_type="x86 archive import";; 35676aec45a7Smrg *) win32_libid_type="x86 archive static";; 35686aec45a7Smrg esac 35696aec45a7Smrg fi 35706aec45a7Smrg ;; 35716aec45a7Smrg *DLL*) 35726aec45a7Smrg win32_libid_type="x86 DLL" 35736aec45a7Smrg ;; 35746aec45a7Smrg *executable*) # but shell scripts are "executable" too... 35756aec45a7Smrg case $win32_fileres in 35766aec45a7Smrg *MS\ Windows\ PE\ Intel*) 35776aec45a7Smrg win32_libid_type="x86 DLL" 35786aec45a7Smrg ;; 35796aec45a7Smrg esac 35806aec45a7Smrg ;; 35816aec45a7Smrg esac 35826aec45a7Smrg $ECHO "$win32_libid_type" 35836aec45a7Smrg} 35841473d951Smrg 3585aa9e3350Smrg# func_cygming_dll_for_implib ARG 3586aa9e3350Smrg# 3587aa9e3350Smrg# Platform-specific function to extract the 3588aa9e3350Smrg# name of the DLL associated with the specified 3589aa9e3350Smrg# import library ARG. 3590aa9e3350Smrg# Invoked by eval'ing the libtool variable 3591aa9e3350Smrg# $sharedlib_from_linklib_cmd 3592aa9e3350Smrg# Result is available in the variable 3593aa9e3350Smrg# $sharedlib_from_linklib_result 3594aa9e3350Smrgfunc_cygming_dll_for_implib () 3595aa9e3350Smrg{ 3596aa9e3350Smrg $opt_debug 3597aa9e3350Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 3598aa9e3350Smrg} 3599aa9e3350Smrg 3600aa9e3350Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 3601aa9e3350Smrg# 3602aa9e3350Smrg# The is the core of a fallback implementation of a 3603aa9e3350Smrg# platform-specific function to extract the name of the 3604aa9e3350Smrg# DLL associated with the specified import library LIBNAME. 3605aa9e3350Smrg# 3606aa9e3350Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 3607aa9e3350Smrg# on the platform and compiler that created the implib. 3608aa9e3350Smrg# 3609aa9e3350Smrg# Echos the name of the DLL associated with the 3610aa9e3350Smrg# specified import library. 3611aa9e3350Smrgfunc_cygming_dll_for_implib_fallback_core () 3612aa9e3350Smrg{ 3613aa9e3350Smrg $opt_debug 3614aa9e3350Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 3615aa9e3350Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 3616aa9e3350Smrg $SED '/^Contents of section '"$match_literal"':/{ 3617aa9e3350Smrg # Place marker at beginning of archive member dllname section 3618aa9e3350Smrg s/.*/====MARK====/ 3619aa9e3350Smrg p 3620aa9e3350Smrg d 3621aa9e3350Smrg } 3622aa9e3350Smrg # These lines can sometimes be longer than 43 characters, but 3623aa9e3350Smrg # are always uninteresting 3624aa9e3350Smrg /:[ ]*file format pe[i]\{,1\}-/d 3625aa9e3350Smrg /^In archive [^:]*:/d 3626aa9e3350Smrg # Ensure marker is printed 3627aa9e3350Smrg /^====MARK====/p 3628aa9e3350Smrg # Remove all lines with less than 43 characters 3629aa9e3350Smrg /^.\{43\}/!d 3630aa9e3350Smrg # From remaining lines, remove first 43 characters 3631aa9e3350Smrg s/^.\{43\}//' | 3632aa9e3350Smrg $SED -n ' 3633aa9e3350Smrg # Join marker and all lines until next marker into a single line 3634aa9e3350Smrg /^====MARK====/ b para 3635aa9e3350Smrg H 3636aa9e3350Smrg $ b para 3637aa9e3350Smrg b 3638aa9e3350Smrg :para 3639aa9e3350Smrg x 3640aa9e3350Smrg s/\n//g 3641aa9e3350Smrg # Remove the marker 3642aa9e3350Smrg s/^====MARK====// 3643aa9e3350Smrg # Remove trailing dots and whitespace 3644aa9e3350Smrg s/[\. \t]*$// 3645aa9e3350Smrg # Print 3646aa9e3350Smrg /./p' | 3647aa9e3350Smrg # we now have a list, one entry per line, of the stringified 3648aa9e3350Smrg # contents of the appropriate section of all members of the 3649aa9e3350Smrg # archive which possess that section. Heuristic: eliminate 3650aa9e3350Smrg # all those which have a first or second character that is 3651aa9e3350Smrg # a '.' (that is, objdump's representation of an unprintable 3652aa9e3350Smrg # character.) This should work for all archives with less than 3653aa9e3350Smrg # 0x302f exports -- but will fail for DLLs whose name actually 3654aa9e3350Smrg # begins with a literal '.' or a single character followed by 3655aa9e3350Smrg # a '.'. 3656aa9e3350Smrg # 3657aa9e3350Smrg # Of those that remain, print the first one. 3658aa9e3350Smrg $SED -e '/^\./d;/^.\./d;q' 3659aa9e3350Smrg} 3660aa9e3350Smrg 3661aa9e3350Smrg# func_cygming_gnu_implib_p ARG 3662aa9e3350Smrg# This predicate returns with zero status (TRUE) if 3663aa9e3350Smrg# ARG is a GNU/binutils-style import library. Returns 3664aa9e3350Smrg# with nonzero status (FALSE) otherwise. 3665aa9e3350Smrgfunc_cygming_gnu_implib_p () 3666aa9e3350Smrg{ 3667aa9e3350Smrg $opt_debug 3668aa9e3350Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3669aa9e3350Smrg 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)$'` 3670aa9e3350Smrg test -n "$func_cygming_gnu_implib_tmp" 3671aa9e3350Smrg} 3672aa9e3350Smrg 3673aa9e3350Smrg# func_cygming_ms_implib_p ARG 3674aa9e3350Smrg# This predicate returns with zero status (TRUE) if 3675aa9e3350Smrg# ARG is an MS-style import library. Returns 3676aa9e3350Smrg# with nonzero status (FALSE) otherwise. 3677aa9e3350Smrgfunc_cygming_ms_implib_p () 3678aa9e3350Smrg{ 3679aa9e3350Smrg $opt_debug 3680aa9e3350Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3681aa9e3350Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 3682aa9e3350Smrg test -n "$func_cygming_ms_implib_tmp" 3683aa9e3350Smrg} 3684aa9e3350Smrg 3685aa9e3350Smrg# func_cygming_dll_for_implib_fallback ARG 3686aa9e3350Smrg# Platform-specific function to extract the 3687aa9e3350Smrg# name of the DLL associated with the specified 3688aa9e3350Smrg# import library ARG. 3689aa9e3350Smrg# 3690aa9e3350Smrg# This fallback implementation is for use when $DLLTOOL 3691aa9e3350Smrg# does not support the --identify-strict option. 3692aa9e3350Smrg# Invoked by eval'ing the libtool variable 3693aa9e3350Smrg# $sharedlib_from_linklib_cmd 3694aa9e3350Smrg# Result is available in the variable 3695aa9e3350Smrg# $sharedlib_from_linklib_result 3696aa9e3350Smrgfunc_cygming_dll_for_implib_fallback () 3697aa9e3350Smrg{ 3698aa9e3350Smrg $opt_debug 3699aa9e3350Smrg if func_cygming_gnu_implib_p "$1" ; then 3700aa9e3350Smrg # binutils import library 3701aa9e3350Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 3702aa9e3350Smrg elif func_cygming_ms_implib_p "$1" ; then 3703aa9e3350Smrg # ms-generated import library 3704aa9e3350Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 3705aa9e3350Smrg else 3706aa9e3350Smrg # unknown 3707aa9e3350Smrg sharedlib_from_linklib_result="" 3708aa9e3350Smrg fi 3709aa9e3350Smrg} 3710ab47cfaaSmrg 3711ab47cfaaSmrg 37126aec45a7Smrg# func_extract_an_archive dir oldlib 37136aec45a7Smrgfunc_extract_an_archive () 37146aec45a7Smrg{ 37156aec45a7Smrg $opt_debug 37166aec45a7Smrg f_ex_an_ar_dir="$1"; shift 37176aec45a7Smrg f_ex_an_ar_oldlib="$1" 37186aec45a7Smrg if test "$lock_old_archive_extraction" = yes; then 37196aec45a7Smrg lockfile=$f_ex_an_ar_oldlib.lock 37206aec45a7Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 37216aec45a7Smrg func_echo "Waiting for $lockfile to be removed" 37226aec45a7Smrg sleep 2 37236aec45a7Smrg done 37246aec45a7Smrg fi 37256aec45a7Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 37266aec45a7Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 37276aec45a7Smrg if test "$lock_old_archive_extraction" = yes; then 37286aec45a7Smrg $opt_dry_run || rm -f "$lockfile" 37296aec45a7Smrg fi 37306aec45a7Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 37316aec45a7Smrg : 37326aec45a7Smrg else 37336aec45a7Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 37346aec45a7Smrg fi 37356aec45a7Smrg} 37361473d951Smrg 37371473d951Smrg 37386aec45a7Smrg# func_extract_archives gentop oldlib ... 37396aec45a7Smrgfunc_extract_archives () 37406aec45a7Smrg{ 37416aec45a7Smrg $opt_debug 37426aec45a7Smrg my_gentop="$1"; shift 37436aec45a7Smrg my_oldlibs=${1+"$@"} 37446aec45a7Smrg my_oldobjs="" 37456aec45a7Smrg my_xlib="" 37466aec45a7Smrg my_xabs="" 37476aec45a7Smrg my_xdir="" 37481473d951Smrg 37496aec45a7Smrg for my_xlib in $my_oldlibs; do 37506aec45a7Smrg # Extract the objects. 37516aec45a7Smrg case $my_xlib in 37526aec45a7Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 37536aec45a7Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 37546aec45a7Smrg esac 37556aec45a7Smrg func_basename "$my_xlib" 37566aec45a7Smrg my_xlib="$func_basename_result" 37576aec45a7Smrg my_xlib_u=$my_xlib 37586aec45a7Smrg while :; do 37596aec45a7Smrg case " $extracted_archives " in 37606aec45a7Smrg *" $my_xlib_u "*) 37616aec45a7Smrg func_arith $extracted_serial + 1 37626aec45a7Smrg extracted_serial=$func_arith_result 37636aec45a7Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 37646aec45a7Smrg *) break ;; 37656aec45a7Smrg esac 37666aec45a7Smrg done 37676aec45a7Smrg extracted_archives="$extracted_archives $my_xlib_u" 37686aec45a7Smrg my_xdir="$my_gentop/$my_xlib_u" 37691473d951Smrg 37706aec45a7Smrg func_mkdir_p "$my_xdir" 37716aec45a7Smrg 37726aec45a7Smrg case $host in 37736aec45a7Smrg *-darwin*) 37746aec45a7Smrg func_verbose "Extracting $my_xabs" 37756aec45a7Smrg # Do not bother doing anything if just a dry run 37766aec45a7Smrg $opt_dry_run || { 37776aec45a7Smrg darwin_orig_dir=`pwd` 37786aec45a7Smrg cd $my_xdir || exit $? 37796aec45a7Smrg darwin_archive=$my_xabs 37806aec45a7Smrg darwin_curdir=`pwd` 37816aec45a7Smrg darwin_base_archive=`basename "$darwin_archive"` 37826aec45a7Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 37836aec45a7Smrg if test -n "$darwin_arches"; then 37846aec45a7Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 37856aec45a7Smrg darwin_arch= 37866aec45a7Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 37876aec45a7Smrg for darwin_arch in $darwin_arches ; do 37886aec45a7Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 37896aec45a7Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 37906aec45a7Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 37916aec45a7Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 37926aec45a7Smrg cd "$darwin_curdir" 37936aec45a7Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 37946aec45a7Smrg done # $darwin_arches 37956aec45a7Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 37966aec45a7Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 37976aec45a7Smrg darwin_file= 37986aec45a7Smrg darwin_files= 37996aec45a7Smrg for darwin_file in $darwin_filelist; do 38006aec45a7Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 38016aec45a7Smrg $LIPO -create -output "$darwin_file" $darwin_files 38026aec45a7Smrg done # $darwin_filelist 38036aec45a7Smrg $RM -rf unfat-$$ 38046aec45a7Smrg cd "$darwin_orig_dir" 38055c42550eSmrg else 38066aec45a7Smrg cd $darwin_orig_dir 38076aec45a7Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 38086aec45a7Smrg fi # $darwin_arches 38096aec45a7Smrg } # !$opt_dry_run 38106aec45a7Smrg ;; 38116aec45a7Smrg *) 38126aec45a7Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 38136aec45a7Smrg ;; 38146aec45a7Smrg esac 38156aec45a7Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 38166aec45a7Smrg done 3817ab47cfaaSmrg 38186aec45a7Smrg func_extract_archives_result="$my_oldobjs" 38196aec45a7Smrg} 3820ab47cfaaSmrg 38211473d951Smrg 38226aec45a7Smrg# func_emit_wrapper [arg=no] 38236aec45a7Smrg# 38246aec45a7Smrg# Emit a libtool wrapper script on stdout. 38256aec45a7Smrg# Don't directly open a file because we may want to 38266aec45a7Smrg# incorporate the script contents within a cygwin/mingw 38276aec45a7Smrg# wrapper executable. Must ONLY be called from within 38286aec45a7Smrg# func_mode_link because it depends on a number of variables 38296aec45a7Smrg# set therein. 38306aec45a7Smrg# 38316aec45a7Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 38326aec45a7Smrg# variable will take. If 'yes', then the emitted script 38336aec45a7Smrg# will assume that the directory in which it is stored is 38346aec45a7Smrg# the $objdir directory. This is a cygwin/mingw-specific 38356aec45a7Smrg# behavior. 38366aec45a7Smrgfunc_emit_wrapper () 38376aec45a7Smrg{ 38386aec45a7Smrg func_emit_wrapper_arg1=${1-no} 38395c42550eSmrg 38406aec45a7Smrg $ECHO "\ 38416aec45a7Smrg#! $SHELL 38421473d951Smrg 38436aec45a7Smrg# $output - temporary wrapper script for $objdir/$outputname 38446aec45a7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 38456aec45a7Smrg# 38466aec45a7Smrg# The $output program cannot be directly executed until all the libtool 38476aec45a7Smrg# libraries that it depends on are installed. 38486aec45a7Smrg# 38496aec45a7Smrg# This wrapper script should never be moved out of the build directory. 38506aec45a7Smrg# If it is, it will not operate correctly. 3851ab47cfaaSmrg 38526aec45a7Smrg# Sed substitution that helps us do robust quoting. It backslashifies 38536aec45a7Smrg# metacharacters that are still active within double-quoted strings. 38546aec45a7Smrgsed_quote_subst='$sed_quote_subst' 3855ab47cfaaSmrg 38566aec45a7Smrg# Be Bourne compatible 38576aec45a7Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 38586aec45a7Smrg emulate sh 38596aec45a7Smrg NULLCMD=: 38606aec45a7Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 38616aec45a7Smrg # is contrary to our usage. Disable this feature. 38626aec45a7Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 38636aec45a7Smrg setopt NO_GLOB_SUBST 38646aec45a7Smrgelse 38656aec45a7Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 38666aec45a7Smrgfi 38676aec45a7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 38686aec45a7SmrgDUALCASE=1; export DUALCASE # for MKS sh 3869ab47cfaaSmrg 38706aec45a7Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 38716aec45a7Smrg# if CDPATH is set. 38726aec45a7Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3873ab47cfaaSmrg 38746aec45a7Smrgrelink_command=\"$relink_command\" 3875ab47cfaaSmrg 38766aec45a7Smrg# This environment variable determines our operation mode. 38776aec45a7Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 38786aec45a7Smrg # install mode needs the following variables: 38796aec45a7Smrg generated_by_libtool_version='$macro_version' 38806aec45a7Smrg notinst_deplibs='$notinst_deplibs' 38816aec45a7Smrgelse 38826aec45a7Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 38836aec45a7Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 38846aec45a7Smrg file=\"\$0\"" 3885ab47cfaaSmrg 38866aec45a7Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 38876aec45a7Smrg $ECHO "\ 3888ab47cfaaSmrg 38896aec45a7Smrg# A function that is used when there is no print builtin or printf. 38906aec45a7Smrgfunc_fallback_echo () 38916aec45a7Smrg{ 38926aec45a7Smrg eval 'cat <<_LTECHO_EOF 38936aec45a7Smrg\$1 38946aec45a7Smrg_LTECHO_EOF' 38956aec45a7Smrg} 38966aec45a7Smrg ECHO=\"$qECHO\" 38976aec45a7Smrg fi 38986aec45a7Smrg 38996aec45a7Smrg# Very basic option parsing. These options are (a) specific to 39006aec45a7Smrg# the libtool wrapper, (b) are identical between the wrapper 39016aec45a7Smrg# /script/ and the wrapper /executable/ which is used only on 39026aec45a7Smrg# windows platforms, and (c) all begin with the string "--lt-" 39036aec45a7Smrg# (application programs are unlikely to have options which match 39046aec45a7Smrg# this pattern). 39056aec45a7Smrg# 39066aec45a7Smrg# There are only two supported options: --lt-debug and 39076aec45a7Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 39086aec45a7Smrg# 39096aec45a7Smrg# The first argument to this parsing function should be the 39106aec45a7Smrg# script's $0 value, followed by "$@". 39116aec45a7Smrglt_option_debug= 39126aec45a7Smrgfunc_parse_lt_options () 39136aec45a7Smrg{ 39146aec45a7Smrg lt_script_arg0=\$0 39156aec45a7Smrg shift 39166aec45a7Smrg for lt_opt 39176aec45a7Smrg do 39186aec45a7Smrg case \"\$lt_opt\" in 39196aec45a7Smrg --lt-debug) lt_option_debug=1 ;; 39206aec45a7Smrg --lt-dump-script) 39216aec45a7Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 39226aec45a7Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 39236aec45a7Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 39246aec45a7Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 39256aec45a7Smrg exit 0 39266aec45a7Smrg ;; 39276aec45a7Smrg --lt-*) 39286aec45a7Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 39296aec45a7Smrg exit 1 39305c42550eSmrg ;; 39316aec45a7Smrg esac 39326aec45a7Smrg done 3933ab47cfaaSmrg 39346aec45a7Smrg # Print the debug banner immediately: 39356aec45a7Smrg if test -n \"\$lt_option_debug\"; then 39366aec45a7Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 39376aec45a7Smrg fi 39386aec45a7Smrg} 3939ab47cfaaSmrg 39406aec45a7Smrg# Used when --lt-debug. Prints its arguments to stdout 39416aec45a7Smrg# (redirection is the responsibility of the caller) 39426aec45a7Smrgfunc_lt_dump_args () 39436aec45a7Smrg{ 39446aec45a7Smrg lt_dump_args_N=1; 39456aec45a7Smrg for lt_arg 39466aec45a7Smrg do 39476aec45a7Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 39486aec45a7Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 39496aec45a7Smrg done 39506aec45a7Smrg} 3951ab47cfaaSmrg 39526aec45a7Smrg# Core function for launching the target application 39536aec45a7Smrgfunc_exec_program_core () 39546aec45a7Smrg{ 39556aec45a7Smrg" 39566aec45a7Smrg case $host in 39576aec45a7Smrg # Backslashes separate directories on plain windows 39586aec45a7Smrg *-*-mingw | *-*-os2* | *-cegcc*) 39596aec45a7Smrg $ECHO "\ 39606aec45a7Smrg if test -n \"\$lt_option_debug\"; then 39616aec45a7Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 39626aec45a7Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 39635c42550eSmrg fi 39646aec45a7Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 39656aec45a7Smrg" 39666aec45a7Smrg ;; 3967ab47cfaaSmrg 39686aec45a7Smrg *) 39696aec45a7Smrg $ECHO "\ 39706aec45a7Smrg if test -n \"\$lt_option_debug\"; then 39716aec45a7Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 39726aec45a7Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 39735c42550eSmrg fi 39746aec45a7Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 39756aec45a7Smrg" 39766aec45a7Smrg ;; 39776aec45a7Smrg esac 39786aec45a7Smrg $ECHO "\ 39796aec45a7Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 39806aec45a7Smrg exit 1 39816aec45a7Smrg} 3982ab47cfaaSmrg 39836aec45a7Smrg# A function to encapsulate launching the target application 39846aec45a7Smrg# Strips options in the --lt-* namespace from \$@ and 39856aec45a7Smrg# launches target application with the remaining arguments. 39866aec45a7Smrgfunc_exec_program () 39876aec45a7Smrg{ 3988aa9e3350Smrg case \" \$* \" in 3989aa9e3350Smrg *\\ --lt-*) 3990aa9e3350Smrg for lt_wr_arg 3991aa9e3350Smrg do 3992aa9e3350Smrg case \$lt_wr_arg in 3993aa9e3350Smrg --lt-*) ;; 3994aa9e3350Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 3995aa9e3350Smrg esac 3996aa9e3350Smrg shift 3997aa9e3350Smrg done ;; 3998aa9e3350Smrg esac 39996aec45a7Smrg func_exec_program_core \${1+\"\$@\"} 40006aec45a7Smrg} 4001ab47cfaaSmrg 40026aec45a7Smrg # Parse options 40036aec45a7Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 4004ab47cfaaSmrg 40056aec45a7Smrg # Find the directory that this script lives in. 40066aec45a7Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 40076aec45a7Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4008ab47cfaaSmrg 40096aec45a7Smrg # Follow symbolic links until we get to the real thisdir. 40106aec45a7Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 40116aec45a7Smrg while test -n \"\$file\"; do 40126aec45a7Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4013ab47cfaaSmrg 40146aec45a7Smrg # If there was a directory component, then change thisdir. 40156aec45a7Smrg if test \"x\$destdir\" != \"x\$file\"; then 40166aec45a7Smrg case \"\$destdir\" in 40176aec45a7Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 40186aec45a7Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 40196aec45a7Smrg esac 40206aec45a7Smrg fi 4021ab47cfaaSmrg 40226aec45a7Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 40236aec45a7Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 40246aec45a7Smrg done 4025ab47cfaaSmrg 40266aec45a7Smrg # Usually 'no', except on cygwin/mingw when embedded into 40276aec45a7Smrg # the cwrapper. 40286aec45a7Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 40296aec45a7Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 40306aec45a7Smrg # special case for '.' 40316aec45a7Smrg if test \"\$thisdir\" = \".\"; then 40326aec45a7Smrg thisdir=\`pwd\` 40336aec45a7Smrg fi 40346aec45a7Smrg # remove .libs from thisdir 40356aec45a7Smrg case \"\$thisdir\" in 40366aec45a7Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 40376aec45a7Smrg $objdir ) thisdir=. ;; 40386aec45a7Smrg esac 40396aec45a7Smrg fi 4040ab47cfaaSmrg 40416aec45a7Smrg # Try to get the absolute directory name. 40426aec45a7Smrg absdir=\`cd \"\$thisdir\" && pwd\` 40436aec45a7Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 40446aec45a7Smrg" 4045ab47cfaaSmrg 40466aec45a7Smrg if test "$fast_install" = yes; then 40476aec45a7Smrg $ECHO "\ 40486aec45a7Smrg program=lt-'$outputname'$exeext 40496aec45a7Smrg progdir=\"\$thisdir/$objdir\" 4050ab47cfaaSmrg 40516aec45a7Smrg if test ! -f \"\$progdir/\$program\" || 40526aec45a7Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 40536aec45a7Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4054ab47cfaaSmrg 40556aec45a7Smrg file=\"\$\$-\$program\" 4056ab47cfaaSmrg 40576aec45a7Smrg if test ! -d \"\$progdir\"; then 40586aec45a7Smrg $MKDIR \"\$progdir\" 40596aec45a7Smrg else 40606aec45a7Smrg $RM \"\$progdir/\$file\" 40616aec45a7Smrg fi" 4062ab47cfaaSmrg 40636aec45a7Smrg $ECHO "\ 4064ab47cfaaSmrg 40656aec45a7Smrg # relink executable if necessary 40666aec45a7Smrg if test -n \"\$relink_command\"; then 40676aec45a7Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 40686aec45a7Smrg else 40696aec45a7Smrg $ECHO \"\$relink_command_output\" >&2 40706aec45a7Smrg $RM \"\$progdir/\$file\" 40716aec45a7Smrg exit 1 40726aec45a7Smrg fi 40736aec45a7Smrg fi 4074ab47cfaaSmrg 40756aec45a7Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 40766aec45a7Smrg { $RM \"\$progdir/\$program\"; 40776aec45a7Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 40786aec45a7Smrg $RM \"\$progdir/\$file\" 40796aec45a7Smrg fi" 40806aec45a7Smrg else 40816aec45a7Smrg $ECHO "\ 40826aec45a7Smrg program='$outputname' 40836aec45a7Smrg progdir=\"\$thisdir/$objdir\" 40846aec45a7Smrg" 40856aec45a7Smrg fi 4086ab47cfaaSmrg 40876aec45a7Smrg $ECHO "\ 4088ab47cfaaSmrg 40896aec45a7Smrg if test -f \"\$progdir/\$program\"; then" 4090ab47cfaaSmrg 4091aa9e3350Smrg # fixup the dll searchpath if we need to. 4092aa9e3350Smrg # 4093aa9e3350Smrg # Fix the DLL searchpath if we need to. Do this before prepending 4094aa9e3350Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 4095aa9e3350Smrg # libraries must come first. 4096aa9e3350Smrg if test -n "$dllsearchpath"; then 4097aa9e3350Smrg $ECHO "\ 4098aa9e3350Smrg # Add the dll search path components to the executable PATH 4099aa9e3350Smrg PATH=$dllsearchpath:\$PATH 4100aa9e3350Smrg" 4101aa9e3350Smrg fi 4102aa9e3350Smrg 41036aec45a7Smrg # Export our shlibpath_var if we have one. 41046aec45a7Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 41056aec45a7Smrg $ECHO "\ 41066aec45a7Smrg # Add our own library path to $shlibpath_var 41076aec45a7Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4108ab47cfaaSmrg 41096aec45a7Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 41106aec45a7Smrg # The second colon is a workaround for a bug in BeOS R4 sed 41116aec45a7Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4112ab47cfaaSmrg 41136aec45a7Smrg export $shlibpath_var 41146aec45a7Smrg" 41156aec45a7Smrg fi 41161473d951Smrg 41176aec45a7Smrg $ECHO "\ 41186aec45a7Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 41196aec45a7Smrg # Run the actual program with our arguments. 41206aec45a7Smrg func_exec_program \${1+\"\$@\"} 41216aec45a7Smrg fi 41226aec45a7Smrg else 41236aec45a7Smrg # The program doesn't exist. 41246aec45a7Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 41256aec45a7Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 41266aec45a7Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 41276aec45a7Smrg exit 1 41286aec45a7Smrg fi 41296aec45a7Smrgfi\ 41306aec45a7Smrg" 41316aec45a7Smrg} 41321473d951Smrg 41331473d951Smrg 41346aec45a7Smrg# func_emit_cwrapperexe_src 41356aec45a7Smrg# emit the source code for a wrapper executable on stdout 41366aec45a7Smrg# Must ONLY be called from within func_mode_link because 41376aec45a7Smrg# it depends on a number of variable set therein. 41386aec45a7Smrgfunc_emit_cwrapperexe_src () 41396aec45a7Smrg{ 41406aec45a7Smrg cat <<EOF 4141ab47cfaaSmrg 41426aec45a7Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 41436aec45a7Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4144ab47cfaaSmrg 41456aec45a7Smrg The $output program cannot be directly executed until all the libtool 41466aec45a7Smrg libraries that it depends on are installed. 4147ab47cfaaSmrg 41486aec45a7Smrg This wrapper executable should never be moved out of the build directory. 41496aec45a7Smrg If it is, it will not operate correctly. 41506aec45a7Smrg*/ 41516aec45a7SmrgEOF 41526aec45a7Smrg cat <<"EOF" 41536aec45a7Smrg#ifdef _MSC_VER 41546aec45a7Smrg# define _CRT_SECURE_NO_DEPRECATE 1 41556aec45a7Smrg#endif 41566aec45a7Smrg#include <stdio.h> 41576aec45a7Smrg#include <stdlib.h> 41586aec45a7Smrg#ifdef _MSC_VER 41596aec45a7Smrg# include <direct.h> 41606aec45a7Smrg# include <process.h> 41616aec45a7Smrg# include <io.h> 41626aec45a7Smrg#else 41636aec45a7Smrg# include <unistd.h> 41646aec45a7Smrg# include <stdint.h> 41656aec45a7Smrg# ifdef __CYGWIN__ 41666aec45a7Smrg# include <io.h> 41676aec45a7Smrg# endif 41686aec45a7Smrg#endif 41696aec45a7Smrg#include <malloc.h> 41706aec45a7Smrg#include <stdarg.h> 41716aec45a7Smrg#include <assert.h> 41726aec45a7Smrg#include <string.h> 41736aec45a7Smrg#include <ctype.h> 41746aec45a7Smrg#include <errno.h> 41756aec45a7Smrg#include <fcntl.h> 41766aec45a7Smrg#include <sys/stat.h> 4177ab47cfaaSmrg 41786aec45a7Smrg/* declarations of non-ANSI functions */ 41796aec45a7Smrg#if defined(__MINGW32__) 41806aec45a7Smrg# ifdef __STRICT_ANSI__ 41816aec45a7Smrgint _putenv (const char *); 41826aec45a7Smrg# endif 41836aec45a7Smrg#elif defined(__CYGWIN__) 41846aec45a7Smrg# ifdef __STRICT_ANSI__ 41856aec45a7Smrgchar *realpath (const char *, char *); 41866aec45a7Smrgint putenv (char *); 41876aec45a7Smrgint setenv (const char *, const char *, int); 41886aec45a7Smrg# endif 41896aec45a7Smrg/* #elif defined (other platforms) ... */ 41906aec45a7Smrg#endif 4191ab47cfaaSmrg 41926aec45a7Smrg/* portability defines, excluding path handling macros */ 41936aec45a7Smrg#if defined(_MSC_VER) 41946aec45a7Smrg# define setmode _setmode 41956aec45a7Smrg# define stat _stat 41966aec45a7Smrg# define chmod _chmod 41976aec45a7Smrg# define getcwd _getcwd 41986aec45a7Smrg# define putenv _putenv 41996aec45a7Smrg# define S_IXUSR _S_IEXEC 42006aec45a7Smrg# ifndef _INTPTR_T_DEFINED 42016aec45a7Smrg# define _INTPTR_T_DEFINED 42026aec45a7Smrg# define intptr_t int 42036aec45a7Smrg# endif 42046aec45a7Smrg#elif defined(__MINGW32__) 42056aec45a7Smrg# define setmode _setmode 42066aec45a7Smrg# define stat _stat 42076aec45a7Smrg# define chmod _chmod 42086aec45a7Smrg# define getcwd _getcwd 42096aec45a7Smrg# define putenv _putenv 42106aec45a7Smrg#elif defined(__CYGWIN__) 42116aec45a7Smrg# define HAVE_SETENV 42126aec45a7Smrg# define FOPEN_WB "wb" 42136aec45a7Smrg/* #elif defined (other platforms) ... */ 42146aec45a7Smrg#endif 4215ab47cfaaSmrg 42166aec45a7Smrg#if defined(PATH_MAX) 42176aec45a7Smrg# define LT_PATHMAX PATH_MAX 42186aec45a7Smrg#elif defined(MAXPATHLEN) 42196aec45a7Smrg# define LT_PATHMAX MAXPATHLEN 42206aec45a7Smrg#else 42216aec45a7Smrg# define LT_PATHMAX 1024 42226aec45a7Smrg#endif 4223ab47cfaaSmrg 42246aec45a7Smrg#ifndef S_IXOTH 42256aec45a7Smrg# define S_IXOTH 0 42266aec45a7Smrg#endif 42276aec45a7Smrg#ifndef S_IXGRP 42286aec45a7Smrg# define S_IXGRP 0 42296aec45a7Smrg#endif 4230ab47cfaaSmrg 42316aec45a7Smrg/* path handling portability macros */ 42326aec45a7Smrg#ifndef DIR_SEPARATOR 42336aec45a7Smrg# define DIR_SEPARATOR '/' 42346aec45a7Smrg# define PATH_SEPARATOR ':' 42356aec45a7Smrg#endif 4236ab47cfaaSmrg 42376aec45a7Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 42386aec45a7Smrg defined (__OS2__) 42396aec45a7Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 42406aec45a7Smrg# define FOPEN_WB "wb" 42416aec45a7Smrg# ifndef DIR_SEPARATOR_2 42426aec45a7Smrg# define DIR_SEPARATOR_2 '\\' 42436aec45a7Smrg# endif 42446aec45a7Smrg# ifndef PATH_SEPARATOR_2 42456aec45a7Smrg# define PATH_SEPARATOR_2 ';' 42466aec45a7Smrg# endif 42476aec45a7Smrg#endif 4248ab47cfaaSmrg 42496aec45a7Smrg#ifndef DIR_SEPARATOR_2 42506aec45a7Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 42516aec45a7Smrg#else /* DIR_SEPARATOR_2 */ 42526aec45a7Smrg# define IS_DIR_SEPARATOR(ch) \ 42536aec45a7Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 42546aec45a7Smrg#endif /* DIR_SEPARATOR_2 */ 4255ab47cfaaSmrg 42566aec45a7Smrg#ifndef PATH_SEPARATOR_2 42576aec45a7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 42586aec45a7Smrg#else /* PATH_SEPARATOR_2 */ 42596aec45a7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 42606aec45a7Smrg#endif /* PATH_SEPARATOR_2 */ 42616aec45a7Smrg 42626aec45a7Smrg#ifndef FOPEN_WB 42636aec45a7Smrg# define FOPEN_WB "w" 42646aec45a7Smrg#endif 42656aec45a7Smrg#ifndef _O_BINARY 42666aec45a7Smrg# define _O_BINARY 0 42676aec45a7Smrg#endif 42686aec45a7Smrg 42696aec45a7Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 42706aec45a7Smrg#define XFREE(stale) do { \ 42716aec45a7Smrg if (stale) { free ((void *) stale); stale = 0; } \ 42726aec45a7Smrg} while (0) 42736aec45a7Smrg 42746aec45a7Smrg#if defined(LT_DEBUGWRAPPER) 42756aec45a7Smrgstatic int lt_debug = 1; 42766aec45a7Smrg#else 42776aec45a7Smrgstatic int lt_debug = 0; 42786aec45a7Smrg#endif 42796aec45a7Smrg 42806aec45a7Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 42816aec45a7Smrg 42826aec45a7Smrgvoid *xmalloc (size_t num); 42836aec45a7Smrgchar *xstrdup (const char *string); 42846aec45a7Smrgconst char *base_name (const char *name); 42856aec45a7Smrgchar *find_executable (const char *wrapper); 42866aec45a7Smrgchar *chase_symlinks (const char *pathspec); 42876aec45a7Smrgint make_executable (const char *path); 42886aec45a7Smrgint check_executable (const char *path); 42896aec45a7Smrgchar *strendzap (char *str, const char *pat); 42906aec45a7Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 42916aec45a7Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 42926aec45a7Smrgstatic const char *nonnull (const char *s); 42936aec45a7Smrgstatic const char *nonempty (const char *s); 42946aec45a7Smrgvoid lt_setenv (const char *name, const char *value); 42956aec45a7Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 42966aec45a7Smrgvoid lt_update_exe_path (const char *name, const char *value); 42976aec45a7Smrgvoid lt_update_lib_path (const char *name, const char *value); 42986aec45a7Smrgchar **prepare_spawn (char **argv); 42996aec45a7Smrgvoid lt_dump_script (FILE *f); 43006aec45a7SmrgEOF 43016aec45a7Smrg 43026aec45a7Smrg cat <<EOF 4303aa9e3350Smrgvolatile const char * MAGIC_EXE = "$magic_exe"; 43046aec45a7Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 43056aec45a7SmrgEOF 43066aec45a7Smrg 43076aec45a7Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4308aa9e3350Smrg func_to_host_path "$temp_rpath" 43096aec45a7Smrg cat <<EOF 4310aa9e3350Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 43115c42550eSmrgEOF 43125c42550eSmrg else 43136aec45a7Smrg cat <<"EOF" 43146aec45a7Smrgconst char * LIB_PATH_VALUE = ""; 43156aec45a7SmrgEOF 43165c42550eSmrg fi 43176aec45a7Smrg 43186aec45a7Smrg if test -n "$dllsearchpath"; then 4319aa9e3350Smrg func_to_host_path "$dllsearchpath:" 43206aec45a7Smrg cat <<EOF 43216aec45a7Smrgconst char * EXE_PATH_VARNAME = "PATH"; 4322aa9e3350Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 43236aec45a7SmrgEOF 43245c42550eSmrg else 43256aec45a7Smrg cat <<"EOF" 43266aec45a7Smrgconst char * EXE_PATH_VARNAME = ""; 43276aec45a7Smrgconst char * EXE_PATH_VALUE = ""; 43286aec45a7SmrgEOF 43295c42550eSmrg fi 43306aec45a7Smrg 43316aec45a7Smrg if test "$fast_install" = yes; then 43326aec45a7Smrg cat <<EOF 43336aec45a7Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 43346aec45a7SmrgEOF 43355c42550eSmrg else 43366aec45a7Smrg cat <<EOF 43376aec45a7Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 43386aec45a7SmrgEOF 43395c42550eSmrg fi 4340ab47cfaaSmrg 4341ab47cfaaSmrg 43426aec45a7Smrg cat <<"EOF" 4343ab47cfaaSmrg 43446aec45a7Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 4345ab47cfaaSmrg 43466aec45a7Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 43476aec45a7Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 43486aec45a7Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4349ab47cfaaSmrg 43506aec45a7Smrgint 43516aec45a7Smrgmain (int argc, char *argv[]) 43526aec45a7Smrg{ 43536aec45a7Smrg char **newargz; 43546aec45a7Smrg int newargc; 43556aec45a7Smrg char *tmp_pathspec; 43566aec45a7Smrg char *actual_cwrapper_path; 43576aec45a7Smrg char *actual_cwrapper_name; 43586aec45a7Smrg char *target_name; 43596aec45a7Smrg char *lt_argv_zero; 43606aec45a7Smrg intptr_t rval = 127; 4361ab47cfaaSmrg 43626aec45a7Smrg int i; 4363ab47cfaaSmrg 43646aec45a7Smrg program_name = (char *) xstrdup (base_name (argv[0])); 43656aec45a7Smrg newargz = XMALLOC (char *, argc + 1); 4366ab47cfaaSmrg 43676aec45a7Smrg /* very simple arg parsing; don't want to rely on getopt 43686aec45a7Smrg * also, copy all non cwrapper options to newargz, except 43696aec45a7Smrg * argz[0], which is handled differently 43706aec45a7Smrg */ 43716aec45a7Smrg newargc=0; 43726aec45a7Smrg for (i = 1; i < argc; i++) 43736aec45a7Smrg { 43746aec45a7Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 43756aec45a7Smrg { 43766aec45a7SmrgEOF 43776aec45a7Smrg case "$host" in 43786aec45a7Smrg *mingw* | *cygwin* ) 43796aec45a7Smrg # make stdout use "unix" line endings 43806aec45a7Smrg echo " setmode(1,_O_BINARY);" 43816aec45a7Smrg ;; 43825c42550eSmrg esac 4383ab47cfaaSmrg 43846aec45a7Smrg cat <<"EOF" 43856aec45a7Smrg lt_dump_script (stdout); 43866aec45a7Smrg return 0; 43876aec45a7Smrg } 43886aec45a7Smrg if (strcmp (argv[i], debug_opt) == 0) 43896aec45a7Smrg { 43906aec45a7Smrg lt_debug = 1; 43916aec45a7Smrg continue; 43926aec45a7Smrg } 43936aec45a7Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 43946aec45a7Smrg { 43956aec45a7Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 43966aec45a7Smrg namespace, but it is not one of the ones we know about and 43976aec45a7Smrg have already dealt with, above (inluding dump-script), then 43986aec45a7Smrg report an error. Otherwise, targets might begin to believe 43996aec45a7Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 44006aec45a7Smrg namespace. The first time any user complains about this, we'll 44016aec45a7Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 44026aec45a7Smrg or a configure.ac-settable value. 44036aec45a7Smrg */ 44046aec45a7Smrg lt_fatal (__FILE__, __LINE__, 44056aec45a7Smrg "unrecognized %s option: '%s'", 44066aec45a7Smrg ltwrapper_option_prefix, argv[i]); 44076aec45a7Smrg } 44086aec45a7Smrg /* otherwise ... */ 44096aec45a7Smrg newargz[++newargc] = xstrdup (argv[i]); 44106aec45a7Smrg } 44116aec45a7Smrg newargz[++newargc] = NULL; 4412ab47cfaaSmrg 44136aec45a7SmrgEOF 44146aec45a7Smrg cat <<EOF 44156aec45a7Smrg /* The GNU banner must be the first non-error debug message */ 44166aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 44176aec45a7SmrgEOF 44186aec45a7Smrg cat <<"EOF" 44196aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 44206aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 44216aec45a7Smrg 44226aec45a7Smrg tmp_pathspec = find_executable (argv[0]); 44236aec45a7Smrg if (tmp_pathspec == NULL) 44246aec45a7Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 44256aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, 44266aec45a7Smrg "(main) found exe (before symlink chase) at: %s\n", 44276aec45a7Smrg tmp_pathspec); 44286aec45a7Smrg 44296aec45a7Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 44306aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, 44316aec45a7Smrg "(main) found exe (after symlink chase) at: %s\n", 44326aec45a7Smrg actual_cwrapper_path); 44336aec45a7Smrg XFREE (tmp_pathspec); 44346aec45a7Smrg 44356aec45a7Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 44366aec45a7Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 44376aec45a7Smrg 44386aec45a7Smrg /* wrapper name transforms */ 44396aec45a7Smrg strendzap (actual_cwrapper_name, ".exe"); 44406aec45a7Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 44416aec45a7Smrg XFREE (actual_cwrapper_name); 44426aec45a7Smrg actual_cwrapper_name = tmp_pathspec; 44436aec45a7Smrg tmp_pathspec = 0; 44446aec45a7Smrg 44456aec45a7Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 44466aec45a7Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 44476aec45a7Smrg strendzap (target_name, ".exe"); 44486aec45a7Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 44496aec45a7Smrg XFREE (target_name); 44506aec45a7Smrg target_name = tmp_pathspec; 44516aec45a7Smrg tmp_pathspec = 0; 44526aec45a7Smrg 44536aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, 44546aec45a7Smrg "(main) libtool target name: %s\n", 44556aec45a7Smrg target_name); 44566aec45a7SmrgEOF 4457ab47cfaaSmrg 44586aec45a7Smrg cat <<EOF 44596aec45a7Smrg newargz[0] = 44606aec45a7Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 44616aec45a7Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 44626aec45a7Smrg strcpy (newargz[0], actual_cwrapper_path); 44636aec45a7Smrg strcat (newargz[0], "$objdir"); 44646aec45a7Smrg strcat (newargz[0], "/"); 44656aec45a7SmrgEOF 4466ab47cfaaSmrg 44676aec45a7Smrg cat <<"EOF" 44686aec45a7Smrg /* stop here, and copy so we don't have to do this twice */ 44696aec45a7Smrg tmp_pathspec = xstrdup (newargz[0]); 4470ab47cfaaSmrg 44716aec45a7Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 44726aec45a7Smrg strcat (newargz[0], actual_cwrapper_name); 4473ab47cfaaSmrg 44746aec45a7Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 44756aec45a7Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 44766aec45a7Smrg XFREE (tmp_pathspec); 44776aec45a7Smrg tmp_pathspec = NULL; 44786aec45a7SmrgEOF 4479ab47cfaaSmrg 44806aec45a7Smrg case $host_os in 44816aec45a7Smrg mingw*) 44826aec45a7Smrg cat <<"EOF" 44836aec45a7Smrg { 44846aec45a7Smrg char* p; 44856aec45a7Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 44866aec45a7Smrg { 44876aec45a7Smrg *p = '/'; 44886aec45a7Smrg } 44896aec45a7Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 44906aec45a7Smrg { 44916aec45a7Smrg *p = '/'; 44926aec45a7Smrg } 44936aec45a7Smrg } 44946aec45a7SmrgEOF 44956aec45a7Smrg ;; 44966aec45a7Smrg esac 4497ab47cfaaSmrg 44986aec45a7Smrg cat <<"EOF" 44996aec45a7Smrg XFREE (target_name); 45006aec45a7Smrg XFREE (actual_cwrapper_path); 45016aec45a7Smrg XFREE (actual_cwrapper_name); 4502ab47cfaaSmrg 45036aec45a7Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 45046aec45a7Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 4505aa9e3350Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 4506aa9e3350Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 4507aa9e3350Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 4508aa9e3350Smrg libraries must come first. */ 45096aec45a7Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 4510aa9e3350Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4511ab47cfaaSmrg 45126aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 45136aec45a7Smrg nonnull (lt_argv_zero)); 45146aec45a7Smrg for (i = 0; i < newargc; i++) 45156aec45a7Smrg { 45166aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 45176aec45a7Smrg i, nonnull (newargz[i])); 45186aec45a7Smrg } 4519ab47cfaaSmrg 45206aec45a7SmrgEOF 4521ab47cfaaSmrg 45226aec45a7Smrg case $host_os in 45236aec45a7Smrg mingw*) 45246aec45a7Smrg cat <<"EOF" 45256aec45a7Smrg /* execv doesn't actually work on mingw as expected on unix */ 45266aec45a7Smrg newargz = prepare_spawn (newargz); 45276aec45a7Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 45286aec45a7Smrg if (rval == -1) 45296aec45a7Smrg { 45306aec45a7Smrg /* failed to start process */ 45316aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, 45326aec45a7Smrg "(main) failed to launch target \"%s\": %s\n", 45336aec45a7Smrg lt_argv_zero, nonnull (strerror (errno))); 45346aec45a7Smrg return 127; 45356aec45a7Smrg } 45366aec45a7Smrg return rval; 45376aec45a7SmrgEOF 45386aec45a7Smrg ;; 45396aec45a7Smrg *) 45406aec45a7Smrg cat <<"EOF" 45416aec45a7Smrg execv (lt_argv_zero, newargz); 45426aec45a7Smrg return rval; /* =127, but avoids unused variable warning */ 45436aec45a7SmrgEOF 45446aec45a7Smrg ;; 45456aec45a7Smrg esac 4546ab47cfaaSmrg 45476aec45a7Smrg cat <<"EOF" 45486aec45a7Smrg} 4549ab47cfaaSmrg 45506aec45a7Smrgvoid * 45516aec45a7Smrgxmalloc (size_t num) 45526aec45a7Smrg{ 45536aec45a7Smrg void *p = (void *) malloc (num); 45546aec45a7Smrg if (!p) 45556aec45a7Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4556ab47cfaaSmrg 45576aec45a7Smrg return p; 45586aec45a7Smrg} 4559ab47cfaaSmrg 45606aec45a7Smrgchar * 45616aec45a7Smrgxstrdup (const char *string) 45626aec45a7Smrg{ 45636aec45a7Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 45646aec45a7Smrg string) : NULL; 45656aec45a7Smrg} 4566ab47cfaaSmrg 45676aec45a7Smrgconst char * 45686aec45a7Smrgbase_name (const char *name) 45696aec45a7Smrg{ 45706aec45a7Smrg const char *base; 4571ab47cfaaSmrg 45726aec45a7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 45736aec45a7Smrg /* Skip over the disk name in MSDOS pathnames. */ 45746aec45a7Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 45756aec45a7Smrg name += 2; 45766aec45a7Smrg#endif 4577ab47cfaaSmrg 45786aec45a7Smrg for (base = name; *name; name++) 45796aec45a7Smrg if (IS_DIR_SEPARATOR (*name)) 45806aec45a7Smrg base = name + 1; 45816aec45a7Smrg return base; 45826aec45a7Smrg} 4583ab47cfaaSmrg 45846aec45a7Smrgint 45856aec45a7Smrgcheck_executable (const char *path) 45866aec45a7Smrg{ 45876aec45a7Smrg struct stat st; 4588ab47cfaaSmrg 45896aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 45906aec45a7Smrg nonempty (path)); 45916aec45a7Smrg if ((!path) || (!*path)) 45926aec45a7Smrg return 0; 4593ab47cfaaSmrg 45946aec45a7Smrg if ((stat (path, &st) >= 0) 45956aec45a7Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 45966aec45a7Smrg return 1; 45976aec45a7Smrg else 45986aec45a7Smrg return 0; 45996aec45a7Smrg} 4600ab47cfaaSmrg 46016aec45a7Smrgint 46026aec45a7Smrgmake_executable (const char *path) 46036aec45a7Smrg{ 46046aec45a7Smrg int rval = 0; 46056aec45a7Smrg struct stat st; 46065c42550eSmrg 46076aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 46086aec45a7Smrg nonempty (path)); 46096aec45a7Smrg if ((!path) || (!*path)) 46106aec45a7Smrg return 0; 46115c42550eSmrg 46126aec45a7Smrg if (stat (path, &st) >= 0) 46136aec45a7Smrg { 46146aec45a7Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 46156aec45a7Smrg } 46166aec45a7Smrg return rval; 46176aec45a7Smrg} 46185c42550eSmrg 46196aec45a7Smrg/* Searches for the full path of the wrapper. Returns 46206aec45a7Smrg newly allocated full path name if found, NULL otherwise 46216aec45a7Smrg Does not chase symlinks, even on platforms that support them. 46226aec45a7Smrg*/ 46236aec45a7Smrgchar * 46246aec45a7Smrgfind_executable (const char *wrapper) 46256aec45a7Smrg{ 46266aec45a7Smrg int has_slash = 0; 46276aec45a7Smrg const char *p; 46286aec45a7Smrg const char *p_next; 46296aec45a7Smrg /* static buffer for getcwd */ 46306aec45a7Smrg char tmp[LT_PATHMAX + 1]; 46316aec45a7Smrg int tmp_len; 46326aec45a7Smrg char *concat_name; 46335c42550eSmrg 46346aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 46356aec45a7Smrg nonempty (wrapper)); 46365c42550eSmrg 46376aec45a7Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 46386aec45a7Smrg return NULL; 4639ab47cfaaSmrg 46406aec45a7Smrg /* Absolute path? */ 46416aec45a7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 46426aec45a7Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 46436aec45a7Smrg { 46446aec45a7Smrg concat_name = xstrdup (wrapper); 46456aec45a7Smrg if (check_executable (concat_name)) 46466aec45a7Smrg return concat_name; 46476aec45a7Smrg XFREE (concat_name); 46486aec45a7Smrg } 46496aec45a7Smrg else 46506aec45a7Smrg { 46516aec45a7Smrg#endif 46526aec45a7Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 46536aec45a7Smrg { 46546aec45a7Smrg concat_name = xstrdup (wrapper); 46556aec45a7Smrg if (check_executable (concat_name)) 46566aec45a7Smrg return concat_name; 46576aec45a7Smrg XFREE (concat_name); 46586aec45a7Smrg } 46596aec45a7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 46606aec45a7Smrg } 46616aec45a7Smrg#endif 4662ab47cfaaSmrg 46636aec45a7Smrg for (p = wrapper; *p; p++) 46646aec45a7Smrg if (*p == '/') 46656aec45a7Smrg { 46666aec45a7Smrg has_slash = 1; 46676aec45a7Smrg break; 46686aec45a7Smrg } 46696aec45a7Smrg if (!has_slash) 46706aec45a7Smrg { 46716aec45a7Smrg /* no slashes; search PATH */ 46726aec45a7Smrg const char *path = getenv ("PATH"); 46736aec45a7Smrg if (path != NULL) 46746aec45a7Smrg { 46756aec45a7Smrg for (p = path; *p; p = p_next) 46766aec45a7Smrg { 46776aec45a7Smrg const char *q; 46786aec45a7Smrg size_t p_len; 46796aec45a7Smrg for (q = p; *q; q++) 46806aec45a7Smrg if (IS_PATH_SEPARATOR (*q)) 46816aec45a7Smrg break; 46826aec45a7Smrg p_len = q - p; 46836aec45a7Smrg p_next = (*q == '\0' ? q : q + 1); 46846aec45a7Smrg if (p_len == 0) 46856aec45a7Smrg { 46866aec45a7Smrg /* empty path: current directory */ 46876aec45a7Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 46886aec45a7Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 46896aec45a7Smrg nonnull (strerror (errno))); 46906aec45a7Smrg tmp_len = strlen (tmp); 46916aec45a7Smrg concat_name = 46926aec45a7Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 46936aec45a7Smrg memcpy (concat_name, tmp, tmp_len); 46946aec45a7Smrg concat_name[tmp_len] = '/'; 46956aec45a7Smrg strcpy (concat_name + tmp_len + 1, wrapper); 46966aec45a7Smrg } 46976aec45a7Smrg else 46986aec45a7Smrg { 46996aec45a7Smrg concat_name = 47006aec45a7Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 47016aec45a7Smrg memcpy (concat_name, p, p_len); 47026aec45a7Smrg concat_name[p_len] = '/'; 47036aec45a7Smrg strcpy (concat_name + p_len + 1, wrapper); 47046aec45a7Smrg } 47056aec45a7Smrg if (check_executable (concat_name)) 47066aec45a7Smrg return concat_name; 47076aec45a7Smrg XFREE (concat_name); 47086aec45a7Smrg } 47096aec45a7Smrg } 47106aec45a7Smrg /* not found in PATH; assume curdir */ 47116aec45a7Smrg } 47126aec45a7Smrg /* Relative path | not found in path: prepend cwd */ 47136aec45a7Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 47146aec45a7Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 47156aec45a7Smrg nonnull (strerror (errno))); 47166aec45a7Smrg tmp_len = strlen (tmp); 47176aec45a7Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 47186aec45a7Smrg memcpy (concat_name, tmp, tmp_len); 47196aec45a7Smrg concat_name[tmp_len] = '/'; 47206aec45a7Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4721ab47cfaaSmrg 47226aec45a7Smrg if (check_executable (concat_name)) 47236aec45a7Smrg return concat_name; 47246aec45a7Smrg XFREE (concat_name); 47256aec45a7Smrg return NULL; 47266aec45a7Smrg} 47275c42550eSmrg 47286aec45a7Smrgchar * 47296aec45a7Smrgchase_symlinks (const char *pathspec) 47306aec45a7Smrg{ 47316aec45a7Smrg#ifndef S_ISLNK 47326aec45a7Smrg return xstrdup (pathspec); 47336aec45a7Smrg#else 47346aec45a7Smrg char buf[LT_PATHMAX]; 47356aec45a7Smrg struct stat s; 47366aec45a7Smrg char *tmp_pathspec = xstrdup (pathspec); 47376aec45a7Smrg char *p; 47386aec45a7Smrg int has_symlinks = 0; 47396aec45a7Smrg while (strlen (tmp_pathspec) && !has_symlinks) 47406aec45a7Smrg { 47416aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, 47426aec45a7Smrg "checking path component for symlinks: %s\n", 47436aec45a7Smrg tmp_pathspec); 47446aec45a7Smrg if (lstat (tmp_pathspec, &s) == 0) 47456aec45a7Smrg { 47466aec45a7Smrg if (S_ISLNK (s.st_mode) != 0) 47476aec45a7Smrg { 47486aec45a7Smrg has_symlinks = 1; 47496aec45a7Smrg break; 47506aec45a7Smrg } 47515c42550eSmrg 47526aec45a7Smrg /* search backwards for last DIR_SEPARATOR */ 47536aec45a7Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 47546aec45a7Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 47556aec45a7Smrg p--; 47566aec45a7Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 47576aec45a7Smrg { 47586aec45a7Smrg /* no more DIR_SEPARATORS left */ 47596aec45a7Smrg break; 47606aec45a7Smrg } 47616aec45a7Smrg *p = '\0'; 47626aec45a7Smrg } 47636aec45a7Smrg else 47646aec45a7Smrg { 47656aec45a7Smrg lt_fatal (__FILE__, __LINE__, 47666aec45a7Smrg "error accessing file \"%s\": %s", 47676aec45a7Smrg tmp_pathspec, nonnull (strerror (errno))); 47686aec45a7Smrg } 47696aec45a7Smrg } 47706aec45a7Smrg XFREE (tmp_pathspec); 47715c42550eSmrg 47726aec45a7Smrg if (!has_symlinks) 47736aec45a7Smrg { 47746aec45a7Smrg return xstrdup (pathspec); 47756aec45a7Smrg } 47765c42550eSmrg 47776aec45a7Smrg tmp_pathspec = realpath (pathspec, buf); 47786aec45a7Smrg if (tmp_pathspec == 0) 47796aec45a7Smrg { 47806aec45a7Smrg lt_fatal (__FILE__, __LINE__, 47816aec45a7Smrg "could not follow symlinks for %s", pathspec); 47826aec45a7Smrg } 47836aec45a7Smrg return xstrdup (tmp_pathspec); 47846aec45a7Smrg#endif 47856aec45a7Smrg} 4786ab47cfaaSmrg 47876aec45a7Smrgchar * 47886aec45a7Smrgstrendzap (char *str, const char *pat) 47896aec45a7Smrg{ 47906aec45a7Smrg size_t len, patlen; 4791ab47cfaaSmrg 47926aec45a7Smrg assert (str != NULL); 47936aec45a7Smrg assert (pat != NULL); 4794ab47cfaaSmrg 47956aec45a7Smrg len = strlen (str); 47966aec45a7Smrg patlen = strlen (pat); 4797ab47cfaaSmrg 47986aec45a7Smrg if (patlen <= len) 47996aec45a7Smrg { 48006aec45a7Smrg str += len - patlen; 48016aec45a7Smrg if (strcmp (str, pat) == 0) 48026aec45a7Smrg *str = '\0'; 48036aec45a7Smrg } 48046aec45a7Smrg return str; 48056aec45a7Smrg} 4806ab47cfaaSmrg 48076aec45a7Smrgvoid 48086aec45a7Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 48096aec45a7Smrg{ 48106aec45a7Smrg va_list args; 48116aec45a7Smrg if (lt_debug) 48126aec45a7Smrg { 48136aec45a7Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 48146aec45a7Smrg va_start (args, fmt); 48156aec45a7Smrg (void) vfprintf (stderr, fmt, args); 48166aec45a7Smrg va_end (args); 48176aec45a7Smrg } 48186aec45a7Smrg} 4819ab47cfaaSmrg 48206aec45a7Smrgstatic void 48216aec45a7Smrglt_error_core (int exit_status, const char *file, 48226aec45a7Smrg int line, const char *mode, 48236aec45a7Smrg const char *message, va_list ap) 48246aec45a7Smrg{ 48256aec45a7Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 48266aec45a7Smrg vfprintf (stderr, message, ap); 48276aec45a7Smrg fprintf (stderr, ".\n"); 4828ab47cfaaSmrg 48296aec45a7Smrg if (exit_status >= 0) 48306aec45a7Smrg exit (exit_status); 48316aec45a7Smrg} 4832ab47cfaaSmrg 48336aec45a7Smrgvoid 48346aec45a7Smrglt_fatal (const char *file, int line, const char *message, ...) 48356aec45a7Smrg{ 48366aec45a7Smrg va_list ap; 48376aec45a7Smrg va_start (ap, message); 48386aec45a7Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 48396aec45a7Smrg va_end (ap); 48406aec45a7Smrg} 4841ab47cfaaSmrg 48426aec45a7Smrgstatic const char * 48436aec45a7Smrgnonnull (const char *s) 48446aec45a7Smrg{ 48456aec45a7Smrg return s ? s : "(null)"; 48466aec45a7Smrg} 4847ab47cfaaSmrg 48486aec45a7Smrgstatic const char * 48496aec45a7Smrgnonempty (const char *s) 48506aec45a7Smrg{ 48516aec45a7Smrg return (s && !*s) ? "(empty)" : nonnull (s); 48526aec45a7Smrg} 4853ab47cfaaSmrg 48546aec45a7Smrgvoid 48556aec45a7Smrglt_setenv (const char *name, const char *value) 48566aec45a7Smrg{ 48576aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, 48586aec45a7Smrg "(lt_setenv) setting '%s' to '%s'\n", 48596aec45a7Smrg nonnull (name), nonnull (value)); 48606aec45a7Smrg { 48616aec45a7Smrg#ifdef HAVE_SETENV 48626aec45a7Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 48636aec45a7Smrg char *str = xstrdup (value); 48646aec45a7Smrg setenv (name, str, 1); 48656aec45a7Smrg#else 48666aec45a7Smrg int len = strlen (name) + 1 + strlen (value) + 1; 48676aec45a7Smrg char *str = XMALLOC (char, len); 48686aec45a7Smrg sprintf (str, "%s=%s", name, value); 48696aec45a7Smrg if (putenv (str) != EXIT_SUCCESS) 48706aec45a7Smrg { 48716aec45a7Smrg XFREE (str); 48726aec45a7Smrg } 48736aec45a7Smrg#endif 48746aec45a7Smrg } 48756aec45a7Smrg} 4876ab47cfaaSmrg 48776aec45a7Smrgchar * 48786aec45a7Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 48796aec45a7Smrg{ 48806aec45a7Smrg char *new_value; 48816aec45a7Smrg if (orig_value && *orig_value) 48826aec45a7Smrg { 48836aec45a7Smrg int orig_value_len = strlen (orig_value); 48846aec45a7Smrg int add_len = strlen (add); 48856aec45a7Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 48866aec45a7Smrg if (to_end) 48876aec45a7Smrg { 48886aec45a7Smrg strcpy (new_value, orig_value); 48896aec45a7Smrg strcpy (new_value + orig_value_len, add); 48906aec45a7Smrg } 48916aec45a7Smrg else 48926aec45a7Smrg { 48936aec45a7Smrg strcpy (new_value, add); 48946aec45a7Smrg strcpy (new_value + add_len, orig_value); 48956aec45a7Smrg } 48966aec45a7Smrg } 48976aec45a7Smrg else 48986aec45a7Smrg { 48996aec45a7Smrg new_value = xstrdup (add); 49006aec45a7Smrg } 49016aec45a7Smrg return new_value; 49026aec45a7Smrg} 4903ab47cfaaSmrg 49046aec45a7Smrgvoid 49056aec45a7Smrglt_update_exe_path (const char *name, const char *value) 49066aec45a7Smrg{ 49076aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, 49086aec45a7Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 49096aec45a7Smrg nonnull (name), nonnull (value)); 4910ab47cfaaSmrg 49116aec45a7Smrg if (name && *name && value && *value) 49126aec45a7Smrg { 49136aec45a7Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 49146aec45a7Smrg /* some systems can't cope with a ':'-terminated path #' */ 49156aec45a7Smrg int len = strlen (new_value); 49166aec45a7Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 49176aec45a7Smrg { 49186aec45a7Smrg new_value[len-1] = '\0'; 49196aec45a7Smrg } 49206aec45a7Smrg lt_setenv (name, new_value); 49216aec45a7Smrg XFREE (new_value); 49226aec45a7Smrg } 49236aec45a7Smrg} 4924ab47cfaaSmrg 49256aec45a7Smrgvoid 49266aec45a7Smrglt_update_lib_path (const char *name, const char *value) 49276aec45a7Smrg{ 49286aec45a7Smrg lt_debugprintf (__FILE__, __LINE__, 49296aec45a7Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 49306aec45a7Smrg nonnull (name), nonnull (value)); 4931ab47cfaaSmrg 49326aec45a7Smrg if (name && *name && value && *value) 49336aec45a7Smrg { 49346aec45a7Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 49356aec45a7Smrg lt_setenv (name, new_value); 49366aec45a7Smrg XFREE (new_value); 49376aec45a7Smrg } 49386aec45a7Smrg} 4939ab47cfaaSmrg 49406aec45a7SmrgEOF 49416aec45a7Smrg case $host_os in 49426aec45a7Smrg mingw*) 49436aec45a7Smrg cat <<"EOF" 49446aec45a7Smrg 49456aec45a7Smrg/* Prepares an argument vector before calling spawn(). 49466aec45a7Smrg Note that spawn() does not by itself call the command interpreter 49476aec45a7Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 49486aec45a7Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 49496aec45a7Smrg GetVersionEx(&v); 49506aec45a7Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 49516aec45a7Smrg }) ? "cmd.exe" : "command.com"). 49526aec45a7Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 49536aec45a7Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 49546aec45a7Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 49556aec45a7Smrg special way: 49566aec45a7Smrg - Space and tab are interpreted as delimiters. They are not treated as 49576aec45a7Smrg delimiters if they are surrounded by double quotes: "...". 49586aec45a7Smrg - Unescaped double quotes are removed from the input. Their only effect is 49596aec45a7Smrg that within double quotes, space and tab are treated like normal 49606aec45a7Smrg characters. 49616aec45a7Smrg - Backslashes not followed by double quotes are not special. 49626aec45a7Smrg - But 2*n+1 backslashes followed by a double quote become 49636aec45a7Smrg n backslashes followed by a double quote (n >= 0): 49646aec45a7Smrg \" -> " 49656aec45a7Smrg \\\" -> \" 49666aec45a7Smrg \\\\\" -> \\" 49676aec45a7Smrg */ 49686aec45a7Smrg#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" 49696aec45a7Smrg#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" 49706aec45a7Smrgchar ** 49716aec45a7Smrgprepare_spawn (char **argv) 49726aec45a7Smrg{ 49736aec45a7Smrg size_t argc; 49746aec45a7Smrg char **new_argv; 49756aec45a7Smrg size_t i; 4976ab47cfaaSmrg 49776aec45a7Smrg /* Count number of arguments. */ 49786aec45a7Smrg for (argc = 0; argv[argc] != NULL; argc++) 49796aec45a7Smrg ; 4980ab47cfaaSmrg 49816aec45a7Smrg /* Allocate new argument vector. */ 49826aec45a7Smrg new_argv = XMALLOC (char *, argc + 1); 4983ab47cfaaSmrg 49846aec45a7Smrg /* Put quoted arguments into the new argument vector. */ 49856aec45a7Smrg for (i = 0; i < argc; i++) 49866aec45a7Smrg { 49876aec45a7Smrg const char *string = argv[i]; 49886aec45a7Smrg 49896aec45a7Smrg if (string[0] == '\0') 49906aec45a7Smrg new_argv[i] = xstrdup ("\"\""); 49916aec45a7Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 49926aec45a7Smrg { 49936aec45a7Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 49946aec45a7Smrg size_t length; 49956aec45a7Smrg unsigned int backslashes; 49966aec45a7Smrg const char *s; 49976aec45a7Smrg char *quoted_string; 49986aec45a7Smrg char *p; 49996aec45a7Smrg 50006aec45a7Smrg length = 0; 50016aec45a7Smrg backslashes = 0; 50026aec45a7Smrg if (quote_around) 50036aec45a7Smrg length++; 50046aec45a7Smrg for (s = string; *s != '\0'; s++) 50056aec45a7Smrg { 50066aec45a7Smrg char c = *s; 50076aec45a7Smrg if (c == '"') 50086aec45a7Smrg length += backslashes + 1; 50096aec45a7Smrg length++; 50106aec45a7Smrg if (c == '\\') 50116aec45a7Smrg backslashes++; 50126aec45a7Smrg else 50136aec45a7Smrg backslashes = 0; 50146aec45a7Smrg } 50156aec45a7Smrg if (quote_around) 50166aec45a7Smrg length += backslashes + 1; 50176aec45a7Smrg 50186aec45a7Smrg quoted_string = XMALLOC (char, length + 1); 50196aec45a7Smrg 50206aec45a7Smrg p = quoted_string; 50216aec45a7Smrg backslashes = 0; 50226aec45a7Smrg if (quote_around) 50236aec45a7Smrg *p++ = '"'; 50246aec45a7Smrg for (s = string; *s != '\0'; s++) 50256aec45a7Smrg { 50266aec45a7Smrg char c = *s; 50276aec45a7Smrg if (c == '"') 50286aec45a7Smrg { 50296aec45a7Smrg unsigned int j; 50306aec45a7Smrg for (j = backslashes + 1; j > 0; j--) 50316aec45a7Smrg *p++ = '\\'; 50326aec45a7Smrg } 50336aec45a7Smrg *p++ = c; 50346aec45a7Smrg if (c == '\\') 50356aec45a7Smrg backslashes++; 50366aec45a7Smrg else 50376aec45a7Smrg backslashes = 0; 50386aec45a7Smrg } 50396aec45a7Smrg if (quote_around) 50406aec45a7Smrg { 50416aec45a7Smrg unsigned int j; 50426aec45a7Smrg for (j = backslashes; j > 0; j--) 50436aec45a7Smrg *p++ = '\\'; 50446aec45a7Smrg *p++ = '"'; 50456aec45a7Smrg } 50466aec45a7Smrg *p = '\0'; 5047ab47cfaaSmrg 50486aec45a7Smrg new_argv[i] = quoted_string; 50496aec45a7Smrg } 50506aec45a7Smrg else 50516aec45a7Smrg new_argv[i] = (char *) string; 50526aec45a7Smrg } 50536aec45a7Smrg new_argv[argc] = NULL; 5054ab47cfaaSmrg 50556aec45a7Smrg return new_argv; 50566aec45a7Smrg} 50576aec45a7SmrgEOF 50585c42550eSmrg ;; 50596aec45a7Smrg esac 5060ab47cfaaSmrg 50616aec45a7Smrg cat <<"EOF" 50626aec45a7Smrgvoid lt_dump_script (FILE* f) 50636aec45a7Smrg{ 50646aec45a7SmrgEOF 50656aec45a7Smrg func_emit_wrapper yes | 5066aa9e3350Smrg $SED -n -e ' 5067aa9e3350Smrgs/^\(.\{79\}\)\(..*\)/\1\ 5068aa9e3350Smrg\2/ 5069aa9e3350Smrgh 5070aa9e3350Smrgs/\([\\"]\)/\\\1/g 5071aa9e3350Smrgs/$/\\n/ 5072aa9e3350Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 5073aa9e3350Smrgg 5074aa9e3350SmrgD' 50756aec45a7Smrg cat <<"EOF" 50766aec45a7Smrg} 50776aec45a7SmrgEOF 50786aec45a7Smrg} 50796aec45a7Smrg# end: func_emit_cwrapperexe_src 5080ab47cfaaSmrg 50816aec45a7Smrg# func_win32_import_lib_p ARG 50826aec45a7Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 50836aec45a7Smrgfunc_win32_import_lib_p () 50846aec45a7Smrg{ 50856aec45a7Smrg $opt_debug 50866aec45a7Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 50876aec45a7Smrg *import*) : ;; 50886aec45a7Smrg *) false ;; 50896aec45a7Smrg esac 50906aec45a7Smrg} 5091ab47cfaaSmrg 50926aec45a7Smrg# func_mode_link arg... 50936aec45a7Smrgfunc_mode_link () 50946aec45a7Smrg{ 50956aec45a7Smrg $opt_debug 50966aec45a7Smrg case $host in 50976aec45a7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 50986aec45a7Smrg # It is impossible to link a dll without this setting, and 50996aec45a7Smrg # we shouldn't force the makefile maintainer to figure out 51006aec45a7Smrg # which system we are compiling for in order to pass an extra 51016aec45a7Smrg # flag for every libtool invocation. 51026aec45a7Smrg # allow_undefined=no 5103ab47cfaaSmrg 51046aec45a7Smrg # FIXME: Unfortunately, there are problems with the above when trying 51056aec45a7Smrg # to make a dll which has undefined symbols, in which case not 51066aec45a7Smrg # even a static library is built. For now, we need to specify 51076aec45a7Smrg # -no-undefined on the libtool link line when we can be certain 51086aec45a7Smrg # that all symbols are satisfied, otherwise we get a static library. 51096aec45a7Smrg allow_undefined=yes 51106aec45a7Smrg ;; 51116aec45a7Smrg *) 51126aec45a7Smrg allow_undefined=yes 51136aec45a7Smrg ;; 51146aec45a7Smrg esac 51156aec45a7Smrg libtool_args=$nonopt 51166aec45a7Smrg base_compile="$nonopt $@" 51176aec45a7Smrg compile_command=$nonopt 51186aec45a7Smrg finalize_command=$nonopt 5119ab47cfaaSmrg 51206aec45a7Smrg compile_rpath= 51216aec45a7Smrg finalize_rpath= 51226aec45a7Smrg compile_shlibpath= 51236aec45a7Smrg finalize_shlibpath= 51246aec45a7Smrg convenience= 51256aec45a7Smrg old_convenience= 51266aec45a7Smrg deplibs= 51276aec45a7Smrg old_deplibs= 51286aec45a7Smrg compiler_flags= 51296aec45a7Smrg linker_flags= 51306aec45a7Smrg dllsearchpath= 51316aec45a7Smrg lib_search_path=`pwd` 51326aec45a7Smrg inst_prefix_dir= 51336aec45a7Smrg new_inherited_linker_flags= 5134ab47cfaaSmrg 51356aec45a7Smrg avoid_version=no 51366aec45a7Smrg bindir= 51376aec45a7Smrg dlfiles= 51386aec45a7Smrg dlprefiles= 51396aec45a7Smrg dlself=no 51406aec45a7Smrg export_dynamic=no 51416aec45a7Smrg export_symbols= 51426aec45a7Smrg export_symbols_regex= 51436aec45a7Smrg generated= 51446aec45a7Smrg libobjs= 51456aec45a7Smrg ltlibs= 51466aec45a7Smrg module=no 51476aec45a7Smrg no_install=no 51486aec45a7Smrg objs= 51496aec45a7Smrg non_pic_objects= 51506aec45a7Smrg precious_files_regex= 51516aec45a7Smrg prefer_static_libs=no 51526aec45a7Smrg preload=no 51536aec45a7Smrg prev= 51546aec45a7Smrg prevarg= 51556aec45a7Smrg release= 51566aec45a7Smrg rpath= 51576aec45a7Smrg xrpath= 51586aec45a7Smrg perm_rpath= 51596aec45a7Smrg temp_rpath= 51606aec45a7Smrg thread_safe=no 51616aec45a7Smrg vinfo= 51626aec45a7Smrg vinfo_number=no 51636aec45a7Smrg weak_libs= 51646aec45a7Smrg single_module="${wl}-single_module" 51656aec45a7Smrg func_infer_tag $base_compile 5166ab47cfaaSmrg 51676aec45a7Smrg # We need to know -static, to get the right output filenames. 51686aec45a7Smrg for arg 51696aec45a7Smrg do 51706aec45a7Smrg case $arg in 51716aec45a7Smrg -shared) 51726aec45a7Smrg test "$build_libtool_libs" != yes && \ 51736aec45a7Smrg func_fatal_configuration "can not build a shared library" 51746aec45a7Smrg build_old_libs=no 51756aec45a7Smrg break 51766aec45a7Smrg ;; 51776aec45a7Smrg -all-static | -static | -static-libtool-libs) 51786aec45a7Smrg case $arg in 51796aec45a7Smrg -all-static) 51806aec45a7Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 51816aec45a7Smrg func_warning "complete static linking is impossible in this configuration" 51826aec45a7Smrg fi 51836aec45a7Smrg if test -n "$link_static_flag"; then 51846aec45a7Smrg dlopen_self=$dlopen_self_static 51856aec45a7Smrg fi 51866aec45a7Smrg prefer_static_libs=yes 51876aec45a7Smrg ;; 51886aec45a7Smrg -static) 51896aec45a7Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 51906aec45a7Smrg dlopen_self=$dlopen_self_static 51916aec45a7Smrg fi 51926aec45a7Smrg prefer_static_libs=built 51936aec45a7Smrg ;; 51946aec45a7Smrg -static-libtool-libs) 51956aec45a7Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 51966aec45a7Smrg dlopen_self=$dlopen_self_static 51976aec45a7Smrg fi 51986aec45a7Smrg prefer_static_libs=yes 51996aec45a7Smrg ;; 52006aec45a7Smrg esac 52016aec45a7Smrg build_libtool_libs=no 52026aec45a7Smrg build_old_libs=yes 52036aec45a7Smrg break 52046aec45a7Smrg ;; 52056aec45a7Smrg esac 52066aec45a7Smrg done 5207ab47cfaaSmrg 52086aec45a7Smrg # See if our shared archives depend on static archives. 52096aec45a7Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5210ab47cfaaSmrg 52116aec45a7Smrg # Go through the arguments, transforming them on the way. 52126aec45a7Smrg while test "$#" -gt 0; do 52136aec45a7Smrg arg="$1" 52146aec45a7Smrg shift 52156aec45a7Smrg func_quote_for_eval "$arg" 52166aec45a7Smrg qarg=$func_quote_for_eval_unquoted_result 52176aec45a7Smrg func_append libtool_args " $func_quote_for_eval_result" 5218ab47cfaaSmrg 52196aec45a7Smrg # If the previous option needs an argument, assign it. 52206aec45a7Smrg if test -n "$prev"; then 52216aec45a7Smrg case $prev in 52226aec45a7Smrg output) 52236aec45a7Smrg func_append compile_command " @OUTPUT@" 52246aec45a7Smrg func_append finalize_command " @OUTPUT@" 52256aec45a7Smrg ;; 52266aec45a7Smrg esac 5227ab47cfaaSmrg 52286aec45a7Smrg case $prev in 52296aec45a7Smrg bindir) 52306aec45a7Smrg bindir="$arg" 52316aec45a7Smrg prev= 52326aec45a7Smrg continue 52336aec45a7Smrg ;; 52346aec45a7Smrg dlfiles|dlprefiles) 52356aec45a7Smrg if test "$preload" = no; then 52366aec45a7Smrg # Add the symbol object into the linking commands. 52376aec45a7Smrg func_append compile_command " @SYMFILE@" 52386aec45a7Smrg func_append finalize_command " @SYMFILE@" 52396aec45a7Smrg preload=yes 52405c42550eSmrg fi 52416aec45a7Smrg case $arg in 52426aec45a7Smrg *.la | *.lo) ;; # We handle these cases below. 52436aec45a7Smrg force) 52446aec45a7Smrg if test "$dlself" = no; then 52456aec45a7Smrg dlself=needless 52466aec45a7Smrg export_dynamic=yes 52475c42550eSmrg fi 52486aec45a7Smrg prev= 52496aec45a7Smrg continue 52506aec45a7Smrg ;; 52516aec45a7Smrg self) 52526aec45a7Smrg if test "$prev" = dlprefiles; then 52536aec45a7Smrg dlself=yes 52546aec45a7Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 52556aec45a7Smrg dlself=yes 52565c42550eSmrg else 52576aec45a7Smrg dlself=needless 52586aec45a7Smrg export_dynamic=yes 52595c42550eSmrg fi 52606aec45a7Smrg prev= 52616aec45a7Smrg continue 52626aec45a7Smrg ;; 52636aec45a7Smrg *) 52646aec45a7Smrg if test "$prev" = dlfiles; then 5265aa9e3350Smrg func_append dlfiles " $arg" 52665c42550eSmrg else 5267aa9e3350Smrg func_append dlprefiles " $arg" 52685c42550eSmrg fi 52696aec45a7Smrg prev= 52706aec45a7Smrg continue 52716aec45a7Smrg ;; 52726aec45a7Smrg esac 52736aec45a7Smrg ;; 52746aec45a7Smrg expsyms) 52756aec45a7Smrg export_symbols="$arg" 52766aec45a7Smrg test -f "$arg" \ 52776aec45a7Smrg || func_fatal_error "symbol file \`$arg' does not exist" 52786aec45a7Smrg prev= 52796aec45a7Smrg continue 52806aec45a7Smrg ;; 52816aec45a7Smrg expsyms_regex) 52826aec45a7Smrg export_symbols_regex="$arg" 52836aec45a7Smrg prev= 52846aec45a7Smrg continue 52856aec45a7Smrg ;; 52866aec45a7Smrg framework) 52875c42550eSmrg case $host in 52886aec45a7Smrg *-*-darwin*) 52896aec45a7Smrg case "$deplibs " in 52906aec45a7Smrg *" $qarg.ltframework "*) ;; 5291aa9e3350Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 52926aec45a7Smrg ;; 52936aec45a7Smrg esac 52946aec45a7Smrg ;; 52955c42550eSmrg esac 52966aec45a7Smrg prev= 52976aec45a7Smrg continue 52985c42550eSmrg ;; 52996aec45a7Smrg inst_prefix) 53006aec45a7Smrg inst_prefix_dir="$arg" 53016aec45a7Smrg prev= 53026aec45a7Smrg continue 53035c42550eSmrg ;; 53046aec45a7Smrg objectlist) 53056aec45a7Smrg if test -f "$arg"; then 53066aec45a7Smrg save_arg=$arg 53076aec45a7Smrg moreargs= 53086aec45a7Smrg for fil in `cat "$save_arg"` 53096aec45a7Smrg do 5310aa9e3350Smrg# func_append moreargs " $fil" 53116aec45a7Smrg arg=$fil 53126aec45a7Smrg # A libtool-controlled object. 5313ab47cfaaSmrg 53146aec45a7Smrg # Check to see that this really is a libtool object. 53156aec45a7Smrg if func_lalib_unsafe_p "$arg"; then 53166aec45a7Smrg pic_object= 53176aec45a7Smrg non_pic_object= 5318ab47cfaaSmrg 53196aec45a7Smrg # Read the .lo file 53206aec45a7Smrg func_source "$arg" 5321ab47cfaaSmrg 53226aec45a7Smrg if test -z "$pic_object" || 53236aec45a7Smrg test -z "$non_pic_object" || 53246aec45a7Smrg test "$pic_object" = none && 53256aec45a7Smrg test "$non_pic_object" = none; then 53266aec45a7Smrg func_fatal_error "cannot find name of object for \`$arg'" 53276aec45a7Smrg fi 5328ab47cfaaSmrg 53296aec45a7Smrg # Extract subdirectory from the argument. 53306aec45a7Smrg func_dirname "$arg" "/" "" 53316aec45a7Smrg xdir="$func_dirname_result" 5332ab47cfaaSmrg 53336aec45a7Smrg if test "$pic_object" != none; then 53346aec45a7Smrg # Prepend the subdirectory the object is found in. 53356aec45a7Smrg pic_object="$xdir$pic_object" 5336ab47cfaaSmrg 53376aec45a7Smrg if test "$prev" = dlfiles; then 53386aec45a7Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5339aa9e3350Smrg func_append dlfiles " $pic_object" 53406aec45a7Smrg prev= 53416aec45a7Smrg continue 53426aec45a7Smrg else 53436aec45a7Smrg # If libtool objects are unsupported, then we need to preload. 53446aec45a7Smrg prev=dlprefiles 53456aec45a7Smrg fi 53466aec45a7Smrg fi 53478697ee19Smrg 53486aec45a7Smrg # CHECK ME: I think I busted this. -Ossama 53496aec45a7Smrg if test "$prev" = dlprefiles; then 53506aec45a7Smrg # Preload the old-style object. 5351aa9e3350Smrg func_append dlprefiles " $pic_object" 53526aec45a7Smrg prev= 53536aec45a7Smrg fi 5354ab47cfaaSmrg 53556aec45a7Smrg # A PIC object. 53566aec45a7Smrg func_append libobjs " $pic_object" 53576aec45a7Smrg arg="$pic_object" 53586aec45a7Smrg fi 53591473d951Smrg 53606aec45a7Smrg # Non-PIC object. 53616aec45a7Smrg if test "$non_pic_object" != none; then 53626aec45a7Smrg # Prepend the subdirectory the object is found in. 53636aec45a7Smrg non_pic_object="$xdir$non_pic_object" 53641473d951Smrg 53656aec45a7Smrg # A standard non-PIC object 53666aec45a7Smrg func_append non_pic_objects " $non_pic_object" 53676aec45a7Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 53686aec45a7Smrg arg="$non_pic_object" 53696aec45a7Smrg fi 53706aec45a7Smrg else 53716aec45a7Smrg # If the PIC object exists, use it instead. 53726aec45a7Smrg # $xdir was prepended to $pic_object above. 53736aec45a7Smrg non_pic_object="$pic_object" 53746aec45a7Smrg func_append non_pic_objects " $non_pic_object" 53756aec45a7Smrg fi 53766aec45a7Smrg else 53776aec45a7Smrg # Only an error if not doing a dry-run. 53786aec45a7Smrg if $opt_dry_run; then 53796aec45a7Smrg # Extract subdirectory from the argument. 53806aec45a7Smrg func_dirname "$arg" "/" "" 53816aec45a7Smrg xdir="$func_dirname_result" 53826aec45a7Smrg 53836aec45a7Smrg func_lo2o "$arg" 53846aec45a7Smrg pic_object=$xdir$objdir/$func_lo2o_result 53856aec45a7Smrg non_pic_object=$xdir$func_lo2o_result 53866aec45a7Smrg func_append libobjs " $pic_object" 53876aec45a7Smrg func_append non_pic_objects " $non_pic_object" 53886aec45a7Smrg else 53896aec45a7Smrg func_fatal_error "\`$arg' is not a valid libtool object" 53906aec45a7Smrg fi 53916aec45a7Smrg fi 53926aec45a7Smrg done 53935c42550eSmrg else 53946aec45a7Smrg func_fatal_error "link input file \`$arg' does not exist" 53955c42550eSmrg fi 53966aec45a7Smrg arg=$save_arg 53976aec45a7Smrg prev= 53986aec45a7Smrg continue 53996aec45a7Smrg ;; 54006aec45a7Smrg precious_regex) 54016aec45a7Smrg precious_files_regex="$arg" 54026aec45a7Smrg prev= 54036aec45a7Smrg continue 54046aec45a7Smrg ;; 54056aec45a7Smrg release) 54066aec45a7Smrg release="-$arg" 54076aec45a7Smrg prev= 54086aec45a7Smrg continue 54096aec45a7Smrg ;; 54106aec45a7Smrg rpath | xrpath) 54116aec45a7Smrg # We need an absolute path. 54126aec45a7Smrg case $arg in 54136aec45a7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 54146aec45a7Smrg *) 54156aec45a7Smrg func_fatal_error "only absolute run-paths are allowed" 54166aec45a7Smrg ;; 54176aec45a7Smrg esac 54186aec45a7Smrg if test "$prev" = rpath; then 54196aec45a7Smrg case "$rpath " in 54206aec45a7Smrg *" $arg "*) ;; 5421aa9e3350Smrg *) func_append rpath " $arg" ;; 54226aec45a7Smrg esac 54235c42550eSmrg else 54246aec45a7Smrg case "$xrpath " in 54256aec45a7Smrg *" $arg "*) ;; 5426aa9e3350Smrg *) func_append xrpath " $arg" ;; 54276aec45a7Smrg esac 54285c42550eSmrg fi 54296aec45a7Smrg prev= 54306aec45a7Smrg continue 54316aec45a7Smrg ;; 54326aec45a7Smrg shrext) 54336aec45a7Smrg shrext_cmds="$arg" 54346aec45a7Smrg prev= 54356aec45a7Smrg continue 54366aec45a7Smrg ;; 54376aec45a7Smrg weak) 5438aa9e3350Smrg func_append weak_libs " $arg" 54396aec45a7Smrg prev= 54406aec45a7Smrg continue 54416aec45a7Smrg ;; 54426aec45a7Smrg xcclinker) 5443aa9e3350Smrg func_append linker_flags " $qarg" 5444aa9e3350Smrg func_append compiler_flags " $qarg" 54456aec45a7Smrg prev= 54466aec45a7Smrg func_append compile_command " $qarg" 54476aec45a7Smrg func_append finalize_command " $qarg" 54486aec45a7Smrg continue 54496aec45a7Smrg ;; 54506aec45a7Smrg xcompiler) 5451aa9e3350Smrg func_append compiler_flags " $qarg" 54526aec45a7Smrg prev= 54536aec45a7Smrg func_append compile_command " $qarg" 54546aec45a7Smrg func_append finalize_command " $qarg" 54556aec45a7Smrg continue 54566aec45a7Smrg ;; 54576aec45a7Smrg xlinker) 5458aa9e3350Smrg func_append linker_flags " $qarg" 5459aa9e3350Smrg func_append compiler_flags " $wl$qarg" 54606aec45a7Smrg prev= 54616aec45a7Smrg func_append compile_command " $wl$qarg" 54626aec45a7Smrg func_append finalize_command " $wl$qarg" 54636aec45a7Smrg continue 54646aec45a7Smrg ;; 54656aec45a7Smrg *) 54666aec45a7Smrg eval "$prev=\"\$arg\"" 54676aec45a7Smrg prev= 54686aec45a7Smrg continue 54696aec45a7Smrg ;; 54701473d951Smrg esac 54716aec45a7Smrg fi # test -n "$prev" 54721473d951Smrg 54736aec45a7Smrg prevarg="$arg" 54741473d951Smrg 54756aec45a7Smrg case $arg in 54766aec45a7Smrg -all-static) 54776aec45a7Smrg if test -n "$link_static_flag"; then 54786aec45a7Smrg # See comment for -static flag below, for more details. 54796aec45a7Smrg func_append compile_command " $link_static_flag" 54806aec45a7Smrg func_append finalize_command " $link_static_flag" 54816aec45a7Smrg fi 54826aec45a7Smrg continue 54836aec45a7Smrg ;; 54841473d951Smrg 54856aec45a7Smrg -allow-undefined) 54866aec45a7Smrg # FIXME: remove this flag sometime in the future. 54876aec45a7Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 54886aec45a7Smrg ;; 54891473d951Smrg 54906aec45a7Smrg -avoid-version) 54916aec45a7Smrg avoid_version=yes 54926aec45a7Smrg continue 54936aec45a7Smrg ;; 54941473d951Smrg 54956aec45a7Smrg -bindir) 54966aec45a7Smrg prev=bindir 54976aec45a7Smrg continue 54986aec45a7Smrg ;; 54991473d951Smrg 55006aec45a7Smrg -dlopen) 55016aec45a7Smrg prev=dlfiles 55026aec45a7Smrg continue 55036aec45a7Smrg ;; 55041473d951Smrg 55056aec45a7Smrg -dlpreopen) 55066aec45a7Smrg prev=dlprefiles 55076aec45a7Smrg continue 55086aec45a7Smrg ;; 55091473d951Smrg 55106aec45a7Smrg -export-dynamic) 55116aec45a7Smrg export_dynamic=yes 55126aec45a7Smrg continue 55136aec45a7Smrg ;; 55141473d951Smrg 55156aec45a7Smrg -export-symbols | -export-symbols-regex) 55166aec45a7Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 55176aec45a7Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 55186aec45a7Smrg fi 55196aec45a7Smrg if test "X$arg" = "X-export-symbols"; then 55206aec45a7Smrg prev=expsyms 55216aec45a7Smrg else 55226aec45a7Smrg prev=expsyms_regex 55236aec45a7Smrg fi 55246aec45a7Smrg continue 55256aec45a7Smrg ;; 55261473d951Smrg 55276aec45a7Smrg -framework) 55286aec45a7Smrg prev=framework 55296aec45a7Smrg continue 55306aec45a7Smrg ;; 55311473d951Smrg 55326aec45a7Smrg -inst-prefix-dir) 55336aec45a7Smrg prev=inst_prefix 55346aec45a7Smrg continue 55356aec45a7Smrg ;; 55361473d951Smrg 55376aec45a7Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 55386aec45a7Smrg # so, if we see these flags be careful not to treat them like -L 55396aec45a7Smrg -L[A-Z][A-Z]*:*) 55406aec45a7Smrg case $with_gcc/$host in 55416aec45a7Smrg no/*-*-irix* | /*-*-irix*) 55426aec45a7Smrg func_append compile_command " $arg" 55436aec45a7Smrg func_append finalize_command " $arg" 55446aec45a7Smrg ;; 55456aec45a7Smrg esac 55466aec45a7Smrg continue 55476aec45a7Smrg ;; 55481473d951Smrg 55496aec45a7Smrg -L*) 5550aa9e3350Smrg func_stripname "-L" '' "$arg" 5551aa9e3350Smrg if test -z "$func_stripname_result"; then 55526aec45a7Smrg if test "$#" -gt 0; then 55536aec45a7Smrg func_fatal_error "require no space between \`-L' and \`$1'" 55546aec45a7Smrg else 55556aec45a7Smrg func_fatal_error "need path for \`-L' option" 55566aec45a7Smrg fi 55576aec45a7Smrg fi 5558aa9e3350Smrg func_resolve_sysroot "$func_stripname_result" 5559aa9e3350Smrg dir=$func_resolve_sysroot_result 55606aec45a7Smrg # We need an absolute path. 55616aec45a7Smrg case $dir in 55626aec45a7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 55636aec45a7Smrg *) 55646aec45a7Smrg absdir=`cd "$dir" && pwd` 55656aec45a7Smrg test -z "$absdir" && \ 55666aec45a7Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 55676aec45a7Smrg dir="$absdir" 55686aec45a7Smrg ;; 55696aec45a7Smrg esac 55706aec45a7Smrg case "$deplibs " in 5571aa9e3350Smrg *" -L$dir "* | *" $arg "*) 5572aa9e3350Smrg # Will only happen for absolute or sysroot arguments 5573aa9e3350Smrg ;; 55746aec45a7Smrg *) 5575aa9e3350Smrg # Preserve sysroot, but never include relative directories 5576aa9e3350Smrg case $dir in 5577aa9e3350Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 5578aa9e3350Smrg *) func_append deplibs " -L$dir" ;; 5579aa9e3350Smrg esac 5580aa9e3350Smrg func_append lib_search_path " $dir" 55816aec45a7Smrg ;; 55826aec45a7Smrg esac 55836aec45a7Smrg case $host in 55846aec45a7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 55856aec45a7Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 55866aec45a7Smrg case :$dllsearchpath: in 55876aec45a7Smrg *":$dir:"*) ;; 55886aec45a7Smrg ::) dllsearchpath=$dir;; 5589aa9e3350Smrg *) func_append dllsearchpath ":$dir";; 55906aec45a7Smrg esac 55916aec45a7Smrg case :$dllsearchpath: in 55926aec45a7Smrg *":$testbindir:"*) ;; 55936aec45a7Smrg ::) dllsearchpath=$testbindir;; 5594aa9e3350Smrg *) func_append dllsearchpath ":$testbindir";; 55956aec45a7Smrg esac 55966aec45a7Smrg ;; 55976aec45a7Smrg esac 55986aec45a7Smrg continue 55996aec45a7Smrg ;; 56001473d951Smrg 56016aec45a7Smrg -l*) 56026aec45a7Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 56036aec45a7Smrg case $host in 56046aec45a7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 56056aec45a7Smrg # These systems don't actually have a C or math library (as such) 56066aec45a7Smrg continue 56076aec45a7Smrg ;; 56086aec45a7Smrg *-*-os2*) 56096aec45a7Smrg # These systems don't actually have a C library (as such) 56106aec45a7Smrg test "X$arg" = "X-lc" && continue 56116aec45a7Smrg ;; 56126aec45a7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 56136aec45a7Smrg # Do not include libc due to us having libc/libc_r. 56146aec45a7Smrg test "X$arg" = "X-lc" && continue 56156aec45a7Smrg ;; 56166aec45a7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 56176aec45a7Smrg # Rhapsody C and math libraries are in the System framework 5618aa9e3350Smrg func_append deplibs " System.ltframework" 56196aec45a7Smrg continue 56206aec45a7Smrg ;; 56216aec45a7Smrg *-*-sco3.2v5* | *-*-sco5v6*) 56226aec45a7Smrg # Causes problems with __ctype 56236aec45a7Smrg test "X$arg" = "X-lc" && continue 56246aec45a7Smrg ;; 56256aec45a7Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 56266aec45a7Smrg # Compiler inserts libc in the correct place for threads to work 56276aec45a7Smrg test "X$arg" = "X-lc" && continue 56286aec45a7Smrg ;; 56296aec45a7Smrg esac 56306aec45a7Smrg elif test "X$arg" = "X-lc_r"; then 56316aec45a7Smrg case $host in 56326aec45a7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 56336aec45a7Smrg # Do not include libc_r directly, use -pthread flag. 56346aec45a7Smrg continue 56356aec45a7Smrg ;; 56366aec45a7Smrg esac 56376aec45a7Smrg fi 5638aa9e3350Smrg func_append deplibs " $arg" 56396aec45a7Smrg continue 56406aec45a7Smrg ;; 56411473d951Smrg 56426aec45a7Smrg -module) 56436aec45a7Smrg module=yes 56446aec45a7Smrg continue 56456aec45a7Smrg ;; 56461473d951Smrg 56476aec45a7Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 56486aec45a7Smrg # classes, name mangling, and exception handling. 56496aec45a7Smrg # Darwin uses the -arch flag to determine output architecture. 5650aa9e3350Smrg -model|-arch|-isysroot|--sysroot) 5651aa9e3350Smrg func_append compiler_flags " $arg" 56526aec45a7Smrg func_append compile_command " $arg" 56536aec45a7Smrg func_append finalize_command " $arg" 56546aec45a7Smrg prev=xcompiler 56556aec45a7Smrg continue 56566aec45a7Smrg ;; 56571473d951Smrg 5658aa9e3350Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 5659aa9e3350Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 5660aa9e3350Smrg func_append compiler_flags " $arg" 56616aec45a7Smrg func_append compile_command " $arg" 56626aec45a7Smrg func_append finalize_command " $arg" 56636aec45a7Smrg case "$new_inherited_linker_flags " in 56646aec45a7Smrg *" $arg "*) ;; 5665aa9e3350Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 56666aec45a7Smrg esac 56676aec45a7Smrg continue 56686aec45a7Smrg ;; 56691473d951Smrg 56706aec45a7Smrg -multi_module) 56716aec45a7Smrg single_module="${wl}-multi_module" 56726aec45a7Smrg continue 56736aec45a7Smrg ;; 56741473d951Smrg 56756aec45a7Smrg -no-fast-install) 56766aec45a7Smrg fast_install=no 56776aec45a7Smrg continue 56786aec45a7Smrg ;; 56791473d951Smrg 56806aec45a7Smrg -no-install) 56816aec45a7Smrg case $host in 56826aec45a7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 56836aec45a7Smrg # The PATH hackery in wrapper scripts is required on Windows 56846aec45a7Smrg # and Darwin in order for the loader to find any dlls it needs. 56856aec45a7Smrg func_warning "\`-no-install' is ignored for $host" 56866aec45a7Smrg func_warning "assuming \`-no-fast-install' instead" 56876aec45a7Smrg fast_install=no 56886aec45a7Smrg ;; 56896aec45a7Smrg *) no_install=yes ;; 56906aec45a7Smrg esac 56916aec45a7Smrg continue 56926aec45a7Smrg ;; 56931473d951Smrg 56946aec45a7Smrg -no-undefined) 56956aec45a7Smrg allow_undefined=no 56966aec45a7Smrg continue 56976aec45a7Smrg ;; 56981473d951Smrg 56996aec45a7Smrg -objectlist) 57006aec45a7Smrg prev=objectlist 57016aec45a7Smrg continue 57026aec45a7Smrg ;; 57031473d951Smrg 57046aec45a7Smrg -o) prev=output ;; 57051473d951Smrg 57066aec45a7Smrg -precious-files-regex) 57076aec45a7Smrg prev=precious_regex 57086aec45a7Smrg continue 57096aec45a7Smrg ;; 57101473d951Smrg 57116aec45a7Smrg -release) 57126aec45a7Smrg prev=release 57136aec45a7Smrg continue 57146aec45a7Smrg ;; 57151473d951Smrg 57166aec45a7Smrg -rpath) 57176aec45a7Smrg prev=rpath 57186aec45a7Smrg continue 57196aec45a7Smrg ;; 57201473d951Smrg 57216aec45a7Smrg -R) 57226aec45a7Smrg prev=xrpath 57236aec45a7Smrg continue 57246aec45a7Smrg ;; 57251473d951Smrg 57266aec45a7Smrg -R*) 57276aec45a7Smrg func_stripname '-R' '' "$arg" 57286aec45a7Smrg dir=$func_stripname_result 57296aec45a7Smrg # We need an absolute path. 57306aec45a7Smrg case $dir in 57316aec45a7Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5732aa9e3350Smrg =*) 5733aa9e3350Smrg func_stripname '=' '' "$dir" 5734aa9e3350Smrg dir=$lt_sysroot$func_stripname_result 5735aa9e3350Smrg ;; 57366aec45a7Smrg *) 57376aec45a7Smrg func_fatal_error "only absolute run-paths are allowed" 57386aec45a7Smrg ;; 57396aec45a7Smrg esac 57406aec45a7Smrg case "$xrpath " in 57416aec45a7Smrg *" $dir "*) ;; 5742aa9e3350Smrg *) func_append xrpath " $dir" ;; 57436aec45a7Smrg esac 57446aec45a7Smrg continue 57456aec45a7Smrg ;; 57461473d951Smrg 57476aec45a7Smrg -shared) 57486aec45a7Smrg # The effects of -shared are defined in a previous loop. 57496aec45a7Smrg continue 57506aec45a7Smrg ;; 57511473d951Smrg 57526aec45a7Smrg -shrext) 57536aec45a7Smrg prev=shrext 57546aec45a7Smrg continue 57556aec45a7Smrg ;; 57561473d951Smrg 57576aec45a7Smrg -static | -static-libtool-libs) 57586aec45a7Smrg # The effects of -static are defined in a previous loop. 57596aec45a7Smrg # We used to do the same as -all-static on platforms that 57606aec45a7Smrg # didn't have a PIC flag, but the assumption that the effects 57616aec45a7Smrg # would be equivalent was wrong. It would break on at least 57626aec45a7Smrg # Digital Unix and AIX. 57636aec45a7Smrg continue 57646aec45a7Smrg ;; 57651473d951Smrg 57666aec45a7Smrg -thread-safe) 57676aec45a7Smrg thread_safe=yes 57686aec45a7Smrg continue 57696aec45a7Smrg ;; 57701473d951Smrg 57716aec45a7Smrg -version-info) 57726aec45a7Smrg prev=vinfo 57736aec45a7Smrg continue 57746aec45a7Smrg ;; 57751473d951Smrg 57766aec45a7Smrg -version-number) 57776aec45a7Smrg prev=vinfo 57786aec45a7Smrg vinfo_number=yes 57796aec45a7Smrg continue 57806aec45a7Smrg ;; 5781ab47cfaaSmrg 57826aec45a7Smrg -weak) 57836aec45a7Smrg prev=weak 57846aec45a7Smrg continue 57856aec45a7Smrg ;; 57865c42550eSmrg 57876aec45a7Smrg -Wc,*) 57886aec45a7Smrg func_stripname '-Wc,' '' "$arg" 57896aec45a7Smrg args=$func_stripname_result 57906aec45a7Smrg arg= 57916aec45a7Smrg save_ifs="$IFS"; IFS=',' 57926aec45a7Smrg for flag in $args; do 57936aec45a7Smrg IFS="$save_ifs" 57946aec45a7Smrg func_quote_for_eval "$flag" 5795aa9e3350Smrg func_append arg " $func_quote_for_eval_result" 5796aa9e3350Smrg func_append compiler_flags " $func_quote_for_eval_result" 57976aec45a7Smrg done 57986aec45a7Smrg IFS="$save_ifs" 57996aec45a7Smrg func_stripname ' ' '' "$arg" 58006aec45a7Smrg arg=$func_stripname_result 58016aec45a7Smrg ;; 58025c42550eSmrg 58036aec45a7Smrg -Wl,*) 58046aec45a7Smrg func_stripname '-Wl,' '' "$arg" 58056aec45a7Smrg args=$func_stripname_result 58066aec45a7Smrg arg= 58076aec45a7Smrg save_ifs="$IFS"; IFS=',' 58086aec45a7Smrg for flag in $args; do 58096aec45a7Smrg IFS="$save_ifs" 58106aec45a7Smrg func_quote_for_eval "$flag" 5811aa9e3350Smrg func_append arg " $wl$func_quote_for_eval_result" 5812aa9e3350Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 5813aa9e3350Smrg func_append linker_flags " $func_quote_for_eval_result" 58146aec45a7Smrg done 58156aec45a7Smrg IFS="$save_ifs" 58166aec45a7Smrg func_stripname ' ' '' "$arg" 58176aec45a7Smrg arg=$func_stripname_result 58186aec45a7Smrg ;; 58195c42550eSmrg 58206aec45a7Smrg -Xcompiler) 58216aec45a7Smrg prev=xcompiler 58226aec45a7Smrg continue 58236aec45a7Smrg ;; 58245c42550eSmrg 58256aec45a7Smrg -Xlinker) 58266aec45a7Smrg prev=xlinker 58276aec45a7Smrg continue 58286aec45a7Smrg ;; 58295c42550eSmrg 58306aec45a7Smrg -XCClinker) 58316aec45a7Smrg prev=xcclinker 58326aec45a7Smrg continue 58336aec45a7Smrg ;; 58345c42550eSmrg 58356aec45a7Smrg # -msg_* for osf cc 58366aec45a7Smrg -msg_*) 58376aec45a7Smrg func_quote_for_eval "$arg" 58386aec45a7Smrg arg="$func_quote_for_eval_result" 58396aec45a7Smrg ;; 58405c42550eSmrg 58416aec45a7Smrg # Flags to be passed through unchanged, with rationale: 58426aec45a7Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 58436aec45a7Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 58446aec45a7Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 58456aec45a7Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 58466aec45a7Smrg # -q* compiler args for the IBM compiler 58476aec45a7Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 58486aec45a7Smrg # -F/path path to uninstalled frameworks, gcc on darwin 58496aec45a7Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 58506aec45a7Smrg # @file GCC response files 58516aec45a7Smrg # -tp=* Portland pgcc target processor selection 5852aa9e3350Smrg # --sysroot=* for sysroot support 5853aa9e3350Smrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 58546aec45a7Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 5855aa9e3350Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 5856aa9e3350Smrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 58576aec45a7Smrg func_quote_for_eval "$arg" 58586aec45a7Smrg arg="$func_quote_for_eval_result" 58596aec45a7Smrg func_append compile_command " $arg" 58606aec45a7Smrg func_append finalize_command " $arg" 5861aa9e3350Smrg func_append compiler_flags " $arg" 58626aec45a7Smrg continue 58636aec45a7Smrg ;; 58645c42550eSmrg 58656aec45a7Smrg # Some other compiler flag. 58666aec45a7Smrg -* | +*) 58676aec45a7Smrg func_quote_for_eval "$arg" 58686aec45a7Smrg arg="$func_quote_for_eval_result" 58696aec45a7Smrg ;; 58705c42550eSmrg 58716aec45a7Smrg *.$objext) 58726aec45a7Smrg # A standard object. 5873aa9e3350Smrg func_append objs " $arg" 58746aec45a7Smrg ;; 58755c42550eSmrg 58766aec45a7Smrg *.lo) 58776aec45a7Smrg # A libtool-controlled object. 58785c42550eSmrg 58796aec45a7Smrg # Check to see that this really is a libtool object. 58806aec45a7Smrg if func_lalib_unsafe_p "$arg"; then 58816aec45a7Smrg pic_object= 58826aec45a7Smrg non_pic_object= 58835c42550eSmrg 58846aec45a7Smrg # Read the .lo file 58856aec45a7Smrg func_source "$arg" 58865c42550eSmrg 58876aec45a7Smrg if test -z "$pic_object" || 58886aec45a7Smrg test -z "$non_pic_object" || 58896aec45a7Smrg test "$pic_object" = none && 58906aec45a7Smrg test "$non_pic_object" = none; then 58916aec45a7Smrg func_fatal_error "cannot find name of object for \`$arg'" 58926aec45a7Smrg fi 58935c42550eSmrg 58946aec45a7Smrg # Extract subdirectory from the argument. 58956aec45a7Smrg func_dirname "$arg" "/" "" 58966aec45a7Smrg xdir="$func_dirname_result" 58975c42550eSmrg 58986aec45a7Smrg if test "$pic_object" != none; then 58996aec45a7Smrg # Prepend the subdirectory the object is found in. 59006aec45a7Smrg pic_object="$xdir$pic_object" 59015c42550eSmrg 59026aec45a7Smrg if test "$prev" = dlfiles; then 59036aec45a7Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5904aa9e3350Smrg func_append dlfiles " $pic_object" 59056aec45a7Smrg prev= 59066aec45a7Smrg continue 59076aec45a7Smrg else 59086aec45a7Smrg # If libtool objects are unsupported, then we need to preload. 59096aec45a7Smrg prev=dlprefiles 59106aec45a7Smrg fi 59116aec45a7Smrg fi 59126aec45a7Smrg 59136aec45a7Smrg # CHECK ME: I think I busted this. -Ossama 59146aec45a7Smrg if test "$prev" = dlprefiles; then 59156aec45a7Smrg # Preload the old-style object. 5916aa9e3350Smrg func_append dlprefiles " $pic_object" 59176aec45a7Smrg prev= 59186aec45a7Smrg fi 59196aec45a7Smrg 59206aec45a7Smrg # A PIC object. 59216aec45a7Smrg func_append libobjs " $pic_object" 59226aec45a7Smrg arg="$pic_object" 59236aec45a7Smrg fi 59246aec45a7Smrg 59256aec45a7Smrg # Non-PIC object. 59266aec45a7Smrg if test "$non_pic_object" != none; then 59276aec45a7Smrg # Prepend the subdirectory the object is found in. 59286aec45a7Smrg non_pic_object="$xdir$non_pic_object" 59296aec45a7Smrg 59306aec45a7Smrg # A standard non-PIC object 59316aec45a7Smrg func_append non_pic_objects " $non_pic_object" 59326aec45a7Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 59336aec45a7Smrg arg="$non_pic_object" 59346aec45a7Smrg fi 59356aec45a7Smrg else 59366aec45a7Smrg # If the PIC object exists, use it instead. 59376aec45a7Smrg # $xdir was prepended to $pic_object above. 59386aec45a7Smrg non_pic_object="$pic_object" 59396aec45a7Smrg func_append non_pic_objects " $non_pic_object" 59406aec45a7Smrg fi 59416aec45a7Smrg else 59426aec45a7Smrg # Only an error if not doing a dry-run. 59436aec45a7Smrg if $opt_dry_run; then 59446aec45a7Smrg # Extract subdirectory from the argument. 59456aec45a7Smrg func_dirname "$arg" "/" "" 59466aec45a7Smrg xdir="$func_dirname_result" 59476aec45a7Smrg 59486aec45a7Smrg func_lo2o "$arg" 59496aec45a7Smrg pic_object=$xdir$objdir/$func_lo2o_result 59506aec45a7Smrg non_pic_object=$xdir$func_lo2o_result 59516aec45a7Smrg func_append libobjs " $pic_object" 59526aec45a7Smrg func_append non_pic_objects " $non_pic_object" 59536aec45a7Smrg else 59546aec45a7Smrg func_fatal_error "\`$arg' is not a valid libtool object" 59556aec45a7Smrg fi 59566aec45a7Smrg fi 59576aec45a7Smrg ;; 59586aec45a7Smrg 59596aec45a7Smrg *.$libext) 59606aec45a7Smrg # An archive. 5961aa9e3350Smrg func_append deplibs " $arg" 5962aa9e3350Smrg func_append old_deplibs " $arg" 59636aec45a7Smrg continue 59646aec45a7Smrg ;; 59656aec45a7Smrg 59666aec45a7Smrg *.la) 59676aec45a7Smrg # A libtool-controlled library. 59686aec45a7Smrg 5969aa9e3350Smrg func_resolve_sysroot "$arg" 59706aec45a7Smrg if test "$prev" = dlfiles; then 59716aec45a7Smrg # This library was specified with -dlopen. 5972aa9e3350Smrg func_append dlfiles " $func_resolve_sysroot_result" 59736aec45a7Smrg prev= 59746aec45a7Smrg elif test "$prev" = dlprefiles; then 59756aec45a7Smrg # The library was specified with -dlpreopen. 5976aa9e3350Smrg func_append dlprefiles " $func_resolve_sysroot_result" 59776aec45a7Smrg prev= 59786aec45a7Smrg else 5979aa9e3350Smrg func_append deplibs " $func_resolve_sysroot_result" 59806aec45a7Smrg fi 59816aec45a7Smrg continue 59826aec45a7Smrg ;; 59836aec45a7Smrg 59846aec45a7Smrg # Some other compiler argument. 59856aec45a7Smrg *) 59866aec45a7Smrg # Unknown arguments in both finalize_command and compile_command need 59876aec45a7Smrg # to be aesthetically quoted because they are evaled later. 59886aec45a7Smrg func_quote_for_eval "$arg" 59896aec45a7Smrg arg="$func_quote_for_eval_result" 59906aec45a7Smrg ;; 59916aec45a7Smrg esac # arg 59926aec45a7Smrg 59936aec45a7Smrg # Now actually substitute the argument into the commands. 59946aec45a7Smrg if test -n "$arg"; then 59956aec45a7Smrg func_append compile_command " $arg" 59966aec45a7Smrg func_append finalize_command " $arg" 59976aec45a7Smrg fi 59986aec45a7Smrg done # argument parsing loop 59996aec45a7Smrg 60006aec45a7Smrg test -n "$prev" && \ 60016aec45a7Smrg func_fatal_help "the \`$prevarg' option requires an argument" 60026aec45a7Smrg 60036aec45a7Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 60046aec45a7Smrg eval arg=\"$export_dynamic_flag_spec\" 60056aec45a7Smrg func_append compile_command " $arg" 60066aec45a7Smrg func_append finalize_command " $arg" 60076aec45a7Smrg fi 60086aec45a7Smrg 60096aec45a7Smrg oldlibs= 60106aec45a7Smrg # calculate the name of the file, without its directory 60116aec45a7Smrg func_basename "$output" 60126aec45a7Smrg outputname="$func_basename_result" 60136aec45a7Smrg libobjs_save="$libobjs" 60146aec45a7Smrg 60156aec45a7Smrg if test -n "$shlibpath_var"; then 60166aec45a7Smrg # get the directories listed in $shlibpath_var 60176aec45a7Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 60185c42550eSmrg else 60196aec45a7Smrg shlib_search_path= 60205c42550eSmrg fi 60216aec45a7Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 60226aec45a7Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 6023ab47cfaaSmrg 60246aec45a7Smrg func_dirname "$output" "/" "" 60256aec45a7Smrg output_objdir="$func_dirname_result$objdir" 6026aa9e3350Smrg func_to_tool_file "$output_objdir/" 6027aa9e3350Smrg tool_output_objdir=$func_to_tool_file_result 60286aec45a7Smrg # Create the object directory. 60296aec45a7Smrg func_mkdir_p "$output_objdir" 6030ab47cfaaSmrg 60316aec45a7Smrg # Determine the type of output 60326aec45a7Smrg case $output in 60336aec45a7Smrg "") 60346aec45a7Smrg func_fatal_help "you must specify an output file" 60356aec45a7Smrg ;; 60366aec45a7Smrg *.$libext) linkmode=oldlib ;; 60376aec45a7Smrg *.lo | *.$objext) linkmode=obj ;; 60386aec45a7Smrg *.la) linkmode=lib ;; 60396aec45a7Smrg *) linkmode=prog ;; # Anything else should be a program. 60406aec45a7Smrg esac 60416aec45a7Smrg 60426aec45a7Smrg specialdeplibs= 60436aec45a7Smrg 60446aec45a7Smrg libs= 60456aec45a7Smrg # Find all interdependent deplibs by searching for libraries 60466aec45a7Smrg # that are linked more than once (e.g. -la -lb -la) 60476aec45a7Smrg for deplib in $deplibs; do 6048aa9e3350Smrg if $opt_preserve_dup_deps ; then 60496aec45a7Smrg case "$libs " in 6050aa9e3350Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 60516aec45a7Smrg esac 60526aec45a7Smrg fi 6053aa9e3350Smrg func_append libs " $deplib" 60546aec45a7Smrg done 60556aec45a7Smrg 60566aec45a7Smrg if test "$linkmode" = lib; then 60576aec45a7Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 60586aec45a7Smrg 60596aec45a7Smrg # Compute libraries that are listed more than once in $predeps 60606aec45a7Smrg # $postdeps and mark them as special (i.e., whose duplicates are 60616aec45a7Smrg # not to be eliminated). 60626aec45a7Smrg pre_post_deps= 60636aec45a7Smrg if $opt_duplicate_compiler_generated_deps; then 60646aec45a7Smrg for pre_post_dep in $predeps $postdeps; do 60656aec45a7Smrg case "$pre_post_deps " in 6066aa9e3350Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 60676aec45a7Smrg esac 6068aa9e3350Smrg func_append pre_post_deps " $pre_post_dep" 60696aec45a7Smrg done 60706aec45a7Smrg fi 60716aec45a7Smrg pre_post_deps= 60726aec45a7Smrg fi 60736aec45a7Smrg 60746aec45a7Smrg deplibs= 60756aec45a7Smrg newdependency_libs= 60766aec45a7Smrg newlib_search_path= 60776aec45a7Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 60786aec45a7Smrg notinst_deplibs= # not-installed libtool libraries 60796aec45a7Smrg notinst_path= # paths that contain not-installed libtool libraries 60806aec45a7Smrg 60816aec45a7Smrg case $linkmode in 60826aec45a7Smrg lib) 60836aec45a7Smrg passes="conv dlpreopen link" 60846aec45a7Smrg for file in $dlfiles $dlprefiles; do 60856aec45a7Smrg case $file in 60866aec45a7Smrg *.la) ;; 60876aec45a7Smrg *) 60886aec45a7Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 60896aec45a7Smrg ;; 60906aec45a7Smrg esac 60916aec45a7Smrg done 60926aec45a7Smrg ;; 60936aec45a7Smrg prog) 60946aec45a7Smrg compile_deplibs= 60956aec45a7Smrg finalize_deplibs= 60966aec45a7Smrg alldeplibs=no 60976aec45a7Smrg newdlfiles= 60986aec45a7Smrg newdlprefiles= 60996aec45a7Smrg passes="conv scan dlopen dlpreopen link" 61006aec45a7Smrg ;; 61016aec45a7Smrg *) passes="conv" 61026aec45a7Smrg ;; 61036aec45a7Smrg esac 61046aec45a7Smrg 61056aec45a7Smrg for pass in $passes; do 61066aec45a7Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 61076aec45a7Smrg # so that -L comes before libs that need it for instance... 61086aec45a7Smrg if test "$linkmode,$pass" = "lib,link"; then 61096aec45a7Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 61106aec45a7Smrg ## order, and fix it there properly 61116aec45a7Smrg tmp_deplibs= 61126aec45a7Smrg for deplib in $deplibs; do 61136aec45a7Smrg tmp_deplibs="$deplib $tmp_deplibs" 61146aec45a7Smrg done 61156aec45a7Smrg deplibs="$tmp_deplibs" 61166aec45a7Smrg fi 61176aec45a7Smrg 61186aec45a7Smrg if test "$linkmode,$pass" = "lib,link" || 61196aec45a7Smrg test "$linkmode,$pass" = "prog,scan"; then 61206aec45a7Smrg libs="$deplibs" 61216aec45a7Smrg deplibs= 61226aec45a7Smrg fi 61236aec45a7Smrg if test "$linkmode" = prog; then 61246aec45a7Smrg case $pass in 61256aec45a7Smrg dlopen) libs="$dlfiles" ;; 61266aec45a7Smrg dlpreopen) libs="$dlprefiles" ;; 61276aec45a7Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 61286aec45a7Smrg esac 61296aec45a7Smrg fi 61306aec45a7Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 61316aec45a7Smrg # Collect and forward deplibs of preopened libtool libs 61326aec45a7Smrg for lib in $dlprefiles; do 61336aec45a7Smrg # Ignore non-libtool-libs 61346aec45a7Smrg dependency_libs= 6135aa9e3350Smrg func_resolve_sysroot "$lib" 61366aec45a7Smrg case $lib in 6137aa9e3350Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 61386aec45a7Smrg esac 61396aec45a7Smrg 61406aec45a7Smrg # Collect preopened libtool deplibs, except any this library 61416aec45a7Smrg # has declared as weak libs 61426aec45a7Smrg for deplib in $dependency_libs; do 61436aec45a7Smrg func_basename "$deplib" 61446aec45a7Smrg deplib_base=$func_basename_result 61456aec45a7Smrg case " $weak_libs " in 61466aec45a7Smrg *" $deplib_base "*) ;; 6147aa9e3350Smrg *) func_append deplibs " $deplib" ;; 61486aec45a7Smrg esac 61496aec45a7Smrg done 61506aec45a7Smrg done 61516aec45a7Smrg libs="$dlprefiles" 61526aec45a7Smrg fi 61536aec45a7Smrg if test "$pass" = dlopen; then 61546aec45a7Smrg # Collect dlpreopened libraries 61556aec45a7Smrg save_deplibs="$deplibs" 61566aec45a7Smrg deplibs= 61576aec45a7Smrg fi 61586aec45a7Smrg 61596aec45a7Smrg for deplib in $libs; do 61606aec45a7Smrg lib= 61616aec45a7Smrg found=no 61626aec45a7Smrg case $deplib in 6163aa9e3350Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 6164aa9e3350Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 61656aec45a7Smrg if test "$linkmode,$pass" = "prog,link"; then 61666aec45a7Smrg compile_deplibs="$deplib $compile_deplibs" 61676aec45a7Smrg finalize_deplibs="$deplib $finalize_deplibs" 61686aec45a7Smrg else 6169aa9e3350Smrg func_append compiler_flags " $deplib" 61706aec45a7Smrg if test "$linkmode" = lib ; then 61716aec45a7Smrg case "$new_inherited_linker_flags " in 61726aec45a7Smrg *" $deplib "*) ;; 6173aa9e3350Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 61746aec45a7Smrg esac 61756aec45a7Smrg fi 61766aec45a7Smrg fi 61776aec45a7Smrg continue 61786aec45a7Smrg ;; 61796aec45a7Smrg -l*) 61806aec45a7Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 61816aec45a7Smrg func_warning "\`-l' is ignored for archives/objects" 61826aec45a7Smrg continue 61836aec45a7Smrg fi 61846aec45a7Smrg func_stripname '-l' '' "$deplib" 61856aec45a7Smrg name=$func_stripname_result 61866aec45a7Smrg if test "$linkmode" = lib; then 61876aec45a7Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 61886aec45a7Smrg else 61896aec45a7Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 61906aec45a7Smrg fi 61916aec45a7Smrg for searchdir in $searchdirs; do 61926aec45a7Smrg for search_ext in .la $std_shrext .so .a; do 61936aec45a7Smrg # Search the libtool library 61946aec45a7Smrg lib="$searchdir/lib${name}${search_ext}" 61956aec45a7Smrg if test -f "$lib"; then 61966aec45a7Smrg if test "$search_ext" = ".la"; then 61976aec45a7Smrg found=yes 61986aec45a7Smrg else 61996aec45a7Smrg found=no 62006aec45a7Smrg fi 62016aec45a7Smrg break 2 62026aec45a7Smrg fi 62036aec45a7Smrg done 62046aec45a7Smrg done 62056aec45a7Smrg if test "$found" != yes; then 62066aec45a7Smrg # deplib doesn't seem to be a libtool library 62076aec45a7Smrg if test "$linkmode,$pass" = "prog,link"; then 62086aec45a7Smrg compile_deplibs="$deplib $compile_deplibs" 62096aec45a7Smrg finalize_deplibs="$deplib $finalize_deplibs" 62106aec45a7Smrg else 62116aec45a7Smrg deplibs="$deplib $deplibs" 62126aec45a7Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 62136aec45a7Smrg fi 62146aec45a7Smrg continue 62156aec45a7Smrg else # deplib is a libtool library 62166aec45a7Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 62176aec45a7Smrg # We need to do some special things here, and not later. 62186aec45a7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 62196aec45a7Smrg case " $predeps $postdeps " in 62206aec45a7Smrg *" $deplib "*) 62216aec45a7Smrg if func_lalib_p "$lib"; then 62226aec45a7Smrg library_names= 62236aec45a7Smrg old_library= 62246aec45a7Smrg func_source "$lib" 62256aec45a7Smrg for l in $old_library $library_names; do 62266aec45a7Smrg ll="$l" 62276aec45a7Smrg done 62286aec45a7Smrg if test "X$ll" = "X$old_library" ; then # only static version available 62296aec45a7Smrg found=no 62306aec45a7Smrg func_dirname "$lib" "" "." 62316aec45a7Smrg ladir="$func_dirname_result" 62326aec45a7Smrg lib=$ladir/$old_library 62336aec45a7Smrg if test "$linkmode,$pass" = "prog,link"; then 62346aec45a7Smrg compile_deplibs="$deplib $compile_deplibs" 62356aec45a7Smrg finalize_deplibs="$deplib $finalize_deplibs" 62366aec45a7Smrg else 62376aec45a7Smrg deplibs="$deplib $deplibs" 62386aec45a7Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 62396aec45a7Smrg fi 62406aec45a7Smrg continue 62416aec45a7Smrg fi 62426aec45a7Smrg fi 62436aec45a7Smrg ;; 62446aec45a7Smrg *) ;; 62456aec45a7Smrg esac 62466aec45a7Smrg fi 62476aec45a7Smrg fi 62486aec45a7Smrg ;; # -l 62496aec45a7Smrg *.ltframework) 62506aec45a7Smrg if test "$linkmode,$pass" = "prog,link"; then 62516aec45a7Smrg compile_deplibs="$deplib $compile_deplibs" 62526aec45a7Smrg finalize_deplibs="$deplib $finalize_deplibs" 62536aec45a7Smrg else 62546aec45a7Smrg deplibs="$deplib $deplibs" 62556aec45a7Smrg if test "$linkmode" = lib ; then 62566aec45a7Smrg case "$new_inherited_linker_flags " in 62576aec45a7Smrg *" $deplib "*) ;; 6258aa9e3350Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 62596aec45a7Smrg esac 62606aec45a7Smrg fi 62616aec45a7Smrg fi 62626aec45a7Smrg continue 62636aec45a7Smrg ;; 62646aec45a7Smrg -L*) 62656aec45a7Smrg case $linkmode in 62666aec45a7Smrg lib) 62676aec45a7Smrg deplibs="$deplib $deplibs" 62686aec45a7Smrg test "$pass" = conv && continue 62696aec45a7Smrg newdependency_libs="$deplib $newdependency_libs" 62706aec45a7Smrg func_stripname '-L' '' "$deplib" 6271aa9e3350Smrg func_resolve_sysroot "$func_stripname_result" 6272aa9e3350Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 62736aec45a7Smrg ;; 62746aec45a7Smrg prog) 62756aec45a7Smrg if test "$pass" = conv; then 62766aec45a7Smrg deplibs="$deplib $deplibs" 62776aec45a7Smrg continue 62786aec45a7Smrg fi 62796aec45a7Smrg if test "$pass" = scan; then 62806aec45a7Smrg deplibs="$deplib $deplibs" 62816aec45a7Smrg else 62826aec45a7Smrg compile_deplibs="$deplib $compile_deplibs" 62836aec45a7Smrg finalize_deplibs="$deplib $finalize_deplibs" 62846aec45a7Smrg fi 62856aec45a7Smrg func_stripname '-L' '' "$deplib" 6286aa9e3350Smrg func_resolve_sysroot "$func_stripname_result" 6287aa9e3350Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 62886aec45a7Smrg ;; 62896aec45a7Smrg *) 62906aec45a7Smrg func_warning "\`-L' is ignored for archives/objects" 62916aec45a7Smrg ;; 62926aec45a7Smrg esac # linkmode 62936aec45a7Smrg continue 62946aec45a7Smrg ;; # -L 62956aec45a7Smrg -R*) 62966aec45a7Smrg if test "$pass" = link; then 62976aec45a7Smrg func_stripname '-R' '' "$deplib" 6298aa9e3350Smrg func_resolve_sysroot "$func_stripname_result" 6299aa9e3350Smrg dir=$func_resolve_sysroot_result 63006aec45a7Smrg # Make sure the xrpath contains only unique directories. 63016aec45a7Smrg case "$xrpath " in 63026aec45a7Smrg *" $dir "*) ;; 6303aa9e3350Smrg *) func_append xrpath " $dir" ;; 63046aec45a7Smrg esac 63056aec45a7Smrg fi 63066aec45a7Smrg deplibs="$deplib $deplibs" 63076aec45a7Smrg continue 63086aec45a7Smrg ;; 6309aa9e3350Smrg *.la) 6310aa9e3350Smrg func_resolve_sysroot "$deplib" 6311aa9e3350Smrg lib=$func_resolve_sysroot_result 6312aa9e3350Smrg ;; 63136aec45a7Smrg *.$libext) 63146aec45a7Smrg if test "$pass" = conv; then 63156aec45a7Smrg deplibs="$deplib $deplibs" 63166aec45a7Smrg continue 63176aec45a7Smrg fi 63186aec45a7Smrg case $linkmode in 63196aec45a7Smrg lib) 63206aec45a7Smrg # Linking convenience modules into shared libraries is allowed, 63216aec45a7Smrg # but linking other static libraries is non-portable. 63226aec45a7Smrg case " $dlpreconveniencelibs " in 63236aec45a7Smrg *" $deplib "*) ;; 63246aec45a7Smrg *) 63256aec45a7Smrg valid_a_lib=no 63266aec45a7Smrg case $deplibs_check_method in 63276aec45a7Smrg match_pattern*) 63286aec45a7Smrg set dummy $deplibs_check_method; shift 63296aec45a7Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 63306aec45a7Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 63316aec45a7Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 63326aec45a7Smrg valid_a_lib=yes 63336aec45a7Smrg fi 63346aec45a7Smrg ;; 63356aec45a7Smrg pass_all) 63366aec45a7Smrg valid_a_lib=yes 63376aec45a7Smrg ;; 63386aec45a7Smrg esac 63396aec45a7Smrg if test "$valid_a_lib" != yes; then 63406aec45a7Smrg echo 63416aec45a7Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 63426aec45a7Smrg echo "*** I have the capability to make that library automatically link in when" 63436aec45a7Smrg echo "*** you link to this library. But I can only do this if you have a" 63446aec45a7Smrg echo "*** shared version of the library, which you do not appear to have" 63456aec45a7Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 63466aec45a7Smrg echo "*** that it is just a static archive that I should not use here." 63476aec45a7Smrg else 63486aec45a7Smrg echo 63496aec45a7Smrg $ECHO "*** Warning: Linking the shared library $output against the" 63506aec45a7Smrg $ECHO "*** static library $deplib is not portable!" 63516aec45a7Smrg deplibs="$deplib $deplibs" 63526aec45a7Smrg fi 63536aec45a7Smrg ;; 63546aec45a7Smrg esac 63556aec45a7Smrg continue 63566aec45a7Smrg ;; 63576aec45a7Smrg prog) 63586aec45a7Smrg if test "$pass" != link; then 63596aec45a7Smrg deplibs="$deplib $deplibs" 63606aec45a7Smrg else 63616aec45a7Smrg compile_deplibs="$deplib $compile_deplibs" 63626aec45a7Smrg finalize_deplibs="$deplib $finalize_deplibs" 63636aec45a7Smrg fi 63646aec45a7Smrg continue 63656aec45a7Smrg ;; 63666aec45a7Smrg esac # linkmode 63676aec45a7Smrg ;; # *.$libext 63686aec45a7Smrg *.lo | *.$objext) 63696aec45a7Smrg if test "$pass" = conv; then 63706aec45a7Smrg deplibs="$deplib $deplibs" 63716aec45a7Smrg elif test "$linkmode" = prog; then 63726aec45a7Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 63736aec45a7Smrg # If there is no dlopen support or we're linking statically, 63746aec45a7Smrg # we need to preload. 6375aa9e3350Smrg func_append newdlprefiles " $deplib" 63766aec45a7Smrg compile_deplibs="$deplib $compile_deplibs" 63776aec45a7Smrg finalize_deplibs="$deplib $finalize_deplibs" 63786aec45a7Smrg else 6379aa9e3350Smrg func_append newdlfiles " $deplib" 63806aec45a7Smrg fi 63816aec45a7Smrg fi 63826aec45a7Smrg continue 63836aec45a7Smrg ;; 63846aec45a7Smrg %DEPLIBS%) 63856aec45a7Smrg alldeplibs=yes 63866aec45a7Smrg continue 63876aec45a7Smrg ;; 63886aec45a7Smrg esac # case $deplib 63896aec45a7Smrg 63906aec45a7Smrg if test "$found" = yes || test -f "$lib"; then : 63916aec45a7Smrg else 63926aec45a7Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 63936aec45a7Smrg fi 63946aec45a7Smrg 63956aec45a7Smrg # Check to see that this really is a libtool archive. 63966aec45a7Smrg func_lalib_unsafe_p "$lib" \ 63976aec45a7Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 63986aec45a7Smrg 63996aec45a7Smrg func_dirname "$lib" "" "." 64006aec45a7Smrg ladir="$func_dirname_result" 64016aec45a7Smrg 64026aec45a7Smrg dlname= 64036aec45a7Smrg dlopen= 64046aec45a7Smrg dlpreopen= 64056aec45a7Smrg libdir= 64066aec45a7Smrg library_names= 64076aec45a7Smrg old_library= 64086aec45a7Smrg inherited_linker_flags= 64096aec45a7Smrg # If the library was installed with an old release of libtool, 64106aec45a7Smrg # it will not redefine variables installed, or shouldnotlink 64116aec45a7Smrg installed=yes 64126aec45a7Smrg shouldnotlink=no 64136aec45a7Smrg avoidtemprpath= 64146aec45a7Smrg 64156aec45a7Smrg 64166aec45a7Smrg # Read the .la file 64176aec45a7Smrg func_source "$lib" 64186aec45a7Smrg 64196aec45a7Smrg # Convert "-framework foo" to "foo.ltframework" 64206aec45a7Smrg if test -n "$inherited_linker_flags"; then 64216aec45a7Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 64226aec45a7Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 64236aec45a7Smrg case " $new_inherited_linker_flags " in 64246aec45a7Smrg *" $tmp_inherited_linker_flag "*) ;; 6425aa9e3350Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 64266aec45a7Smrg esac 64276aec45a7Smrg done 64286aec45a7Smrg fi 64296aec45a7Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 64306aec45a7Smrg if test "$linkmode,$pass" = "lib,link" || 64316aec45a7Smrg test "$linkmode,$pass" = "prog,scan" || 64326aec45a7Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 6433aa9e3350Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 6434aa9e3350Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 64356aec45a7Smrg fi 64366aec45a7Smrg 64376aec45a7Smrg if test "$pass" = conv; then 64386aec45a7Smrg # Only check for convenience libraries 64396aec45a7Smrg deplibs="$lib $deplibs" 64406aec45a7Smrg if test -z "$libdir"; then 64416aec45a7Smrg if test -z "$old_library"; then 64426aec45a7Smrg func_fatal_error "cannot find name of link library for \`$lib'" 64436aec45a7Smrg fi 64446aec45a7Smrg # It is a libtool convenience library, so add in its objects. 6445aa9e3350Smrg func_append convenience " $ladir/$objdir/$old_library" 6446aa9e3350Smrg func_append old_convenience " $ladir/$objdir/$old_library" 64476aec45a7Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 64486aec45a7Smrg func_fatal_error "\`$lib' is not a convenience library" 64496aec45a7Smrg fi 64506aec45a7Smrg tmp_libs= 64516aec45a7Smrg for deplib in $dependency_libs; do 64526aec45a7Smrg deplibs="$deplib $deplibs" 6453aa9e3350Smrg if $opt_preserve_dup_deps ; then 64546aec45a7Smrg case "$tmp_libs " in 6455aa9e3350Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 64566aec45a7Smrg esac 64576aec45a7Smrg fi 6458aa9e3350Smrg func_append tmp_libs " $deplib" 64596aec45a7Smrg done 64606aec45a7Smrg continue 64616aec45a7Smrg fi # $pass = conv 64626aec45a7Smrg 64636aec45a7Smrg 64646aec45a7Smrg # Get the name of the library we link against. 64656aec45a7Smrg linklib= 6466aa9e3350Smrg if test -n "$old_library" && 6467aa9e3350Smrg { test "$prefer_static_libs" = yes || 6468aa9e3350Smrg test "$prefer_static_libs,$installed" = "built,no"; }; then 6469aa9e3350Smrg linklib=$old_library 6470aa9e3350Smrg else 6471aa9e3350Smrg for l in $old_library $library_names; do 6472aa9e3350Smrg linklib="$l" 6473aa9e3350Smrg done 6474aa9e3350Smrg fi 64756aec45a7Smrg if test -z "$linklib"; then 64766aec45a7Smrg func_fatal_error "cannot find name of link library for \`$lib'" 64776aec45a7Smrg fi 64786aec45a7Smrg 64796aec45a7Smrg # This library was specified with -dlopen. 64806aec45a7Smrg if test "$pass" = dlopen; then 64816aec45a7Smrg if test -z "$libdir"; then 64826aec45a7Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 64836aec45a7Smrg fi 64846aec45a7Smrg if test -z "$dlname" || 64856aec45a7Smrg test "$dlopen_support" != yes || 64866aec45a7Smrg test "$build_libtool_libs" = no; then 64876aec45a7Smrg # If there is no dlname, no dlopen support or we're linking 64886aec45a7Smrg # statically, we need to preload. We also need to preload any 64896aec45a7Smrg # dependent libraries so libltdl's deplib preloader doesn't 64906aec45a7Smrg # bomb out in the load deplibs phase. 6491aa9e3350Smrg func_append dlprefiles " $lib $dependency_libs" 64926aec45a7Smrg else 6493aa9e3350Smrg func_append newdlfiles " $lib" 64946aec45a7Smrg fi 64956aec45a7Smrg continue 64966aec45a7Smrg fi # $pass = dlopen 64976aec45a7Smrg 64986aec45a7Smrg # We need an absolute path. 64996aec45a7Smrg case $ladir in 65006aec45a7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 65016aec45a7Smrg *) 65026aec45a7Smrg abs_ladir=`cd "$ladir" && pwd` 65036aec45a7Smrg if test -z "$abs_ladir"; then 65046aec45a7Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 65056aec45a7Smrg func_warning "passing it literally to the linker, although it might fail" 65066aec45a7Smrg abs_ladir="$ladir" 65076aec45a7Smrg fi 65086aec45a7Smrg ;; 65096aec45a7Smrg esac 65106aec45a7Smrg func_basename "$lib" 65116aec45a7Smrg laname="$func_basename_result" 65126aec45a7Smrg 65136aec45a7Smrg # Find the relevant object directory and library name. 65146aec45a7Smrg if test "X$installed" = Xyes; then 6515aa9e3350Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 65166aec45a7Smrg func_warning "library \`$lib' was moved." 65176aec45a7Smrg dir="$ladir" 65186aec45a7Smrg absdir="$abs_ladir" 65196aec45a7Smrg libdir="$abs_ladir" 65206aec45a7Smrg else 6521aa9e3350Smrg dir="$lt_sysroot$libdir" 6522aa9e3350Smrg absdir="$lt_sysroot$libdir" 65236aec45a7Smrg fi 65246aec45a7Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 65256aec45a7Smrg else 65266aec45a7Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 65276aec45a7Smrg dir="$ladir" 65286aec45a7Smrg absdir="$abs_ladir" 65296aec45a7Smrg # Remove this search path later 6530aa9e3350Smrg func_append notinst_path " $abs_ladir" 65316aec45a7Smrg else 65326aec45a7Smrg dir="$ladir/$objdir" 65336aec45a7Smrg absdir="$abs_ladir/$objdir" 65346aec45a7Smrg # Remove this search path later 6535aa9e3350Smrg func_append notinst_path " $abs_ladir" 65366aec45a7Smrg fi 65376aec45a7Smrg fi # $installed = yes 65386aec45a7Smrg func_stripname 'lib' '.la' "$laname" 65396aec45a7Smrg name=$func_stripname_result 65406aec45a7Smrg 65416aec45a7Smrg # This library was specified with -dlpreopen. 65426aec45a7Smrg if test "$pass" = dlpreopen; then 65436aec45a7Smrg if test -z "$libdir" && test "$linkmode" = prog; then 65446aec45a7Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 65456aec45a7Smrg fi 6546aa9e3350Smrg case "$host" in 6547aa9e3350Smrg # special handling for platforms with PE-DLLs. 6548aa9e3350Smrg *cygwin* | *mingw* | *cegcc* ) 6549aa9e3350Smrg # Linker will automatically link against shared library if both 6550aa9e3350Smrg # static and shared are present. Therefore, ensure we extract 6551aa9e3350Smrg # symbols from the import library if a shared library is present 6552aa9e3350Smrg # (otherwise, the dlopen module name will be incorrect). We do 6553aa9e3350Smrg # this by putting the import library name into $newdlprefiles. 6554aa9e3350Smrg # We recover the dlopen module name by 'saving' the la file 6555aa9e3350Smrg # name in a special purpose variable, and (later) extracting the 6556aa9e3350Smrg # dlname from the la file. 6557aa9e3350Smrg if test -n "$dlname"; then 6558aa9e3350Smrg func_tr_sh "$dir/$linklib" 6559aa9e3350Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 6560aa9e3350Smrg func_append newdlprefiles " $dir/$linklib" 6561aa9e3350Smrg else 6562aa9e3350Smrg func_append newdlprefiles " $dir/$old_library" 6563aa9e3350Smrg # Keep a list of preopened convenience libraries to check 6564aa9e3350Smrg # that they are being used correctly in the link pass. 6565aa9e3350Smrg test -z "$libdir" && \ 6566aa9e3350Smrg func_append dlpreconveniencelibs " $dir/$old_library" 6567aa9e3350Smrg fi 6568aa9e3350Smrg ;; 6569aa9e3350Smrg * ) 6570aa9e3350Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 6571aa9e3350Smrg # are required to link). 6572aa9e3350Smrg if test -n "$old_library"; then 6573aa9e3350Smrg func_append newdlprefiles " $dir/$old_library" 6574aa9e3350Smrg # Keep a list of preopened convenience libraries to check 6575aa9e3350Smrg # that they are being used correctly in the link pass. 6576aa9e3350Smrg test -z "$libdir" && \ 6577aa9e3350Smrg func_append dlpreconveniencelibs " $dir/$old_library" 6578aa9e3350Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 6579aa9e3350Smrg elif test -n "$dlname"; then 6580aa9e3350Smrg func_append newdlprefiles " $dir/$dlname" 6581aa9e3350Smrg else 6582aa9e3350Smrg func_append newdlprefiles " $dir/$linklib" 6583aa9e3350Smrg fi 6584aa9e3350Smrg ;; 6585aa9e3350Smrg esac 65866aec45a7Smrg fi # $pass = dlpreopen 65876aec45a7Smrg 65886aec45a7Smrg if test -z "$libdir"; then 65896aec45a7Smrg # Link the convenience library 65906aec45a7Smrg if test "$linkmode" = lib; then 65916aec45a7Smrg deplibs="$dir/$old_library $deplibs" 65926aec45a7Smrg elif test "$linkmode,$pass" = "prog,link"; then 65936aec45a7Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 65946aec45a7Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 65956aec45a7Smrg else 65966aec45a7Smrg deplibs="$lib $deplibs" # used for prog,scan pass 65976aec45a7Smrg fi 65986aec45a7Smrg continue 65996aec45a7Smrg fi 66006aec45a7Smrg 66016aec45a7Smrg 66026aec45a7Smrg if test "$linkmode" = prog && test "$pass" != link; then 6603aa9e3350Smrg func_append newlib_search_path " $ladir" 66046aec45a7Smrg deplibs="$lib $deplibs" 66056aec45a7Smrg 66066aec45a7Smrg linkalldeplibs=no 66076aec45a7Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 66086aec45a7Smrg test "$build_libtool_libs" = no; then 66096aec45a7Smrg linkalldeplibs=yes 66106aec45a7Smrg fi 66116aec45a7Smrg 66126aec45a7Smrg tmp_libs= 66136aec45a7Smrg for deplib in $dependency_libs; do 66146aec45a7Smrg case $deplib in 66156aec45a7Smrg -L*) func_stripname '-L' '' "$deplib" 6616aa9e3350Smrg func_resolve_sysroot "$func_stripname_result" 6617aa9e3350Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 66186aec45a7Smrg ;; 66196aec45a7Smrg esac 66206aec45a7Smrg # Need to link against all dependency_libs? 66216aec45a7Smrg if test "$linkalldeplibs" = yes; then 66226aec45a7Smrg deplibs="$deplib $deplibs" 66236aec45a7Smrg else 66246aec45a7Smrg # Need to hardcode shared library paths 66256aec45a7Smrg # or/and link against static libraries 66266aec45a7Smrg newdependency_libs="$deplib $newdependency_libs" 66276aec45a7Smrg fi 6628aa9e3350Smrg if $opt_preserve_dup_deps ; then 66296aec45a7Smrg case "$tmp_libs " in 6630aa9e3350Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 66316aec45a7Smrg esac 66326aec45a7Smrg fi 6633aa9e3350Smrg func_append tmp_libs " $deplib" 66346aec45a7Smrg done # for deplib 66356aec45a7Smrg continue 66366aec45a7Smrg fi # $linkmode = prog... 66376aec45a7Smrg 66386aec45a7Smrg if test "$linkmode,$pass" = "prog,link"; then 66396aec45a7Smrg if test -n "$library_names" && 66406aec45a7Smrg { { test "$prefer_static_libs" = no || 66416aec45a7Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 66426aec45a7Smrg test -z "$old_library"; }; then 66436aec45a7Smrg # We need to hardcode the library path 66446aec45a7Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 66456aec45a7Smrg # Make sure the rpath contains only unique directories. 66466aec45a7Smrg case "$temp_rpath:" in 66476aec45a7Smrg *"$absdir:"*) ;; 6648aa9e3350Smrg *) func_append temp_rpath "$absdir:" ;; 66496aec45a7Smrg esac 66506aec45a7Smrg fi 66516aec45a7Smrg 66526aec45a7Smrg # Hardcode the library path. 66536aec45a7Smrg # Skip directories that are in the system default run-time 66546aec45a7Smrg # search path. 66556aec45a7Smrg case " $sys_lib_dlsearch_path " in 66566aec45a7Smrg *" $absdir "*) ;; 66576aec45a7Smrg *) 66586aec45a7Smrg case "$compile_rpath " in 66596aec45a7Smrg *" $absdir "*) ;; 6660aa9e3350Smrg *) func_append compile_rpath " $absdir" ;; 66616aec45a7Smrg esac 66626aec45a7Smrg ;; 66636aec45a7Smrg esac 66646aec45a7Smrg case " $sys_lib_dlsearch_path " in 66656aec45a7Smrg *" $libdir "*) ;; 66666aec45a7Smrg *) 66676aec45a7Smrg case "$finalize_rpath " in 66686aec45a7Smrg *" $libdir "*) ;; 6669aa9e3350Smrg *) func_append finalize_rpath " $libdir" ;; 66706aec45a7Smrg esac 66716aec45a7Smrg ;; 66726aec45a7Smrg esac 66736aec45a7Smrg fi # $linkmode,$pass = prog,link... 66746aec45a7Smrg 66756aec45a7Smrg if test "$alldeplibs" = yes && 66766aec45a7Smrg { test "$deplibs_check_method" = pass_all || 66776aec45a7Smrg { test "$build_libtool_libs" = yes && 66786aec45a7Smrg test -n "$library_names"; }; }; then 66796aec45a7Smrg # We only need to search for static libraries 66806aec45a7Smrg continue 66816aec45a7Smrg fi 66826aec45a7Smrg fi 66836aec45a7Smrg 66846aec45a7Smrg link_static=no # Whether the deplib will be linked statically 66856aec45a7Smrg use_static_libs=$prefer_static_libs 66866aec45a7Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 66876aec45a7Smrg use_static_libs=no 66886aec45a7Smrg fi 66896aec45a7Smrg if test -n "$library_names" && 66906aec45a7Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 66916aec45a7Smrg case $host in 66926aec45a7Smrg *cygwin* | *mingw* | *cegcc*) 66936aec45a7Smrg # No point in relinking DLLs because paths are not encoded 6694aa9e3350Smrg func_append notinst_deplibs " $lib" 66956aec45a7Smrg need_relink=no 66966aec45a7Smrg ;; 66976aec45a7Smrg *) 66986aec45a7Smrg if test "$installed" = no; then 6699aa9e3350Smrg func_append notinst_deplibs " $lib" 67006aec45a7Smrg need_relink=yes 67016aec45a7Smrg fi 67026aec45a7Smrg ;; 67036aec45a7Smrg esac 67046aec45a7Smrg # This is a shared library 67056aec45a7Smrg 67066aec45a7Smrg # Warn about portability, can't link against -module's on some 67076aec45a7Smrg # systems (darwin). Don't bleat about dlopened modules though! 67086aec45a7Smrg dlopenmodule="" 67096aec45a7Smrg for dlpremoduletest in $dlprefiles; do 67106aec45a7Smrg if test "X$dlpremoduletest" = "X$lib"; then 67116aec45a7Smrg dlopenmodule="$dlpremoduletest" 67126aec45a7Smrg break 67136aec45a7Smrg fi 67146aec45a7Smrg done 67156aec45a7Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 67166aec45a7Smrg echo 67176aec45a7Smrg if test "$linkmode" = prog; then 67186aec45a7Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 67196aec45a7Smrg else 67206aec45a7Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 67216aec45a7Smrg fi 67226aec45a7Smrg $ECHO "*** $linklib is not portable!" 67236aec45a7Smrg fi 67246aec45a7Smrg if test "$linkmode" = lib && 67256aec45a7Smrg test "$hardcode_into_libs" = yes; then 67266aec45a7Smrg # Hardcode the library path. 67276aec45a7Smrg # Skip directories that are in the system default run-time 67286aec45a7Smrg # search path. 67296aec45a7Smrg case " $sys_lib_dlsearch_path " in 67306aec45a7Smrg *" $absdir "*) ;; 67316aec45a7Smrg *) 67326aec45a7Smrg case "$compile_rpath " in 67336aec45a7Smrg *" $absdir "*) ;; 6734aa9e3350Smrg *) func_append compile_rpath " $absdir" ;; 67356aec45a7Smrg esac 67366aec45a7Smrg ;; 67376aec45a7Smrg esac 67386aec45a7Smrg case " $sys_lib_dlsearch_path " in 67396aec45a7Smrg *" $libdir "*) ;; 67406aec45a7Smrg *) 67416aec45a7Smrg case "$finalize_rpath " in 67426aec45a7Smrg *" $libdir "*) ;; 6743aa9e3350Smrg *) func_append finalize_rpath " $libdir" ;; 67446aec45a7Smrg esac 67456aec45a7Smrg ;; 67466aec45a7Smrg esac 67476aec45a7Smrg fi 67486aec45a7Smrg 67496aec45a7Smrg if test -n "$old_archive_from_expsyms_cmds"; then 67506aec45a7Smrg # figure out the soname 67516aec45a7Smrg set dummy $library_names 67526aec45a7Smrg shift 67536aec45a7Smrg realname="$1" 67546aec45a7Smrg shift 67556aec45a7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 67566aec45a7Smrg # use dlname if we got it. it's perfectly good, no? 67576aec45a7Smrg if test -n "$dlname"; then 67586aec45a7Smrg soname="$dlname" 67596aec45a7Smrg elif test -n "$soname_spec"; then 67606aec45a7Smrg # bleh windows 67616aec45a7Smrg case $host in 67626aec45a7Smrg *cygwin* | mingw* | *cegcc*) 67636aec45a7Smrg func_arith $current - $age 67646aec45a7Smrg major=$func_arith_result 67656aec45a7Smrg versuffix="-$major" 67666aec45a7Smrg ;; 67676aec45a7Smrg esac 67686aec45a7Smrg eval soname=\"$soname_spec\" 67696aec45a7Smrg else 67706aec45a7Smrg soname="$realname" 67716aec45a7Smrg fi 67726aec45a7Smrg 67736aec45a7Smrg # Make a new name for the extract_expsyms_cmds to use 67746aec45a7Smrg soroot="$soname" 67756aec45a7Smrg func_basename "$soroot" 67766aec45a7Smrg soname="$func_basename_result" 67776aec45a7Smrg func_stripname 'lib' '.dll' "$soname" 67786aec45a7Smrg newlib=libimp-$func_stripname_result.a 67796aec45a7Smrg 67806aec45a7Smrg # If the library has no export list, then create one now 67816aec45a7Smrg if test -f "$output_objdir/$soname-def"; then : 67826aec45a7Smrg else 67836aec45a7Smrg func_verbose "extracting exported symbol list from \`$soname'" 67846aec45a7Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 67856aec45a7Smrg fi 67866aec45a7Smrg 67876aec45a7Smrg # Create $newlib 67886aec45a7Smrg if test -f "$output_objdir/$newlib"; then :; else 67896aec45a7Smrg func_verbose "generating import library for \`$soname'" 67906aec45a7Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 67916aec45a7Smrg fi 67926aec45a7Smrg # make sure the library variables are pointing to the new library 67936aec45a7Smrg dir=$output_objdir 67946aec45a7Smrg linklib=$newlib 67956aec45a7Smrg fi # test -n "$old_archive_from_expsyms_cmds" 67966aec45a7Smrg 6797aa9e3350Smrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 67986aec45a7Smrg add_shlibpath= 67996aec45a7Smrg add_dir= 68006aec45a7Smrg add= 68016aec45a7Smrg lib_linked=yes 68026aec45a7Smrg case $hardcode_action in 68036aec45a7Smrg immediate | unsupported) 68046aec45a7Smrg if test "$hardcode_direct" = no; then 68056aec45a7Smrg add="$dir/$linklib" 68066aec45a7Smrg case $host in 68076aec45a7Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 68086aec45a7Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 68096aec45a7Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 68106aec45a7Smrg *-*-unixware7*) add_dir="-L$dir" ;; 68116aec45a7Smrg *-*-darwin* ) 68126aec45a7Smrg # if the lib is a (non-dlopened) module then we can not 68136aec45a7Smrg # link against it, someone is ignoring the earlier warnings 68146aec45a7Smrg if /usr/bin/file -L $add 2> /dev/null | 68156aec45a7Smrg $GREP ": [^:]* bundle" >/dev/null ; then 68166aec45a7Smrg if test "X$dlopenmodule" != "X$lib"; then 68176aec45a7Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 68186aec45a7Smrg if test -z "$old_library" ; then 68196aec45a7Smrg echo 68206aec45a7Smrg echo "*** And there doesn't seem to be a static archive available" 68216aec45a7Smrg echo "*** The link will probably fail, sorry" 68226aec45a7Smrg else 68236aec45a7Smrg add="$dir/$old_library" 68246aec45a7Smrg fi 68256aec45a7Smrg elif test -n "$old_library"; then 68266aec45a7Smrg add="$dir/$old_library" 68276aec45a7Smrg fi 68286aec45a7Smrg fi 68296aec45a7Smrg esac 68306aec45a7Smrg elif test "$hardcode_minus_L" = no; then 68316aec45a7Smrg case $host in 68326aec45a7Smrg *-*-sunos*) add_shlibpath="$dir" ;; 68336aec45a7Smrg esac 68346aec45a7Smrg add_dir="-L$dir" 68356aec45a7Smrg add="-l$name" 68366aec45a7Smrg elif test "$hardcode_shlibpath_var" = no; then 68376aec45a7Smrg add_shlibpath="$dir" 68386aec45a7Smrg add="-l$name" 68396aec45a7Smrg else 68406aec45a7Smrg lib_linked=no 68416aec45a7Smrg fi 68426aec45a7Smrg ;; 68436aec45a7Smrg relink) 68446aec45a7Smrg if test "$hardcode_direct" = yes && 68456aec45a7Smrg test "$hardcode_direct_absolute" = no; then 68466aec45a7Smrg add="$dir/$linklib" 68476aec45a7Smrg elif test "$hardcode_minus_L" = yes; then 6848aa9e3350Smrg add_dir="-L$absdir" 68496aec45a7Smrg # Try looking first in the location we're being installed to. 68506aec45a7Smrg if test -n "$inst_prefix_dir"; then 68516aec45a7Smrg case $libdir in 68526aec45a7Smrg [\\/]*) 6853aa9e3350Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 68546aec45a7Smrg ;; 68556aec45a7Smrg esac 68566aec45a7Smrg fi 68576aec45a7Smrg add="-l$name" 68586aec45a7Smrg elif test "$hardcode_shlibpath_var" = yes; then 68596aec45a7Smrg add_shlibpath="$dir" 68606aec45a7Smrg add="-l$name" 68616aec45a7Smrg else 68626aec45a7Smrg lib_linked=no 68636aec45a7Smrg fi 68646aec45a7Smrg ;; 68656aec45a7Smrg *) lib_linked=no ;; 68666aec45a7Smrg esac 68676aec45a7Smrg 68686aec45a7Smrg if test "$lib_linked" != yes; then 68696aec45a7Smrg func_fatal_configuration "unsupported hardcode properties" 68706aec45a7Smrg fi 68716aec45a7Smrg 68726aec45a7Smrg if test -n "$add_shlibpath"; then 68736aec45a7Smrg case :$compile_shlibpath: in 68746aec45a7Smrg *":$add_shlibpath:"*) ;; 6875aa9e3350Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 68766aec45a7Smrg esac 68776aec45a7Smrg fi 68786aec45a7Smrg if test "$linkmode" = prog; then 68796aec45a7Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 68806aec45a7Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 68816aec45a7Smrg else 68826aec45a7Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 68836aec45a7Smrg test -n "$add" && deplibs="$add $deplibs" 68846aec45a7Smrg if test "$hardcode_direct" != yes && 68856aec45a7Smrg test "$hardcode_minus_L" != yes && 68866aec45a7Smrg test "$hardcode_shlibpath_var" = yes; then 68876aec45a7Smrg case :$finalize_shlibpath: in 68886aec45a7Smrg *":$libdir:"*) ;; 6889aa9e3350Smrg *) func_append finalize_shlibpath "$libdir:" ;; 68906aec45a7Smrg esac 68916aec45a7Smrg fi 68926aec45a7Smrg fi 68936aec45a7Smrg fi 68946aec45a7Smrg 6895aa9e3350Smrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 68966aec45a7Smrg add_shlibpath= 68976aec45a7Smrg add_dir= 68986aec45a7Smrg add= 68996aec45a7Smrg # Finalize command for both is simple: just hardcode it. 69006aec45a7Smrg if test "$hardcode_direct" = yes && 69016aec45a7Smrg test "$hardcode_direct_absolute" = no; then 69026aec45a7Smrg add="$libdir/$linklib" 69036aec45a7Smrg elif test "$hardcode_minus_L" = yes; then 69046aec45a7Smrg add_dir="-L$libdir" 69056aec45a7Smrg add="-l$name" 69066aec45a7Smrg elif test "$hardcode_shlibpath_var" = yes; then 69076aec45a7Smrg case :$finalize_shlibpath: in 69086aec45a7Smrg *":$libdir:"*) ;; 6909aa9e3350Smrg *) func_append finalize_shlibpath "$libdir:" ;; 69106aec45a7Smrg esac 69116aec45a7Smrg add="-l$name" 69126aec45a7Smrg elif test "$hardcode_automatic" = yes; then 69136aec45a7Smrg if test -n "$inst_prefix_dir" && 69146aec45a7Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 69156aec45a7Smrg add="$inst_prefix_dir$libdir/$linklib" 69166aec45a7Smrg else 69176aec45a7Smrg add="$libdir/$linklib" 69186aec45a7Smrg fi 69196aec45a7Smrg else 69206aec45a7Smrg # We cannot seem to hardcode it, guess we'll fake it. 69216aec45a7Smrg add_dir="-L$libdir" 69226aec45a7Smrg # Try looking first in the location we're being installed to. 69236aec45a7Smrg if test -n "$inst_prefix_dir"; then 69246aec45a7Smrg case $libdir in 69256aec45a7Smrg [\\/]*) 6926aa9e3350Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 69276aec45a7Smrg ;; 69286aec45a7Smrg esac 69296aec45a7Smrg fi 69306aec45a7Smrg add="-l$name" 69316aec45a7Smrg fi 69326aec45a7Smrg 69336aec45a7Smrg if test "$linkmode" = prog; then 69346aec45a7Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 69356aec45a7Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 69366aec45a7Smrg else 69376aec45a7Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 69386aec45a7Smrg test -n "$add" && deplibs="$add $deplibs" 69396aec45a7Smrg fi 69406aec45a7Smrg fi 69416aec45a7Smrg elif test "$linkmode" = prog; then 69426aec45a7Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 69436aec45a7Smrg # is not unsupported. This is valid on all known static and 69446aec45a7Smrg # shared platforms. 69456aec45a7Smrg if test "$hardcode_direct" != unsupported; then 69466aec45a7Smrg test -n "$old_library" && linklib="$old_library" 69476aec45a7Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 69486aec45a7Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 69496aec45a7Smrg else 69506aec45a7Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 69516aec45a7Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 69526aec45a7Smrg fi 69536aec45a7Smrg elif test "$build_libtool_libs" = yes; then 69546aec45a7Smrg # Not a shared library 69556aec45a7Smrg if test "$deplibs_check_method" != pass_all; then 69566aec45a7Smrg # We're trying link a shared library against a static one 69576aec45a7Smrg # but the system doesn't support it. 69586aec45a7Smrg 69596aec45a7Smrg # Just print a warning and add the library to dependency_libs so 69606aec45a7Smrg # that the program can be linked against the static library. 69616aec45a7Smrg echo 69626aec45a7Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 69636aec45a7Smrg echo "*** I have the capability to make that library automatically link in when" 69646aec45a7Smrg echo "*** you link to this library. But I can only do this if you have a" 69656aec45a7Smrg echo "*** shared version of the library, which you do not appear to have." 69666aec45a7Smrg if test "$module" = yes; then 69676aec45a7Smrg echo "*** But as you try to build a module library, libtool will still create " 69686aec45a7Smrg echo "*** a static module, that should work as long as the dlopening application" 69696aec45a7Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 69706aec45a7Smrg if test -z "$global_symbol_pipe"; then 69716aec45a7Smrg echo 69726aec45a7Smrg echo "*** However, this would only work if libtool was able to extract symbol" 69736aec45a7Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 69746aec45a7Smrg echo "*** not find such a program. So, this module is probably useless." 69756aec45a7Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 69766aec45a7Smrg fi 69776aec45a7Smrg if test "$build_old_libs" = no; then 69786aec45a7Smrg build_libtool_libs=module 69796aec45a7Smrg build_old_libs=yes 69806aec45a7Smrg else 69816aec45a7Smrg build_libtool_libs=no 69826aec45a7Smrg fi 69836aec45a7Smrg fi 69846aec45a7Smrg else 69856aec45a7Smrg deplibs="$dir/$old_library $deplibs" 69866aec45a7Smrg link_static=yes 69876aec45a7Smrg fi 69886aec45a7Smrg fi # link shared/static library? 69896aec45a7Smrg 69906aec45a7Smrg if test "$linkmode" = lib; then 69916aec45a7Smrg if test -n "$dependency_libs" && 69926aec45a7Smrg { test "$hardcode_into_libs" != yes || 69936aec45a7Smrg test "$build_old_libs" = yes || 69946aec45a7Smrg test "$link_static" = yes; }; then 69956aec45a7Smrg # Extract -R from dependency_libs 69966aec45a7Smrg temp_deplibs= 69976aec45a7Smrg for libdir in $dependency_libs; do 69986aec45a7Smrg case $libdir in 69996aec45a7Smrg -R*) func_stripname '-R' '' "$libdir" 70006aec45a7Smrg temp_xrpath=$func_stripname_result 70016aec45a7Smrg case " $xrpath " in 70026aec45a7Smrg *" $temp_xrpath "*) ;; 7003aa9e3350Smrg *) func_append xrpath " $temp_xrpath";; 70046aec45a7Smrg esac;; 7005aa9e3350Smrg *) func_append temp_deplibs " $libdir";; 70066aec45a7Smrg esac 70076aec45a7Smrg done 70086aec45a7Smrg dependency_libs="$temp_deplibs" 70096aec45a7Smrg fi 70106aec45a7Smrg 7011aa9e3350Smrg func_append newlib_search_path " $absdir" 70126aec45a7Smrg # Link against this library 70136aec45a7Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 70146aec45a7Smrg # ... and its dependency_libs 70156aec45a7Smrg tmp_libs= 70166aec45a7Smrg for deplib in $dependency_libs; do 70176aec45a7Smrg newdependency_libs="$deplib $newdependency_libs" 7018aa9e3350Smrg case $deplib in 7019aa9e3350Smrg -L*) func_stripname '-L' '' "$deplib" 7020aa9e3350Smrg func_resolve_sysroot "$func_stripname_result";; 7021aa9e3350Smrg *) func_resolve_sysroot "$deplib" ;; 7022aa9e3350Smrg esac 7023aa9e3350Smrg if $opt_preserve_dup_deps ; then 70246aec45a7Smrg case "$tmp_libs " in 7025aa9e3350Smrg *" $func_resolve_sysroot_result "*) 7026aa9e3350Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 70276aec45a7Smrg esac 70286aec45a7Smrg fi 7029aa9e3350Smrg func_append tmp_libs " $func_resolve_sysroot_result" 70306aec45a7Smrg done 70316aec45a7Smrg 70326aec45a7Smrg if test "$link_all_deplibs" != no; then 70336aec45a7Smrg # Add the search paths of all dependency libraries 70346aec45a7Smrg for deplib in $dependency_libs; do 70356aec45a7Smrg path= 70366aec45a7Smrg case $deplib in 70376aec45a7Smrg -L*) path="$deplib" ;; 70386aec45a7Smrg *.la) 7039aa9e3350Smrg func_resolve_sysroot "$deplib" 7040aa9e3350Smrg deplib=$func_resolve_sysroot_result 70416aec45a7Smrg func_dirname "$deplib" "" "." 7042aa9e3350Smrg dir=$func_dirname_result 70436aec45a7Smrg # We need an absolute path. 70446aec45a7Smrg case $dir in 70456aec45a7Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 70466aec45a7Smrg *) 70476aec45a7Smrg absdir=`cd "$dir" && pwd` 70486aec45a7Smrg if test -z "$absdir"; then 70496aec45a7Smrg func_warning "cannot determine absolute directory name of \`$dir'" 70506aec45a7Smrg absdir="$dir" 70516aec45a7Smrg fi 70526aec45a7Smrg ;; 70536aec45a7Smrg esac 70546aec45a7Smrg if $GREP "^installed=no" $deplib > /dev/null; then 70556aec45a7Smrg case $host in 70566aec45a7Smrg *-*-darwin*) 70576aec45a7Smrg depdepl= 70586aec45a7Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 70596aec45a7Smrg if test -n "$deplibrary_names" ; then 70606aec45a7Smrg for tmp in $deplibrary_names ; do 70616aec45a7Smrg depdepl=$tmp 70626aec45a7Smrg done 70636aec45a7Smrg if test -f "$absdir/$objdir/$depdepl" ; then 70646aec45a7Smrg depdepl="$absdir/$objdir/$depdepl" 70656aec45a7Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 70666aec45a7Smrg if test -z "$darwin_install_name"; then 70676aec45a7Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 70686aec45a7Smrg fi 7069aa9e3350Smrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 7070aa9e3350Smrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 70716aec45a7Smrg path= 70726aec45a7Smrg fi 70736aec45a7Smrg fi 70746aec45a7Smrg ;; 70756aec45a7Smrg *) 70766aec45a7Smrg path="-L$absdir/$objdir" 70776aec45a7Smrg ;; 70786aec45a7Smrg esac 70796aec45a7Smrg else 70806aec45a7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 70816aec45a7Smrg test -z "$libdir" && \ 70826aec45a7Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 70836aec45a7Smrg test "$absdir" != "$libdir" && \ 70846aec45a7Smrg func_warning "\`$deplib' seems to be moved" 70856aec45a7Smrg 70866aec45a7Smrg path="-L$absdir" 70876aec45a7Smrg fi 70886aec45a7Smrg ;; 70896aec45a7Smrg esac 70906aec45a7Smrg case " $deplibs " in 70916aec45a7Smrg *" $path "*) ;; 70926aec45a7Smrg *) deplibs="$path $deplibs" ;; 70936aec45a7Smrg esac 70946aec45a7Smrg done 70956aec45a7Smrg fi # link_all_deplibs != no 70966aec45a7Smrg fi # linkmode = lib 70976aec45a7Smrg done # for deplib in $libs 70986aec45a7Smrg if test "$pass" = link; then 70996aec45a7Smrg if test "$linkmode" = "prog"; then 71006aec45a7Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 71016aec45a7Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 71026aec45a7Smrg else 71036aec45a7Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 71046aec45a7Smrg fi 71056aec45a7Smrg fi 71066aec45a7Smrg dependency_libs="$newdependency_libs" 71076aec45a7Smrg if test "$pass" = dlpreopen; then 71086aec45a7Smrg # Link the dlpreopened libraries before other libraries 71096aec45a7Smrg for deplib in $save_deplibs; do 71106aec45a7Smrg deplibs="$deplib $deplibs" 71116aec45a7Smrg done 71126aec45a7Smrg fi 71136aec45a7Smrg if test "$pass" != dlopen; then 71146aec45a7Smrg if test "$pass" != conv; then 71156aec45a7Smrg # Make sure lib_search_path contains only unique directories. 71166aec45a7Smrg lib_search_path= 71176aec45a7Smrg for dir in $newlib_search_path; do 71186aec45a7Smrg case "$lib_search_path " in 71196aec45a7Smrg *" $dir "*) ;; 7120aa9e3350Smrg *) func_append lib_search_path " $dir" ;; 71216aec45a7Smrg esac 71226aec45a7Smrg done 71236aec45a7Smrg newlib_search_path= 71246aec45a7Smrg fi 71256aec45a7Smrg 71266aec45a7Smrg if test "$linkmode,$pass" != "prog,link"; then 71276aec45a7Smrg vars="deplibs" 71286aec45a7Smrg else 71296aec45a7Smrg vars="compile_deplibs finalize_deplibs" 71306aec45a7Smrg fi 71316aec45a7Smrg for var in $vars dependency_libs; do 71326aec45a7Smrg # Add libraries to $var in reverse order 71336aec45a7Smrg eval tmp_libs=\"\$$var\" 71346aec45a7Smrg new_libs= 71356aec45a7Smrg for deplib in $tmp_libs; do 71366aec45a7Smrg # FIXME: Pedantically, this is the right thing to do, so 71376aec45a7Smrg # that some nasty dependency loop isn't accidentally 71386aec45a7Smrg # broken: 71396aec45a7Smrg #new_libs="$deplib $new_libs" 71406aec45a7Smrg # Pragmatically, this seems to cause very few problems in 71416aec45a7Smrg # practice: 71426aec45a7Smrg case $deplib in 71436aec45a7Smrg -L*) new_libs="$deplib $new_libs" ;; 71446aec45a7Smrg -R*) ;; 71456aec45a7Smrg *) 71466aec45a7Smrg # And here is the reason: when a library appears more 71476aec45a7Smrg # than once as an explicit dependence of a library, or 71486aec45a7Smrg # is implicitly linked in more than once by the 71496aec45a7Smrg # compiler, it is considered special, and multiple 71506aec45a7Smrg # occurrences thereof are not removed. Compare this 71516aec45a7Smrg # with having the same library being listed as a 71526aec45a7Smrg # dependency of multiple other libraries: in this case, 71536aec45a7Smrg # we know (pedantically, we assume) the library does not 71546aec45a7Smrg # need to be listed more than once, so we keep only the 71556aec45a7Smrg # last copy. This is not always right, but it is rare 71566aec45a7Smrg # enough that we require users that really mean to play 71576aec45a7Smrg # such unportable linking tricks to link the library 71586aec45a7Smrg # using -Wl,-lname, so that libtool does not consider it 71596aec45a7Smrg # for duplicate removal. 71606aec45a7Smrg case " $specialdeplibs " in 71616aec45a7Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 71626aec45a7Smrg *) 71636aec45a7Smrg case " $new_libs " in 71646aec45a7Smrg *" $deplib "*) ;; 71656aec45a7Smrg *) new_libs="$deplib $new_libs" ;; 71666aec45a7Smrg esac 71676aec45a7Smrg ;; 71686aec45a7Smrg esac 71696aec45a7Smrg ;; 71706aec45a7Smrg esac 71716aec45a7Smrg done 71726aec45a7Smrg tmp_libs= 71736aec45a7Smrg for deplib in $new_libs; do 71746aec45a7Smrg case $deplib in 71756aec45a7Smrg -L*) 71766aec45a7Smrg case " $tmp_libs " in 71776aec45a7Smrg *" $deplib "*) ;; 7178aa9e3350Smrg *) func_append tmp_libs " $deplib" ;; 71796aec45a7Smrg esac 71806aec45a7Smrg ;; 7181aa9e3350Smrg *) func_append tmp_libs " $deplib" ;; 71826aec45a7Smrg esac 71836aec45a7Smrg done 71846aec45a7Smrg eval $var=\"$tmp_libs\" 71856aec45a7Smrg done # for var 71866aec45a7Smrg fi 71876aec45a7Smrg # Last step: remove runtime libs from dependency_libs 71886aec45a7Smrg # (they stay in deplibs) 71896aec45a7Smrg tmp_libs= 71906aec45a7Smrg for i in $dependency_libs ; do 71916aec45a7Smrg case " $predeps $postdeps $compiler_lib_search_path " in 71926aec45a7Smrg *" $i "*) 71936aec45a7Smrg i="" 71946aec45a7Smrg ;; 71956aec45a7Smrg esac 71966aec45a7Smrg if test -n "$i" ; then 7197aa9e3350Smrg func_append tmp_libs " $i" 71986aec45a7Smrg fi 71996aec45a7Smrg done 72006aec45a7Smrg dependency_libs=$tmp_libs 72016aec45a7Smrg done # for pass 72026aec45a7Smrg if test "$linkmode" = prog; then 72036aec45a7Smrg dlfiles="$newdlfiles" 72046aec45a7Smrg fi 72056aec45a7Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 72066aec45a7Smrg dlprefiles="$newdlprefiles" 72076aec45a7Smrg fi 72086aec45a7Smrg 72096aec45a7Smrg case $linkmode in 72106aec45a7Smrg oldlib) 72116aec45a7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 72126aec45a7Smrg func_warning "\`-dlopen' is ignored for archives" 72136aec45a7Smrg fi 72146aec45a7Smrg 72156aec45a7Smrg case " $deplibs" in 72166aec45a7Smrg *\ -l* | *\ -L*) 72176aec45a7Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 72186aec45a7Smrg esac 72196aec45a7Smrg 72206aec45a7Smrg test -n "$rpath" && \ 72216aec45a7Smrg func_warning "\`-rpath' is ignored for archives" 72226aec45a7Smrg 72236aec45a7Smrg test -n "$xrpath" && \ 72246aec45a7Smrg func_warning "\`-R' is ignored for archives" 72256aec45a7Smrg 72266aec45a7Smrg test -n "$vinfo" && \ 72276aec45a7Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 72286aec45a7Smrg 72296aec45a7Smrg test -n "$release" && \ 72306aec45a7Smrg func_warning "\`-release' is ignored for archives" 72316aec45a7Smrg 72326aec45a7Smrg test -n "$export_symbols$export_symbols_regex" && \ 72336aec45a7Smrg func_warning "\`-export-symbols' is ignored for archives" 72346aec45a7Smrg 72356aec45a7Smrg # Now set the variables for building old libraries. 72366aec45a7Smrg build_libtool_libs=no 72376aec45a7Smrg oldlibs="$output" 7238aa9e3350Smrg func_append objs "$old_deplibs" 72396aec45a7Smrg ;; 72406aec45a7Smrg 72416aec45a7Smrg lib) 72426aec45a7Smrg # Make sure we only generate libraries of the form `libNAME.la'. 72436aec45a7Smrg case $outputname in 72446aec45a7Smrg lib*) 72456aec45a7Smrg func_stripname 'lib' '.la' "$outputname" 72466aec45a7Smrg name=$func_stripname_result 72476aec45a7Smrg eval shared_ext=\"$shrext_cmds\" 72486aec45a7Smrg eval libname=\"$libname_spec\" 72496aec45a7Smrg ;; 72506aec45a7Smrg *) 72516aec45a7Smrg test "$module" = no && \ 72526aec45a7Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 72536aec45a7Smrg 72546aec45a7Smrg if test "$need_lib_prefix" != no; then 72556aec45a7Smrg # Add the "lib" prefix for modules if required 72566aec45a7Smrg func_stripname '' '.la' "$outputname" 72576aec45a7Smrg name=$func_stripname_result 72586aec45a7Smrg eval shared_ext=\"$shrext_cmds\" 72596aec45a7Smrg eval libname=\"$libname_spec\" 72606aec45a7Smrg else 72616aec45a7Smrg func_stripname '' '.la' "$outputname" 72626aec45a7Smrg libname=$func_stripname_result 72636aec45a7Smrg fi 72646aec45a7Smrg ;; 72656aec45a7Smrg esac 72666aec45a7Smrg 72676aec45a7Smrg if test -n "$objs"; then 72686aec45a7Smrg if test "$deplibs_check_method" != pass_all; then 72696aec45a7Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 72706aec45a7Smrg else 72716aec45a7Smrg echo 72726aec45a7Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 72736aec45a7Smrg $ECHO "*** objects $objs is not portable!" 7274aa9e3350Smrg func_append libobjs " $objs" 72756aec45a7Smrg fi 72766aec45a7Smrg fi 72776aec45a7Smrg 72786aec45a7Smrg test "$dlself" != no && \ 72796aec45a7Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 72806aec45a7Smrg 72816aec45a7Smrg set dummy $rpath 72826aec45a7Smrg shift 72836aec45a7Smrg test "$#" -gt 1 && \ 72846aec45a7Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 72856aec45a7Smrg 72866aec45a7Smrg install_libdir="$1" 72876aec45a7Smrg 72886aec45a7Smrg oldlibs= 72896aec45a7Smrg if test -z "$rpath"; then 72906aec45a7Smrg if test "$build_libtool_libs" = yes; then 72916aec45a7Smrg # Building a libtool convenience library. 72926aec45a7Smrg # Some compilers have problems with a `.al' extension so 72936aec45a7Smrg # convenience libraries should have the same extension an 72946aec45a7Smrg # archive normally would. 72956aec45a7Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 72966aec45a7Smrg build_libtool_libs=convenience 72976aec45a7Smrg build_old_libs=yes 72986aec45a7Smrg fi 72996aec45a7Smrg 73006aec45a7Smrg test -n "$vinfo" && \ 73016aec45a7Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 73026aec45a7Smrg 73036aec45a7Smrg test -n "$release" && \ 73046aec45a7Smrg func_warning "\`-release' is ignored for convenience libraries" 73056aec45a7Smrg else 73066aec45a7Smrg 73076aec45a7Smrg # Parse the version information argument. 73086aec45a7Smrg save_ifs="$IFS"; IFS=':' 73096aec45a7Smrg set dummy $vinfo 0 0 0 73106aec45a7Smrg shift 73116aec45a7Smrg IFS="$save_ifs" 73126aec45a7Smrg 73136aec45a7Smrg test -n "$7" && \ 73146aec45a7Smrg func_fatal_help "too many parameters to \`-version-info'" 73156aec45a7Smrg 73166aec45a7Smrg # convert absolute version numbers to libtool ages 73176aec45a7Smrg # this retains compatibility with .la files and attempts 73186aec45a7Smrg # to make the code below a bit more comprehensible 73196aec45a7Smrg 73206aec45a7Smrg case $vinfo_number in 73216aec45a7Smrg yes) 73226aec45a7Smrg number_major="$1" 73236aec45a7Smrg number_minor="$2" 73246aec45a7Smrg number_revision="$3" 73256aec45a7Smrg # 73266aec45a7Smrg # There are really only two kinds -- those that 73276aec45a7Smrg # use the current revision as the major version 73286aec45a7Smrg # and those that subtract age and use age as 73296aec45a7Smrg # a minor version. But, then there is irix 73306aec45a7Smrg # which has an extra 1 added just for fun 73316aec45a7Smrg # 73326aec45a7Smrg case $version_type in 7333aa9e3350Smrg # correct linux to gnu/linux during the next big refactor 73346aec45a7Smrg darwin|linux|osf|windows|none) 73356aec45a7Smrg func_arith $number_major + $number_minor 73366aec45a7Smrg current=$func_arith_result 73376aec45a7Smrg age="$number_minor" 73386aec45a7Smrg revision="$number_revision" 73396aec45a7Smrg ;; 73406aec45a7Smrg freebsd-aout|freebsd-elf|qnx|sunos) 73416aec45a7Smrg current="$number_major" 73426aec45a7Smrg revision="$number_minor" 73436aec45a7Smrg age="0" 73446aec45a7Smrg ;; 73456aec45a7Smrg irix|nonstopux) 73466aec45a7Smrg func_arith $number_major + $number_minor 73476aec45a7Smrg current=$func_arith_result 73486aec45a7Smrg age="$number_minor" 73496aec45a7Smrg revision="$number_minor" 73506aec45a7Smrg lt_irix_increment=no 73516aec45a7Smrg ;; 73526aec45a7Smrg esac 73536aec45a7Smrg ;; 73546aec45a7Smrg no) 73556aec45a7Smrg current="$1" 73566aec45a7Smrg revision="$2" 73576aec45a7Smrg age="$3" 73586aec45a7Smrg ;; 73596aec45a7Smrg esac 73606aec45a7Smrg 73616aec45a7Smrg # Check that each of the things are valid numbers. 73626aec45a7Smrg case $current in 73636aec45a7Smrg 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]) ;; 73646aec45a7Smrg *) 73656aec45a7Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 73666aec45a7Smrg func_fatal_error "\`$vinfo' is not valid version information" 73676aec45a7Smrg ;; 73686aec45a7Smrg esac 73696aec45a7Smrg 73706aec45a7Smrg case $revision in 73716aec45a7Smrg 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]) ;; 73726aec45a7Smrg *) 73736aec45a7Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 73746aec45a7Smrg func_fatal_error "\`$vinfo' is not valid version information" 73756aec45a7Smrg ;; 73766aec45a7Smrg esac 73776aec45a7Smrg 73786aec45a7Smrg case $age in 73796aec45a7Smrg 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]) ;; 73806aec45a7Smrg *) 73816aec45a7Smrg func_error "AGE \`$age' must be a nonnegative integer" 73826aec45a7Smrg func_fatal_error "\`$vinfo' is not valid version information" 73836aec45a7Smrg ;; 73846aec45a7Smrg esac 73856aec45a7Smrg 73866aec45a7Smrg if test "$age" -gt "$current"; then 73876aec45a7Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 73886aec45a7Smrg func_fatal_error "\`$vinfo' is not valid version information" 73896aec45a7Smrg fi 73906aec45a7Smrg 73916aec45a7Smrg # Calculate the version variables. 73926aec45a7Smrg major= 73936aec45a7Smrg versuffix= 73946aec45a7Smrg verstring= 73956aec45a7Smrg case $version_type in 73966aec45a7Smrg none) ;; 73976aec45a7Smrg 73986aec45a7Smrg darwin) 73996aec45a7Smrg # Like Linux, but with the current version available in 74006aec45a7Smrg # verstring for coding it into the library header 74016aec45a7Smrg func_arith $current - $age 74026aec45a7Smrg major=.$func_arith_result 74036aec45a7Smrg versuffix="$major.$age.$revision" 74046aec45a7Smrg # Darwin ld doesn't like 0 for these options... 74056aec45a7Smrg func_arith $current + 1 74066aec45a7Smrg minor_current=$func_arith_result 74076aec45a7Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 74086aec45a7Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 74096aec45a7Smrg ;; 74106aec45a7Smrg 74116aec45a7Smrg freebsd-aout) 74126aec45a7Smrg major=".$current" 74136aec45a7Smrg versuffix=".$current.$revision"; 74146aec45a7Smrg ;; 74156aec45a7Smrg 74166aec45a7Smrg freebsd-elf) 74176aec45a7Smrg major=".$current" 74186aec45a7Smrg versuffix=".$current" 74196aec45a7Smrg ;; 74206aec45a7Smrg 74216aec45a7Smrg irix | nonstopux) 74226aec45a7Smrg if test "X$lt_irix_increment" = "Xno"; then 74236aec45a7Smrg func_arith $current - $age 74246aec45a7Smrg else 74256aec45a7Smrg func_arith $current - $age + 1 74266aec45a7Smrg fi 74276aec45a7Smrg major=$func_arith_result 74286aec45a7Smrg 74296aec45a7Smrg case $version_type in 74306aec45a7Smrg nonstopux) verstring_prefix=nonstopux ;; 74316aec45a7Smrg *) verstring_prefix=sgi ;; 74326aec45a7Smrg esac 74336aec45a7Smrg verstring="$verstring_prefix$major.$revision" 74346aec45a7Smrg 74356aec45a7Smrg # Add in all the interfaces that we are compatible with. 74366aec45a7Smrg loop=$revision 74376aec45a7Smrg while test "$loop" -ne 0; do 74386aec45a7Smrg func_arith $revision - $loop 74396aec45a7Smrg iface=$func_arith_result 74406aec45a7Smrg func_arith $loop - 1 74416aec45a7Smrg loop=$func_arith_result 74426aec45a7Smrg verstring="$verstring_prefix$major.$iface:$verstring" 74436aec45a7Smrg done 74446aec45a7Smrg 74456aec45a7Smrg # Before this point, $major must not contain `.'. 74466aec45a7Smrg major=.$major 74476aec45a7Smrg versuffix="$major.$revision" 74486aec45a7Smrg ;; 74496aec45a7Smrg 7450aa9e3350Smrg linux) # correct to gnu/linux during the next big refactor 74516aec45a7Smrg func_arith $current - $age 74526aec45a7Smrg major=.$func_arith_result 74536aec45a7Smrg versuffix="$major.$age.$revision" 74546aec45a7Smrg ;; 74556aec45a7Smrg 74566aec45a7Smrg osf) 74576aec45a7Smrg func_arith $current - $age 74586aec45a7Smrg major=.$func_arith_result 74596aec45a7Smrg versuffix=".$current.$age.$revision" 74606aec45a7Smrg verstring="$current.$age.$revision" 74616aec45a7Smrg 74626aec45a7Smrg # Add in all the interfaces that we are compatible with. 74636aec45a7Smrg loop=$age 74646aec45a7Smrg while test "$loop" -ne 0; do 74656aec45a7Smrg func_arith $current - $loop 74666aec45a7Smrg iface=$func_arith_result 74676aec45a7Smrg func_arith $loop - 1 74686aec45a7Smrg loop=$func_arith_result 74696aec45a7Smrg verstring="$verstring:${iface}.0" 74706aec45a7Smrg done 74716aec45a7Smrg 74726aec45a7Smrg # Make executables depend on our current version. 7473aa9e3350Smrg func_append verstring ":${current}.0" 74746aec45a7Smrg ;; 74756aec45a7Smrg 74766aec45a7Smrg qnx) 74776aec45a7Smrg major=".$current" 74786aec45a7Smrg versuffix=".$current" 74796aec45a7Smrg ;; 74806aec45a7Smrg 74816aec45a7Smrg sunos) 74826aec45a7Smrg major=".$current" 74836aec45a7Smrg versuffix=".$current.$revision" 74846aec45a7Smrg ;; 74856aec45a7Smrg 74866aec45a7Smrg windows) 74876aec45a7Smrg # Use '-' rather than '.', since we only want one 74886aec45a7Smrg # extension on DOS 8.3 filesystems. 74896aec45a7Smrg func_arith $current - $age 74906aec45a7Smrg major=$func_arith_result 74916aec45a7Smrg versuffix="-$major" 74926aec45a7Smrg ;; 74936aec45a7Smrg 74946aec45a7Smrg *) 74956aec45a7Smrg func_fatal_configuration "unknown library version type \`$version_type'" 74966aec45a7Smrg ;; 74976aec45a7Smrg esac 74986aec45a7Smrg 74996aec45a7Smrg # Clear the version info if we defaulted, and they specified a release. 75006aec45a7Smrg if test -z "$vinfo" && test -n "$release"; then 75016aec45a7Smrg major= 75026aec45a7Smrg case $version_type in 75036aec45a7Smrg darwin) 75046aec45a7Smrg # we can't check for "0.0" in archive_cmds due to quoting 75056aec45a7Smrg # problems, so we reset it completely 75066aec45a7Smrg verstring= 75076aec45a7Smrg ;; 75086aec45a7Smrg *) 75096aec45a7Smrg verstring="0.0" 75106aec45a7Smrg ;; 75116aec45a7Smrg esac 75126aec45a7Smrg if test "$need_version" = no; then 75136aec45a7Smrg versuffix= 75146aec45a7Smrg else 75156aec45a7Smrg versuffix=".0.0" 75166aec45a7Smrg fi 75176aec45a7Smrg fi 75186aec45a7Smrg 75196aec45a7Smrg # Remove version info from name if versioning should be avoided 75206aec45a7Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 75216aec45a7Smrg major= 75226aec45a7Smrg versuffix= 75236aec45a7Smrg verstring="" 75246aec45a7Smrg fi 75256aec45a7Smrg 75266aec45a7Smrg # Check to see if the archive will have undefined symbols. 75276aec45a7Smrg if test "$allow_undefined" = yes; then 75286aec45a7Smrg if test "$allow_undefined_flag" = unsupported; then 75296aec45a7Smrg func_warning "undefined symbols not allowed in $host shared libraries" 75306aec45a7Smrg build_libtool_libs=no 75316aec45a7Smrg build_old_libs=yes 75326aec45a7Smrg fi 75336aec45a7Smrg else 75346aec45a7Smrg # Don't allow undefined symbols. 75356aec45a7Smrg allow_undefined_flag="$no_undefined_flag" 75366aec45a7Smrg fi 75376aec45a7Smrg 75386aec45a7Smrg fi 75396aec45a7Smrg 75406aec45a7Smrg func_generate_dlsyms "$libname" "$libname" "yes" 7541aa9e3350Smrg func_append libobjs " $symfileobj" 75426aec45a7Smrg test "X$libobjs" = "X " && libobjs= 75436aec45a7Smrg 7544aa9e3350Smrg if test "$opt_mode" != relink; then 75456aec45a7Smrg # Remove our outputs, but don't remove object files since they 75466aec45a7Smrg # may have been created when compiling PIC objects. 75476aec45a7Smrg removelist= 75486aec45a7Smrg tempremovelist=`$ECHO "$output_objdir/*"` 75496aec45a7Smrg for p in $tempremovelist; do 75506aec45a7Smrg case $p in 75516aec45a7Smrg *.$objext | *.gcno) 75526aec45a7Smrg ;; 75536aec45a7Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 75546aec45a7Smrg if test "X$precious_files_regex" != "X"; then 75556aec45a7Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 75566aec45a7Smrg then 75576aec45a7Smrg continue 75586aec45a7Smrg fi 75596aec45a7Smrg fi 7560aa9e3350Smrg func_append removelist " $p" 75616aec45a7Smrg ;; 75626aec45a7Smrg *) ;; 75636aec45a7Smrg esac 75646aec45a7Smrg done 75656aec45a7Smrg test -n "$removelist" && \ 75666aec45a7Smrg func_show_eval "${RM}r \$removelist" 75676aec45a7Smrg fi 75686aec45a7Smrg 75696aec45a7Smrg # Now set the variables for building old libraries. 75706aec45a7Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 7571aa9e3350Smrg func_append oldlibs " $output_objdir/$libname.$libext" 75726aec45a7Smrg 75736aec45a7Smrg # Transform .lo files to .o files. 75746aec45a7Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 75756aec45a7Smrg fi 75766aec45a7Smrg 75776aec45a7Smrg # Eliminate all temporary directories. 75786aec45a7Smrg #for path in $notinst_path; do 75796aec45a7Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 75806aec45a7Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 75816aec45a7Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 75826aec45a7Smrg #done 75836aec45a7Smrg 75846aec45a7Smrg if test -n "$xrpath"; then 75856aec45a7Smrg # If the user specified any rpath flags, then add them. 75866aec45a7Smrg temp_xrpath= 75876aec45a7Smrg for libdir in $xrpath; do 7588aa9e3350Smrg func_replace_sysroot "$libdir" 7589aa9e3350Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 75906aec45a7Smrg case "$finalize_rpath " in 75916aec45a7Smrg *" $libdir "*) ;; 7592aa9e3350Smrg *) func_append finalize_rpath " $libdir" ;; 75936aec45a7Smrg esac 75946aec45a7Smrg done 75956aec45a7Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 75966aec45a7Smrg dependency_libs="$temp_xrpath $dependency_libs" 75976aec45a7Smrg fi 75986aec45a7Smrg fi 75996aec45a7Smrg 76006aec45a7Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 76016aec45a7Smrg old_dlfiles="$dlfiles" 76026aec45a7Smrg dlfiles= 76036aec45a7Smrg for lib in $old_dlfiles; do 76046aec45a7Smrg case " $dlprefiles $dlfiles " in 76056aec45a7Smrg *" $lib "*) ;; 7606aa9e3350Smrg *) func_append dlfiles " $lib" ;; 76076aec45a7Smrg esac 76086aec45a7Smrg done 76096aec45a7Smrg 76106aec45a7Smrg # Make sure dlprefiles contains only unique files 76116aec45a7Smrg old_dlprefiles="$dlprefiles" 76126aec45a7Smrg dlprefiles= 76136aec45a7Smrg for lib in $old_dlprefiles; do 76146aec45a7Smrg case "$dlprefiles " in 76156aec45a7Smrg *" $lib "*) ;; 7616aa9e3350Smrg *) func_append dlprefiles " $lib" ;; 76176aec45a7Smrg esac 76186aec45a7Smrg done 76196aec45a7Smrg 76206aec45a7Smrg if test "$build_libtool_libs" = yes; then 76216aec45a7Smrg if test -n "$rpath"; then 76226aec45a7Smrg case $host in 76236aec45a7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 76246aec45a7Smrg # these systems don't actually have a c library (as such)! 76256aec45a7Smrg ;; 76266aec45a7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 76276aec45a7Smrg # Rhapsody C library is in the System framework 7628aa9e3350Smrg func_append deplibs " System.ltframework" 76296aec45a7Smrg ;; 76306aec45a7Smrg *-*-netbsd*) 76316aec45a7Smrg # Don't link with libc until the a.out ld.so is fixed. 76326aec45a7Smrg ;; 76336aec45a7Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 76346aec45a7Smrg # Do not include libc due to us having libc/libc_r. 76356aec45a7Smrg ;; 76366aec45a7Smrg *-*-sco3.2v5* | *-*-sco5v6*) 76376aec45a7Smrg # Causes problems with __ctype 76386aec45a7Smrg ;; 76396aec45a7Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 76406aec45a7Smrg # Compiler inserts libc in the correct place for threads to work 76416aec45a7Smrg ;; 76426aec45a7Smrg *) 76436aec45a7Smrg # Add libc to deplibs on all other systems if necessary. 76446aec45a7Smrg if test "$build_libtool_need_lc" = "yes"; then 7645aa9e3350Smrg func_append deplibs " -lc" 76466aec45a7Smrg fi 76476aec45a7Smrg ;; 76486aec45a7Smrg esac 76496aec45a7Smrg fi 76506aec45a7Smrg 76516aec45a7Smrg # Transform deplibs into only deplibs that can be linked in shared. 76526aec45a7Smrg name_save=$name 76536aec45a7Smrg libname_save=$libname 76546aec45a7Smrg release_save=$release 76556aec45a7Smrg versuffix_save=$versuffix 76566aec45a7Smrg major_save=$major 76576aec45a7Smrg # I'm not sure if I'm treating the release correctly. I think 76586aec45a7Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 76596aec45a7Smrg # add it in twice. Is that correct? 76606aec45a7Smrg release="" 76616aec45a7Smrg versuffix="" 76626aec45a7Smrg major="" 76636aec45a7Smrg newdeplibs= 76646aec45a7Smrg droppeddeps=no 76656aec45a7Smrg case $deplibs_check_method in 76666aec45a7Smrg pass_all) 76676aec45a7Smrg # Don't check for shared/static. Everything works. 76686aec45a7Smrg # This might be a little naive. We might want to check 76696aec45a7Smrg # whether the library exists or not. But this is on 76706aec45a7Smrg # osf3 & osf4 and I'm not really sure... Just 76716aec45a7Smrg # implementing what was already the behavior. 76726aec45a7Smrg newdeplibs=$deplibs 76736aec45a7Smrg ;; 76746aec45a7Smrg test_compile) 76756aec45a7Smrg # This code stresses the "libraries are programs" paradigm to its 76766aec45a7Smrg # limits. Maybe even breaks it. We compile a program, linking it 76776aec45a7Smrg # against the deplibs as a proxy for the library. Then we can check 76786aec45a7Smrg # whether they linked in statically or dynamically with ldd. 76796aec45a7Smrg $opt_dry_run || $RM conftest.c 76806aec45a7Smrg cat > conftest.c <<EOF 76816aec45a7Smrg int main() { return 0; } 76826aec45a7SmrgEOF 76836aec45a7Smrg $opt_dry_run || $RM conftest 76846aec45a7Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 76856aec45a7Smrg ldd_output=`ldd conftest` 76866aec45a7Smrg for i in $deplibs; do 76876aec45a7Smrg case $i in 76886aec45a7Smrg -l*) 76896aec45a7Smrg func_stripname -l '' "$i" 76906aec45a7Smrg name=$func_stripname_result 76916aec45a7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 76926aec45a7Smrg case " $predeps $postdeps " in 76936aec45a7Smrg *" $i "*) 7694aa9e3350Smrg func_append newdeplibs " $i" 76956aec45a7Smrg i="" 76966aec45a7Smrg ;; 76976aec45a7Smrg esac 76986aec45a7Smrg fi 76996aec45a7Smrg if test -n "$i" ; then 77006aec45a7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 77016aec45a7Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 77026aec45a7Smrg set dummy $deplib_matches; shift 77036aec45a7Smrg deplib_match=$1 77046aec45a7Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7705aa9e3350Smrg func_append newdeplibs " $i" 77066aec45a7Smrg else 77076aec45a7Smrg droppeddeps=yes 77086aec45a7Smrg echo 77096aec45a7Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 77106aec45a7Smrg echo "*** I have the capability to make that library automatically link in when" 77116aec45a7Smrg echo "*** you link to this library. But I can only do this if you have a" 77126aec45a7Smrg echo "*** shared version of the library, which I believe you do not have" 77136aec45a7Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 77146aec45a7Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 77156aec45a7Smrg fi 77166aec45a7Smrg fi 77176aec45a7Smrg ;; 77186aec45a7Smrg *) 7719aa9e3350Smrg func_append newdeplibs " $i" 77206aec45a7Smrg ;; 77216aec45a7Smrg esac 77226aec45a7Smrg done 77236aec45a7Smrg else 77246aec45a7Smrg # Error occurred in the first compile. Let's try to salvage 77256aec45a7Smrg # the situation: Compile a separate program for each library. 77266aec45a7Smrg for i in $deplibs; do 77276aec45a7Smrg case $i in 77286aec45a7Smrg -l*) 77296aec45a7Smrg func_stripname -l '' "$i" 77306aec45a7Smrg name=$func_stripname_result 77316aec45a7Smrg $opt_dry_run || $RM conftest 77326aec45a7Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 77336aec45a7Smrg ldd_output=`ldd conftest` 77346aec45a7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 77356aec45a7Smrg case " $predeps $postdeps " in 77366aec45a7Smrg *" $i "*) 7737aa9e3350Smrg func_append newdeplibs " $i" 77386aec45a7Smrg i="" 77396aec45a7Smrg ;; 77406aec45a7Smrg esac 77416aec45a7Smrg fi 77426aec45a7Smrg if test -n "$i" ; then 77436aec45a7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 77446aec45a7Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 77456aec45a7Smrg set dummy $deplib_matches; shift 77466aec45a7Smrg deplib_match=$1 77476aec45a7Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7748aa9e3350Smrg func_append newdeplibs " $i" 77496aec45a7Smrg else 77506aec45a7Smrg droppeddeps=yes 77516aec45a7Smrg echo 77526aec45a7Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 77536aec45a7Smrg echo "*** I have the capability to make that library automatically link in when" 77546aec45a7Smrg echo "*** you link to this library. But I can only do this if you have a" 77556aec45a7Smrg echo "*** shared version of the library, which you do not appear to have" 77566aec45a7Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 77576aec45a7Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 77586aec45a7Smrg fi 77596aec45a7Smrg fi 77606aec45a7Smrg else 77616aec45a7Smrg droppeddeps=yes 77626aec45a7Smrg echo 77636aec45a7Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 77646aec45a7Smrg echo "*** make it link in! You will probably need to install it or some" 77656aec45a7Smrg echo "*** library that it depends on before this library will be fully" 77666aec45a7Smrg echo "*** functional. Installing it before continuing would be even better." 77676aec45a7Smrg fi 77686aec45a7Smrg ;; 77696aec45a7Smrg *) 7770aa9e3350Smrg func_append newdeplibs " $i" 77716aec45a7Smrg ;; 77726aec45a7Smrg esac 77736aec45a7Smrg done 77746aec45a7Smrg fi 77756aec45a7Smrg ;; 77766aec45a7Smrg file_magic*) 77776aec45a7Smrg set dummy $deplibs_check_method; shift 77786aec45a7Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 77796aec45a7Smrg for a_deplib in $deplibs; do 77806aec45a7Smrg case $a_deplib in 77816aec45a7Smrg -l*) 77826aec45a7Smrg func_stripname -l '' "$a_deplib" 77836aec45a7Smrg name=$func_stripname_result 77846aec45a7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 77856aec45a7Smrg case " $predeps $postdeps " in 77866aec45a7Smrg *" $a_deplib "*) 7787aa9e3350Smrg func_append newdeplibs " $a_deplib" 77886aec45a7Smrg a_deplib="" 77896aec45a7Smrg ;; 77906aec45a7Smrg esac 77916aec45a7Smrg fi 77926aec45a7Smrg if test -n "$a_deplib" ; then 77936aec45a7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7794aa9e3350Smrg if test -n "$file_magic_glob"; then 7795aa9e3350Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 7796aa9e3350Smrg else 7797aa9e3350Smrg libnameglob=$libname 7798aa9e3350Smrg fi 7799aa9e3350Smrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 78006aec45a7Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7801aa9e3350Smrg if test "$want_nocaseglob" = yes; then 7802aa9e3350Smrg shopt -s nocaseglob 7803aa9e3350Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7804aa9e3350Smrg $nocaseglob 7805aa9e3350Smrg else 7806aa9e3350Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7807aa9e3350Smrg fi 78086aec45a7Smrg for potent_lib in $potential_libs; do 78096aec45a7Smrg # Follow soft links. 78106aec45a7Smrg if ls -lLd "$potent_lib" 2>/dev/null | 78116aec45a7Smrg $GREP " -> " >/dev/null; then 78126aec45a7Smrg continue 78136aec45a7Smrg fi 78146aec45a7Smrg # The statement above tries to avoid entering an 78156aec45a7Smrg # endless loop below, in case of cyclic links. 78166aec45a7Smrg # We might still enter an endless loop, since a link 78176aec45a7Smrg # loop can be closed while we follow links, 78186aec45a7Smrg # but so what? 78196aec45a7Smrg potlib="$potent_lib" 78206aec45a7Smrg while test -h "$potlib" 2>/dev/null; do 78216aec45a7Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 78226aec45a7Smrg case $potliblink in 78236aec45a7Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 78246aec45a7Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 78256aec45a7Smrg esac 78266aec45a7Smrg done 78276aec45a7Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 78286aec45a7Smrg $SED -e 10q | 78296aec45a7Smrg $EGREP "$file_magic_regex" > /dev/null; then 7830aa9e3350Smrg func_append newdeplibs " $a_deplib" 78316aec45a7Smrg a_deplib="" 78326aec45a7Smrg break 2 78336aec45a7Smrg fi 78346aec45a7Smrg done 78356aec45a7Smrg done 78366aec45a7Smrg fi 78376aec45a7Smrg if test -n "$a_deplib" ; then 78386aec45a7Smrg droppeddeps=yes 78396aec45a7Smrg echo 78406aec45a7Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 78416aec45a7Smrg echo "*** I have the capability to make that library automatically link in when" 78426aec45a7Smrg echo "*** you link to this library. But I can only do this if you have a" 78436aec45a7Smrg echo "*** shared version of the library, which you do not appear to have" 78446aec45a7Smrg echo "*** because I did check the linker path looking for a file starting" 78456aec45a7Smrg if test -z "$potlib" ; then 78466aec45a7Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 78476aec45a7Smrg else 78486aec45a7Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 78496aec45a7Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 78506aec45a7Smrg fi 78516aec45a7Smrg fi 78526aec45a7Smrg ;; 78536aec45a7Smrg *) 78546aec45a7Smrg # Add a -L argument. 7855aa9e3350Smrg func_append newdeplibs " $a_deplib" 78566aec45a7Smrg ;; 78576aec45a7Smrg esac 78586aec45a7Smrg done # Gone through all deplibs. 78596aec45a7Smrg ;; 78606aec45a7Smrg match_pattern*) 78616aec45a7Smrg set dummy $deplibs_check_method; shift 78626aec45a7Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 78636aec45a7Smrg for a_deplib in $deplibs; do 78646aec45a7Smrg case $a_deplib in 78656aec45a7Smrg -l*) 78666aec45a7Smrg func_stripname -l '' "$a_deplib" 78676aec45a7Smrg name=$func_stripname_result 78686aec45a7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 78696aec45a7Smrg case " $predeps $postdeps " in 78706aec45a7Smrg *" $a_deplib "*) 7871aa9e3350Smrg func_append newdeplibs " $a_deplib" 78726aec45a7Smrg a_deplib="" 78736aec45a7Smrg ;; 78746aec45a7Smrg esac 78756aec45a7Smrg fi 78766aec45a7Smrg if test -n "$a_deplib" ; then 78776aec45a7Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 78786aec45a7Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 78796aec45a7Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 78806aec45a7Smrg for potent_lib in $potential_libs; do 78816aec45a7Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 78826aec45a7Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 78836aec45a7Smrg $EGREP "$match_pattern_regex" > /dev/null; then 7884aa9e3350Smrg func_append newdeplibs " $a_deplib" 78856aec45a7Smrg a_deplib="" 78866aec45a7Smrg break 2 78876aec45a7Smrg fi 78886aec45a7Smrg done 78896aec45a7Smrg done 78906aec45a7Smrg fi 78916aec45a7Smrg if test -n "$a_deplib" ; then 78926aec45a7Smrg droppeddeps=yes 78936aec45a7Smrg echo 78946aec45a7Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 78956aec45a7Smrg echo "*** I have the capability to make that library automatically link in when" 78966aec45a7Smrg echo "*** you link to this library. But I can only do this if you have a" 78976aec45a7Smrg echo "*** shared version of the library, which you do not appear to have" 78986aec45a7Smrg echo "*** because I did check the linker path looking for a file starting" 78996aec45a7Smrg if test -z "$potlib" ; then 79006aec45a7Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 79016aec45a7Smrg else 79026aec45a7Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 79036aec45a7Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 79046aec45a7Smrg fi 79056aec45a7Smrg fi 79066aec45a7Smrg ;; 79076aec45a7Smrg *) 79086aec45a7Smrg # Add a -L argument. 7909aa9e3350Smrg func_append newdeplibs " $a_deplib" 79106aec45a7Smrg ;; 79116aec45a7Smrg esac 79126aec45a7Smrg done # Gone through all deplibs. 79136aec45a7Smrg ;; 79146aec45a7Smrg none | unknown | *) 79156aec45a7Smrg newdeplibs="" 79166aec45a7Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 79176aec45a7Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 79186aec45a7Smrg for i in $predeps $postdeps ; do 79196aec45a7Smrg # can't use Xsed below, because $i might contain '/' 79206aec45a7Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 79216aec45a7Smrg done 79226aec45a7Smrg fi 79236aec45a7Smrg case $tmp_deplibs in 79246aec45a7Smrg *[!\ \ ]*) 79256aec45a7Smrg echo 79266aec45a7Smrg if test "X$deplibs_check_method" = "Xnone"; then 79276aec45a7Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 79286aec45a7Smrg else 79296aec45a7Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 79306aec45a7Smrg fi 79316aec45a7Smrg echo "*** All declared inter-library dependencies are being dropped." 79326aec45a7Smrg droppeddeps=yes 79336aec45a7Smrg ;; 79346aec45a7Smrg esac 79356aec45a7Smrg ;; 79366aec45a7Smrg esac 79376aec45a7Smrg versuffix=$versuffix_save 79386aec45a7Smrg major=$major_save 79396aec45a7Smrg release=$release_save 79406aec45a7Smrg libname=$libname_save 79416aec45a7Smrg name=$name_save 79426aec45a7Smrg 79436aec45a7Smrg case $host in 79446aec45a7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 79456aec45a7Smrg # On Rhapsody replace the C library with the System framework 79466aec45a7Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 79476aec45a7Smrg ;; 79486aec45a7Smrg esac 79496aec45a7Smrg 79506aec45a7Smrg if test "$droppeddeps" = yes; then 79516aec45a7Smrg if test "$module" = yes; then 79526aec45a7Smrg echo 79536aec45a7Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 79546aec45a7Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 79556aec45a7Smrg echo "*** a static module, that should work as long as the dlopening" 79566aec45a7Smrg echo "*** application is linked with the -dlopen flag." 79576aec45a7Smrg if test -z "$global_symbol_pipe"; then 79586aec45a7Smrg echo 79596aec45a7Smrg echo "*** However, this would only work if libtool was able to extract symbol" 79606aec45a7Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 79616aec45a7Smrg echo "*** not find such a program. So, this module is probably useless." 79626aec45a7Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 79636aec45a7Smrg fi 79646aec45a7Smrg if test "$build_old_libs" = no; then 79656aec45a7Smrg oldlibs="$output_objdir/$libname.$libext" 79666aec45a7Smrg build_libtool_libs=module 79676aec45a7Smrg build_old_libs=yes 79686aec45a7Smrg else 79696aec45a7Smrg build_libtool_libs=no 79706aec45a7Smrg fi 79716aec45a7Smrg else 79726aec45a7Smrg echo "*** The inter-library dependencies that have been dropped here will be" 79736aec45a7Smrg echo "*** automatically added whenever a program is linked with this library" 79746aec45a7Smrg echo "*** or is declared to -dlopen it." 79756aec45a7Smrg 79766aec45a7Smrg if test "$allow_undefined" = no; then 79776aec45a7Smrg echo 79786aec45a7Smrg echo "*** Since this library must not contain undefined symbols," 79796aec45a7Smrg echo "*** because either the platform does not support them or" 79806aec45a7Smrg echo "*** it was explicitly requested with -no-undefined," 79816aec45a7Smrg echo "*** libtool will only create a static version of it." 79826aec45a7Smrg if test "$build_old_libs" = no; then 79836aec45a7Smrg oldlibs="$output_objdir/$libname.$libext" 79846aec45a7Smrg build_libtool_libs=module 79856aec45a7Smrg build_old_libs=yes 79866aec45a7Smrg else 79876aec45a7Smrg build_libtool_libs=no 79886aec45a7Smrg fi 79896aec45a7Smrg fi 79906aec45a7Smrg fi 79916aec45a7Smrg fi 79926aec45a7Smrg # Done checking deplibs! 79936aec45a7Smrg deplibs=$newdeplibs 79946aec45a7Smrg fi 79956aec45a7Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 79966aec45a7Smrg case $host in 79976aec45a7Smrg *-*-darwin*) 79986aec45a7Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 79996aec45a7Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 80006aec45a7Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 80016aec45a7Smrg ;; 80026aec45a7Smrg esac 80036aec45a7Smrg 80046aec45a7Smrg # move library search paths that coincide with paths to not yet 80056aec45a7Smrg # installed libraries to the beginning of the library search list 80066aec45a7Smrg new_libs= 80076aec45a7Smrg for path in $notinst_path; do 80086aec45a7Smrg case " $new_libs " in 80096aec45a7Smrg *" -L$path/$objdir "*) ;; 80106aec45a7Smrg *) 80116aec45a7Smrg case " $deplibs " in 80126aec45a7Smrg *" -L$path/$objdir "*) 8013aa9e3350Smrg func_append new_libs " -L$path/$objdir" ;; 80146aec45a7Smrg esac 80156aec45a7Smrg ;; 80166aec45a7Smrg esac 80176aec45a7Smrg done 80186aec45a7Smrg for deplib in $deplibs; do 80196aec45a7Smrg case $deplib in 80206aec45a7Smrg -L*) 80216aec45a7Smrg case " $new_libs " in 80226aec45a7Smrg *" $deplib "*) ;; 8023aa9e3350Smrg *) func_append new_libs " $deplib" ;; 80246aec45a7Smrg esac 80256aec45a7Smrg ;; 8026aa9e3350Smrg *) func_append new_libs " $deplib" ;; 80276aec45a7Smrg esac 80286aec45a7Smrg done 80296aec45a7Smrg deplibs="$new_libs" 80306aec45a7Smrg 80316aec45a7Smrg # All the library-specific variables (install_libdir is set above). 80326aec45a7Smrg library_names= 80336aec45a7Smrg old_library= 80346aec45a7Smrg dlname= 80356aec45a7Smrg 80366aec45a7Smrg # Test again, we may have decided not to build it any more 80376aec45a7Smrg if test "$build_libtool_libs" = yes; then 8038aa9e3350Smrg # Remove ${wl} instances when linking with ld. 8039aa9e3350Smrg # FIXME: should test the right _cmds variable. 8040aa9e3350Smrg case $archive_cmds in 8041aa9e3350Smrg *\$LD\ *) wl= ;; 8042aa9e3350Smrg esac 80436aec45a7Smrg if test "$hardcode_into_libs" = yes; then 80446aec45a7Smrg # Hardcode the library paths 80456aec45a7Smrg hardcode_libdirs= 80466aec45a7Smrg dep_rpath= 80476aec45a7Smrg rpath="$finalize_rpath" 8048aa9e3350Smrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 80496aec45a7Smrg for libdir in $rpath; do 80506aec45a7Smrg if test -n "$hardcode_libdir_flag_spec"; then 80516aec45a7Smrg if test -n "$hardcode_libdir_separator"; then 8052aa9e3350Smrg func_replace_sysroot "$libdir" 8053aa9e3350Smrg libdir=$func_replace_sysroot_result 80546aec45a7Smrg if test -z "$hardcode_libdirs"; then 80556aec45a7Smrg hardcode_libdirs="$libdir" 80566aec45a7Smrg else 80576aec45a7Smrg # Just accumulate the unique libdirs. 80586aec45a7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 80596aec45a7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 80606aec45a7Smrg ;; 80616aec45a7Smrg *) 8062aa9e3350Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 80636aec45a7Smrg ;; 80646aec45a7Smrg esac 80656aec45a7Smrg fi 80666aec45a7Smrg else 80676aec45a7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8068aa9e3350Smrg func_append dep_rpath " $flag" 80696aec45a7Smrg fi 80706aec45a7Smrg elif test -n "$runpath_var"; then 80716aec45a7Smrg case "$perm_rpath " in 80726aec45a7Smrg *" $libdir "*) ;; 8073aa9e3350Smrg *) func_append perm_rpath " $libdir" ;; 80746aec45a7Smrg esac 80756aec45a7Smrg fi 80766aec45a7Smrg done 80776aec45a7Smrg # Substitute the hardcoded libdirs into the rpath. 80786aec45a7Smrg if test -n "$hardcode_libdir_separator" && 80796aec45a7Smrg test -n "$hardcode_libdirs"; then 80806aec45a7Smrg libdir="$hardcode_libdirs" 8081aa9e3350Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 80826aec45a7Smrg fi 80836aec45a7Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 80846aec45a7Smrg # We should set the runpath_var. 80856aec45a7Smrg rpath= 80866aec45a7Smrg for dir in $perm_rpath; do 8087aa9e3350Smrg func_append rpath "$dir:" 80886aec45a7Smrg done 80896aec45a7Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 80906aec45a7Smrg fi 80916aec45a7Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 80926aec45a7Smrg fi 8093ab47cfaaSmrg 80946aec45a7Smrg shlibpath="$finalize_shlibpath" 8095aa9e3350Smrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 80966aec45a7Smrg if test -n "$shlibpath"; then 80976aec45a7Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 80986aec45a7Smrg fi 8099ab47cfaaSmrg 81006aec45a7Smrg # Get the real and link names of the library. 81016aec45a7Smrg eval shared_ext=\"$shrext_cmds\" 81026aec45a7Smrg eval library_names=\"$library_names_spec\" 81036aec45a7Smrg set dummy $library_names 81046aec45a7Smrg shift 81056aec45a7Smrg realname="$1" 81066aec45a7Smrg shift 8107ab47cfaaSmrg 81086aec45a7Smrg if test -n "$soname_spec"; then 81096aec45a7Smrg eval soname=\"$soname_spec\" 81106aec45a7Smrg else 81116aec45a7Smrg soname="$realname" 81126aec45a7Smrg fi 81136aec45a7Smrg if test -z "$dlname"; then 81146aec45a7Smrg dlname=$soname 81156aec45a7Smrg fi 8116ab47cfaaSmrg 81176aec45a7Smrg lib="$output_objdir/$realname" 81186aec45a7Smrg linknames= 81196aec45a7Smrg for link 81206aec45a7Smrg do 8121aa9e3350Smrg func_append linknames " $link" 81226aec45a7Smrg done 8123ab47cfaaSmrg 81246aec45a7Smrg # Use standard objects if they are pic 81256aec45a7Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 81266aec45a7Smrg test "X$libobjs" = "X " && libobjs= 8127ab47cfaaSmrg 81286aec45a7Smrg delfiles= 81296aec45a7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 81306aec45a7Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 81316aec45a7Smrg export_symbols="$output_objdir/$libname.uexp" 8132aa9e3350Smrg func_append delfiles " $export_symbols" 81336aec45a7Smrg fi 8134ab47cfaaSmrg 81356aec45a7Smrg orig_export_symbols= 81366aec45a7Smrg case $host_os in 81376aec45a7Smrg cygwin* | mingw* | cegcc*) 81386aec45a7Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 81396aec45a7Smrg # exporting using user supplied symfile 81406aec45a7Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 81416aec45a7Smrg # and it's NOT already a .def file. Must figure out 81426aec45a7Smrg # which of the given symbols are data symbols and tag 81436aec45a7Smrg # them as such. So, trigger use of export_symbols_cmds. 81446aec45a7Smrg # export_symbols gets reassigned inside the "prepare 81456aec45a7Smrg # the list of exported symbols" if statement, so the 81466aec45a7Smrg # include_expsyms logic still works. 81476aec45a7Smrg orig_export_symbols="$export_symbols" 81486aec45a7Smrg export_symbols= 81496aec45a7Smrg always_export_symbols=yes 81506aec45a7Smrg fi 81516aec45a7Smrg fi 81526aec45a7Smrg ;; 81536aec45a7Smrg esac 8154ab47cfaaSmrg 81556aec45a7Smrg # Prepare the list of exported symbols 81566aec45a7Smrg if test -z "$export_symbols"; then 81576aec45a7Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 81586aec45a7Smrg func_verbose "generating symbol list for \`$libname.la'" 81596aec45a7Smrg export_symbols="$output_objdir/$libname.exp" 81606aec45a7Smrg $opt_dry_run || $RM $export_symbols 81616aec45a7Smrg cmds=$export_symbols_cmds 81626aec45a7Smrg save_ifs="$IFS"; IFS='~' 8163aa9e3350Smrg for cmd1 in $cmds; do 81646aec45a7Smrg IFS="$save_ifs" 8165aa9e3350Smrg # Take the normal branch if the nm_file_list_spec branch 8166aa9e3350Smrg # doesn't work or if tool conversion is not needed. 8167aa9e3350Smrg case $nm_file_list_spec~$to_tool_file_cmd in 8168aa9e3350Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 8169aa9e3350Smrg try_normal_branch=yes 8170aa9e3350Smrg eval cmd=\"$cmd1\" 8171aa9e3350Smrg func_len " $cmd" 8172aa9e3350Smrg len=$func_len_result 8173aa9e3350Smrg ;; 8174aa9e3350Smrg *) 8175aa9e3350Smrg try_normal_branch=no 8176aa9e3350Smrg ;; 8177aa9e3350Smrg esac 8178aa9e3350Smrg if test "$try_normal_branch" = yes \ 8179aa9e3350Smrg && { test "$len" -lt "$max_cmd_len" \ 8180aa9e3350Smrg || test "$max_cmd_len" -le -1; } 8181aa9e3350Smrg then 8182aa9e3350Smrg func_show_eval "$cmd" 'exit $?' 8183aa9e3350Smrg skipped_export=false 8184aa9e3350Smrg elif test -n "$nm_file_list_spec"; then 8185aa9e3350Smrg func_basename "$output" 8186aa9e3350Smrg output_la=$func_basename_result 8187aa9e3350Smrg save_libobjs=$libobjs 8188aa9e3350Smrg save_output=$output 8189aa9e3350Smrg output=${output_objdir}/${output_la}.nm 8190aa9e3350Smrg func_to_tool_file "$output" 8191aa9e3350Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 8192aa9e3350Smrg func_append delfiles " $output" 8193aa9e3350Smrg func_verbose "creating $NM input file list: $output" 8194aa9e3350Smrg for obj in $save_libobjs; do 8195aa9e3350Smrg func_to_tool_file "$obj" 8196aa9e3350Smrg $ECHO "$func_to_tool_file_result" 8197aa9e3350Smrg done > "$output" 8198aa9e3350Smrg eval cmd=\"$cmd1\" 81996aec45a7Smrg func_show_eval "$cmd" 'exit $?' 8200aa9e3350Smrg output=$save_output 8201aa9e3350Smrg libobjs=$save_libobjs 82026aec45a7Smrg skipped_export=false 82036aec45a7Smrg else 82046aec45a7Smrg # The command line is too long to execute in one step. 82056aec45a7Smrg func_verbose "using reloadable object file for export list..." 82066aec45a7Smrg skipped_export=: 82076aec45a7Smrg # Break out early, otherwise skipped_export may be 82086aec45a7Smrg # set to false by a later but shorter cmd. 82096aec45a7Smrg break 82106aec45a7Smrg fi 82116aec45a7Smrg done 82126aec45a7Smrg IFS="$save_ifs" 82136aec45a7Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 82146aec45a7Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 82156aec45a7Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 82166aec45a7Smrg fi 82176aec45a7Smrg fi 82186aec45a7Smrg fi 8219ab47cfaaSmrg 82206aec45a7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 82216aec45a7Smrg tmp_export_symbols="$export_symbols" 82226aec45a7Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 82236aec45a7Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 82246aec45a7Smrg fi 8225ab47cfaaSmrg 82266aec45a7Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 82276aec45a7Smrg # The given exports_symbols file has to be filtered, so filter it. 82286aec45a7Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 82296aec45a7Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 82306aec45a7Smrg # 's' commands which not all seds can handle. GNU sed should be fine 82316aec45a7Smrg # though. Also, the filter scales superlinearly with the number of 82326aec45a7Smrg # global variables. join(1) would be nice here, but unfortunately 82336aec45a7Smrg # isn't a blessed tool. 82346aec45a7Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8235aa9e3350Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 82366aec45a7Smrg export_symbols=$output_objdir/$libname.def 82376aec45a7Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 82381473d951Smrg fi 8239ab47cfaaSmrg 82406aec45a7Smrg tmp_deplibs= 82416aec45a7Smrg for test_deplib in $deplibs; do 82426aec45a7Smrg case " $convenience " in 82436aec45a7Smrg *" $test_deplib "*) ;; 82446aec45a7Smrg *) 8245aa9e3350Smrg func_append tmp_deplibs " $test_deplib" 82466aec45a7Smrg ;; 82476aec45a7Smrg esac 82486aec45a7Smrg done 82496aec45a7Smrg deplibs="$tmp_deplibs" 8250ab47cfaaSmrg 82516aec45a7Smrg if test -n "$convenience"; then 82526aec45a7Smrg if test -n "$whole_archive_flag_spec" && 82536aec45a7Smrg test "$compiler_needs_object" = yes && 82546aec45a7Smrg test -z "$libobjs"; then 82556aec45a7Smrg # extract the archives, so we have objects to list. 82566aec45a7Smrg # TODO: could optimize this to just extract one archive. 82576aec45a7Smrg whole_archive_flag_spec= 82586aec45a7Smrg fi 82596aec45a7Smrg if test -n "$whole_archive_flag_spec"; then 82606aec45a7Smrg save_libobjs=$libobjs 82616aec45a7Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 82626aec45a7Smrg test "X$libobjs" = "X " && libobjs= 82636aec45a7Smrg else 82646aec45a7Smrg gentop="$output_objdir/${outputname}x" 8265aa9e3350Smrg func_append generated " $gentop" 8266ab47cfaaSmrg 82676aec45a7Smrg func_extract_archives $gentop $convenience 8268aa9e3350Smrg func_append libobjs " $func_extract_archives_result" 82696aec45a7Smrg test "X$libobjs" = "X " && libobjs= 82706aec45a7Smrg fi 82716aec45a7Smrg fi 8272ab47cfaaSmrg 82736aec45a7Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 82746aec45a7Smrg eval flag=\"$thread_safe_flag_spec\" 8275aa9e3350Smrg func_append linker_flags " $flag" 82766aec45a7Smrg fi 8277ab47cfaaSmrg 82786aec45a7Smrg # Make a backup of the uninstalled library when relinking 8279aa9e3350Smrg if test "$opt_mode" = relink; then 82806aec45a7Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 82815c42550eSmrg fi 8282ab47cfaaSmrg 82836aec45a7Smrg # Do each of the archive commands. 82846aec45a7Smrg if test "$module" = yes && test -n "$module_cmds" ; then 82856aec45a7Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 82866aec45a7Smrg eval test_cmds=\"$module_expsym_cmds\" 82876aec45a7Smrg cmds=$module_expsym_cmds 82886aec45a7Smrg else 82896aec45a7Smrg eval test_cmds=\"$module_cmds\" 82906aec45a7Smrg cmds=$module_cmds 82916aec45a7Smrg fi 82926aec45a7Smrg else 82936aec45a7Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 82946aec45a7Smrg eval test_cmds=\"$archive_expsym_cmds\" 82956aec45a7Smrg cmds=$archive_expsym_cmds 82966aec45a7Smrg else 82976aec45a7Smrg eval test_cmds=\"$archive_cmds\" 82986aec45a7Smrg cmds=$archive_cmds 82996aec45a7Smrg fi 83005c42550eSmrg fi 8301ab47cfaaSmrg 83026aec45a7Smrg if test "X$skipped_export" != "X:" && 83036aec45a7Smrg func_len " $test_cmds" && 83046aec45a7Smrg len=$func_len_result && 83056aec45a7Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 83066aec45a7Smrg : 83076aec45a7Smrg else 83086aec45a7Smrg # The command line is too long to link in one step, link piecewise 83096aec45a7Smrg # or, if using GNU ld and skipped_export is not :, use a linker 83106aec45a7Smrg # script. 8311ab47cfaaSmrg 83126aec45a7Smrg # Save the value of $output and $libobjs because we want to 83136aec45a7Smrg # use them later. If we have whole_archive_flag_spec, we 83146aec45a7Smrg # want to use save_libobjs as it was before 83156aec45a7Smrg # whole_archive_flag_spec was expanded, because we can't 83166aec45a7Smrg # assume the linker understands whole_archive_flag_spec. 83176aec45a7Smrg # This may have to be revisited, in case too many 83186aec45a7Smrg # convenience libraries get linked in and end up exceeding 83196aec45a7Smrg # the spec. 83206aec45a7Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 83216aec45a7Smrg save_libobjs=$libobjs 83226aec45a7Smrg fi 83236aec45a7Smrg save_output=$output 83246aec45a7Smrg func_basename "$output" 83256aec45a7Smrg output_la=$func_basename_result 83261473d951Smrg 83276aec45a7Smrg # Clear the reloadable object creation command queue and 83286aec45a7Smrg # initialize k to one. 83296aec45a7Smrg test_cmds= 83306aec45a7Smrg concat_cmds= 83316aec45a7Smrg objlist= 83326aec45a7Smrg last_robj= 83336aec45a7Smrg k=1 8334ab47cfaaSmrg 83356aec45a7Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 83366aec45a7Smrg output=${output_objdir}/${output_la}.lnkscript 83376aec45a7Smrg func_verbose "creating GNU ld script: $output" 83386aec45a7Smrg echo 'INPUT (' > $output 83396aec45a7Smrg for obj in $save_libobjs 83406aec45a7Smrg do 8341aa9e3350Smrg func_to_tool_file "$obj" 8342aa9e3350Smrg $ECHO "$func_to_tool_file_result" >> $output 83436aec45a7Smrg done 83446aec45a7Smrg echo ')' >> $output 8345aa9e3350Smrg func_append delfiles " $output" 8346aa9e3350Smrg func_to_tool_file "$output" 8347aa9e3350Smrg output=$func_to_tool_file_result 83486aec45a7Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 83496aec45a7Smrg output=${output_objdir}/${output_la}.lnk 83506aec45a7Smrg func_verbose "creating linker input file list: $output" 83516aec45a7Smrg : > $output 83526aec45a7Smrg set x $save_libobjs 83536aec45a7Smrg shift 83546aec45a7Smrg firstobj= 83556aec45a7Smrg if test "$compiler_needs_object" = yes; then 83566aec45a7Smrg firstobj="$1 " 83576aec45a7Smrg shift 83586aec45a7Smrg fi 83596aec45a7Smrg for obj 83606aec45a7Smrg do 8361aa9e3350Smrg func_to_tool_file "$obj" 8362aa9e3350Smrg $ECHO "$func_to_tool_file_result" >> $output 83636aec45a7Smrg done 8364aa9e3350Smrg func_append delfiles " $output" 8365aa9e3350Smrg func_to_tool_file "$output" 8366aa9e3350Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 83676aec45a7Smrg else 83686aec45a7Smrg if test -n "$save_libobjs"; then 83696aec45a7Smrg func_verbose "creating reloadable object files..." 83706aec45a7Smrg output=$output_objdir/$output_la-${k}.$objext 83716aec45a7Smrg eval test_cmds=\"$reload_cmds\" 83726aec45a7Smrg func_len " $test_cmds" 83736aec45a7Smrg len0=$func_len_result 83746aec45a7Smrg len=$len0 83756aec45a7Smrg 83766aec45a7Smrg # Loop over the list of objects to be linked. 83776aec45a7Smrg for obj in $save_libobjs 83786aec45a7Smrg do 83796aec45a7Smrg func_len " $obj" 83806aec45a7Smrg func_arith $len + $func_len_result 83816aec45a7Smrg len=$func_arith_result 83826aec45a7Smrg if test "X$objlist" = X || 83836aec45a7Smrg test "$len" -lt "$max_cmd_len"; then 83846aec45a7Smrg func_append objlist " $obj" 83856aec45a7Smrg else 83866aec45a7Smrg # The command $test_cmds is almost too long, add a 83876aec45a7Smrg # command to the queue. 83886aec45a7Smrg if test "$k" -eq 1 ; then 83896aec45a7Smrg # The first file doesn't have a previous command to add. 83906aec45a7Smrg reload_objs=$objlist 83916aec45a7Smrg eval concat_cmds=\"$reload_cmds\" 83926aec45a7Smrg else 83936aec45a7Smrg # All subsequent reloadable object files will link in 83946aec45a7Smrg # the last one created. 83956aec45a7Smrg reload_objs="$objlist $last_robj" 83966aec45a7Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 83976aec45a7Smrg fi 83986aec45a7Smrg last_robj=$output_objdir/$output_la-${k}.$objext 83996aec45a7Smrg func_arith $k + 1 84006aec45a7Smrg k=$func_arith_result 84016aec45a7Smrg output=$output_objdir/$output_la-${k}.$objext 84026aec45a7Smrg objlist=" $obj" 84036aec45a7Smrg func_len " $last_robj" 84046aec45a7Smrg func_arith $len0 + $func_len_result 84056aec45a7Smrg len=$func_arith_result 84066aec45a7Smrg fi 84076aec45a7Smrg done 84086aec45a7Smrg # Handle the remaining objects by creating one last 84096aec45a7Smrg # reloadable object file. All subsequent reloadable object 84106aec45a7Smrg # files will link in the last one created. 84116aec45a7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 84126aec45a7Smrg reload_objs="$objlist $last_robj" 84136aec45a7Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 84146aec45a7Smrg if test -n "$last_robj"; then 84156aec45a7Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 84166aec45a7Smrg fi 8417aa9e3350Smrg func_append delfiles " $output" 84186aec45a7Smrg 84196aec45a7Smrg else 84206aec45a7Smrg output= 84216aec45a7Smrg fi 8422ab47cfaaSmrg 84236aec45a7Smrg if ${skipped_export-false}; then 84246aec45a7Smrg func_verbose "generating symbol list for \`$libname.la'" 84256aec45a7Smrg export_symbols="$output_objdir/$libname.exp" 84266aec45a7Smrg $opt_dry_run || $RM $export_symbols 84276aec45a7Smrg libobjs=$output 84286aec45a7Smrg # Append the command to create the export file. 84296aec45a7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 84306aec45a7Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 84316aec45a7Smrg if test -n "$last_robj"; then 84326aec45a7Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 84336aec45a7Smrg fi 84346aec45a7Smrg fi 8435ab47cfaaSmrg 84366aec45a7Smrg test -n "$save_libobjs" && 84376aec45a7Smrg func_verbose "creating a temporary reloadable object file: $output" 8438ab47cfaaSmrg 84396aec45a7Smrg # Loop through the commands generated above and execute them. 84406aec45a7Smrg save_ifs="$IFS"; IFS='~' 84416aec45a7Smrg for cmd in $concat_cmds; do 84426aec45a7Smrg IFS="$save_ifs" 84436aec45a7Smrg $opt_silent || { 84446aec45a7Smrg func_quote_for_expand "$cmd" 84456aec45a7Smrg eval "func_echo $func_quote_for_expand_result" 84466aec45a7Smrg } 84476aec45a7Smrg $opt_dry_run || eval "$cmd" || { 84486aec45a7Smrg lt_exit=$? 84496aec45a7Smrg 84506aec45a7Smrg # Restore the uninstalled library and exit 8451aa9e3350Smrg if test "$opt_mode" = relink; then 84526aec45a7Smrg ( cd "$output_objdir" && \ 84536aec45a7Smrg $RM "${realname}T" && \ 84546aec45a7Smrg $MV "${realname}U" "$realname" ) 84556aec45a7Smrg fi 8456ab47cfaaSmrg 84576aec45a7Smrg exit $lt_exit 84586aec45a7Smrg } 84596aec45a7Smrg done 84606aec45a7Smrg IFS="$save_ifs" 8461ab47cfaaSmrg 84626aec45a7Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 84636aec45a7Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 84646aec45a7Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 84651473d951Smrg fi 84661473d951Smrg fi 8467ab47cfaaSmrg 84686aec45a7Smrg if ${skipped_export-false}; then 84696aec45a7Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 84706aec45a7Smrg tmp_export_symbols="$export_symbols" 84716aec45a7Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 84726aec45a7Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 84736aec45a7Smrg fi 8474ab47cfaaSmrg 84756aec45a7Smrg if test -n "$orig_export_symbols"; then 84766aec45a7Smrg # The given exports_symbols file has to be filtered, so filter it. 84776aec45a7Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 84786aec45a7Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 84796aec45a7Smrg # 's' commands which not all seds can handle. GNU sed should be fine 84806aec45a7Smrg # though. Also, the filter scales superlinearly with the number of 84816aec45a7Smrg # global variables. join(1) would be nice here, but unfortunately 84826aec45a7Smrg # isn't a blessed tool. 84836aec45a7Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8484aa9e3350Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 84856aec45a7Smrg export_symbols=$output_objdir/$libname.def 84866aec45a7Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 84876aec45a7Smrg fi 84886aec45a7Smrg fi 84891473d951Smrg 84906aec45a7Smrg libobjs=$output 84916aec45a7Smrg # Restore the value of output. 84926aec45a7Smrg output=$save_output 84935c42550eSmrg 84946aec45a7Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 84956aec45a7Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 84966aec45a7Smrg test "X$libobjs" = "X " && libobjs= 84976aec45a7Smrg fi 84986aec45a7Smrg # Expand the library linking commands again to reset the 84996aec45a7Smrg # value of $libobjs for piecewise linking. 85006aec45a7Smrg 85016aec45a7Smrg # Do each of the archive commands. 85026aec45a7Smrg if test "$module" = yes && test -n "$module_cmds" ; then 85036aec45a7Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 85046aec45a7Smrg cmds=$module_expsym_cmds 8505ab47cfaaSmrg else 85066aec45a7Smrg cmds=$module_cmds 8507ab47cfaaSmrg fi 8508ab47cfaaSmrg else 85096aec45a7Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 85106aec45a7Smrg cmds=$archive_expsym_cmds 85116aec45a7Smrg else 85126aec45a7Smrg cmds=$archive_cmds 85136aec45a7Smrg fi 8514ab47cfaaSmrg fi 8515ab47cfaaSmrg fi 8516ab47cfaaSmrg 85176aec45a7Smrg if test -n "$delfiles"; then 85186aec45a7Smrg # Append the command to remove temporary files to $cmds. 85196aec45a7Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 85206aec45a7Smrg fi 8521ab47cfaaSmrg 85226aec45a7Smrg # Add any objects from preloaded convenience libraries 85236aec45a7Smrg if test -n "$dlprefiles"; then 85246aec45a7Smrg gentop="$output_objdir/${outputname}x" 8525aa9e3350Smrg func_append generated " $gentop" 8526ab47cfaaSmrg 85276aec45a7Smrg func_extract_archives $gentop $dlprefiles 8528aa9e3350Smrg func_append libobjs " $func_extract_archives_result" 85296aec45a7Smrg test "X$libobjs" = "X " && libobjs= 85301473d951Smrg fi 8531ab47cfaaSmrg 85326aec45a7Smrg save_ifs="$IFS"; IFS='~' 85336aec45a7Smrg for cmd in $cmds; do 85346aec45a7Smrg IFS="$save_ifs" 85356aec45a7Smrg eval cmd=\"$cmd\" 85366aec45a7Smrg $opt_silent || { 85376aec45a7Smrg func_quote_for_expand "$cmd" 85386aec45a7Smrg eval "func_echo $func_quote_for_expand_result" 85396aec45a7Smrg } 85406aec45a7Smrg $opt_dry_run || eval "$cmd" || { 85416aec45a7Smrg lt_exit=$? 8542ab47cfaaSmrg 85436aec45a7Smrg # Restore the uninstalled library and exit 8544aa9e3350Smrg if test "$opt_mode" = relink; then 85456aec45a7Smrg ( cd "$output_objdir" && \ 85466aec45a7Smrg $RM "${realname}T" && \ 85476aec45a7Smrg $MV "${realname}U" "$realname" ) 85485c42550eSmrg fi 8549ab47cfaaSmrg 85506aec45a7Smrg exit $lt_exit 85516aec45a7Smrg } 85526aec45a7Smrg done 85536aec45a7Smrg IFS="$save_ifs" 8554ab47cfaaSmrg 85556aec45a7Smrg # Restore the uninstalled library and exit 8556aa9e3350Smrg if test "$opt_mode" = relink; then 85576aec45a7Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8558ab47cfaaSmrg 85596aec45a7Smrg if test -n "$convenience"; then 85606aec45a7Smrg if test -z "$whole_archive_flag_spec"; then 85616aec45a7Smrg func_show_eval '${RM}r "$gentop"' 85626aec45a7Smrg fi 85636aec45a7Smrg fi 8564ab47cfaaSmrg 85656aec45a7Smrg exit $EXIT_SUCCESS 85666aec45a7Smrg fi 85671473d951Smrg 85686aec45a7Smrg # Create links to the real library. 85696aec45a7Smrg for linkname in $linknames; do 85706aec45a7Smrg if test "$realname" != "$linkname"; then 85716aec45a7Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 85726aec45a7Smrg fi 85736aec45a7Smrg done 85741473d951Smrg 85756aec45a7Smrg # If -module or -export-dynamic was specified, set the dlname. 85766aec45a7Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 85776aec45a7Smrg # On all known operating systems, these are identical. 85786aec45a7Smrg dlname="$soname" 85796aec45a7Smrg fi 85806aec45a7Smrg fi 85816aec45a7Smrg ;; 85821473d951Smrg 85836aec45a7Smrg obj) 85846aec45a7Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 85856aec45a7Smrg func_warning "\`-dlopen' is ignored for objects" 85866aec45a7Smrg fi 85871473d951Smrg 85886aec45a7Smrg case " $deplibs" in 85896aec45a7Smrg *\ -l* | *\ -L*) 85906aec45a7Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 85916aec45a7Smrg esac 85921473d951Smrg 85936aec45a7Smrg test -n "$rpath" && \ 85946aec45a7Smrg func_warning "\`-rpath' is ignored for objects" 85951473d951Smrg 85966aec45a7Smrg test -n "$xrpath" && \ 85976aec45a7Smrg func_warning "\`-R' is ignored for objects" 85986aec45a7Smrg 85996aec45a7Smrg test -n "$vinfo" && \ 86006aec45a7Smrg func_warning "\`-version-info' is ignored for objects" 8601ab47cfaaSmrg 86026aec45a7Smrg test -n "$release" && \ 86036aec45a7Smrg func_warning "\`-release' is ignored for objects" 86045c42550eSmrg 86056aec45a7Smrg case $output in 86066aec45a7Smrg *.lo) 86076aec45a7Smrg test -n "$objs$old_deplibs" && \ 86086aec45a7Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 86096aec45a7Smrg 86106aec45a7Smrg libobj=$output 86116aec45a7Smrg func_lo2o "$libobj" 86126aec45a7Smrg obj=$func_lo2o_result 86136aec45a7Smrg ;; 86146aec45a7Smrg *) 86156aec45a7Smrg libobj= 86166aec45a7Smrg obj="$output" 86175c42550eSmrg ;; 86181473d951Smrg esac 8619ab47cfaaSmrg 86206aec45a7Smrg # Delete the old objects. 86216aec45a7Smrg $opt_dry_run || $RM $obj $libobj 8622ab47cfaaSmrg 86236aec45a7Smrg # Objects from convenience libraries. This assumes 86246aec45a7Smrg # single-version convenience libraries. Whenever we create 86256aec45a7Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 86266aec45a7Smrg # the extraction. 86276aec45a7Smrg reload_conv_objs= 86286aec45a7Smrg gentop= 86296aec45a7Smrg # reload_cmds runs $LD directly, so let us get rid of 86306aec45a7Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 86316aec45a7Smrg # turning comma into space.. 86326aec45a7Smrg wl= 86331473d951Smrg 86346aec45a7Smrg if test -n "$convenience"; then 86356aec45a7Smrg if test -n "$whole_archive_flag_spec"; then 86366aec45a7Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 86376aec45a7Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 86385c42550eSmrg else 86396aec45a7Smrg gentop="$output_objdir/${obj}x" 8640aa9e3350Smrg func_append generated " $gentop" 86416aec45a7Smrg 86426aec45a7Smrg func_extract_archives $gentop $convenience 86436aec45a7Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 86445c42550eSmrg fi 86456aec45a7Smrg fi 8646ab47cfaaSmrg 8647aa9e3350Smrg # If we're not building shared, we need to use non_pic_objs 8648aa9e3350Smrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8649aa9e3350Smrg 86506aec45a7Smrg # Create the old-style object. 86516aec45a7Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8652ab47cfaaSmrg 86536aec45a7Smrg output="$obj" 86546aec45a7Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8655ab47cfaaSmrg 86566aec45a7Smrg # Exit if we aren't doing a library object file. 86576aec45a7Smrg if test -z "$libobj"; then 86586aec45a7Smrg if test -n "$gentop"; then 86596aec45a7Smrg func_show_eval '${RM}r "$gentop"' 86606aec45a7Smrg fi 86615c42550eSmrg 86626aec45a7Smrg exit $EXIT_SUCCESS 86635c42550eSmrg fi 86645c42550eSmrg 86656aec45a7Smrg if test "$build_libtool_libs" != yes; then 86666aec45a7Smrg if test -n "$gentop"; then 86676aec45a7Smrg func_show_eval '${RM}r "$gentop"' 86686aec45a7Smrg fi 86695c42550eSmrg 86706aec45a7Smrg # Create an invalid libtool object if no PIC, so that we don't 86716aec45a7Smrg # accidentally link it into a program. 86726aec45a7Smrg # $show "echo timestamp > $libobj" 86736aec45a7Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 86746aec45a7Smrg exit $EXIT_SUCCESS 86756aec45a7Smrg fi 86765c42550eSmrg 86776aec45a7Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 86786aec45a7Smrg # Only do commands if we really have different PIC objects. 86796aec45a7Smrg reload_objs="$libobjs $reload_conv_objs" 86806aec45a7Smrg output="$libobj" 86816aec45a7Smrg func_execute_cmds "$reload_cmds" 'exit $?' 86825c42550eSmrg fi 86836aec45a7Smrg 86846aec45a7Smrg if test -n "$gentop"; then 86856aec45a7Smrg func_show_eval '${RM}r "$gentop"' 86866aec45a7Smrg fi 86876aec45a7Smrg 86886aec45a7Smrg exit $EXIT_SUCCESS 86895c42550eSmrg ;; 8690ab47cfaaSmrg 86916aec45a7Smrg prog) 86926aec45a7Smrg case $host in 86936aec45a7Smrg *cygwin*) func_stripname '' '.exe' "$output" 86946aec45a7Smrg output=$func_stripname_result.exe;; 86956aec45a7Smrg esac 86966aec45a7Smrg test -n "$vinfo" && \ 86976aec45a7Smrg func_warning "\`-version-info' is ignored for programs" 8698ab47cfaaSmrg 86996aec45a7Smrg test -n "$release" && \ 87006aec45a7Smrg func_warning "\`-release' is ignored for programs" 8701ab47cfaaSmrg 87026aec45a7Smrg test "$preload" = yes \ 87036aec45a7Smrg && test "$dlopen_support" = unknown \ 87046aec45a7Smrg && test "$dlopen_self" = unknown \ 87056aec45a7Smrg && test "$dlopen_self_static" = unknown && \ 87066aec45a7Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 87076aec45a7Smrg 87086aec45a7Smrg case $host in 87096aec45a7Smrg *-*-rhapsody* | *-*-darwin1.[012]) 87106aec45a7Smrg # On Rhapsody replace the C library is the System framework 87116aec45a7Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 87126aec45a7Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 87135c42550eSmrg ;; 87146aec45a7Smrg esac 87155c42550eSmrg 87166aec45a7Smrg case $host in 87176aec45a7Smrg *-*-darwin*) 87186aec45a7Smrg # Don't allow lazy linking, it breaks C++ global constructors 87196aec45a7Smrg # But is supposedly fixed on 10.4 or later (yay!). 87206aec45a7Smrg if test "$tagname" = CXX ; then 87216aec45a7Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 87226aec45a7Smrg 10.[0123]) 8723aa9e3350Smrg func_append compile_command " ${wl}-bind_at_load" 8724aa9e3350Smrg func_append finalize_command " ${wl}-bind_at_load" 87256aec45a7Smrg ;; 87266aec45a7Smrg esac 87275c42550eSmrg fi 87286aec45a7Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 87296aec45a7Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 87306aec45a7Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 87316aec45a7Smrg ;; 87326aec45a7Smrg esac 87335c42550eSmrg 87345c42550eSmrg 87356aec45a7Smrg # move library search paths that coincide with paths to not yet 87366aec45a7Smrg # installed libraries to the beginning of the library search list 87376aec45a7Smrg new_libs= 87386aec45a7Smrg for path in $notinst_path; do 87396aec45a7Smrg case " $new_libs " in 87406aec45a7Smrg *" -L$path/$objdir "*) ;; 87416aec45a7Smrg *) 87426aec45a7Smrg case " $compile_deplibs " in 87436aec45a7Smrg *" -L$path/$objdir "*) 8744aa9e3350Smrg func_append new_libs " -L$path/$objdir" ;; 87451473d951Smrg esac 87466aec45a7Smrg ;; 87476aec45a7Smrg esac 87486aec45a7Smrg done 87496aec45a7Smrg for deplib in $compile_deplibs; do 87506aec45a7Smrg case $deplib in 87516aec45a7Smrg -L*) 87526aec45a7Smrg case " $new_libs " in 87536aec45a7Smrg *" $deplib "*) ;; 8754aa9e3350Smrg *) func_append new_libs " $deplib" ;; 87551473d951Smrg esac 87566aec45a7Smrg ;; 8757aa9e3350Smrg *) func_append new_libs " $deplib" ;; 87586aec45a7Smrg esac 87596aec45a7Smrg done 87606aec45a7Smrg compile_deplibs="$new_libs" 8761ab47cfaaSmrg 87625c42550eSmrg 8763aa9e3350Smrg func_append compile_command " $compile_deplibs" 8764aa9e3350Smrg func_append finalize_command " $finalize_deplibs" 87655c42550eSmrg 87666aec45a7Smrg if test -n "$rpath$xrpath"; then 87676aec45a7Smrg # If the user specified any rpath flags, then add them. 87686aec45a7Smrg for libdir in $rpath $xrpath; do 87696aec45a7Smrg # This is the magic to use -rpath. 87706aec45a7Smrg case "$finalize_rpath " in 87716aec45a7Smrg *" $libdir "*) ;; 8772aa9e3350Smrg *) func_append finalize_rpath " $libdir" ;; 87736aec45a7Smrg esac 87746aec45a7Smrg done 87756aec45a7Smrg fi 87765c42550eSmrg 87776aec45a7Smrg # Now hardcode the library paths 87786aec45a7Smrg rpath= 87796aec45a7Smrg hardcode_libdirs= 87806aec45a7Smrg for libdir in $compile_rpath $finalize_rpath; do 87816aec45a7Smrg if test -n "$hardcode_libdir_flag_spec"; then 87826aec45a7Smrg if test -n "$hardcode_libdir_separator"; then 87836aec45a7Smrg if test -z "$hardcode_libdirs"; then 87846aec45a7Smrg hardcode_libdirs="$libdir" 87856aec45a7Smrg else 87866aec45a7Smrg # Just accumulate the unique libdirs. 87876aec45a7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 87886aec45a7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 87896aec45a7Smrg ;; 87906aec45a7Smrg *) 8791aa9e3350Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 87926aec45a7Smrg ;; 87936aec45a7Smrg esac 87946aec45a7Smrg fi 87955c42550eSmrg else 87966aec45a7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8797aa9e3350Smrg func_append rpath " $flag" 87985c42550eSmrg fi 87996aec45a7Smrg elif test -n "$runpath_var"; then 88006aec45a7Smrg case "$perm_rpath " in 88016aec45a7Smrg *" $libdir "*) ;; 8802aa9e3350Smrg *) func_append perm_rpath " $libdir" ;; 88036aec45a7Smrg esac 88046aec45a7Smrg fi 88056aec45a7Smrg case $host in 88066aec45a7Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 88076aec45a7Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 88086aec45a7Smrg case :$dllsearchpath: in 88096aec45a7Smrg *":$libdir:"*) ;; 88106aec45a7Smrg ::) dllsearchpath=$libdir;; 8811aa9e3350Smrg *) func_append dllsearchpath ":$libdir";; 88126aec45a7Smrg esac 88136aec45a7Smrg case :$dllsearchpath: in 88146aec45a7Smrg *":$testbindir:"*) ;; 88156aec45a7Smrg ::) dllsearchpath=$testbindir;; 8816aa9e3350Smrg *) func_append dllsearchpath ":$testbindir";; 88176aec45a7Smrg esac 88186aec45a7Smrg ;; 88196aec45a7Smrg esac 88206aec45a7Smrg done 88216aec45a7Smrg # Substitute the hardcoded libdirs into the rpath. 88226aec45a7Smrg if test -n "$hardcode_libdir_separator" && 88236aec45a7Smrg test -n "$hardcode_libdirs"; then 88246aec45a7Smrg libdir="$hardcode_libdirs" 88256aec45a7Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 88266aec45a7Smrg fi 88276aec45a7Smrg compile_rpath="$rpath" 88285c42550eSmrg 88296aec45a7Smrg rpath= 88306aec45a7Smrg hardcode_libdirs= 88316aec45a7Smrg for libdir in $finalize_rpath; do 88326aec45a7Smrg if test -n "$hardcode_libdir_flag_spec"; then 88336aec45a7Smrg if test -n "$hardcode_libdir_separator"; then 88346aec45a7Smrg if test -z "$hardcode_libdirs"; then 88356aec45a7Smrg hardcode_libdirs="$libdir" 88366aec45a7Smrg else 88376aec45a7Smrg # Just accumulate the unique libdirs. 88386aec45a7Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 88396aec45a7Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 88406aec45a7Smrg ;; 88416aec45a7Smrg *) 8842aa9e3350Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 88436aec45a7Smrg ;; 88446aec45a7Smrg esac 88456aec45a7Smrg fi 8846ab47cfaaSmrg else 88476aec45a7Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8848aa9e3350Smrg func_append rpath " $flag" 8849ab47cfaaSmrg fi 88506aec45a7Smrg elif test -n "$runpath_var"; then 88516aec45a7Smrg case "$finalize_perm_rpath " in 88526aec45a7Smrg *" $libdir "*) ;; 8853aa9e3350Smrg *) func_append finalize_perm_rpath " $libdir" ;; 88546aec45a7Smrg esac 8855ab47cfaaSmrg fi 88566aec45a7Smrg done 88576aec45a7Smrg # Substitute the hardcoded libdirs into the rpath. 88586aec45a7Smrg if test -n "$hardcode_libdir_separator" && 88596aec45a7Smrg test -n "$hardcode_libdirs"; then 88606aec45a7Smrg libdir="$hardcode_libdirs" 88616aec45a7Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 88626aec45a7Smrg fi 88636aec45a7Smrg finalize_rpath="$rpath" 8864ab47cfaaSmrg 88656aec45a7Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 88666aec45a7Smrg # Transform all the library objects into standard objects. 88676aec45a7Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 88686aec45a7Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 88696aec45a7Smrg fi 8870ab47cfaaSmrg 88716aec45a7Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8872ab47cfaaSmrg 88736aec45a7Smrg # template prelinking step 88746aec45a7Smrg if test -n "$prelink_cmds"; then 88756aec45a7Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 88766aec45a7Smrg fi 8877ab47cfaaSmrg 88786aec45a7Smrg wrappers_required=yes 88796aec45a7Smrg case $host in 88806aec45a7Smrg *cegcc* | *mingw32ce*) 88816aec45a7Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 88826aec45a7Smrg wrappers_required=no 88836aec45a7Smrg ;; 88846aec45a7Smrg *cygwin* | *mingw* ) 88856aec45a7Smrg if test "$build_libtool_libs" != yes; then 88866aec45a7Smrg wrappers_required=no 88876aec45a7Smrg fi 88886aec45a7Smrg ;; 88896aec45a7Smrg *) 88906aec45a7Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 88916aec45a7Smrg wrappers_required=no 88926aec45a7Smrg fi 88936aec45a7Smrg ;; 88946aec45a7Smrg esac 88956aec45a7Smrg if test "$wrappers_required" = no; then 88966aec45a7Smrg # Replace the output file specification. 88976aec45a7Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 88986aec45a7Smrg link_command="$compile_command$compile_rpath" 8899ab47cfaaSmrg 89006aec45a7Smrg # We have no uninstalled library dependencies, so finalize right now. 89016aec45a7Smrg exit_status=0 89026aec45a7Smrg func_show_eval "$link_command" 'exit_status=$?' 8903ab47cfaaSmrg 8904aa9e3350Smrg if test -n "$postlink_cmds"; then 8905aa9e3350Smrg func_to_tool_file "$output" 8906aa9e3350Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8907aa9e3350Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8908aa9e3350Smrg fi 8909aa9e3350Smrg 89106aec45a7Smrg # Delete the generated files. 89116aec45a7Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 89126aec45a7Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8913ab47cfaaSmrg fi 8914ab47cfaaSmrg 89156aec45a7Smrg exit $exit_status 89166aec45a7Smrg fi 8917ab47cfaaSmrg 89186aec45a7Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 89196aec45a7Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 89206aec45a7Smrg fi 89216aec45a7Smrg if test -n "$finalize_shlibpath"; then 89226aec45a7Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 89236aec45a7Smrg fi 89245c42550eSmrg 89256aec45a7Smrg compile_var= 89266aec45a7Smrg finalize_var= 89276aec45a7Smrg if test -n "$runpath_var"; then 89286aec45a7Smrg if test -n "$perm_rpath"; then 89296aec45a7Smrg # We should set the runpath_var. 89306aec45a7Smrg rpath= 89316aec45a7Smrg for dir in $perm_rpath; do 8932aa9e3350Smrg func_append rpath "$dir:" 89336aec45a7Smrg done 89346aec45a7Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8935ab47cfaaSmrg fi 89366aec45a7Smrg if test -n "$finalize_perm_rpath"; then 89376aec45a7Smrg # We should set the runpath_var. 89386aec45a7Smrg rpath= 89396aec45a7Smrg for dir in $finalize_perm_rpath; do 8940aa9e3350Smrg func_append rpath "$dir:" 89416aec45a7Smrg done 89426aec45a7Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8943ab47cfaaSmrg fi 89446aec45a7Smrg fi 8945ab47cfaaSmrg 89466aec45a7Smrg if test "$no_install" = yes; then 89476aec45a7Smrg # We don't need to create a wrapper script. 89486aec45a7Smrg link_command="$compile_var$compile_command$compile_rpath" 89496aec45a7Smrg # Replace the output file specification. 89506aec45a7Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 89516aec45a7Smrg # Delete the old output file. 89526aec45a7Smrg $opt_dry_run || $RM $output 89536aec45a7Smrg # Link the executable and exit 89546aec45a7Smrg func_show_eval "$link_command" 'exit $?' 8955aa9e3350Smrg 8956aa9e3350Smrg if test -n "$postlink_cmds"; then 8957aa9e3350Smrg func_to_tool_file "$output" 8958aa9e3350Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8959aa9e3350Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8960aa9e3350Smrg fi 8961aa9e3350Smrg 89625c42550eSmrg exit $EXIT_SUCCESS 89636aec45a7Smrg fi 89641473d951Smrg 89656aec45a7Smrg if test "$hardcode_action" = relink; then 89666aec45a7Smrg # Fast installation is not supported 89676aec45a7Smrg link_command="$compile_var$compile_command$compile_rpath" 89686aec45a7Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 89696aec45a7Smrg 89706aec45a7Smrg func_warning "this platform does not like uninstalled shared libraries" 89716aec45a7Smrg func_warning "\`$output' will be relinked during installation" 89726aec45a7Smrg else 89736aec45a7Smrg if test "$fast_install" != no; then 89746aec45a7Smrg link_command="$finalize_var$compile_command$finalize_rpath" 89756aec45a7Smrg if test "$fast_install" = yes; then 89766aec45a7Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 89776aec45a7Smrg else 89786aec45a7Smrg # fast_install is set to needless 89796aec45a7Smrg relink_command= 89806aec45a7Smrg fi 8981ab47cfaaSmrg else 89826aec45a7Smrg link_command="$compile_var$compile_command$compile_rpath" 89836aec45a7Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8984ab47cfaaSmrg fi 89856aec45a7Smrg fi 8986ab47cfaaSmrg 89876aec45a7Smrg # Replace the output file specification. 89886aec45a7Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8989ab47cfaaSmrg 89906aec45a7Smrg # Delete the old output files. 89916aec45a7Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8992ab47cfaaSmrg 89936aec45a7Smrg func_show_eval "$link_command" 'exit $?' 89945c42550eSmrg 8995aa9e3350Smrg if test -n "$postlink_cmds"; then 8996aa9e3350Smrg func_to_tool_file "$output_objdir/$outputname" 8997aa9e3350Smrg 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'` 8998aa9e3350Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8999aa9e3350Smrg fi 9000aa9e3350Smrg 90016aec45a7Smrg # Now create the wrapper script. 90026aec45a7Smrg func_verbose "creating $output" 90035c42550eSmrg 90046aec45a7Smrg # Quote the relink command for shipping. 90056aec45a7Smrg if test -n "$relink_command"; then 90066aec45a7Smrg # Preserve any variables that may affect compiler behavior 90076aec45a7Smrg for var in $variables_saved_for_relink; do 90086aec45a7Smrg if eval test -z \"\${$var+set}\"; then 90096aec45a7Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 90106aec45a7Smrg elif eval var_value=\$$var; test -z "$var_value"; then 90116aec45a7Smrg relink_command="$var=; export $var; $relink_command" 9012ab47cfaaSmrg else 90136aec45a7Smrg func_quote_for_eval "$var_value" 90146aec45a7Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9015ab47cfaaSmrg fi 90166aec45a7Smrg done 90176aec45a7Smrg relink_command="(cd `pwd`; $relink_command)" 90186aec45a7Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 90196aec45a7Smrg fi 90201473d951Smrg 90216aec45a7Smrg # Only actually do things if not in dry run mode. 90226aec45a7Smrg $opt_dry_run || { 90236aec45a7Smrg # win32 will think the script is a binary if it has 90246aec45a7Smrg # a .exe suffix, so we strip it off here. 90256aec45a7Smrg case $output in 90266aec45a7Smrg *.exe) func_stripname '' '.exe' "$output" 90276aec45a7Smrg output=$func_stripname_result ;; 90286aec45a7Smrg esac 90296aec45a7Smrg # test for cygwin because mv fails w/o .exe extensions 90306aec45a7Smrg case $host in 90316aec45a7Smrg *cygwin*) 90326aec45a7Smrg exeext=.exe 90336aec45a7Smrg func_stripname '' '.exe' "$outputname" 90346aec45a7Smrg outputname=$func_stripname_result ;; 90356aec45a7Smrg *) exeext= ;; 9036ab47cfaaSmrg esac 90376aec45a7Smrg case $host in 90386aec45a7Smrg *cygwin* | *mingw* ) 90396aec45a7Smrg func_dirname_and_basename "$output" "" "." 90406aec45a7Smrg output_name=$func_basename_result 90416aec45a7Smrg output_path=$func_dirname_result 90426aec45a7Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 90436aec45a7Smrg cwrapper="$output_path/$output_name.exe" 90446aec45a7Smrg $RM $cwrappersource $cwrapper 90456aec45a7Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 90466aec45a7Smrg 90476aec45a7Smrg func_emit_cwrapperexe_src > $cwrappersource 90486aec45a7Smrg 90496aec45a7Smrg # The wrapper executable is built using the $host compiler, 90506aec45a7Smrg # because it contains $host paths and files. If cross- 90516aec45a7Smrg # compiling, it, like the target executable, must be 90526aec45a7Smrg # executed on the $host or under an emulation environment. 90536aec45a7Smrg $opt_dry_run || { 90546aec45a7Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 90556aec45a7Smrg $STRIP $cwrapper 90566aec45a7Smrg } 9057ab47cfaaSmrg 90586aec45a7Smrg # Now, create the wrapper script for func_source use: 90596aec45a7Smrg func_ltwrapper_scriptname $cwrapper 90606aec45a7Smrg $RM $func_ltwrapper_scriptname_result 90616aec45a7Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 90626aec45a7Smrg $opt_dry_run || { 90636aec45a7Smrg # note: this script will not be executed, so do not chmod. 90646aec45a7Smrg if test "x$build" = "x$host" ; then 90656aec45a7Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 90666aec45a7Smrg else 90676aec45a7Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 90686aec45a7Smrg fi 90696aec45a7Smrg } 90706aec45a7Smrg ;; 90716aec45a7Smrg * ) 90726aec45a7Smrg $RM $output 90736aec45a7Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9074ab47cfaaSmrg 90756aec45a7Smrg func_emit_wrapper no > $output 90766aec45a7Smrg chmod +x $output 90776aec45a7Smrg ;; 90786aec45a7Smrg esac 90796aec45a7Smrg } 90806aec45a7Smrg exit $EXIT_SUCCESS 90816aec45a7Smrg ;; 90826aec45a7Smrg esac 9083ab47cfaaSmrg 90846aec45a7Smrg # See if we need to build an old-fashioned archive. 90856aec45a7Smrg for oldlib in $oldlibs; do 9086ab47cfaaSmrg 90876aec45a7Smrg if test "$build_libtool_libs" = convenience; then 90886aec45a7Smrg oldobjs="$libobjs_save $symfileobj" 90896aec45a7Smrg addlibs="$convenience" 90906aec45a7Smrg build_libtool_libs=no 90916aec45a7Smrg else 90926aec45a7Smrg if test "$build_libtool_libs" = module; then 90936aec45a7Smrg oldobjs="$libobjs_save" 90946aec45a7Smrg build_libtool_libs=no 90956aec45a7Smrg else 90966aec45a7Smrg oldobjs="$old_deplibs $non_pic_objects" 90976aec45a7Smrg if test "$preload" = yes && test -f "$symfileobj"; then 9098aa9e3350Smrg func_append oldobjs " $symfileobj" 90996aec45a7Smrg fi 91006aec45a7Smrg fi 91016aec45a7Smrg addlibs="$old_convenience" 9102ab47cfaaSmrg fi 9103ab47cfaaSmrg 91046aec45a7Smrg if test -n "$addlibs"; then 91056aec45a7Smrg gentop="$output_objdir/${outputname}x" 9106aa9e3350Smrg func_append generated " $gentop" 9107ab47cfaaSmrg 91086aec45a7Smrg func_extract_archives $gentop $addlibs 9109aa9e3350Smrg func_append oldobjs " $func_extract_archives_result" 91106aec45a7Smrg fi 9111ab47cfaaSmrg 91126aec45a7Smrg # Do each command in the archive commands. 91136aec45a7Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 91146aec45a7Smrg cmds=$old_archive_from_new_cmds 91156aec45a7Smrg else 9116ab47cfaaSmrg 91176aec45a7Smrg # Add any objects from preloaded convenience libraries 91186aec45a7Smrg if test -n "$dlprefiles"; then 91196aec45a7Smrg gentop="$output_objdir/${outputname}x" 9120aa9e3350Smrg func_append generated " $gentop" 9121ab47cfaaSmrg 91226aec45a7Smrg func_extract_archives $gentop $dlprefiles 9123aa9e3350Smrg func_append oldobjs " $func_extract_archives_result" 91246aec45a7Smrg fi 9125ab47cfaaSmrg 91266aec45a7Smrg # POSIX demands no paths to be encoded in archives. We have 91276aec45a7Smrg # to avoid creating archives with duplicate basenames if we 91286aec45a7Smrg # might have to extract them afterwards, e.g., when creating a 91296aec45a7Smrg # static archive out of a convenience library, or when linking 91306aec45a7Smrg # the entirety of a libtool archive into another (currently 91316aec45a7Smrg # not supported by libtool). 91326aec45a7Smrg if (for obj in $oldobjs 91336aec45a7Smrg do 91346aec45a7Smrg func_basename "$obj" 91356aec45a7Smrg $ECHO "$func_basename_result" 91366aec45a7Smrg done | sort | sort -uc >/dev/null 2>&1); then 91376aec45a7Smrg : 91386aec45a7Smrg else 91396aec45a7Smrg echo "copying selected object files to avoid basename conflicts..." 91406aec45a7Smrg gentop="$output_objdir/${outputname}x" 9141aa9e3350Smrg func_append generated " $gentop" 91426aec45a7Smrg func_mkdir_p "$gentop" 91436aec45a7Smrg save_oldobjs=$oldobjs 91446aec45a7Smrg oldobjs= 91456aec45a7Smrg counter=1 91466aec45a7Smrg for obj in $save_oldobjs 91476aec45a7Smrg do 91486aec45a7Smrg func_basename "$obj" 91496aec45a7Smrg objbase="$func_basename_result" 91506aec45a7Smrg case " $oldobjs " in 91516aec45a7Smrg " ") oldobjs=$obj ;; 91526aec45a7Smrg *[\ /]"$objbase "*) 91536aec45a7Smrg while :; do 91546aec45a7Smrg # Make sure we don't pick an alternate name that also 91556aec45a7Smrg # overlaps. 91566aec45a7Smrg newobj=lt$counter-$objbase 91576aec45a7Smrg func_arith $counter + 1 91586aec45a7Smrg counter=$func_arith_result 91596aec45a7Smrg case " $oldobjs " in 91606aec45a7Smrg *[\ /]"$newobj "*) ;; 91616aec45a7Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 91626aec45a7Smrg esac 91636aec45a7Smrg done 91646aec45a7Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 9165aa9e3350Smrg func_append oldobjs " $gentop/$newobj" 91666aec45a7Smrg ;; 9167aa9e3350Smrg *) func_append oldobjs " $obj" ;; 91686aec45a7Smrg esac 9169ab47cfaaSmrg done 91701473d951Smrg fi 9171aa9e3350Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 9172aa9e3350Smrg tool_oldlib=$func_to_tool_file_result 91736aec45a7Smrg eval cmds=\"$old_archive_cmds\" 91745c42550eSmrg 91756aec45a7Smrg func_len " $cmds" 91766aec45a7Smrg len=$func_len_result 91776aec45a7Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 91786aec45a7Smrg cmds=$old_archive_cmds 9179aa9e3350Smrg elif test -n "$archiver_list_spec"; then 9180aa9e3350Smrg func_verbose "using command file archive linking..." 9181aa9e3350Smrg for obj in $oldobjs 9182aa9e3350Smrg do 9183aa9e3350Smrg func_to_tool_file "$obj" 9184aa9e3350Smrg $ECHO "$func_to_tool_file_result" 9185aa9e3350Smrg done > $output_objdir/$libname.libcmd 9186aa9e3350Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 9187aa9e3350Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 9188aa9e3350Smrg cmds=$old_archive_cmds 91896aec45a7Smrg else 91906aec45a7Smrg # the command line is too long to link in one step, link in parts 91916aec45a7Smrg func_verbose "using piecewise archive linking..." 91926aec45a7Smrg save_RANLIB=$RANLIB 91936aec45a7Smrg RANLIB=: 91946aec45a7Smrg objlist= 91956aec45a7Smrg concat_cmds= 91966aec45a7Smrg save_oldobjs=$oldobjs 91976aec45a7Smrg oldobjs= 91986aec45a7Smrg # Is there a better way of finding the last object in the list? 91996aec45a7Smrg for obj in $save_oldobjs 92006aec45a7Smrg do 92016aec45a7Smrg last_oldobj=$obj 92026aec45a7Smrg done 92036aec45a7Smrg eval test_cmds=\"$old_archive_cmds\" 92046aec45a7Smrg func_len " $test_cmds" 92056aec45a7Smrg len0=$func_len_result 92066aec45a7Smrg len=$len0 92076aec45a7Smrg for obj in $save_oldobjs 92086aec45a7Smrg do 92096aec45a7Smrg func_len " $obj" 92106aec45a7Smrg func_arith $len + $func_len_result 92116aec45a7Smrg len=$func_arith_result 92126aec45a7Smrg func_append objlist " $obj" 92136aec45a7Smrg if test "$len" -lt "$max_cmd_len"; then 92146aec45a7Smrg : 92156aec45a7Smrg else 92166aec45a7Smrg # the above command should be used before it gets too long 92176aec45a7Smrg oldobjs=$objlist 92186aec45a7Smrg if test "$obj" = "$last_oldobj" ; then 92196aec45a7Smrg RANLIB=$save_RANLIB 92206aec45a7Smrg fi 92216aec45a7Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 92226aec45a7Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 92236aec45a7Smrg objlist= 92246aec45a7Smrg len=$len0 92256aec45a7Smrg fi 92266aec45a7Smrg done 92276aec45a7Smrg RANLIB=$save_RANLIB 92286aec45a7Smrg oldobjs=$objlist 92296aec45a7Smrg if test "X$oldobjs" = "X" ; then 92306aec45a7Smrg eval cmds=\"\$concat_cmds\" 92316aec45a7Smrg else 92326aec45a7Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 92336aec45a7Smrg fi 92346aec45a7Smrg fi 92356aec45a7Smrg fi 92366aec45a7Smrg func_execute_cmds "$cmds" 'exit $?' 9237ab47cfaaSmrg done 9238ab47cfaaSmrg 92396aec45a7Smrg test -n "$generated" && \ 92406aec45a7Smrg func_show_eval "${RM}r$generated" 9241ab47cfaaSmrg 92426aec45a7Smrg # Now create the libtool archive. 92436aec45a7Smrg case $output in 92446aec45a7Smrg *.la) 92456aec45a7Smrg old_library= 92466aec45a7Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 92476aec45a7Smrg func_verbose "creating $output" 92481473d951Smrg 92496aec45a7Smrg # Preserve any variables that may affect compiler behavior 92506aec45a7Smrg for var in $variables_saved_for_relink; do 92516aec45a7Smrg if eval test -z \"\${$var+set}\"; then 92526aec45a7Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 92536aec45a7Smrg elif eval var_value=\$$var; test -z "$var_value"; then 92546aec45a7Smrg relink_command="$var=; export $var; $relink_command" 92555c42550eSmrg else 92566aec45a7Smrg func_quote_for_eval "$var_value" 92576aec45a7Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 92585c42550eSmrg fi 92596aec45a7Smrg done 92606aec45a7Smrg # Quote the link command for shipping. 92616aec45a7Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 92626aec45a7Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 92636aec45a7Smrg if test "$hardcode_automatic" = yes ; then 92646aec45a7Smrg relink_command= 92656aec45a7Smrg fi 9266ab47cfaaSmrg 92676aec45a7Smrg # Only create the output if not a dry run. 92686aec45a7Smrg $opt_dry_run || { 92696aec45a7Smrg for installed in no yes; do 92706aec45a7Smrg if test "$installed" = yes; then 92716aec45a7Smrg if test -z "$install_libdir"; then 92726aec45a7Smrg break 92736aec45a7Smrg fi 92746aec45a7Smrg output="$output_objdir/$outputname"i 92756aec45a7Smrg # Replace all uninstalled libtool libraries with the installed ones 92766aec45a7Smrg newdependency_libs= 92776aec45a7Smrg for deplib in $dependency_libs; do 92786aec45a7Smrg case $deplib in 92796aec45a7Smrg *.la) 92806aec45a7Smrg func_basename "$deplib" 92816aec45a7Smrg name="$func_basename_result" 9282aa9e3350Smrg func_resolve_sysroot "$deplib" 9283aa9e3350Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 92846aec45a7Smrg test -z "$libdir" && \ 92856aec45a7Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 9286aa9e3350Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 9287aa9e3350Smrg ;; 9288aa9e3350Smrg -L*) 9289aa9e3350Smrg func_stripname -L '' "$deplib" 9290aa9e3350Smrg func_replace_sysroot "$func_stripname_result" 9291aa9e3350Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 9292aa9e3350Smrg ;; 9293aa9e3350Smrg -R*) 9294aa9e3350Smrg func_stripname -R '' "$deplib" 9295aa9e3350Smrg func_replace_sysroot "$func_stripname_result" 9296aa9e3350Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 92976aec45a7Smrg ;; 9298aa9e3350Smrg *) func_append newdependency_libs " $deplib" ;; 92996aec45a7Smrg esac 93006aec45a7Smrg done 93016aec45a7Smrg dependency_libs="$newdependency_libs" 93026aec45a7Smrg newdlfiles= 93036aec45a7Smrg 93046aec45a7Smrg for lib in $dlfiles; do 93056aec45a7Smrg case $lib in 93066aec45a7Smrg *.la) 93076aec45a7Smrg func_basename "$lib" 93086aec45a7Smrg name="$func_basename_result" 93096aec45a7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 93106aec45a7Smrg test -z "$libdir" && \ 93116aec45a7Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 9312aa9e3350Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 93136aec45a7Smrg ;; 9314aa9e3350Smrg *) func_append newdlfiles " $lib" ;; 93156aec45a7Smrg esac 93166aec45a7Smrg done 93176aec45a7Smrg dlfiles="$newdlfiles" 93186aec45a7Smrg newdlprefiles= 93196aec45a7Smrg for lib in $dlprefiles; do 93206aec45a7Smrg case $lib in 93216aec45a7Smrg *.la) 93226aec45a7Smrg # Only pass preopened files to the pseudo-archive (for 93236aec45a7Smrg # eventual linking with the app. that links it) if we 93246aec45a7Smrg # didn't already link the preopened objects directly into 93256aec45a7Smrg # the library: 93266aec45a7Smrg func_basename "$lib" 93276aec45a7Smrg name="$func_basename_result" 93286aec45a7Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 93296aec45a7Smrg test -z "$libdir" && \ 93306aec45a7Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 9331aa9e3350Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 93326aec45a7Smrg ;; 93336aec45a7Smrg esac 93346aec45a7Smrg done 93356aec45a7Smrg dlprefiles="$newdlprefiles" 93366aec45a7Smrg else 93376aec45a7Smrg newdlfiles= 93386aec45a7Smrg for lib in $dlfiles; do 93396aec45a7Smrg case $lib in 93406aec45a7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 93416aec45a7Smrg *) abs=`pwd`"/$lib" ;; 93426aec45a7Smrg esac 9343aa9e3350Smrg func_append newdlfiles " $abs" 93446aec45a7Smrg done 93456aec45a7Smrg dlfiles="$newdlfiles" 93466aec45a7Smrg newdlprefiles= 93476aec45a7Smrg for lib in $dlprefiles; do 93486aec45a7Smrg case $lib in 93496aec45a7Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 93506aec45a7Smrg *) abs=`pwd`"/$lib" ;; 93516aec45a7Smrg esac 9352aa9e3350Smrg func_append newdlprefiles " $abs" 93536aec45a7Smrg done 93546aec45a7Smrg dlprefiles="$newdlprefiles" 93556aec45a7Smrg fi 93566aec45a7Smrg $RM $output 93576aec45a7Smrg # place dlname in correct position for cygwin 93586aec45a7Smrg # In fact, it would be nice if we could use this code for all target 93596aec45a7Smrg # systems that can't hard-code library paths into their executables 93606aec45a7Smrg # and that have no shared library path variable independent of PATH, 93616aec45a7Smrg # but it turns out we can't easily determine that from inspecting 93626aec45a7Smrg # libtool variables, so we have to hard-code the OSs to which it 93636aec45a7Smrg # applies here; at the moment, that means platforms that use the PE 93646aec45a7Smrg # object format with DLL files. See the long comment at the top of 93656aec45a7Smrg # tests/bindir.at for full details. 93666aec45a7Smrg tdlname=$dlname 93676aec45a7Smrg case $host,$output,$installed,$module,$dlname in 93686aec45a7Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 93696aec45a7Smrg # If a -bindir argument was supplied, place the dll there. 93706aec45a7Smrg if test "x$bindir" != x ; 93716aec45a7Smrg then 93726aec45a7Smrg func_relative_path "$install_libdir" "$bindir" 93736aec45a7Smrg tdlname=$func_relative_path_result$dlname 93746aec45a7Smrg else 93756aec45a7Smrg # Otherwise fall back on heuristic. 93766aec45a7Smrg tdlname=../bin/$dlname 93776aec45a7Smrg fi 93786aec45a7Smrg ;; 93796aec45a7Smrg esac 93806aec45a7Smrg $ECHO > $output "\ 93816aec45a7Smrg# $outputname - a libtool library file 93826aec45a7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 93836aec45a7Smrg# 93846aec45a7Smrg# Please DO NOT delete this file! 93856aec45a7Smrg# It is necessary for linking the library. 9386ab47cfaaSmrg 93876aec45a7Smrg# The name that we can dlopen(3). 93886aec45a7Smrgdlname='$tdlname' 9389ab47cfaaSmrg 93906aec45a7Smrg# Names of this library. 93916aec45a7Smrglibrary_names='$library_names' 9392ab47cfaaSmrg 93936aec45a7Smrg# The name of the static archive. 93946aec45a7Smrgold_library='$old_library' 9395ab47cfaaSmrg 93966aec45a7Smrg# Linker flags that can not go in dependency_libs. 93976aec45a7Smrginherited_linker_flags='$new_inherited_linker_flags' 9398ab47cfaaSmrg 93996aec45a7Smrg# Libraries that this one depends upon. 94006aec45a7Smrgdependency_libs='$dependency_libs' 9401ab47cfaaSmrg 94026aec45a7Smrg# Names of additional weak libraries provided by this library 94036aec45a7Smrgweak_library_names='$weak_libs' 9404ab47cfaaSmrg 94056aec45a7Smrg# Version information for $libname. 94066aec45a7Smrgcurrent=$current 94076aec45a7Smrgage=$age 94086aec45a7Smrgrevision=$revision 9409ab47cfaaSmrg 94106aec45a7Smrg# Is this an already installed library? 94116aec45a7Smrginstalled=$installed 9412ab47cfaaSmrg 94136aec45a7Smrg# Should we warn about portability when linking against -modules? 94146aec45a7Smrgshouldnotlink=$module 9415ab47cfaaSmrg 94166aec45a7Smrg# Files to dlopen/dlpreopen 94176aec45a7Smrgdlopen='$dlfiles' 94186aec45a7Smrgdlpreopen='$dlprefiles' 9419ab47cfaaSmrg 94206aec45a7Smrg# Directory that this library needs to be installed in: 94216aec45a7Smrglibdir='$install_libdir'" 94226aec45a7Smrg if test "$installed" = no && test "$need_relink" = yes; then 94236aec45a7Smrg $ECHO >> $output "\ 94246aec45a7Smrgrelink_command=\"$relink_command\"" 94256aec45a7Smrg fi 94266aec45a7Smrg done 94276aec45a7Smrg } 9428ab47cfaaSmrg 94296aec45a7Smrg # Do a symbolic link so that the libtool archive can be found in 94306aec45a7Smrg # LD_LIBRARY_PATH before the program is installed. 94316aec45a7Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 94326aec45a7Smrg ;; 94336aec45a7Smrg esac 94346aec45a7Smrg exit $EXIT_SUCCESS 94356aec45a7Smrg} 94365c42550eSmrg 9437aa9e3350Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 94386aec45a7Smrg func_mode_link ${1+"$@"} 9439ab47cfaaSmrg 9440ab47cfaaSmrg 94416aec45a7Smrg# func_mode_uninstall arg... 94426aec45a7Smrgfunc_mode_uninstall () 94436aec45a7Smrg{ 94446aec45a7Smrg $opt_debug 94456aec45a7Smrg RM="$nonopt" 9446ab47cfaaSmrg files= 9447ab47cfaaSmrg rmforce= 9448ab47cfaaSmrg exit_status=0 9449ab47cfaaSmrg 9450ab47cfaaSmrg # This variable tells wrapper scripts just to set variables rather 9451ab47cfaaSmrg # than running their programs. 9452ab47cfaaSmrg libtool_install_magic="$magic" 9453ab47cfaaSmrg 9454ab47cfaaSmrg for arg 9455ab47cfaaSmrg do 9456ab47cfaaSmrg case $arg in 9457aa9e3350Smrg -f) func_append RM " $arg"; rmforce=yes ;; 9458aa9e3350Smrg -*) func_append RM " $arg" ;; 9459aa9e3350Smrg *) func_append files " $arg" ;; 9460ab47cfaaSmrg esac 9461ab47cfaaSmrg done 9462ab47cfaaSmrg 94636aec45a7Smrg test -z "$RM" && \ 94646aec45a7Smrg func_fatal_help "you must specify an RM program" 9465ab47cfaaSmrg 9466ab47cfaaSmrg rmdirs= 9467ab47cfaaSmrg 9468ab47cfaaSmrg for file in $files; do 94696aec45a7Smrg func_dirname "$file" "" "." 94706aec45a7Smrg dir="$func_dirname_result" 94716aec45a7Smrg if test "X$dir" = X.; then 9472aa9e3350Smrg odir="$objdir" 9473ab47cfaaSmrg else 9474aa9e3350Smrg odir="$dir/$objdir" 9475ab47cfaaSmrg fi 94766aec45a7Smrg func_basename "$file" 94776aec45a7Smrg name="$func_basename_result" 9478aa9e3350Smrg test "$opt_mode" = uninstall && odir="$dir" 9479ab47cfaaSmrg 9480aa9e3350Smrg # Remember odir for removal later, being careful to avoid duplicates 9481aa9e3350Smrg if test "$opt_mode" = clean; then 9482ab47cfaaSmrg case " $rmdirs " in 9483aa9e3350Smrg *" $odir "*) ;; 9484aa9e3350Smrg *) func_append rmdirs " $odir" ;; 9485ab47cfaaSmrg esac 9486ab47cfaaSmrg fi 9487ab47cfaaSmrg 9488ab47cfaaSmrg # Don't error if the file doesn't exist and rm -f was used. 94896aec45a7Smrg if { test -L "$file"; } >/dev/null 2>&1 || 94906aec45a7Smrg { test -h "$file"; } >/dev/null 2>&1 || 94916aec45a7Smrg test -f "$file"; then 9492ab47cfaaSmrg : 9493ab47cfaaSmrg elif test -d "$file"; then 9494ab47cfaaSmrg exit_status=1 9495ab47cfaaSmrg continue 9496ab47cfaaSmrg elif test "$rmforce" = yes; then 9497ab47cfaaSmrg continue 9498ab47cfaaSmrg fi 9499ab47cfaaSmrg 9500ab47cfaaSmrg rmfiles="$file" 9501ab47cfaaSmrg 9502ab47cfaaSmrg case $name in 9503ab47cfaaSmrg *.la) 9504ab47cfaaSmrg # Possibly a libtool archive, so verify it. 95056aec45a7Smrg if func_lalib_p "$file"; then 95066aec45a7Smrg func_source $dir/$name 9507ab47cfaaSmrg 9508ab47cfaaSmrg # Delete the libtool libraries and symlinks. 9509ab47cfaaSmrg for n in $library_names; do 9510aa9e3350Smrg func_append rmfiles " $odir/$n" 9511ab47cfaaSmrg done 9512aa9e3350Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9513ab47cfaaSmrg 9514aa9e3350Smrg case "$opt_mode" in 9515ab47cfaaSmrg clean) 9516aa9e3350Smrg case " $library_names " in 9517ab47cfaaSmrg *" $dlname "*) ;; 9518aa9e3350Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9519ab47cfaaSmrg esac 9520aa9e3350Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9521ab47cfaaSmrg ;; 9522ab47cfaaSmrg uninstall) 9523ab47cfaaSmrg if test -n "$library_names"; then 9524ab47cfaaSmrg # Do each command in the postuninstall commands. 95256aec45a7Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9526ab47cfaaSmrg fi 9527ab47cfaaSmrg 9528ab47cfaaSmrg if test -n "$old_library"; then 9529ab47cfaaSmrg # Do each command in the old_postuninstall commands. 95306aec45a7Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9531ab47cfaaSmrg fi 9532ab47cfaaSmrg # FIXME: should reinstall the best remaining shared library. 9533ab47cfaaSmrg ;; 9534ab47cfaaSmrg esac 9535ab47cfaaSmrg fi 9536ab47cfaaSmrg ;; 9537ab47cfaaSmrg 9538ab47cfaaSmrg *.lo) 9539ab47cfaaSmrg # Possibly a libtool object, so verify it. 95406aec45a7Smrg if func_lalib_p "$file"; then 9541ab47cfaaSmrg 9542ab47cfaaSmrg # Read the .lo file 95436aec45a7Smrg func_source $dir/$name 9544ab47cfaaSmrg 9545ab47cfaaSmrg # Add PIC object to the list of files to remove. 95466aec45a7Smrg if test -n "$pic_object" && 95476aec45a7Smrg test "$pic_object" != none; then 9548aa9e3350Smrg func_append rmfiles " $dir/$pic_object" 9549ab47cfaaSmrg fi 9550ab47cfaaSmrg 9551ab47cfaaSmrg # Add non-PIC object to the list of files to remove. 95526aec45a7Smrg if test -n "$non_pic_object" && 95536aec45a7Smrg test "$non_pic_object" != none; then 9554aa9e3350Smrg func_append rmfiles " $dir/$non_pic_object" 9555ab47cfaaSmrg fi 9556ab47cfaaSmrg fi 9557ab47cfaaSmrg ;; 9558ab47cfaaSmrg 9559ab47cfaaSmrg *) 9560aa9e3350Smrg if test "$opt_mode" = clean ; then 9561ab47cfaaSmrg noexename=$name 9562ab47cfaaSmrg case $file in 9563ab47cfaaSmrg *.exe) 95646aec45a7Smrg func_stripname '' '.exe' "$file" 95656aec45a7Smrg file=$func_stripname_result 95666aec45a7Smrg func_stripname '' '.exe' "$name" 95676aec45a7Smrg noexename=$func_stripname_result 9568ab47cfaaSmrg # $file with .exe has already been added to rmfiles, 9569ab47cfaaSmrg # add $file without .exe 9570aa9e3350Smrg func_append rmfiles " $file" 9571ab47cfaaSmrg ;; 9572ab47cfaaSmrg esac 9573ab47cfaaSmrg # Do a test to see if this is a libtool program. 95746aec45a7Smrg if func_ltwrapper_p "$file"; then 95756aec45a7Smrg if func_ltwrapper_executable_p "$file"; then 95766aec45a7Smrg func_ltwrapper_scriptname "$file" 95776aec45a7Smrg relink_command= 95786aec45a7Smrg func_source $func_ltwrapper_scriptname_result 9579aa9e3350Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 95806aec45a7Smrg else 95816aec45a7Smrg relink_command= 95826aec45a7Smrg func_source $dir/$noexename 95836aec45a7Smrg fi 9584ab47cfaaSmrg 9585ab47cfaaSmrg # note $name still contains .exe if it was in $file originally 9586ab47cfaaSmrg # as does the version of $file that was added into $rmfiles 9587aa9e3350Smrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9588ab47cfaaSmrg if test "$fast_install" = yes && test -n "$relink_command"; then 9589aa9e3350Smrg func_append rmfiles " $odir/lt-$name" 9590ab47cfaaSmrg fi 9591ab47cfaaSmrg if test "X$noexename" != "X$name" ; then 9592aa9e3350Smrg func_append rmfiles " $odir/lt-${noexename}.c" 9593ab47cfaaSmrg fi 9594ab47cfaaSmrg fi 9595ab47cfaaSmrg fi 9596ab47cfaaSmrg ;; 9597ab47cfaaSmrg esac 95986aec45a7Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 9599ab47cfaaSmrg done 9600ab47cfaaSmrg 9601ab47cfaaSmrg # Try to remove the ${objdir}s in the directories where we deleted files 9602ab47cfaaSmrg for dir in $rmdirs; do 9603ab47cfaaSmrg if test -d "$dir"; then 96046aec45a7Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 9605ab47cfaaSmrg fi 9606ab47cfaaSmrg done 9607ab47cfaaSmrg 9608ab47cfaaSmrg exit $exit_status 96096aec45a7Smrg} 9610ab47cfaaSmrg 9611aa9e3350Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 96126aec45a7Smrg func_mode_uninstall ${1+"$@"} 96131473d951Smrg 9614aa9e3350Smrgtest -z "$opt_mode" && { 96156aec45a7Smrg help="$generic_help" 96166aec45a7Smrg func_fatal_help "you must specify a MODE" 96176aec45a7Smrg} 96186aec45a7Smrg 96196aec45a7Smrgtest -z "$exec_cmd" && \ 9620aa9e3350Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 9621ab47cfaaSmrg 9622ab47cfaaSmrgif test -n "$exec_cmd"; then 96236aec45a7Smrg eval exec "$exec_cmd" 9624ab47cfaaSmrg exit $EXIT_FAILURE 9625ab47cfaaSmrgfi 9626ab47cfaaSmrg 96276aec45a7Smrgexit $exit_status 96285c42550eSmrg 9629ab47cfaaSmrg 9630ab47cfaaSmrg# The TAGs below are defined such that we never get into a situation 9631ab47cfaaSmrg# in which we disable both kinds of libraries. Given conflicting 9632ab47cfaaSmrg# choices, we go for a static library, that is the most portable, 9633ab47cfaaSmrg# since we can't tell whether shared libraries were disabled because 9634ab47cfaaSmrg# the user asked for that or because the platform doesn't support 9635ab47cfaaSmrg# them. This is particularly important on AIX, because we don't 9636ab47cfaaSmrg# support having both static and shared libraries enabled at the same 9637ab47cfaaSmrg# time on that platform, so we default to a shared-only configuration. 9638ab47cfaaSmrg# If a disable-shared tag is given, we'll fallback to a static-only 9639ab47cfaaSmrg# configuration. But we'll never go from static-only to shared-only. 9640ab47cfaaSmrg 9641ab47cfaaSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 96426aec45a7Smrgbuild_libtool_libs=no 96436aec45a7Smrgbuild_old_libs=yes 9644ab47cfaaSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 9645ab47cfaaSmrg 9646ab47cfaaSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 96476aec45a7Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9648ab47cfaaSmrg# ### END LIBTOOL TAG CONFIG: disable-static 9649ab47cfaaSmrg 9650ab47cfaaSmrg# Local Variables: 9651ab47cfaaSmrg# mode:shell-script 9652ab47cfaaSmrg# sh-indentation:2 9653ab47cfaaSmrg# End: 96546aec45a7Smrg# vi:sw=2 96556aec45a7Smrg 9656