190b17f1bSmrg 2983b4bf2Smrg# libtool (GNU libtool) 2.4.2 390b17f1bSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 490b17f1bSmrg 5983b4bf2Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 6983b4bf2Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 790b17f1bSmrg# This is free software; see the source for copying conditions. There is NO 890b17f1bSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 990b17f1bSmrg 1090b17f1bSmrg# GNU Libtool is free software; you can redistribute it and/or modify 117e6fb56fSmrg# it under the terms of the GNU General Public License as published by 127e6fb56fSmrg# the Free Software Foundation; either version 2 of the License, or 137e6fb56fSmrg# (at your option) any later version. 147e6fb56fSmrg# 1590b17f1bSmrg# As a special exception to the GNU General Public License, 1690b17f1bSmrg# if you distribute this file as part of a program or library that 1790b17f1bSmrg# is built using GNU Libtool, you may include this file under the 1890b17f1bSmrg# same distribution terms that you use for the rest of that program. 1990b17f1bSmrg# 2090b17f1bSmrg# GNU Libtool is distributed in the hope that it will be useful, but 217e6fb56fSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 227e6fb56fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 237e6fb56fSmrg# General Public License for more details. 247e6fb56fSmrg# 257e6fb56fSmrg# You should have received a copy of the GNU General Public License 26983b4bf2Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 27983b4bf2Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 28983b4bf2Smrg# or obtained by writing to the Free Software Foundation, Inc., 29983b4bf2Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30963d66acSmrg 31983b4bf2Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 32983b4bf2Smrg# 33983b4bf2Smrg# Provide generalized library-building support services. 34963d66acSmrg# 35983b4bf2Smrg# --config show all configuration variables 36983b4bf2Smrg# --debug enable verbose shell tracing 37983b4bf2Smrg# -n, --dry-run display commands without modifying any files 38983b4bf2Smrg# --features display basic configuration information and exit 39983b4bf2Smrg# --mode=MODE use operation mode MODE 40983b4bf2Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 41983b4bf2Smrg# --quiet, --silent don't print informational messages 42983b4bf2Smrg# --no-quiet, --no-silent 43983b4bf2Smrg# print informational messages (default) 44983b4bf2Smrg# --no-warn don't display warning messages 45983b4bf2Smrg# --tag=TAG use configuration variables from tag TAG 46983b4bf2Smrg# -v, --verbose print more informational messages than default 47983b4bf2Smrg# --no-verbose don't print the extra informational messages 48983b4bf2Smrg# --version print version information 49983b4bf2Smrg# -h, --help, --help-all print short, long, or detailed help message 50963d66acSmrg# 51983b4bf2Smrg# MODE must be one of the following: 52983b4bf2Smrg# 53983b4bf2Smrg# clean remove files from the build directory 54983b4bf2Smrg# compile compile a source file into a libtool object 55983b4bf2Smrg# execute automatically set library path, then run a program 56983b4bf2Smrg# finish complete the installation of libtool libraries 57983b4bf2Smrg# install install libraries or executables 58983b4bf2Smrg# link create a library or an executable 59983b4bf2Smrg# uninstall remove libraries from an installed directory 60983b4bf2Smrg# 61983b4bf2Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 62983b4bf2Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 63983b4bf2Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 64983b4bf2Smrg# 65983b4bf2Smrg# When reporting a bug, please describe a test case to reproduce it and 66983b4bf2Smrg# include the following information: 67983b4bf2Smrg# 68983b4bf2Smrg# host-triplet: $host 69983b4bf2Smrg# shell: $SHELL 70983b4bf2Smrg# compiler: $LTCC 71983b4bf2Smrg# compiler flags: $LTCFLAGS 72983b4bf2Smrg# linker: $LD (gnu? $with_gnu_ld) 73983b4bf2Smrg# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 74983b4bf2Smrg# automake: $automake_version 75983b4bf2Smrg# autoconf: $autoconf_version 76983b4bf2Smrg# 77983b4bf2Smrg# Report bugs to <bug-libtool@gnu.org>. 78983b4bf2Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 79983b4bf2Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 80963d66acSmrg 81983b4bf2SmrgPROGRAM=libtool 82983b4bf2SmrgPACKAGE=libtool 83983b4bf2SmrgVERSION="2.4.2 Debian-2.4.2-1ubuntu1" 84983b4bf2SmrgTIMESTAMP="" 85983b4bf2Smrgpackage_revision=1.3337 86963d66acSmrg 87983b4bf2Smrg# Be Bourne compatible 88983b4bf2Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 897e6fb56fSmrg emulate sh 907e6fb56fSmrg NULLCMD=: 91983b4bf2Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 927e6fb56fSmrg # is contrary to our usage. Disable this feature. 937e6fb56fSmrg alias -g '${1+"$@"}'='"$@"' 947e6fb56fSmrg setopt NO_GLOB_SUBST 957e6fb56fSmrgelse 96983b4bf2Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 97963d66acSmrgfi 98983b4bf2SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 99983b4bf2SmrgDUALCASE=1; export DUALCASE # for MKS sh 10090b17f1bSmrg 101983b4bf2Smrg# A function that is used when there is no print builtin or printf. 102983b4bf2Smrgfunc_fallback_echo () 103963d66acSmrg{ 104983b4bf2Smrg eval 'cat <<_LTECHO_EOF 105983b4bf2Smrg$1 106983b4bf2Smrg_LTECHO_EOF' 107963d66acSmrg} 108963d66acSmrg 109983b4bf2Smrg# NLS nuisances: We save the old values to restore during execute mode. 110983b4bf2Smrglt_user_locale= 111983b4bf2Smrglt_safe_locale= 112983b4bf2Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 113983b4bf2Smrgdo 114983b4bf2Smrg eval "if test \"\${$lt_var+set}\" = set; then 115983b4bf2Smrg save_$lt_var=\$$lt_var 116983b4bf2Smrg $lt_var=C 117983b4bf2Smrg export $lt_var 118983b4bf2Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 119983b4bf2Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 120983b4bf2Smrg fi" 121983b4bf2Smrgdone 122983b4bf2SmrgLC_ALL=C 123983b4bf2SmrgLANGUAGE=C 124983b4bf2Smrgexport LANGUAGE LC_ALL 125963d66acSmrg 126983b4bf2Smrg$lt_unset CDPATH 127963d66acSmrg 128963d66acSmrg 129983b4bf2Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 130983b4bf2Smrg# is ksh but when the shell is invoked as "sh" and the current value of 131983b4bf2Smrg# the _XPG environment variable is not equal to 1 (one), the special 132983b4bf2Smrg# positional parameter $0, within a function call, is the name of the 133983b4bf2Smrg# function. 134983b4bf2Smrgprogpath="$0" 135963d66acSmrg 136963d66acSmrg 13790b17f1bSmrg 13890b17f1bSmrg: ${CP="cp -f"} 139983b4bf2Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 14090b17f1bSmrg: ${MAKE="make"} 14190b17f1bSmrg: ${MKDIR="mkdir"} 14290b17f1bSmrg: ${MV="mv -f"} 14390b17f1bSmrg: ${RM="rm -f"} 14490b17f1bSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 145983b4bf2Smrg: ${Xsed="$SED -e 1s/^X//"} 1467e6fb56fSmrg 147983b4bf2Smrg# Global variables: 148983b4bf2SmrgEXIT_SUCCESS=0 149983b4bf2SmrgEXIT_FAILURE=1 150983b4bf2SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 151983b4bf2SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 1527e6fb56fSmrg 153983b4bf2Smrgexit_status=$EXIT_SUCCESS 15490b17f1bSmrg 155983b4bf2Smrg# Make sure IFS has a sensible default 156983b4bf2Smrglt_nl=' 157983b4bf2Smrg' 158983b4bf2SmrgIFS=" $lt_nl" 15990b17f1bSmrg 160983b4bf2Smrgdirname="s,/[^/]*$,," 161983b4bf2Smrgbasename="s,^.*/,," 16290b17f1bSmrg 163983b4bf2Smrg# func_dirname file append nondir_replacement 164983b4bf2Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 165983b4bf2Smrg# otherwise set result to NONDIR_REPLACEMENT. 166983b4bf2Smrgfunc_dirname () 167983b4bf2Smrg{ 168983b4bf2Smrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 169983b4bf2Smrg if test "X$func_dirname_result" = "X${1}"; then 170983b4bf2Smrg func_dirname_result="${3}" 171983b4bf2Smrg else 172983b4bf2Smrg func_dirname_result="$func_dirname_result${2}" 173983b4bf2Smrg fi 174983b4bf2Smrg} # func_dirname may be replaced by extended shell implementation 17590b17f1bSmrg 17690b17f1bSmrg 177983b4bf2Smrg# func_basename file 178983b4bf2Smrgfunc_basename () 179983b4bf2Smrg{ 180983b4bf2Smrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 181983b4bf2Smrg} # func_basename may be replaced by extended shell implementation 18290b17f1bSmrg 18390b17f1bSmrg 184983b4bf2Smrg# func_dirname_and_basename file append nondir_replacement 185983b4bf2Smrg# perform func_basename and func_dirname in a single function 186983b4bf2Smrg# call: 187983b4bf2Smrg# dirname: Compute the dirname of FILE. If nonempty, 188983b4bf2Smrg# add APPEND to the result, otherwise set result 189983b4bf2Smrg# to NONDIR_REPLACEMENT. 190983b4bf2Smrg# value returned in "$func_dirname_result" 191983b4bf2Smrg# basename: Compute filename of FILE. 192983b4bf2Smrg# value retuned in "$func_basename_result" 193983b4bf2Smrg# Implementation must be kept synchronized with func_dirname 194983b4bf2Smrg# and func_basename. For efficiency, we do not delegate to 195983b4bf2Smrg# those functions but instead duplicate the functionality here. 196983b4bf2Smrgfunc_dirname_and_basename () 197983b4bf2Smrg{ 198983b4bf2Smrg # Extract subdirectory from the argument. 199983b4bf2Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 200983b4bf2Smrg if test "X$func_dirname_result" = "X${1}"; then 201983b4bf2Smrg func_dirname_result="${3}" 202983b4bf2Smrg else 203983b4bf2Smrg func_dirname_result="$func_dirname_result${2}" 204983b4bf2Smrg fi 205983b4bf2Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 206983b4bf2Smrg} # func_dirname_and_basename may be replaced by extended shell implementation 20790b17f1bSmrg 20890b17f1bSmrg 209983b4bf2Smrg# func_stripname prefix suffix name 210983b4bf2Smrg# strip PREFIX and SUFFIX off of NAME. 211983b4bf2Smrg# PREFIX and SUFFIX must not contain globbing or regex special 212983b4bf2Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 213983b4bf2Smrg# dot (in which case that matches only a dot). 214983b4bf2Smrg# func_strip_suffix prefix name 215983b4bf2Smrgfunc_stripname () 216983b4bf2Smrg{ 217983b4bf2Smrg case ${2} in 218983b4bf2Smrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 219983b4bf2Smrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 220983b4bf2Smrg esac 221983b4bf2Smrg} # func_stripname may be replaced by extended shell implementation 22290b17f1bSmrg 22390b17f1bSmrg 224983b4bf2Smrg# These SED scripts presuppose an absolute path with a trailing slash. 225983b4bf2Smrgpathcar='s,^/\([^/]*\).*$,\1,' 226983b4bf2Smrgpathcdr='s,^/[^/]*,,' 227983b4bf2Smrgremovedotparts=':dotsl 228983b4bf2Smrg s@/\./@/@g 229983b4bf2Smrg t dotsl 230983b4bf2Smrg s,/\.$,/,' 231983b4bf2Smrgcollapseslashes='s@/\{1,\}@/@g' 232983b4bf2Smrgfinalslash='s,/*$,/,' 23390b17f1bSmrg 234983b4bf2Smrg# func_normal_abspath PATH 235983b4bf2Smrg# Remove doubled-up and trailing slashes, "." path components, 236983b4bf2Smrg# and cancel out any ".." path components in PATH after making 237983b4bf2Smrg# it an absolute path. 238983b4bf2Smrg# value returned in "$func_normal_abspath_result" 239983b4bf2Smrgfunc_normal_abspath () 240983b4bf2Smrg{ 241983b4bf2Smrg # Start from root dir and reassemble the path. 242983b4bf2Smrg func_normal_abspath_result= 243983b4bf2Smrg func_normal_abspath_tpath=$1 244983b4bf2Smrg func_normal_abspath_altnamespace= 245983b4bf2Smrg case $func_normal_abspath_tpath in 246983b4bf2Smrg "") 247983b4bf2Smrg # Empty path, that just means $cwd. 248983b4bf2Smrg func_stripname '' '/' "`pwd`" 249983b4bf2Smrg func_normal_abspath_result=$func_stripname_result 250983b4bf2Smrg return 251983b4bf2Smrg ;; 252983b4bf2Smrg # The next three entries are used to spot a run of precisely 253983b4bf2Smrg # two leading slashes without using negated character classes; 254983b4bf2Smrg # we take advantage of case's first-match behaviour. 255983b4bf2Smrg ///*) 256983b4bf2Smrg # Unusual form of absolute path, do nothing. 257983b4bf2Smrg ;; 258983b4bf2Smrg //*) 259983b4bf2Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 260983b4bf2Smrg # and for example Cygwin uses it to access remote file shares 261983b4bf2Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 262983b4bf2Smrg func_normal_abspath_altnamespace=/ 263983b4bf2Smrg ;; 264983b4bf2Smrg /*) 265983b4bf2Smrg # Absolute path, do nothing. 266983b4bf2Smrg ;; 267983b4bf2Smrg *) 268983b4bf2Smrg # Relative path, prepend $cwd. 269983b4bf2Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 270983b4bf2Smrg ;; 271983b4bf2Smrg esac 272983b4bf2Smrg # Cancel out all the simple stuff to save iterations. We also want 273983b4bf2Smrg # the path to end with a slash for ease of parsing, so make sure 274983b4bf2Smrg # there is one (and only one) here. 275983b4bf2Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 276983b4bf2Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 277983b4bf2Smrg while :; do 278983b4bf2Smrg # Processed it all yet? 279983b4bf2Smrg if test "$func_normal_abspath_tpath" = / ; then 280983b4bf2Smrg # If we ascended to the root using ".." the result may be empty now. 281983b4bf2Smrg if test -z "$func_normal_abspath_result" ; then 282983b4bf2Smrg func_normal_abspath_result=/ 283983b4bf2Smrg fi 284983b4bf2Smrg break 285983b4bf2Smrg fi 286983b4bf2Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 287983b4bf2Smrg -e "$pathcar"` 288983b4bf2Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 289983b4bf2Smrg -e "$pathcdr"` 290983b4bf2Smrg # Figure out what to do with it 291983b4bf2Smrg case $func_normal_abspath_tcomponent in 292983b4bf2Smrg "") 293983b4bf2Smrg # Trailing empty path component, ignore it. 294983b4bf2Smrg ;; 295983b4bf2Smrg ..) 296983b4bf2Smrg # Parent dir; strip last assembled component from result. 297983b4bf2Smrg func_dirname "$func_normal_abspath_result" 298983b4bf2Smrg func_normal_abspath_result=$func_dirname_result 299983b4bf2Smrg ;; 300983b4bf2Smrg *) 301983b4bf2Smrg # Actual path component, append it. 302983b4bf2Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 303983b4bf2Smrg ;; 304983b4bf2Smrg esac 305983b4bf2Smrg done 306983b4bf2Smrg # Restore leading double-slash if one was found on entry. 307983b4bf2Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 308983b4bf2Smrg} 309983b4bf2Smrg 310983b4bf2Smrg# func_relative_path SRCDIR DSTDIR 311983b4bf2Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 312983b4bf2Smrg# slash if non-empty, suitable for immediately appending a filename 313983b4bf2Smrg# without needing to append a separator. 314983b4bf2Smrg# value returned in "$func_relative_path_result" 315983b4bf2Smrgfunc_relative_path () 316983b4bf2Smrg{ 317983b4bf2Smrg func_relative_path_result= 318983b4bf2Smrg func_normal_abspath "$1" 319983b4bf2Smrg func_relative_path_tlibdir=$func_normal_abspath_result 320983b4bf2Smrg func_normal_abspath "$2" 321983b4bf2Smrg func_relative_path_tbindir=$func_normal_abspath_result 322983b4bf2Smrg 323983b4bf2Smrg # Ascend the tree starting from libdir 324983b4bf2Smrg while :; do 325983b4bf2Smrg # check if we have found a prefix of bindir 326983b4bf2Smrg case $func_relative_path_tbindir in 327983b4bf2Smrg $func_relative_path_tlibdir) 328983b4bf2Smrg # found an exact match 329983b4bf2Smrg func_relative_path_tcancelled= 330983b4bf2Smrg break 331983b4bf2Smrg ;; 332983b4bf2Smrg $func_relative_path_tlibdir*) 333983b4bf2Smrg # found a matching prefix 334983b4bf2Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 335983b4bf2Smrg func_relative_path_tcancelled=$func_stripname_result 336983b4bf2Smrg if test -z "$func_relative_path_result"; then 337983b4bf2Smrg func_relative_path_result=. 338983b4bf2Smrg fi 339983b4bf2Smrg break 340983b4bf2Smrg ;; 341983b4bf2Smrg *) 342983b4bf2Smrg func_dirname $func_relative_path_tlibdir 343983b4bf2Smrg func_relative_path_tlibdir=${func_dirname_result} 344983b4bf2Smrg if test "x$func_relative_path_tlibdir" = x ; then 345983b4bf2Smrg # Have to descend all the way to the root! 346983b4bf2Smrg func_relative_path_result=../$func_relative_path_result 347983b4bf2Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 348983b4bf2Smrg break 349983b4bf2Smrg fi 350983b4bf2Smrg func_relative_path_result=../$func_relative_path_result 351983b4bf2Smrg ;; 352983b4bf2Smrg esac 353983b4bf2Smrg done 354983b4bf2Smrg 355983b4bf2Smrg # Now calculate path; take care to avoid doubling-up slashes. 356983b4bf2Smrg func_stripname '' '/' "$func_relative_path_result" 357983b4bf2Smrg func_relative_path_result=$func_stripname_result 358983b4bf2Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 359983b4bf2Smrg if test "x$func_stripname_result" != x ; then 360983b4bf2Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 361983b4bf2Smrg fi 362983b4bf2Smrg 363983b4bf2Smrg # Normalisation. If bindir is libdir, return empty string, 364983b4bf2Smrg # else relative path ending with a slash; either way, target 365983b4bf2Smrg # file name can be directly appended. 366983b4bf2Smrg if test ! -z "$func_relative_path_result"; then 367983b4bf2Smrg func_stripname './' '' "$func_relative_path_result/" 368983b4bf2Smrg func_relative_path_result=$func_stripname_result 369983b4bf2Smrg fi 370983b4bf2Smrg} 37190b17f1bSmrg 372983b4bf2Smrg# The name of this program: 373983b4bf2Smrgfunc_dirname_and_basename "$progpath" 374983b4bf2Smrgprogname=$func_basename_result 37590b17f1bSmrg 376983b4bf2Smrg# Make sure we have an absolute path for reexecution: 37790b17f1bSmrgcase $progpath in 37890b17f1bSmrg [\\/]*|[A-Za-z]:\\*) ;; 37990b17f1bSmrg *[\\/]*) 380983b4bf2Smrg progdir=$func_dirname_result 38190b17f1bSmrg progdir=`cd "$progdir" && pwd` 382983b4bf2Smrg progpath="$progdir/$progname" 38390b17f1bSmrg ;; 38490b17f1bSmrg *) 385983b4bf2Smrg save_IFS="$IFS" 38690b17f1bSmrg IFS=${PATH_SEPARATOR-:} 38790b17f1bSmrg for progdir in $PATH; do 388983b4bf2Smrg IFS="$save_IFS" 38990b17f1bSmrg test -x "$progdir/$progname" && break 39090b17f1bSmrg done 391983b4bf2Smrg IFS="$save_IFS" 39290b17f1bSmrg test -n "$progdir" || progdir=`pwd` 393983b4bf2Smrg progpath="$progdir/$progname" 39490b17f1bSmrg ;; 39590b17f1bSmrgesac 39690b17f1bSmrg 397983b4bf2Smrg# Sed substitution that helps us do robust quoting. It backslashifies 398983b4bf2Smrg# metacharacters that are still active within double-quoted strings. 399983b4bf2SmrgXsed="${SED}"' -e 1s/^X//' 400983b4bf2Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 401983b4bf2Smrg 402983b4bf2Smrg# Same as above, but do not quote variable references. 403983b4bf2Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 40490b17f1bSmrg 405983b4bf2Smrg# Sed substitution that turns a string into a regex matching for the 406983b4bf2Smrg# string literally. 407983b4bf2Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 40890b17f1bSmrg 409983b4bf2Smrg# Sed substitution that converts a w32 file name or path 410983b4bf2Smrg# which contains forward slashes, into one that contains 411983b4bf2Smrg# (escaped) backslashes. A very naive implementation. 412983b4bf2Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 413983b4bf2Smrg 414983b4bf2Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 415983b4bf2Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 416983b4bf2Smrg# in input to double_quote_subst, that '$' was protected from expansion. 417983b4bf2Smrg# Since each input `\' is now two `\'s, look for any number of runs of 418983b4bf2Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 419983b4bf2Smrgbs='\\' 420983b4bf2Smrgbs2='\\\\' 421983b4bf2Smrgbs4='\\\\\\\\' 422983b4bf2Smrgdollar='\$' 423983b4bf2Smrgsed_double_backslash="\ 424983b4bf2Smrg s/$bs4/&\\ 425983b4bf2Smrg/g 426983b4bf2Smrg s/^$bs2$dollar/$bs&/ 427983b4bf2Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 428983b4bf2Smrg s/\n//g" 42990b17f1bSmrg 430983b4bf2Smrg# Standard options: 43190b17f1bSmrgopt_dry_run=false 432983b4bf2Smrgopt_help=false 43390b17f1bSmrgopt_quiet=false 43490b17f1bSmrgopt_verbose=false 435983b4bf2Smrgopt_warning=: 43690b17f1bSmrg 437983b4bf2Smrg# func_echo arg... 438983b4bf2Smrg# Echo program name prefixed message, along with the current mode 439983b4bf2Smrg# name if it has been set yet. 440983b4bf2Smrgfunc_echo () 441983b4bf2Smrg{ 442983b4bf2Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 443983b4bf2Smrg} 44490b17f1bSmrg 445983b4bf2Smrg# func_verbose arg... 446983b4bf2Smrg# Echo program name prefixed message in verbose mode only. 447983b4bf2Smrgfunc_verbose () 448983b4bf2Smrg{ 449983b4bf2Smrg $opt_verbose && func_echo ${1+"$@"} 45090b17f1bSmrg 451983b4bf2Smrg # A bug in bash halts the script if the last line of a function 452983b4bf2Smrg # fails when set -e is in force, so we need another command to 453983b4bf2Smrg # work around that: 454983b4bf2Smrg : 455983b4bf2Smrg} 45690b17f1bSmrg 457983b4bf2Smrg# func_echo_all arg... 458983b4bf2Smrg# Invoke $ECHO with all args, space-separated. 459983b4bf2Smrgfunc_echo_all () 460983b4bf2Smrg{ 461983b4bf2Smrg $ECHO "$*" 462983b4bf2Smrg} 46390b17f1bSmrg 464983b4bf2Smrg# func_error arg... 465983b4bf2Smrg# Echo program name prefixed message to standard error. 466983b4bf2Smrgfunc_error () 467983b4bf2Smrg{ 468983b4bf2Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 469983b4bf2Smrg} 47090b17f1bSmrg 471983b4bf2Smrg# func_warning arg... 472983b4bf2Smrg# Echo program name prefixed warning message to standard error. 473983b4bf2Smrgfunc_warning () 474983b4bf2Smrg{ 475983b4bf2Smrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 47690b17f1bSmrg 477983b4bf2Smrg # bash bug again: 478983b4bf2Smrg : 479983b4bf2Smrg} 48090b17f1bSmrg 481983b4bf2Smrg# func_fatal_error arg... 482983b4bf2Smrg# Echo program name prefixed message to standard error, and exit. 483983b4bf2Smrgfunc_fatal_error () 48490b17f1bSmrg{ 485983b4bf2Smrg func_error ${1+"$@"} 486983b4bf2Smrg exit $EXIT_FAILURE 487983b4bf2Smrg} 48890b17f1bSmrg 489983b4bf2Smrg# func_fatal_help arg... 490983b4bf2Smrg# Echo program name prefixed message to standard error, followed by 491983b4bf2Smrg# a help hint, and exit. 492983b4bf2Smrgfunc_fatal_help () 493983b4bf2Smrg{ 494983b4bf2Smrg func_error ${1+"$@"} 495983b4bf2Smrg func_fatal_error "$help" 49690b17f1bSmrg} 497983b4bf2Smrghelp="Try \`$progname --help' for more information." ## default 49890b17f1bSmrg 49990b17f1bSmrg 500983b4bf2Smrg# func_grep expression filename 50190b17f1bSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 50290b17f1bSmrgfunc_grep () 50390b17f1bSmrg{ 50490b17f1bSmrg $GREP "$1" "$2" >/dev/null 2>&1 50590b17f1bSmrg} 50690b17f1bSmrg 50790b17f1bSmrg 508983b4bf2Smrg# func_mkdir_p directory-path 50990b17f1bSmrg# Make sure the entire path to DIRECTORY-PATH is available. 51090b17f1bSmrgfunc_mkdir_p () 51190b17f1bSmrg{ 512983b4bf2Smrg my_directory_path="$1" 513983b4bf2Smrg my_dir_list= 51490b17f1bSmrg 515983b4bf2Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 516963d66acSmrg 517983b4bf2Smrg # Protect directory names starting with `-' 518983b4bf2Smrg case $my_directory_path in 519983b4bf2Smrg -*) my_directory_path="./$my_directory_path" ;; 52090b17f1bSmrg esac 52190b17f1bSmrg 52290b17f1bSmrg # While some portion of DIR does not yet exist... 523983b4bf2Smrg while test ! -d "$my_directory_path"; do 52490b17f1bSmrg # ...make a list in topmost first order. Use a colon delimited 52590b17f1bSmrg # list incase some portion of path contains whitespace. 526983b4bf2Smrg my_dir_list="$my_directory_path:$my_dir_list" 52790b17f1bSmrg 52890b17f1bSmrg # If the last portion added has no slash in it, the list is done 529983b4bf2Smrg case $my_directory_path in */*) ;; *) break ;; esac 53090b17f1bSmrg 53190b17f1bSmrg # ...otherwise throw away the child directory and loop 532983b4bf2Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 53390b17f1bSmrg done 534983b4bf2Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 53590b17f1bSmrg 536983b4bf2Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 537983b4bf2Smrg for my_dir in $my_dir_list; do 538983b4bf2Smrg IFS="$save_mkdir_p_IFS" 539983b4bf2Smrg # mkdir can fail with a `File exist' error if two processes 54090b17f1bSmrg # try to create one of the directories concurrently. Don't 54190b17f1bSmrg # stop in that case! 542983b4bf2Smrg $MKDIR "$my_dir" 2>/dev/null || : 54390b17f1bSmrg done 544983b4bf2Smrg IFS="$save_mkdir_p_IFS" 54590b17f1bSmrg 54690b17f1bSmrg # Bail out if we (or some other process) failed to create a directory. 547983b4bf2Smrg test -d "$my_directory_path" || \ 548983b4bf2Smrg func_fatal_error "Failed to create \`$1'" 54990b17f1bSmrg fi 55090b17f1bSmrg} 5517e6fb56fSmrg 5527e6fb56fSmrg 553983b4bf2Smrg# func_mktempdir [string] 5547e6fb56fSmrg# Make a temporary directory that won't clash with other running 5557e6fb56fSmrg# libtool processes, and avoids race conditions if possible. If 556983b4bf2Smrg# given, STRING is the basename for that directory. 5577e6fb56fSmrgfunc_mktempdir () 5587e6fb56fSmrg{ 559983b4bf2Smrg my_template="${TMPDIR-/tmp}/${1-$progname}" 560963d66acSmrg 561983b4bf2Smrg if test "$opt_dry_run" = ":"; then 5627e6fb56fSmrg # Return a directory name, but don't create it in dry-run mode 563983b4bf2Smrg my_tmpdir="${my_template}-$$" 5647e6fb56fSmrg else 5657e6fb56fSmrg 5667e6fb56fSmrg # If mktemp works, use that first and foremost 567983b4bf2Smrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 5687e6fb56fSmrg 569983b4bf2Smrg if test ! -d "$my_tmpdir"; then 57090b17f1bSmrg # Failing that, at least try and use $RANDOM to avoid a race 571983b4bf2Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 5727e6fb56fSmrg 573983b4bf2Smrg save_mktempdir_umask=`umask` 57490b17f1bSmrg umask 0077 575983b4bf2Smrg $MKDIR "$my_tmpdir" 576983b4bf2Smrg umask $save_mktempdir_umask 5777e6fb56fSmrg fi 5787e6fb56fSmrg 5797e6fb56fSmrg # If we're not in dry-run mode, bomb out on failure 580983b4bf2Smrg test -d "$my_tmpdir" || \ 581983b4bf2Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 5827e6fb56fSmrg fi 5837e6fb56fSmrg 584983b4bf2Smrg $ECHO "$my_tmpdir" 585963d66acSmrg} 586963d66acSmrg 587963d66acSmrg 588983b4bf2Smrg# func_quote_for_eval arg 589983b4bf2Smrg# Aesthetically quote ARG to be evaled later. 590983b4bf2Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 591983b4bf2Smrg# is double-quoted, suitable for a subsequent eval, whereas 592983b4bf2Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 593983b4bf2Smrg# which are still active within double quotes backslashified. 594963d66acSmrgfunc_quote_for_eval () 595963d66acSmrg{ 596963d66acSmrg case $1 in 597983b4bf2Smrg *[\\\`\"\$]*) 598983b4bf2Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 599963d66acSmrg *) 600983b4bf2Smrg func_quote_for_eval_unquoted_result="$1" ;; 601963d66acSmrg esac 602963d66acSmrg 603983b4bf2Smrg case $func_quote_for_eval_unquoted_result in 604963d66acSmrg # Double-quote args containing shell metacharacters to delay 605983b4bf2Smrg # word splitting, command substitution and and variable 606983b4bf2Smrg # expansion for a subsequent eval. 607963d66acSmrg # Many Bourne shells cannot handle close brackets correctly 608963d66acSmrg # in scan sets, so we specify it separately. 609963d66acSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 610983b4bf2Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 611963d66acSmrg ;; 612983b4bf2Smrg *) 613983b4bf2Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 614963d66acSmrg esac 615963d66acSmrg} 616963d66acSmrg 617963d66acSmrg 618983b4bf2Smrg# func_quote_for_expand arg 619983b4bf2Smrg# Aesthetically quote ARG to be evaled later; same as above, 620983b4bf2Smrg# but do not quote variable references. 621983b4bf2Smrgfunc_quote_for_expand () 622963d66acSmrg{ 623963d66acSmrg case $1 in 624983b4bf2Smrg *[\\\`\"]*) 625983b4bf2Smrg my_arg=`$ECHO "$1" | $SED \ 626983b4bf2Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 627983b4bf2Smrg *) 628983b4bf2Smrg my_arg="$1" ;; 629963d66acSmrg esac 630963d66acSmrg 631983b4bf2Smrg case $my_arg in 632983b4bf2Smrg # Double-quote args containing shell metacharacters to delay 633983b4bf2Smrg # word splitting and command substitution for a subsequent eval. 634983b4bf2Smrg # Many Bourne shells cannot handle close brackets correctly 635983b4bf2Smrg # in scan sets, so we specify it separately. 636983b4bf2Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 637983b4bf2Smrg my_arg="\"$my_arg\"" 638983b4bf2Smrg ;; 639983b4bf2Smrg esac 640963d66acSmrg 641983b4bf2Smrg func_quote_for_expand_result="$my_arg" 6427e6fb56fSmrg} 6437e6fb56fSmrg 6447e6fb56fSmrg 645983b4bf2Smrg# func_show_eval cmd [fail_exp] 646983b4bf2Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 647983b4bf2Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 648983b4bf2Smrg# is given, then evaluate it. 649983b4bf2Smrgfunc_show_eval () 6507e6fb56fSmrg{ 651983b4bf2Smrg my_cmd="$1" 652983b4bf2Smrg my_fail_exp="${2-:}" 653963d66acSmrg 654983b4bf2Smrg ${opt_silent-false} || { 655983b4bf2Smrg func_quote_for_expand "$my_cmd" 656983b4bf2Smrg eval "func_echo $func_quote_for_expand_result" 657983b4bf2Smrg } 658963d66acSmrg 659983b4bf2Smrg if ${opt_dry_run-false}; then :; else 660983b4bf2Smrg eval "$my_cmd" 661983b4bf2Smrg my_status=$? 662983b4bf2Smrg if test "$my_status" -eq 0; then :; else 663983b4bf2Smrg eval "(exit $my_status); $my_fail_exp" 664983b4bf2Smrg fi 665983b4bf2Smrg fi 66690b17f1bSmrg} 66790b17f1bSmrg 66890b17f1bSmrg 669983b4bf2Smrg# func_show_eval_locale cmd [fail_exp] 670983b4bf2Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 671983b4bf2Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 672983b4bf2Smrg# is given, then evaluate it. Use the saved locale for evaluation. 673983b4bf2Smrgfunc_show_eval_locale () 67490b17f1bSmrg{ 675983b4bf2Smrg my_cmd="$1" 676983b4bf2Smrg my_fail_exp="${2-:}" 67790b17f1bSmrg 678983b4bf2Smrg ${opt_silent-false} || { 679983b4bf2Smrg func_quote_for_expand "$my_cmd" 680983b4bf2Smrg eval "func_echo $func_quote_for_expand_result" 681983b4bf2Smrg } 682963d66acSmrg 683983b4bf2Smrg if ${opt_dry_run-false}; then :; else 684983b4bf2Smrg eval "$lt_user_locale 685983b4bf2Smrg $my_cmd" 686983b4bf2Smrg my_status=$? 687983b4bf2Smrg eval "$lt_safe_locale" 688983b4bf2Smrg if test "$my_status" -eq 0; then :; else 689983b4bf2Smrg eval "(exit $my_status); $my_fail_exp" 690983b4bf2Smrg fi 691983b4bf2Smrg fi 69290b17f1bSmrg} 69390b17f1bSmrg 694983b4bf2Smrg# func_tr_sh 695983b4bf2Smrg# Turn $1 into a string suitable for a shell variable name. 696983b4bf2Smrg# Result is stored in $func_tr_sh_result. All characters 697983b4bf2Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 698983b4bf2Smrg# if $1 begins with a digit, a '_' is prepended as well. 699983b4bf2Smrgfunc_tr_sh () 70090b17f1bSmrg{ 701983b4bf2Smrg case $1 in 702983b4bf2Smrg [0-9]* | *[!a-zA-Z0-9_]*) 703983b4bf2Smrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 704983b4bf2Smrg ;; 705983b4bf2Smrg * ) 706983b4bf2Smrg func_tr_sh_result=$1 707983b4bf2Smrg ;; 708983b4bf2Smrg esac 7097e6fb56fSmrg} 7107e6fb56fSmrg 7117e6fb56fSmrg 712983b4bf2Smrg# func_version 713983b4bf2Smrg# Echo version message to standard output and exit. 714983b4bf2Smrgfunc_version () 715983b4bf2Smrg{ 716983b4bf2Smrg $opt_debug 71790b17f1bSmrg 718983b4bf2Smrg $SED -n '/(C)/!b go 719983b4bf2Smrg :more 720983b4bf2Smrg /\./!{ 721983b4bf2Smrg N 722983b4bf2Smrg s/\n# / / 723983b4bf2Smrg b more 724983b4bf2Smrg } 725983b4bf2Smrg :go 726983b4bf2Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 727983b4bf2Smrg s/^# // 728983b4bf2Smrg s/^# *$// 729983b4bf2Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 730983b4bf2Smrg p 731983b4bf2Smrg }' < "$progpath" 732983b4bf2Smrg exit $? 733983b4bf2Smrg} 734963d66acSmrg 735983b4bf2Smrg# func_usage 736983b4bf2Smrg# Echo short help message to standard output and exit. 737983b4bf2Smrgfunc_usage () 7387e6fb56fSmrg{ 739983b4bf2Smrg $opt_debug 74090b17f1bSmrg 741983b4bf2Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 742983b4bf2Smrg s/^# // 743983b4bf2Smrg s/^# *$// 744983b4bf2Smrg s/\$progname/'$progname'/ 745983b4bf2Smrg p 746983b4bf2Smrg }' < "$progpath" 747983b4bf2Smrg echo 748983b4bf2Smrg $ECHO "run \`$progname --help | more' for full usage" 749983b4bf2Smrg exit $? 7507e6fb56fSmrg} 7517e6fb56fSmrg 752983b4bf2Smrg# func_help [NOEXIT] 753983b4bf2Smrg# Echo long help message to standard output and exit, 754983b4bf2Smrg# unless 'noexit' is passed as argument. 75590b17f1bSmrgfunc_help () 7567e6fb56fSmrg{ 757983b4bf2Smrg $opt_debug 758983b4bf2Smrg 759983b4bf2Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 760983b4bf2Smrg :print 761983b4bf2Smrg s/^# // 762983b4bf2Smrg s/^# *$// 763983b4bf2Smrg s*\$progname*'$progname'* 764983b4bf2Smrg s*\$host*'"$host"'* 765983b4bf2Smrg s*\$SHELL*'"$SHELL"'* 766983b4bf2Smrg s*\$LTCC*'"$LTCC"'* 767983b4bf2Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 768983b4bf2Smrg s*\$LD*'"$LD"'* 769983b4bf2Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 770983b4bf2Smrg s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 771983b4bf2Smrg s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 772983b4bf2Smrg p 773983b4bf2Smrg d 774983b4bf2Smrg } 775983b4bf2Smrg /^# .* home page:/b print 776983b4bf2Smrg /^# General help using/b print 777983b4bf2Smrg ' < "$progpath" 778983b4bf2Smrg ret=$? 779983b4bf2Smrg if test -z "$1"; then 780983b4bf2Smrg exit $ret 781983b4bf2Smrg fi 78290b17f1bSmrg} 7837e6fb56fSmrg 784983b4bf2Smrg# func_missing_arg argname 78590b17f1bSmrg# Echo program name prefixed message to standard error and set global 78690b17f1bSmrg# exit_cmd. 78790b17f1bSmrgfunc_missing_arg () 78890b17f1bSmrg{ 789983b4bf2Smrg $opt_debug 7907e6fb56fSmrg 791983b4bf2Smrg func_error "missing argument for $1." 79290b17f1bSmrg exit_cmd=exit 7937e6fb56fSmrg} 7947e6fb56fSmrg 7957e6fb56fSmrg 796983b4bf2Smrg# func_split_short_opt shortopt 79790b17f1bSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 79890b17f1bSmrg# variables after splitting SHORTOPT after the 2nd character. 799983b4bf2Smrgfunc_split_short_opt () 80090b17f1bSmrg{ 801983b4bf2Smrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 802983b4bf2Smrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 80390b17f1bSmrg 804983b4bf2Smrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 805983b4bf2Smrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 806983b4bf2Smrg} # func_split_short_opt may be replaced by extended shell implementation 8077e6fb56fSmrg 8087e6fb56fSmrg 809983b4bf2Smrg# func_split_long_opt longopt 810983b4bf2Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 811983b4bf2Smrg# variables after splitting LONGOPT at the `=' sign. 812983b4bf2Smrgfunc_split_long_opt () 81390b17f1bSmrg{ 814983b4bf2Smrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 815983b4bf2Smrg my_sed_long_arg='1s/^--[^=]*=//' 8167e6fb56fSmrg 817983b4bf2Smrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 818983b4bf2Smrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 819983b4bf2Smrg} # func_split_long_opt may be replaced by extended shell implementation 8207e6fb56fSmrg 821983b4bf2Smrgexit_cmd=: 8227e6fb56fSmrg 8237e6fb56fSmrg 8247e6fb56fSmrg 8257e6fb56fSmrg 8267e6fb56fSmrg 827983b4bf2Smrgmagic="%%%MAGIC variable%%%" 828983b4bf2Smrgmagic_exe="%%%MAGIC EXE variable%%%" 82990b17f1bSmrg 830983b4bf2Smrg# Global variables. 831983b4bf2Smrgnonopt= 832983b4bf2Smrgpreserve_args= 833983b4bf2Smrglo2o="s/\\.lo\$/.${objext}/" 834983b4bf2Smrgo2lo="s/\\.${objext}\$/.lo/" 835983b4bf2Smrgextracted_archives= 836983b4bf2Smrgextracted_serial=0 83790b17f1bSmrg 838983b4bf2Smrg# If this variable is set in any of the actions, the command in it 839983b4bf2Smrg# will be execed at the end. This prevents here-documents from being 840983b4bf2Smrg# left over by shells. 841983b4bf2Smrgexec_cmd= 84290b17f1bSmrg 843983b4bf2Smrg# func_append var value 844983b4bf2Smrg# Append VALUE to the end of shell variable VAR. 845983b4bf2Smrgfunc_append () 84690b17f1bSmrg{ 847983b4bf2Smrg eval "${1}=\$${1}\${2}" 848983b4bf2Smrg} # func_append may be replaced by extended shell implementation 84990b17f1bSmrg 850983b4bf2Smrg# func_append_quoted var value 851983b4bf2Smrg# Quote VALUE and append to the end of shell variable VAR, separated 852983b4bf2Smrg# by a space. 853983b4bf2Smrgfunc_append_quoted () 85490b17f1bSmrg{ 855983b4bf2Smrg func_quote_for_eval "${2}" 856983b4bf2Smrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 857983b4bf2Smrg} # func_append_quoted may be replaced by extended shell implementation 85890b17f1bSmrg 85990b17f1bSmrg 860983b4bf2Smrg# func_arith arithmetic-term... 861983b4bf2Smrgfunc_arith () 86290b17f1bSmrg{ 863983b4bf2Smrg func_arith_result=`expr "${@}"` 864983b4bf2Smrg} # func_arith may be replaced by extended shell implementation 86590b17f1bSmrg 86690b17f1bSmrg 867983b4bf2Smrg# func_len string 868983b4bf2Smrg# STRING may not start with a hyphen. 869983b4bf2Smrgfunc_len () 870983b4bf2Smrg{ 871983b4bf2Smrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 872983b4bf2Smrg} # func_len may be replaced by extended shell implementation 873963d66acSmrg 874963d66acSmrg 875983b4bf2Smrg# func_lo2o object 876983b4bf2Smrgfunc_lo2o () 877983b4bf2Smrg{ 878983b4bf2Smrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 879983b4bf2Smrg} # func_lo2o may be replaced by extended shell implementation 880963d66acSmrg 881963d66acSmrg 882983b4bf2Smrg# func_xform libobj-or-source 883983b4bf2Smrgfunc_xform () 884983b4bf2Smrg{ 885983b4bf2Smrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 886983b4bf2Smrg} # func_xform may be replaced by extended shell implementation 88790b17f1bSmrg 88890b17f1bSmrg 889983b4bf2Smrg# func_fatal_configuration arg... 89090b17f1bSmrg# Echo program name prefixed message to standard error, followed by 89190b17f1bSmrg# a configuration failure hint, and exit. 89290b17f1bSmrgfunc_fatal_configuration () 89390b17f1bSmrg{ 894983b4bf2Smrg func_error ${1+"$@"} 895983b4bf2Smrg func_error "See the $PACKAGE documentation for more information." 896983b4bf2Smrg func_fatal_error "Fatal configuration error." 89790b17f1bSmrg} 89890b17f1bSmrg 89990b17f1bSmrg 90090b17f1bSmrg# func_config 90190b17f1bSmrg# Display the configuration for all the tags in this script. 90290b17f1bSmrgfunc_config () 90390b17f1bSmrg{ 90490b17f1bSmrg re_begincf='^# ### BEGIN LIBTOOL' 90590b17f1bSmrg re_endcf='^# ### END LIBTOOL' 90690b17f1bSmrg 90790b17f1bSmrg # Default configuration. 90890b17f1bSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 90990b17f1bSmrg 9107e6fb56fSmrg # Now print the configurations for the tags. 9117e6fb56fSmrg for tagname in $taglist; do 91290b17f1bSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 9137e6fb56fSmrg done 9147e6fb56fSmrg 91590b17f1bSmrg exit $? 91690b17f1bSmrg} 9177e6fb56fSmrg 91890b17f1bSmrg# func_features 91990b17f1bSmrg# Display the features supported by this script. 92090b17f1bSmrgfunc_features () 92190b17f1bSmrg{ 92290b17f1bSmrg echo "host: $host" 923983b4bf2Smrg if test "$build_libtool_libs" = yes; then 92490b17f1bSmrg echo "enable shared libraries" 9257e6fb56fSmrg else 92690b17f1bSmrg echo "disable shared libraries" 9277e6fb56fSmrg fi 928983b4bf2Smrg if test "$build_old_libs" = yes; then 92990b17f1bSmrg echo "enable static libraries" 9307e6fb56fSmrg else 93190b17f1bSmrg echo "disable static libraries" 9327e6fb56fSmrg fi 9337e6fb56fSmrg 93490b17f1bSmrg exit $? 93590b17f1bSmrg} 9367e6fb56fSmrg 937983b4bf2Smrg# func_enable_tag tagname 93890b17f1bSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 93990b17f1bSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 94090b17f1bSmrg# variable here. 94190b17f1bSmrgfunc_enable_tag () 94290b17f1bSmrg{ 943983b4bf2Smrg # Global variable: 944983b4bf2Smrg tagname="$1" 9457e6fb56fSmrg 946983b4bf2Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 947983b4bf2Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 948983b4bf2Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 9497e6fb56fSmrg 950983b4bf2Smrg # Validate tagname. 951983b4bf2Smrg case $tagname in 952983b4bf2Smrg *[!-_A-Za-z0-9,/]*) 953983b4bf2Smrg func_fatal_error "invalid tag name: $tagname" 954983b4bf2Smrg ;; 955983b4bf2Smrg esac 9567e6fb56fSmrg 957983b4bf2Smrg # Don't test for the "default" C tag, as we know it's 958983b4bf2Smrg # there but not specially marked. 959983b4bf2Smrg case $tagname in 960983b4bf2Smrg CC) ;; 96190b17f1bSmrg *) 962983b4bf2Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 963983b4bf2Smrg taglist="$taglist $tagname" 964983b4bf2Smrg 965983b4bf2Smrg # Evaluate the configuration. Be careful to quote the path 966983b4bf2Smrg # and the sed script, to avoid splitting on whitespace, but 967983b4bf2Smrg # also don't use non-portable quotes within backquotes within 968983b4bf2Smrg # quotes we have to do it in 2 steps: 969983b4bf2Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 970983b4bf2Smrg eval "$extractedcf" 971983b4bf2Smrg else 972983b4bf2Smrg func_error "ignoring unknown tag $tagname" 973983b4bf2Smrg fi 974983b4bf2Smrg ;; 975983b4bf2Smrg esac 97690b17f1bSmrg} 9777e6fb56fSmrg 97890b17f1bSmrg# func_check_version_match 97990b17f1bSmrg# Ensure that we are using m4 macros, and libtool script from the same 98090b17f1bSmrg# release of libtool. 98190b17f1bSmrgfunc_check_version_match () 98290b17f1bSmrg{ 983983b4bf2Smrg if test "$package_revision" != "$macro_revision"; then 984983b4bf2Smrg if test "$VERSION" != "$macro_version"; then 985983b4bf2Smrg if test -z "$macro_version"; then 986983b4bf2Smrg cat >&2 <<_LT_EOF 98790b17f1bSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 98890b17f1bSmrg$progname: definition of this LT_INIT comes from an older release. 98990b17f1bSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99090b17f1bSmrg$progname: and run autoconf again. 99190b17f1bSmrg_LT_EOF 992983b4bf2Smrg else 993983b4bf2Smrg cat >&2 <<_LT_EOF 99490b17f1bSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99590b17f1bSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 99690b17f1bSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99790b17f1bSmrg$progname: and run autoconf again. 99890b17f1bSmrg_LT_EOF 999983b4bf2Smrg fi 1000983b4bf2Smrg else 1001983b4bf2Smrg cat >&2 <<_LT_EOF 100290b17f1bSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 100390b17f1bSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 100490b17f1bSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 100590b17f1bSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 100690b17f1bSmrg_LT_EOF 1007963d66acSmrg fi 10087e6fb56fSmrg 1009983b4bf2Smrg exit $EXIT_MISMATCH 1010983b4bf2Smrg fi 1011983b4bf2Smrg} 10127e6fb56fSmrg 10137e6fb56fSmrg 1014983b4bf2Smrg# Shorthand for --mode=foo, only valid as the first argument 1015983b4bf2Smrgcase $1 in 1016983b4bf2Smrgclean|clea|cle|cl) 1017983b4bf2Smrg shift; set dummy --mode clean ${1+"$@"}; shift 1018983b4bf2Smrg ;; 1019983b4bf2Smrgcompile|compil|compi|comp|com|co|c) 1020983b4bf2Smrg shift; set dummy --mode compile ${1+"$@"}; shift 1021983b4bf2Smrg ;; 1022983b4bf2Smrgexecute|execut|execu|exec|exe|ex|e) 1023983b4bf2Smrg shift; set dummy --mode execute ${1+"$@"}; shift 1024983b4bf2Smrg ;; 1025983b4bf2Smrgfinish|finis|fini|fin|fi|f) 1026983b4bf2Smrg shift; set dummy --mode finish ${1+"$@"}; shift 1027983b4bf2Smrg ;; 1028983b4bf2Smrginstall|instal|insta|inst|ins|in|i) 1029983b4bf2Smrg shift; set dummy --mode install ${1+"$@"}; shift 1030983b4bf2Smrg ;; 1031983b4bf2Smrglink|lin|li|l) 1032983b4bf2Smrg shift; set dummy --mode link ${1+"$@"}; shift 1033983b4bf2Smrg ;; 1034983b4bf2Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 1035983b4bf2Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 1036983b4bf2Smrg ;; 1037983b4bf2Smrgesac 10387e6fb56fSmrg 10397e6fb56fSmrg 1040963d66acSmrg 1041983b4bf2Smrg# Option defaults: 1042983b4bf2Smrgopt_debug=: 1043983b4bf2Smrgopt_dry_run=false 1044983b4bf2Smrgopt_config=false 1045983b4bf2Smrgopt_preserve_dup_deps=false 1046983b4bf2Smrgopt_features=false 1047983b4bf2Smrgopt_finish=false 1048983b4bf2Smrgopt_help=false 1049983b4bf2Smrgopt_help_all=false 1050983b4bf2Smrgopt_silent=: 1051983b4bf2Smrgopt_warning=: 1052983b4bf2Smrgopt_verbose=: 1053983b4bf2Smrgopt_silent=false 1054983b4bf2Smrgopt_verbose=false 10557e6fb56fSmrg 105690b17f1bSmrg 1057983b4bf2Smrg# Parse options once, thoroughly. This comes as soon as possible in the 1058983b4bf2Smrg# script to make things like `--version' happen as quickly as we can. 105990b17f1bSmrg{ 1060983b4bf2Smrg # this just eases exit handling 1061983b4bf2Smrg while test $# -gt 0; do 1062983b4bf2Smrg opt="$1" 1063983b4bf2Smrg shift 1064983b4bf2Smrg case $opt in 1065983b4bf2Smrg --debug|-x) opt_debug='set -x' 1066983b4bf2Smrg func_echo "enabling shell trace mode" 1067983b4bf2Smrg $opt_debug 1068983b4bf2Smrg ;; 1069983b4bf2Smrg --dry-run|--dryrun|-n) 1070983b4bf2Smrg opt_dry_run=: 1071983b4bf2Smrg ;; 1072983b4bf2Smrg --config) 1073983b4bf2Smrg opt_config=: 1074983b4bf2Smrgfunc_config 1075983b4bf2Smrg ;; 1076983b4bf2Smrg --dlopen|-dlopen) 1077983b4bf2Smrg optarg="$1" 1078983b4bf2Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 1079983b4bf2Smrg}$optarg" 1080983b4bf2Smrg shift 1081983b4bf2Smrg ;; 1082983b4bf2Smrg --preserve-dup-deps) 1083983b4bf2Smrg opt_preserve_dup_deps=: 1084983b4bf2Smrg ;; 1085983b4bf2Smrg --features) 1086983b4bf2Smrg opt_features=: 1087983b4bf2Smrgfunc_features 1088983b4bf2Smrg ;; 1089983b4bf2Smrg --finish) 1090983b4bf2Smrg opt_finish=: 1091983b4bf2Smrgset dummy --mode finish ${1+"$@"}; shift 1092983b4bf2Smrg ;; 1093983b4bf2Smrg --help) 1094983b4bf2Smrg opt_help=: 1095983b4bf2Smrg ;; 1096983b4bf2Smrg --help-all) 1097983b4bf2Smrg opt_help_all=: 1098983b4bf2Smrgopt_help=': help-all' 1099983b4bf2Smrg ;; 1100983b4bf2Smrg --mode) 1101983b4bf2Smrg test $# = 0 && func_missing_arg $opt && break 1102983b4bf2Smrg optarg="$1" 1103983b4bf2Smrg opt_mode="$optarg" 1104983b4bf2Smrgcase $optarg in 1105983b4bf2Smrg # Valid mode arguments: 1106983b4bf2Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 1107983b4bf2Smrg 1108983b4bf2Smrg # Catch anything else as an error 1109983b4bf2Smrg *) func_error "invalid argument for $opt" 1110983b4bf2Smrg exit_cmd=exit 1111983b4bf2Smrg break 1112983b4bf2Smrg ;; 1113983b4bf2Smrgesac 1114983b4bf2Smrg shift 1115983b4bf2Smrg ;; 1116983b4bf2Smrg --no-silent|--no-quiet) 1117983b4bf2Smrg opt_silent=false 1118983b4bf2Smrgfunc_append preserve_args " $opt" 1119983b4bf2Smrg ;; 1120983b4bf2Smrg --no-warning|--no-warn) 1121983b4bf2Smrg opt_warning=false 1122983b4bf2Smrgfunc_append preserve_args " $opt" 1123983b4bf2Smrg ;; 1124983b4bf2Smrg --no-verbose) 1125983b4bf2Smrg opt_verbose=false 1126983b4bf2Smrgfunc_append preserve_args " $opt" 1127983b4bf2Smrg ;; 1128983b4bf2Smrg --silent|--quiet) 1129983b4bf2Smrg opt_silent=: 1130983b4bf2Smrgfunc_append preserve_args " $opt" 1131983b4bf2Smrg opt_verbose=false 1132983b4bf2Smrg ;; 1133983b4bf2Smrg --verbose|-v) 1134983b4bf2Smrg opt_verbose=: 1135983b4bf2Smrgfunc_append preserve_args " $opt" 1136983b4bf2Smrgopt_silent=false 1137983b4bf2Smrg ;; 1138983b4bf2Smrg --tag) 1139983b4bf2Smrg test $# = 0 && func_missing_arg $opt && break 1140983b4bf2Smrg optarg="$1" 1141983b4bf2Smrg opt_tag="$optarg" 1142983b4bf2Smrgfunc_append preserve_args " $opt $optarg" 1143983b4bf2Smrgfunc_enable_tag "$optarg" 1144983b4bf2Smrg shift 1145983b4bf2Smrg ;; 1146983b4bf2Smrg 1147983b4bf2Smrg -\?|-h) func_usage ;; 1148983b4bf2Smrg --help) func_help ;; 1149983b4bf2Smrg --version) func_version ;; 1150983b4bf2Smrg 1151983b4bf2Smrg # Separate optargs to long options: 1152983b4bf2Smrg --*=*) 1153983b4bf2Smrg func_split_long_opt "$opt" 1154983b4bf2Smrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 1155983b4bf2Smrg shift 1156983b4bf2Smrg ;; 1157983b4bf2Smrg 1158983b4bf2Smrg # Separate non-argument short options: 1159983b4bf2Smrg -\?*|-h*|-n*|-v*) 1160983b4bf2Smrg func_split_short_opt "$opt" 1161983b4bf2Smrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 1162983b4bf2Smrg shift 1163983b4bf2Smrg ;; 1164983b4bf2Smrg 1165983b4bf2Smrg --) break ;; 1166983b4bf2Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 1167983b4bf2Smrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1168983b4bf2Smrg esac 1169983b4bf2Smrg done 11707e6fb56fSmrg 1171983b4bf2Smrg # Validate options: 117290b17f1bSmrg 1173983b4bf2Smrg # save first non-option argument 1174983b4bf2Smrg if test "$#" -gt 0; then 1175983b4bf2Smrg nonopt="$opt" 1176983b4bf2Smrg shift 1177983b4bf2Smrg fi 11787e6fb56fSmrg 1179983b4bf2Smrg # preserve --debug 1180983b4bf2Smrg test "$opt_debug" = : || func_append preserve_args " --debug" 11817e6fb56fSmrg 1182983b4bf2Smrg case $host in 1183983b4bf2Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 1184983b4bf2Smrg # don't eliminate duplications in $postdeps and $predeps 1185983b4bf2Smrg opt_duplicate_compiler_generated_deps=: 1186983b4bf2Smrg ;; 1187983b4bf2Smrg *) 1188983b4bf2Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 1189983b4bf2Smrg ;; 1190983b4bf2Smrg esac 11917e6fb56fSmrg 1192983b4bf2Smrg $opt_help || { 1193983b4bf2Smrg # Sanity checks first: 1194983b4bf2Smrg func_check_version_match 11957e6fb56fSmrg 1196983b4bf2Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 1197983b4bf2Smrg func_fatal_configuration "not configured to build any kind of library" 119890b17f1bSmrg fi 11997e6fb56fSmrg 1200983b4bf2Smrg # Darwin sucks 1201983b4bf2Smrg eval std_shrext=\"$shrext_cmds\" 1202963d66acSmrg 1203983b4bf2Smrg # Only execute mode is allowed to have -dlopen flags. 1204983b4bf2Smrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 1205983b4bf2Smrg func_error "unrecognized option \`-dlopen'" 1206983b4bf2Smrg $ECHO "$help" 1>&2 1207983b4bf2Smrg exit $EXIT_FAILURE 1208983b4bf2Smrg fi 1209963d66acSmrg 1210983b4bf2Smrg # Change the help message to a mode-specific one. 1211983b4bf2Smrg generic_help="$help" 1212983b4bf2Smrg help="Try \`$progname --help --mode=$opt_mode' for more information." 1213983b4bf2Smrg } 12147e6fb56fSmrg 12157e6fb56fSmrg 1216983b4bf2Smrg # Bail if the options were screwed 1217983b4bf2Smrg $exit_cmd $EXIT_FAILURE 121890b17f1bSmrg} 12197e6fb56fSmrg 1220963d66acSmrg 12217e6fb56fSmrg 12227e6fb56fSmrg 122390b17f1bSmrg## ----------- ## 122490b17f1bSmrg## Main. ## 122590b17f1bSmrg## ----------- ## 12267e6fb56fSmrg 122790b17f1bSmrg# func_lalib_p file 1228983b4bf2Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 122990b17f1bSmrg# This function is only a basic sanity check; it will hardly flush out 123090b17f1bSmrg# determined imposters. 123190b17f1bSmrgfunc_lalib_p () 123290b17f1bSmrg{ 123390b17f1bSmrg test -f "$1" && 1234983b4bf2Smrg $SED -e 4q "$1" 2>/dev/null \ 1235983b4bf2Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 123690b17f1bSmrg} 12377e6fb56fSmrg 123890b17f1bSmrg# func_lalib_unsafe_p file 1239983b4bf2Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 124090b17f1bSmrg# This function implements the same check as func_lalib_p without 124190b17f1bSmrg# resorting to external programs. To this end, it redirects stdin and 124290b17f1bSmrg# closes it afterwards, without saving the original file descriptor. 124390b17f1bSmrg# As a safety measure, use it only where a negative result would be 1244983b4bf2Smrg# fatal anyway. Works if `file' does not exist. 124590b17f1bSmrgfunc_lalib_unsafe_p () 124690b17f1bSmrg{ 124790b17f1bSmrg lalib_p=no 124890b17f1bSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 124990b17f1bSmrg for lalib_p_l in 1 2 3 4 125090b17f1bSmrg do 125190b17f1bSmrg read lalib_p_line 1252983b4bf2Smrg case "$lalib_p_line" in 125390b17f1bSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 125490b17f1bSmrg esac 125590b17f1bSmrg done 125690b17f1bSmrg exec 0<&5 5<&- 125790b17f1bSmrg fi 1258983b4bf2Smrg test "$lalib_p" = yes 125990b17f1bSmrg} 12607e6fb56fSmrg 126190b17f1bSmrg# func_ltwrapper_script_p file 126290b17f1bSmrg# True iff FILE is a libtool wrapper script 126390b17f1bSmrg# This function is only a basic sanity check; it will hardly flush out 126490b17f1bSmrg# determined imposters. 126590b17f1bSmrgfunc_ltwrapper_script_p () 126690b17f1bSmrg{ 1267983b4bf2Smrg func_lalib_p "$1" 126890b17f1bSmrg} 12697e6fb56fSmrg 127090b17f1bSmrg# func_ltwrapper_executable_p file 127190b17f1bSmrg# True iff FILE is a libtool wrapper executable 127290b17f1bSmrg# This function is only a basic sanity check; it will hardly flush out 127390b17f1bSmrg# determined imposters. 127490b17f1bSmrgfunc_ltwrapper_executable_p () 127590b17f1bSmrg{ 127690b17f1bSmrg func_ltwrapper_exec_suffix= 127790b17f1bSmrg case $1 in 127890b17f1bSmrg *.exe) ;; 127990b17f1bSmrg *) func_ltwrapper_exec_suffix=.exe ;; 12807e6fb56fSmrg esac 128190b17f1bSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 128290b17f1bSmrg} 12837e6fb56fSmrg 128490b17f1bSmrg# func_ltwrapper_scriptname file 128590b17f1bSmrg# Assumes file is an ltwrapper_executable 128690b17f1bSmrg# uses $file to determine the appropriate filename for a 128790b17f1bSmrg# temporary ltwrapper_script. 128890b17f1bSmrgfunc_ltwrapper_scriptname () 128990b17f1bSmrg{ 129090b17f1bSmrg func_dirname_and_basename "$1" "" "." 129190b17f1bSmrg func_stripname '' '.exe' "$func_basename_result" 1292983b4bf2Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 129390b17f1bSmrg} 12947e6fb56fSmrg 129590b17f1bSmrg# func_ltwrapper_p file 129690b17f1bSmrg# True iff FILE is a libtool wrapper script or wrapper executable 129790b17f1bSmrg# This function is only a basic sanity check; it will hardly flush out 129890b17f1bSmrg# determined imposters. 129990b17f1bSmrgfunc_ltwrapper_p () 130090b17f1bSmrg{ 130190b17f1bSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 130290b17f1bSmrg} 13037e6fb56fSmrg 13047e6fb56fSmrg 130590b17f1bSmrg# func_execute_cmds commands fail_cmd 130690b17f1bSmrg# Execute tilde-delimited COMMANDS. 130790b17f1bSmrg# If FAIL_CMD is given, eval that upon failure. 130890b17f1bSmrg# FAIL_CMD may read-access the current command in variable CMD! 130990b17f1bSmrgfunc_execute_cmds () 131090b17f1bSmrg{ 1311983b4bf2Smrg $opt_debug 131290b17f1bSmrg save_ifs=$IFS; IFS='~' 131390b17f1bSmrg for cmd in $1; do 1314963d66acSmrg IFS=$save_ifs 1315983b4bf2Smrg eval cmd=\"$cmd\" 131690b17f1bSmrg func_show_eval "$cmd" "${2-:}" 13177e6fb56fSmrg done 131890b17f1bSmrg IFS=$save_ifs 131990b17f1bSmrg} 13207e6fb56fSmrg 13217e6fb56fSmrg 132290b17f1bSmrg# func_source file 132390b17f1bSmrg# Source FILE, adding directory component if necessary. 132490b17f1bSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 132590b17f1bSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 132690b17f1bSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 1327983b4bf2Smrg# `FILE.' does not work on cygwin managed mounts. 132890b17f1bSmrgfunc_source () 132990b17f1bSmrg{ 1330983b4bf2Smrg $opt_debug 133190b17f1bSmrg case $1 in 133290b17f1bSmrg */* | *\\*) . "$1" ;; 133390b17f1bSmrg *) . "./$1" ;; 133490b17f1bSmrg esac 133590b17f1bSmrg} 13367e6fb56fSmrg 13377e6fb56fSmrg 133890b17f1bSmrg# func_resolve_sysroot PATH 133990b17f1bSmrg# Replace a leading = in PATH with a sysroot. Store the result into 134090b17f1bSmrg# func_resolve_sysroot_result 134190b17f1bSmrgfunc_resolve_sysroot () 134290b17f1bSmrg{ 134390b17f1bSmrg func_resolve_sysroot_result=$1 134490b17f1bSmrg case $func_resolve_sysroot_result in 134590b17f1bSmrg =*) 134690b17f1bSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 134790b17f1bSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 134890b17f1bSmrg ;; 134990b17f1bSmrg esac 135090b17f1bSmrg} 13517e6fb56fSmrg 135290b17f1bSmrg# func_replace_sysroot PATH 135390b17f1bSmrg# If PATH begins with the sysroot, replace it with = and 135490b17f1bSmrg# store the result into func_replace_sysroot_result. 135590b17f1bSmrgfunc_replace_sysroot () 135690b17f1bSmrg{ 1357983b4bf2Smrg case "$lt_sysroot:$1" in 135890b17f1bSmrg ?*:"$lt_sysroot"*) 135990b17f1bSmrg func_stripname "$lt_sysroot" '' "$1" 1360983b4bf2Smrg func_replace_sysroot_result="=$func_stripname_result" 136190b17f1bSmrg ;; 136290b17f1bSmrg *) 136390b17f1bSmrg # Including no sysroot. 136490b17f1bSmrg func_replace_sysroot_result=$1 136590b17f1bSmrg ;; 136690b17f1bSmrg esac 136790b17f1bSmrg} 13687e6fb56fSmrg 136990b17f1bSmrg# func_infer_tag arg 137090b17f1bSmrg# Infer tagged configuration to use if any are available and 137190b17f1bSmrg# if one wasn't chosen via the "--tag" command line option. 137290b17f1bSmrg# Only attempt this if the compiler in the base compile 137390b17f1bSmrg# command doesn't match the default compiler. 137490b17f1bSmrg# arg is usually of the form 'gcc ...' 137590b17f1bSmrgfunc_infer_tag () 137690b17f1bSmrg{ 1377983b4bf2Smrg $opt_debug 137890b17f1bSmrg if test -n "$available_tags" && test -z "$tagname"; then 137990b17f1bSmrg CC_quoted= 138090b17f1bSmrg for arg in $CC; do 138190b17f1bSmrg func_append_quoted CC_quoted "$arg" 138290b17f1bSmrg done 138390b17f1bSmrg CC_expanded=`func_echo_all $CC` 138490b17f1bSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 138590b17f1bSmrg case $@ in 138690b17f1bSmrg # Blanks in the command may have been stripped by the calling shell, 138790b17f1bSmrg # but not from the CC environment variable when configure was run. 138890b17f1bSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 138990b17f1bSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 139090b17f1bSmrg # Blanks at the start of $base_compile will cause this to fail 139190b17f1bSmrg # if we don't check for them as well. 139290b17f1bSmrg *) 139390b17f1bSmrg for z in $available_tags; do 139490b17f1bSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 139590b17f1bSmrg # Evaluate the configuration. 1396983b4bf2Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 139790b17f1bSmrg CC_quoted= 139890b17f1bSmrg for arg in $CC; do 139990b17f1bSmrg # Double-quote args containing other shell metacharacters. 140090b17f1bSmrg func_append_quoted CC_quoted "$arg" 140190b17f1bSmrg done 140290b17f1bSmrg CC_expanded=`func_echo_all $CC` 140390b17f1bSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 140490b17f1bSmrg case "$@ " in 140590b17f1bSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 140690b17f1bSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 140790b17f1bSmrg # The compiler in the base compile command matches 140890b17f1bSmrg # the one in the tagged configuration. 140990b17f1bSmrg # Assume this is the tagged configuration we want. 141090b17f1bSmrg tagname=$z 141190b17f1bSmrg break 141290b17f1bSmrg ;; 141390b17f1bSmrg esac 141490b17f1bSmrg fi 141590b17f1bSmrg done 141690b17f1bSmrg # If $tagname still isn't set, then no tagged configuration 141790b17f1bSmrg # was found and let the user know that the "--tag" command 141890b17f1bSmrg # line option must be used. 141990b17f1bSmrg if test -z "$tagname"; then 142090b17f1bSmrg func_echo "unable to infer tagged configuration" 1421983b4bf2Smrg func_fatal_error "specify a tag with \`--tag'" 142290b17f1bSmrg# else 142390b17f1bSmrg# func_verbose "using $tagname tagged configuration" 142490b17f1bSmrg fi 142590b17f1bSmrg ;; 142690b17f1bSmrg esac 14277e6fb56fSmrg fi 142890b17f1bSmrg} 14297e6fb56fSmrg 14307e6fb56fSmrg 14317e6fb56fSmrg 143290b17f1bSmrg# func_write_libtool_object output_name pic_name nonpic_name 143390b17f1bSmrg# Create a libtool object file (analogous to a ".la" file), 143490b17f1bSmrg# but don't create it if we're doing a dry run. 143590b17f1bSmrgfunc_write_libtool_object () 143690b17f1bSmrg{ 1437983b4bf2Smrg write_libobj=${1} 1438983b4bf2Smrg if test "$build_libtool_libs" = yes; then 1439983b4bf2Smrg write_lobj=\'${2}\' 144090b17f1bSmrg else 144190b17f1bSmrg write_lobj=none 14427e6fb56fSmrg fi 14437e6fb56fSmrg 1444983b4bf2Smrg if test "$build_old_libs" = yes; then 1445983b4bf2Smrg write_oldobj=\'${3}\' 144690b17f1bSmrg else 144790b17f1bSmrg write_oldobj=none 14487e6fb56fSmrg fi 14497e6fb56fSmrg 145090b17f1bSmrg $opt_dry_run || { 145190b17f1bSmrg cat >${write_libobj}T <<EOF 145290b17f1bSmrg# $write_libobj - a libtool object file 1453983b4bf2Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 14547e6fb56fSmrg# 14557e6fb56fSmrg# Please DO NOT delete this file! 14567e6fb56fSmrg# It is necessary for linking the library. 14577e6fb56fSmrg 14587e6fb56fSmrg# Name of the PIC object. 145990b17f1bSmrgpic_object=$write_lobj 14607e6fb56fSmrg 146190b17f1bSmrg# Name of the non-PIC object 146290b17f1bSmrgnon_pic_object=$write_oldobj 14637e6fb56fSmrg 146490b17f1bSmrgEOF 1465983b4bf2Smrg $MV "${write_libobj}T" "${write_libobj}" 146690b17f1bSmrg } 146790b17f1bSmrg} 14687e6fb56fSmrg 14697e6fb56fSmrg 147090b17f1bSmrg################################################## 147190b17f1bSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 147290b17f1bSmrg################################################## 14737e6fb56fSmrg 147490b17f1bSmrg# func_convert_core_file_wine_to_w32 ARG 147590b17f1bSmrg# Helper function used by file name conversion functions when $build is *nix, 147690b17f1bSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 147790b17f1bSmrg# correctly configured wine environment available, with the winepath program 147890b17f1bSmrg# in $build's $PATH. 147990b17f1bSmrg# 148090b17f1bSmrg# ARG is the $build file name to be converted to w32 format. 148190b17f1bSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 148290b17f1bSmrg# be empty on error (or when ARG is empty) 148390b17f1bSmrgfunc_convert_core_file_wine_to_w32 () 148490b17f1bSmrg{ 1485983b4bf2Smrg $opt_debug 1486983b4bf2Smrg func_convert_core_file_wine_to_w32_result="$1" 148790b17f1bSmrg if test -n "$1"; then 148890b17f1bSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 148990b17f1bSmrg # are forced to check the contents of stdout. On the other hand, if the 149090b17f1bSmrg # command is not found, the shell will set an exit code of 127 and print 149190b17f1bSmrg # *an error message* to stdout. So we must check for both error code of 149290b17f1bSmrg # zero AND non-empty stdout, which explains the odd construction: 149390b17f1bSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 1494983b4bf2Smrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 149590b17f1bSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 1496983b4bf2Smrg $SED -e "$lt_sed_naive_backslashify"` 149790b17f1bSmrg else 149890b17f1bSmrg func_convert_core_file_wine_to_w32_result= 149990b17f1bSmrg fi 150090b17f1bSmrg fi 150190b17f1bSmrg} 150290b17f1bSmrg# end: func_convert_core_file_wine_to_w32 15037e6fb56fSmrg 150490b17f1bSmrg 150590b17f1bSmrg# func_convert_core_path_wine_to_w32 ARG 150690b17f1bSmrg# Helper function used by path conversion functions when $build is *nix, and 150790b17f1bSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 150890b17f1bSmrg# configured wine environment available, with the winepath program in $build's 150990b17f1bSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 151090b17f1bSmrg# 151190b17f1bSmrg# ARG is path to be converted from $build format to win32. 151290b17f1bSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 151390b17f1bSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 151490b17f1bSmrg# are convertible, then the result may be empty. 151590b17f1bSmrgfunc_convert_core_path_wine_to_w32 () 151690b17f1bSmrg{ 1517983b4bf2Smrg $opt_debug 151890b17f1bSmrg # unfortunately, winepath doesn't convert paths, only file names 1519983b4bf2Smrg func_convert_core_path_wine_to_w32_result="" 152090b17f1bSmrg if test -n "$1"; then 152190b17f1bSmrg oldIFS=$IFS 152290b17f1bSmrg IFS=: 152390b17f1bSmrg for func_convert_core_path_wine_to_w32_f in $1; do 152490b17f1bSmrg IFS=$oldIFS 152590b17f1bSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 1526983b4bf2Smrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 152790b17f1bSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 1528983b4bf2Smrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 152990b17f1bSmrg else 153090b17f1bSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 153190b17f1bSmrg fi 15327e6fb56fSmrg fi 153390b17f1bSmrg done 153490b17f1bSmrg IFS=$oldIFS 153590b17f1bSmrg fi 153690b17f1bSmrg} 153790b17f1bSmrg# end: func_convert_core_path_wine_to_w32 153890b17f1bSmrg 153990b17f1bSmrg 154090b17f1bSmrg# func_cygpath ARGS... 154190b17f1bSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 154290b17f1bSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 154390b17f1bSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 154490b17f1bSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 154590b17f1bSmrg# file name or path is assumed to be in w32 format, as previously converted 154690b17f1bSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 154790b17f1bSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 154890b17f1bSmrg# Cygwin format). Returns an empty string on error. 154990b17f1bSmrg# 155090b17f1bSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 155190b17f1bSmrg# be converted. 155290b17f1bSmrg# 155390b17f1bSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 155490b17f1bSmrg# environment variable; do not put it in $PATH. 155590b17f1bSmrgfunc_cygpath () 155690b17f1bSmrg{ 1557983b4bf2Smrg $opt_debug 155890b17f1bSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 155990b17f1bSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 156090b17f1bSmrg if test "$?" -ne 0; then 156190b17f1bSmrg # on failure, ensure result is empty 156290b17f1bSmrg func_cygpath_result= 156390b17f1bSmrg fi 156490b17f1bSmrg else 156590b17f1bSmrg func_cygpath_result= 1566983b4bf2Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 156790b17f1bSmrg fi 156890b17f1bSmrg} 156990b17f1bSmrg#end: func_cygpath 15707e6fb56fSmrg 15717e6fb56fSmrg 157290b17f1bSmrg# func_convert_core_msys_to_w32 ARG 157390b17f1bSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 157490b17f1bSmrg# result in func_convert_core_msys_to_w32_result. 157590b17f1bSmrgfunc_convert_core_msys_to_w32 () 157690b17f1bSmrg{ 1577983b4bf2Smrg $opt_debug 157890b17f1bSmrg # awkward: cmd appends spaces to result 157990b17f1bSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 1580983b4bf2Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 158190b17f1bSmrg} 158290b17f1bSmrg#end: func_convert_core_msys_to_w32 15837e6fb56fSmrg 15847e6fb56fSmrg 158590b17f1bSmrg# func_convert_file_check ARG1 ARG2 158690b17f1bSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 158790b17f1bSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 158890b17f1bSmrg# func_to_host_file_result to ARG1). 158990b17f1bSmrgfunc_convert_file_check () 159090b17f1bSmrg{ 1591983b4bf2Smrg $opt_debug 1592983b4bf2Smrg if test -z "$2" && test -n "$1" ; then 159390b17f1bSmrg func_error "Could not determine host file name corresponding to" 1594983b4bf2Smrg func_error " \`$1'" 159590b17f1bSmrg func_error "Continuing, but uninstalled executables may not work." 159690b17f1bSmrg # Fallback: 1597983b4bf2Smrg func_to_host_file_result="$1" 159890b17f1bSmrg fi 159990b17f1bSmrg} 160090b17f1bSmrg# end func_convert_file_check 16017e6fb56fSmrg 16027e6fb56fSmrg 160390b17f1bSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 160490b17f1bSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 160590b17f1bSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 160690b17f1bSmrg# func_to_host_file_result to a simplistic fallback value (see below). 160790b17f1bSmrgfunc_convert_path_check () 160890b17f1bSmrg{ 1609983b4bf2Smrg $opt_debug 161090b17f1bSmrg if test -z "$4" && test -n "$3"; then 161190b17f1bSmrg func_error "Could not determine the host path corresponding to" 1612983b4bf2Smrg func_error " \`$3'" 161390b17f1bSmrg func_error "Continuing, but uninstalled executables may not work." 161490b17f1bSmrg # Fallback. This is a deliberately simplistic "conversion" and 161590b17f1bSmrg # should not be "improved". See libtool.info. 161690b17f1bSmrg if test "x$1" != "x$2"; then 161790b17f1bSmrg lt_replace_pathsep_chars="s|$1|$2|g" 161890b17f1bSmrg func_to_host_path_result=`echo "$3" | 161990b17f1bSmrg $SED -e "$lt_replace_pathsep_chars"` 162090b17f1bSmrg else 1621983b4bf2Smrg func_to_host_path_result="$3" 162290b17f1bSmrg fi 162390b17f1bSmrg fi 162490b17f1bSmrg} 162590b17f1bSmrg# end func_convert_path_check 16267e6fb56fSmrg 16277e6fb56fSmrg 162890b17f1bSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 162990b17f1bSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 163090b17f1bSmrg# and appending REPL if ORIG matches BACKPAT. 163190b17f1bSmrgfunc_convert_path_front_back_pathsep () 163290b17f1bSmrg{ 1633983b4bf2Smrg $opt_debug 163490b17f1bSmrg case $4 in 1635983b4bf2Smrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 163690b17f1bSmrg ;; 163790b17f1bSmrg esac 163890b17f1bSmrg case $4 in 163990b17f1bSmrg $2 ) func_append func_to_host_path_result "$3" 164090b17f1bSmrg ;; 164190b17f1bSmrg esac 164290b17f1bSmrg} 164390b17f1bSmrg# end func_convert_path_front_back_pathsep 16447e6fb56fSmrg 16457e6fb56fSmrg 164690b17f1bSmrg################################################## 164790b17f1bSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 164890b17f1bSmrg################################################## 1649983b4bf2Smrg# invoked via `$to_host_file_cmd ARG' 165090b17f1bSmrg# 165190b17f1bSmrg# In each case, ARG is the path to be converted from $build to $host format. 165290b17f1bSmrg# Result will be available in $func_to_host_file_result. 16537e6fb56fSmrg 16547e6fb56fSmrg 165590b17f1bSmrg# func_to_host_file ARG 165690b17f1bSmrg# Converts the file name ARG from $build format to $host format. Return result 165790b17f1bSmrg# in func_to_host_file_result. 165890b17f1bSmrgfunc_to_host_file () 165990b17f1bSmrg{ 1660983b4bf2Smrg $opt_debug 166190b17f1bSmrg $to_host_file_cmd "$1" 166290b17f1bSmrg} 166390b17f1bSmrg# end func_to_host_file 16647e6fb56fSmrg 16657e6fb56fSmrg 166690b17f1bSmrg# func_to_tool_file ARG LAZY 166790b17f1bSmrg# converts the file name ARG from $build format to toolchain format. Return 166890b17f1bSmrg# result in func_to_tool_file_result. If the conversion in use is listed 166990b17f1bSmrg# in (the comma separated) LAZY, no conversion takes place. 167090b17f1bSmrgfunc_to_tool_file () 167190b17f1bSmrg{ 1672983b4bf2Smrg $opt_debug 167390b17f1bSmrg case ,$2, in 167490b17f1bSmrg *,"$to_tool_file_cmd",*) 167590b17f1bSmrg func_to_tool_file_result=$1 167690b17f1bSmrg ;; 167790b17f1bSmrg *) 167890b17f1bSmrg $to_tool_file_cmd "$1" 167990b17f1bSmrg func_to_tool_file_result=$func_to_host_file_result 168090b17f1bSmrg ;; 168190b17f1bSmrg esac 168290b17f1bSmrg} 168390b17f1bSmrg# end func_to_tool_file 16847e6fb56fSmrg 16857e6fb56fSmrg 168690b17f1bSmrg# func_convert_file_noop ARG 168790b17f1bSmrg# Copy ARG to func_to_host_file_result. 168890b17f1bSmrgfunc_convert_file_noop () 168990b17f1bSmrg{ 1690983b4bf2Smrg func_to_host_file_result="$1" 169190b17f1bSmrg} 169290b17f1bSmrg# end func_convert_file_noop 16937e6fb56fSmrg 16947e6fb56fSmrg 169590b17f1bSmrg# func_convert_file_msys_to_w32 ARG 169690b17f1bSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 169790b17f1bSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 169890b17f1bSmrg# func_to_host_file_result. 169990b17f1bSmrgfunc_convert_file_msys_to_w32 () 170090b17f1bSmrg{ 1701983b4bf2Smrg $opt_debug 1702983b4bf2Smrg func_to_host_file_result="$1" 170390b17f1bSmrg if test -n "$1"; then 170490b17f1bSmrg func_convert_core_msys_to_w32 "$1" 1705983b4bf2Smrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 170690b17f1bSmrg fi 170790b17f1bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 170890b17f1bSmrg} 170990b17f1bSmrg# end func_convert_file_msys_to_w32 17107e6fb56fSmrg 17117e6fb56fSmrg 171290b17f1bSmrg# func_convert_file_cygwin_to_w32 ARG 171390b17f1bSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 171490b17f1bSmrg# func_to_host_file_result. 171590b17f1bSmrgfunc_convert_file_cygwin_to_w32 () 171690b17f1bSmrg{ 1717983b4bf2Smrg $opt_debug 1718983b4bf2Smrg func_to_host_file_result="$1" 171990b17f1bSmrg if test -n "$1"; then 172090b17f1bSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 172190b17f1bSmrg # LT_CYGPATH in this case. 172290b17f1bSmrg func_to_host_file_result=`cygpath -m "$1"` 172390b17f1bSmrg fi 172490b17f1bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 172590b17f1bSmrg} 172690b17f1bSmrg# end func_convert_file_cygwin_to_w32 17277e6fb56fSmrg 17287e6fb56fSmrg 172990b17f1bSmrg# func_convert_file_nix_to_w32 ARG 173090b17f1bSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 173190b17f1bSmrg# and a working winepath. Returns result in func_to_host_file_result. 173290b17f1bSmrgfunc_convert_file_nix_to_w32 () 173390b17f1bSmrg{ 1734983b4bf2Smrg $opt_debug 1735983b4bf2Smrg func_to_host_file_result="$1" 173690b17f1bSmrg if test -n "$1"; then 173790b17f1bSmrg func_convert_core_file_wine_to_w32 "$1" 1738983b4bf2Smrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 173990b17f1bSmrg fi 174090b17f1bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 174190b17f1bSmrg} 174290b17f1bSmrg# end func_convert_file_nix_to_w32 17437e6fb56fSmrg 17447e6fb56fSmrg 174590b17f1bSmrg# func_convert_file_msys_to_cygwin ARG 174690b17f1bSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 174790b17f1bSmrg# Returns result in func_to_host_file_result. 174890b17f1bSmrgfunc_convert_file_msys_to_cygwin () 174990b17f1bSmrg{ 1750983b4bf2Smrg $opt_debug 1751983b4bf2Smrg func_to_host_file_result="$1" 175290b17f1bSmrg if test -n "$1"; then 175390b17f1bSmrg func_convert_core_msys_to_w32 "$1" 175490b17f1bSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 1755983b4bf2Smrg func_to_host_file_result="$func_cygpath_result" 175690b17f1bSmrg fi 175790b17f1bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 175890b17f1bSmrg} 175990b17f1bSmrg# end func_convert_file_msys_to_cygwin 17607e6fb56fSmrg 17617e6fb56fSmrg 176290b17f1bSmrg# func_convert_file_nix_to_cygwin ARG 176390b17f1bSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 176490b17f1bSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 176590b17f1bSmrg# in func_to_host_file_result. 176690b17f1bSmrgfunc_convert_file_nix_to_cygwin () 176790b17f1bSmrg{ 1768983b4bf2Smrg $opt_debug 1769983b4bf2Smrg func_to_host_file_result="$1" 177090b17f1bSmrg if test -n "$1"; then 177190b17f1bSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 177290b17f1bSmrg func_convert_core_file_wine_to_w32 "$1" 177390b17f1bSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 1774983b4bf2Smrg func_to_host_file_result="$func_cygpath_result" 177590b17f1bSmrg fi 177690b17f1bSmrg func_convert_file_check "$1" "$func_to_host_file_result" 177790b17f1bSmrg} 177890b17f1bSmrg# end func_convert_file_nix_to_cygwin 17797e6fb56fSmrg 17807e6fb56fSmrg 178190b17f1bSmrg############################################# 178290b17f1bSmrg# $build to $host PATH CONVERSION FUNCTIONS # 178390b17f1bSmrg############################################# 1784983b4bf2Smrg# invoked via `$to_host_path_cmd ARG' 178590b17f1bSmrg# 178690b17f1bSmrg# In each case, ARG is the path to be converted from $build to $host format. 178790b17f1bSmrg# The result will be available in $func_to_host_path_result. 178890b17f1bSmrg# 178990b17f1bSmrg# Path separators are also converted from $build format to $host format. If 179090b17f1bSmrg# ARG begins or ends with a path separator character, it is preserved (but 179190b17f1bSmrg# converted to $host format) on output. 179290b17f1bSmrg# 179390b17f1bSmrg# All path conversion functions are named using the following convention: 179490b17f1bSmrg# file name conversion function : func_convert_file_X_to_Y () 179590b17f1bSmrg# path conversion function : func_convert_path_X_to_Y () 179690b17f1bSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 179790b17f1bSmrg# same. If conversion functions are added for new $build/$host combinations, 179890b17f1bSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 179990b17f1bSmrg# will break. 180090b17f1bSmrg 180190b17f1bSmrg 180290b17f1bSmrg# func_init_to_host_path_cmd 180390b17f1bSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 180490b17f1bSmrg# appropriate value, based on the value of $to_host_file_cmd. 180590b17f1bSmrgto_host_path_cmd= 180690b17f1bSmrgfunc_init_to_host_path_cmd () 180790b17f1bSmrg{ 1808983b4bf2Smrg $opt_debug 180990b17f1bSmrg if test -z "$to_host_path_cmd"; then 181090b17f1bSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 1811983b4bf2Smrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 181290b17f1bSmrg fi 181390b17f1bSmrg} 18147e6fb56fSmrg 18157e6fb56fSmrg 181690b17f1bSmrg# func_to_host_path ARG 181790b17f1bSmrg# Converts the path ARG from $build format to $host format. Return result 181890b17f1bSmrg# in func_to_host_path_result. 181990b17f1bSmrgfunc_to_host_path () 182090b17f1bSmrg{ 1821983b4bf2Smrg $opt_debug 182290b17f1bSmrg func_init_to_host_path_cmd 182390b17f1bSmrg $to_host_path_cmd "$1" 182490b17f1bSmrg} 182590b17f1bSmrg# end func_to_host_path 18267e6fb56fSmrg 18277e6fb56fSmrg 182890b17f1bSmrg# func_convert_path_noop ARG 182990b17f1bSmrg# Copy ARG to func_to_host_path_result. 183090b17f1bSmrgfunc_convert_path_noop () 183190b17f1bSmrg{ 1832983b4bf2Smrg func_to_host_path_result="$1" 183390b17f1bSmrg} 183490b17f1bSmrg# end func_convert_path_noop 18357e6fb56fSmrg 18367e6fb56fSmrg 183790b17f1bSmrg# func_convert_path_msys_to_w32 ARG 183890b17f1bSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 183990b17f1bSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 184090b17f1bSmrg# func_to_host_path_result. 184190b17f1bSmrgfunc_convert_path_msys_to_w32 () 184290b17f1bSmrg{ 1843983b4bf2Smrg $opt_debug 1844983b4bf2Smrg func_to_host_path_result="$1" 184590b17f1bSmrg if test -n "$1"; then 184690b17f1bSmrg # Remove leading and trailing path separator characters from ARG. MSYS 184790b17f1bSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 184890b17f1bSmrg # and winepath ignores them completely. 184990b17f1bSmrg func_stripname : : "$1" 185090b17f1bSmrg func_to_host_path_tmp1=$func_stripname_result 185190b17f1bSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1852983b4bf2Smrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 185390b17f1bSmrg func_convert_path_check : ";" \ 185490b17f1bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 185590b17f1bSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 185690b17f1bSmrg fi 185790b17f1bSmrg} 185890b17f1bSmrg# end func_convert_path_msys_to_w32 18597e6fb56fSmrg 18607e6fb56fSmrg 186190b17f1bSmrg# func_convert_path_cygwin_to_w32 ARG 186290b17f1bSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 186390b17f1bSmrg# func_to_host_file_result. 186490b17f1bSmrgfunc_convert_path_cygwin_to_w32 () 186590b17f1bSmrg{ 1866983b4bf2Smrg $opt_debug 1867983b4bf2Smrg func_to_host_path_result="$1" 186890b17f1bSmrg if test -n "$1"; then 186990b17f1bSmrg # See func_convert_path_msys_to_w32: 187090b17f1bSmrg func_stripname : : "$1" 187190b17f1bSmrg func_to_host_path_tmp1=$func_stripname_result 187290b17f1bSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 187390b17f1bSmrg func_convert_path_check : ";" \ 187490b17f1bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 187590b17f1bSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 187690b17f1bSmrg fi 187790b17f1bSmrg} 187890b17f1bSmrg# end func_convert_path_cygwin_to_w32 18797e6fb56fSmrg 18807e6fb56fSmrg 188190b17f1bSmrg# func_convert_path_nix_to_w32 ARG 188290b17f1bSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 188390b17f1bSmrg# a working winepath. Returns result in func_to_host_file_result. 188490b17f1bSmrgfunc_convert_path_nix_to_w32 () 188590b17f1bSmrg{ 1886983b4bf2Smrg $opt_debug 1887983b4bf2Smrg func_to_host_path_result="$1" 188890b17f1bSmrg if test -n "$1"; then 188990b17f1bSmrg # See func_convert_path_msys_to_w32: 189090b17f1bSmrg func_stripname : : "$1" 189190b17f1bSmrg func_to_host_path_tmp1=$func_stripname_result 189290b17f1bSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1893983b4bf2Smrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 189490b17f1bSmrg func_convert_path_check : ";" \ 189590b17f1bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 189690b17f1bSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 189790b17f1bSmrg fi 189890b17f1bSmrg} 189990b17f1bSmrg# end func_convert_path_nix_to_w32 19007e6fb56fSmrg 19017e6fb56fSmrg 190290b17f1bSmrg# func_convert_path_msys_to_cygwin ARG 190390b17f1bSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 190490b17f1bSmrg# Returns result in func_to_host_file_result. 190590b17f1bSmrgfunc_convert_path_msys_to_cygwin () 190690b17f1bSmrg{ 1907983b4bf2Smrg $opt_debug 1908983b4bf2Smrg func_to_host_path_result="$1" 190990b17f1bSmrg if test -n "$1"; then 191090b17f1bSmrg # See func_convert_path_msys_to_w32: 191190b17f1bSmrg func_stripname : : "$1" 191290b17f1bSmrg func_to_host_path_tmp1=$func_stripname_result 191390b17f1bSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 191490b17f1bSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 1915983b4bf2Smrg func_to_host_path_result="$func_cygpath_result" 191690b17f1bSmrg func_convert_path_check : : \ 191790b17f1bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 191890b17f1bSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 191990b17f1bSmrg fi 192090b17f1bSmrg} 192190b17f1bSmrg# end func_convert_path_msys_to_cygwin 19227e6fb56fSmrg 19237e6fb56fSmrg 192490b17f1bSmrg# func_convert_path_nix_to_cygwin ARG 192590b17f1bSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 192690b17f1bSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 192790b17f1bSmrg# func_to_host_file_result. 192890b17f1bSmrgfunc_convert_path_nix_to_cygwin () 192990b17f1bSmrg{ 1930983b4bf2Smrg $opt_debug 1931983b4bf2Smrg func_to_host_path_result="$1" 193290b17f1bSmrg if test -n "$1"; then 193390b17f1bSmrg # Remove leading and trailing path separator characters from 193490b17f1bSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 193590b17f1bSmrg # into '.;' and ';.', and winepath ignores them completely. 193690b17f1bSmrg func_stripname : : "$1" 193790b17f1bSmrg func_to_host_path_tmp1=$func_stripname_result 193890b17f1bSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 193990b17f1bSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 1940983b4bf2Smrg func_to_host_path_result="$func_cygpath_result" 194190b17f1bSmrg func_convert_path_check : : \ 194290b17f1bSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 194390b17f1bSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 194490b17f1bSmrg fi 194590b17f1bSmrg} 194690b17f1bSmrg# end func_convert_path_nix_to_cygwin 19477e6fb56fSmrg 19487e6fb56fSmrg 194990b17f1bSmrg# func_mode_compile arg... 195090b17f1bSmrgfunc_mode_compile () 195190b17f1bSmrg{ 1952983b4bf2Smrg $opt_debug 195390b17f1bSmrg # Get the compilation command and the source file. 195490b17f1bSmrg base_compile= 1955983b4bf2Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 195690b17f1bSmrg suppress_opt=yes 195790b17f1bSmrg suppress_output= 195890b17f1bSmrg arg_mode=normal 195990b17f1bSmrg libobj= 196090b17f1bSmrg later= 196190b17f1bSmrg pie_flag= 196290b17f1bSmrg 196390b17f1bSmrg for arg 196490b17f1bSmrg do 196590b17f1bSmrg case $arg_mode in 196690b17f1bSmrg arg ) 196790b17f1bSmrg # do not "continue". Instead, add this to base_compile 1968983b4bf2Smrg lastarg="$arg" 196990b17f1bSmrg arg_mode=normal 197090b17f1bSmrg ;; 197190b17f1bSmrg 197290b17f1bSmrg target ) 1973983b4bf2Smrg libobj="$arg" 197490b17f1bSmrg arg_mode=normal 197590b17f1bSmrg continue 197690b17f1bSmrg ;; 197790b17f1bSmrg 197890b17f1bSmrg normal ) 197990b17f1bSmrg # Accept any command-line options. 198090b17f1bSmrg case $arg in 198190b17f1bSmrg -o) 198290b17f1bSmrg test -n "$libobj" && \ 1983983b4bf2Smrg func_fatal_error "you cannot specify \`-o' more than once" 198490b17f1bSmrg arg_mode=target 19857e6fb56fSmrg continue 19867e6fb56fSmrg ;; 198790b17f1bSmrg 198890b17f1bSmrg -pie | -fpie | -fPIE) 198990b17f1bSmrg func_append pie_flag " $arg" 19907e6fb56fSmrg continue 19917e6fb56fSmrg ;; 199290b17f1bSmrg 199390b17f1bSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 199490b17f1bSmrg func_append later " $arg" 19957e6fb56fSmrg continue 19967e6fb56fSmrg ;; 199790b17f1bSmrg 199890b17f1bSmrg -no-suppress) 199990b17f1bSmrg suppress_opt=no 20007e6fb56fSmrg continue 20017e6fb56fSmrg ;; 20027e6fb56fSmrg 200390b17f1bSmrg -Xcompiler) 200490b17f1bSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 200590b17f1bSmrg continue # The current "srcfile" will either be retained or 200690b17f1bSmrg ;; # replaced later. I would guess that would be a bug. 20077e6fb56fSmrg 200890b17f1bSmrg -Wc,*) 200990b17f1bSmrg func_stripname '-Wc,' '' "$arg" 201090b17f1bSmrg args=$func_stripname_result 201190b17f1bSmrg lastarg= 2012983b4bf2Smrg save_ifs="$IFS"; IFS=',' 201390b17f1bSmrg for arg in $args; do 2014983b4bf2Smrg IFS="$save_ifs" 201590b17f1bSmrg func_append_quoted lastarg "$arg" 201690b17f1bSmrg done 2017983b4bf2Smrg IFS="$save_ifs" 201890b17f1bSmrg func_stripname ' ' '' "$lastarg" 201990b17f1bSmrg lastarg=$func_stripname_result 20207e6fb56fSmrg 202190b17f1bSmrg # Add the arguments to base_compile. 202290b17f1bSmrg func_append base_compile " $lastarg" 202390b17f1bSmrg continue 202490b17f1bSmrg ;; 20257e6fb56fSmrg 202690b17f1bSmrg *) 202790b17f1bSmrg # Accept the current argument as the source file. 202890b17f1bSmrg # The previous "srcfile" becomes the current argument. 202990b17f1bSmrg # 2030983b4bf2Smrg lastarg="$srcfile" 2031983b4bf2Smrg srcfile="$arg" 203290b17f1bSmrg ;; 203390b17f1bSmrg esac # case $arg 20347e6fb56fSmrg ;; 203590b17f1bSmrg esac # case $arg_mode 20367e6fb56fSmrg 203790b17f1bSmrg # Aesthetically quote the previous argument. 203890b17f1bSmrg func_append_quoted base_compile "$lastarg" 203990b17f1bSmrg done # for arg 20407e6fb56fSmrg 204190b17f1bSmrg case $arg_mode in 204290b17f1bSmrg arg) 204390b17f1bSmrg func_fatal_error "you must specify an argument for -Xcompile" 204490b17f1bSmrg ;; 204590b17f1bSmrg target) 2046983b4bf2Smrg func_fatal_error "you must specify a target with \`-o'" 204790b17f1bSmrg ;; 204890b17f1bSmrg *) 204990b17f1bSmrg # Get the name of the library object. 205090b17f1bSmrg test -z "$libobj" && { 205190b17f1bSmrg func_basename "$srcfile" 2052983b4bf2Smrg libobj="$func_basename_result" 205390b17f1bSmrg } 205490b17f1bSmrg ;; 205590b17f1bSmrg esac 20567e6fb56fSmrg 205790b17f1bSmrg # Recognize several different file suffixes. 205890b17f1bSmrg # If the user specifies -o file.o, it is replaced with file.lo 205990b17f1bSmrg case $libobj in 206090b17f1bSmrg *.[cCFSifmso] | \ 206190b17f1bSmrg *.ada | *.adb | *.ads | *.asm | \ 206290b17f1bSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 206390b17f1bSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 206490b17f1bSmrg func_xform "$libobj" 206590b17f1bSmrg libobj=$func_xform_result 206690b17f1bSmrg ;; 206790b17f1bSmrg esac 20687e6fb56fSmrg 206990b17f1bSmrg case $libobj in 207090b17f1bSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 207190b17f1bSmrg *) 2072983b4bf2Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 207390b17f1bSmrg ;; 207490b17f1bSmrg esac 20757e6fb56fSmrg 207690b17f1bSmrg func_infer_tag $base_compile 20777e6fb56fSmrg 207890b17f1bSmrg for arg in $later; do 207990b17f1bSmrg case $arg in 208090b17f1bSmrg -shared) 2081983b4bf2Smrg test "$build_libtool_libs" != yes && \ 2082983b4bf2Smrg func_fatal_configuration "can not build a shared library" 208390b17f1bSmrg build_old_libs=no 20847e6fb56fSmrg continue 20857e6fb56fSmrg ;; 20867e6fb56fSmrg 208790b17f1bSmrg -static) 208890b17f1bSmrg build_libtool_libs=no 208990b17f1bSmrg build_old_libs=yes 20907e6fb56fSmrg continue 20917e6fb56fSmrg ;; 20927e6fb56fSmrg 209390b17f1bSmrg -prefer-pic) 209490b17f1bSmrg pic_mode=yes 20957e6fb56fSmrg continue 20967e6fb56fSmrg ;; 20977e6fb56fSmrg 209890b17f1bSmrg -prefer-non-pic) 209990b17f1bSmrg pic_mode=no 21007e6fb56fSmrg continue 21017e6fb56fSmrg ;; 210290b17f1bSmrg esac 210390b17f1bSmrg done 21047e6fb56fSmrg 210590b17f1bSmrg func_quote_for_eval "$libobj" 210690b17f1bSmrg test "X$libobj" != "X$func_quote_for_eval_result" \ 210790b17f1bSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 2108983b4bf2Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 210990b17f1bSmrg func_dirname_and_basename "$obj" "/" "" 2110983b4bf2Smrg objname="$func_basename_result" 2111983b4bf2Smrg xdir="$func_dirname_result" 2112983b4bf2Smrg lobj=${xdir}$objdir/$objname 21137e6fb56fSmrg 211490b17f1bSmrg test -z "$base_compile" && \ 211590b17f1bSmrg func_fatal_help "you must specify a compilation command" 21167e6fb56fSmrg 211790b17f1bSmrg # Delete any leftover library objects. 2118983b4bf2Smrg if test "$build_old_libs" = yes; then 211990b17f1bSmrg removelist="$obj $lobj $libobj ${libobj}T" 212090b17f1bSmrg else 212190b17f1bSmrg removelist="$lobj $libobj ${libobj}T" 212290b17f1bSmrg fi 21237e6fb56fSmrg 212490b17f1bSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 212590b17f1bSmrg case $host_os in 212690b17f1bSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 212790b17f1bSmrg pic_mode=default 212890b17f1bSmrg ;; 212990b17f1bSmrg esac 2130983b4bf2Smrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 213190b17f1bSmrg # non-PIC code in shared libraries is not supported 213290b17f1bSmrg pic_mode=default 213390b17f1bSmrg fi 21347e6fb56fSmrg 213590b17f1bSmrg # Calculate the filename of the output object if compiler does 213690b17f1bSmrg # not support -o with -c 2137983b4bf2Smrg if test "$compiler_c_o" = no; then 2138983b4bf2Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2139983b4bf2Smrg lockfile="$output_obj.lock" 214090b17f1bSmrg else 214190b17f1bSmrg output_obj= 214290b17f1bSmrg need_locks=no 214390b17f1bSmrg lockfile= 214490b17f1bSmrg fi 21457e6fb56fSmrg 214690b17f1bSmrg # Lock this critical section if it is needed 214790b17f1bSmrg # We use this script file to make the link, it avoids creating a new file 2148983b4bf2Smrg if test "$need_locks" = yes; then 214990b17f1bSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 215090b17f1bSmrg func_echo "Waiting for $lockfile to be removed" 215190b17f1bSmrg sleep 2 215290b17f1bSmrg done 2153983b4bf2Smrg elif test "$need_locks" = warn; then 215490b17f1bSmrg if test -f "$lockfile"; then 215590b17f1bSmrg $ECHO "\ 215690b17f1bSmrg*** ERROR, $lockfile exists and contains: 215790b17f1bSmrg`cat $lockfile 2>/dev/null` 21587e6fb56fSmrg 215990b17f1bSmrgThis indicates that another process is trying to use the same 216090b17f1bSmrgtemporary object file, and libtool could not work around it because 2161983b4bf2Smrgyour compiler does not support \`-c' and \`-o' together. If you 216290b17f1bSmrgrepeat this compilation, it may succeed, by chance, but you had better 216390b17f1bSmrgavoid parallel builds (make -j) in this platform, or get a better 216490b17f1bSmrgcompiler." 21657e6fb56fSmrg 216690b17f1bSmrg $opt_dry_run || $RM $removelist 216790b17f1bSmrg exit $EXIT_FAILURE 216890b17f1bSmrg fi 216990b17f1bSmrg func_append removelist " $output_obj" 217090b17f1bSmrg $ECHO "$srcfile" > "$lockfile" 217190b17f1bSmrg fi 21727e6fb56fSmrg 217390b17f1bSmrg $opt_dry_run || $RM $removelist 217490b17f1bSmrg func_append removelist " $lockfile" 217590b17f1bSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 21767e6fb56fSmrg 217790b17f1bSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 217890b17f1bSmrg srcfile=$func_to_tool_file_result 217990b17f1bSmrg func_quote_for_eval "$srcfile" 218090b17f1bSmrg qsrcfile=$func_quote_for_eval_result 21817e6fb56fSmrg 218290b17f1bSmrg # Only build a PIC object if we are building libtool libraries. 2183983b4bf2Smrg if test "$build_libtool_libs" = yes; then 218490b17f1bSmrg # Without this assignment, base_compile gets emptied. 218590b17f1bSmrg fbsd_hideous_sh_bug=$base_compile 21867e6fb56fSmrg 2187983b4bf2Smrg if test "$pic_mode" != no; then 218890b17f1bSmrg command="$base_compile $qsrcfile $pic_flag" 218990b17f1bSmrg else 219090b17f1bSmrg # Don't build PIC code 219190b17f1bSmrg command="$base_compile $qsrcfile" 219290b17f1bSmrg fi 21937e6fb56fSmrg 219490b17f1bSmrg func_mkdir_p "$xdir$objdir" 21957e6fb56fSmrg 219690b17f1bSmrg if test -z "$output_obj"; then 219790b17f1bSmrg # Place PIC objects in $objdir 219890b17f1bSmrg func_append command " -o $lobj" 219990b17f1bSmrg fi 22007e6fb56fSmrg 220190b17f1bSmrg func_show_eval_locale "$command" \ 220290b17f1bSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 22037e6fb56fSmrg 2204983b4bf2Smrg if test "$need_locks" = warn && 220590b17f1bSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 220690b17f1bSmrg $ECHO "\ 220790b17f1bSmrg*** ERROR, $lockfile contains: 220890b17f1bSmrg`cat $lockfile 2>/dev/null` 22097e6fb56fSmrg 221090b17f1bSmrgbut it should contain: 221190b17f1bSmrg$srcfile 22127e6fb56fSmrg 221390b17f1bSmrgThis indicates that another process is trying to use the same 221490b17f1bSmrgtemporary object file, and libtool could not work around it because 2215983b4bf2Smrgyour compiler does not support \`-c' and \`-o' together. If you 221690b17f1bSmrgrepeat this compilation, it may succeed, by chance, but you had better 221790b17f1bSmrgavoid parallel builds (make -j) in this platform, or get a better 221890b17f1bSmrgcompiler." 22197e6fb56fSmrg 222090b17f1bSmrg $opt_dry_run || $RM $removelist 222190b17f1bSmrg exit $EXIT_FAILURE 222290b17f1bSmrg fi 22237e6fb56fSmrg 222490b17f1bSmrg # Just move the object if needed, then go on to compile the next one 222590b17f1bSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 222690b17f1bSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 222790b17f1bSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 222890b17f1bSmrg fi 22297e6fb56fSmrg 223090b17f1bSmrg # Allow error messages only from the first compilation. 2231983b4bf2Smrg if test "$suppress_opt" = yes; then 223290b17f1bSmrg suppress_output=' >/dev/null 2>&1' 223390b17f1bSmrg fi 223490b17f1bSmrg fi 22357e6fb56fSmrg 223690b17f1bSmrg # Only build a position-dependent object if we build old libraries. 2237983b4bf2Smrg if test "$build_old_libs" = yes; then 2238983b4bf2Smrg if test "$pic_mode" != yes; then 223990b17f1bSmrg # Don't build PIC code 224090b17f1bSmrg command="$base_compile $qsrcfile$pie_flag" 224190b17f1bSmrg else 224290b17f1bSmrg command="$base_compile $qsrcfile $pic_flag" 224390b17f1bSmrg fi 2244983b4bf2Smrg if test "$compiler_c_o" = yes; then 224590b17f1bSmrg func_append command " -o $obj" 224690b17f1bSmrg fi 22477e6fb56fSmrg 224890b17f1bSmrg # Suppress compiler output if we already did a PIC compilation. 224990b17f1bSmrg func_append command "$suppress_output" 225090b17f1bSmrg func_show_eval_locale "$command" \ 225190b17f1bSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 22527e6fb56fSmrg 2253983b4bf2Smrg if test "$need_locks" = warn && 225490b17f1bSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 225590b17f1bSmrg $ECHO "\ 225690b17f1bSmrg*** ERROR, $lockfile contains: 225790b17f1bSmrg`cat $lockfile 2>/dev/null` 22587e6fb56fSmrg 225990b17f1bSmrgbut it should contain: 226090b17f1bSmrg$srcfile 22617e6fb56fSmrg 226290b17f1bSmrgThis indicates that another process is trying to use the same 226390b17f1bSmrgtemporary object file, and libtool could not work around it because 2264983b4bf2Smrgyour compiler does not support \`-c' and \`-o' together. If you 226590b17f1bSmrgrepeat this compilation, it may succeed, by chance, but you had better 226690b17f1bSmrgavoid parallel builds (make -j) in this platform, or get a better 226790b17f1bSmrgcompiler." 22687e6fb56fSmrg 226990b17f1bSmrg $opt_dry_run || $RM $removelist 227090b17f1bSmrg exit $EXIT_FAILURE 227190b17f1bSmrg fi 22727e6fb56fSmrg 227390b17f1bSmrg # Just move the object if needed 227490b17f1bSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 227590b17f1bSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 227690b17f1bSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 227790b17f1bSmrg fi 227890b17f1bSmrg fi 22797e6fb56fSmrg 228090b17f1bSmrg $opt_dry_run || { 228190b17f1bSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 22827e6fb56fSmrg 228390b17f1bSmrg # Unlock the critical section if it was locked 2284983b4bf2Smrg if test "$need_locks" != no; then 228590b17f1bSmrg removelist=$lockfile 228690b17f1bSmrg $RM "$lockfile" 228790b17f1bSmrg fi 228890b17f1bSmrg } 22897e6fb56fSmrg 229090b17f1bSmrg exit $EXIT_SUCCESS 229190b17f1bSmrg} 22927e6fb56fSmrg 229390b17f1bSmrg$opt_help || { 2294983b4bf2Smrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 229590b17f1bSmrg} 22967e6fb56fSmrg 229790b17f1bSmrgfunc_mode_help () 229890b17f1bSmrg{ 229990b17f1bSmrg # We need to display help for each of the modes. 230090b17f1bSmrg case $opt_mode in 230190b17f1bSmrg "") 230290b17f1bSmrg # Generic help is extracted from the usage comments 230390b17f1bSmrg # at the start of this file. 230490b17f1bSmrg func_help 230590b17f1bSmrg ;; 23067e6fb56fSmrg 230790b17f1bSmrg clean) 230890b17f1bSmrg $ECHO \ 230990b17f1bSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 23107e6fb56fSmrg 231190b17f1bSmrgRemove files from the build directory. 23127e6fb56fSmrg 231390b17f1bSmrgRM is the name of the program to use to delete files associated with each FILE 2314983b4bf2Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 231590b17f1bSmrgto RM. 23167e6fb56fSmrg 231790b17f1bSmrgIf FILE is a libtool library, object or program, all the files associated 231890b17f1bSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 231990b17f1bSmrg ;; 23207e6fb56fSmrg 232190b17f1bSmrg compile) 232290b17f1bSmrg $ECHO \ 232390b17f1bSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 23247e6fb56fSmrg 232590b17f1bSmrgCompile a source file into a libtool library object. 23267e6fb56fSmrg 232790b17f1bSmrgThis mode accepts the following additional options: 23287e6fb56fSmrg 232990b17f1bSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 233090b17f1bSmrg -no-suppress do not suppress compiler output for multiple passes 233190b17f1bSmrg -prefer-pic try to build PIC objects only 233290b17f1bSmrg -prefer-non-pic try to build non-PIC objects only 2333983b4bf2Smrg -shared do not build a \`.o' file suitable for static linking 2334983b4bf2Smrg -static only build a \`.o' file suitable for static linking 233590b17f1bSmrg -Wc,FLAG pass FLAG directly to the compiler 23367e6fb56fSmrg 2337983b4bf2SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 233890b17f1bSmrgfrom the given SOURCEFILE. 23397e6fb56fSmrg 234090b17f1bSmrgThe output file name is determined by removing the directory component from 2341983b4bf2SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 2342983b4bf2Smrglibrary object suffix, \`.lo'." 234390b17f1bSmrg ;; 23447e6fb56fSmrg 234590b17f1bSmrg execute) 234690b17f1bSmrg $ECHO \ 234790b17f1bSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 23487e6fb56fSmrg 234990b17f1bSmrgAutomatically set library path, then run a program. 23507e6fb56fSmrg 235190b17f1bSmrgThis mode accepts the following additional options: 23527e6fb56fSmrg 235390b17f1bSmrg -dlopen FILE add the directory containing FILE to the library path 23547e6fb56fSmrg 2355983b4bf2SmrgThis mode sets the library path environment variable according to \`-dlopen' 235690b17f1bSmrgflags. 23577e6fb56fSmrg 235890b17f1bSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 235990b17f1bSmrginto their corresponding uninstalled binary, and any of their required library 236090b17f1bSmrgdirectories are added to the library path. 23617e6fb56fSmrg 236290b17f1bSmrgThen, COMMAND is executed, with ARGS as arguments." 236390b17f1bSmrg ;; 236490b17f1bSmrg 236590b17f1bSmrg finish) 236690b17f1bSmrg $ECHO \ 236790b17f1bSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 236890b17f1bSmrg 236990b17f1bSmrgComplete the installation of libtool libraries. 237090b17f1bSmrg 237190b17f1bSmrgEach LIBDIR is a directory that contains libtool libraries. 237290b17f1bSmrg 237390b17f1bSmrgThe commands that this mode executes may require superuser privileges. Use 2374983b4bf2Smrgthe \`--dry-run' option if you just want to see what would be executed." 237590b17f1bSmrg ;; 237690b17f1bSmrg 237790b17f1bSmrg install) 237890b17f1bSmrg $ECHO \ 237990b17f1bSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 238090b17f1bSmrg 238190b17f1bSmrgInstall executables or libraries. 238290b17f1bSmrg 238390b17f1bSmrgINSTALL-COMMAND is the installation command. The first component should be 2384983b4bf2Smrgeither the \`install' or \`cp' program. 238590b17f1bSmrg 238690b17f1bSmrgThe following components of INSTALL-COMMAND are treated specially: 238790b17f1bSmrg 238890b17f1bSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 238990b17f1bSmrg 239090b17f1bSmrgThe rest of the components are interpreted as arguments to that command (only 239190b17f1bSmrgBSD-compatible install options are recognized)." 239290b17f1bSmrg ;; 239390b17f1bSmrg 239490b17f1bSmrg link) 239590b17f1bSmrg $ECHO \ 239690b17f1bSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 239790b17f1bSmrg 239890b17f1bSmrgLink object files or libraries together to form another library, or to 239990b17f1bSmrgcreate an executable program. 240090b17f1bSmrg 240190b17f1bSmrgLINK-COMMAND is a command using the C compiler that you would use to create 240290b17f1bSmrga program from several object files. 240390b17f1bSmrg 240490b17f1bSmrgThe following components of LINK-COMMAND are treated specially: 240590b17f1bSmrg 240690b17f1bSmrg -all-static do not do any dynamic linking at all 240790b17f1bSmrg -avoid-version do not add a version suffix if possible 240890b17f1bSmrg -bindir BINDIR specify path to binaries directory (for systems where 240990b17f1bSmrg libraries must be found in the PATH setting at runtime) 2410983b4bf2Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 241190b17f1bSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 241290b17f1bSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 241390b17f1bSmrg -export-symbols SYMFILE 241490b17f1bSmrg try to export only the symbols listed in SYMFILE 241590b17f1bSmrg -export-symbols-regex REGEX 241690b17f1bSmrg try to export only the symbols matching REGEX 241790b17f1bSmrg -LLIBDIR search LIBDIR for required installed libraries 241890b17f1bSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 241990b17f1bSmrg -module build a library that can dlopened 242090b17f1bSmrg -no-fast-install disable the fast-install mode 242190b17f1bSmrg -no-install link a not-installable executable 242290b17f1bSmrg -no-undefined declare that a library does not refer to external symbols 242390b17f1bSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 2424983b4bf2Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 242590b17f1bSmrg -precious-files-regex REGEX 242690b17f1bSmrg don't remove output files matching REGEX 242790b17f1bSmrg -release RELEASE specify package release information 242890b17f1bSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 242990b17f1bSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 243090b17f1bSmrg -shared only do dynamic linking of libtool libraries 243190b17f1bSmrg -shrext SUFFIX override the standard shared library file extension 243290b17f1bSmrg -static do not do any dynamic linking of uninstalled libtool libraries 243390b17f1bSmrg -static-libtool-libs 243490b17f1bSmrg do not do any dynamic linking of libtool libraries 243590b17f1bSmrg -version-info CURRENT[:REVISION[:AGE]] 243690b17f1bSmrg specify library version info [each variable defaults to 0] 243790b17f1bSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 243890b17f1bSmrg -Wc,FLAG 243990b17f1bSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 244090b17f1bSmrg -Wl,FLAG 244190b17f1bSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 244290b17f1bSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 244390b17f1bSmrg 2444983b4bf2SmrgAll other options (arguments beginning with \`-') are ignored. 244590b17f1bSmrg 2446983b4bf2SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 244790b17f1bSmrgtreated as uninstalled libtool libraries, other files are standard or library 244890b17f1bSmrgobject files. 244990b17f1bSmrg 2450983b4bf2SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 2451983b4bf2Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 245290b17f1bSmrgrequired, except when creating a convenience library. 245390b17f1bSmrg 2454983b4bf2SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 2455983b4bf2Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 245690b17f1bSmrg 2457983b4bf2SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 245890b17f1bSmrgis created, otherwise an executable program is created." 245990b17f1bSmrg ;; 246090b17f1bSmrg 246190b17f1bSmrg uninstall) 246290b17f1bSmrg $ECHO \ 246390b17f1bSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 246490b17f1bSmrg 246590b17f1bSmrgRemove libraries from an installation directory. 246690b17f1bSmrg 246790b17f1bSmrgRM is the name of the program to use to delete files associated with each FILE 2468983b4bf2Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 246990b17f1bSmrgto RM. 247090b17f1bSmrg 247190b17f1bSmrgIf FILE is a libtool library, all the files associated with it are deleted. 247290b17f1bSmrgOtherwise, only FILE itself is deleted using RM." 247390b17f1bSmrg ;; 247490b17f1bSmrg 247590b17f1bSmrg *) 2476983b4bf2Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 247790b17f1bSmrg ;; 24787e6fb56fSmrg esac 24797e6fb56fSmrg 248090b17f1bSmrg echo 2481983b4bf2Smrg $ECHO "Try \`$progname --help' for more information about other modes." 248290b17f1bSmrg} 24837e6fb56fSmrg 248490b17f1bSmrg# Now that we've collected a possible --mode arg, show help if necessary 248590b17f1bSmrgif $opt_help; then 2486983b4bf2Smrg if test "$opt_help" = :; then 248790b17f1bSmrg func_mode_help 248890b17f1bSmrg else 248990b17f1bSmrg { 249090b17f1bSmrg func_help noexit 249190b17f1bSmrg for opt_mode in compile link execute install finish uninstall clean; do 249290b17f1bSmrg func_mode_help 249390b17f1bSmrg done 2494983b4bf2Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 249590b17f1bSmrg { 249690b17f1bSmrg func_help noexit 249790b17f1bSmrg for opt_mode in compile link execute install finish uninstall clean; do 249890b17f1bSmrg echo 249990b17f1bSmrg func_mode_help 250090b17f1bSmrg done 250190b17f1bSmrg } | 2502983b4bf2Smrg sed '1d 250390b17f1bSmrg /^When reporting/,/^Report/{ 250490b17f1bSmrg H 250590b17f1bSmrg d 250690b17f1bSmrg } 250790b17f1bSmrg $x 250890b17f1bSmrg /information about other modes/d 250990b17f1bSmrg /more detailed .*MODE/d 251090b17f1bSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 251190b17f1bSmrg fi 251290b17f1bSmrg exit $? 251390b17f1bSmrgfi 25147e6fb56fSmrg 25157e6fb56fSmrg 251690b17f1bSmrg# func_mode_execute arg... 251790b17f1bSmrgfunc_mode_execute () 251890b17f1bSmrg{ 2519983b4bf2Smrg $opt_debug 252090b17f1bSmrg # The first argument is the command name. 2521983b4bf2Smrg cmd="$nonopt" 252290b17f1bSmrg test -z "$cmd" && \ 252390b17f1bSmrg func_fatal_help "you must specify a COMMAND" 252490b17f1bSmrg 252590b17f1bSmrg # Handle -dlopen flags immediately. 252690b17f1bSmrg for file in $opt_dlopen; do 252790b17f1bSmrg test -f "$file" \ 2528983b4bf2Smrg || func_fatal_help "\`$file' is not a file" 252990b17f1bSmrg 253090b17f1bSmrg dir= 253190b17f1bSmrg case $file in 253290b17f1bSmrg *.la) 253390b17f1bSmrg func_resolve_sysroot "$file" 253490b17f1bSmrg file=$func_resolve_sysroot_result 253590b17f1bSmrg 253690b17f1bSmrg # Check to see that this really is a libtool archive. 253790b17f1bSmrg func_lalib_unsafe_p "$file" \ 2538983b4bf2Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 253990b17f1bSmrg 254090b17f1bSmrg # Read the libtool library. 254190b17f1bSmrg dlname= 254290b17f1bSmrg library_names= 254390b17f1bSmrg func_source "$file" 254490b17f1bSmrg 254590b17f1bSmrg # Skip this library if it cannot be dlopened. 254690b17f1bSmrg if test -z "$dlname"; then 254790b17f1bSmrg # Warn if it was a shared library. 254890b17f1bSmrg test -n "$library_names" && \ 2549983b4bf2Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 255090b17f1bSmrg continue 255190b17f1bSmrg fi 255290b17f1bSmrg 255390b17f1bSmrg func_dirname "$file" "" "." 2554983b4bf2Smrg dir="$func_dirname_result" 255590b17f1bSmrg 255690b17f1bSmrg if test -f "$dir/$objdir/$dlname"; then 255790b17f1bSmrg func_append dir "/$objdir" 255890b17f1bSmrg else 255990b17f1bSmrg if test ! -f "$dir/$dlname"; then 2560983b4bf2Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 256190b17f1bSmrg fi 256290b17f1bSmrg fi 25637e6fb56fSmrg ;; 256490b17f1bSmrg 256590b17f1bSmrg *.lo) 256690b17f1bSmrg # Just add the directory containing the .lo file. 256790b17f1bSmrg func_dirname "$file" "" "." 2568983b4bf2Smrg dir="$func_dirname_result" 25697e6fb56fSmrg ;; 257090b17f1bSmrg 257190b17f1bSmrg *) 2572983b4bf2Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 257390b17f1bSmrg continue 25747e6fb56fSmrg ;; 257590b17f1bSmrg esac 257690b17f1bSmrg 257790b17f1bSmrg # Get the absolute pathname. 257890b17f1bSmrg absdir=`cd "$dir" && pwd` 2579983b4bf2Smrg test -n "$absdir" && dir="$absdir" 258090b17f1bSmrg 258190b17f1bSmrg # Now add the directory to shlibpath_var. 258290b17f1bSmrg if eval "test -z \"\$$shlibpath_var\""; then 258390b17f1bSmrg eval "$shlibpath_var=\"\$dir\"" 258490b17f1bSmrg else 258590b17f1bSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 25867e6fb56fSmrg fi 258790b17f1bSmrg done 258890b17f1bSmrg 258990b17f1bSmrg # This variable tells wrapper scripts just to set shlibpath_var 259090b17f1bSmrg # rather than running their programs. 2591983b4bf2Smrg libtool_execute_magic="$magic" 259290b17f1bSmrg 259390b17f1bSmrg # Check if any of the arguments is a wrapper script. 259490b17f1bSmrg args= 259590b17f1bSmrg for file 259690b17f1bSmrg do 259790b17f1bSmrg case $file in 259890b17f1bSmrg -* | *.la | *.lo ) ;; 259990b17f1bSmrg *) 260090b17f1bSmrg # Do a test to see if this is really a libtool program. 260190b17f1bSmrg if func_ltwrapper_script_p "$file"; then 260290b17f1bSmrg func_source "$file" 260390b17f1bSmrg # Transform arg to wrapped name. 2604983b4bf2Smrg file="$progdir/$program" 260590b17f1bSmrg elif func_ltwrapper_executable_p "$file"; then 260690b17f1bSmrg func_ltwrapper_scriptname "$file" 260790b17f1bSmrg func_source "$func_ltwrapper_scriptname_result" 260890b17f1bSmrg # Transform arg to wrapped name. 2609983b4bf2Smrg file="$progdir/$program" 261090b17f1bSmrg fi 261190b17f1bSmrg ;; 261290b17f1bSmrg esac 261390b17f1bSmrg # Quote arguments (to preserve shell metacharacters). 261490b17f1bSmrg func_append_quoted args "$file" 261590b17f1bSmrg done 261690b17f1bSmrg 2617983b4bf2Smrg if test "X$opt_dry_run" = Xfalse; then 261890b17f1bSmrg if test -n "$shlibpath_var"; then 261990b17f1bSmrg # Export the shlibpath_var. 262090b17f1bSmrg eval "export $shlibpath_var" 26217e6fb56fSmrg fi 262290b17f1bSmrg 262390b17f1bSmrg # Restore saved environment variables 262490b17f1bSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 262590b17f1bSmrg do 262690b17f1bSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 262790b17f1bSmrg $lt_var=\$save_$lt_var; export $lt_var 262890b17f1bSmrg else 262990b17f1bSmrg $lt_unset $lt_var 263090b17f1bSmrg fi" 263190b17f1bSmrg done 263290b17f1bSmrg 263390b17f1bSmrg # Now prepare to actually exec the command. 2634983b4bf2Smrg exec_cmd="\$cmd$args" 2635983b4bf2Smrg else 2636983b4bf2Smrg # Display what would be done. 2637983b4bf2Smrg if test -n "$shlibpath_var"; then 2638983b4bf2Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 2639983b4bf2Smrg echo "export $shlibpath_var" 2640983b4bf2Smrg fi 2641983b4bf2Smrg $ECHO "$cmd$args" 2642983b4bf2Smrg exit $EXIT_SUCCESS 264390b17f1bSmrg fi 264490b17f1bSmrg} 26457e6fb56fSmrg 2646983b4bf2Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 26477e6fb56fSmrg 26487e6fb56fSmrg 264990b17f1bSmrg# func_mode_finish arg... 265090b17f1bSmrgfunc_mode_finish () 265190b17f1bSmrg{ 2652983b4bf2Smrg $opt_debug 265390b17f1bSmrg libs= 265490b17f1bSmrg libdirs= 265590b17f1bSmrg admincmds= 26567e6fb56fSmrg 265790b17f1bSmrg for opt in "$nonopt" ${1+"$@"} 265890b17f1bSmrg do 265990b17f1bSmrg if test -d "$opt"; then 266090b17f1bSmrg func_append libdirs " $opt" 26617e6fb56fSmrg 266290b17f1bSmrg elif test -f "$opt"; then 266390b17f1bSmrg if func_lalib_unsafe_p "$opt"; then 266490b17f1bSmrg func_append libs " $opt" 266590b17f1bSmrg else 2666983b4bf2Smrg func_warning "\`$opt' is not a valid libtool archive" 26677e6fb56fSmrg fi 26687e6fb56fSmrg 266990b17f1bSmrg else 2670983b4bf2Smrg func_fatal_error "invalid argument \`$opt'" 267190b17f1bSmrg fi 267290b17f1bSmrg done 26737e6fb56fSmrg 267490b17f1bSmrg if test -n "$libs"; then 267590b17f1bSmrg if test -n "$lt_sysroot"; then 267690b17f1bSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 267790b17f1bSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 267890b17f1bSmrg else 267990b17f1bSmrg sysroot_cmd= 268090b17f1bSmrg fi 26817e6fb56fSmrg 268290b17f1bSmrg # Remove sysroot references 268390b17f1bSmrg if $opt_dry_run; then 268490b17f1bSmrg for lib in $libs; do 2685983b4bf2Smrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 268690b17f1bSmrg done 268790b17f1bSmrg else 268890b17f1bSmrg tmpdir=`func_mktempdir` 268990b17f1bSmrg for lib in $libs; do 2690983b4bf2Smrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 269190b17f1bSmrg > $tmpdir/tmp-la 269290b17f1bSmrg mv -f $tmpdir/tmp-la $lib 26937e6fb56fSmrg done 269490b17f1bSmrg ${RM}r "$tmpdir" 269590b17f1bSmrg fi 269690b17f1bSmrg fi 269790b17f1bSmrg 269890b17f1bSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 269990b17f1bSmrg for libdir in $libdirs; do 270090b17f1bSmrg if test -n "$finish_cmds"; then 270190b17f1bSmrg # Do each command in the finish commands. 270290b17f1bSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 270390b17f1bSmrg'"$cmd"'"' 270490b17f1bSmrg fi 270590b17f1bSmrg if test -n "$finish_eval"; then 270690b17f1bSmrg # Do the single finish_eval. 270790b17f1bSmrg eval cmds=\"$finish_eval\" 270890b17f1bSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 270990b17f1bSmrg $cmds" 27107e6fb56fSmrg fi 271190b17f1bSmrg done 271290b17f1bSmrg fi 27137e6fb56fSmrg 271490b17f1bSmrg # Exit here if they wanted silent mode. 2715983b4bf2Smrg $opt_silent && exit $EXIT_SUCCESS 27167e6fb56fSmrg 271790b17f1bSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 271890b17f1bSmrg echo "----------------------------------------------------------------------" 271990b17f1bSmrg echo "Libraries have been installed in:" 272090b17f1bSmrg for libdir in $libdirs; do 272190b17f1bSmrg $ECHO " $libdir" 272290b17f1bSmrg done 272390b17f1bSmrg echo 272490b17f1bSmrg echo "If you ever happen to want to link against installed libraries" 272590b17f1bSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 2726983b4bf2Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 272790b17f1bSmrg echo "flag during linking and do at least one of the following:" 272890b17f1bSmrg if test -n "$shlibpath_var"; then 2729983b4bf2Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 273090b17f1bSmrg echo " during execution" 273190b17f1bSmrg fi 273290b17f1bSmrg if test -n "$runpath_var"; then 2733983b4bf2Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 273490b17f1bSmrg echo " during linking" 273590b17f1bSmrg fi 273690b17f1bSmrg if test -n "$hardcode_libdir_flag_spec"; then 273790b17f1bSmrg libdir=LIBDIR 273890b17f1bSmrg eval flag=\"$hardcode_libdir_flag_spec\" 273990b17f1bSmrg 2740983b4bf2Smrg $ECHO " - use the \`$flag' linker flag" 274190b17f1bSmrg fi 274290b17f1bSmrg if test -n "$admincmds"; then 274390b17f1bSmrg $ECHO " - have your system administrator run these commands:$admincmds" 274490b17f1bSmrg fi 274590b17f1bSmrg if test -f /etc/ld.so.conf; then 2746983b4bf2Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 274790b17f1bSmrg fi 274890b17f1bSmrg echo 274990b17f1bSmrg 275090b17f1bSmrg echo "See any operating system documentation about shared libraries for" 275190b17f1bSmrg case $host in 275290b17f1bSmrg solaris2.[6789]|solaris2.1[0-9]) 275390b17f1bSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 275490b17f1bSmrg echo "pages." 275590b17f1bSmrg ;; 27567e6fb56fSmrg *) 275790b17f1bSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 27587e6fb56fSmrg ;; 275990b17f1bSmrg esac 276090b17f1bSmrg echo "----------------------------------------------------------------------" 276190b17f1bSmrg fi 276290b17f1bSmrg exit $EXIT_SUCCESS 276390b17f1bSmrg} 27647e6fb56fSmrg 2765983b4bf2Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 27667e6fb56fSmrg 27677e6fb56fSmrg 276890b17f1bSmrg# func_mode_install arg... 276990b17f1bSmrgfunc_mode_install () 277090b17f1bSmrg{ 2771983b4bf2Smrg $opt_debug 277290b17f1bSmrg # There may be an optional sh(1) argument at the beginning of 277390b17f1bSmrg # install_prog (especially on Windows NT). 2774983b4bf2Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 277590b17f1bSmrg # Allow the use of GNU shtool's install command. 2776983b4bf2Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 277790b17f1bSmrg # Aesthetically quote it. 277890b17f1bSmrg func_quote_for_eval "$nonopt" 277990b17f1bSmrg install_prog="$func_quote_for_eval_result " 278090b17f1bSmrg arg=$1 278190b17f1bSmrg shift 278290b17f1bSmrg else 278390b17f1bSmrg install_prog= 278490b17f1bSmrg arg=$nonopt 278590b17f1bSmrg fi 278690b17f1bSmrg 278790b17f1bSmrg # The real first argument should be the name of the installation program. 278890b17f1bSmrg # Aesthetically quote it. 278990b17f1bSmrg func_quote_for_eval "$arg" 279090b17f1bSmrg func_append install_prog "$func_quote_for_eval_result" 279190b17f1bSmrg install_shared_prog=$install_prog 279290b17f1bSmrg case " $install_prog " in 279390b17f1bSmrg *[\\\ /]cp\ *) install_cp=: ;; 279490b17f1bSmrg *) install_cp=false ;; 279590b17f1bSmrg esac 279690b17f1bSmrg 279790b17f1bSmrg # We need to accept at least all the BSD install flags. 279890b17f1bSmrg dest= 279990b17f1bSmrg files= 280090b17f1bSmrg opts= 280190b17f1bSmrg prev= 280290b17f1bSmrg install_type= 2803983b4bf2Smrg isdir=no 280490b17f1bSmrg stripme= 280590b17f1bSmrg no_mode=: 280690b17f1bSmrg for arg 280790b17f1bSmrg do 280890b17f1bSmrg arg2= 280990b17f1bSmrg if test -n "$dest"; then 281090b17f1bSmrg func_append files " $dest" 281190b17f1bSmrg dest=$arg 281290b17f1bSmrg continue 281390b17f1bSmrg fi 281490b17f1bSmrg 281590b17f1bSmrg case $arg in 2816983b4bf2Smrg -d) isdir=yes ;; 281790b17f1bSmrg -f) 281890b17f1bSmrg if $install_cp; then :; else 281990b17f1bSmrg prev=$arg 282090b17f1bSmrg fi 282190b17f1bSmrg ;; 282290b17f1bSmrg -g | -m | -o) 282390b17f1bSmrg prev=$arg 282490b17f1bSmrg ;; 282590b17f1bSmrg -s) 282690b17f1bSmrg stripme=" -s" 282790b17f1bSmrg continue 282890b17f1bSmrg ;; 282990b17f1bSmrg -*) 283090b17f1bSmrg ;; 283190b17f1bSmrg *) 283290b17f1bSmrg # If the previous option needed an argument, then skip it. 283390b17f1bSmrg if test -n "$prev"; then 2834983b4bf2Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 283590b17f1bSmrg arg2=$install_override_mode 283690b17f1bSmrg no_mode=false 28377e6fb56fSmrg fi 283890b17f1bSmrg prev= 283990b17f1bSmrg else 284090b17f1bSmrg dest=$arg 28417e6fb56fSmrg continue 28427e6fb56fSmrg fi 284390b17f1bSmrg ;; 284490b17f1bSmrg esac 28457e6fb56fSmrg 284690b17f1bSmrg # Aesthetically quote the argument. 284790b17f1bSmrg func_quote_for_eval "$arg" 284890b17f1bSmrg func_append install_prog " $func_quote_for_eval_result" 284990b17f1bSmrg if test -n "$arg2"; then 285090b17f1bSmrg func_quote_for_eval "$arg2" 285190b17f1bSmrg fi 285290b17f1bSmrg func_append install_shared_prog " $func_quote_for_eval_result" 285390b17f1bSmrg done 28547e6fb56fSmrg 285590b17f1bSmrg test -z "$install_prog" && \ 285690b17f1bSmrg func_fatal_help "you must specify an install program" 28577e6fb56fSmrg 285890b17f1bSmrg test -n "$prev" && \ 2859983b4bf2Smrg func_fatal_help "the \`$prev' option requires an argument" 28607e6fb56fSmrg 286190b17f1bSmrg if test -n "$install_override_mode" && $no_mode; then 286290b17f1bSmrg if $install_cp; then :; else 286390b17f1bSmrg func_quote_for_eval "$install_override_mode" 286490b17f1bSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 286590b17f1bSmrg fi 286690b17f1bSmrg fi 28677e6fb56fSmrg 286890b17f1bSmrg if test -z "$files"; then 286990b17f1bSmrg if test -z "$dest"; then 287090b17f1bSmrg func_fatal_help "no file or destination specified" 287190b17f1bSmrg else 287290b17f1bSmrg func_fatal_help "you must specify a destination" 287390b17f1bSmrg fi 287490b17f1bSmrg fi 28757e6fb56fSmrg 287690b17f1bSmrg # Strip any trailing slash from the destination. 287790b17f1bSmrg func_stripname '' '/' "$dest" 287890b17f1bSmrg dest=$func_stripname_result 28797e6fb56fSmrg 288090b17f1bSmrg # Check to see that the destination is a directory. 2881983b4bf2Smrg test -d "$dest" && isdir=yes 2882983b4bf2Smrg if test "$isdir" = yes; then 2883983b4bf2Smrg destdir="$dest" 288490b17f1bSmrg destname= 288590b17f1bSmrg else 288690b17f1bSmrg func_dirname_and_basename "$dest" "" "." 2887983b4bf2Smrg destdir="$func_dirname_result" 2888983b4bf2Smrg destname="$func_basename_result" 28897e6fb56fSmrg 289090b17f1bSmrg # Not a directory, so check to see that there is only one file specified. 289190b17f1bSmrg set dummy $files; shift 289290b17f1bSmrg test "$#" -gt 1 && \ 2893983b4bf2Smrg func_fatal_help "\`$dest' is not a directory" 289490b17f1bSmrg fi 289590b17f1bSmrg case $destdir in 289690b17f1bSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 289790b17f1bSmrg *) 289890b17f1bSmrg for file in $files; do 289990b17f1bSmrg case $file in 290090b17f1bSmrg *.lo) ;; 290190b17f1bSmrg *) 2902983b4bf2Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 290390b17f1bSmrg ;; 290490b17f1bSmrg esac 290590b17f1bSmrg done 290690b17f1bSmrg ;; 290790b17f1bSmrg esac 29087e6fb56fSmrg 290990b17f1bSmrg # This variable tells wrapper scripts just to set variables rather 291090b17f1bSmrg # than running their programs. 2911983b4bf2Smrg libtool_install_magic="$magic" 29127e6fb56fSmrg 291390b17f1bSmrg staticlibs= 291490b17f1bSmrg future_libdirs= 291590b17f1bSmrg current_libdirs= 291690b17f1bSmrg for file in $files; do 29177e6fb56fSmrg 291890b17f1bSmrg # Do each installation. 291990b17f1bSmrg case $file in 292090b17f1bSmrg *.$libext) 292190b17f1bSmrg # Do the static libraries later. 292290b17f1bSmrg func_append staticlibs " $file" 292390b17f1bSmrg ;; 29247e6fb56fSmrg 292590b17f1bSmrg *.la) 292690b17f1bSmrg func_resolve_sysroot "$file" 292790b17f1bSmrg file=$func_resolve_sysroot_result 29287e6fb56fSmrg 292990b17f1bSmrg # Check to see that this really is a libtool archive. 293090b17f1bSmrg func_lalib_unsafe_p "$file" \ 2931983b4bf2Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 29327e6fb56fSmrg 293390b17f1bSmrg library_names= 293490b17f1bSmrg old_library= 293590b17f1bSmrg relink_command= 293690b17f1bSmrg func_source "$file" 29377e6fb56fSmrg 293890b17f1bSmrg # Add the libdir to current_libdirs if it is the destination. 293990b17f1bSmrg if test "X$destdir" = "X$libdir"; then 294090b17f1bSmrg case "$current_libdirs " in 294190b17f1bSmrg *" $libdir "*) ;; 294290b17f1bSmrg *) func_append current_libdirs " $libdir" ;; 294390b17f1bSmrg esac 294490b17f1bSmrg else 294590b17f1bSmrg # Note the libdir as a future libdir. 294690b17f1bSmrg case "$future_libdirs " in 294790b17f1bSmrg *" $libdir "*) ;; 294890b17f1bSmrg *) func_append future_libdirs " $libdir" ;; 294990b17f1bSmrg esac 295090b17f1bSmrg fi 29517e6fb56fSmrg 295290b17f1bSmrg func_dirname "$file" "/" "" 2953983b4bf2Smrg dir="$func_dirname_result" 295490b17f1bSmrg func_append dir "$objdir" 29557e6fb56fSmrg 295690b17f1bSmrg if test -n "$relink_command"; then 295790b17f1bSmrg # Determine the prefix the user has applied to our future dir. 295890b17f1bSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 29597e6fb56fSmrg 296090b17f1bSmrg # Don't allow the user to place us outside of our expected 296190b17f1bSmrg # location b/c this prevents finding dependent libraries that 296290b17f1bSmrg # are installed to the same prefix. 296390b17f1bSmrg # At present, this check doesn't affect windows .dll's that 296490b17f1bSmrg # are installed into $libdir/../bin (currently, that works fine) 296590b17f1bSmrg # but it's something to keep an eye on. 296690b17f1bSmrg test "$inst_prefix_dir" = "$destdir" && \ 2967983b4bf2Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 296890b17f1bSmrg 296990b17f1bSmrg if test -n "$inst_prefix_dir"; then 297090b17f1bSmrg # Stick the inst_prefix_dir data into the link command. 297190b17f1bSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 29727e6fb56fSmrg else 297390b17f1bSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 29747e6fb56fSmrg fi 29757e6fb56fSmrg 2976983b4bf2Smrg func_warning "relinking \`$file'" 297790b17f1bSmrg func_show_eval "$relink_command" \ 2978983b4bf2Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 297990b17f1bSmrg fi 298090b17f1bSmrg 298190b17f1bSmrg # See the names of the shared library. 298290b17f1bSmrg set dummy $library_names; shift 298390b17f1bSmrg if test -n "$1"; then 2984983b4bf2Smrg realname="$1" 298590b17f1bSmrg shift 298690b17f1bSmrg 2987983b4bf2Smrg srcname="$realname" 2988983b4bf2Smrg test -n "$relink_command" && srcname="$realname"T 298990b17f1bSmrg 299090b17f1bSmrg # Install the shared library and build the symlinks. 299190b17f1bSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 299290b17f1bSmrg 'exit $?' 2993983b4bf2Smrg tstripme="$stripme" 299490b17f1bSmrg case $host_os in 299590b17f1bSmrg cygwin* | mingw* | pw32* | cegcc*) 299690b17f1bSmrg case $realname in 299790b17f1bSmrg *.dll.a) 2998983b4bf2Smrg tstripme="" 299990b17f1bSmrg ;; 300090b17f1bSmrg esac 300190b17f1bSmrg ;; 300290b17f1bSmrg esac 300390b17f1bSmrg if test -n "$tstripme" && test -n "$striplib"; then 300490b17f1bSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 30057e6fb56fSmrg fi 30067e6fb56fSmrg 300790b17f1bSmrg if test "$#" -gt 0; then 300890b17f1bSmrg # Delete the old symlinks, and create new ones. 3009983b4bf2Smrg # Try `ln -sf' first, because the `ln' binary might depend on 301090b17f1bSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 301190b17f1bSmrg # so we also need to try rm && ln -s. 301290b17f1bSmrg for linkname 301390b17f1bSmrg do 301490b17f1bSmrg test "$linkname" != "$realname" \ 301590b17f1bSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 30167e6fb56fSmrg done 30177e6fb56fSmrg fi 30187e6fb56fSmrg 301990b17f1bSmrg # Do each command in the postinstall commands. 3020983b4bf2Smrg lib="$destdir/$realname" 302190b17f1bSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 302290b17f1bSmrg fi 30237e6fb56fSmrg 302490b17f1bSmrg # Install the pseudo-library for information purposes. 302590b17f1bSmrg func_basename "$file" 3026983b4bf2Smrg name="$func_basename_result" 3027983b4bf2Smrg instname="$dir/$name"i 302890b17f1bSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 30297e6fb56fSmrg 303090b17f1bSmrg # Maybe install the static library, too. 303190b17f1bSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 303290b17f1bSmrg ;; 303390b17f1bSmrg 303490b17f1bSmrg *.lo) 303590b17f1bSmrg # Install (i.e. copy) a libtool object. 303690b17f1bSmrg 303790b17f1bSmrg # Figure out destination file name, if it wasn't already specified. 303890b17f1bSmrg if test -n "$destname"; then 3039983b4bf2Smrg destfile="$destdir/$destname" 30407e6fb56fSmrg else 304190b17f1bSmrg func_basename "$file" 3042983b4bf2Smrg destfile="$func_basename_result" 3043983b4bf2Smrg destfile="$destdir/$destfile" 30447e6fb56fSmrg fi 304590b17f1bSmrg 304690b17f1bSmrg # Deduce the name of the destination old-style object file. 304790b17f1bSmrg case $destfile in 304890b17f1bSmrg *.lo) 304990b17f1bSmrg func_lo2o "$destfile" 305090b17f1bSmrg staticdest=$func_lo2o_result 305190b17f1bSmrg ;; 305290b17f1bSmrg *.$objext) 3053983b4bf2Smrg staticdest="$destfile" 305490b17f1bSmrg destfile= 305590b17f1bSmrg ;; 305690b17f1bSmrg *) 3057983b4bf2Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 30587e6fb56fSmrg ;; 30597e6fb56fSmrg esac 30607e6fb56fSmrg 306190b17f1bSmrg # Install the libtool object if requested. 306290b17f1bSmrg test -n "$destfile" && \ 306390b17f1bSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 30647e6fb56fSmrg 306590b17f1bSmrg # Install the old object if enabled. 3066983b4bf2Smrg if test "$build_old_libs" = yes; then 306790b17f1bSmrg # Deduce the name of the old-style object file. 306890b17f1bSmrg func_lo2o "$file" 306990b17f1bSmrg staticobj=$func_lo2o_result 307090b17f1bSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 307190b17f1bSmrg fi 307290b17f1bSmrg exit $EXIT_SUCCESS 307390b17f1bSmrg ;; 30747e6fb56fSmrg 307590b17f1bSmrg *) 307690b17f1bSmrg # Figure out destination file name, if it wasn't already specified. 307790b17f1bSmrg if test -n "$destname"; then 3078983b4bf2Smrg destfile="$destdir/$destname" 307990b17f1bSmrg else 308090b17f1bSmrg func_basename "$file" 3081983b4bf2Smrg destfile="$func_basename_result" 3082983b4bf2Smrg destfile="$destdir/$destfile" 308390b17f1bSmrg fi 30847e6fb56fSmrg 308590b17f1bSmrg # If the file is missing, and there is a .exe on the end, strip it 308690b17f1bSmrg # because it is most likely a libtool script we actually want to 308790b17f1bSmrg # install 3088983b4bf2Smrg stripped_ext="" 308990b17f1bSmrg case $file in 309090b17f1bSmrg *.exe) 309190b17f1bSmrg if test ! -f "$file"; then 309290b17f1bSmrg func_stripname '' '.exe' "$file" 309390b17f1bSmrg file=$func_stripname_result 3094983b4bf2Smrg stripped_ext=".exe" 309590b17f1bSmrg fi 309690b17f1bSmrg ;; 309790b17f1bSmrg esac 30987e6fb56fSmrg 309990b17f1bSmrg # Do a test to see if this is really a libtool program. 310090b17f1bSmrg case $host in 310190b17f1bSmrg *cygwin* | *mingw*) 310290b17f1bSmrg if func_ltwrapper_executable_p "$file"; then 310390b17f1bSmrg func_ltwrapper_scriptname "$file" 310490b17f1bSmrg wrapper=$func_ltwrapper_scriptname_result 310590b17f1bSmrg else 310690b17f1bSmrg func_stripname '' '.exe' "$file" 310790b17f1bSmrg wrapper=$func_stripname_result 310890b17f1bSmrg fi 310990b17f1bSmrg ;; 311090b17f1bSmrg *) 311190b17f1bSmrg wrapper=$file 311290b17f1bSmrg ;; 311390b17f1bSmrg esac 311490b17f1bSmrg if func_ltwrapper_script_p "$wrapper"; then 311590b17f1bSmrg notinst_deplibs= 311690b17f1bSmrg relink_command= 31177e6fb56fSmrg 311890b17f1bSmrg func_source "$wrapper" 31197e6fb56fSmrg 312090b17f1bSmrg # Check the variables that should have been set. 312190b17f1bSmrg test -z "$generated_by_libtool_version" && \ 3122983b4bf2Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 31237e6fb56fSmrg 3124983b4bf2Smrg finalize=yes 312590b17f1bSmrg for lib in $notinst_deplibs; do 312690b17f1bSmrg # Check to see that each library is installed. 312790b17f1bSmrg libdir= 312890b17f1bSmrg if test -f "$lib"; then 312990b17f1bSmrg func_source "$lib" 313090b17f1bSmrg fi 3131983b4bf2Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 313290b17f1bSmrg if test -n "$libdir" && test ! -f "$libfile"; then 3133983b4bf2Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 3134983b4bf2Smrg finalize=no 313590b17f1bSmrg fi 313690b17f1bSmrg done 31377e6fb56fSmrg 313890b17f1bSmrg relink_command= 313990b17f1bSmrg func_source "$wrapper" 314090b17f1bSmrg 314190b17f1bSmrg outputname= 3142983b4bf2Smrg if test "$fast_install" = no && test -n "$relink_command"; then 314390b17f1bSmrg $opt_dry_run || { 3144983b4bf2Smrg if test "$finalize" = yes; then 314590b17f1bSmrg tmpdir=`func_mktempdir` 314690b17f1bSmrg func_basename "$file$stripped_ext" 3147983b4bf2Smrg file="$func_basename_result" 3148983b4bf2Smrg outputname="$tmpdir/$file" 314990b17f1bSmrg # Replace the output file specification. 315090b17f1bSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 315190b17f1bSmrg 3152983b4bf2Smrg $opt_silent || { 315390b17f1bSmrg func_quote_for_expand "$relink_command" 315490b17f1bSmrg eval "func_echo $func_quote_for_expand_result" 315590b17f1bSmrg } 315690b17f1bSmrg if eval "$relink_command"; then : 315790b17f1bSmrg else 3158983b4bf2Smrg func_error "error: relink \`$file' with the above command before installing it" 315990b17f1bSmrg $opt_dry_run || ${RM}r "$tmpdir" 316090b17f1bSmrg continue 316190b17f1bSmrg fi 3162983b4bf2Smrg file="$outputname" 316390b17f1bSmrg else 3164983b4bf2Smrg func_warning "cannot relink \`$file'" 316590b17f1bSmrg fi 316690b17f1bSmrg } 316790b17f1bSmrg else 316890b17f1bSmrg # Install the binary that we compiled earlier. 316990b17f1bSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 317090b17f1bSmrg fi 31717e6fb56fSmrg fi 317290b17f1bSmrg 317390b17f1bSmrg # remove .exe since cygwin /usr/bin/install will append another 317490b17f1bSmrg # one anyway 317590b17f1bSmrg case $install_prog,$host in 317690b17f1bSmrg */usr/bin/install*,*cygwin*) 317790b17f1bSmrg case $file:$destfile in 317890b17f1bSmrg *.exe:*.exe) 317990b17f1bSmrg # this is ok 318090b17f1bSmrg ;; 318190b17f1bSmrg *.exe:*) 318290b17f1bSmrg destfile=$destfile.exe 318390b17f1bSmrg ;; 318490b17f1bSmrg *:*.exe) 318590b17f1bSmrg func_stripname '' '.exe' "$destfile" 318690b17f1bSmrg destfile=$func_stripname_result 318790b17f1bSmrg ;; 318890b17f1bSmrg esac 318990b17f1bSmrg ;; 319090b17f1bSmrg esac 319190b17f1bSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 319290b17f1bSmrg $opt_dry_run || if test -n "$outputname"; then 319390b17f1bSmrg ${RM}r "$tmpdir" 31947e6fb56fSmrg fi 31957e6fb56fSmrg ;; 31967e6fb56fSmrg esac 319790b17f1bSmrg done 31987e6fb56fSmrg 319990b17f1bSmrg for file in $staticlibs; do 320090b17f1bSmrg func_basename "$file" 3201983b4bf2Smrg name="$func_basename_result" 32027e6fb56fSmrg 320390b17f1bSmrg # Set up the ranlib parameters. 3204983b4bf2Smrg oldlib="$destdir/$name" 320590b17f1bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 320690b17f1bSmrg tool_oldlib=$func_to_tool_file_result 32077e6fb56fSmrg 320890b17f1bSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 320990b17f1bSmrg 321090b17f1bSmrg if test -n "$stripme" && test -n "$old_striplib"; then 321190b17f1bSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 32127e6fb56fSmrg fi 32137e6fb56fSmrg 321490b17f1bSmrg # Do each command in the postinstall commands. 321590b17f1bSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 321690b17f1bSmrg done 32177e6fb56fSmrg 321890b17f1bSmrg test -n "$future_libdirs" && \ 3219983b4bf2Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 32207e6fb56fSmrg 322190b17f1bSmrg if test -n "$current_libdirs"; then 322290b17f1bSmrg # Maybe just do a dry run. 322390b17f1bSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 3224983b4bf2Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 322590b17f1bSmrg else 322690b17f1bSmrg exit $EXIT_SUCCESS 322790b17f1bSmrg fi 322890b17f1bSmrg} 32297e6fb56fSmrg 3230983b4bf2Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 32317e6fb56fSmrg 32327e6fb56fSmrg 323390b17f1bSmrg# func_generate_dlsyms outputname originator pic_p 323490b17f1bSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 323590b17f1bSmrg# a dlpreopen symbol table. 323690b17f1bSmrgfunc_generate_dlsyms () 323790b17f1bSmrg{ 3238983b4bf2Smrg $opt_debug 3239983b4bf2Smrg my_outputname="$1" 3240983b4bf2Smrg my_originator="$2" 3241983b4bf2Smrg my_pic_p="${3-no}" 3242983b4bf2Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 324390b17f1bSmrg my_dlsyms= 324490b17f1bSmrg 3245983b4bf2Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 324690b17f1bSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 3247983b4bf2Smrg my_dlsyms="${my_outputname}S.c" 324890b17f1bSmrg else 324990b17f1bSmrg func_error "not configured to extract global symbols from dlpreopened files" 325090b17f1bSmrg fi 325190b17f1bSmrg fi 32527e6fb56fSmrg 325390b17f1bSmrg if test -n "$my_dlsyms"; then 325490b17f1bSmrg case $my_dlsyms in 325590b17f1bSmrg "") ;; 325690b17f1bSmrg *.c) 325790b17f1bSmrg # Discover the nlist of each of the dlfiles. 3258983b4bf2Smrg nlist="$output_objdir/${my_outputname}.nm" 32597e6fb56fSmrg 326090b17f1bSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 32617e6fb56fSmrg 326290b17f1bSmrg # Parse the name list into a source file. 326390b17f1bSmrg func_verbose "creating $output_objdir/$my_dlsyms" 32647e6fb56fSmrg 326590b17f1bSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 3266983b4bf2Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 3267983b4bf2Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 32687e6fb56fSmrg 326990b17f1bSmrg#ifdef __cplusplus 327090b17f1bSmrgextern \"C\" { 327190b17f1bSmrg#endif 32727e6fb56fSmrg 3273983b4bf2Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 327490b17f1bSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 327590b17f1bSmrg#endif 32767e6fb56fSmrg 327790b17f1bSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 3278983b4bf2Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 3279983b4bf2Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 328090b17f1bSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 328190b17f1bSmrg# define LT_DLSYM_CONST 3282983b4bf2Smrg#elif defined(__osf__) 328390b17f1bSmrg/* This system does not cope well with relocations in const data. */ 328490b17f1bSmrg# define LT_DLSYM_CONST 328590b17f1bSmrg#else 328690b17f1bSmrg# define LT_DLSYM_CONST const 328790b17f1bSmrg#endif 32887e6fb56fSmrg 328990b17f1bSmrg/* External symbol declarations for the compiler. */\ 329090b17f1bSmrg" 32917e6fb56fSmrg 3292983b4bf2Smrg if test "$dlself" = yes; then 3293983b4bf2Smrg func_verbose "generating symbol list for \`$output'" 32947e6fb56fSmrg 329590b17f1bSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 32967e6fb56fSmrg 329790b17f1bSmrg # Add our own program objects to the symbol list. 329890b17f1bSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 329990b17f1bSmrg for progfile in $progfiles; do 330090b17f1bSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 3301983b4bf2Smrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 330290b17f1bSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 33037e6fb56fSmrg done 33047e6fb56fSmrg 330590b17f1bSmrg if test -n "$exclude_expsyms"; then 330690b17f1bSmrg $opt_dry_run || { 330790b17f1bSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 330890b17f1bSmrg eval '$MV "$nlist"T "$nlist"' 330990b17f1bSmrg } 331090b17f1bSmrg fi 33117e6fb56fSmrg 331290b17f1bSmrg if test -n "$export_symbols_regex"; then 331390b17f1bSmrg $opt_dry_run || { 331490b17f1bSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 331590b17f1bSmrg eval '$MV "$nlist"T "$nlist"' 331690b17f1bSmrg } 331790b17f1bSmrg fi 33187e6fb56fSmrg 331990b17f1bSmrg # Prepare the list of exported symbols 332090b17f1bSmrg if test -z "$export_symbols"; then 3321983b4bf2Smrg export_symbols="$output_objdir/$outputname.exp" 332290b17f1bSmrg $opt_dry_run || { 332390b17f1bSmrg $RM $export_symbols 3324983b4bf2Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 332590b17f1bSmrg case $host in 332690b17f1bSmrg *cygwin* | *mingw* | *cegcc* ) 332790b17f1bSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 332890b17f1bSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 332990b17f1bSmrg ;; 333090b17f1bSmrg esac 333190b17f1bSmrg } 333290b17f1bSmrg else 333390b17f1bSmrg $opt_dry_run || { 3334983b4bf2Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 333590b17f1bSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 333690b17f1bSmrg eval '$MV "$nlist"T "$nlist"' 333790b17f1bSmrg case $host in 333890b17f1bSmrg *cygwin* | *mingw* | *cegcc* ) 333990b17f1bSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 334090b17f1bSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 334190b17f1bSmrg ;; 334290b17f1bSmrg esac 334390b17f1bSmrg } 334490b17f1bSmrg fi 334590b17f1bSmrg fi 33467e6fb56fSmrg 334790b17f1bSmrg for dlprefile in $dlprefiles; do 3348983b4bf2Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 334990b17f1bSmrg func_basename "$dlprefile" 3350983b4bf2Smrg name="$func_basename_result" 335190b17f1bSmrg case $host in 335290b17f1bSmrg *cygwin* | *mingw* | *cegcc* ) 335390b17f1bSmrg # if an import library, we need to obtain dlname 335490b17f1bSmrg if func_win32_import_lib_p "$dlprefile"; then 335590b17f1bSmrg func_tr_sh "$dlprefile" 335690b17f1bSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 3357983b4bf2Smrg dlprefile_dlbasename="" 335890b17f1bSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 335990b17f1bSmrg # Use subshell, to avoid clobbering current variable values 336090b17f1bSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 3361983b4bf2Smrg if test -n "$dlprefile_dlname" ; then 336290b17f1bSmrg func_basename "$dlprefile_dlname" 3363983b4bf2Smrg dlprefile_dlbasename="$func_basename_result" 336490b17f1bSmrg else 336590b17f1bSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 336690b17f1bSmrg $sharedlib_from_linklib_cmd "$dlprefile" 336790b17f1bSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 336890b17f1bSmrg fi 336990b17f1bSmrg fi 337090b17f1bSmrg $opt_dry_run || { 3371983b4bf2Smrg if test -n "$dlprefile_dlbasename" ; then 337290b17f1bSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 337390b17f1bSmrg else 337490b17f1bSmrg func_warning "Could not compute DLL name from $name" 337590b17f1bSmrg eval '$ECHO ": $name " >> "$nlist"' 337690b17f1bSmrg fi 337790b17f1bSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 337890b17f1bSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 337990b17f1bSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 338090b17f1bSmrg } 338190b17f1bSmrg else # not an import lib 338290b17f1bSmrg $opt_dry_run || { 338390b17f1bSmrg eval '$ECHO ": $name " >> "$nlist"' 338490b17f1bSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 338590b17f1bSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 338690b17f1bSmrg } 338790b17f1bSmrg fi 338890b17f1bSmrg ;; 338990b17f1bSmrg *) 339090b17f1bSmrg $opt_dry_run || { 339190b17f1bSmrg eval '$ECHO ": $name " >> "$nlist"' 339290b17f1bSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 339390b17f1bSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 339490b17f1bSmrg } 339590b17f1bSmrg ;; 339690b17f1bSmrg esac 339790b17f1bSmrg done 33987e6fb56fSmrg 339990b17f1bSmrg $opt_dry_run || { 340090b17f1bSmrg # Make sure we have at least an empty file. 340190b17f1bSmrg test -f "$nlist" || : > "$nlist" 34027e6fb56fSmrg 340390b17f1bSmrg if test -n "$exclude_expsyms"; then 340490b17f1bSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 340590b17f1bSmrg $MV "$nlist"T "$nlist" 340690b17f1bSmrg fi 34077e6fb56fSmrg 340890b17f1bSmrg # Try sorting and uniquifying the output. 340990b17f1bSmrg if $GREP -v "^: " < "$nlist" | 341090b17f1bSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 341190b17f1bSmrg sort -k 3 341290b17f1bSmrg else 341390b17f1bSmrg sort +2 341490b17f1bSmrg fi | 341590b17f1bSmrg uniq > "$nlist"S; then 341690b17f1bSmrg : 341790b17f1bSmrg else 341890b17f1bSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 341990b17f1bSmrg fi 34207e6fb56fSmrg 342190b17f1bSmrg if test -f "$nlist"S; then 342290b17f1bSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 342390b17f1bSmrg else 342490b17f1bSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 342590b17f1bSmrg fi 34267e6fb56fSmrg 342790b17f1bSmrg echo >> "$output_objdir/$my_dlsyms" "\ 342890b17f1bSmrg 342990b17f1bSmrg/* The mapping between symbol names and symbols. */ 343090b17f1bSmrgtypedef struct { 343190b17f1bSmrg const char *name; 343290b17f1bSmrg void *address; 343390b17f1bSmrg} lt_dlsymlist; 343490b17f1bSmrgextern LT_DLSYM_CONST lt_dlsymlist 3435983b4bf2Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 343690b17f1bSmrgLT_DLSYM_CONST lt_dlsymlist 343790b17f1bSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 3438983b4bf2Smrg{\ 3439983b4bf2Smrg { \"$my_originator\", (void *) 0 }," 344090b17f1bSmrg 344190b17f1bSmrg case $need_lib_prefix in 344290b17f1bSmrg no) 344390b17f1bSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 34447e6fb56fSmrg ;; 34457e6fb56fSmrg *) 344690b17f1bSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 34477e6fb56fSmrg ;; 34487e6fb56fSmrg esac 344990b17f1bSmrg echo >> "$output_objdir/$my_dlsyms" "\ 345090b17f1bSmrg {0, (void *) 0} 345190b17f1bSmrg}; 34527e6fb56fSmrg 345390b17f1bSmrg/* This works around a problem in FreeBSD linker */ 345490b17f1bSmrg#ifdef FREEBSD_WORKAROUND 345590b17f1bSmrgstatic const void *lt_preloaded_setup() { 345690b17f1bSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 345790b17f1bSmrg} 345890b17f1bSmrg#endif 34597e6fb56fSmrg 346090b17f1bSmrg#ifdef __cplusplus 346190b17f1bSmrg} 346290b17f1bSmrg#endif\ 346390b17f1bSmrg" 346490b17f1bSmrg } # !$opt_dry_run 34657e6fb56fSmrg 346690b17f1bSmrg pic_flag_for_symtable= 346790b17f1bSmrg case "$compile_command " in 346890b17f1bSmrg *" -static "*) ;; 346990b17f1bSmrg *) 347090b17f1bSmrg case $host in 347190b17f1bSmrg # compiling the symbol table file with pic_flag works around 347290b17f1bSmrg # a FreeBSD bug that causes programs to crash when -lm is 347390b17f1bSmrg # linked before any other PIC object. But we must not use 347490b17f1bSmrg # pic_flag when linking with -static. The problem exists in 347590b17f1bSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 347690b17f1bSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 347790b17f1bSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 347890b17f1bSmrg *-*-hpux*) 347990b17f1bSmrg pic_flag_for_symtable=" $pic_flag" ;; 348090b17f1bSmrg *) 3481983b4bf2Smrg if test "X$my_pic_p" != Xno; then 3482983b4bf2Smrg pic_flag_for_symtable=" $pic_flag" 3483983b4bf2Smrg fi 348490b17f1bSmrg ;; 348590b17f1bSmrg esac 348690b17f1bSmrg ;; 348790b17f1bSmrg esac 348890b17f1bSmrg symtab_cflags= 348990b17f1bSmrg for arg in $LTCFLAGS; do 349090b17f1bSmrg case $arg in 349190b17f1bSmrg -pie | -fpie | -fPIE) ;; 349290b17f1bSmrg *) func_append symtab_cflags " $arg" ;; 34937e6fb56fSmrg esac 34947e6fb56fSmrg done 34957e6fb56fSmrg 349690b17f1bSmrg # Now compile the dynamic symbol file. 349790b17f1bSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 34987e6fb56fSmrg 349990b17f1bSmrg # Clean up the generated files. 3500983b4bf2Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 35017e6fb56fSmrg 350290b17f1bSmrg # Transform the symbol file into the correct name. 3503983b4bf2Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 350490b17f1bSmrg case $host in 350590b17f1bSmrg *cygwin* | *mingw* | *cegcc* ) 350690b17f1bSmrg if test -f "$output_objdir/$my_outputname.def"; then 350790b17f1bSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350890b17f1bSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350990b17f1bSmrg else 351090b17f1bSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351190b17f1bSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351290b17f1bSmrg fi 351390b17f1bSmrg ;; 351490b17f1bSmrg *) 351590b17f1bSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351690b17f1bSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351790b17f1bSmrg ;; 351890b17f1bSmrg esac 351990b17f1bSmrg ;; 352090b17f1bSmrg *) 3521983b4bf2Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 352290b17f1bSmrg ;; 352390b17f1bSmrg esac 352490b17f1bSmrg else 352590b17f1bSmrg # We keep going just in case the user didn't refer to 352690b17f1bSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 352790b17f1bSmrg # really was required. 35287e6fb56fSmrg 352990b17f1bSmrg # Nullify the symbol file. 353090b17f1bSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 353190b17f1bSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 353290b17f1bSmrg fi 353390b17f1bSmrg} 35347e6fb56fSmrg 353590b17f1bSmrg# func_win32_libid arg 353690b17f1bSmrg# return the library type of file 'arg' 353790b17f1bSmrg# 353890b17f1bSmrg# Need a lot of goo to handle *both* DLLs and import libs 353990b17f1bSmrg# Has to be a shell function in order to 'eat' the argument 354090b17f1bSmrg# that is supplied when $file_magic_command is called. 354190b17f1bSmrg# Despite the name, also deal with 64 bit binaries. 354290b17f1bSmrgfunc_win32_libid () 354390b17f1bSmrg{ 3544983b4bf2Smrg $opt_debug 3545983b4bf2Smrg win32_libid_type="unknown" 354690b17f1bSmrg win32_fileres=`file -L $1 2>/dev/null` 354790b17f1bSmrg case $win32_fileres in 354890b17f1bSmrg *ar\ archive\ import\ library*) # definitely import 354990b17f1bSmrg win32_libid_type="x86 archive import" 355090b17f1bSmrg ;; 355190b17f1bSmrg *ar\ archive*) # could be an import, or static 355290b17f1bSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 355390b17f1bSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 355490b17f1bSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 3555983b4bf2Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3556983b4bf2Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 3557983b4bf2Smrg $SED -n -e ' 355890b17f1bSmrg 1,100{ 355990b17f1bSmrg / I /{ 3560983b4bf2Smrg s,.*,import, 356190b17f1bSmrg p 356290b17f1bSmrg q 356390b17f1bSmrg } 356490b17f1bSmrg }'` 356590b17f1bSmrg case $win32_nmres in 356690b17f1bSmrg import*) win32_libid_type="x86 archive import";; 356790b17f1bSmrg *) win32_libid_type="x86 archive static";; 356890b17f1bSmrg esac 356990b17f1bSmrg fi 357090b17f1bSmrg ;; 357190b17f1bSmrg *DLL*) 357290b17f1bSmrg win32_libid_type="x86 DLL" 357390b17f1bSmrg ;; 357490b17f1bSmrg *executable*) # but shell scripts are "executable" too... 357590b17f1bSmrg case $win32_fileres in 357690b17f1bSmrg *MS\ Windows\ PE\ Intel*) 357790b17f1bSmrg win32_libid_type="x86 DLL" 357890b17f1bSmrg ;; 357990b17f1bSmrg esac 358090b17f1bSmrg ;; 358190b17f1bSmrg esac 358290b17f1bSmrg $ECHO "$win32_libid_type" 358390b17f1bSmrg} 358490b17f1bSmrg 358590b17f1bSmrg# func_cygming_dll_for_implib ARG 358690b17f1bSmrg# 358790b17f1bSmrg# Platform-specific function to extract the 358890b17f1bSmrg# name of the DLL associated with the specified 358990b17f1bSmrg# import library ARG. 359090b17f1bSmrg# Invoked by eval'ing the libtool variable 359190b17f1bSmrg# $sharedlib_from_linklib_cmd 359290b17f1bSmrg# Result is available in the variable 359390b17f1bSmrg# $sharedlib_from_linklib_result 359490b17f1bSmrgfunc_cygming_dll_for_implib () 359590b17f1bSmrg{ 3596983b4bf2Smrg $opt_debug 359790b17f1bSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 359890b17f1bSmrg} 359990b17f1bSmrg 360090b17f1bSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 360190b17f1bSmrg# 360290b17f1bSmrg# The is the core of a fallback implementation of a 360390b17f1bSmrg# platform-specific function to extract the name of the 360490b17f1bSmrg# DLL associated with the specified import library LIBNAME. 360590b17f1bSmrg# 360690b17f1bSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 360790b17f1bSmrg# on the platform and compiler that created the implib. 360890b17f1bSmrg# 360990b17f1bSmrg# Echos the name of the DLL associated with the 361090b17f1bSmrg# specified import library. 361190b17f1bSmrgfunc_cygming_dll_for_implib_fallback_core () 361290b17f1bSmrg{ 3613983b4bf2Smrg $opt_debug 361490b17f1bSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 361590b17f1bSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 361690b17f1bSmrg $SED '/^Contents of section '"$match_literal"':/{ 361790b17f1bSmrg # Place marker at beginning of archive member dllname section 361890b17f1bSmrg s/.*/====MARK====/ 361990b17f1bSmrg p 362090b17f1bSmrg d 362190b17f1bSmrg } 362290b17f1bSmrg # These lines can sometimes be longer than 43 characters, but 362390b17f1bSmrg # are always uninteresting 362490b17f1bSmrg /:[ ]*file format pe[i]\{,1\}-/d 362590b17f1bSmrg /^In archive [^:]*:/d 362690b17f1bSmrg # Ensure marker is printed 362790b17f1bSmrg /^====MARK====/p 362890b17f1bSmrg # Remove all lines with less than 43 characters 362990b17f1bSmrg /^.\{43\}/!d 363090b17f1bSmrg # From remaining lines, remove first 43 characters 363190b17f1bSmrg s/^.\{43\}//' | 363290b17f1bSmrg $SED -n ' 363390b17f1bSmrg # Join marker and all lines until next marker into a single line 363490b17f1bSmrg /^====MARK====/ b para 363590b17f1bSmrg H 363690b17f1bSmrg $ b para 363790b17f1bSmrg b 363890b17f1bSmrg :para 363990b17f1bSmrg x 364090b17f1bSmrg s/\n//g 364190b17f1bSmrg # Remove the marker 364290b17f1bSmrg s/^====MARK====// 364390b17f1bSmrg # Remove trailing dots and whitespace 364490b17f1bSmrg s/[\. \t]*$// 364590b17f1bSmrg # Print 364690b17f1bSmrg /./p' | 364790b17f1bSmrg # we now have a list, one entry per line, of the stringified 364890b17f1bSmrg # contents of the appropriate section of all members of the 3649983b4bf2Smrg # archive which possess that section. Heuristic: eliminate 3650983b4bf2Smrg # all those which have a first or second character that is 365190b17f1bSmrg # a '.' (that is, objdump's representation of an unprintable 365290b17f1bSmrg # character.) This should work for all archives with less than 365390b17f1bSmrg # 0x302f exports -- but will fail for DLLs whose name actually 365490b17f1bSmrg # begins with a literal '.' or a single character followed by 365590b17f1bSmrg # a '.'. 365690b17f1bSmrg # 365790b17f1bSmrg # Of those that remain, print the first one. 365890b17f1bSmrg $SED -e '/^\./d;/^.\./d;q' 365990b17f1bSmrg} 366090b17f1bSmrg 3661983b4bf2Smrg# func_cygming_gnu_implib_p ARG 3662983b4bf2Smrg# This predicate returns with zero status (TRUE) if 3663983b4bf2Smrg# ARG is a GNU/binutils-style import library. Returns 3664983b4bf2Smrg# with nonzero status (FALSE) otherwise. 3665983b4bf2Smrgfunc_cygming_gnu_implib_p () 3666983b4bf2Smrg{ 3667983b4bf2Smrg $opt_debug 3668983b4bf2Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3669983b4bf2Smrg 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)$'` 3670983b4bf2Smrg test -n "$func_cygming_gnu_implib_tmp" 3671983b4bf2Smrg} 3672983b4bf2Smrg 3673983b4bf2Smrg# func_cygming_ms_implib_p ARG 3674983b4bf2Smrg# This predicate returns with zero status (TRUE) if 3675983b4bf2Smrg# ARG is an MS-style import library. Returns 3676983b4bf2Smrg# with nonzero status (FALSE) otherwise. 3677983b4bf2Smrgfunc_cygming_ms_implib_p () 3678983b4bf2Smrg{ 3679983b4bf2Smrg $opt_debug 3680983b4bf2Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3681983b4bf2Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 3682983b4bf2Smrg test -n "$func_cygming_ms_implib_tmp" 3683983b4bf2Smrg} 3684983b4bf2Smrg 368590b17f1bSmrg# func_cygming_dll_for_implib_fallback ARG 368690b17f1bSmrg# Platform-specific function to extract the 368790b17f1bSmrg# name of the DLL associated with the specified 368890b17f1bSmrg# import library ARG. 368990b17f1bSmrg# 369090b17f1bSmrg# This fallback implementation is for use when $DLLTOOL 369190b17f1bSmrg# does not support the --identify-strict option. 369290b17f1bSmrg# Invoked by eval'ing the libtool variable 369390b17f1bSmrg# $sharedlib_from_linklib_cmd 369490b17f1bSmrg# Result is available in the variable 369590b17f1bSmrg# $sharedlib_from_linklib_result 369690b17f1bSmrgfunc_cygming_dll_for_implib_fallback () 369790b17f1bSmrg{ 3698983b4bf2Smrg $opt_debug 3699983b4bf2Smrg if func_cygming_gnu_implib_p "$1" ; then 370090b17f1bSmrg # binutils import library 370190b17f1bSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 3702983b4bf2Smrg elif func_cygming_ms_implib_p "$1" ; then 370390b17f1bSmrg # ms-generated import library 370490b17f1bSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 370590b17f1bSmrg else 370690b17f1bSmrg # unknown 3707983b4bf2Smrg sharedlib_from_linklib_result="" 370890b17f1bSmrg fi 370990b17f1bSmrg} 371090b17f1bSmrg 371190b17f1bSmrg 371290b17f1bSmrg# func_extract_an_archive dir oldlib 371390b17f1bSmrgfunc_extract_an_archive () 371490b17f1bSmrg{ 3715983b4bf2Smrg $opt_debug 3716983b4bf2Smrg f_ex_an_ar_dir="$1"; shift 3717983b4bf2Smrg f_ex_an_ar_oldlib="$1" 3718983b4bf2Smrg if test "$lock_old_archive_extraction" = yes; then 371990b17f1bSmrg lockfile=$f_ex_an_ar_oldlib.lock 372090b17f1bSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 372190b17f1bSmrg func_echo "Waiting for $lockfile to be removed" 372290b17f1bSmrg sleep 2 37237e6fb56fSmrg done 372490b17f1bSmrg fi 372590b17f1bSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 372690b17f1bSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 3727983b4bf2Smrg if test "$lock_old_archive_extraction" = yes; then 372890b17f1bSmrg $opt_dry_run || rm -f "$lockfile" 372990b17f1bSmrg fi 373090b17f1bSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 373190b17f1bSmrg : 373290b17f1bSmrg else 373390b17f1bSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 373490b17f1bSmrg fi 373590b17f1bSmrg} 37367e6fb56fSmrg 373790b17f1bSmrg 373890b17f1bSmrg# func_extract_archives gentop oldlib ... 373990b17f1bSmrgfunc_extract_archives () 374090b17f1bSmrg{ 3741983b4bf2Smrg $opt_debug 3742983b4bf2Smrg my_gentop="$1"; shift 374390b17f1bSmrg my_oldlibs=${1+"$@"} 3744983b4bf2Smrg my_oldobjs="" 3745983b4bf2Smrg my_xlib="" 3746983b4bf2Smrg my_xabs="" 3747983b4bf2Smrg my_xdir="" 374890b17f1bSmrg 374990b17f1bSmrg for my_xlib in $my_oldlibs; do 375090b17f1bSmrg # Extract the objects. 375190b17f1bSmrg case $my_xlib in 3752983b4bf2Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 375390b17f1bSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 375490b17f1bSmrg esac 375590b17f1bSmrg func_basename "$my_xlib" 3756983b4bf2Smrg my_xlib="$func_basename_result" 375790b17f1bSmrg my_xlib_u=$my_xlib 375890b17f1bSmrg while :; do 375990b17f1bSmrg case " $extracted_archives " in 376090b17f1bSmrg *" $my_xlib_u "*) 376190b17f1bSmrg func_arith $extracted_serial + 1 376290b17f1bSmrg extracted_serial=$func_arith_result 376390b17f1bSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 376490b17f1bSmrg *) break ;; 37657e6fb56fSmrg esac 37667e6fb56fSmrg done 376790b17f1bSmrg extracted_archives="$extracted_archives $my_xlib_u" 3768983b4bf2Smrg my_xdir="$my_gentop/$my_xlib_u" 37697e6fb56fSmrg 377090b17f1bSmrg func_mkdir_p "$my_xdir" 37717e6fb56fSmrg 377290b17f1bSmrg case $host in 377390b17f1bSmrg *-darwin*) 377490b17f1bSmrg func_verbose "Extracting $my_xabs" 377590b17f1bSmrg # Do not bother doing anything if just a dry run 377690b17f1bSmrg $opt_dry_run || { 377790b17f1bSmrg darwin_orig_dir=`pwd` 377890b17f1bSmrg cd $my_xdir || exit $? 377990b17f1bSmrg darwin_archive=$my_xabs 378090b17f1bSmrg darwin_curdir=`pwd` 3781983b4bf2Smrg darwin_base_archive=`basename "$darwin_archive"` 378290b17f1bSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 378390b17f1bSmrg if test -n "$darwin_arches"; then 378490b17f1bSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 378590b17f1bSmrg darwin_arch= 378690b17f1bSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 3787983b4bf2Smrg for darwin_arch in $darwin_arches ; do 3788983b4bf2Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3789983b4bf2Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 3790983b4bf2Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3791983b4bf2Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 379290b17f1bSmrg cd "$darwin_curdir" 3793983b4bf2Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 379490b17f1bSmrg done # $darwin_arches 379590b17f1bSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 3796983b4bf2Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 379790b17f1bSmrg darwin_file= 379890b17f1bSmrg darwin_files= 379990b17f1bSmrg for darwin_file in $darwin_filelist; do 380090b17f1bSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 380190b17f1bSmrg $LIPO -create -output "$darwin_file" $darwin_files 380290b17f1bSmrg done # $darwin_filelist 380390b17f1bSmrg $RM -rf unfat-$$ 380490b17f1bSmrg cd "$darwin_orig_dir" 38057e6fb56fSmrg else 380690b17f1bSmrg cd $darwin_orig_dir 380790b17f1bSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 380890b17f1bSmrg fi # $darwin_arches 380990b17f1bSmrg } # !$opt_dry_run 381090b17f1bSmrg ;; 381190b17f1bSmrg *) 381290b17f1bSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 381390b17f1bSmrg ;; 381490b17f1bSmrg esac 381590b17f1bSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 381690b17f1bSmrg done 38177e6fb56fSmrg 3818983b4bf2Smrg func_extract_archives_result="$my_oldobjs" 381990b17f1bSmrg} 38207e6fb56fSmrg 38217e6fb56fSmrg 382290b17f1bSmrg# func_emit_wrapper [arg=no] 382390b17f1bSmrg# 382490b17f1bSmrg# Emit a libtool wrapper script on stdout. 382590b17f1bSmrg# Don't directly open a file because we may want to 382690b17f1bSmrg# incorporate the script contents within a cygwin/mingw 382790b17f1bSmrg# wrapper executable. Must ONLY be called from within 382890b17f1bSmrg# func_mode_link because it depends on a number of variables 382990b17f1bSmrg# set therein. 383090b17f1bSmrg# 383190b17f1bSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 383290b17f1bSmrg# variable will take. If 'yes', then the emitted script 3833983b4bf2Smrg# will assume that the directory in which it is stored is 383490b17f1bSmrg# the $objdir directory. This is a cygwin/mingw-specific 383590b17f1bSmrg# behavior. 383690b17f1bSmrgfunc_emit_wrapper () 383790b17f1bSmrg{ 383890b17f1bSmrg func_emit_wrapper_arg1=${1-no} 38397e6fb56fSmrg 384090b17f1bSmrg $ECHO "\ 384190b17f1bSmrg#! $SHELL 38427e6fb56fSmrg 384390b17f1bSmrg# $output - temporary wrapper script for $objdir/$outputname 3844983b4bf2Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 384590b17f1bSmrg# 384690b17f1bSmrg# The $output program cannot be directly executed until all the libtool 384790b17f1bSmrg# libraries that it depends on are installed. 384890b17f1bSmrg# 384990b17f1bSmrg# This wrapper script should never be moved out of the build directory. 385090b17f1bSmrg# If it is, it will not operate correctly. 38517e6fb56fSmrg 385290b17f1bSmrg# Sed substitution that helps us do robust quoting. It backslashifies 385390b17f1bSmrg# metacharacters that are still active within double-quoted strings. 385490b17f1bSmrgsed_quote_subst='$sed_quote_subst' 38557e6fb56fSmrg 385690b17f1bSmrg# Be Bourne compatible 385790b17f1bSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 385890b17f1bSmrg emulate sh 385990b17f1bSmrg NULLCMD=: 386090b17f1bSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 386190b17f1bSmrg # is contrary to our usage. Disable this feature. 386290b17f1bSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 386390b17f1bSmrg setopt NO_GLOB_SUBST 386490b17f1bSmrgelse 386590b17f1bSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 386690b17f1bSmrgfi 386790b17f1bSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 386890b17f1bSmrgDUALCASE=1; export DUALCASE # for MKS sh 38697e6fb56fSmrg 387090b17f1bSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 387190b17f1bSmrg# if CDPATH is set. 387290b17f1bSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 38737e6fb56fSmrg 387490b17f1bSmrgrelink_command=\"$relink_command\" 38757e6fb56fSmrg 387690b17f1bSmrg# This environment variable determines our operation mode. 387790b17f1bSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 387890b17f1bSmrg # install mode needs the following variables: 387990b17f1bSmrg generated_by_libtool_version='$macro_version' 388090b17f1bSmrg notinst_deplibs='$notinst_deplibs' 388190b17f1bSmrgelse 388290b17f1bSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 388390b17f1bSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 388490b17f1bSmrg file=\"\$0\"" 38857e6fb56fSmrg 388690b17f1bSmrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 388790b17f1bSmrg $ECHO "\ 38887e6fb56fSmrg 388990b17f1bSmrg# A function that is used when there is no print builtin or printf. 389090b17f1bSmrgfunc_fallback_echo () 389190b17f1bSmrg{ 389290b17f1bSmrg eval 'cat <<_LTECHO_EOF 389390b17f1bSmrg\$1 389490b17f1bSmrg_LTECHO_EOF' 389590b17f1bSmrg} 389690b17f1bSmrg ECHO=\"$qECHO\" 389790b17f1bSmrg fi 38987e6fb56fSmrg 389990b17f1bSmrg# Very basic option parsing. These options are (a) specific to 390090b17f1bSmrg# the libtool wrapper, (b) are identical between the wrapper 3901983b4bf2Smrg# /script/ and the wrapper /executable/ which is used only on 390290b17f1bSmrg# windows platforms, and (c) all begin with the string "--lt-" 3903983b4bf2Smrg# (application programs are unlikely to have options which match 390490b17f1bSmrg# this pattern). 390590b17f1bSmrg# 390690b17f1bSmrg# There are only two supported options: --lt-debug and 390790b17f1bSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 390890b17f1bSmrg# 390990b17f1bSmrg# The first argument to this parsing function should be the 391090b17f1bSmrg# script's $0 value, followed by "$@". 391190b17f1bSmrglt_option_debug= 391290b17f1bSmrgfunc_parse_lt_options () 391390b17f1bSmrg{ 391490b17f1bSmrg lt_script_arg0=\$0 391590b17f1bSmrg shift 391690b17f1bSmrg for lt_opt 391790b17f1bSmrg do 391890b17f1bSmrg case \"\$lt_opt\" in 391990b17f1bSmrg --lt-debug) lt_option_debug=1 ;; 392090b17f1bSmrg --lt-dump-script) 392190b17f1bSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 392290b17f1bSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 392390b17f1bSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 392490b17f1bSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 392590b17f1bSmrg exit 0 392690b17f1bSmrg ;; 392790b17f1bSmrg --lt-*) 392890b17f1bSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 392990b17f1bSmrg exit 1 393090b17f1bSmrg ;; 393190b17f1bSmrg esac 393290b17f1bSmrg done 39337e6fb56fSmrg 393490b17f1bSmrg # Print the debug banner immediately: 393590b17f1bSmrg if test -n \"\$lt_option_debug\"; then 3936983b4bf2Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 393790b17f1bSmrg fi 393890b17f1bSmrg} 39397e6fb56fSmrg 394090b17f1bSmrg# Used when --lt-debug. Prints its arguments to stdout 394190b17f1bSmrg# (redirection is the responsibility of the caller) 394290b17f1bSmrgfunc_lt_dump_args () 394390b17f1bSmrg{ 394490b17f1bSmrg lt_dump_args_N=1; 394590b17f1bSmrg for lt_arg 394690b17f1bSmrg do 3947983b4bf2Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 394890b17f1bSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 394990b17f1bSmrg done 395090b17f1bSmrg} 39517e6fb56fSmrg 395290b17f1bSmrg# Core function for launching the target application 395390b17f1bSmrgfunc_exec_program_core () 395490b17f1bSmrg{ 395590b17f1bSmrg" 395690b17f1bSmrg case $host in 395790b17f1bSmrg # Backslashes separate directories on plain windows 395890b17f1bSmrg *-*-mingw | *-*-os2* | *-cegcc*) 395990b17f1bSmrg $ECHO "\ 396090b17f1bSmrg if test -n \"\$lt_option_debug\"; then 3961983b4bf2Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 396290b17f1bSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 396390b17f1bSmrg fi 396490b17f1bSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 396590b17f1bSmrg" 396690b17f1bSmrg ;; 39677e6fb56fSmrg 396890b17f1bSmrg *) 396990b17f1bSmrg $ECHO "\ 397090b17f1bSmrg if test -n \"\$lt_option_debug\"; then 3971983b4bf2Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 397290b17f1bSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 397390b17f1bSmrg fi 397490b17f1bSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 397590b17f1bSmrg" 397690b17f1bSmrg ;; 397790b17f1bSmrg esac 397890b17f1bSmrg $ECHO "\ 397990b17f1bSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 398090b17f1bSmrg exit 1 398190b17f1bSmrg} 39827e6fb56fSmrg 398390b17f1bSmrg# A function to encapsulate launching the target application 398490b17f1bSmrg# Strips options in the --lt-* namespace from \$@ and 398590b17f1bSmrg# launches target application with the remaining arguments. 398690b17f1bSmrgfunc_exec_program () 398790b17f1bSmrg{ 398890b17f1bSmrg case \" \$* \" in 398990b17f1bSmrg *\\ --lt-*) 399090b17f1bSmrg for lt_wr_arg 399190b17f1bSmrg do 399290b17f1bSmrg case \$lt_wr_arg in 399390b17f1bSmrg --lt-*) ;; 399490b17f1bSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 399590b17f1bSmrg esac 399690b17f1bSmrg shift 399790b17f1bSmrg done ;; 399890b17f1bSmrg esac 399990b17f1bSmrg func_exec_program_core \${1+\"\$@\"} 400090b17f1bSmrg} 40017e6fb56fSmrg 400290b17f1bSmrg # Parse options 400390b17f1bSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 40047e6fb56fSmrg 400590b17f1bSmrg # Find the directory that this script lives in. 400690b17f1bSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 400790b17f1bSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 40087e6fb56fSmrg 400990b17f1bSmrg # Follow symbolic links until we get to the real thisdir. 401090b17f1bSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 401190b17f1bSmrg while test -n \"\$file\"; do 401290b17f1bSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 40137e6fb56fSmrg 401490b17f1bSmrg # If there was a directory component, then change thisdir. 401590b17f1bSmrg if test \"x\$destdir\" != \"x\$file\"; then 401690b17f1bSmrg case \"\$destdir\" in 401790b17f1bSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 401890b17f1bSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 401990b17f1bSmrg esac 402090b17f1bSmrg fi 40217e6fb56fSmrg 402290b17f1bSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 402390b17f1bSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 402490b17f1bSmrg done 40257e6fb56fSmrg 402690b17f1bSmrg # Usually 'no', except on cygwin/mingw when embedded into 402790b17f1bSmrg # the cwrapper. 402890b17f1bSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 402990b17f1bSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 403090b17f1bSmrg # special case for '.' 403190b17f1bSmrg if test \"\$thisdir\" = \".\"; then 403290b17f1bSmrg thisdir=\`pwd\` 403390b17f1bSmrg fi 403490b17f1bSmrg # remove .libs from thisdir 403590b17f1bSmrg case \"\$thisdir\" in 403690b17f1bSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 403790b17f1bSmrg $objdir ) thisdir=. ;; 403890b17f1bSmrg esac 403990b17f1bSmrg fi 40407e6fb56fSmrg 404190b17f1bSmrg # Try to get the absolute directory name. 404290b17f1bSmrg absdir=\`cd \"\$thisdir\" && pwd\` 404390b17f1bSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 404490b17f1bSmrg" 40457e6fb56fSmrg 4046983b4bf2Smrg if test "$fast_install" = yes; then 404790b17f1bSmrg $ECHO "\ 404890b17f1bSmrg program=lt-'$outputname'$exeext 404990b17f1bSmrg progdir=\"\$thisdir/$objdir\" 40507e6fb56fSmrg 405190b17f1bSmrg if test ! -f \"\$progdir/\$program\" || 4052983b4bf2Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 405390b17f1bSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 40547e6fb56fSmrg 405590b17f1bSmrg file=\"\$\$-\$program\" 40567e6fb56fSmrg 405790b17f1bSmrg if test ! -d \"\$progdir\"; then 405890b17f1bSmrg $MKDIR \"\$progdir\" 405990b17f1bSmrg else 406090b17f1bSmrg $RM \"\$progdir/\$file\" 406190b17f1bSmrg fi" 40627e6fb56fSmrg 406390b17f1bSmrg $ECHO "\ 40647e6fb56fSmrg 406590b17f1bSmrg # relink executable if necessary 406690b17f1bSmrg if test -n \"\$relink_command\"; then 406790b17f1bSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 406890b17f1bSmrg else 4069983b4bf2Smrg $ECHO \"\$relink_command_output\" >&2 407090b17f1bSmrg $RM \"\$progdir/\$file\" 407190b17f1bSmrg exit 1 407290b17f1bSmrg fi 407390b17f1bSmrg fi 40747e6fb56fSmrg 407590b17f1bSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 407690b17f1bSmrg { $RM \"\$progdir/\$program\"; 407790b17f1bSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 407890b17f1bSmrg $RM \"\$progdir/\$file\" 407990b17f1bSmrg fi" 408090b17f1bSmrg else 408190b17f1bSmrg $ECHO "\ 408290b17f1bSmrg program='$outputname' 408390b17f1bSmrg progdir=\"\$thisdir/$objdir\" 408490b17f1bSmrg" 408590b17f1bSmrg fi 40867e6fb56fSmrg 408790b17f1bSmrg $ECHO "\ 40887e6fb56fSmrg 408990b17f1bSmrg if test -f \"\$progdir/\$program\"; then" 409090b17f1bSmrg 409190b17f1bSmrg # fixup the dll searchpath if we need to. 409290b17f1bSmrg # 409390b17f1bSmrg # Fix the DLL searchpath if we need to. Do this before prepending 409490b17f1bSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 409590b17f1bSmrg # libraries must come first. 409690b17f1bSmrg if test -n "$dllsearchpath"; then 409790b17f1bSmrg $ECHO "\ 409890b17f1bSmrg # Add the dll search path components to the executable PATH 409990b17f1bSmrg PATH=$dllsearchpath:\$PATH 410090b17f1bSmrg" 41017e6fb56fSmrg fi 41027e6fb56fSmrg 410390b17f1bSmrg # Export our shlibpath_var if we have one. 4104983b4bf2Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 410590b17f1bSmrg $ECHO "\ 410690b17f1bSmrg # Add our own library path to $shlibpath_var 410790b17f1bSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 41087e6fb56fSmrg 410990b17f1bSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 411090b17f1bSmrg # The second colon is a workaround for a bug in BeOS R4 sed 411190b17f1bSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 411290b17f1bSmrg 411390b17f1bSmrg export $shlibpath_var 411490b17f1bSmrg" 41157e6fb56fSmrg fi 41167e6fb56fSmrg 411790b17f1bSmrg $ECHO "\ 411890b17f1bSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 411990b17f1bSmrg # Run the actual program with our arguments. 412090b17f1bSmrg func_exec_program \${1+\"\$@\"} 412190b17f1bSmrg fi 412290b17f1bSmrg else 412390b17f1bSmrg # The program doesn't exist. 4124983b4bf2Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 412590b17f1bSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 412690b17f1bSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 412790b17f1bSmrg exit 1 412890b17f1bSmrg fi 412990b17f1bSmrgfi\ 413090b17f1bSmrg" 413190b17f1bSmrg} 41327e6fb56fSmrg 41337e6fb56fSmrg 413490b17f1bSmrg# func_emit_cwrapperexe_src 413590b17f1bSmrg# emit the source code for a wrapper executable on stdout 413690b17f1bSmrg# Must ONLY be called from within func_mode_link because 413790b17f1bSmrg# it depends on a number of variable set therein. 413890b17f1bSmrgfunc_emit_cwrapperexe_src () 413990b17f1bSmrg{ 414090b17f1bSmrg cat <<EOF 41417e6fb56fSmrg 414290b17f1bSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4143983b4bf2Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 41447e6fb56fSmrg 414590b17f1bSmrg The $output program cannot be directly executed until all the libtool 414690b17f1bSmrg libraries that it depends on are installed. 41477e6fb56fSmrg 414890b17f1bSmrg This wrapper executable should never be moved out of the build directory. 414990b17f1bSmrg If it is, it will not operate correctly. 415090b17f1bSmrg*/ 415190b17f1bSmrgEOF 415290b17f1bSmrg cat <<"EOF" 415390b17f1bSmrg#ifdef _MSC_VER 415490b17f1bSmrg# define _CRT_SECURE_NO_DEPRECATE 1 415590b17f1bSmrg#endif 415690b17f1bSmrg#include <stdio.h> 415790b17f1bSmrg#include <stdlib.h> 415890b17f1bSmrg#ifdef _MSC_VER 415990b17f1bSmrg# include <direct.h> 416090b17f1bSmrg# include <process.h> 416190b17f1bSmrg# include <io.h> 416290b17f1bSmrg#else 416390b17f1bSmrg# include <unistd.h> 416490b17f1bSmrg# include <stdint.h> 416590b17f1bSmrg# ifdef __CYGWIN__ 416690b17f1bSmrg# include <io.h> 416790b17f1bSmrg# endif 416890b17f1bSmrg#endif 416990b17f1bSmrg#include <malloc.h> 417090b17f1bSmrg#include <stdarg.h> 417190b17f1bSmrg#include <assert.h> 417290b17f1bSmrg#include <string.h> 417390b17f1bSmrg#include <ctype.h> 417490b17f1bSmrg#include <errno.h> 417590b17f1bSmrg#include <fcntl.h> 417690b17f1bSmrg#include <sys/stat.h> 41777e6fb56fSmrg 417890b17f1bSmrg/* declarations of non-ANSI functions */ 4179983b4bf2Smrg#if defined(__MINGW32__) 418090b17f1bSmrg# ifdef __STRICT_ANSI__ 418190b17f1bSmrgint _putenv (const char *); 418290b17f1bSmrg# endif 4183983b4bf2Smrg#elif defined(__CYGWIN__) 418490b17f1bSmrg# ifdef __STRICT_ANSI__ 418590b17f1bSmrgchar *realpath (const char *, char *); 418690b17f1bSmrgint putenv (char *); 418790b17f1bSmrgint setenv (const char *, const char *, int); 418890b17f1bSmrg# endif 4189983b4bf2Smrg/* #elif defined (other platforms) ... */ 419090b17f1bSmrg#endif 41917e6fb56fSmrg 419290b17f1bSmrg/* portability defines, excluding path handling macros */ 4193983b4bf2Smrg#if defined(_MSC_VER) 419490b17f1bSmrg# define setmode _setmode 419590b17f1bSmrg# define stat _stat 419690b17f1bSmrg# define chmod _chmod 419790b17f1bSmrg# define getcwd _getcwd 419890b17f1bSmrg# define putenv _putenv 419990b17f1bSmrg# define S_IXUSR _S_IEXEC 4200983b4bf2Smrg# ifndef _INTPTR_T_DEFINED 4201983b4bf2Smrg# define _INTPTR_T_DEFINED 4202983b4bf2Smrg# define intptr_t int 4203983b4bf2Smrg# endif 4204983b4bf2Smrg#elif defined(__MINGW32__) 420590b17f1bSmrg# define setmode _setmode 420690b17f1bSmrg# define stat _stat 420790b17f1bSmrg# define chmod _chmod 420890b17f1bSmrg# define getcwd _getcwd 420990b17f1bSmrg# define putenv _putenv 4210983b4bf2Smrg#elif defined(__CYGWIN__) 421190b17f1bSmrg# define HAVE_SETENV 421290b17f1bSmrg# define FOPEN_WB "wb" 4213983b4bf2Smrg/* #elif defined (other platforms) ... */ 421490b17f1bSmrg#endif 42157e6fb56fSmrg 4216983b4bf2Smrg#if defined(PATH_MAX) 421790b17f1bSmrg# define LT_PATHMAX PATH_MAX 4218983b4bf2Smrg#elif defined(MAXPATHLEN) 421990b17f1bSmrg# define LT_PATHMAX MAXPATHLEN 422090b17f1bSmrg#else 422190b17f1bSmrg# define LT_PATHMAX 1024 422290b17f1bSmrg#endif 42237e6fb56fSmrg 422490b17f1bSmrg#ifndef S_IXOTH 422590b17f1bSmrg# define S_IXOTH 0 422690b17f1bSmrg#endif 422790b17f1bSmrg#ifndef S_IXGRP 422890b17f1bSmrg# define S_IXGRP 0 422990b17f1bSmrg#endif 42307e6fb56fSmrg 423190b17f1bSmrg/* path handling portability macros */ 423290b17f1bSmrg#ifndef DIR_SEPARATOR 423390b17f1bSmrg# define DIR_SEPARATOR '/' 423490b17f1bSmrg# define PATH_SEPARATOR ':' 423590b17f1bSmrg#endif 42367e6fb56fSmrg 4237983b4bf2Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4238983b4bf2Smrg defined (__OS2__) 423990b17f1bSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 424090b17f1bSmrg# define FOPEN_WB "wb" 424190b17f1bSmrg# ifndef DIR_SEPARATOR_2 424290b17f1bSmrg# define DIR_SEPARATOR_2 '\\' 424390b17f1bSmrg# endif 424490b17f1bSmrg# ifndef PATH_SEPARATOR_2 424590b17f1bSmrg# define PATH_SEPARATOR_2 ';' 424690b17f1bSmrg# endif 424790b17f1bSmrg#endif 42487e6fb56fSmrg 424990b17f1bSmrg#ifndef DIR_SEPARATOR_2 425090b17f1bSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 425190b17f1bSmrg#else /* DIR_SEPARATOR_2 */ 425290b17f1bSmrg# define IS_DIR_SEPARATOR(ch) \ 425390b17f1bSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 425490b17f1bSmrg#endif /* DIR_SEPARATOR_2 */ 42557e6fb56fSmrg 425690b17f1bSmrg#ifndef PATH_SEPARATOR_2 425790b17f1bSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 425890b17f1bSmrg#else /* PATH_SEPARATOR_2 */ 425990b17f1bSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 426090b17f1bSmrg#endif /* PATH_SEPARATOR_2 */ 42617e6fb56fSmrg 426290b17f1bSmrg#ifndef FOPEN_WB 426390b17f1bSmrg# define FOPEN_WB "w" 426490b17f1bSmrg#endif 426590b17f1bSmrg#ifndef _O_BINARY 426690b17f1bSmrg# define _O_BINARY 0 426790b17f1bSmrg#endif 42687e6fb56fSmrg 426990b17f1bSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 427090b17f1bSmrg#define XFREE(stale) do { \ 4271983b4bf2Smrg if (stale) { free ((void *) stale); stale = 0; } \ 427290b17f1bSmrg} while (0) 42737e6fb56fSmrg 4274983b4bf2Smrg#if defined(LT_DEBUGWRAPPER) 427590b17f1bSmrgstatic int lt_debug = 1; 427690b17f1bSmrg#else 427790b17f1bSmrgstatic int lt_debug = 0; 427890b17f1bSmrg#endif 42797e6fb56fSmrg 428090b17f1bSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 428190b17f1bSmrg 428290b17f1bSmrgvoid *xmalloc (size_t num); 428390b17f1bSmrgchar *xstrdup (const char *string); 428490b17f1bSmrgconst char *base_name (const char *name); 428590b17f1bSmrgchar *find_executable (const char *wrapper); 428690b17f1bSmrgchar *chase_symlinks (const char *pathspec); 428790b17f1bSmrgint make_executable (const char *path); 428890b17f1bSmrgint check_executable (const char *path); 428990b17f1bSmrgchar *strendzap (char *str, const char *pat); 429090b17f1bSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 429190b17f1bSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 429290b17f1bSmrgstatic const char *nonnull (const char *s); 429390b17f1bSmrgstatic const char *nonempty (const char *s); 429490b17f1bSmrgvoid lt_setenv (const char *name, const char *value); 429590b17f1bSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 429690b17f1bSmrgvoid lt_update_exe_path (const char *name, const char *value); 429790b17f1bSmrgvoid lt_update_lib_path (const char *name, const char *value); 429890b17f1bSmrgchar **prepare_spawn (char **argv); 429990b17f1bSmrgvoid lt_dump_script (FILE *f); 430090b17f1bSmrgEOF 43017e6fb56fSmrg 430290b17f1bSmrg cat <<EOF 4303983b4bf2Smrgvolatile const char * MAGIC_EXE = "$magic_exe"; 430490b17f1bSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 430590b17f1bSmrgEOF 43067e6fb56fSmrg 4307983b4bf2Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 430890b17f1bSmrg func_to_host_path "$temp_rpath" 430990b17f1bSmrg cat <<EOF 431090b17f1bSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 431190b17f1bSmrgEOF 431290b17f1bSmrg else 431390b17f1bSmrg cat <<"EOF" 431490b17f1bSmrgconst char * LIB_PATH_VALUE = ""; 431590b17f1bSmrgEOF 431690b17f1bSmrg fi 43177e6fb56fSmrg 431890b17f1bSmrg if test -n "$dllsearchpath"; then 431990b17f1bSmrg func_to_host_path "$dllsearchpath:" 432090b17f1bSmrg cat <<EOF 432190b17f1bSmrgconst char * EXE_PATH_VARNAME = "PATH"; 432290b17f1bSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 432390b17f1bSmrgEOF 432490b17f1bSmrg else 432590b17f1bSmrg cat <<"EOF" 432690b17f1bSmrgconst char * EXE_PATH_VARNAME = ""; 432790b17f1bSmrgconst char * EXE_PATH_VALUE = ""; 432890b17f1bSmrgEOF 432990b17f1bSmrg fi 43307e6fb56fSmrg 4331983b4bf2Smrg if test "$fast_install" = yes; then 433290b17f1bSmrg cat <<EOF 433390b17f1bSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 433490b17f1bSmrgEOF 433590b17f1bSmrg else 433690b17f1bSmrg cat <<EOF 433790b17f1bSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 433890b17f1bSmrgEOF 433990b17f1bSmrg fi 43407e6fb56fSmrg 43417e6fb56fSmrg 434290b17f1bSmrg cat <<"EOF" 43437e6fb56fSmrg 434490b17f1bSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 43457e6fb56fSmrg 434690b17f1bSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 434790b17f1bSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 434890b17f1bSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 43497e6fb56fSmrg 435090b17f1bSmrgint 435190b17f1bSmrgmain (int argc, char *argv[]) 435290b17f1bSmrg{ 435390b17f1bSmrg char **newargz; 435490b17f1bSmrg int newargc; 435590b17f1bSmrg char *tmp_pathspec; 435690b17f1bSmrg char *actual_cwrapper_path; 435790b17f1bSmrg char *actual_cwrapper_name; 435890b17f1bSmrg char *target_name; 435990b17f1bSmrg char *lt_argv_zero; 4360983b4bf2Smrg intptr_t rval = 127; 436190b17f1bSmrg 436290b17f1bSmrg int i; 43637e6fb56fSmrg 436490b17f1bSmrg program_name = (char *) xstrdup (base_name (argv[0])); 4365983b4bf2Smrg newargz = XMALLOC (char *, argc + 1); 43667e6fb56fSmrg 436790b17f1bSmrg /* very simple arg parsing; don't want to rely on getopt 436890b17f1bSmrg * also, copy all non cwrapper options to newargz, except 436990b17f1bSmrg * argz[0], which is handled differently 437090b17f1bSmrg */ 437190b17f1bSmrg newargc=0; 437290b17f1bSmrg for (i = 1; i < argc; i++) 437390b17f1bSmrg { 4374983b4bf2Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 437590b17f1bSmrg { 437690b17f1bSmrgEOF 4377983b4bf2Smrg case "$host" in 437890b17f1bSmrg *mingw* | *cygwin* ) 437990b17f1bSmrg # make stdout use "unix" line endings 438090b17f1bSmrg echo " setmode(1,_O_BINARY);" 438190b17f1bSmrg ;; 438290b17f1bSmrg esac 43837e6fb56fSmrg 438490b17f1bSmrg cat <<"EOF" 438590b17f1bSmrg lt_dump_script (stdout); 438690b17f1bSmrg return 0; 438790b17f1bSmrg } 4388983b4bf2Smrg if (strcmp (argv[i], debug_opt) == 0) 438990b17f1bSmrg { 439090b17f1bSmrg lt_debug = 1; 439190b17f1bSmrg continue; 439290b17f1bSmrg } 4393983b4bf2Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 439490b17f1bSmrg { 439590b17f1bSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 439690b17f1bSmrg namespace, but it is not one of the ones we know about and 439790b17f1bSmrg have already dealt with, above (inluding dump-script), then 439890b17f1bSmrg report an error. Otherwise, targets might begin to believe 439990b17f1bSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 440090b17f1bSmrg namespace. The first time any user complains about this, we'll 440190b17f1bSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 440290b17f1bSmrg or a configure.ac-settable value. 440390b17f1bSmrg */ 440490b17f1bSmrg lt_fatal (__FILE__, __LINE__, 440590b17f1bSmrg "unrecognized %s option: '%s'", 440690b17f1bSmrg ltwrapper_option_prefix, argv[i]); 440790b17f1bSmrg } 440890b17f1bSmrg /* otherwise ... */ 440990b17f1bSmrg newargz[++newargc] = xstrdup (argv[i]); 441090b17f1bSmrg } 441190b17f1bSmrg newargz[++newargc] = NULL; 44127e6fb56fSmrg 441390b17f1bSmrgEOF 441490b17f1bSmrg cat <<EOF 441590b17f1bSmrg /* The GNU banner must be the first non-error debug message */ 4416983b4bf2Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 441790b17f1bSmrgEOF 441890b17f1bSmrg cat <<"EOF" 441990b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 442090b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 442190b17f1bSmrg 442290b17f1bSmrg tmp_pathspec = find_executable (argv[0]); 442390b17f1bSmrg if (tmp_pathspec == NULL) 442490b17f1bSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 442590b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, 442690b17f1bSmrg "(main) found exe (before symlink chase) at: %s\n", 442790b17f1bSmrg tmp_pathspec); 442890b17f1bSmrg 442990b17f1bSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 443090b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, 443190b17f1bSmrg "(main) found exe (after symlink chase) at: %s\n", 443290b17f1bSmrg actual_cwrapper_path); 443390b17f1bSmrg XFREE (tmp_pathspec); 443490b17f1bSmrg 443590b17f1bSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 443690b17f1bSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 443790b17f1bSmrg 443890b17f1bSmrg /* wrapper name transforms */ 443990b17f1bSmrg strendzap (actual_cwrapper_name, ".exe"); 444090b17f1bSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 444190b17f1bSmrg XFREE (actual_cwrapper_name); 444290b17f1bSmrg actual_cwrapper_name = tmp_pathspec; 444390b17f1bSmrg tmp_pathspec = 0; 444490b17f1bSmrg 444590b17f1bSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 444690b17f1bSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 444790b17f1bSmrg strendzap (target_name, ".exe"); 444890b17f1bSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 444990b17f1bSmrg XFREE (target_name); 445090b17f1bSmrg target_name = tmp_pathspec; 445190b17f1bSmrg tmp_pathspec = 0; 445290b17f1bSmrg 445390b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, 445490b17f1bSmrg "(main) libtool target name: %s\n", 445590b17f1bSmrg target_name); 445690b17f1bSmrgEOF 445790b17f1bSmrg 445890b17f1bSmrg cat <<EOF 445990b17f1bSmrg newargz[0] = 446090b17f1bSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 446190b17f1bSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 446290b17f1bSmrg strcpy (newargz[0], actual_cwrapper_path); 446390b17f1bSmrg strcat (newargz[0], "$objdir"); 446490b17f1bSmrg strcat (newargz[0], "/"); 446590b17f1bSmrgEOF 446690b17f1bSmrg 446790b17f1bSmrg cat <<"EOF" 446890b17f1bSmrg /* stop here, and copy so we don't have to do this twice */ 446990b17f1bSmrg tmp_pathspec = xstrdup (newargz[0]); 447090b17f1bSmrg 447190b17f1bSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 447290b17f1bSmrg strcat (newargz[0], actual_cwrapper_name); 447390b17f1bSmrg 447490b17f1bSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 447590b17f1bSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 447690b17f1bSmrg XFREE (tmp_pathspec); 447790b17f1bSmrg tmp_pathspec = NULL; 447890b17f1bSmrgEOF 447990b17f1bSmrg 448090b17f1bSmrg case $host_os in 448190b17f1bSmrg mingw*) 448290b17f1bSmrg cat <<"EOF" 448390b17f1bSmrg { 448490b17f1bSmrg char* p; 448590b17f1bSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 448690b17f1bSmrg { 448790b17f1bSmrg *p = '/'; 448890b17f1bSmrg } 448990b17f1bSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 449090b17f1bSmrg { 449190b17f1bSmrg *p = '/'; 449290b17f1bSmrg } 449390b17f1bSmrg } 449490b17f1bSmrgEOF 449590b17f1bSmrg ;; 449690b17f1bSmrg esac 449790b17f1bSmrg 449890b17f1bSmrg cat <<"EOF" 449990b17f1bSmrg XFREE (target_name); 450090b17f1bSmrg XFREE (actual_cwrapper_path); 450190b17f1bSmrg XFREE (actual_cwrapper_name); 450290b17f1bSmrg 450390b17f1bSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 450490b17f1bSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 450590b17f1bSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 450690b17f1bSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 450790b17f1bSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 450890b17f1bSmrg libraries must come first. */ 450990b17f1bSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 451090b17f1bSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 451190b17f1bSmrg 451290b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 451390b17f1bSmrg nonnull (lt_argv_zero)); 451490b17f1bSmrg for (i = 0; i < newargc; i++) 451590b17f1bSmrg { 451690b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 451790b17f1bSmrg i, nonnull (newargz[i])); 451890b17f1bSmrg } 451990b17f1bSmrg 452090b17f1bSmrgEOF 452190b17f1bSmrg 452290b17f1bSmrg case $host_os in 452390b17f1bSmrg mingw*) 452490b17f1bSmrg cat <<"EOF" 452590b17f1bSmrg /* execv doesn't actually work on mingw as expected on unix */ 452690b17f1bSmrg newargz = prepare_spawn (newargz); 4527983b4bf2Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 452890b17f1bSmrg if (rval == -1) 452990b17f1bSmrg { 453090b17f1bSmrg /* failed to start process */ 453190b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, 453290b17f1bSmrg "(main) failed to launch target \"%s\": %s\n", 453390b17f1bSmrg lt_argv_zero, nonnull (strerror (errno))); 453490b17f1bSmrg return 127; 453590b17f1bSmrg } 453690b17f1bSmrg return rval; 453790b17f1bSmrgEOF 45387e6fb56fSmrg ;; 45397e6fb56fSmrg *) 454090b17f1bSmrg cat <<"EOF" 454190b17f1bSmrg execv (lt_argv_zero, newargz); 454290b17f1bSmrg return rval; /* =127, but avoids unused variable warning */ 454390b17f1bSmrgEOF 45447e6fb56fSmrg ;; 454590b17f1bSmrg esac 45467e6fb56fSmrg 454790b17f1bSmrg cat <<"EOF" 454890b17f1bSmrg} 45497e6fb56fSmrg 455090b17f1bSmrgvoid * 455190b17f1bSmrgxmalloc (size_t num) 455290b17f1bSmrg{ 455390b17f1bSmrg void *p = (void *) malloc (num); 455490b17f1bSmrg if (!p) 455590b17f1bSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 45567e6fb56fSmrg 455790b17f1bSmrg return p; 455890b17f1bSmrg} 45597e6fb56fSmrg 456090b17f1bSmrgchar * 456190b17f1bSmrgxstrdup (const char *string) 456290b17f1bSmrg{ 456390b17f1bSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 456490b17f1bSmrg string) : NULL; 456590b17f1bSmrg} 45667e6fb56fSmrg 456790b17f1bSmrgconst char * 456890b17f1bSmrgbase_name (const char *name) 456990b17f1bSmrg{ 457090b17f1bSmrg const char *base; 45717e6fb56fSmrg 4572983b4bf2Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 457390b17f1bSmrg /* Skip over the disk name in MSDOS pathnames. */ 457490b17f1bSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 457590b17f1bSmrg name += 2; 45767e6fb56fSmrg#endif 45777e6fb56fSmrg 457890b17f1bSmrg for (base = name; *name; name++) 457990b17f1bSmrg if (IS_DIR_SEPARATOR (*name)) 458090b17f1bSmrg base = name + 1; 458190b17f1bSmrg return base; 458290b17f1bSmrg} 45837e6fb56fSmrg 458490b17f1bSmrgint 458590b17f1bSmrgcheck_executable (const char *path) 458690b17f1bSmrg{ 458790b17f1bSmrg struct stat st; 45887e6fb56fSmrg 458990b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 459090b17f1bSmrg nonempty (path)); 459190b17f1bSmrg if ((!path) || (!*path)) 459290b17f1bSmrg return 0; 45937e6fb56fSmrg 459490b17f1bSmrg if ((stat (path, &st) >= 0) 459590b17f1bSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 459690b17f1bSmrg return 1; 459790b17f1bSmrg else 459890b17f1bSmrg return 0; 459990b17f1bSmrg} 46007e6fb56fSmrg 460190b17f1bSmrgint 460290b17f1bSmrgmake_executable (const char *path) 460390b17f1bSmrg{ 460490b17f1bSmrg int rval = 0; 460590b17f1bSmrg struct stat st; 46067e6fb56fSmrg 460790b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 460890b17f1bSmrg nonempty (path)); 460990b17f1bSmrg if ((!path) || (!*path)) 461090b17f1bSmrg return 0; 46117e6fb56fSmrg 461290b17f1bSmrg if (stat (path, &st) >= 0) 461390b17f1bSmrg { 461490b17f1bSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 461590b17f1bSmrg } 461690b17f1bSmrg return rval; 461790b17f1bSmrg} 46187e6fb56fSmrg 461990b17f1bSmrg/* Searches for the full path of the wrapper. Returns 462090b17f1bSmrg newly allocated full path name if found, NULL otherwise 462190b17f1bSmrg Does not chase symlinks, even on platforms that support them. 462290b17f1bSmrg*/ 462390b17f1bSmrgchar * 462490b17f1bSmrgfind_executable (const char *wrapper) 462590b17f1bSmrg{ 462690b17f1bSmrg int has_slash = 0; 462790b17f1bSmrg const char *p; 462890b17f1bSmrg const char *p_next; 462990b17f1bSmrg /* static buffer for getcwd */ 463090b17f1bSmrg char tmp[LT_PATHMAX + 1]; 4631983b4bf2Smrg int tmp_len; 463290b17f1bSmrg char *concat_name; 46337e6fb56fSmrg 463490b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 463590b17f1bSmrg nonempty (wrapper)); 46367e6fb56fSmrg 463790b17f1bSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 463890b17f1bSmrg return NULL; 46397e6fb56fSmrg 464090b17f1bSmrg /* Absolute path? */ 4641983b4bf2Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 464290b17f1bSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 464390b17f1bSmrg { 464490b17f1bSmrg concat_name = xstrdup (wrapper); 464590b17f1bSmrg if (check_executable (concat_name)) 464690b17f1bSmrg return concat_name; 464790b17f1bSmrg XFREE (concat_name); 464890b17f1bSmrg } 464990b17f1bSmrg else 465090b17f1bSmrg { 465190b17f1bSmrg#endif 465290b17f1bSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 465390b17f1bSmrg { 465490b17f1bSmrg concat_name = xstrdup (wrapper); 465590b17f1bSmrg if (check_executable (concat_name)) 465690b17f1bSmrg return concat_name; 465790b17f1bSmrg XFREE (concat_name); 465890b17f1bSmrg } 4659983b4bf2Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 466090b17f1bSmrg } 466190b17f1bSmrg#endif 46627e6fb56fSmrg 466390b17f1bSmrg for (p = wrapper; *p; p++) 466490b17f1bSmrg if (*p == '/') 466590b17f1bSmrg { 466690b17f1bSmrg has_slash = 1; 466790b17f1bSmrg break; 466890b17f1bSmrg } 466990b17f1bSmrg if (!has_slash) 467090b17f1bSmrg { 467190b17f1bSmrg /* no slashes; search PATH */ 467290b17f1bSmrg const char *path = getenv ("PATH"); 467390b17f1bSmrg if (path != NULL) 467490b17f1bSmrg { 467590b17f1bSmrg for (p = path; *p; p = p_next) 467690b17f1bSmrg { 467790b17f1bSmrg const char *q; 467890b17f1bSmrg size_t p_len; 467990b17f1bSmrg for (q = p; *q; q++) 468090b17f1bSmrg if (IS_PATH_SEPARATOR (*q)) 468190b17f1bSmrg break; 4682983b4bf2Smrg p_len = q - p; 468390b17f1bSmrg p_next = (*q == '\0' ? q : q + 1); 468490b17f1bSmrg if (p_len == 0) 468590b17f1bSmrg { 468690b17f1bSmrg /* empty path: current directory */ 468790b17f1bSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 468890b17f1bSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 468990b17f1bSmrg nonnull (strerror (errno))); 469090b17f1bSmrg tmp_len = strlen (tmp); 469190b17f1bSmrg concat_name = 469290b17f1bSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 469390b17f1bSmrg memcpy (concat_name, tmp, tmp_len); 469490b17f1bSmrg concat_name[tmp_len] = '/'; 469590b17f1bSmrg strcpy (concat_name + tmp_len + 1, wrapper); 469690b17f1bSmrg } 469790b17f1bSmrg else 469890b17f1bSmrg { 469990b17f1bSmrg concat_name = 470090b17f1bSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 470190b17f1bSmrg memcpy (concat_name, p, p_len); 470290b17f1bSmrg concat_name[p_len] = '/'; 470390b17f1bSmrg strcpy (concat_name + p_len + 1, wrapper); 470490b17f1bSmrg } 470590b17f1bSmrg if (check_executable (concat_name)) 470690b17f1bSmrg return concat_name; 470790b17f1bSmrg XFREE (concat_name); 470890b17f1bSmrg } 470990b17f1bSmrg } 471090b17f1bSmrg /* not found in PATH; assume curdir */ 471190b17f1bSmrg } 471290b17f1bSmrg /* Relative path | not found in path: prepend cwd */ 471390b17f1bSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 471490b17f1bSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 471590b17f1bSmrg nonnull (strerror (errno))); 471690b17f1bSmrg tmp_len = strlen (tmp); 471790b17f1bSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 471890b17f1bSmrg memcpy (concat_name, tmp, tmp_len); 471990b17f1bSmrg concat_name[tmp_len] = '/'; 472090b17f1bSmrg strcpy (concat_name + tmp_len + 1, wrapper); 47217e6fb56fSmrg 472290b17f1bSmrg if (check_executable (concat_name)) 472390b17f1bSmrg return concat_name; 472490b17f1bSmrg XFREE (concat_name); 472590b17f1bSmrg return NULL; 472690b17f1bSmrg} 47277e6fb56fSmrg 472890b17f1bSmrgchar * 472990b17f1bSmrgchase_symlinks (const char *pathspec) 473090b17f1bSmrg{ 473190b17f1bSmrg#ifndef S_ISLNK 473290b17f1bSmrg return xstrdup (pathspec); 473390b17f1bSmrg#else 473490b17f1bSmrg char buf[LT_PATHMAX]; 473590b17f1bSmrg struct stat s; 473690b17f1bSmrg char *tmp_pathspec = xstrdup (pathspec); 473790b17f1bSmrg char *p; 473890b17f1bSmrg int has_symlinks = 0; 473990b17f1bSmrg while (strlen (tmp_pathspec) && !has_symlinks) 474090b17f1bSmrg { 474190b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, 474290b17f1bSmrg "checking path component for symlinks: %s\n", 474390b17f1bSmrg tmp_pathspec); 474490b17f1bSmrg if (lstat (tmp_pathspec, &s) == 0) 474590b17f1bSmrg { 474690b17f1bSmrg if (S_ISLNK (s.st_mode) != 0) 474790b17f1bSmrg { 474890b17f1bSmrg has_symlinks = 1; 474990b17f1bSmrg break; 475090b17f1bSmrg } 475190b17f1bSmrg 475290b17f1bSmrg /* search backwards for last DIR_SEPARATOR */ 475390b17f1bSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 475490b17f1bSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 475590b17f1bSmrg p--; 475690b17f1bSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 475790b17f1bSmrg { 475890b17f1bSmrg /* no more DIR_SEPARATORS left */ 475990b17f1bSmrg break; 476090b17f1bSmrg } 476190b17f1bSmrg *p = '\0'; 476290b17f1bSmrg } 476390b17f1bSmrg else 476490b17f1bSmrg { 476590b17f1bSmrg lt_fatal (__FILE__, __LINE__, 476690b17f1bSmrg "error accessing file \"%s\": %s", 476790b17f1bSmrg tmp_pathspec, nonnull (strerror (errno))); 476890b17f1bSmrg } 476990b17f1bSmrg } 477090b17f1bSmrg XFREE (tmp_pathspec); 47717e6fb56fSmrg 477290b17f1bSmrg if (!has_symlinks) 477390b17f1bSmrg { 477490b17f1bSmrg return xstrdup (pathspec); 477590b17f1bSmrg } 47767e6fb56fSmrg 477790b17f1bSmrg tmp_pathspec = realpath (pathspec, buf); 477890b17f1bSmrg if (tmp_pathspec == 0) 477990b17f1bSmrg { 478090b17f1bSmrg lt_fatal (__FILE__, __LINE__, 478190b17f1bSmrg "could not follow symlinks for %s", pathspec); 478290b17f1bSmrg } 478390b17f1bSmrg return xstrdup (tmp_pathspec); 47847e6fb56fSmrg#endif 478590b17f1bSmrg} 47867e6fb56fSmrg 478790b17f1bSmrgchar * 478890b17f1bSmrgstrendzap (char *str, const char *pat) 478990b17f1bSmrg{ 479090b17f1bSmrg size_t len, patlen; 47917e6fb56fSmrg 479290b17f1bSmrg assert (str != NULL); 479390b17f1bSmrg assert (pat != NULL); 47947e6fb56fSmrg 479590b17f1bSmrg len = strlen (str); 479690b17f1bSmrg patlen = strlen (pat); 47977e6fb56fSmrg 479890b17f1bSmrg if (patlen <= len) 479990b17f1bSmrg { 480090b17f1bSmrg str += len - patlen; 4801983b4bf2Smrg if (strcmp (str, pat) == 0) 480290b17f1bSmrg *str = '\0'; 480390b17f1bSmrg } 480490b17f1bSmrg return str; 48057e6fb56fSmrg} 48067e6fb56fSmrg 480790b17f1bSmrgvoid 480890b17f1bSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 480990b17f1bSmrg{ 481090b17f1bSmrg va_list args; 481190b17f1bSmrg if (lt_debug) 481290b17f1bSmrg { 481390b17f1bSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 481490b17f1bSmrg va_start (args, fmt); 481590b17f1bSmrg (void) vfprintf (stderr, fmt, args); 481690b17f1bSmrg va_end (args); 481790b17f1bSmrg } 481890b17f1bSmrg} 48197e6fb56fSmrg 482090b17f1bSmrgstatic void 482190b17f1bSmrglt_error_core (int exit_status, const char *file, 482290b17f1bSmrg int line, const char *mode, 482390b17f1bSmrg const char *message, va_list ap) 482490b17f1bSmrg{ 482590b17f1bSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 482690b17f1bSmrg vfprintf (stderr, message, ap); 482790b17f1bSmrg fprintf (stderr, ".\n"); 48287e6fb56fSmrg 482990b17f1bSmrg if (exit_status >= 0) 483090b17f1bSmrg exit (exit_status); 48317e6fb56fSmrg} 48327e6fb56fSmrg 483390b17f1bSmrgvoid 483490b17f1bSmrglt_fatal (const char *file, int line, const char *message, ...) 483590b17f1bSmrg{ 483690b17f1bSmrg va_list ap; 483790b17f1bSmrg va_start (ap, message); 483890b17f1bSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 483990b17f1bSmrg va_end (ap); 48407e6fb56fSmrg} 48417e6fb56fSmrg 484290b17f1bSmrgstatic const char * 484390b17f1bSmrgnonnull (const char *s) 484490b17f1bSmrg{ 484590b17f1bSmrg return s ? s : "(null)"; 484690b17f1bSmrg} 48477e6fb56fSmrg 484890b17f1bSmrgstatic const char * 484990b17f1bSmrgnonempty (const char *s) 485090b17f1bSmrg{ 485190b17f1bSmrg return (s && !*s) ? "(empty)" : nonnull (s); 485290b17f1bSmrg} 48537e6fb56fSmrg 485490b17f1bSmrgvoid 485590b17f1bSmrglt_setenv (const char *name, const char *value) 485690b17f1bSmrg{ 485790b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, 485890b17f1bSmrg "(lt_setenv) setting '%s' to '%s'\n", 485990b17f1bSmrg nonnull (name), nonnull (value)); 486090b17f1bSmrg { 486190b17f1bSmrg#ifdef HAVE_SETENV 486290b17f1bSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 486390b17f1bSmrg char *str = xstrdup (value); 486490b17f1bSmrg setenv (name, str, 1); 486590b17f1bSmrg#else 4866983b4bf2Smrg int len = strlen (name) + 1 + strlen (value) + 1; 486790b17f1bSmrg char *str = XMALLOC (char, len); 486890b17f1bSmrg sprintf (str, "%s=%s", name, value); 486990b17f1bSmrg if (putenv (str) != EXIT_SUCCESS) 487090b17f1bSmrg { 487190b17f1bSmrg XFREE (str); 487290b17f1bSmrg } 487390b17f1bSmrg#endif 487490b17f1bSmrg } 487590b17f1bSmrg} 48767e6fb56fSmrg 487790b17f1bSmrgchar * 487890b17f1bSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 487990b17f1bSmrg{ 488090b17f1bSmrg char *new_value; 488190b17f1bSmrg if (orig_value && *orig_value) 488290b17f1bSmrg { 4883983b4bf2Smrg int orig_value_len = strlen (orig_value); 4884983b4bf2Smrg int add_len = strlen (add); 488590b17f1bSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 488690b17f1bSmrg if (to_end) 488790b17f1bSmrg { 488890b17f1bSmrg strcpy (new_value, orig_value); 488990b17f1bSmrg strcpy (new_value + orig_value_len, add); 489090b17f1bSmrg } 48917e6fb56fSmrg else 489290b17f1bSmrg { 489390b17f1bSmrg strcpy (new_value, add); 489490b17f1bSmrg strcpy (new_value + add_len, orig_value); 489590b17f1bSmrg } 489690b17f1bSmrg } 489790b17f1bSmrg else 489890b17f1bSmrg { 489990b17f1bSmrg new_value = xstrdup (add); 490090b17f1bSmrg } 490190b17f1bSmrg return new_value; 490290b17f1bSmrg} 49037e6fb56fSmrg 490490b17f1bSmrgvoid 490590b17f1bSmrglt_update_exe_path (const char *name, const char *value) 490690b17f1bSmrg{ 490790b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, 490890b17f1bSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 490990b17f1bSmrg nonnull (name), nonnull (value)); 49107e6fb56fSmrg 491190b17f1bSmrg if (name && *name && value && *value) 491290b17f1bSmrg { 491390b17f1bSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 491490b17f1bSmrg /* some systems can't cope with a ':'-terminated path #' */ 4915983b4bf2Smrg int len = strlen (new_value); 4916983b4bf2Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 491790b17f1bSmrg { 4918983b4bf2Smrg new_value[len-1] = '\0'; 491990b17f1bSmrg } 492090b17f1bSmrg lt_setenv (name, new_value); 492190b17f1bSmrg XFREE (new_value); 492290b17f1bSmrg } 492390b17f1bSmrg} 49247e6fb56fSmrg 492590b17f1bSmrgvoid 492690b17f1bSmrglt_update_lib_path (const char *name, const char *value) 492790b17f1bSmrg{ 492890b17f1bSmrg lt_debugprintf (__FILE__, __LINE__, 492990b17f1bSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 493090b17f1bSmrg nonnull (name), nonnull (value)); 49317e6fb56fSmrg 493290b17f1bSmrg if (name && *name && value && *value) 493390b17f1bSmrg { 493490b17f1bSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 493590b17f1bSmrg lt_setenv (name, new_value); 493690b17f1bSmrg XFREE (new_value); 493790b17f1bSmrg } 493890b17f1bSmrg} 49397e6fb56fSmrg 49407e6fb56fSmrgEOF 494190b17f1bSmrg case $host_os in 494290b17f1bSmrg mingw*) 494390b17f1bSmrg cat <<"EOF" 494490b17f1bSmrg 494590b17f1bSmrg/* Prepares an argument vector before calling spawn(). 494690b17f1bSmrg Note that spawn() does not by itself call the command interpreter 494790b17f1bSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 494890b17f1bSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 494990b17f1bSmrg GetVersionEx(&v); 495090b17f1bSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 495190b17f1bSmrg }) ? "cmd.exe" : "command.com"). 495290b17f1bSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 495390b17f1bSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 495490b17f1bSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 495590b17f1bSmrg special way: 495690b17f1bSmrg - Space and tab are interpreted as delimiters. They are not treated as 495790b17f1bSmrg delimiters if they are surrounded by double quotes: "...". 495890b17f1bSmrg - Unescaped double quotes are removed from the input. Their only effect is 495990b17f1bSmrg that within double quotes, space and tab are treated like normal 496090b17f1bSmrg characters. 496190b17f1bSmrg - Backslashes not followed by double quotes are not special. 496290b17f1bSmrg - But 2*n+1 backslashes followed by a double quote become 496390b17f1bSmrg n backslashes followed by a double quote (n >= 0): 496490b17f1bSmrg \" -> " 496590b17f1bSmrg \\\" -> \" 496690b17f1bSmrg \\\\\" -> \\" 496790b17f1bSmrg */ 496890b17f1bSmrg#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" 496990b17f1bSmrg#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" 497090b17f1bSmrgchar ** 497190b17f1bSmrgprepare_spawn (char **argv) 49727e6fb56fSmrg{ 497390b17f1bSmrg size_t argc; 497490b17f1bSmrg char **new_argv; 497590b17f1bSmrg size_t i; 49767e6fb56fSmrg 497790b17f1bSmrg /* Count number of arguments. */ 497890b17f1bSmrg for (argc = 0; argv[argc] != NULL; argc++) 497990b17f1bSmrg ; 49807e6fb56fSmrg 498190b17f1bSmrg /* Allocate new argument vector. */ 498290b17f1bSmrg new_argv = XMALLOC (char *, argc + 1); 49837e6fb56fSmrg 498490b17f1bSmrg /* Put quoted arguments into the new argument vector. */ 498590b17f1bSmrg for (i = 0; i < argc; i++) 498690b17f1bSmrg { 498790b17f1bSmrg const char *string = argv[i]; 498890b17f1bSmrg 498990b17f1bSmrg if (string[0] == '\0') 499090b17f1bSmrg new_argv[i] = xstrdup ("\"\""); 499190b17f1bSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 499290b17f1bSmrg { 499390b17f1bSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 499490b17f1bSmrg size_t length; 499590b17f1bSmrg unsigned int backslashes; 499690b17f1bSmrg const char *s; 499790b17f1bSmrg char *quoted_string; 499890b17f1bSmrg char *p; 499990b17f1bSmrg 500090b17f1bSmrg length = 0; 500190b17f1bSmrg backslashes = 0; 500290b17f1bSmrg if (quote_around) 500390b17f1bSmrg length++; 500490b17f1bSmrg for (s = string; *s != '\0'; s++) 500590b17f1bSmrg { 500690b17f1bSmrg char c = *s; 500790b17f1bSmrg if (c == '"') 500890b17f1bSmrg length += backslashes + 1; 500990b17f1bSmrg length++; 501090b17f1bSmrg if (c == '\\') 501190b17f1bSmrg backslashes++; 501290b17f1bSmrg else 501390b17f1bSmrg backslashes = 0; 501490b17f1bSmrg } 501590b17f1bSmrg if (quote_around) 501690b17f1bSmrg length += backslashes + 1; 501790b17f1bSmrg 501890b17f1bSmrg quoted_string = XMALLOC (char, length + 1); 501990b17f1bSmrg 502090b17f1bSmrg p = quoted_string; 502190b17f1bSmrg backslashes = 0; 502290b17f1bSmrg if (quote_around) 502390b17f1bSmrg *p++ = '"'; 502490b17f1bSmrg for (s = string; *s != '\0'; s++) 502590b17f1bSmrg { 502690b17f1bSmrg char c = *s; 502790b17f1bSmrg if (c == '"') 502890b17f1bSmrg { 502990b17f1bSmrg unsigned int j; 503090b17f1bSmrg for (j = backslashes + 1; j > 0; j--) 503190b17f1bSmrg *p++ = '\\'; 503290b17f1bSmrg } 503390b17f1bSmrg *p++ = c; 503490b17f1bSmrg if (c == '\\') 503590b17f1bSmrg backslashes++; 503690b17f1bSmrg else 503790b17f1bSmrg backslashes = 0; 503890b17f1bSmrg } 503990b17f1bSmrg if (quote_around) 504090b17f1bSmrg { 504190b17f1bSmrg unsigned int j; 504290b17f1bSmrg for (j = backslashes; j > 0; j--) 504390b17f1bSmrg *p++ = '\\'; 504490b17f1bSmrg *p++ = '"'; 504590b17f1bSmrg } 504690b17f1bSmrg *p = '\0'; 50477e6fb56fSmrg 504890b17f1bSmrg new_argv[i] = quoted_string; 504990b17f1bSmrg } 505090b17f1bSmrg else 505190b17f1bSmrg new_argv[i] = (char *) string; 505290b17f1bSmrg } 505390b17f1bSmrg new_argv[argc] = NULL; 50547e6fb56fSmrg 505590b17f1bSmrg return new_argv; 505690b17f1bSmrg} 50577e6fb56fSmrgEOF 505890b17f1bSmrg ;; 505990b17f1bSmrg esac 50607e6fb56fSmrg 506190b17f1bSmrg cat <<"EOF" 506290b17f1bSmrgvoid lt_dump_script (FILE* f) 506390b17f1bSmrg{ 50647e6fb56fSmrgEOF 506590b17f1bSmrg func_emit_wrapper yes | 506690b17f1bSmrg $SED -n -e ' 506790b17f1bSmrgs/^\(.\{79\}\)\(..*\)/\1\ 506890b17f1bSmrg\2/ 506990b17f1bSmrgh 507090b17f1bSmrgs/\([\\"]\)/\\\1/g 507190b17f1bSmrgs/$/\\n/ 507290b17f1bSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 507390b17f1bSmrgg 507490b17f1bSmrgD' 507590b17f1bSmrg cat <<"EOF" 50767e6fb56fSmrg} 507790b17f1bSmrgEOF 50787e6fb56fSmrg} 507990b17f1bSmrg# end: func_emit_cwrapperexe_src 50807e6fb56fSmrg 508190b17f1bSmrg# func_win32_import_lib_p ARG 508290b17f1bSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 508390b17f1bSmrgfunc_win32_import_lib_p () 50847e6fb56fSmrg{ 5085983b4bf2Smrg $opt_debug 508690b17f1bSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 508790b17f1bSmrg *import*) : ;; 508890b17f1bSmrg *) false ;; 508990b17f1bSmrg esac 50907e6fb56fSmrg} 50917e6fb56fSmrg 509290b17f1bSmrg# func_mode_link arg... 509390b17f1bSmrgfunc_mode_link () 50947e6fb56fSmrg{ 5095983b4bf2Smrg $opt_debug 509690b17f1bSmrg case $host in 509790b17f1bSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 509890b17f1bSmrg # It is impossible to link a dll without this setting, and 509990b17f1bSmrg # we shouldn't force the makefile maintainer to figure out 5100983b4bf2Smrg # which system we are compiling for in order to pass an extra 510190b17f1bSmrg # flag for every libtool invocation. 510290b17f1bSmrg # allow_undefined=no 51037e6fb56fSmrg 510490b17f1bSmrg # FIXME: Unfortunately, there are problems with the above when trying 5105983b4bf2Smrg # to make a dll which has undefined symbols, in which case not 510690b17f1bSmrg # even a static library is built. For now, we need to specify 510790b17f1bSmrg # -no-undefined on the libtool link line when we can be certain 510890b17f1bSmrg # that all symbols are satisfied, otherwise we get a static library. 510990b17f1bSmrg allow_undefined=yes 511090b17f1bSmrg ;; 511190b17f1bSmrg *) 511290b17f1bSmrg allow_undefined=yes 511390b17f1bSmrg ;; 511490b17f1bSmrg esac 511590b17f1bSmrg libtool_args=$nonopt 511690b17f1bSmrg base_compile="$nonopt $@" 511790b17f1bSmrg compile_command=$nonopt 511890b17f1bSmrg finalize_command=$nonopt 51197e6fb56fSmrg 512090b17f1bSmrg compile_rpath= 512190b17f1bSmrg finalize_rpath= 512290b17f1bSmrg compile_shlibpath= 512390b17f1bSmrg finalize_shlibpath= 512490b17f1bSmrg convenience= 512590b17f1bSmrg old_convenience= 512690b17f1bSmrg deplibs= 512790b17f1bSmrg old_deplibs= 512890b17f1bSmrg compiler_flags= 512990b17f1bSmrg linker_flags= 513090b17f1bSmrg dllsearchpath= 513190b17f1bSmrg lib_search_path=`pwd` 513290b17f1bSmrg inst_prefix_dir= 513390b17f1bSmrg new_inherited_linker_flags= 51347e6fb56fSmrg 513590b17f1bSmrg avoid_version=no 513690b17f1bSmrg bindir= 513790b17f1bSmrg dlfiles= 513890b17f1bSmrg dlprefiles= 513990b17f1bSmrg dlself=no 514090b17f1bSmrg export_dynamic=no 514190b17f1bSmrg export_symbols= 514290b17f1bSmrg export_symbols_regex= 514390b17f1bSmrg generated= 514490b17f1bSmrg libobjs= 514590b17f1bSmrg ltlibs= 514690b17f1bSmrg module=no 514790b17f1bSmrg no_install=no 514890b17f1bSmrg objs= 514990b17f1bSmrg non_pic_objects= 515090b17f1bSmrg precious_files_regex= 515190b17f1bSmrg prefer_static_libs=no 5152983b4bf2Smrg preload=no 515390b17f1bSmrg prev= 515490b17f1bSmrg prevarg= 515590b17f1bSmrg release= 515690b17f1bSmrg rpath= 515790b17f1bSmrg xrpath= 515890b17f1bSmrg perm_rpath= 515990b17f1bSmrg temp_rpath= 516090b17f1bSmrg thread_safe=no 516190b17f1bSmrg vinfo= 516290b17f1bSmrg vinfo_number=no 516390b17f1bSmrg weak_libs= 5164983b4bf2Smrg single_module="${wl}-single_module" 516590b17f1bSmrg func_infer_tag $base_compile 51667e6fb56fSmrg 516790b17f1bSmrg # We need to know -static, to get the right output filenames. 516890b17f1bSmrg for arg 516990b17f1bSmrg do 517090b17f1bSmrg case $arg in 517190b17f1bSmrg -shared) 5172983b4bf2Smrg test "$build_libtool_libs" != yes && \ 5173983b4bf2Smrg func_fatal_configuration "can not build a shared library" 517490b17f1bSmrg build_old_libs=no 517590b17f1bSmrg break 517690b17f1bSmrg ;; 517790b17f1bSmrg -all-static | -static | -static-libtool-libs) 517890b17f1bSmrg case $arg in 517990b17f1bSmrg -all-static) 5180983b4bf2Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 518190b17f1bSmrg func_warning "complete static linking is impossible in this configuration" 518290b17f1bSmrg fi 518390b17f1bSmrg if test -n "$link_static_flag"; then 518490b17f1bSmrg dlopen_self=$dlopen_self_static 518590b17f1bSmrg fi 518690b17f1bSmrg prefer_static_libs=yes 518790b17f1bSmrg ;; 518890b17f1bSmrg -static) 518990b17f1bSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 519090b17f1bSmrg dlopen_self=$dlopen_self_static 519190b17f1bSmrg fi 519290b17f1bSmrg prefer_static_libs=built 519390b17f1bSmrg ;; 519490b17f1bSmrg -static-libtool-libs) 519590b17f1bSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 519690b17f1bSmrg dlopen_self=$dlopen_self_static 519790b17f1bSmrg fi 519890b17f1bSmrg prefer_static_libs=yes 519990b17f1bSmrg ;; 520090b17f1bSmrg esac 520190b17f1bSmrg build_libtool_libs=no 520290b17f1bSmrg build_old_libs=yes 520390b17f1bSmrg break 520490b17f1bSmrg ;; 520590b17f1bSmrg esac 520690b17f1bSmrg done 52077e6fb56fSmrg 520890b17f1bSmrg # See if our shared archives depend on static archives. 520990b17f1bSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 52107e6fb56fSmrg 521190b17f1bSmrg # Go through the arguments, transforming them on the way. 521290b17f1bSmrg while test "$#" -gt 0; do 5213983b4bf2Smrg arg="$1" 521490b17f1bSmrg shift 521590b17f1bSmrg func_quote_for_eval "$arg" 521690b17f1bSmrg qarg=$func_quote_for_eval_unquoted_result 521790b17f1bSmrg func_append libtool_args " $func_quote_for_eval_result" 52187e6fb56fSmrg 521990b17f1bSmrg # If the previous option needs an argument, assign it. 522090b17f1bSmrg if test -n "$prev"; then 522190b17f1bSmrg case $prev in 522290b17f1bSmrg output) 522390b17f1bSmrg func_append compile_command " @OUTPUT@" 522490b17f1bSmrg func_append finalize_command " @OUTPUT@" 522590b17f1bSmrg ;; 522690b17f1bSmrg esac 52277e6fb56fSmrg 522890b17f1bSmrg case $prev in 522990b17f1bSmrg bindir) 5230983b4bf2Smrg bindir="$arg" 523190b17f1bSmrg prev= 523290b17f1bSmrg continue 523390b17f1bSmrg ;; 523490b17f1bSmrg dlfiles|dlprefiles) 5235983b4bf2Smrg if test "$preload" = no; then 523690b17f1bSmrg # Add the symbol object into the linking commands. 523790b17f1bSmrg func_append compile_command " @SYMFILE@" 523890b17f1bSmrg func_append finalize_command " @SYMFILE@" 5239983b4bf2Smrg preload=yes 5240983b4bf2Smrg fi 524190b17f1bSmrg case $arg in 524290b17f1bSmrg *.la | *.lo) ;; # We handle these cases below. 524390b17f1bSmrg force) 5244983b4bf2Smrg if test "$dlself" = no; then 524590b17f1bSmrg dlself=needless 524690b17f1bSmrg export_dynamic=yes 524790b17f1bSmrg fi 524890b17f1bSmrg prev= 524990b17f1bSmrg continue 525090b17f1bSmrg ;; 525190b17f1bSmrg self) 5252983b4bf2Smrg if test "$prev" = dlprefiles; then 525390b17f1bSmrg dlself=yes 5254983b4bf2Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 525590b17f1bSmrg dlself=yes 525690b17f1bSmrg else 525790b17f1bSmrg dlself=needless 525890b17f1bSmrg export_dynamic=yes 525990b17f1bSmrg fi 526090b17f1bSmrg prev= 526190b17f1bSmrg continue 526290b17f1bSmrg ;; 526390b17f1bSmrg *) 5264983b4bf2Smrg if test "$prev" = dlfiles; then 526590b17f1bSmrg func_append dlfiles " $arg" 526690b17f1bSmrg else 526790b17f1bSmrg func_append dlprefiles " $arg" 526890b17f1bSmrg fi 526990b17f1bSmrg prev= 527090b17f1bSmrg continue 527190b17f1bSmrg ;; 527290b17f1bSmrg esac 527390b17f1bSmrg ;; 527490b17f1bSmrg expsyms) 5275983b4bf2Smrg export_symbols="$arg" 527690b17f1bSmrg test -f "$arg" \ 5277983b4bf2Smrg || func_fatal_error "symbol file \`$arg' does not exist" 527890b17f1bSmrg prev= 527990b17f1bSmrg continue 528090b17f1bSmrg ;; 528190b17f1bSmrg expsyms_regex) 5282983b4bf2Smrg export_symbols_regex="$arg" 528390b17f1bSmrg prev= 528490b17f1bSmrg continue 528590b17f1bSmrg ;; 528690b17f1bSmrg framework) 528790b17f1bSmrg case $host in 528890b17f1bSmrg *-*-darwin*) 528990b17f1bSmrg case "$deplibs " in 529090b17f1bSmrg *" $qarg.ltframework "*) ;; 529190b17f1bSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 529290b17f1bSmrg ;; 529390b17f1bSmrg esac 529490b17f1bSmrg ;; 529590b17f1bSmrg esac 529690b17f1bSmrg prev= 529790b17f1bSmrg continue 529890b17f1bSmrg ;; 529990b17f1bSmrg inst_prefix) 5300983b4bf2Smrg inst_prefix_dir="$arg" 530190b17f1bSmrg prev= 530290b17f1bSmrg continue 530390b17f1bSmrg ;; 530490b17f1bSmrg objectlist) 530590b17f1bSmrg if test -f "$arg"; then 530690b17f1bSmrg save_arg=$arg 530790b17f1bSmrg moreargs= 530890b17f1bSmrg for fil in `cat "$save_arg"` 530990b17f1bSmrg do 531090b17f1bSmrg# func_append moreargs " $fil" 531190b17f1bSmrg arg=$fil 531290b17f1bSmrg # A libtool-controlled object. 53137e6fb56fSmrg 531490b17f1bSmrg # Check to see that this really is a libtool object. 531590b17f1bSmrg if func_lalib_unsafe_p "$arg"; then 531690b17f1bSmrg pic_object= 531790b17f1bSmrg non_pic_object= 53187e6fb56fSmrg 531990b17f1bSmrg # Read the .lo file 532090b17f1bSmrg func_source "$arg" 53217e6fb56fSmrg 532290b17f1bSmrg if test -z "$pic_object" || 532390b17f1bSmrg test -z "$non_pic_object" || 5324983b4bf2Smrg test "$pic_object" = none && 5325983b4bf2Smrg test "$non_pic_object" = none; then 5326983b4bf2Smrg func_fatal_error "cannot find name of object for \`$arg'" 532790b17f1bSmrg fi 53287e6fb56fSmrg 532990b17f1bSmrg # Extract subdirectory from the argument. 533090b17f1bSmrg func_dirname "$arg" "/" "" 5331983b4bf2Smrg xdir="$func_dirname_result" 53327e6fb56fSmrg 5333983b4bf2Smrg if test "$pic_object" != none; then 533490b17f1bSmrg # Prepend the subdirectory the object is found in. 5335983b4bf2Smrg pic_object="$xdir$pic_object" 53367e6fb56fSmrg 5337983b4bf2Smrg if test "$prev" = dlfiles; then 5338983b4bf2Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 533990b17f1bSmrg func_append dlfiles " $pic_object" 534090b17f1bSmrg prev= 534190b17f1bSmrg continue 534290b17f1bSmrg else 534390b17f1bSmrg # If libtool objects are unsupported, then we need to preload. 534490b17f1bSmrg prev=dlprefiles 534590b17f1bSmrg fi 534690b17f1bSmrg fi 53477e6fb56fSmrg 534890b17f1bSmrg # CHECK ME: I think I busted this. -Ossama 5349983b4bf2Smrg if test "$prev" = dlprefiles; then 535090b17f1bSmrg # Preload the old-style object. 535190b17f1bSmrg func_append dlprefiles " $pic_object" 535290b17f1bSmrg prev= 535390b17f1bSmrg fi 53547e6fb56fSmrg 535590b17f1bSmrg # A PIC object. 535690b17f1bSmrg func_append libobjs " $pic_object" 5357983b4bf2Smrg arg="$pic_object" 535890b17f1bSmrg fi 53597e6fb56fSmrg 536090b17f1bSmrg # Non-PIC object. 5361983b4bf2Smrg if test "$non_pic_object" != none; then 536290b17f1bSmrg # Prepend the subdirectory the object is found in. 5363983b4bf2Smrg non_pic_object="$xdir$non_pic_object" 53647e6fb56fSmrg 536590b17f1bSmrg # A standard non-PIC object 536690b17f1bSmrg func_append non_pic_objects " $non_pic_object" 5367983b4bf2Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5368983b4bf2Smrg arg="$non_pic_object" 536990b17f1bSmrg fi 537090b17f1bSmrg else 537190b17f1bSmrg # If the PIC object exists, use it instead. 537290b17f1bSmrg # $xdir was prepended to $pic_object above. 5373983b4bf2Smrg non_pic_object="$pic_object" 537490b17f1bSmrg func_append non_pic_objects " $non_pic_object" 537590b17f1bSmrg fi 537690b17f1bSmrg else 537790b17f1bSmrg # Only an error if not doing a dry-run. 537890b17f1bSmrg if $opt_dry_run; then 537990b17f1bSmrg # Extract subdirectory from the argument. 538090b17f1bSmrg func_dirname "$arg" "/" "" 5381983b4bf2Smrg xdir="$func_dirname_result" 538290b17f1bSmrg 538390b17f1bSmrg func_lo2o "$arg" 538490b17f1bSmrg pic_object=$xdir$objdir/$func_lo2o_result 538590b17f1bSmrg non_pic_object=$xdir$func_lo2o_result 538690b17f1bSmrg func_append libobjs " $pic_object" 538790b17f1bSmrg func_append non_pic_objects " $non_pic_object" 538890b17f1bSmrg else 5389983b4bf2Smrg func_fatal_error "\`$arg' is not a valid libtool object" 539090b17f1bSmrg fi 539190b17f1bSmrg fi 539290b17f1bSmrg done 539390b17f1bSmrg else 5394983b4bf2Smrg func_fatal_error "link input file \`$arg' does not exist" 539590b17f1bSmrg fi 539690b17f1bSmrg arg=$save_arg 539790b17f1bSmrg prev= 539890b17f1bSmrg continue 539990b17f1bSmrg ;; 540090b17f1bSmrg precious_regex) 5401983b4bf2Smrg precious_files_regex="$arg" 540290b17f1bSmrg prev= 540390b17f1bSmrg continue 540490b17f1bSmrg ;; 540590b17f1bSmrg release) 5406983b4bf2Smrg release="-$arg" 540790b17f1bSmrg prev= 540890b17f1bSmrg continue 540990b17f1bSmrg ;; 541090b17f1bSmrg rpath | xrpath) 541190b17f1bSmrg # We need an absolute path. 541290b17f1bSmrg case $arg in 541390b17f1bSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 541490b17f1bSmrg *) 541590b17f1bSmrg func_fatal_error "only absolute run-paths are allowed" 541690b17f1bSmrg ;; 541790b17f1bSmrg esac 5418983b4bf2Smrg if test "$prev" = rpath; then 541990b17f1bSmrg case "$rpath " in 542090b17f1bSmrg *" $arg "*) ;; 542190b17f1bSmrg *) func_append rpath " $arg" ;; 542290b17f1bSmrg esac 542390b17f1bSmrg else 542490b17f1bSmrg case "$xrpath " in 542590b17f1bSmrg *" $arg "*) ;; 542690b17f1bSmrg *) func_append xrpath " $arg" ;; 542790b17f1bSmrg esac 542890b17f1bSmrg fi 542990b17f1bSmrg prev= 543090b17f1bSmrg continue 543190b17f1bSmrg ;; 543290b17f1bSmrg shrext) 5433983b4bf2Smrg shrext_cmds="$arg" 543490b17f1bSmrg prev= 543590b17f1bSmrg continue 543690b17f1bSmrg ;; 543790b17f1bSmrg weak) 543890b17f1bSmrg func_append weak_libs " $arg" 543990b17f1bSmrg prev= 544090b17f1bSmrg continue 544190b17f1bSmrg ;; 544290b17f1bSmrg xcclinker) 544390b17f1bSmrg func_append linker_flags " $qarg" 544490b17f1bSmrg func_append compiler_flags " $qarg" 544590b17f1bSmrg prev= 544690b17f1bSmrg func_append compile_command " $qarg" 544790b17f1bSmrg func_append finalize_command " $qarg" 544890b17f1bSmrg continue 544990b17f1bSmrg ;; 545090b17f1bSmrg xcompiler) 545190b17f1bSmrg func_append compiler_flags " $qarg" 545290b17f1bSmrg prev= 545390b17f1bSmrg func_append compile_command " $qarg" 545490b17f1bSmrg func_append finalize_command " $qarg" 545590b17f1bSmrg continue 545690b17f1bSmrg ;; 545790b17f1bSmrg xlinker) 545890b17f1bSmrg func_append linker_flags " $qarg" 545990b17f1bSmrg func_append compiler_flags " $wl$qarg" 546090b17f1bSmrg prev= 546190b17f1bSmrg func_append compile_command " $wl$qarg" 546290b17f1bSmrg func_append finalize_command " $wl$qarg" 546390b17f1bSmrg continue 546490b17f1bSmrg ;; 546590b17f1bSmrg *) 546690b17f1bSmrg eval "$prev=\"\$arg\"" 546790b17f1bSmrg prev= 546890b17f1bSmrg continue 546990b17f1bSmrg ;; 547090b17f1bSmrg esac 547190b17f1bSmrg fi # test -n "$prev" 54727e6fb56fSmrg 5473983b4bf2Smrg prevarg="$arg" 54747e6fb56fSmrg 547590b17f1bSmrg case $arg in 547690b17f1bSmrg -all-static) 547790b17f1bSmrg if test -n "$link_static_flag"; then 547890b17f1bSmrg # See comment for -static flag below, for more details. 547990b17f1bSmrg func_append compile_command " $link_static_flag" 548090b17f1bSmrg func_append finalize_command " $link_static_flag" 548190b17f1bSmrg fi 548290b17f1bSmrg continue 548390b17f1bSmrg ;; 54847e6fb56fSmrg 548590b17f1bSmrg -allow-undefined) 548690b17f1bSmrg # FIXME: remove this flag sometime in the future. 5487983b4bf2Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 548890b17f1bSmrg ;; 54897e6fb56fSmrg 549090b17f1bSmrg -avoid-version) 549190b17f1bSmrg avoid_version=yes 549290b17f1bSmrg continue 549390b17f1bSmrg ;; 54947e6fb56fSmrg 549590b17f1bSmrg -bindir) 549690b17f1bSmrg prev=bindir 549790b17f1bSmrg continue 549890b17f1bSmrg ;; 54997e6fb56fSmrg 550090b17f1bSmrg -dlopen) 550190b17f1bSmrg prev=dlfiles 550290b17f1bSmrg continue 550390b17f1bSmrg ;; 55047e6fb56fSmrg 550590b17f1bSmrg -dlpreopen) 550690b17f1bSmrg prev=dlprefiles 550790b17f1bSmrg continue 550890b17f1bSmrg ;; 55097e6fb56fSmrg 551090b17f1bSmrg -export-dynamic) 551190b17f1bSmrg export_dynamic=yes 551290b17f1bSmrg continue 551390b17f1bSmrg ;; 55147e6fb56fSmrg 551590b17f1bSmrg -export-symbols | -export-symbols-regex) 551690b17f1bSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 551790b17f1bSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 551890b17f1bSmrg fi 5519983b4bf2Smrg if test "X$arg" = "X-export-symbols"; then 552090b17f1bSmrg prev=expsyms 552190b17f1bSmrg else 552290b17f1bSmrg prev=expsyms_regex 552390b17f1bSmrg fi 552490b17f1bSmrg continue 552590b17f1bSmrg ;; 55267e6fb56fSmrg 552790b17f1bSmrg -framework) 552890b17f1bSmrg prev=framework 552990b17f1bSmrg continue 553090b17f1bSmrg ;; 55317e6fb56fSmrg 553290b17f1bSmrg -inst-prefix-dir) 553390b17f1bSmrg prev=inst_prefix 553490b17f1bSmrg continue 553590b17f1bSmrg ;; 55367e6fb56fSmrg 553790b17f1bSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 553890b17f1bSmrg # so, if we see these flags be careful not to treat them like -L 553990b17f1bSmrg -L[A-Z][A-Z]*:*) 554090b17f1bSmrg case $with_gcc/$host in 554190b17f1bSmrg no/*-*-irix* | /*-*-irix*) 554290b17f1bSmrg func_append compile_command " $arg" 554390b17f1bSmrg func_append finalize_command " $arg" 554490b17f1bSmrg ;; 554590b17f1bSmrg esac 554690b17f1bSmrg continue 554790b17f1bSmrg ;; 55487e6fb56fSmrg 554990b17f1bSmrg -L*) 555090b17f1bSmrg func_stripname "-L" '' "$arg" 555190b17f1bSmrg if test -z "$func_stripname_result"; then 555290b17f1bSmrg if test "$#" -gt 0; then 5553983b4bf2Smrg func_fatal_error "require no space between \`-L' and \`$1'" 555490b17f1bSmrg else 5555983b4bf2Smrg func_fatal_error "need path for \`-L' option" 555690b17f1bSmrg fi 555790b17f1bSmrg fi 555890b17f1bSmrg func_resolve_sysroot "$func_stripname_result" 555990b17f1bSmrg dir=$func_resolve_sysroot_result 556090b17f1bSmrg # We need an absolute path. 556190b17f1bSmrg case $dir in 556290b17f1bSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 556390b17f1bSmrg *) 556490b17f1bSmrg absdir=`cd "$dir" && pwd` 556590b17f1bSmrg test -z "$absdir" && \ 5566983b4bf2Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 5567983b4bf2Smrg dir="$absdir" 556890b17f1bSmrg ;; 556990b17f1bSmrg esac 557090b17f1bSmrg case "$deplibs " in 557190b17f1bSmrg *" -L$dir "* | *" $arg "*) 557290b17f1bSmrg # Will only happen for absolute or sysroot arguments 557390b17f1bSmrg ;; 557490b17f1bSmrg *) 557590b17f1bSmrg # Preserve sysroot, but never include relative directories 557690b17f1bSmrg case $dir in 557790b17f1bSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 557890b17f1bSmrg *) func_append deplibs " -L$dir" ;; 557990b17f1bSmrg esac 558090b17f1bSmrg func_append lib_search_path " $dir" 558190b17f1bSmrg ;; 558290b17f1bSmrg esac 558390b17f1bSmrg case $host in 558490b17f1bSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 558590b17f1bSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 558690b17f1bSmrg case :$dllsearchpath: in 558790b17f1bSmrg *":$dir:"*) ;; 558890b17f1bSmrg ::) dllsearchpath=$dir;; 558990b17f1bSmrg *) func_append dllsearchpath ":$dir";; 559090b17f1bSmrg esac 559190b17f1bSmrg case :$dllsearchpath: in 559290b17f1bSmrg *":$testbindir:"*) ;; 559390b17f1bSmrg ::) dllsearchpath=$testbindir;; 559490b17f1bSmrg *) func_append dllsearchpath ":$testbindir";; 559590b17f1bSmrg esac 559690b17f1bSmrg ;; 559790b17f1bSmrg esac 559890b17f1bSmrg continue 559990b17f1bSmrg ;; 56007e6fb56fSmrg 560190b17f1bSmrg -l*) 5602983b4bf2Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 560390b17f1bSmrg case $host in 560490b17f1bSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 560590b17f1bSmrg # These systems don't actually have a C or math library (as such) 560690b17f1bSmrg continue 560790b17f1bSmrg ;; 560890b17f1bSmrg *-*-os2*) 560990b17f1bSmrg # These systems don't actually have a C library (as such) 5610983b4bf2Smrg test "X$arg" = "X-lc" && continue 561190b17f1bSmrg ;; 5612983b4bf2Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 561390b17f1bSmrg # Do not include libc due to us having libc/libc_r. 5614983b4bf2Smrg test "X$arg" = "X-lc" && continue 561590b17f1bSmrg ;; 561690b17f1bSmrg *-*-rhapsody* | *-*-darwin1.[012]) 561790b17f1bSmrg # Rhapsody C and math libraries are in the System framework 561890b17f1bSmrg func_append deplibs " System.ltframework" 561990b17f1bSmrg continue 562090b17f1bSmrg ;; 562190b17f1bSmrg *-*-sco3.2v5* | *-*-sco5v6*) 562290b17f1bSmrg # Causes problems with __ctype 5623983b4bf2Smrg test "X$arg" = "X-lc" && continue 562490b17f1bSmrg ;; 562590b17f1bSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 562690b17f1bSmrg # Compiler inserts libc in the correct place for threads to work 5627983b4bf2Smrg test "X$arg" = "X-lc" && continue 562890b17f1bSmrg ;; 562990b17f1bSmrg esac 5630983b4bf2Smrg elif test "X$arg" = "X-lc_r"; then 563190b17f1bSmrg case $host in 5632983b4bf2Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 563390b17f1bSmrg # Do not include libc_r directly, use -pthread flag. 563490b17f1bSmrg continue 563590b17f1bSmrg ;; 563690b17f1bSmrg esac 563790b17f1bSmrg fi 563890b17f1bSmrg func_append deplibs " $arg" 563990b17f1bSmrg continue 564090b17f1bSmrg ;; 564190b17f1bSmrg 564290b17f1bSmrg -module) 564390b17f1bSmrg module=yes 564490b17f1bSmrg continue 564590b17f1bSmrg ;; 564690b17f1bSmrg 564790b17f1bSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 564890b17f1bSmrg # classes, name mangling, and exception handling. 564990b17f1bSmrg # Darwin uses the -arch flag to determine output architecture. 565090b17f1bSmrg -model|-arch|-isysroot|--sysroot) 565190b17f1bSmrg func_append compiler_flags " $arg" 565290b17f1bSmrg func_append compile_command " $arg" 565390b17f1bSmrg func_append finalize_command " $arg" 565490b17f1bSmrg prev=xcompiler 565590b17f1bSmrg continue 565690b17f1bSmrg ;; 565790b17f1bSmrg 565890b17f1bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 565990b17f1bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 566090b17f1bSmrg func_append compiler_flags " $arg" 566190b17f1bSmrg func_append compile_command " $arg" 566290b17f1bSmrg func_append finalize_command " $arg" 566390b17f1bSmrg case "$new_inherited_linker_flags " in 566490b17f1bSmrg *" $arg "*) ;; 566590b17f1bSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 566690b17f1bSmrg esac 566790b17f1bSmrg continue 566890b17f1bSmrg ;; 566990b17f1bSmrg 567090b17f1bSmrg -multi_module) 5671983b4bf2Smrg single_module="${wl}-multi_module" 567290b17f1bSmrg continue 567390b17f1bSmrg ;; 567490b17f1bSmrg 567590b17f1bSmrg -no-fast-install) 567690b17f1bSmrg fast_install=no 567790b17f1bSmrg continue 567890b17f1bSmrg ;; 567990b17f1bSmrg 568090b17f1bSmrg -no-install) 568190b17f1bSmrg case $host in 568290b17f1bSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 568390b17f1bSmrg # The PATH hackery in wrapper scripts is required on Windows 568490b17f1bSmrg # and Darwin in order for the loader to find any dlls it needs. 5685983b4bf2Smrg func_warning "\`-no-install' is ignored for $host" 5686983b4bf2Smrg func_warning "assuming \`-no-fast-install' instead" 568790b17f1bSmrg fast_install=no 568890b17f1bSmrg ;; 568990b17f1bSmrg *) no_install=yes ;; 569090b17f1bSmrg esac 569190b17f1bSmrg continue 569290b17f1bSmrg ;; 569390b17f1bSmrg 569490b17f1bSmrg -no-undefined) 569590b17f1bSmrg allow_undefined=no 569690b17f1bSmrg continue 569790b17f1bSmrg ;; 569890b17f1bSmrg 569990b17f1bSmrg -objectlist) 570090b17f1bSmrg prev=objectlist 570190b17f1bSmrg continue 570290b17f1bSmrg ;; 570390b17f1bSmrg 570490b17f1bSmrg -o) prev=output ;; 570590b17f1bSmrg 570690b17f1bSmrg -precious-files-regex) 570790b17f1bSmrg prev=precious_regex 570890b17f1bSmrg continue 570990b17f1bSmrg ;; 571090b17f1bSmrg 571190b17f1bSmrg -release) 571290b17f1bSmrg prev=release 571390b17f1bSmrg continue 571490b17f1bSmrg ;; 571590b17f1bSmrg 571690b17f1bSmrg -rpath) 571790b17f1bSmrg prev=rpath 571890b17f1bSmrg continue 571990b17f1bSmrg ;; 572090b17f1bSmrg 572190b17f1bSmrg -R) 572290b17f1bSmrg prev=xrpath 572390b17f1bSmrg continue 572490b17f1bSmrg ;; 572590b17f1bSmrg 572690b17f1bSmrg -R*) 572790b17f1bSmrg func_stripname '-R' '' "$arg" 572890b17f1bSmrg dir=$func_stripname_result 572990b17f1bSmrg # We need an absolute path. 573090b17f1bSmrg case $dir in 573190b17f1bSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 573290b17f1bSmrg =*) 573390b17f1bSmrg func_stripname '=' '' "$dir" 573490b17f1bSmrg dir=$lt_sysroot$func_stripname_result 573590b17f1bSmrg ;; 573690b17f1bSmrg *) 573790b17f1bSmrg func_fatal_error "only absolute run-paths are allowed" 573890b17f1bSmrg ;; 573990b17f1bSmrg esac 574090b17f1bSmrg case "$xrpath " in 574190b17f1bSmrg *" $dir "*) ;; 574290b17f1bSmrg *) func_append xrpath " $dir" ;; 574390b17f1bSmrg esac 574490b17f1bSmrg continue 574590b17f1bSmrg ;; 574690b17f1bSmrg 574790b17f1bSmrg -shared) 574890b17f1bSmrg # The effects of -shared are defined in a previous loop. 574990b17f1bSmrg continue 575090b17f1bSmrg ;; 575190b17f1bSmrg 575290b17f1bSmrg -shrext) 575390b17f1bSmrg prev=shrext 575490b17f1bSmrg continue 575590b17f1bSmrg ;; 575690b17f1bSmrg 575790b17f1bSmrg -static | -static-libtool-libs) 575890b17f1bSmrg # The effects of -static are defined in a previous loop. 575990b17f1bSmrg # We used to do the same as -all-static on platforms that 576090b17f1bSmrg # didn't have a PIC flag, but the assumption that the effects 576190b17f1bSmrg # would be equivalent was wrong. It would break on at least 576290b17f1bSmrg # Digital Unix and AIX. 576390b17f1bSmrg continue 576490b17f1bSmrg ;; 576590b17f1bSmrg 576690b17f1bSmrg -thread-safe) 576790b17f1bSmrg thread_safe=yes 576890b17f1bSmrg continue 576990b17f1bSmrg ;; 577090b17f1bSmrg 577190b17f1bSmrg -version-info) 577290b17f1bSmrg prev=vinfo 577390b17f1bSmrg continue 577490b17f1bSmrg ;; 577590b17f1bSmrg 577690b17f1bSmrg -version-number) 577790b17f1bSmrg prev=vinfo 577890b17f1bSmrg vinfo_number=yes 577990b17f1bSmrg continue 578090b17f1bSmrg ;; 578190b17f1bSmrg 578290b17f1bSmrg -weak) 578390b17f1bSmrg prev=weak 578490b17f1bSmrg continue 578590b17f1bSmrg ;; 578690b17f1bSmrg 578790b17f1bSmrg -Wc,*) 578890b17f1bSmrg func_stripname '-Wc,' '' "$arg" 578990b17f1bSmrg args=$func_stripname_result 579090b17f1bSmrg arg= 5791983b4bf2Smrg save_ifs="$IFS"; IFS=',' 579290b17f1bSmrg for flag in $args; do 5793983b4bf2Smrg IFS="$save_ifs" 579490b17f1bSmrg func_quote_for_eval "$flag" 579590b17f1bSmrg func_append arg " $func_quote_for_eval_result" 579690b17f1bSmrg func_append compiler_flags " $func_quote_for_eval_result" 579790b17f1bSmrg done 5798983b4bf2Smrg IFS="$save_ifs" 579990b17f1bSmrg func_stripname ' ' '' "$arg" 580090b17f1bSmrg arg=$func_stripname_result 580190b17f1bSmrg ;; 580290b17f1bSmrg 580390b17f1bSmrg -Wl,*) 580490b17f1bSmrg func_stripname '-Wl,' '' "$arg" 580590b17f1bSmrg args=$func_stripname_result 580690b17f1bSmrg arg= 5807983b4bf2Smrg save_ifs="$IFS"; IFS=',' 580890b17f1bSmrg for flag in $args; do 5809983b4bf2Smrg IFS="$save_ifs" 581090b17f1bSmrg func_quote_for_eval "$flag" 581190b17f1bSmrg func_append arg " $wl$func_quote_for_eval_result" 581290b17f1bSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 581390b17f1bSmrg func_append linker_flags " $func_quote_for_eval_result" 581490b17f1bSmrg done 5815983b4bf2Smrg IFS="$save_ifs" 581690b17f1bSmrg func_stripname ' ' '' "$arg" 581790b17f1bSmrg arg=$func_stripname_result 581890b17f1bSmrg ;; 581990b17f1bSmrg 582090b17f1bSmrg -Xcompiler) 582190b17f1bSmrg prev=xcompiler 582290b17f1bSmrg continue 582390b17f1bSmrg ;; 582490b17f1bSmrg 582590b17f1bSmrg -Xlinker) 582690b17f1bSmrg prev=xlinker 582790b17f1bSmrg continue 582890b17f1bSmrg ;; 582990b17f1bSmrg 583090b17f1bSmrg -XCClinker) 583190b17f1bSmrg prev=xcclinker 583290b17f1bSmrg continue 583390b17f1bSmrg ;; 583490b17f1bSmrg 583590b17f1bSmrg # -msg_* for osf cc 583690b17f1bSmrg -msg_*) 583790b17f1bSmrg func_quote_for_eval "$arg" 5838983b4bf2Smrg arg="$func_quote_for_eval_result" 583990b17f1bSmrg ;; 584090b17f1bSmrg 584190b17f1bSmrg # Flags to be passed through unchanged, with rationale: 584290b17f1bSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 584390b17f1bSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 584490b17f1bSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 584590b17f1bSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 584690b17f1bSmrg # -q* compiler args for the IBM compiler 584790b17f1bSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 584890b17f1bSmrg # -F/path path to uninstalled frameworks, gcc on darwin 584990b17f1bSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 585090b17f1bSmrg # @file GCC response files 585190b17f1bSmrg # -tp=* Portland pgcc target processor selection 585290b17f1bSmrg # --sysroot=* for sysroot support 5853983b4bf2Smrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 585490b17f1bSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 585590b17f1bSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 5856983b4bf2Smrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 585790b17f1bSmrg func_quote_for_eval "$arg" 5858983b4bf2Smrg arg="$func_quote_for_eval_result" 585990b17f1bSmrg func_append compile_command " $arg" 586090b17f1bSmrg func_append finalize_command " $arg" 586190b17f1bSmrg func_append compiler_flags " $arg" 586290b17f1bSmrg continue 586390b17f1bSmrg ;; 586490b17f1bSmrg 586590b17f1bSmrg # Some other compiler flag. 586690b17f1bSmrg -* | +*) 586790b17f1bSmrg func_quote_for_eval "$arg" 5868983b4bf2Smrg arg="$func_quote_for_eval_result" 586990b17f1bSmrg ;; 587090b17f1bSmrg 587190b17f1bSmrg *.$objext) 587290b17f1bSmrg # A standard object. 587390b17f1bSmrg func_append objs " $arg" 587490b17f1bSmrg ;; 587590b17f1bSmrg 587690b17f1bSmrg *.lo) 587790b17f1bSmrg # A libtool-controlled object. 587890b17f1bSmrg 587990b17f1bSmrg # Check to see that this really is a libtool object. 588090b17f1bSmrg if func_lalib_unsafe_p "$arg"; then 588190b17f1bSmrg pic_object= 588290b17f1bSmrg non_pic_object= 588390b17f1bSmrg 588490b17f1bSmrg # Read the .lo file 588590b17f1bSmrg func_source "$arg" 588690b17f1bSmrg 588790b17f1bSmrg if test -z "$pic_object" || 588890b17f1bSmrg test -z "$non_pic_object" || 5889983b4bf2Smrg test "$pic_object" = none && 5890983b4bf2Smrg test "$non_pic_object" = none; then 5891983b4bf2Smrg func_fatal_error "cannot find name of object for \`$arg'" 589290b17f1bSmrg fi 589390b17f1bSmrg 589490b17f1bSmrg # Extract subdirectory from the argument. 589590b17f1bSmrg func_dirname "$arg" "/" "" 5896983b4bf2Smrg xdir="$func_dirname_result" 589790b17f1bSmrg 5898983b4bf2Smrg if test "$pic_object" != none; then 589990b17f1bSmrg # Prepend the subdirectory the object is found in. 5900983b4bf2Smrg pic_object="$xdir$pic_object" 590190b17f1bSmrg 5902983b4bf2Smrg if test "$prev" = dlfiles; then 5903983b4bf2Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 590490b17f1bSmrg func_append dlfiles " $pic_object" 590590b17f1bSmrg prev= 590690b17f1bSmrg continue 590790b17f1bSmrg else 590890b17f1bSmrg # If libtool objects are unsupported, then we need to preload. 590990b17f1bSmrg prev=dlprefiles 591090b17f1bSmrg fi 591190b17f1bSmrg fi 591290b17f1bSmrg 591390b17f1bSmrg # CHECK ME: I think I busted this. -Ossama 5914983b4bf2Smrg if test "$prev" = dlprefiles; then 591590b17f1bSmrg # Preload the old-style object. 591690b17f1bSmrg func_append dlprefiles " $pic_object" 591790b17f1bSmrg prev= 591890b17f1bSmrg fi 591990b17f1bSmrg 592090b17f1bSmrg # A PIC object. 592190b17f1bSmrg func_append libobjs " $pic_object" 5922983b4bf2Smrg arg="$pic_object" 5923983b4bf2Smrg fi 592490b17f1bSmrg 592590b17f1bSmrg # Non-PIC object. 5926983b4bf2Smrg if test "$non_pic_object" != none; then 592790b17f1bSmrg # Prepend the subdirectory the object is found in. 5928983b4bf2Smrg non_pic_object="$xdir$non_pic_object" 592990b17f1bSmrg 593090b17f1bSmrg # A standard non-PIC object 593190b17f1bSmrg func_append non_pic_objects " $non_pic_object" 5932983b4bf2Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5933983b4bf2Smrg arg="$non_pic_object" 593490b17f1bSmrg fi 593590b17f1bSmrg else 593690b17f1bSmrg # If the PIC object exists, use it instead. 593790b17f1bSmrg # $xdir was prepended to $pic_object above. 5938983b4bf2Smrg non_pic_object="$pic_object" 593990b17f1bSmrg func_append non_pic_objects " $non_pic_object" 594090b17f1bSmrg fi 594190b17f1bSmrg else 594290b17f1bSmrg # Only an error if not doing a dry-run. 594390b17f1bSmrg if $opt_dry_run; then 594490b17f1bSmrg # Extract subdirectory from the argument. 594590b17f1bSmrg func_dirname "$arg" "/" "" 5946983b4bf2Smrg xdir="$func_dirname_result" 594790b17f1bSmrg 594890b17f1bSmrg func_lo2o "$arg" 594990b17f1bSmrg pic_object=$xdir$objdir/$func_lo2o_result 595090b17f1bSmrg non_pic_object=$xdir$func_lo2o_result 595190b17f1bSmrg func_append libobjs " $pic_object" 595290b17f1bSmrg func_append non_pic_objects " $non_pic_object" 595390b17f1bSmrg else 5954983b4bf2Smrg func_fatal_error "\`$arg' is not a valid libtool object" 595590b17f1bSmrg fi 595690b17f1bSmrg fi 595790b17f1bSmrg ;; 595890b17f1bSmrg 595990b17f1bSmrg *.$libext) 596090b17f1bSmrg # An archive. 596190b17f1bSmrg func_append deplibs " $arg" 596290b17f1bSmrg func_append old_deplibs " $arg" 596390b17f1bSmrg continue 596490b17f1bSmrg ;; 596590b17f1bSmrg 596690b17f1bSmrg *.la) 596790b17f1bSmrg # A libtool-controlled library. 596890b17f1bSmrg 596990b17f1bSmrg func_resolve_sysroot "$arg" 5970983b4bf2Smrg if test "$prev" = dlfiles; then 597190b17f1bSmrg # This library was specified with -dlopen. 597290b17f1bSmrg func_append dlfiles " $func_resolve_sysroot_result" 597390b17f1bSmrg prev= 5974983b4bf2Smrg elif test "$prev" = dlprefiles; then 597590b17f1bSmrg # The library was specified with -dlpreopen. 597690b17f1bSmrg func_append dlprefiles " $func_resolve_sysroot_result" 597790b17f1bSmrg prev= 597890b17f1bSmrg else 597990b17f1bSmrg func_append deplibs " $func_resolve_sysroot_result" 598090b17f1bSmrg fi 598190b17f1bSmrg continue 598290b17f1bSmrg ;; 598390b17f1bSmrg 598490b17f1bSmrg # Some other compiler argument. 598590b17f1bSmrg *) 598690b17f1bSmrg # Unknown arguments in both finalize_command and compile_command need 598790b17f1bSmrg # to be aesthetically quoted because they are evaled later. 598890b17f1bSmrg func_quote_for_eval "$arg" 5989983b4bf2Smrg arg="$func_quote_for_eval_result" 599090b17f1bSmrg ;; 599190b17f1bSmrg esac # arg 599290b17f1bSmrg 599390b17f1bSmrg # Now actually substitute the argument into the commands. 599490b17f1bSmrg if test -n "$arg"; then 599590b17f1bSmrg func_append compile_command " $arg" 599690b17f1bSmrg func_append finalize_command " $arg" 599790b17f1bSmrg fi 599890b17f1bSmrg done # argument parsing loop 599990b17f1bSmrg 600090b17f1bSmrg test -n "$prev" && \ 6001983b4bf2Smrg func_fatal_help "the \`$prevarg' option requires an argument" 600290b17f1bSmrg 6003983b4bf2Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 600490b17f1bSmrg eval arg=\"$export_dynamic_flag_spec\" 600590b17f1bSmrg func_append compile_command " $arg" 600690b17f1bSmrg func_append finalize_command " $arg" 600790b17f1bSmrg fi 600890b17f1bSmrg 600990b17f1bSmrg oldlibs= 601090b17f1bSmrg # calculate the name of the file, without its directory 601190b17f1bSmrg func_basename "$output" 6012983b4bf2Smrg outputname="$func_basename_result" 6013983b4bf2Smrg libobjs_save="$libobjs" 601490b17f1bSmrg 601590b17f1bSmrg if test -n "$shlibpath_var"; then 601690b17f1bSmrg # get the directories listed in $shlibpath_var 6017983b4bf2Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 601890b17f1bSmrg else 601990b17f1bSmrg shlib_search_path= 602090b17f1bSmrg fi 602190b17f1bSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 602290b17f1bSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 602390b17f1bSmrg 602490b17f1bSmrg func_dirname "$output" "/" "" 6025983b4bf2Smrg output_objdir="$func_dirname_result$objdir" 602690b17f1bSmrg func_to_tool_file "$output_objdir/" 602790b17f1bSmrg tool_output_objdir=$func_to_tool_file_result 602890b17f1bSmrg # Create the object directory. 602990b17f1bSmrg func_mkdir_p "$output_objdir" 603090b17f1bSmrg 603190b17f1bSmrg # Determine the type of output 603290b17f1bSmrg case $output in 603390b17f1bSmrg "") 603490b17f1bSmrg func_fatal_help "you must specify an output file" 603590b17f1bSmrg ;; 603690b17f1bSmrg *.$libext) linkmode=oldlib ;; 603790b17f1bSmrg *.lo | *.$objext) linkmode=obj ;; 603890b17f1bSmrg *.la) linkmode=lib ;; 603990b17f1bSmrg *) linkmode=prog ;; # Anything else should be a program. 604090b17f1bSmrg esac 604190b17f1bSmrg 604290b17f1bSmrg specialdeplibs= 604390b17f1bSmrg 604490b17f1bSmrg libs= 604590b17f1bSmrg # Find all interdependent deplibs by searching for libraries 604690b17f1bSmrg # that are linked more than once (e.g. -la -lb -la) 604790b17f1bSmrg for deplib in $deplibs; do 6048983b4bf2Smrg if $opt_preserve_dup_deps ; then 604990b17f1bSmrg case "$libs " in 605090b17f1bSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 605190b17f1bSmrg esac 605290b17f1bSmrg fi 605390b17f1bSmrg func_append libs " $deplib" 605490b17f1bSmrg done 605590b17f1bSmrg 6056983b4bf2Smrg if test "$linkmode" = lib; then 605790b17f1bSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 605890b17f1bSmrg 605990b17f1bSmrg # Compute libraries that are listed more than once in $predeps 606090b17f1bSmrg # $postdeps and mark them as special (i.e., whose duplicates are 606190b17f1bSmrg # not to be eliminated). 606290b17f1bSmrg pre_post_deps= 606390b17f1bSmrg if $opt_duplicate_compiler_generated_deps; then 606490b17f1bSmrg for pre_post_dep in $predeps $postdeps; do 606590b17f1bSmrg case "$pre_post_deps " in 606690b17f1bSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 606790b17f1bSmrg esac 606890b17f1bSmrg func_append pre_post_deps " $pre_post_dep" 606990b17f1bSmrg done 607090b17f1bSmrg fi 607190b17f1bSmrg pre_post_deps= 607290b17f1bSmrg fi 607390b17f1bSmrg 607490b17f1bSmrg deplibs= 607590b17f1bSmrg newdependency_libs= 607690b17f1bSmrg newlib_search_path= 607790b17f1bSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 607890b17f1bSmrg notinst_deplibs= # not-installed libtool libraries 607990b17f1bSmrg notinst_path= # paths that contain not-installed libtool libraries 608090b17f1bSmrg 608190b17f1bSmrg case $linkmode in 608290b17f1bSmrg lib) 608390b17f1bSmrg passes="conv dlpreopen link" 608490b17f1bSmrg for file in $dlfiles $dlprefiles; do 608590b17f1bSmrg case $file in 608690b17f1bSmrg *.la) ;; 608790b17f1bSmrg *) 6088983b4bf2Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 608990b17f1bSmrg ;; 609090b17f1bSmrg esac 609190b17f1bSmrg done 609290b17f1bSmrg ;; 609390b17f1bSmrg prog) 609490b17f1bSmrg compile_deplibs= 609590b17f1bSmrg finalize_deplibs= 6096983b4bf2Smrg alldeplibs=no 609790b17f1bSmrg newdlfiles= 609890b17f1bSmrg newdlprefiles= 609990b17f1bSmrg passes="conv scan dlopen dlpreopen link" 610090b17f1bSmrg ;; 610190b17f1bSmrg *) passes="conv" 610290b17f1bSmrg ;; 610390b17f1bSmrg esac 610490b17f1bSmrg 610590b17f1bSmrg for pass in $passes; do 610690b17f1bSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 610790b17f1bSmrg # so that -L comes before libs that need it for instance... 6108983b4bf2Smrg if test "$linkmode,$pass" = "lib,link"; then 610990b17f1bSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 611090b17f1bSmrg ## order, and fix it there properly 611190b17f1bSmrg tmp_deplibs= 611290b17f1bSmrg for deplib in $deplibs; do 611390b17f1bSmrg tmp_deplibs="$deplib $tmp_deplibs" 611490b17f1bSmrg done 6115983b4bf2Smrg deplibs="$tmp_deplibs" 611690b17f1bSmrg fi 611790b17f1bSmrg 6118983b4bf2Smrg if test "$linkmode,$pass" = "lib,link" || 6119983b4bf2Smrg test "$linkmode,$pass" = "prog,scan"; then 6120983b4bf2Smrg libs="$deplibs" 612190b17f1bSmrg deplibs= 612290b17f1bSmrg fi 6123983b4bf2Smrg if test "$linkmode" = prog; then 612490b17f1bSmrg case $pass in 6125983b4bf2Smrg dlopen) libs="$dlfiles" ;; 6126983b4bf2Smrg dlpreopen) libs="$dlprefiles" ;; 6127983b4bf2Smrg link) 6128983b4bf2Smrg libs="$deplibs %DEPLIBS%" 6129983b4bf2Smrg test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" 6130983b4bf2Smrg ;; 613190b17f1bSmrg esac 613290b17f1bSmrg fi 6133983b4bf2Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 613490b17f1bSmrg # Collect and forward deplibs of preopened libtool libs 613590b17f1bSmrg for lib in $dlprefiles; do 613690b17f1bSmrg # Ignore non-libtool-libs 613790b17f1bSmrg dependency_libs= 613890b17f1bSmrg func_resolve_sysroot "$lib" 613990b17f1bSmrg case $lib in 614090b17f1bSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 614190b17f1bSmrg esac 614290b17f1bSmrg 614390b17f1bSmrg # Collect preopened libtool deplibs, except any this library 614490b17f1bSmrg # has declared as weak libs 614590b17f1bSmrg for deplib in $dependency_libs; do 614690b17f1bSmrg func_basename "$deplib" 614790b17f1bSmrg deplib_base=$func_basename_result 614890b17f1bSmrg case " $weak_libs " in 614990b17f1bSmrg *" $deplib_base "*) ;; 615090b17f1bSmrg *) func_append deplibs " $deplib" ;; 615190b17f1bSmrg esac 615290b17f1bSmrg done 615390b17f1bSmrg done 6154983b4bf2Smrg libs="$dlprefiles" 615590b17f1bSmrg fi 6156983b4bf2Smrg if test "$pass" = dlopen; then 615790b17f1bSmrg # Collect dlpreopened libraries 6158983b4bf2Smrg save_deplibs="$deplibs" 615990b17f1bSmrg deplibs= 616090b17f1bSmrg fi 616190b17f1bSmrg 616290b17f1bSmrg for deplib in $libs; do 616390b17f1bSmrg lib= 6164983b4bf2Smrg found=no 616590b17f1bSmrg case $deplib in 616690b17f1bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 616790b17f1bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 6168983b4bf2Smrg if test "$linkmode,$pass" = "prog,link"; then 616990b17f1bSmrg compile_deplibs="$deplib $compile_deplibs" 617090b17f1bSmrg finalize_deplibs="$deplib $finalize_deplibs" 617190b17f1bSmrg else 617290b17f1bSmrg func_append compiler_flags " $deplib" 6173983b4bf2Smrg if test "$linkmode" = lib ; then 617490b17f1bSmrg case "$new_inherited_linker_flags " in 617590b17f1bSmrg *" $deplib "*) ;; 617690b17f1bSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 617790b17f1bSmrg esac 617890b17f1bSmrg fi 617990b17f1bSmrg fi 618090b17f1bSmrg continue 618190b17f1bSmrg ;; 618290b17f1bSmrg -l*) 6183983b4bf2Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 6184983b4bf2Smrg func_warning "\`-l' is ignored for archives/objects" 618590b17f1bSmrg continue 618690b17f1bSmrg fi 618790b17f1bSmrg func_stripname '-l' '' "$deplib" 618890b17f1bSmrg name=$func_stripname_result 6189983b4bf2Smrg if test "$linkmode" = lib; then 619090b17f1bSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 619190b17f1bSmrg else 619290b17f1bSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 619390b17f1bSmrg fi 619490b17f1bSmrg for searchdir in $searchdirs; do 619590b17f1bSmrg for search_ext in .la $std_shrext .so .a; do 619690b17f1bSmrg # Search the libtool library 6197983b4bf2Smrg lib="$searchdir/lib${name}${search_ext}" 619890b17f1bSmrg if test -f "$lib"; then 6199983b4bf2Smrg if test "$search_ext" = ".la"; then 6200983b4bf2Smrg found=yes 620190b17f1bSmrg else 6202983b4bf2Smrg found=no 620390b17f1bSmrg fi 620490b17f1bSmrg break 2 620590b17f1bSmrg fi 620690b17f1bSmrg done 620790b17f1bSmrg done 6208983b4bf2Smrg if test "$found" != yes; then 6209983b4bf2Smrg # deplib doesn't seem to be a libtool library 6210983b4bf2Smrg if test "$linkmode,$pass" = "prog,link"; then 6211983b4bf2Smrg compile_deplibs="$deplib $compile_deplibs" 6212983b4bf2Smrg finalize_deplibs="$deplib $finalize_deplibs" 6213983b4bf2Smrg else 6214983b4bf2Smrg deplibs="$deplib $deplibs" 6215983b4bf2Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6216983b4bf2Smrg fi 6217983b4bf2Smrg continue 6218983b4bf2Smrg else # deplib is a libtool library 621990b17f1bSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 622090b17f1bSmrg # We need to do some special things here, and not later. 6221983b4bf2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 622290b17f1bSmrg case " $predeps $postdeps " in 622390b17f1bSmrg *" $deplib "*) 622490b17f1bSmrg if func_lalib_p "$lib"; then 622590b17f1bSmrg library_names= 622690b17f1bSmrg old_library= 622790b17f1bSmrg func_source "$lib" 622890b17f1bSmrg for l in $old_library $library_names; do 6229983b4bf2Smrg ll="$l" 623090b17f1bSmrg done 6231983b4bf2Smrg if test "X$ll" = "X$old_library" ; then # only static version available 6232983b4bf2Smrg found=no 623390b17f1bSmrg func_dirname "$lib" "" "." 6234983b4bf2Smrg ladir="$func_dirname_result" 623590b17f1bSmrg lib=$ladir/$old_library 6236983b4bf2Smrg if test "$linkmode,$pass" = "prog,link"; then 623790b17f1bSmrg compile_deplibs="$deplib $compile_deplibs" 623890b17f1bSmrg finalize_deplibs="$deplib $finalize_deplibs" 623990b17f1bSmrg else 624090b17f1bSmrg deplibs="$deplib $deplibs" 6241983b4bf2Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 624290b17f1bSmrg fi 624390b17f1bSmrg continue 624490b17f1bSmrg fi 624590b17f1bSmrg fi 624690b17f1bSmrg ;; 624790b17f1bSmrg *) ;; 624890b17f1bSmrg esac 624990b17f1bSmrg fi 625090b17f1bSmrg fi 625190b17f1bSmrg ;; # -l 625290b17f1bSmrg *.ltframework) 6253983b4bf2Smrg if test "$linkmode,$pass" = "prog,link"; then 625490b17f1bSmrg compile_deplibs="$deplib $compile_deplibs" 625590b17f1bSmrg finalize_deplibs="$deplib $finalize_deplibs" 625690b17f1bSmrg else 625790b17f1bSmrg deplibs="$deplib $deplibs" 6258983b4bf2Smrg if test "$linkmode" = lib ; then 625990b17f1bSmrg case "$new_inherited_linker_flags " in 626090b17f1bSmrg *" $deplib "*) ;; 626190b17f1bSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 626290b17f1bSmrg esac 626390b17f1bSmrg fi 626490b17f1bSmrg fi 626590b17f1bSmrg continue 626690b17f1bSmrg ;; 626790b17f1bSmrg -L*) 626890b17f1bSmrg case $linkmode in 626990b17f1bSmrg lib) 627090b17f1bSmrg deplibs="$deplib $deplibs" 6271983b4bf2Smrg test "$pass" = conv && continue 627290b17f1bSmrg newdependency_libs="$deplib $newdependency_libs" 627390b17f1bSmrg func_stripname '-L' '' "$deplib" 627490b17f1bSmrg func_resolve_sysroot "$func_stripname_result" 627590b17f1bSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 627690b17f1bSmrg ;; 627790b17f1bSmrg prog) 6278983b4bf2Smrg if test "$pass" = conv; then 627990b17f1bSmrg deplibs="$deplib $deplibs" 628090b17f1bSmrg continue 628190b17f1bSmrg fi 6282983b4bf2Smrg if test "$pass" = scan; then 628390b17f1bSmrg deplibs="$deplib $deplibs" 628490b17f1bSmrg else 628590b17f1bSmrg compile_deplibs="$deplib $compile_deplibs" 628690b17f1bSmrg finalize_deplibs="$deplib $finalize_deplibs" 628790b17f1bSmrg fi 628890b17f1bSmrg func_stripname '-L' '' "$deplib" 628990b17f1bSmrg func_resolve_sysroot "$func_stripname_result" 629090b17f1bSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 629190b17f1bSmrg ;; 629290b17f1bSmrg *) 6293983b4bf2Smrg func_warning "\`-L' is ignored for archives/objects" 629490b17f1bSmrg ;; 629590b17f1bSmrg esac # linkmode 629690b17f1bSmrg continue 629790b17f1bSmrg ;; # -L 629890b17f1bSmrg -R*) 6299983b4bf2Smrg if test "$pass" = link; then 630090b17f1bSmrg func_stripname '-R' '' "$deplib" 630190b17f1bSmrg func_resolve_sysroot "$func_stripname_result" 630290b17f1bSmrg dir=$func_resolve_sysroot_result 630390b17f1bSmrg # Make sure the xrpath contains only unique directories. 630490b17f1bSmrg case "$xrpath " in 630590b17f1bSmrg *" $dir "*) ;; 630690b17f1bSmrg *) func_append xrpath " $dir" ;; 630790b17f1bSmrg esac 630890b17f1bSmrg fi 630990b17f1bSmrg deplibs="$deplib $deplibs" 631090b17f1bSmrg continue 631190b17f1bSmrg ;; 631290b17f1bSmrg *.la) 631390b17f1bSmrg func_resolve_sysroot "$deplib" 631490b17f1bSmrg lib=$func_resolve_sysroot_result 631590b17f1bSmrg ;; 631690b17f1bSmrg *.$libext) 6317983b4bf2Smrg if test "$pass" = conv; then 631890b17f1bSmrg deplibs="$deplib $deplibs" 631990b17f1bSmrg continue 632090b17f1bSmrg fi 632190b17f1bSmrg case $linkmode in 632290b17f1bSmrg lib) 632390b17f1bSmrg # Linking convenience modules into shared libraries is allowed, 632490b17f1bSmrg # but linking other static libraries is non-portable. 632590b17f1bSmrg case " $dlpreconveniencelibs " in 632690b17f1bSmrg *" $deplib "*) ;; 632790b17f1bSmrg *) 6328983b4bf2Smrg valid_a_lib=no 632990b17f1bSmrg case $deplibs_check_method in 633090b17f1bSmrg match_pattern*) 633190b17f1bSmrg set dummy $deplibs_check_method; shift 633290b17f1bSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 633390b17f1bSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 633490b17f1bSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 6335983b4bf2Smrg valid_a_lib=yes 633690b17f1bSmrg fi 633790b17f1bSmrg ;; 633890b17f1bSmrg pass_all) 6339983b4bf2Smrg valid_a_lib=yes 634090b17f1bSmrg ;; 634190b17f1bSmrg esac 6342983b4bf2Smrg if test "$valid_a_lib" != yes; then 634390b17f1bSmrg echo 634490b17f1bSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 634590b17f1bSmrg echo "*** I have the capability to make that library automatically link in when" 634690b17f1bSmrg echo "*** you link to this library. But I can only do this if you have a" 634790b17f1bSmrg echo "*** shared version of the library, which you do not appear to have" 634890b17f1bSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 634990b17f1bSmrg echo "*** that it is just a static archive that I should not use here." 6350983b4bf2Smrg else 6351983b4bf2Smrg echo 6352983b4bf2Smrg $ECHO "*** Warning: Linking the shared library $output against the" 6353983b4bf2Smrg $ECHO "*** static library $deplib is not portable!" 6354983b4bf2Smrg deplibs="$deplib $deplibs" 635590b17f1bSmrg fi 635690b17f1bSmrg ;; 635790b17f1bSmrg esac 635890b17f1bSmrg continue 635990b17f1bSmrg ;; 636090b17f1bSmrg prog) 6361983b4bf2Smrg if test "$pass" != link; then 636290b17f1bSmrg deplibs="$deplib $deplibs" 636390b17f1bSmrg else 636490b17f1bSmrg compile_deplibs="$deplib $compile_deplibs" 636590b17f1bSmrg finalize_deplibs="$deplib $finalize_deplibs" 636690b17f1bSmrg fi 636790b17f1bSmrg continue 636890b17f1bSmrg ;; 636990b17f1bSmrg esac # linkmode 637090b17f1bSmrg ;; # *.$libext 637190b17f1bSmrg *.lo | *.$objext) 6372983b4bf2Smrg if test "$pass" = conv; then 637390b17f1bSmrg deplibs="$deplib $deplibs" 6374983b4bf2Smrg elif test "$linkmode" = prog; then 6375983b4bf2Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 637690b17f1bSmrg # If there is no dlopen support or we're linking statically, 637790b17f1bSmrg # we need to preload. 637890b17f1bSmrg func_append newdlprefiles " $deplib" 637990b17f1bSmrg compile_deplibs="$deplib $compile_deplibs" 638090b17f1bSmrg finalize_deplibs="$deplib $finalize_deplibs" 638190b17f1bSmrg else 638290b17f1bSmrg func_append newdlfiles " $deplib" 638390b17f1bSmrg fi 638490b17f1bSmrg fi 638590b17f1bSmrg continue 638690b17f1bSmrg ;; 638790b17f1bSmrg %DEPLIBS%) 6388983b4bf2Smrg alldeplibs=yes 638990b17f1bSmrg continue 639090b17f1bSmrg ;; 639190b17f1bSmrg esac # case $deplib 639290b17f1bSmrg 6393983b4bf2Smrg if test "$found" = yes || test -f "$lib"; then : 6394983b4bf2Smrg else 6395983b4bf2Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 6396983b4bf2Smrg fi 639790b17f1bSmrg 639890b17f1bSmrg # Check to see that this really is a libtool archive. 639990b17f1bSmrg func_lalib_unsafe_p "$lib" \ 6400983b4bf2Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 640190b17f1bSmrg 640290b17f1bSmrg func_dirname "$lib" "" "." 6403983b4bf2Smrg ladir="$func_dirname_result" 640490b17f1bSmrg 640590b17f1bSmrg dlname= 640690b17f1bSmrg dlopen= 640790b17f1bSmrg dlpreopen= 640890b17f1bSmrg libdir= 640990b17f1bSmrg library_names= 641090b17f1bSmrg old_library= 641190b17f1bSmrg inherited_linker_flags= 641290b17f1bSmrg # If the library was installed with an old release of libtool, 641390b17f1bSmrg # it will not redefine variables installed, or shouldnotlink 641490b17f1bSmrg installed=yes 641590b17f1bSmrg shouldnotlink=no 641690b17f1bSmrg avoidtemprpath= 641790b17f1bSmrg 641890b17f1bSmrg 641990b17f1bSmrg # Read the .la file 642090b17f1bSmrg func_source "$lib" 642190b17f1bSmrg 642290b17f1bSmrg # Convert "-framework foo" to "foo.ltframework" 642390b17f1bSmrg if test -n "$inherited_linker_flags"; then 642490b17f1bSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 642590b17f1bSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 642690b17f1bSmrg case " $new_inherited_linker_flags " in 642790b17f1bSmrg *" $tmp_inherited_linker_flag "*) ;; 642890b17f1bSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 642990b17f1bSmrg esac 643090b17f1bSmrg done 643190b17f1bSmrg fi 643290b17f1bSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 6433983b4bf2Smrg if test "$linkmode,$pass" = "lib,link" || 6434983b4bf2Smrg test "$linkmode,$pass" = "prog,scan" || 6435983b4bf2Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 643690b17f1bSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 643790b17f1bSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 643890b17f1bSmrg fi 643990b17f1bSmrg 6440983b4bf2Smrg if test "$pass" = conv; then 644190b17f1bSmrg # Only check for convenience libraries 644290b17f1bSmrg deplibs="$lib $deplibs" 644390b17f1bSmrg if test -z "$libdir"; then 644490b17f1bSmrg if test -z "$old_library"; then 6445983b4bf2Smrg func_fatal_error "cannot find name of link library for \`$lib'" 644690b17f1bSmrg fi 644790b17f1bSmrg # It is a libtool convenience library, so add in its objects. 644890b17f1bSmrg func_append convenience " $ladir/$objdir/$old_library" 644990b17f1bSmrg func_append old_convenience " $ladir/$objdir/$old_library" 6450983b4bf2Smrg tmp_libs= 6451983b4bf2Smrg for deplib in $dependency_libs; do 6452983b4bf2Smrg deplibs="$deplib $deplibs" 6453983b4bf2Smrg if $opt_preserve_dup_deps ; then 6454983b4bf2Smrg case "$tmp_libs " in 6455983b4bf2Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6456983b4bf2Smrg esac 6457983b4bf2Smrg fi 6458983b4bf2Smrg func_append tmp_libs " $deplib" 6459983b4bf2Smrg done 6460983b4bf2Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 6461983b4bf2Smrg func_fatal_error "\`$lib' is not a convenience library" 646290b17f1bSmrg fi 646390b17f1bSmrg continue 646490b17f1bSmrg fi # $pass = conv 646590b17f1bSmrg 646690b17f1bSmrg 646790b17f1bSmrg # Get the name of the library we link against. 646890b17f1bSmrg linklib= 646990b17f1bSmrg if test -n "$old_library" && 6470983b4bf2Smrg { test "$prefer_static_libs" = yes || 6471983b4bf2Smrg test "$prefer_static_libs,$installed" = "built,no"; }; then 647290b17f1bSmrg linklib=$old_library 647390b17f1bSmrg else 647490b17f1bSmrg for l in $old_library $library_names; do 6475983b4bf2Smrg linklib="$l" 647690b17f1bSmrg done 647790b17f1bSmrg fi 647890b17f1bSmrg if test -z "$linklib"; then 6479983b4bf2Smrg func_fatal_error "cannot find name of link library for \`$lib'" 648090b17f1bSmrg fi 648190b17f1bSmrg 648290b17f1bSmrg # This library was specified with -dlopen. 6483983b4bf2Smrg if test "$pass" = dlopen; then 6484983b4bf2Smrg if test -z "$libdir"; then 6485983b4bf2Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 6486983b4bf2Smrg fi 648790b17f1bSmrg if test -z "$dlname" || 6488983b4bf2Smrg test "$dlopen_support" != yes || 6489983b4bf2Smrg test "$build_libtool_libs" = no; then 649090b17f1bSmrg # If there is no dlname, no dlopen support or we're linking 649190b17f1bSmrg # statically, we need to preload. We also need to preload any 649290b17f1bSmrg # dependent libraries so libltdl's deplib preloader doesn't 649390b17f1bSmrg # bomb out in the load deplibs phase. 649490b17f1bSmrg func_append dlprefiles " $lib $dependency_libs" 649590b17f1bSmrg else 649690b17f1bSmrg func_append newdlfiles " $lib" 649790b17f1bSmrg fi 649890b17f1bSmrg continue 649990b17f1bSmrg fi # $pass = dlopen 650090b17f1bSmrg 650190b17f1bSmrg # We need an absolute path. 650290b17f1bSmrg case $ladir in 6503983b4bf2Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 650490b17f1bSmrg *) 650590b17f1bSmrg abs_ladir=`cd "$ladir" && pwd` 650690b17f1bSmrg if test -z "$abs_ladir"; then 6507983b4bf2Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 650890b17f1bSmrg func_warning "passing it literally to the linker, although it might fail" 6509983b4bf2Smrg abs_ladir="$ladir" 651090b17f1bSmrg fi 651190b17f1bSmrg ;; 651290b17f1bSmrg esac 651390b17f1bSmrg func_basename "$lib" 6514983b4bf2Smrg laname="$func_basename_result" 651590b17f1bSmrg 651690b17f1bSmrg # Find the relevant object directory and library name. 6517983b4bf2Smrg if test "X$installed" = Xyes; then 651890b17f1bSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6519983b4bf2Smrg func_warning "library \`$lib' was moved." 6520983b4bf2Smrg dir="$ladir" 6521983b4bf2Smrg absdir="$abs_ladir" 6522983b4bf2Smrg libdir="$abs_ladir" 652390b17f1bSmrg else 6524983b4bf2Smrg dir="$lt_sysroot$libdir" 6525983b4bf2Smrg absdir="$lt_sysroot$libdir" 652690b17f1bSmrg fi 6527983b4bf2Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 652890b17f1bSmrg else 652990b17f1bSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6530983b4bf2Smrg dir="$ladir" 6531983b4bf2Smrg absdir="$abs_ladir" 653290b17f1bSmrg # Remove this search path later 653390b17f1bSmrg func_append notinst_path " $abs_ladir" 653490b17f1bSmrg else 6535983b4bf2Smrg dir="$ladir/$objdir" 6536983b4bf2Smrg absdir="$abs_ladir/$objdir" 653790b17f1bSmrg # Remove this search path later 653890b17f1bSmrg func_append notinst_path " $abs_ladir" 653990b17f1bSmrg fi 654090b17f1bSmrg fi # $installed = yes 654190b17f1bSmrg func_stripname 'lib' '.la' "$laname" 654290b17f1bSmrg name=$func_stripname_result 654390b17f1bSmrg 654490b17f1bSmrg # This library was specified with -dlpreopen. 6545983b4bf2Smrg if test "$pass" = dlpreopen; then 6546983b4bf2Smrg if test -z "$libdir" && test "$linkmode" = prog; then 6547983b4bf2Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 654890b17f1bSmrg fi 6549983b4bf2Smrg case "$host" in 655090b17f1bSmrg # special handling for platforms with PE-DLLs. 655190b17f1bSmrg *cygwin* | *mingw* | *cegcc* ) 655290b17f1bSmrg # Linker will automatically link against shared library if both 655390b17f1bSmrg # static and shared are present. Therefore, ensure we extract 655490b17f1bSmrg # symbols from the import library if a shared library is present 655590b17f1bSmrg # (otherwise, the dlopen module name will be incorrect). We do 655690b17f1bSmrg # this by putting the import library name into $newdlprefiles. 655790b17f1bSmrg # We recover the dlopen module name by 'saving' the la file 655890b17f1bSmrg # name in a special purpose variable, and (later) extracting the 655990b17f1bSmrg # dlname from the la file. 656090b17f1bSmrg if test -n "$dlname"; then 656190b17f1bSmrg func_tr_sh "$dir/$linklib" 656290b17f1bSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 656390b17f1bSmrg func_append newdlprefiles " $dir/$linklib" 656490b17f1bSmrg else 656590b17f1bSmrg func_append newdlprefiles " $dir/$old_library" 656690b17f1bSmrg # Keep a list of preopened convenience libraries to check 656790b17f1bSmrg # that they are being used correctly in the link pass. 656890b17f1bSmrg test -z "$libdir" && \ 656990b17f1bSmrg func_append dlpreconveniencelibs " $dir/$old_library" 657090b17f1bSmrg fi 657190b17f1bSmrg ;; 657290b17f1bSmrg * ) 657390b17f1bSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 657490b17f1bSmrg # are required to link). 657590b17f1bSmrg if test -n "$old_library"; then 657690b17f1bSmrg func_append newdlprefiles " $dir/$old_library" 657790b17f1bSmrg # Keep a list of preopened convenience libraries to check 657890b17f1bSmrg # that they are being used correctly in the link pass. 657990b17f1bSmrg test -z "$libdir" && \ 658090b17f1bSmrg func_append dlpreconveniencelibs " $dir/$old_library" 658190b17f1bSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 658290b17f1bSmrg elif test -n "$dlname"; then 658390b17f1bSmrg func_append newdlprefiles " $dir/$dlname" 658490b17f1bSmrg else 658590b17f1bSmrg func_append newdlprefiles " $dir/$linklib" 658690b17f1bSmrg fi 658790b17f1bSmrg ;; 658890b17f1bSmrg esac 658990b17f1bSmrg fi # $pass = dlpreopen 659090b17f1bSmrg 659190b17f1bSmrg if test -z "$libdir"; then 659290b17f1bSmrg # Link the convenience library 6593983b4bf2Smrg if test "$linkmode" = lib; then 659490b17f1bSmrg deplibs="$dir/$old_library $deplibs" 6595983b4bf2Smrg elif test "$linkmode,$pass" = "prog,link"; then 659690b17f1bSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 659790b17f1bSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 659890b17f1bSmrg else 659990b17f1bSmrg deplibs="$lib $deplibs" # used for prog,scan pass 660090b17f1bSmrg fi 660190b17f1bSmrg continue 660290b17f1bSmrg fi 660390b17f1bSmrg 660490b17f1bSmrg 6605983b4bf2Smrg if test "$linkmode" = prog && test "$pass" != link; then 660690b17f1bSmrg func_append newlib_search_path " $ladir" 660790b17f1bSmrg deplibs="$lib $deplibs" 660890b17f1bSmrg 6609983b4bf2Smrg linkalldeplibs=no 6610983b4bf2Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 6611983b4bf2Smrg test "$build_libtool_libs" = no; then 6612983b4bf2Smrg linkalldeplibs=yes 661390b17f1bSmrg fi 661490b17f1bSmrg 661590b17f1bSmrg tmp_libs= 661690b17f1bSmrg for deplib in $dependency_libs; do 661790b17f1bSmrg case $deplib in 661890b17f1bSmrg -L*) func_stripname '-L' '' "$deplib" 661990b17f1bSmrg func_resolve_sysroot "$func_stripname_result" 662090b17f1bSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 662190b17f1bSmrg ;; 662290b17f1bSmrg esac 662390b17f1bSmrg # Need to link against all dependency_libs? 6624983b4bf2Smrg if test "$linkalldeplibs" = yes; then 662590b17f1bSmrg deplibs="$deplib $deplibs" 662690b17f1bSmrg else 662790b17f1bSmrg # Need to hardcode shared library paths 662890b17f1bSmrg # or/and link against static libraries 662990b17f1bSmrg newdependency_libs="$deplib $newdependency_libs" 663090b17f1bSmrg fi 6631983b4bf2Smrg if $opt_preserve_dup_deps ; then 663290b17f1bSmrg case "$tmp_libs " in 663390b17f1bSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 663490b17f1bSmrg esac 663590b17f1bSmrg fi 663690b17f1bSmrg func_append tmp_libs " $deplib" 663790b17f1bSmrg done # for deplib 663890b17f1bSmrg continue 663990b17f1bSmrg fi # $linkmode = prog... 664090b17f1bSmrg 6641983b4bf2Smrg if test "$linkmode,$pass" = "prog,link"; then 664290b17f1bSmrg if test -n "$library_names" && 6643983b4bf2Smrg { { test "$prefer_static_libs" = no || 6644983b4bf2Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 664590b17f1bSmrg test -z "$old_library"; }; then 664690b17f1bSmrg # We need to hardcode the library path 6647983b4bf2Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 664890b17f1bSmrg # Make sure the rpath contains only unique directories. 6649983b4bf2Smrg case "$temp_rpath:" in 665090b17f1bSmrg *"$absdir:"*) ;; 665190b17f1bSmrg *) func_append temp_rpath "$absdir:" ;; 665290b17f1bSmrg esac 665390b17f1bSmrg fi 665490b17f1bSmrg 665590b17f1bSmrg # Hardcode the library path. 665690b17f1bSmrg # Skip directories that are in the system default run-time 665790b17f1bSmrg # search path. 665890b17f1bSmrg case " $sys_lib_dlsearch_path " in 665990b17f1bSmrg *" $absdir "*) ;; 666090b17f1bSmrg *) 666190b17f1bSmrg case "$compile_rpath " in 666290b17f1bSmrg *" $absdir "*) ;; 666390b17f1bSmrg *) func_append compile_rpath " $absdir" ;; 666490b17f1bSmrg esac 666590b17f1bSmrg ;; 666690b17f1bSmrg esac 666790b17f1bSmrg case " $sys_lib_dlsearch_path " in 666890b17f1bSmrg *" $libdir "*) ;; 666990b17f1bSmrg *) 667090b17f1bSmrg case "$finalize_rpath " in 667190b17f1bSmrg *" $libdir "*) ;; 667290b17f1bSmrg *) func_append finalize_rpath " $libdir" ;; 667390b17f1bSmrg esac 667490b17f1bSmrg ;; 667590b17f1bSmrg esac 667690b17f1bSmrg fi # $linkmode,$pass = prog,link... 667790b17f1bSmrg 6678983b4bf2Smrg if test "$alldeplibs" = yes && 6679983b4bf2Smrg { test "$deplibs_check_method" = pass_all || 6680983b4bf2Smrg { test "$build_libtool_libs" = yes && 668190b17f1bSmrg test -n "$library_names"; }; }; then 668290b17f1bSmrg # We only need to search for static libraries 668390b17f1bSmrg continue 668490b17f1bSmrg fi 668590b17f1bSmrg fi 668690b17f1bSmrg 668790b17f1bSmrg link_static=no # Whether the deplib will be linked statically 668890b17f1bSmrg use_static_libs=$prefer_static_libs 6689983b4bf2Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 669090b17f1bSmrg use_static_libs=no 669190b17f1bSmrg fi 669290b17f1bSmrg if test -n "$library_names" && 6693983b4bf2Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 669490b17f1bSmrg case $host in 6695983b4bf2Smrg *cygwin* | *mingw* | *cegcc*) 669690b17f1bSmrg # No point in relinking DLLs because paths are not encoded 669790b17f1bSmrg func_append notinst_deplibs " $lib" 669890b17f1bSmrg need_relink=no 669990b17f1bSmrg ;; 670090b17f1bSmrg *) 6701983b4bf2Smrg if test "$installed" = no; then 670290b17f1bSmrg func_append notinst_deplibs " $lib" 670390b17f1bSmrg need_relink=yes 670490b17f1bSmrg fi 670590b17f1bSmrg ;; 670690b17f1bSmrg esac 670790b17f1bSmrg # This is a shared library 670890b17f1bSmrg 670990b17f1bSmrg # Warn about portability, can't link against -module's on some 671090b17f1bSmrg # systems (darwin). Don't bleat about dlopened modules though! 6711983b4bf2Smrg dlopenmodule="" 671290b17f1bSmrg for dlpremoduletest in $dlprefiles; do 671390b17f1bSmrg if test "X$dlpremoduletest" = "X$lib"; then 6714983b4bf2Smrg dlopenmodule="$dlpremoduletest" 671590b17f1bSmrg break 671690b17f1bSmrg fi 671790b17f1bSmrg done 6718983b4bf2Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 671990b17f1bSmrg echo 6720983b4bf2Smrg if test "$linkmode" = prog; then 672190b17f1bSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 672290b17f1bSmrg else 672390b17f1bSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 672490b17f1bSmrg fi 672590b17f1bSmrg $ECHO "*** $linklib is not portable!" 672690b17f1bSmrg fi 6727983b4bf2Smrg if test "$linkmode" = lib && 6728983b4bf2Smrg test "$hardcode_into_libs" = yes; then 672990b17f1bSmrg # Hardcode the library path. 673090b17f1bSmrg # Skip directories that are in the system default run-time 673190b17f1bSmrg # search path. 673290b17f1bSmrg case " $sys_lib_dlsearch_path " in 673390b17f1bSmrg *" $absdir "*) ;; 673490b17f1bSmrg *) 673590b17f1bSmrg case "$compile_rpath " in 673690b17f1bSmrg *" $absdir "*) ;; 673790b17f1bSmrg *) func_append compile_rpath " $absdir" ;; 673890b17f1bSmrg esac 673990b17f1bSmrg ;; 674090b17f1bSmrg esac 674190b17f1bSmrg case " $sys_lib_dlsearch_path " in 674290b17f1bSmrg *" $libdir "*) ;; 674390b17f1bSmrg *) 674490b17f1bSmrg case "$finalize_rpath " in 674590b17f1bSmrg *" $libdir "*) ;; 674690b17f1bSmrg *) func_append finalize_rpath " $libdir" ;; 674790b17f1bSmrg esac 674890b17f1bSmrg ;; 674990b17f1bSmrg esac 675090b17f1bSmrg fi 675190b17f1bSmrg 675290b17f1bSmrg if test -n "$old_archive_from_expsyms_cmds"; then 675390b17f1bSmrg # figure out the soname 675490b17f1bSmrg set dummy $library_names 675590b17f1bSmrg shift 6756983b4bf2Smrg realname="$1" 675790b17f1bSmrg shift 675890b17f1bSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 675990b17f1bSmrg # use dlname if we got it. it's perfectly good, no? 676090b17f1bSmrg if test -n "$dlname"; then 6761983b4bf2Smrg soname="$dlname" 676290b17f1bSmrg elif test -n "$soname_spec"; then 676390b17f1bSmrg # bleh windows 676490b17f1bSmrg case $host in 6765983b4bf2Smrg *cygwin* | mingw* | *cegcc*) 676690b17f1bSmrg func_arith $current - $age 676790b17f1bSmrg major=$func_arith_result 6768983b4bf2Smrg versuffix="-$major" 676990b17f1bSmrg ;; 677090b17f1bSmrg esac 677190b17f1bSmrg eval soname=\"$soname_spec\" 677290b17f1bSmrg else 6773983b4bf2Smrg soname="$realname" 677490b17f1bSmrg fi 677590b17f1bSmrg 677690b17f1bSmrg # Make a new name for the extract_expsyms_cmds to use 6777983b4bf2Smrg soroot="$soname" 677890b17f1bSmrg func_basename "$soroot" 6779983b4bf2Smrg soname="$func_basename_result" 678090b17f1bSmrg func_stripname 'lib' '.dll' "$soname" 678190b17f1bSmrg newlib=libimp-$func_stripname_result.a 678290b17f1bSmrg 678390b17f1bSmrg # If the library has no export list, then create one now 678490b17f1bSmrg if test -f "$output_objdir/$soname-def"; then : 678590b17f1bSmrg else 6786983b4bf2Smrg func_verbose "extracting exported symbol list from \`$soname'" 678790b17f1bSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 678890b17f1bSmrg fi 678990b17f1bSmrg 679090b17f1bSmrg # Create $newlib 679190b17f1bSmrg if test -f "$output_objdir/$newlib"; then :; else 6792983b4bf2Smrg func_verbose "generating import library for \`$soname'" 679390b17f1bSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 679490b17f1bSmrg fi 679590b17f1bSmrg # make sure the library variables are pointing to the new library 679690b17f1bSmrg dir=$output_objdir 679790b17f1bSmrg linklib=$newlib 679890b17f1bSmrg fi # test -n "$old_archive_from_expsyms_cmds" 679990b17f1bSmrg 6800983b4bf2Smrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 680190b17f1bSmrg add_shlibpath= 680290b17f1bSmrg add_dir= 680390b17f1bSmrg add= 680490b17f1bSmrg lib_linked=yes 680590b17f1bSmrg case $hardcode_action in 680690b17f1bSmrg immediate | unsupported) 6807983b4bf2Smrg if test "$hardcode_direct" = no; then 6808983b4bf2Smrg add="$dir/$linklib" 680990b17f1bSmrg case $host in 6810983b4bf2Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6811983b4bf2Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 681290b17f1bSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6813983b4bf2Smrg *-*-unixware7*) add_dir="-L$dir" ;; 681490b17f1bSmrg *-*-darwin* ) 6815983b4bf2Smrg # if the lib is a (non-dlopened) module then we can not 681690b17f1bSmrg # link against it, someone is ignoring the earlier warnings 681790b17f1bSmrg if /usr/bin/file -L $add 2> /dev/null | 6818983b4bf2Smrg $GREP ": [^:]* bundle" >/dev/null ; then 681990b17f1bSmrg if test "X$dlopenmodule" != "X$lib"; then 682090b17f1bSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6821983b4bf2Smrg if test -z "$old_library" ; then 682290b17f1bSmrg echo 682390b17f1bSmrg echo "*** And there doesn't seem to be a static archive available" 682490b17f1bSmrg echo "*** The link will probably fail, sorry" 682590b17f1bSmrg else 6826983b4bf2Smrg add="$dir/$old_library" 682790b17f1bSmrg fi 682890b17f1bSmrg elif test -n "$old_library"; then 6829983b4bf2Smrg add="$dir/$old_library" 683090b17f1bSmrg fi 683190b17f1bSmrg fi 683290b17f1bSmrg esac 6833983b4bf2Smrg elif test "$hardcode_minus_L" = no; then 683490b17f1bSmrg case $host in 6835983b4bf2Smrg *-*-sunos*) add_shlibpath="$dir" ;; 683690b17f1bSmrg esac 6837983b4bf2Smrg add_dir="-L$dir" 6838983b4bf2Smrg add="-l$name" 6839983b4bf2Smrg elif test "$hardcode_shlibpath_var" = no; then 6840983b4bf2Smrg add_shlibpath="$dir" 6841983b4bf2Smrg add="-l$name" 684290b17f1bSmrg else 684390b17f1bSmrg lib_linked=no 684490b17f1bSmrg fi 684590b17f1bSmrg ;; 684690b17f1bSmrg relink) 6847983b4bf2Smrg if test "$hardcode_direct" = yes && 6848983b4bf2Smrg test "$hardcode_direct_absolute" = no; then 6849983b4bf2Smrg add="$dir/$linklib" 6850983b4bf2Smrg elif test "$hardcode_minus_L" = yes; then 6851983b4bf2Smrg add_dir="-L$absdir" 685290b17f1bSmrg # Try looking first in the location we're being installed to. 685390b17f1bSmrg if test -n "$inst_prefix_dir"; then 685490b17f1bSmrg case $libdir in 685590b17f1bSmrg [\\/]*) 685690b17f1bSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 685790b17f1bSmrg ;; 685890b17f1bSmrg esac 685990b17f1bSmrg fi 6860983b4bf2Smrg add="-l$name" 6861983b4bf2Smrg elif test "$hardcode_shlibpath_var" = yes; then 6862983b4bf2Smrg add_shlibpath="$dir" 6863983b4bf2Smrg add="-l$name" 686490b17f1bSmrg else 686590b17f1bSmrg lib_linked=no 686690b17f1bSmrg fi 686790b17f1bSmrg ;; 686890b17f1bSmrg *) lib_linked=no ;; 686990b17f1bSmrg esac 687090b17f1bSmrg 6871983b4bf2Smrg if test "$lib_linked" != yes; then 687290b17f1bSmrg func_fatal_configuration "unsupported hardcode properties" 687390b17f1bSmrg fi 687490b17f1bSmrg 687590b17f1bSmrg if test -n "$add_shlibpath"; then 687690b17f1bSmrg case :$compile_shlibpath: in 687790b17f1bSmrg *":$add_shlibpath:"*) ;; 687890b17f1bSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 687990b17f1bSmrg esac 688090b17f1bSmrg fi 6881983b4bf2Smrg if test "$linkmode" = prog; then 688290b17f1bSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 688390b17f1bSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 688490b17f1bSmrg else 688590b17f1bSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 688690b17f1bSmrg test -n "$add" && deplibs="$add $deplibs" 6887983b4bf2Smrg if test "$hardcode_direct" != yes && 6888983b4bf2Smrg test "$hardcode_minus_L" != yes && 6889983b4bf2Smrg test "$hardcode_shlibpath_var" = yes; then 689090b17f1bSmrg case :$finalize_shlibpath: in 689190b17f1bSmrg *":$libdir:"*) ;; 689290b17f1bSmrg *) func_append finalize_shlibpath "$libdir:" ;; 689390b17f1bSmrg esac 689490b17f1bSmrg fi 689590b17f1bSmrg fi 689690b17f1bSmrg fi 689790b17f1bSmrg 6898983b4bf2Smrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 689990b17f1bSmrg add_shlibpath= 690090b17f1bSmrg add_dir= 690190b17f1bSmrg add= 690290b17f1bSmrg # Finalize command for both is simple: just hardcode it. 6903983b4bf2Smrg if test "$hardcode_direct" = yes && 6904983b4bf2Smrg test "$hardcode_direct_absolute" = no; then 6905983b4bf2Smrg add="$libdir/$linklib" 6906983b4bf2Smrg elif test "$hardcode_minus_L" = yes; then 6907983b4bf2Smrg add_dir="-L$libdir" 6908983b4bf2Smrg add="-l$name" 6909983b4bf2Smrg elif test "$hardcode_shlibpath_var" = yes; then 691090b17f1bSmrg case :$finalize_shlibpath: in 691190b17f1bSmrg *":$libdir:"*) ;; 691290b17f1bSmrg *) func_append finalize_shlibpath "$libdir:" ;; 691390b17f1bSmrg esac 6914983b4bf2Smrg add="-l$name" 6915983b4bf2Smrg elif test "$hardcode_automatic" = yes; then 691690b17f1bSmrg if test -n "$inst_prefix_dir" && 6917983b4bf2Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 6918983b4bf2Smrg add="$inst_prefix_dir$libdir/$linklib" 691990b17f1bSmrg else 6920983b4bf2Smrg add="$libdir/$linklib" 692190b17f1bSmrg fi 692290b17f1bSmrg else 692390b17f1bSmrg # We cannot seem to hardcode it, guess we'll fake it. 6924983b4bf2Smrg add_dir="-L$libdir" 692590b17f1bSmrg # Try looking first in the location we're being installed to. 692690b17f1bSmrg if test -n "$inst_prefix_dir"; then 692790b17f1bSmrg case $libdir in 692890b17f1bSmrg [\\/]*) 692990b17f1bSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 693090b17f1bSmrg ;; 693190b17f1bSmrg esac 693290b17f1bSmrg fi 6933983b4bf2Smrg add="-l$name" 693490b17f1bSmrg fi 693590b17f1bSmrg 6936983b4bf2Smrg if test "$linkmode" = prog; then 693790b17f1bSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 693890b17f1bSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 693990b17f1bSmrg else 694090b17f1bSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 694190b17f1bSmrg test -n "$add" && deplibs="$add $deplibs" 694290b17f1bSmrg fi 694390b17f1bSmrg fi 6944983b4bf2Smrg elif test "$linkmode" = prog; then 694590b17f1bSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 694690b17f1bSmrg # is not unsupported. This is valid on all known static and 694790b17f1bSmrg # shared platforms. 6948983b4bf2Smrg if test "$hardcode_direct" != unsupported; then 6949983b4bf2Smrg test -n "$old_library" && linklib="$old_library" 695090b17f1bSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 695190b17f1bSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 695290b17f1bSmrg else 695390b17f1bSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 695490b17f1bSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 695590b17f1bSmrg fi 6956983b4bf2Smrg elif test "$build_libtool_libs" = yes; then 695790b17f1bSmrg # Not a shared library 6958983b4bf2Smrg if test "$deplibs_check_method" != pass_all; then 695990b17f1bSmrg # We're trying link a shared library against a static one 696090b17f1bSmrg # but the system doesn't support it. 696190b17f1bSmrg 696290b17f1bSmrg # Just print a warning and add the library to dependency_libs so 696390b17f1bSmrg # that the program can be linked against the static library. 696490b17f1bSmrg echo 6965983b4bf2Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 696690b17f1bSmrg echo "*** I have the capability to make that library automatically link in when" 696790b17f1bSmrg echo "*** you link to this library. But I can only do this if you have a" 696890b17f1bSmrg echo "*** shared version of the library, which you do not appear to have." 6969983b4bf2Smrg if test "$module" = yes; then 697090b17f1bSmrg echo "*** But as you try to build a module library, libtool will still create " 697190b17f1bSmrg echo "*** a static module, that should work as long as the dlopening application" 697290b17f1bSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 697390b17f1bSmrg if test -z "$global_symbol_pipe"; then 697490b17f1bSmrg echo 697590b17f1bSmrg echo "*** However, this would only work if libtool was able to extract symbol" 6976983b4bf2Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 697790b17f1bSmrg echo "*** not find such a program. So, this module is probably useless." 6978983b4bf2Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 697990b17f1bSmrg fi 6980983b4bf2Smrg if test "$build_old_libs" = no; then 698190b17f1bSmrg build_libtool_libs=module 698290b17f1bSmrg build_old_libs=yes 698390b17f1bSmrg else 698490b17f1bSmrg build_libtool_libs=no 698590b17f1bSmrg fi 698690b17f1bSmrg fi 698790b17f1bSmrg else 698890b17f1bSmrg deplibs="$dir/$old_library $deplibs" 698990b17f1bSmrg link_static=yes 699090b17f1bSmrg fi 699190b17f1bSmrg fi # link shared/static library? 699290b17f1bSmrg 6993983b4bf2Smrg if test "$linkmode" = lib; then 699490b17f1bSmrg if test -n "$dependency_libs" && 6995983b4bf2Smrg { test "$hardcode_into_libs" != yes || 6996983b4bf2Smrg test "$build_old_libs" = yes || 6997983b4bf2Smrg test "$link_static" = yes; }; then 699890b17f1bSmrg # Extract -R from dependency_libs 699990b17f1bSmrg temp_deplibs= 700090b17f1bSmrg for libdir in $dependency_libs; do 700190b17f1bSmrg case $libdir in 700290b17f1bSmrg -R*) func_stripname '-R' '' "$libdir" 700390b17f1bSmrg temp_xrpath=$func_stripname_result 700490b17f1bSmrg case " $xrpath " in 700590b17f1bSmrg *" $temp_xrpath "*) ;; 700690b17f1bSmrg *) func_append xrpath " $temp_xrpath";; 700790b17f1bSmrg esac;; 700890b17f1bSmrg *) func_append temp_deplibs " $libdir";; 700990b17f1bSmrg esac 701090b17f1bSmrg done 7011983b4bf2Smrg dependency_libs="$temp_deplibs" 701290b17f1bSmrg fi 701390b17f1bSmrg 701490b17f1bSmrg func_append newlib_search_path " $absdir" 701590b17f1bSmrg # Link against this library 7016983b4bf2Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 701790b17f1bSmrg # ... and its dependency_libs 701890b17f1bSmrg tmp_libs= 701990b17f1bSmrg for deplib in $dependency_libs; do 702090b17f1bSmrg newdependency_libs="$deplib $newdependency_libs" 702190b17f1bSmrg case $deplib in 702290b17f1bSmrg -L*) func_stripname '-L' '' "$deplib" 702390b17f1bSmrg func_resolve_sysroot "$func_stripname_result";; 702490b17f1bSmrg *) func_resolve_sysroot "$deplib" ;; 702590b17f1bSmrg esac 7026983b4bf2Smrg if $opt_preserve_dup_deps ; then 702790b17f1bSmrg case "$tmp_libs " in 702890b17f1bSmrg *" $func_resolve_sysroot_result "*) 702990b17f1bSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 703090b17f1bSmrg esac 703190b17f1bSmrg fi 703290b17f1bSmrg func_append tmp_libs " $func_resolve_sysroot_result" 703390b17f1bSmrg done 703490b17f1bSmrg 7035983b4bf2Smrg if test "$link_all_deplibs" != no; then 703690b17f1bSmrg # Add the search paths of all dependency libraries 703790b17f1bSmrg for deplib in $dependency_libs; do 703890b17f1bSmrg path= 703990b17f1bSmrg case $deplib in 7040983b4bf2Smrg -L*) path="$deplib" ;; 704190b17f1bSmrg *.la) 704290b17f1bSmrg func_resolve_sysroot "$deplib" 704390b17f1bSmrg deplib=$func_resolve_sysroot_result 704490b17f1bSmrg func_dirname "$deplib" "" "." 704590b17f1bSmrg dir=$func_dirname_result 704690b17f1bSmrg # We need an absolute path. 704790b17f1bSmrg case $dir in 7048983b4bf2Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 704990b17f1bSmrg *) 705090b17f1bSmrg absdir=`cd "$dir" && pwd` 705190b17f1bSmrg if test -z "$absdir"; then 7052983b4bf2Smrg func_warning "cannot determine absolute directory name of \`$dir'" 7053983b4bf2Smrg absdir="$dir" 705490b17f1bSmrg fi 705590b17f1bSmrg ;; 705690b17f1bSmrg esac 705790b17f1bSmrg if $GREP "^installed=no" $deplib > /dev/null; then 705890b17f1bSmrg case $host in 705990b17f1bSmrg *-*-darwin*) 706090b17f1bSmrg depdepl= 7061983b4bf2Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 7062983b4bf2Smrg if test -n "$deplibrary_names" ; then 7063983b4bf2Smrg for tmp in $deplibrary_names ; do 706490b17f1bSmrg depdepl=$tmp 706590b17f1bSmrg done 7066983b4bf2Smrg if test -f "$absdir/$objdir/$depdepl" ; then 7067983b4bf2Smrg depdepl="$absdir/$objdir/$depdepl" 7068983b4bf2Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 706990b17f1bSmrg if test -z "$darwin_install_name"; then 7070983b4bf2Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 707190b17f1bSmrg fi 7072983b4bf2Smrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 7073983b4bf2Smrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 707490b17f1bSmrg path= 707590b17f1bSmrg fi 707690b17f1bSmrg fi 707790b17f1bSmrg ;; 707890b17f1bSmrg *) 7079983b4bf2Smrg path="-L$absdir/$objdir" 708090b17f1bSmrg ;; 708190b17f1bSmrg esac 708290b17f1bSmrg else 7083983b4bf2Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 708490b17f1bSmrg test -z "$libdir" && \ 7085983b4bf2Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 708690b17f1bSmrg test "$absdir" != "$libdir" && \ 7087983b4bf2Smrg func_warning "\`$deplib' seems to be moved" 708890b17f1bSmrg 7089983b4bf2Smrg path="-L$absdir" 709090b17f1bSmrg fi 709190b17f1bSmrg ;; 709290b17f1bSmrg esac 709390b17f1bSmrg case " $deplibs " in 709490b17f1bSmrg *" $path "*) ;; 709590b17f1bSmrg *) deplibs="$path $deplibs" ;; 709690b17f1bSmrg esac 709790b17f1bSmrg done 709890b17f1bSmrg fi # link_all_deplibs != no 709990b17f1bSmrg fi # linkmode = lib 710090b17f1bSmrg done # for deplib in $libs 7101983b4bf2Smrg if test "$pass" = link; then 7102983b4bf2Smrg if test "$linkmode" = "prog"; then 710390b17f1bSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 710490b17f1bSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 710590b17f1bSmrg else 710690b17f1bSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 710790b17f1bSmrg fi 710890b17f1bSmrg fi 7109983b4bf2Smrg dependency_libs="$newdependency_libs" 7110983b4bf2Smrg if test "$pass" = dlpreopen; then 711190b17f1bSmrg # Link the dlpreopened libraries before other libraries 711290b17f1bSmrg for deplib in $save_deplibs; do 711390b17f1bSmrg deplibs="$deplib $deplibs" 711490b17f1bSmrg done 711590b17f1bSmrg fi 7116983b4bf2Smrg if test "$pass" != dlopen; then 7117983b4bf2Smrg if test "$pass" != conv; then 711890b17f1bSmrg # Make sure lib_search_path contains only unique directories. 711990b17f1bSmrg lib_search_path= 712090b17f1bSmrg for dir in $newlib_search_path; do 712190b17f1bSmrg case "$lib_search_path " in 712290b17f1bSmrg *" $dir "*) ;; 712390b17f1bSmrg *) func_append lib_search_path " $dir" ;; 712490b17f1bSmrg esac 712590b17f1bSmrg done 712690b17f1bSmrg newlib_search_path= 7127983b4bf2Smrg fi 712890b17f1bSmrg 7129983b4bf2Smrg if test "$linkmode,$pass" != "prog,link"; then 7130983b4bf2Smrg vars="deplibs" 7131963d66acSmrg else 7132983b4bf2Smrg vars="compile_deplibs finalize_deplibs" 713390b17f1bSmrg fi 713490b17f1bSmrg for var in $vars dependency_libs; do 713590b17f1bSmrg # Add libraries to $var in reverse order 713690b17f1bSmrg eval tmp_libs=\"\$$var\" 713790b17f1bSmrg new_libs= 713890b17f1bSmrg for deplib in $tmp_libs; do 713990b17f1bSmrg # FIXME: Pedantically, this is the right thing to do, so 714090b17f1bSmrg # that some nasty dependency loop isn't accidentally 714190b17f1bSmrg # broken: 714290b17f1bSmrg #new_libs="$deplib $new_libs" 714390b17f1bSmrg # Pragmatically, this seems to cause very few problems in 714490b17f1bSmrg # practice: 714590b17f1bSmrg case $deplib in 714690b17f1bSmrg -L*) new_libs="$deplib $new_libs" ;; 714790b17f1bSmrg -R*) ;; 714890b17f1bSmrg *) 714990b17f1bSmrg # And here is the reason: when a library appears more 715090b17f1bSmrg # than once as an explicit dependence of a library, or 715190b17f1bSmrg # is implicitly linked in more than once by the 715290b17f1bSmrg # compiler, it is considered special, and multiple 715390b17f1bSmrg # occurrences thereof are not removed. Compare this 715490b17f1bSmrg # with having the same library being listed as a 715590b17f1bSmrg # dependency of multiple other libraries: in this case, 715690b17f1bSmrg # we know (pedantically, we assume) the library does not 715790b17f1bSmrg # need to be listed more than once, so we keep only the 715890b17f1bSmrg # last copy. This is not always right, but it is rare 715990b17f1bSmrg # enough that we require users that really mean to play 716090b17f1bSmrg # such unportable linking tricks to link the library 716190b17f1bSmrg # using -Wl,-lname, so that libtool does not consider it 716290b17f1bSmrg # for duplicate removal. 716390b17f1bSmrg case " $specialdeplibs " in 716490b17f1bSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 716590b17f1bSmrg *) 716690b17f1bSmrg case " $new_libs " in 716790b17f1bSmrg *" $deplib "*) ;; 716890b17f1bSmrg *) new_libs="$deplib $new_libs" ;; 716990b17f1bSmrg esac 717090b17f1bSmrg ;; 717190b17f1bSmrg esac 717290b17f1bSmrg ;; 717390b17f1bSmrg esac 717490b17f1bSmrg done 717590b17f1bSmrg tmp_libs= 717690b17f1bSmrg for deplib in $new_libs; do 717790b17f1bSmrg case $deplib in 717890b17f1bSmrg -L*) 717990b17f1bSmrg case " $tmp_libs " in 718090b17f1bSmrg *" $deplib "*) ;; 718190b17f1bSmrg *) func_append tmp_libs " $deplib" ;; 718290b17f1bSmrg esac 718390b17f1bSmrg ;; 718490b17f1bSmrg *) func_append tmp_libs " $deplib" ;; 718590b17f1bSmrg esac 718690b17f1bSmrg done 718790b17f1bSmrg eval $var=\"$tmp_libs\" 718890b17f1bSmrg done # for var 718990b17f1bSmrg fi 719090b17f1bSmrg # Last step: remove runtime libs from dependency_libs 719190b17f1bSmrg # (they stay in deplibs) 719290b17f1bSmrg tmp_libs= 7193983b4bf2Smrg for i in $dependency_libs ; do 719490b17f1bSmrg case " $predeps $postdeps $compiler_lib_search_path " in 719590b17f1bSmrg *" $i "*) 7196983b4bf2Smrg i="" 719790b17f1bSmrg ;; 719890b17f1bSmrg esac 7199983b4bf2Smrg if test -n "$i" ; then 720090b17f1bSmrg func_append tmp_libs " $i" 720190b17f1bSmrg fi 720290b17f1bSmrg done 720390b17f1bSmrg dependency_libs=$tmp_libs 720490b17f1bSmrg done # for pass 7205983b4bf2Smrg if test "$linkmode" = prog; then 7206983b4bf2Smrg dlfiles="$newdlfiles" 720790b17f1bSmrg fi 7208983b4bf2Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 7209983b4bf2Smrg dlprefiles="$newdlprefiles" 721090b17f1bSmrg fi 721190b17f1bSmrg 721290b17f1bSmrg case $linkmode in 721390b17f1bSmrg oldlib) 7214983b4bf2Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7215983b4bf2Smrg func_warning "\`-dlopen' is ignored for archives" 721690b17f1bSmrg fi 721790b17f1bSmrg 721890b17f1bSmrg case " $deplibs" in 721990b17f1bSmrg *\ -l* | *\ -L*) 7220983b4bf2Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 722190b17f1bSmrg esac 722290b17f1bSmrg 722390b17f1bSmrg test -n "$rpath" && \ 7224983b4bf2Smrg func_warning "\`-rpath' is ignored for archives" 722590b17f1bSmrg 722690b17f1bSmrg test -n "$xrpath" && \ 7227983b4bf2Smrg func_warning "\`-R' is ignored for archives" 722890b17f1bSmrg 722990b17f1bSmrg test -n "$vinfo" && \ 7230983b4bf2Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 723190b17f1bSmrg 723290b17f1bSmrg test -n "$release" && \ 7233983b4bf2Smrg func_warning "\`-release' is ignored for archives" 723490b17f1bSmrg 723590b17f1bSmrg test -n "$export_symbols$export_symbols_regex" && \ 7236983b4bf2Smrg func_warning "\`-export-symbols' is ignored for archives" 723790b17f1bSmrg 723890b17f1bSmrg # Now set the variables for building old libraries. 723990b17f1bSmrg build_libtool_libs=no 7240983b4bf2Smrg oldlibs="$output" 724190b17f1bSmrg func_append objs "$old_deplibs" 724290b17f1bSmrg ;; 724390b17f1bSmrg 724490b17f1bSmrg lib) 7245983b4bf2Smrg # Make sure we only generate libraries of the form `libNAME.la'. 724690b17f1bSmrg case $outputname in 724790b17f1bSmrg lib*) 724890b17f1bSmrg func_stripname 'lib' '.la' "$outputname" 724990b17f1bSmrg name=$func_stripname_result 725090b17f1bSmrg eval shared_ext=\"$shrext_cmds\" 725190b17f1bSmrg eval libname=\"$libname_spec\" 725290b17f1bSmrg ;; 725390b17f1bSmrg *) 7254983b4bf2Smrg test "$module" = no && \ 7255983b4bf2Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 725690b17f1bSmrg 7257983b4bf2Smrg if test "$need_lib_prefix" != no; then 725890b17f1bSmrg # Add the "lib" prefix for modules if required 725990b17f1bSmrg func_stripname '' '.la' "$outputname" 726090b17f1bSmrg name=$func_stripname_result 726190b17f1bSmrg eval shared_ext=\"$shrext_cmds\" 726290b17f1bSmrg eval libname=\"$libname_spec\" 726390b17f1bSmrg else 726490b17f1bSmrg func_stripname '' '.la' "$outputname" 726590b17f1bSmrg libname=$func_stripname_result 726690b17f1bSmrg fi 726790b17f1bSmrg ;; 726890b17f1bSmrg esac 726990b17f1bSmrg 727090b17f1bSmrg if test -n "$objs"; then 7271983b4bf2Smrg if test "$deplibs_check_method" != pass_all; then 7272983b4bf2Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 727390b17f1bSmrg else 727490b17f1bSmrg echo 727590b17f1bSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 727690b17f1bSmrg $ECHO "*** objects $objs is not portable!" 727790b17f1bSmrg func_append libobjs " $objs" 727890b17f1bSmrg fi 727990b17f1bSmrg fi 728090b17f1bSmrg 7281983b4bf2Smrg test "$dlself" != no && \ 7282983b4bf2Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 728390b17f1bSmrg 728490b17f1bSmrg set dummy $rpath 728590b17f1bSmrg shift 7286983b4bf2Smrg test "$#" -gt 1 && \ 7287983b4bf2Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 728890b17f1bSmrg 7289983b4bf2Smrg install_libdir="$1" 729090b17f1bSmrg 729190b17f1bSmrg oldlibs= 729290b17f1bSmrg if test -z "$rpath"; then 7293983b4bf2Smrg if test "$build_libtool_libs" = yes; then 729490b17f1bSmrg # Building a libtool convenience library. 7295983b4bf2Smrg # Some compilers have problems with a `.al' extension so 729690b17f1bSmrg # convenience libraries should have the same extension an 729790b17f1bSmrg # archive normally would. 729890b17f1bSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 729990b17f1bSmrg build_libtool_libs=convenience 730090b17f1bSmrg build_old_libs=yes 730190b17f1bSmrg fi 730290b17f1bSmrg 730390b17f1bSmrg test -n "$vinfo" && \ 7304983b4bf2Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 730590b17f1bSmrg 730690b17f1bSmrg test -n "$release" && \ 7307983b4bf2Smrg func_warning "\`-release' is ignored for convenience libraries" 730890b17f1bSmrg else 730990b17f1bSmrg 731090b17f1bSmrg # Parse the version information argument. 7311983b4bf2Smrg save_ifs="$IFS"; IFS=':' 731290b17f1bSmrg set dummy $vinfo 0 0 0 731390b17f1bSmrg shift 7314983b4bf2Smrg IFS="$save_ifs" 731590b17f1bSmrg 731690b17f1bSmrg test -n "$7" && \ 7317983b4bf2Smrg func_fatal_help "too many parameters to \`-version-info'" 731890b17f1bSmrg 731990b17f1bSmrg # convert absolute version numbers to libtool ages 732090b17f1bSmrg # this retains compatibility with .la files and attempts 732190b17f1bSmrg # to make the code below a bit more comprehensible 732290b17f1bSmrg 732390b17f1bSmrg case $vinfo_number in 732490b17f1bSmrg yes) 7325983b4bf2Smrg number_major="$1" 7326983b4bf2Smrg number_minor="$2" 7327983b4bf2Smrg number_revision="$3" 732890b17f1bSmrg # 732990b17f1bSmrg # There are really only two kinds -- those that 733090b17f1bSmrg # use the current revision as the major version 733190b17f1bSmrg # and those that subtract age and use age as 733290b17f1bSmrg # a minor version. But, then there is irix 7333983b4bf2Smrg # which has an extra 1 added just for fun 733490b17f1bSmrg # 733590b17f1bSmrg case $version_type in 733690b17f1bSmrg # correct linux to gnu/linux during the next big refactor 7337983b4bf2Smrg darwin|linux|osf|windows|none) 733890b17f1bSmrg func_arith $number_major + $number_minor 733990b17f1bSmrg current=$func_arith_result 7340983b4bf2Smrg age="$number_minor" 7341983b4bf2Smrg revision="$number_revision" 734290b17f1bSmrg ;; 7343983b4bf2Smrg freebsd-aout|freebsd-elf|qnx|sunos) 7344983b4bf2Smrg current="$number_major" 7345983b4bf2Smrg revision="$number_minor" 7346983b4bf2Smrg age="0" 734790b17f1bSmrg ;; 734890b17f1bSmrg irix|nonstopux) 734990b17f1bSmrg func_arith $number_major + $number_minor 735090b17f1bSmrg current=$func_arith_result 7351983b4bf2Smrg age="$number_minor" 7352983b4bf2Smrg revision="$number_minor" 735390b17f1bSmrg lt_irix_increment=no 735490b17f1bSmrg ;; 7355983b4bf2Smrg *) 7356983b4bf2Smrg func_fatal_configuration "$modename: unknown library version type \`$version_type'" 7357983b4bf2Smrg ;; 735890b17f1bSmrg esac 735990b17f1bSmrg ;; 736090b17f1bSmrg no) 7361983b4bf2Smrg current="$1" 7362983b4bf2Smrg revision="$2" 7363983b4bf2Smrg age="$3" 736490b17f1bSmrg ;; 736590b17f1bSmrg esac 736690b17f1bSmrg 736790b17f1bSmrg # Check that each of the things are valid numbers. 736890b17f1bSmrg case $current in 736990b17f1bSmrg 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]) ;; 737090b17f1bSmrg *) 7371983b4bf2Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 7372983b4bf2Smrg func_fatal_error "\`$vinfo' is not valid version information" 737390b17f1bSmrg ;; 737490b17f1bSmrg esac 737590b17f1bSmrg 737690b17f1bSmrg case $revision in 737790b17f1bSmrg 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]) ;; 737890b17f1bSmrg *) 7379983b4bf2Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 7380983b4bf2Smrg func_fatal_error "\`$vinfo' is not valid version information" 738190b17f1bSmrg ;; 738290b17f1bSmrg esac 738390b17f1bSmrg 738490b17f1bSmrg case $age in 738590b17f1bSmrg 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]) ;; 738690b17f1bSmrg *) 7387983b4bf2Smrg func_error "AGE \`$age' must be a nonnegative integer" 7388983b4bf2Smrg func_fatal_error "\`$vinfo' is not valid version information" 738990b17f1bSmrg ;; 739090b17f1bSmrg esac 739190b17f1bSmrg 739290b17f1bSmrg if test "$age" -gt "$current"; then 7393983b4bf2Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 7394983b4bf2Smrg func_fatal_error "\`$vinfo' is not valid version information" 739590b17f1bSmrg fi 739690b17f1bSmrg 739790b17f1bSmrg # Calculate the version variables. 739890b17f1bSmrg major= 739990b17f1bSmrg versuffix= 740090b17f1bSmrg verstring= 740190b17f1bSmrg case $version_type in 740290b17f1bSmrg none) ;; 740390b17f1bSmrg 740490b17f1bSmrg darwin) 740590b17f1bSmrg # Like Linux, but with the current version available in 740690b17f1bSmrg # verstring for coding it into the library header 740790b17f1bSmrg func_arith $current - $age 740890b17f1bSmrg major=.$func_arith_result 7409983b4bf2Smrg versuffix="$major.$age.$revision" 741090b17f1bSmrg # Darwin ld doesn't like 0 for these options... 741190b17f1bSmrg func_arith $current + 1 741290b17f1bSmrg minor_current=$func_arith_result 7413983b4bf2Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 741490b17f1bSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 741590b17f1bSmrg ;; 741690b17f1bSmrg 741790b17f1bSmrg freebsd-aout) 7418983b4bf2Smrg major=".$current" 7419983b4bf2Smrg versuffix=".$current.$revision"; 742090b17f1bSmrg ;; 742190b17f1bSmrg 742290b17f1bSmrg freebsd-elf) 7423983b4bf2Smrg major=".$current" 7424983b4bf2Smrg versuffix=".$current" 742590b17f1bSmrg ;; 742690b17f1bSmrg 742790b17f1bSmrg irix | nonstopux) 7428983b4bf2Smrg if test "X$lt_irix_increment" = "Xno"; then 742990b17f1bSmrg func_arith $current - $age 743090b17f1bSmrg else 743190b17f1bSmrg func_arith $current - $age + 1 743290b17f1bSmrg fi 743390b17f1bSmrg major=$func_arith_result 743490b17f1bSmrg 743590b17f1bSmrg case $version_type in 743690b17f1bSmrg nonstopux) verstring_prefix=nonstopux ;; 743790b17f1bSmrg *) verstring_prefix=sgi ;; 743890b17f1bSmrg esac 7439983b4bf2Smrg verstring="$verstring_prefix$major.$revision" 744090b17f1bSmrg 744190b17f1bSmrg # Add in all the interfaces that we are compatible with. 744290b17f1bSmrg loop=$revision 7443983b4bf2Smrg while test "$loop" -ne 0; do 744490b17f1bSmrg func_arith $revision - $loop 744590b17f1bSmrg iface=$func_arith_result 744690b17f1bSmrg func_arith $loop - 1 744790b17f1bSmrg loop=$func_arith_result 7448983b4bf2Smrg verstring="$verstring_prefix$major.$iface:$verstring" 744990b17f1bSmrg done 745090b17f1bSmrg 7451983b4bf2Smrg # Before this point, $major must not contain `.'. 745290b17f1bSmrg major=.$major 7453983b4bf2Smrg versuffix="$major.$revision" 745490b17f1bSmrg ;; 745590b17f1bSmrg 745690b17f1bSmrg linux) # correct to gnu/linux during the next big refactor 745790b17f1bSmrg func_arith $current - $age 745890b17f1bSmrg major=.$func_arith_result 7459983b4bf2Smrg versuffix="$major.$age.$revision" 746090b17f1bSmrg ;; 746190b17f1bSmrg 746290b17f1bSmrg osf) 746390b17f1bSmrg func_arith $current - $age 746490b17f1bSmrg major=.$func_arith_result 7465983b4bf2Smrg versuffix=".$current.$age.$revision" 7466983b4bf2Smrg verstring="$current.$age.$revision" 746790b17f1bSmrg 746890b17f1bSmrg # Add in all the interfaces that we are compatible with. 746990b17f1bSmrg loop=$age 7470983b4bf2Smrg while test "$loop" -ne 0; do 747190b17f1bSmrg func_arith $current - $loop 747290b17f1bSmrg iface=$func_arith_result 747390b17f1bSmrg func_arith $loop - 1 747490b17f1bSmrg loop=$func_arith_result 7475983b4bf2Smrg verstring="$verstring:${iface}.0" 747690b17f1bSmrg done 747790b17f1bSmrg 747890b17f1bSmrg # Make executables depend on our current version. 7479983b4bf2Smrg func_append verstring ":${current}.0" 748090b17f1bSmrg ;; 748190b17f1bSmrg 748290b17f1bSmrg qnx) 7483983b4bf2Smrg major=".$current" 7484983b4bf2Smrg versuffix=".$current" 748590b17f1bSmrg ;; 748690b17f1bSmrg 748790b17f1bSmrg sunos) 7488983b4bf2Smrg major=".$current" 7489983b4bf2Smrg versuffix=".$current.$revision" 749090b17f1bSmrg ;; 749190b17f1bSmrg 749290b17f1bSmrg windows) 749390b17f1bSmrg # Use '-' rather than '.', since we only want one 7494983b4bf2Smrg # extension on DOS 8.3 filesystems. 749590b17f1bSmrg func_arith $current - $age 749690b17f1bSmrg major=$func_arith_result 7497983b4bf2Smrg versuffix="-$major" 749890b17f1bSmrg ;; 749990b17f1bSmrg 750090b17f1bSmrg *) 7501983b4bf2Smrg func_fatal_configuration "unknown library version type \`$version_type'" 750290b17f1bSmrg ;; 750390b17f1bSmrg esac 750490b17f1bSmrg 750590b17f1bSmrg # Clear the version info if we defaulted, and they specified a release. 750690b17f1bSmrg if test -z "$vinfo" && test -n "$release"; then 750790b17f1bSmrg major= 750890b17f1bSmrg case $version_type in 750990b17f1bSmrg darwin) 751090b17f1bSmrg # we can't check for "0.0" in archive_cmds due to quoting 751190b17f1bSmrg # problems, so we reset it completely 751290b17f1bSmrg verstring= 751390b17f1bSmrg ;; 751490b17f1bSmrg *) 7515983b4bf2Smrg verstring="0.0" 751690b17f1bSmrg ;; 751790b17f1bSmrg esac 7518983b4bf2Smrg if test "$need_version" = no; then 751990b17f1bSmrg versuffix= 752090b17f1bSmrg else 7521983b4bf2Smrg versuffix=".0.0" 752290b17f1bSmrg fi 752390b17f1bSmrg fi 752490b17f1bSmrg 752590b17f1bSmrg # Remove version info from name if versioning should be avoided 7526983b4bf2Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 752790b17f1bSmrg major= 752890b17f1bSmrg versuffix= 7529983b4bf2Smrg verstring="" 753090b17f1bSmrg fi 753190b17f1bSmrg 753290b17f1bSmrg # Check to see if the archive will have undefined symbols. 7533983b4bf2Smrg if test "$allow_undefined" = yes; then 7534983b4bf2Smrg if test "$allow_undefined_flag" = unsupported; then 7535983b4bf2Smrg func_warning "undefined symbols not allowed in $host shared libraries" 7536983b4bf2Smrg build_libtool_libs=no 7537983b4bf2Smrg build_old_libs=yes 753890b17f1bSmrg fi 753990b17f1bSmrg else 754090b17f1bSmrg # Don't allow undefined symbols. 7541983b4bf2Smrg allow_undefined_flag="$no_undefined_flag" 754290b17f1bSmrg fi 754390b17f1bSmrg 754490b17f1bSmrg fi 754590b17f1bSmrg 7546983b4bf2Smrg func_generate_dlsyms "$libname" "$libname" "yes" 754790b17f1bSmrg func_append libobjs " $symfileobj" 7548983b4bf2Smrg test "X$libobjs" = "X " && libobjs= 754990b17f1bSmrg 7550983b4bf2Smrg if test "$opt_mode" != relink; then 755190b17f1bSmrg # Remove our outputs, but don't remove object files since they 755290b17f1bSmrg # may have been created when compiling PIC objects. 755390b17f1bSmrg removelist= 755490b17f1bSmrg tempremovelist=`$ECHO "$output_objdir/*"` 755590b17f1bSmrg for p in $tempremovelist; do 755690b17f1bSmrg case $p in 755790b17f1bSmrg *.$objext | *.gcno) 755890b17f1bSmrg ;; 7559983b4bf2Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 7560983b4bf2Smrg if test "X$precious_files_regex" != "X"; then 756190b17f1bSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 756290b17f1bSmrg then 756390b17f1bSmrg continue 756490b17f1bSmrg fi 756590b17f1bSmrg fi 756690b17f1bSmrg func_append removelist " $p" 756790b17f1bSmrg ;; 756890b17f1bSmrg *) ;; 756990b17f1bSmrg esac 757090b17f1bSmrg done 757190b17f1bSmrg test -n "$removelist" && \ 757290b17f1bSmrg func_show_eval "${RM}r \$removelist" 757390b17f1bSmrg fi 757490b17f1bSmrg 757590b17f1bSmrg # Now set the variables for building old libraries. 7576983b4bf2Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 757790b17f1bSmrg func_append oldlibs " $output_objdir/$libname.$libext" 757890b17f1bSmrg 757990b17f1bSmrg # Transform .lo files to .o files. 7580983b4bf2Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 758190b17f1bSmrg fi 758290b17f1bSmrg 758390b17f1bSmrg # Eliminate all temporary directories. 758490b17f1bSmrg #for path in $notinst_path; do 758590b17f1bSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 758690b17f1bSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 758790b17f1bSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 758890b17f1bSmrg #done 758990b17f1bSmrg 759090b17f1bSmrg if test -n "$xrpath"; then 759190b17f1bSmrg # If the user specified any rpath flags, then add them. 759290b17f1bSmrg temp_xrpath= 759390b17f1bSmrg for libdir in $xrpath; do 759490b17f1bSmrg func_replace_sysroot "$libdir" 759590b17f1bSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 759690b17f1bSmrg case "$finalize_rpath " in 759790b17f1bSmrg *" $libdir "*) ;; 759890b17f1bSmrg *) func_append finalize_rpath " $libdir" ;; 759990b17f1bSmrg esac 760090b17f1bSmrg done 7601983b4bf2Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 760290b17f1bSmrg dependency_libs="$temp_xrpath $dependency_libs" 760390b17f1bSmrg fi 760490b17f1bSmrg fi 760590b17f1bSmrg 760690b17f1bSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 7607983b4bf2Smrg old_dlfiles="$dlfiles" 760890b17f1bSmrg dlfiles= 760990b17f1bSmrg for lib in $old_dlfiles; do 761090b17f1bSmrg case " $dlprefiles $dlfiles " in 761190b17f1bSmrg *" $lib "*) ;; 761290b17f1bSmrg *) func_append dlfiles " $lib" ;; 761390b17f1bSmrg esac 761490b17f1bSmrg done 761590b17f1bSmrg 761690b17f1bSmrg # Make sure dlprefiles contains only unique files 7617983b4bf2Smrg old_dlprefiles="$dlprefiles" 761890b17f1bSmrg dlprefiles= 761990b17f1bSmrg for lib in $old_dlprefiles; do 762090b17f1bSmrg case "$dlprefiles " in 762190b17f1bSmrg *" $lib "*) ;; 762290b17f1bSmrg *) func_append dlprefiles " $lib" ;; 762390b17f1bSmrg esac 762490b17f1bSmrg done 762590b17f1bSmrg 7626983b4bf2Smrg if test "$build_libtool_libs" = yes; then 762790b17f1bSmrg if test -n "$rpath"; then 762890b17f1bSmrg case $host in 762990b17f1bSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 763090b17f1bSmrg # these systems don't actually have a c library (as such)! 763190b17f1bSmrg ;; 763290b17f1bSmrg *-*-rhapsody* | *-*-darwin1.[012]) 763390b17f1bSmrg # Rhapsody C library is in the System framework 763490b17f1bSmrg func_append deplibs " System.ltframework" 763590b17f1bSmrg ;; 763690b17f1bSmrg *-*-netbsd*) 763790b17f1bSmrg # Don't link with libc until the a.out ld.so is fixed. 763890b17f1bSmrg ;; 763990b17f1bSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 764090b17f1bSmrg # Do not include libc due to us having libc/libc_r. 764190b17f1bSmrg ;; 764290b17f1bSmrg *-*-sco3.2v5* | *-*-sco5v6*) 764390b17f1bSmrg # Causes problems with __ctype 764490b17f1bSmrg ;; 764590b17f1bSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 764690b17f1bSmrg # Compiler inserts libc in the correct place for threads to work 764790b17f1bSmrg ;; 764890b17f1bSmrg *) 764990b17f1bSmrg # Add libc to deplibs on all other systems if necessary. 7650983b4bf2Smrg if test "$build_libtool_need_lc" = "yes"; then 765190b17f1bSmrg func_append deplibs " -lc" 765290b17f1bSmrg fi 765390b17f1bSmrg ;; 765490b17f1bSmrg esac 765590b17f1bSmrg fi 765690b17f1bSmrg 765790b17f1bSmrg # Transform deplibs into only deplibs that can be linked in shared. 765890b17f1bSmrg name_save=$name 765990b17f1bSmrg libname_save=$libname 766090b17f1bSmrg release_save=$release 766190b17f1bSmrg versuffix_save=$versuffix 766290b17f1bSmrg major_save=$major 766390b17f1bSmrg # I'm not sure if I'm treating the release correctly. I think 766490b17f1bSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 766590b17f1bSmrg # add it in twice. Is that correct? 7666983b4bf2Smrg release="" 7667983b4bf2Smrg versuffix="" 7668983b4bf2Smrg major="" 766990b17f1bSmrg newdeplibs= 767090b17f1bSmrg droppeddeps=no 767190b17f1bSmrg case $deplibs_check_method in 767290b17f1bSmrg pass_all) 767390b17f1bSmrg # Don't check for shared/static. Everything works. 767490b17f1bSmrg # This might be a little naive. We might want to check 767590b17f1bSmrg # whether the library exists or not. But this is on 767690b17f1bSmrg # osf3 & osf4 and I'm not really sure... Just 767790b17f1bSmrg # implementing what was already the behavior. 767890b17f1bSmrg newdeplibs=$deplibs 767990b17f1bSmrg ;; 768090b17f1bSmrg test_compile) 768190b17f1bSmrg # This code stresses the "libraries are programs" paradigm to its 768290b17f1bSmrg # limits. Maybe even breaks it. We compile a program, linking it 768390b17f1bSmrg # against the deplibs as a proxy for the library. Then we can check 768490b17f1bSmrg # whether they linked in statically or dynamically with ldd. 768590b17f1bSmrg $opt_dry_run || $RM conftest.c 768690b17f1bSmrg cat > conftest.c <<EOF 768790b17f1bSmrg int main() { return 0; } 768890b17f1bSmrgEOF 768990b17f1bSmrg $opt_dry_run || $RM conftest 769090b17f1bSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 769190b17f1bSmrg ldd_output=`ldd conftest` 769290b17f1bSmrg for i in $deplibs; do 769390b17f1bSmrg case $i in 769490b17f1bSmrg -l*) 769590b17f1bSmrg func_stripname -l '' "$i" 769690b17f1bSmrg name=$func_stripname_result 7697983b4bf2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 769890b17f1bSmrg case " $predeps $postdeps " in 769990b17f1bSmrg *" $i "*) 770090b17f1bSmrg func_append newdeplibs " $i" 7701983b4bf2Smrg i="" 770290b17f1bSmrg ;; 770390b17f1bSmrg esac 770490b17f1bSmrg fi 7705983b4bf2Smrg if test -n "$i" ; then 770690b17f1bSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 770790b17f1bSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 770890b17f1bSmrg set dummy $deplib_matches; shift 770990b17f1bSmrg deplib_match=$1 7710983b4bf2Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 771190b17f1bSmrg func_append newdeplibs " $i" 771290b17f1bSmrg else 771390b17f1bSmrg droppeddeps=yes 771490b17f1bSmrg echo 771590b17f1bSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 771690b17f1bSmrg echo "*** I have the capability to make that library automatically link in when" 771790b17f1bSmrg echo "*** you link to this library. But I can only do this if you have a" 771890b17f1bSmrg echo "*** shared version of the library, which I believe you do not have" 771990b17f1bSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 772090b17f1bSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 772190b17f1bSmrg fi 772290b17f1bSmrg fi 772390b17f1bSmrg ;; 772490b17f1bSmrg *) 772590b17f1bSmrg func_append newdeplibs " $i" 772690b17f1bSmrg ;; 772790b17f1bSmrg esac 772890b17f1bSmrg done 772990b17f1bSmrg else 773090b17f1bSmrg # Error occurred in the first compile. Let's try to salvage 773190b17f1bSmrg # the situation: Compile a separate program for each library. 773290b17f1bSmrg for i in $deplibs; do 773390b17f1bSmrg case $i in 773490b17f1bSmrg -l*) 773590b17f1bSmrg func_stripname -l '' "$i" 773690b17f1bSmrg name=$func_stripname_result 773790b17f1bSmrg $opt_dry_run || $RM conftest 773890b17f1bSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 773990b17f1bSmrg ldd_output=`ldd conftest` 7740983b4bf2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 774190b17f1bSmrg case " $predeps $postdeps " in 774290b17f1bSmrg *" $i "*) 774390b17f1bSmrg func_append newdeplibs " $i" 7744983b4bf2Smrg i="" 774590b17f1bSmrg ;; 774690b17f1bSmrg esac 774790b17f1bSmrg fi 7748983b4bf2Smrg if test -n "$i" ; then 774990b17f1bSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 775090b17f1bSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 775190b17f1bSmrg set dummy $deplib_matches; shift 775290b17f1bSmrg deplib_match=$1 7753983b4bf2Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 775490b17f1bSmrg func_append newdeplibs " $i" 775590b17f1bSmrg else 775690b17f1bSmrg droppeddeps=yes 775790b17f1bSmrg echo 775890b17f1bSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 775990b17f1bSmrg echo "*** I have the capability to make that library automatically link in when" 776090b17f1bSmrg echo "*** you link to this library. But I can only do this if you have a" 776190b17f1bSmrg echo "*** shared version of the library, which you do not appear to have" 776290b17f1bSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 776390b17f1bSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 776490b17f1bSmrg fi 776590b17f1bSmrg fi 776690b17f1bSmrg else 776790b17f1bSmrg droppeddeps=yes 776890b17f1bSmrg echo 776990b17f1bSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 777090b17f1bSmrg echo "*** make it link in! You will probably need to install it or some" 777190b17f1bSmrg echo "*** library that it depends on before this library will be fully" 777290b17f1bSmrg echo "*** functional. Installing it before continuing would be even better." 777390b17f1bSmrg fi 777490b17f1bSmrg ;; 777590b17f1bSmrg *) 777690b17f1bSmrg func_append newdeplibs " $i" 777790b17f1bSmrg ;; 777890b17f1bSmrg esac 777990b17f1bSmrg done 778090b17f1bSmrg fi 778190b17f1bSmrg ;; 778290b17f1bSmrg file_magic*) 778390b17f1bSmrg set dummy $deplibs_check_method; shift 778490b17f1bSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 778590b17f1bSmrg for a_deplib in $deplibs; do 778690b17f1bSmrg case $a_deplib in 778790b17f1bSmrg -l*) 778890b17f1bSmrg func_stripname -l '' "$a_deplib" 778990b17f1bSmrg name=$func_stripname_result 7790983b4bf2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 779190b17f1bSmrg case " $predeps $postdeps " in 779290b17f1bSmrg *" $a_deplib "*) 779390b17f1bSmrg func_append newdeplibs " $a_deplib" 7794983b4bf2Smrg a_deplib="" 779590b17f1bSmrg ;; 779690b17f1bSmrg esac 779790b17f1bSmrg fi 7798983b4bf2Smrg if test -n "$a_deplib" ; then 779990b17f1bSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 780090b17f1bSmrg if test -n "$file_magic_glob"; then 780190b17f1bSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 780290b17f1bSmrg else 780390b17f1bSmrg libnameglob=$libname 780490b17f1bSmrg fi 7805983b4bf2Smrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 780690b17f1bSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7807983b4bf2Smrg if test "$want_nocaseglob" = yes; then 780890b17f1bSmrg shopt -s nocaseglob 780990b17f1bSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 781090b17f1bSmrg $nocaseglob 781190b17f1bSmrg else 781290b17f1bSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 781390b17f1bSmrg fi 781490b17f1bSmrg for potent_lib in $potential_libs; do 781590b17f1bSmrg # Follow soft links. 781690b17f1bSmrg if ls -lLd "$potent_lib" 2>/dev/null | 781790b17f1bSmrg $GREP " -> " >/dev/null; then 781890b17f1bSmrg continue 781990b17f1bSmrg fi 782090b17f1bSmrg # The statement above tries to avoid entering an 782190b17f1bSmrg # endless loop below, in case of cyclic links. 782290b17f1bSmrg # We might still enter an endless loop, since a link 782390b17f1bSmrg # loop can be closed while we follow links, 782490b17f1bSmrg # but so what? 7825983b4bf2Smrg potlib="$potent_lib" 782690b17f1bSmrg while test -h "$potlib" 2>/dev/null; do 7827983b4bf2Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 782890b17f1bSmrg case $potliblink in 7829983b4bf2Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 7830983b4bf2Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 783190b17f1bSmrg esac 783290b17f1bSmrg done 783390b17f1bSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 783490b17f1bSmrg $SED -e 10q | 783590b17f1bSmrg $EGREP "$file_magic_regex" > /dev/null; then 783690b17f1bSmrg func_append newdeplibs " $a_deplib" 7837983b4bf2Smrg a_deplib="" 783890b17f1bSmrg break 2 783990b17f1bSmrg fi 784090b17f1bSmrg done 784190b17f1bSmrg done 784290b17f1bSmrg fi 7843983b4bf2Smrg if test -n "$a_deplib" ; then 784490b17f1bSmrg droppeddeps=yes 784590b17f1bSmrg echo 784690b17f1bSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 784790b17f1bSmrg echo "*** I have the capability to make that library automatically link in when" 784890b17f1bSmrg echo "*** you link to this library. But I can only do this if you have a" 784990b17f1bSmrg echo "*** shared version of the library, which you do not appear to have" 785090b17f1bSmrg echo "*** because I did check the linker path looking for a file starting" 7851983b4bf2Smrg if test -z "$potlib" ; then 785290b17f1bSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 785390b17f1bSmrg else 785490b17f1bSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 785590b17f1bSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 785690b17f1bSmrg fi 785790b17f1bSmrg fi 785890b17f1bSmrg ;; 785990b17f1bSmrg *) 786090b17f1bSmrg # Add a -L argument. 786190b17f1bSmrg func_append newdeplibs " $a_deplib" 786290b17f1bSmrg ;; 786390b17f1bSmrg esac 786490b17f1bSmrg done # Gone through all deplibs. 786590b17f1bSmrg ;; 786690b17f1bSmrg match_pattern*) 786790b17f1bSmrg set dummy $deplibs_check_method; shift 786890b17f1bSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 786990b17f1bSmrg for a_deplib in $deplibs; do 787090b17f1bSmrg case $a_deplib in 787190b17f1bSmrg -l*) 787290b17f1bSmrg func_stripname -l '' "$a_deplib" 787390b17f1bSmrg name=$func_stripname_result 7874983b4bf2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 787590b17f1bSmrg case " $predeps $postdeps " in 787690b17f1bSmrg *" $a_deplib "*) 787790b17f1bSmrg func_append newdeplibs " $a_deplib" 7878983b4bf2Smrg a_deplib="" 787990b17f1bSmrg ;; 788090b17f1bSmrg esac 788190b17f1bSmrg fi 7882983b4bf2Smrg if test -n "$a_deplib" ; then 788390b17f1bSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 788490b17f1bSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 788590b17f1bSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 788690b17f1bSmrg for potent_lib in $potential_libs; do 7887983b4bf2Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 788890b17f1bSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 788990b17f1bSmrg $EGREP "$match_pattern_regex" > /dev/null; then 789090b17f1bSmrg func_append newdeplibs " $a_deplib" 7891983b4bf2Smrg a_deplib="" 789290b17f1bSmrg break 2 789390b17f1bSmrg fi 789490b17f1bSmrg done 789590b17f1bSmrg done 789690b17f1bSmrg fi 7897983b4bf2Smrg if test -n "$a_deplib" ; then 789890b17f1bSmrg droppeddeps=yes 789990b17f1bSmrg echo 790090b17f1bSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 790190b17f1bSmrg echo "*** I have the capability to make that library automatically link in when" 790290b17f1bSmrg echo "*** you link to this library. But I can only do this if you have a" 790390b17f1bSmrg echo "*** shared version of the library, which you do not appear to have" 790490b17f1bSmrg echo "*** because I did check the linker path looking for a file starting" 7905983b4bf2Smrg if test -z "$potlib" ; then 790690b17f1bSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 790790b17f1bSmrg else 790890b17f1bSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 790990b17f1bSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 791090b17f1bSmrg fi 791190b17f1bSmrg fi 791290b17f1bSmrg ;; 791390b17f1bSmrg *) 791490b17f1bSmrg # Add a -L argument. 791590b17f1bSmrg func_append newdeplibs " $a_deplib" 791690b17f1bSmrg ;; 791790b17f1bSmrg esac 791890b17f1bSmrg done # Gone through all deplibs. 791990b17f1bSmrg ;; 792090b17f1bSmrg none | unknown | *) 7921983b4bf2Smrg newdeplibs="" 792290b17f1bSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7923983b4bf2Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7924983b4bf2Smrg for i in $predeps $postdeps ; do 792590b17f1bSmrg # can't use Xsed below, because $i might contain '/' 7926983b4bf2Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 792790b17f1bSmrg done 792890b17f1bSmrg fi 792990b17f1bSmrg case $tmp_deplibs in 793090b17f1bSmrg *[!\ \ ]*) 793190b17f1bSmrg echo 7932983b4bf2Smrg if test "X$deplibs_check_method" = "Xnone"; then 793390b17f1bSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 793490b17f1bSmrg else 793590b17f1bSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 793690b17f1bSmrg fi 793790b17f1bSmrg echo "*** All declared inter-library dependencies are being dropped." 793890b17f1bSmrg droppeddeps=yes 793990b17f1bSmrg ;; 794090b17f1bSmrg esac 794190b17f1bSmrg ;; 794290b17f1bSmrg esac 794390b17f1bSmrg versuffix=$versuffix_save 794490b17f1bSmrg major=$major_save 794590b17f1bSmrg release=$release_save 794690b17f1bSmrg libname=$libname_save 794790b17f1bSmrg name=$name_save 79487e6fb56fSmrg 794990b17f1bSmrg case $host in 795090b17f1bSmrg *-*-rhapsody* | *-*-darwin1.[012]) 795190b17f1bSmrg # On Rhapsody replace the C library with the System framework 795290b17f1bSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 795390b17f1bSmrg ;; 795490b17f1bSmrg esac 79557e6fb56fSmrg 7956983b4bf2Smrg if test "$droppeddeps" = yes; then 7957983b4bf2Smrg if test "$module" = yes; then 795890b17f1bSmrg echo 795990b17f1bSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 796090b17f1bSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 796190b17f1bSmrg echo "*** a static module, that should work as long as the dlopening" 796290b17f1bSmrg echo "*** application is linked with the -dlopen flag." 796390b17f1bSmrg if test -z "$global_symbol_pipe"; then 796490b17f1bSmrg echo 796590b17f1bSmrg echo "*** However, this would only work if libtool was able to extract symbol" 7966983b4bf2Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 796790b17f1bSmrg echo "*** not find such a program. So, this module is probably useless." 7968983b4bf2Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 796990b17f1bSmrg fi 7970983b4bf2Smrg if test "$build_old_libs" = no; then 7971983b4bf2Smrg oldlibs="$output_objdir/$libname.$libext" 797290b17f1bSmrg build_libtool_libs=module 797390b17f1bSmrg build_old_libs=yes 797490b17f1bSmrg else 797590b17f1bSmrg build_libtool_libs=no 797690b17f1bSmrg fi 797790b17f1bSmrg else 797890b17f1bSmrg echo "*** The inter-library dependencies that have been dropped here will be" 797990b17f1bSmrg echo "*** automatically added whenever a program is linked with this library" 798090b17f1bSmrg echo "*** or is declared to -dlopen it." 79817e6fb56fSmrg 7982983b4bf2Smrg if test "$allow_undefined" = no; then 798390b17f1bSmrg echo 798490b17f1bSmrg echo "*** Since this library must not contain undefined symbols," 798590b17f1bSmrg echo "*** because either the platform does not support them or" 798690b17f1bSmrg echo "*** it was explicitly requested with -no-undefined," 798790b17f1bSmrg echo "*** libtool will only create a static version of it." 7988983b4bf2Smrg if test "$build_old_libs" = no; then 7989983b4bf2Smrg oldlibs="$output_objdir/$libname.$libext" 799090b17f1bSmrg build_libtool_libs=module 799190b17f1bSmrg build_old_libs=yes 799290b17f1bSmrg else 799390b17f1bSmrg build_libtool_libs=no 799490b17f1bSmrg fi 799590b17f1bSmrg fi 799690b17f1bSmrg fi 79977e6fb56fSmrg fi 799890b17f1bSmrg # Done checking deplibs! 799990b17f1bSmrg deplibs=$newdeplibs 800090b17f1bSmrg fi 800190b17f1bSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 800290b17f1bSmrg case $host in 800390b17f1bSmrg *-*-darwin*) 800490b17f1bSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 800590b17f1bSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 800690b17f1bSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 800790b17f1bSmrg ;; 800890b17f1bSmrg esac 80097e6fb56fSmrg 801090b17f1bSmrg # move library search paths that coincide with paths to not yet 801190b17f1bSmrg # installed libraries to the beginning of the library search list 801290b17f1bSmrg new_libs= 801390b17f1bSmrg for path in $notinst_path; do 801490b17f1bSmrg case " $new_libs " in 801590b17f1bSmrg *" -L$path/$objdir "*) ;; 801690b17f1bSmrg *) 801790b17f1bSmrg case " $deplibs " in 801890b17f1bSmrg *" -L$path/$objdir "*) 801990b17f1bSmrg func_append new_libs " -L$path/$objdir" ;; 802090b17f1bSmrg esac 802190b17f1bSmrg ;; 802290b17f1bSmrg esac 802390b17f1bSmrg done 802490b17f1bSmrg for deplib in $deplibs; do 802590b17f1bSmrg case $deplib in 802690b17f1bSmrg -L*) 802790b17f1bSmrg case " $new_libs " in 802890b17f1bSmrg *" $deplib "*) ;; 802990b17f1bSmrg *) func_append new_libs " $deplib" ;; 803090b17f1bSmrg esac 803190b17f1bSmrg ;; 803290b17f1bSmrg *) func_append new_libs " $deplib" ;; 803390b17f1bSmrg esac 803490b17f1bSmrg done 8035983b4bf2Smrg deplibs="$new_libs" 80367e6fb56fSmrg 803790b17f1bSmrg # All the library-specific variables (install_libdir is set above). 803890b17f1bSmrg library_names= 803990b17f1bSmrg old_library= 804090b17f1bSmrg dlname= 80417e6fb56fSmrg 804290b17f1bSmrg # Test again, we may have decided not to build it any more 8043983b4bf2Smrg if test "$build_libtool_libs" = yes; then 8044983b4bf2Smrg # Remove ${wl} instances when linking with ld. 804590b17f1bSmrg # FIXME: should test the right _cmds variable. 804690b17f1bSmrg case $archive_cmds in 804790b17f1bSmrg *\$LD\ *) wl= ;; 804890b17f1bSmrg esac 8049983b4bf2Smrg if test "$hardcode_into_libs" = yes; then 805090b17f1bSmrg # Hardcode the library paths 805190b17f1bSmrg hardcode_libdirs= 805290b17f1bSmrg dep_rpath= 8053983b4bf2Smrg rpath="$finalize_rpath" 8054983b4bf2Smrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 805590b17f1bSmrg for libdir in $rpath; do 805690b17f1bSmrg if test -n "$hardcode_libdir_flag_spec"; then 805790b17f1bSmrg if test -n "$hardcode_libdir_separator"; then 805890b17f1bSmrg func_replace_sysroot "$libdir" 805990b17f1bSmrg libdir=$func_replace_sysroot_result 806090b17f1bSmrg if test -z "$hardcode_libdirs"; then 8061983b4bf2Smrg hardcode_libdirs="$libdir" 806290b17f1bSmrg else 806390b17f1bSmrg # Just accumulate the unique libdirs. 806490b17f1bSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 806590b17f1bSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 806690b17f1bSmrg ;; 806790b17f1bSmrg *) 806890b17f1bSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 806990b17f1bSmrg ;; 807090b17f1bSmrg esac 807190b17f1bSmrg fi 807290b17f1bSmrg else 807390b17f1bSmrg eval flag=\"$hardcode_libdir_flag_spec\" 807490b17f1bSmrg func_append dep_rpath " $flag" 807590b17f1bSmrg fi 807690b17f1bSmrg elif test -n "$runpath_var"; then 807790b17f1bSmrg case "$perm_rpath " in 807890b17f1bSmrg *" $libdir "*) ;; 807990b17f1bSmrg *) func_append perm_rpath " $libdir" ;; 808090b17f1bSmrg esac 808190b17f1bSmrg fi 808290b17f1bSmrg done 808390b17f1bSmrg # Substitute the hardcoded libdirs into the rpath. 808490b17f1bSmrg if test -n "$hardcode_libdir_separator" && 808590b17f1bSmrg test -n "$hardcode_libdirs"; then 8086983b4bf2Smrg libdir="$hardcode_libdirs" 808790b17f1bSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 808890b17f1bSmrg fi 808990b17f1bSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 809090b17f1bSmrg # We should set the runpath_var. 809190b17f1bSmrg rpath= 809290b17f1bSmrg for dir in $perm_rpath; do 809390b17f1bSmrg func_append rpath "$dir:" 809490b17f1bSmrg done 809590b17f1bSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 809690b17f1bSmrg fi 809790b17f1bSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 80987e6fb56fSmrg fi 80997e6fb56fSmrg 8100983b4bf2Smrg shlibpath="$finalize_shlibpath" 8101983b4bf2Smrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 810290b17f1bSmrg if test -n "$shlibpath"; then 810390b17f1bSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 81047e6fb56fSmrg fi 81057e6fb56fSmrg 810690b17f1bSmrg # Get the real and link names of the library. 810790b17f1bSmrg eval shared_ext=\"$shrext_cmds\" 810890b17f1bSmrg eval library_names=\"$library_names_spec\" 810990b17f1bSmrg set dummy $library_names 811090b17f1bSmrg shift 8111983b4bf2Smrg realname="$1" 811290b17f1bSmrg shift 81137e6fb56fSmrg 811490b17f1bSmrg if test -n "$soname_spec"; then 811590b17f1bSmrg eval soname=\"$soname_spec\" 81167e6fb56fSmrg else 8117983b4bf2Smrg soname="$realname" 811890b17f1bSmrg fi 811990b17f1bSmrg if test -z "$dlname"; then 812090b17f1bSmrg dlname=$soname 81217e6fb56fSmrg fi 81227e6fb56fSmrg 8123983b4bf2Smrg lib="$output_objdir/$realname" 812490b17f1bSmrg linknames= 812590b17f1bSmrg for link 812690b17f1bSmrg do 812790b17f1bSmrg func_append linknames " $link" 812890b17f1bSmrg done 81297e6fb56fSmrg 813090b17f1bSmrg # Use standard objects if they are pic 813190b17f1bSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 813290b17f1bSmrg test "X$libobjs" = "X " && libobjs= 81337e6fb56fSmrg 813490b17f1bSmrg delfiles= 813590b17f1bSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 813690b17f1bSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 8137983b4bf2Smrg export_symbols="$output_objdir/$libname.uexp" 813890b17f1bSmrg func_append delfiles " $export_symbols" 813990b17f1bSmrg fi 81407e6fb56fSmrg 814190b17f1bSmrg orig_export_symbols= 814290b17f1bSmrg case $host_os in 814390b17f1bSmrg cygwin* | mingw* | cegcc*) 814490b17f1bSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 814590b17f1bSmrg # exporting using user supplied symfile 8146983b4bf2Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 814790b17f1bSmrg # and it's NOT already a .def file. Must figure out 814890b17f1bSmrg # which of the given symbols are data symbols and tag 814990b17f1bSmrg # them as such. So, trigger use of export_symbols_cmds. 815090b17f1bSmrg # export_symbols gets reassigned inside the "prepare 815190b17f1bSmrg # the list of exported symbols" if statement, so the 815290b17f1bSmrg # include_expsyms logic still works. 8153983b4bf2Smrg orig_export_symbols="$export_symbols" 815490b17f1bSmrg export_symbols= 815590b17f1bSmrg always_export_symbols=yes 8156983b4bf2Smrg fi 81577e6fb56fSmrg fi 815890b17f1bSmrg ;; 815990b17f1bSmrg esac 81607e6fb56fSmrg 816190b17f1bSmrg # Prepare the list of exported symbols 816290b17f1bSmrg if test -z "$export_symbols"; then 8163983b4bf2Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 8164983b4bf2Smrg func_verbose "generating symbol list for \`$libname.la'" 8165983b4bf2Smrg export_symbols="$output_objdir/$libname.exp" 816690b17f1bSmrg $opt_dry_run || $RM $export_symbols 816790b17f1bSmrg cmds=$export_symbols_cmds 8168983b4bf2Smrg save_ifs="$IFS"; IFS='~' 816990b17f1bSmrg for cmd1 in $cmds; do 8170983b4bf2Smrg IFS="$save_ifs" 817190b17f1bSmrg # Take the normal branch if the nm_file_list_spec branch 817290b17f1bSmrg # doesn't work or if tool conversion is not needed. 817390b17f1bSmrg case $nm_file_list_spec~$to_tool_file_cmd in 817490b17f1bSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 817590b17f1bSmrg try_normal_branch=yes 817690b17f1bSmrg eval cmd=\"$cmd1\" 817790b17f1bSmrg func_len " $cmd" 817890b17f1bSmrg len=$func_len_result 817990b17f1bSmrg ;; 818090b17f1bSmrg *) 818190b17f1bSmrg try_normal_branch=no 818290b17f1bSmrg ;; 818390b17f1bSmrg esac 8184983b4bf2Smrg if test "$try_normal_branch" = yes \ 818590b17f1bSmrg && { test "$len" -lt "$max_cmd_len" \ 818690b17f1bSmrg || test "$max_cmd_len" -le -1; } 818790b17f1bSmrg then 818890b17f1bSmrg func_show_eval "$cmd" 'exit $?' 818990b17f1bSmrg skipped_export=false 819090b17f1bSmrg elif test -n "$nm_file_list_spec"; then 819190b17f1bSmrg func_basename "$output" 819290b17f1bSmrg output_la=$func_basename_result 819390b17f1bSmrg save_libobjs=$libobjs 819490b17f1bSmrg save_output=$output 8195983b4bf2Smrg output=${output_objdir}/${output_la}.nm 819690b17f1bSmrg func_to_tool_file "$output" 819790b17f1bSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 819890b17f1bSmrg func_append delfiles " $output" 819990b17f1bSmrg func_verbose "creating $NM input file list: $output" 820090b17f1bSmrg for obj in $save_libobjs; do 820190b17f1bSmrg func_to_tool_file "$obj" 820290b17f1bSmrg $ECHO "$func_to_tool_file_result" 820390b17f1bSmrg done > "$output" 820490b17f1bSmrg eval cmd=\"$cmd1\" 820590b17f1bSmrg func_show_eval "$cmd" 'exit $?' 820690b17f1bSmrg output=$save_output 820790b17f1bSmrg libobjs=$save_libobjs 820890b17f1bSmrg skipped_export=false 820990b17f1bSmrg else 821090b17f1bSmrg # The command line is too long to execute in one step. 821190b17f1bSmrg func_verbose "using reloadable object file for export list..." 821290b17f1bSmrg skipped_export=: 821390b17f1bSmrg # Break out early, otherwise skipped_export may be 821490b17f1bSmrg # set to false by a later but shorter cmd. 821590b17f1bSmrg break 821690b17f1bSmrg fi 821790b17f1bSmrg done 8218983b4bf2Smrg IFS="$save_ifs" 8219983b4bf2Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 822090b17f1bSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 822190b17f1bSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 822290b17f1bSmrg fi 822390b17f1bSmrg fi 822490b17f1bSmrg fi 822590b17f1bSmrg 822690b17f1bSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8227983b4bf2Smrg tmp_export_symbols="$export_symbols" 8228983b4bf2Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 822990b17f1bSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 82307e6fb56fSmrg fi 82317e6fb56fSmrg 8232983b4bf2Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 823390b17f1bSmrg # The given exports_symbols file has to be filtered, so filter it. 8234983b4bf2Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 823590b17f1bSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8236983b4bf2Smrg # 's' commands which not all seds can handle. GNU sed should be fine 823790b17f1bSmrg # though. Also, the filter scales superlinearly with the number of 823890b17f1bSmrg # global variables. join(1) would be nice here, but unfortunately 823990b17f1bSmrg # isn't a blessed tool. 824090b17f1bSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 824190b17f1bSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 824290b17f1bSmrg export_symbols=$output_objdir/$libname.def 824390b17f1bSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 824490b17f1bSmrg fi 82457e6fb56fSmrg 824690b17f1bSmrg tmp_deplibs= 824790b17f1bSmrg for test_deplib in $deplibs; do 824890b17f1bSmrg case " $convenience " in 824990b17f1bSmrg *" $test_deplib "*) ;; 825090b17f1bSmrg *) 825190b17f1bSmrg func_append tmp_deplibs " $test_deplib" 825290b17f1bSmrg ;; 825390b17f1bSmrg esac 825490b17f1bSmrg done 8255983b4bf2Smrg deplibs="$tmp_deplibs" 82567e6fb56fSmrg 825790b17f1bSmrg if test -n "$convenience"; then 825890b17f1bSmrg if test -n "$whole_archive_flag_spec" && 8259983b4bf2Smrg test "$compiler_needs_object" = yes && 826090b17f1bSmrg test -z "$libobjs"; then 826190b17f1bSmrg # extract the archives, so we have objects to list. 826290b17f1bSmrg # TODO: could optimize this to just extract one archive. 826390b17f1bSmrg whole_archive_flag_spec= 826490b17f1bSmrg fi 826590b17f1bSmrg if test -n "$whole_archive_flag_spec"; then 826690b17f1bSmrg save_libobjs=$libobjs 826790b17f1bSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 826890b17f1bSmrg test "X$libobjs" = "X " && libobjs= 82697e6fb56fSmrg else 8270983b4bf2Smrg gentop="$output_objdir/${outputname}x" 827190b17f1bSmrg func_append generated " $gentop" 827290b17f1bSmrg 827390b17f1bSmrg func_extract_archives $gentop $convenience 827490b17f1bSmrg func_append libobjs " $func_extract_archives_result" 827590b17f1bSmrg test "X$libobjs" = "X " && libobjs= 82767e6fb56fSmrg fi 82777e6fb56fSmrg fi 82787e6fb56fSmrg 8279983b4bf2Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 828090b17f1bSmrg eval flag=\"$thread_safe_flag_spec\" 828190b17f1bSmrg func_append linker_flags " $flag" 828290b17f1bSmrg fi 82837e6fb56fSmrg 828490b17f1bSmrg # Make a backup of the uninstalled library when relinking 8285983b4bf2Smrg if test "$opt_mode" = relink; then 828690b17f1bSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 828790b17f1bSmrg fi 82887e6fb56fSmrg 828990b17f1bSmrg # Do each of the archive commands. 8290983b4bf2Smrg if test "$module" = yes && test -n "$module_cmds" ; then 829190b17f1bSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 829290b17f1bSmrg eval test_cmds=\"$module_expsym_cmds\" 829390b17f1bSmrg cmds=$module_expsym_cmds 829490b17f1bSmrg else 829590b17f1bSmrg eval test_cmds=\"$module_cmds\" 829690b17f1bSmrg cmds=$module_cmds 829790b17f1bSmrg fi 82987e6fb56fSmrg else 829990b17f1bSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 830090b17f1bSmrg eval test_cmds=\"$archive_expsym_cmds\" 830190b17f1bSmrg cmds=$archive_expsym_cmds 830290b17f1bSmrg else 830390b17f1bSmrg eval test_cmds=\"$archive_cmds\" 830490b17f1bSmrg cmds=$archive_cmds 830590b17f1bSmrg fi 83067e6fb56fSmrg fi 83077e6fb56fSmrg 8308983b4bf2Smrg if test "X$skipped_export" != "X:" && 830990b17f1bSmrg func_len " $test_cmds" && 831090b17f1bSmrg len=$func_len_result && 831190b17f1bSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 831290b17f1bSmrg : 831390b17f1bSmrg else 831490b17f1bSmrg # The command line is too long to link in one step, link piecewise 831590b17f1bSmrg # or, if using GNU ld and skipped_export is not :, use a linker 831690b17f1bSmrg # script. 83177e6fb56fSmrg 831890b17f1bSmrg # Save the value of $output and $libobjs because we want to 831990b17f1bSmrg # use them later. If we have whole_archive_flag_spec, we 832090b17f1bSmrg # want to use save_libobjs as it was before 832190b17f1bSmrg # whole_archive_flag_spec was expanded, because we can't 832290b17f1bSmrg # assume the linker understands whole_archive_flag_spec. 832390b17f1bSmrg # This may have to be revisited, in case too many 832490b17f1bSmrg # convenience libraries get linked in and end up exceeding 832590b17f1bSmrg # the spec. 832690b17f1bSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 832790b17f1bSmrg save_libobjs=$libobjs 832890b17f1bSmrg fi 832990b17f1bSmrg save_output=$output 833090b17f1bSmrg func_basename "$output" 833190b17f1bSmrg output_la=$func_basename_result 833290b17f1bSmrg 833390b17f1bSmrg # Clear the reloadable object creation command queue and 833490b17f1bSmrg # initialize k to one. 833590b17f1bSmrg test_cmds= 833690b17f1bSmrg concat_cmds= 833790b17f1bSmrg objlist= 833890b17f1bSmrg last_robj= 833990b17f1bSmrg k=1 834090b17f1bSmrg 8341983b4bf2Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 8342983b4bf2Smrg output=${output_objdir}/${output_la}.lnkscript 834390b17f1bSmrg func_verbose "creating GNU ld script: $output" 834490b17f1bSmrg echo 'INPUT (' > $output 834590b17f1bSmrg for obj in $save_libobjs 834690b17f1bSmrg do 834790b17f1bSmrg func_to_tool_file "$obj" 834890b17f1bSmrg $ECHO "$func_to_tool_file_result" >> $output 834990b17f1bSmrg done 835090b17f1bSmrg echo ')' >> $output 835190b17f1bSmrg func_append delfiles " $output" 835290b17f1bSmrg func_to_tool_file "$output" 835390b17f1bSmrg output=$func_to_tool_file_result 8354983b4bf2Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 8355983b4bf2Smrg output=${output_objdir}/${output_la}.lnk 835690b17f1bSmrg func_verbose "creating linker input file list: $output" 835790b17f1bSmrg : > $output 835890b17f1bSmrg set x $save_libobjs 835990b17f1bSmrg shift 836090b17f1bSmrg firstobj= 8361983b4bf2Smrg if test "$compiler_needs_object" = yes; then 836290b17f1bSmrg firstobj="$1 " 836390b17f1bSmrg shift 83647e6fb56fSmrg fi 836590b17f1bSmrg for obj 836690b17f1bSmrg do 836790b17f1bSmrg func_to_tool_file "$obj" 836890b17f1bSmrg $ECHO "$func_to_tool_file_result" >> $output 83697e6fb56fSmrg done 837090b17f1bSmrg func_append delfiles " $output" 837190b17f1bSmrg func_to_tool_file "$output" 837290b17f1bSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 837390b17f1bSmrg else 837490b17f1bSmrg if test -n "$save_libobjs"; then 837590b17f1bSmrg func_verbose "creating reloadable object files..." 8376983b4bf2Smrg output=$output_objdir/$output_la-${k}.$objext 837790b17f1bSmrg eval test_cmds=\"$reload_cmds\" 837890b17f1bSmrg func_len " $test_cmds" 837990b17f1bSmrg len0=$func_len_result 838090b17f1bSmrg len=$len0 838190b17f1bSmrg 838290b17f1bSmrg # Loop over the list of objects to be linked. 838390b17f1bSmrg for obj in $save_libobjs 838490b17f1bSmrg do 838590b17f1bSmrg func_len " $obj" 838690b17f1bSmrg func_arith $len + $func_len_result 838790b17f1bSmrg len=$func_arith_result 8388983b4bf2Smrg if test "X$objlist" = X || 838990b17f1bSmrg test "$len" -lt "$max_cmd_len"; then 839090b17f1bSmrg func_append objlist " $obj" 839190b17f1bSmrg else 839290b17f1bSmrg # The command $test_cmds is almost too long, add a 839390b17f1bSmrg # command to the queue. 8394983b4bf2Smrg if test "$k" -eq 1 ; then 839590b17f1bSmrg # The first file doesn't have a previous command to add. 839690b17f1bSmrg reload_objs=$objlist 839790b17f1bSmrg eval concat_cmds=\"$reload_cmds\" 839890b17f1bSmrg else 839990b17f1bSmrg # All subsequent reloadable object files will link in 840090b17f1bSmrg # the last one created. 840190b17f1bSmrg reload_objs="$objlist $last_robj" 840290b17f1bSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 840390b17f1bSmrg fi 8404983b4bf2Smrg last_robj=$output_objdir/$output_la-${k}.$objext 840590b17f1bSmrg func_arith $k + 1 840690b17f1bSmrg k=$func_arith_result 8407983b4bf2Smrg output=$output_objdir/$output_la-${k}.$objext 840890b17f1bSmrg objlist=" $obj" 840990b17f1bSmrg func_len " $last_robj" 841090b17f1bSmrg func_arith $len0 + $func_len_result 841190b17f1bSmrg len=$func_arith_result 841290b17f1bSmrg fi 841390b17f1bSmrg done 841490b17f1bSmrg # Handle the remaining objects by creating one last 841590b17f1bSmrg # reloadable object file. All subsequent reloadable object 841690b17f1bSmrg # files will link in the last one created. 841790b17f1bSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 841890b17f1bSmrg reload_objs="$objlist $last_robj" 8419983b4bf2Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 842090b17f1bSmrg if test -n "$last_robj"; then 8421983b4bf2Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 84227e6fb56fSmrg fi 842390b17f1bSmrg func_append delfiles " $output" 842490b17f1bSmrg 842590b17f1bSmrg else 842690b17f1bSmrg output= 842790b17f1bSmrg fi 842890b17f1bSmrg 8429983b4bf2Smrg if ${skipped_export-false}; then 8430983b4bf2Smrg func_verbose "generating symbol list for \`$libname.la'" 8431983b4bf2Smrg export_symbols="$output_objdir/$libname.exp" 843290b17f1bSmrg $opt_dry_run || $RM $export_symbols 843390b17f1bSmrg libobjs=$output 843490b17f1bSmrg # Append the command to create the export file. 843590b17f1bSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 843690b17f1bSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 843790b17f1bSmrg if test -n "$last_robj"; then 843890b17f1bSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 84397e6fb56fSmrg fi 8440983b4bf2Smrg fi 844190b17f1bSmrg 844290b17f1bSmrg test -n "$save_libobjs" && 844390b17f1bSmrg func_verbose "creating a temporary reloadable object file: $output" 844490b17f1bSmrg 844590b17f1bSmrg # Loop through the commands generated above and execute them. 8446983b4bf2Smrg save_ifs="$IFS"; IFS='~' 844790b17f1bSmrg for cmd in $concat_cmds; do 8448983b4bf2Smrg IFS="$save_ifs" 8449983b4bf2Smrg $opt_silent || { 845090b17f1bSmrg func_quote_for_expand "$cmd" 845190b17f1bSmrg eval "func_echo $func_quote_for_expand_result" 845290b17f1bSmrg } 845390b17f1bSmrg $opt_dry_run || eval "$cmd" || { 845490b17f1bSmrg lt_exit=$? 845590b17f1bSmrg 845690b17f1bSmrg # Restore the uninstalled library and exit 8457983b4bf2Smrg if test "$opt_mode" = relink; then 845890b17f1bSmrg ( cd "$output_objdir" && \ 845990b17f1bSmrg $RM "${realname}T" && \ 846090b17f1bSmrg $MV "${realname}U" "$realname" ) 846190b17f1bSmrg fi 846290b17f1bSmrg 846390b17f1bSmrg exit $lt_exit 846490b17f1bSmrg } 84657e6fb56fSmrg done 8466983b4bf2Smrg IFS="$save_ifs" 846790b17f1bSmrg 846890b17f1bSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 846990b17f1bSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 847090b17f1bSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 847190b17f1bSmrg fi 847290b17f1bSmrg fi 847390b17f1bSmrg 8474983b4bf2Smrg if ${skipped_export-false}; then 847590b17f1bSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8476983b4bf2Smrg tmp_export_symbols="$export_symbols" 8477983b4bf2Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 847890b17f1bSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 847990b17f1bSmrg fi 848090b17f1bSmrg 848190b17f1bSmrg if test -n "$orig_export_symbols"; then 848290b17f1bSmrg # The given exports_symbols file has to be filtered, so filter it. 8483983b4bf2Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 848490b17f1bSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8485983b4bf2Smrg # 's' commands which not all seds can handle. GNU sed should be fine 848690b17f1bSmrg # though. Also, the filter scales superlinearly with the number of 848790b17f1bSmrg # global variables. join(1) would be nice here, but unfortunately 848890b17f1bSmrg # isn't a blessed tool. 848990b17f1bSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 849090b17f1bSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 849190b17f1bSmrg export_symbols=$output_objdir/$libname.def 849290b17f1bSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 849390b17f1bSmrg fi 8494983b4bf2Smrg fi 849590b17f1bSmrg 849690b17f1bSmrg libobjs=$output 849790b17f1bSmrg # Restore the value of output. 849890b17f1bSmrg output=$save_output 849990b17f1bSmrg 850090b17f1bSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 850190b17f1bSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 850290b17f1bSmrg test "X$libobjs" = "X " && libobjs= 850390b17f1bSmrg fi 850490b17f1bSmrg # Expand the library linking commands again to reset the 850590b17f1bSmrg # value of $libobjs for piecewise linking. 850690b17f1bSmrg 850790b17f1bSmrg # Do each of the archive commands. 8508983b4bf2Smrg if test "$module" = yes && test -n "$module_cmds" ; then 850990b17f1bSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 851090b17f1bSmrg cmds=$module_expsym_cmds 851190b17f1bSmrg else 851290b17f1bSmrg cmds=$module_cmds 851390b17f1bSmrg fi 85147e6fb56fSmrg else 851590b17f1bSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 851690b17f1bSmrg cmds=$archive_expsym_cmds 851790b17f1bSmrg else 851890b17f1bSmrg cmds=$archive_cmds 851990b17f1bSmrg fi 85207e6fb56fSmrg fi 852190b17f1bSmrg fi 85227e6fb56fSmrg 852390b17f1bSmrg if test -n "$delfiles"; then 852490b17f1bSmrg # Append the command to remove temporary files to $cmds. 852590b17f1bSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 852690b17f1bSmrg fi 85277e6fb56fSmrg 852890b17f1bSmrg # Add any objects from preloaded convenience libraries 852990b17f1bSmrg if test -n "$dlprefiles"; then 8530983b4bf2Smrg gentop="$output_objdir/${outputname}x" 853190b17f1bSmrg func_append generated " $gentop" 85327e6fb56fSmrg 853390b17f1bSmrg func_extract_archives $gentop $dlprefiles 853490b17f1bSmrg func_append libobjs " $func_extract_archives_result" 853590b17f1bSmrg test "X$libobjs" = "X " && libobjs= 853690b17f1bSmrg fi 85377e6fb56fSmrg 8538983b4bf2Smrg save_ifs="$IFS"; IFS='~' 853990b17f1bSmrg for cmd in $cmds; do 8540983b4bf2Smrg IFS="$save_ifs" 854190b17f1bSmrg eval cmd=\"$cmd\" 8542983b4bf2Smrg $opt_silent || { 854390b17f1bSmrg func_quote_for_expand "$cmd" 854490b17f1bSmrg eval "func_echo $func_quote_for_expand_result" 854590b17f1bSmrg } 854690b17f1bSmrg $opt_dry_run || eval "$cmd" || { 854790b17f1bSmrg lt_exit=$? 85487e6fb56fSmrg 854990b17f1bSmrg # Restore the uninstalled library and exit 8550983b4bf2Smrg if test "$opt_mode" = relink; then 855190b17f1bSmrg ( cd "$output_objdir" && \ 855290b17f1bSmrg $RM "${realname}T" && \ 855390b17f1bSmrg $MV "${realname}U" "$realname" ) 855490b17f1bSmrg fi 85557e6fb56fSmrg 855690b17f1bSmrg exit $lt_exit 855790b17f1bSmrg } 855890b17f1bSmrg done 8559983b4bf2Smrg IFS="$save_ifs" 85607e6fb56fSmrg 856190b17f1bSmrg # Restore the uninstalled library and exit 8562983b4bf2Smrg if test "$opt_mode" = relink; then 856390b17f1bSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 85647e6fb56fSmrg 856590b17f1bSmrg if test -n "$convenience"; then 856690b17f1bSmrg if test -z "$whole_archive_flag_spec"; then 856790b17f1bSmrg func_show_eval '${RM}r "$gentop"' 856890b17f1bSmrg fi 856990b17f1bSmrg fi 85707e6fb56fSmrg 857190b17f1bSmrg exit $EXIT_SUCCESS 857290b17f1bSmrg fi 857390b17f1bSmrg 857490b17f1bSmrg # Create links to the real library. 857590b17f1bSmrg for linkname in $linknames; do 857690b17f1bSmrg if test "$realname" != "$linkname"; then 857790b17f1bSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 85787e6fb56fSmrg fi 85797e6fb56fSmrg done 85807e6fb56fSmrg 858190b17f1bSmrg # If -module or -export-dynamic was specified, set the dlname. 8582983b4bf2Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 858390b17f1bSmrg # On all known operating systems, these are identical. 8584983b4bf2Smrg dlname="$soname" 858590b17f1bSmrg fi 858690b17f1bSmrg fi 85877e6fb56fSmrg ;; 85887e6fb56fSmrg 858990b17f1bSmrg obj) 8590983b4bf2Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 8591983b4bf2Smrg func_warning "\`-dlopen' is ignored for objects" 859290b17f1bSmrg fi 85937e6fb56fSmrg 859490b17f1bSmrg case " $deplibs" in 859590b17f1bSmrg *\ -l* | *\ -L*) 8596983b4bf2Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 85977e6fb56fSmrg esac 85987e6fb56fSmrg 859990b17f1bSmrg test -n "$rpath" && \ 8600983b4bf2Smrg func_warning "\`-rpath' is ignored for objects" 86017e6fb56fSmrg 860290b17f1bSmrg test -n "$xrpath" && \ 8603983b4bf2Smrg func_warning "\`-R' is ignored for objects" 86047e6fb56fSmrg 860590b17f1bSmrg test -n "$vinfo" && \ 8606983b4bf2Smrg func_warning "\`-version-info' is ignored for objects" 860790b17f1bSmrg 860890b17f1bSmrg test -n "$release" && \ 8609983b4bf2Smrg func_warning "\`-release' is ignored for objects" 861090b17f1bSmrg 861190b17f1bSmrg case $output in 861290b17f1bSmrg *.lo) 861390b17f1bSmrg test -n "$objs$old_deplibs" && \ 8614983b4bf2Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 861590b17f1bSmrg 861690b17f1bSmrg libobj=$output 861790b17f1bSmrg func_lo2o "$libobj" 861890b17f1bSmrg obj=$func_lo2o_result 86197e6fb56fSmrg ;; 86207e6fb56fSmrg *) 862190b17f1bSmrg libobj= 8622983b4bf2Smrg obj="$output" 86237e6fb56fSmrg ;; 86247e6fb56fSmrg esac 86257e6fb56fSmrg 862690b17f1bSmrg # Delete the old objects. 862790b17f1bSmrg $opt_dry_run || $RM $obj $libobj 86287e6fb56fSmrg 862990b17f1bSmrg # Objects from convenience libraries. This assumes 863090b17f1bSmrg # single-version convenience libraries. Whenever we create 863190b17f1bSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 863290b17f1bSmrg # the extraction. 863390b17f1bSmrg reload_conv_objs= 863490b17f1bSmrg gentop= 8635983b4bf2Smrg # reload_cmds runs $LD directly, so let us get rid of 8636983b4bf2Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 8637983b4bf2Smrg # turning comma into space.. 8638983b4bf2Smrg wl= 8639983b4bf2Smrg 864090b17f1bSmrg if test -n "$convenience"; then 864190b17f1bSmrg if test -n "$whole_archive_flag_spec"; then 864290b17f1bSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 8643983b4bf2Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 864490b17f1bSmrg else 8645983b4bf2Smrg gentop="$output_objdir/${obj}x" 864690b17f1bSmrg func_append generated " $gentop" 86477e6fb56fSmrg 864890b17f1bSmrg func_extract_archives $gentop $convenience 864990b17f1bSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 865090b17f1bSmrg fi 86517e6fb56fSmrg fi 86527e6fb56fSmrg 865390b17f1bSmrg # If we're not building shared, we need to use non_pic_objs 8654983b4bf2Smrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 86557e6fb56fSmrg 865690b17f1bSmrg # Create the old-style object. 8657983b4bf2Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 86587e6fb56fSmrg 8659983b4bf2Smrg output="$obj" 866090b17f1bSmrg func_execute_cmds "$reload_cmds" 'exit $?' 866190b17f1bSmrg 866290b17f1bSmrg # Exit if we aren't doing a library object file. 866390b17f1bSmrg if test -z "$libobj"; then 866490b17f1bSmrg if test -n "$gentop"; then 866590b17f1bSmrg func_show_eval '${RM}r "$gentop"' 866690b17f1bSmrg fi 866790b17f1bSmrg 866890b17f1bSmrg exit $EXIT_SUCCESS 86697e6fb56fSmrg fi 867090b17f1bSmrg 8671983b4bf2Smrg if test "$build_libtool_libs" != yes; then 867290b17f1bSmrg if test -n "$gentop"; then 867390b17f1bSmrg func_show_eval '${RM}r "$gentop"' 867490b17f1bSmrg fi 867590b17f1bSmrg 867690b17f1bSmrg # Create an invalid libtool object if no PIC, so that we don't 867790b17f1bSmrg # accidentally link it into a program. 867890b17f1bSmrg # $show "echo timestamp > $libobj" 867990b17f1bSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 868090b17f1bSmrg exit $EXIT_SUCCESS 8681983b4bf2Smrg fi 868290b17f1bSmrg 8683983b4bf2Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 868490b17f1bSmrg # Only do commands if we really have different PIC objects. 868590b17f1bSmrg reload_objs="$libobjs $reload_conv_objs" 8686983b4bf2Smrg output="$libobj" 868790b17f1bSmrg func_execute_cmds "$reload_cmds" 'exit $?' 868890b17f1bSmrg fi 868990b17f1bSmrg 869090b17f1bSmrg if test -n "$gentop"; then 869190b17f1bSmrg func_show_eval '${RM}r "$gentop"' 869290b17f1bSmrg fi 869390b17f1bSmrg 869490b17f1bSmrg exit $EXIT_SUCCESS 86957e6fb56fSmrg ;; 86967e6fb56fSmrg 869790b17f1bSmrg prog) 869890b17f1bSmrg case $host in 869990b17f1bSmrg *cygwin*) func_stripname '' '.exe' "$output" 870090b17f1bSmrg output=$func_stripname_result.exe;; 870190b17f1bSmrg esac 870290b17f1bSmrg test -n "$vinfo" && \ 8703983b4bf2Smrg func_warning "\`-version-info' is ignored for programs" 87047e6fb56fSmrg 870590b17f1bSmrg test -n "$release" && \ 8706983b4bf2Smrg func_warning "\`-release' is ignored for programs" 87077e6fb56fSmrg 8708983b4bf2Smrg test "$preload" = yes \ 8709983b4bf2Smrg && test "$dlopen_support" = unknown \ 8710983b4bf2Smrg && test "$dlopen_self" = unknown \ 8711983b4bf2Smrg && test "$dlopen_self_static" = unknown && \ 8712983b4bf2Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 871390b17f1bSmrg 871490b17f1bSmrg case $host in 871590b17f1bSmrg *-*-rhapsody* | *-*-darwin1.[012]) 871690b17f1bSmrg # On Rhapsody replace the C library is the System framework 871790b17f1bSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 871890b17f1bSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 87197e6fb56fSmrg ;; 872090b17f1bSmrg esac 87217e6fb56fSmrg 872290b17f1bSmrg case $host in 872390b17f1bSmrg *-*-darwin*) 872490b17f1bSmrg # Don't allow lazy linking, it breaks C++ global constructors 872590b17f1bSmrg # But is supposedly fixed on 10.4 or later (yay!). 8726983b4bf2Smrg if test "$tagname" = CXX ; then 872790b17f1bSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 872890b17f1bSmrg 10.[0123]) 8729983b4bf2Smrg func_append compile_command " ${wl}-bind_at_load" 8730983b4bf2Smrg func_append finalize_command " ${wl}-bind_at_load" 873190b17f1bSmrg ;; 873290b17f1bSmrg esac 87337e6fb56fSmrg fi 873490b17f1bSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 873590b17f1bSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 873690b17f1bSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 873790b17f1bSmrg ;; 873890b17f1bSmrg esac 87397e6fb56fSmrg 87407e6fb56fSmrg 874190b17f1bSmrg # move library search paths that coincide with paths to not yet 874290b17f1bSmrg # installed libraries to the beginning of the library search list 874390b17f1bSmrg new_libs= 874490b17f1bSmrg for path in $notinst_path; do 874590b17f1bSmrg case " $new_libs " in 874690b17f1bSmrg *" -L$path/$objdir "*) ;; 874790b17f1bSmrg *) 874890b17f1bSmrg case " $compile_deplibs " in 874990b17f1bSmrg *" -L$path/$objdir "*) 875090b17f1bSmrg func_append new_libs " -L$path/$objdir" ;; 87517e6fb56fSmrg esac 875290b17f1bSmrg ;; 875390b17f1bSmrg esac 875490b17f1bSmrg done 875590b17f1bSmrg for deplib in $compile_deplibs; do 875690b17f1bSmrg case $deplib in 875790b17f1bSmrg -L*) 875890b17f1bSmrg case " $new_libs " in 875990b17f1bSmrg *" $deplib "*) ;; 876090b17f1bSmrg *) func_append new_libs " $deplib" ;; 87617e6fb56fSmrg esac 876290b17f1bSmrg ;; 876390b17f1bSmrg *) func_append new_libs " $deplib" ;; 876490b17f1bSmrg esac 876590b17f1bSmrg done 8766983b4bf2Smrg compile_deplibs="$new_libs" 87677e6fb56fSmrg 87687e6fb56fSmrg 876990b17f1bSmrg func_append compile_command " $compile_deplibs" 877090b17f1bSmrg func_append finalize_command " $finalize_deplibs" 87717e6fb56fSmrg 877290b17f1bSmrg if test -n "$rpath$xrpath"; then 877390b17f1bSmrg # If the user specified any rpath flags, then add them. 877490b17f1bSmrg for libdir in $rpath $xrpath; do 877590b17f1bSmrg # This is the magic to use -rpath. 877690b17f1bSmrg case "$finalize_rpath " in 877790b17f1bSmrg *" $libdir "*) ;; 877890b17f1bSmrg *) func_append finalize_rpath " $libdir" ;; 877990b17f1bSmrg esac 878090b17f1bSmrg done 878190b17f1bSmrg fi 87827e6fb56fSmrg 878390b17f1bSmrg # Now hardcode the library paths 878490b17f1bSmrg rpath= 878590b17f1bSmrg hardcode_libdirs= 878690b17f1bSmrg for libdir in $compile_rpath $finalize_rpath; do 878790b17f1bSmrg if test -n "$hardcode_libdir_flag_spec"; then 878890b17f1bSmrg if test -n "$hardcode_libdir_separator"; then 878990b17f1bSmrg if test -z "$hardcode_libdirs"; then 8790983b4bf2Smrg hardcode_libdirs="$libdir" 879190b17f1bSmrg else 879290b17f1bSmrg # Just accumulate the unique libdirs. 879390b17f1bSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 879490b17f1bSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 879590b17f1bSmrg ;; 879690b17f1bSmrg *) 879790b17f1bSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 879890b17f1bSmrg ;; 879990b17f1bSmrg esac 880090b17f1bSmrg fi 88017e6fb56fSmrg else 880290b17f1bSmrg eval flag=\"$hardcode_libdir_flag_spec\" 880390b17f1bSmrg func_append rpath " $flag" 88047e6fb56fSmrg fi 880590b17f1bSmrg elif test -n "$runpath_var"; then 880690b17f1bSmrg case "$perm_rpath " in 880790b17f1bSmrg *" $libdir "*) ;; 880890b17f1bSmrg *) func_append perm_rpath " $libdir" ;; 880990b17f1bSmrg esac 881090b17f1bSmrg fi 881190b17f1bSmrg case $host in 881290b17f1bSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 8813983b4bf2Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 881490b17f1bSmrg case :$dllsearchpath: in 881590b17f1bSmrg *":$libdir:"*) ;; 881690b17f1bSmrg ::) dllsearchpath=$libdir;; 881790b17f1bSmrg *) func_append dllsearchpath ":$libdir";; 881890b17f1bSmrg esac 881990b17f1bSmrg case :$dllsearchpath: in 882090b17f1bSmrg *":$testbindir:"*) ;; 882190b17f1bSmrg ::) dllsearchpath=$testbindir;; 882290b17f1bSmrg *) func_append dllsearchpath ":$testbindir";; 882390b17f1bSmrg esac 882490b17f1bSmrg ;; 882590b17f1bSmrg esac 882690b17f1bSmrg done 882790b17f1bSmrg # Substitute the hardcoded libdirs into the rpath. 882890b17f1bSmrg if test -n "$hardcode_libdir_separator" && 882990b17f1bSmrg test -n "$hardcode_libdirs"; then 8830983b4bf2Smrg libdir="$hardcode_libdirs" 883190b17f1bSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 883290b17f1bSmrg fi 8833983b4bf2Smrg compile_rpath="$rpath" 88347e6fb56fSmrg 883590b17f1bSmrg rpath= 883690b17f1bSmrg hardcode_libdirs= 883790b17f1bSmrg for libdir in $finalize_rpath; do 883890b17f1bSmrg if test -n "$hardcode_libdir_flag_spec"; then 883990b17f1bSmrg if test -n "$hardcode_libdir_separator"; then 884090b17f1bSmrg if test -z "$hardcode_libdirs"; then 8841983b4bf2Smrg hardcode_libdirs="$libdir" 884290b17f1bSmrg else 884390b17f1bSmrg # Just accumulate the unique libdirs. 884490b17f1bSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 884590b17f1bSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 884690b17f1bSmrg ;; 884790b17f1bSmrg *) 884890b17f1bSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 884990b17f1bSmrg ;; 885090b17f1bSmrg esac 885190b17f1bSmrg fi 88527e6fb56fSmrg else 885390b17f1bSmrg eval flag=\"$hardcode_libdir_flag_spec\" 885490b17f1bSmrg func_append rpath " $flag" 88557e6fb56fSmrg fi 885690b17f1bSmrg elif test -n "$runpath_var"; then 885790b17f1bSmrg case "$finalize_perm_rpath " in 885890b17f1bSmrg *" $libdir "*) ;; 885990b17f1bSmrg *) func_append finalize_perm_rpath " $libdir" ;; 886090b17f1bSmrg esac 88617e6fb56fSmrg fi 886290b17f1bSmrg done 886390b17f1bSmrg # Substitute the hardcoded libdirs into the rpath. 886490b17f1bSmrg if test -n "$hardcode_libdir_separator" && 886590b17f1bSmrg test -n "$hardcode_libdirs"; then 8866983b4bf2Smrg libdir="$hardcode_libdirs" 886790b17f1bSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 886890b17f1bSmrg fi 8869983b4bf2Smrg finalize_rpath="$rpath" 88707e6fb56fSmrg 8871983b4bf2Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 887290b17f1bSmrg # Transform all the library objects into standard objects. 887390b17f1bSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 887490b17f1bSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 887590b17f1bSmrg fi 88767e6fb56fSmrg 8877983b4bf2Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 88787e6fb56fSmrg 887990b17f1bSmrg # template prelinking step 888090b17f1bSmrg if test -n "$prelink_cmds"; then 888190b17f1bSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 888290b17f1bSmrg fi 88837e6fb56fSmrg 8884983b4bf2Smrg wrappers_required=yes 888590b17f1bSmrg case $host in 888690b17f1bSmrg *cegcc* | *mingw32ce*) 888790b17f1bSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 8888983b4bf2Smrg wrappers_required=no 888990b17f1bSmrg ;; 889090b17f1bSmrg *cygwin* | *mingw* ) 8891983b4bf2Smrg if test "$build_libtool_libs" != yes; then 8892983b4bf2Smrg wrappers_required=no 8893983b4bf2Smrg fi 889490b17f1bSmrg ;; 889590b17f1bSmrg *) 8896983b4bf2Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8897983b4bf2Smrg wrappers_required=no 889890b17f1bSmrg fi 889990b17f1bSmrg ;; 890090b17f1bSmrg esac 8901983b4bf2Smrg if test "$wrappers_required" = no; then 890290b17f1bSmrg # Replace the output file specification. 890390b17f1bSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8904983b4bf2Smrg link_command="$compile_command$compile_rpath" 89057e6fb56fSmrg 890690b17f1bSmrg # We have no uninstalled library dependencies, so finalize right now. 890790b17f1bSmrg exit_status=0 890890b17f1bSmrg func_show_eval "$link_command" 'exit_status=$?' 89097e6fb56fSmrg 891090b17f1bSmrg if test -n "$postlink_cmds"; then 891190b17f1bSmrg func_to_tool_file "$output" 891290b17f1bSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 891390b17f1bSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 89147e6fb56fSmrg fi 89157e6fb56fSmrg 891690b17f1bSmrg # Delete the generated files. 8917983b4bf2Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 8918983b4bf2Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 891990b17f1bSmrg fi 89207e6fb56fSmrg 892190b17f1bSmrg exit $exit_status 8922983b4bf2Smrg fi 89237e6fb56fSmrg 892490b17f1bSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 892590b17f1bSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 892690b17f1bSmrg fi 892790b17f1bSmrg if test -n "$finalize_shlibpath"; then 892890b17f1bSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 892990b17f1bSmrg fi 89307e6fb56fSmrg 893190b17f1bSmrg compile_var= 893290b17f1bSmrg finalize_var= 893390b17f1bSmrg if test -n "$runpath_var"; then 893490b17f1bSmrg if test -n "$perm_rpath"; then 893590b17f1bSmrg # We should set the runpath_var. 893690b17f1bSmrg rpath= 893790b17f1bSmrg for dir in $perm_rpath; do 893890b17f1bSmrg func_append rpath "$dir:" 893990b17f1bSmrg done 894090b17f1bSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 89417e6fb56fSmrg fi 894290b17f1bSmrg if test -n "$finalize_perm_rpath"; then 894390b17f1bSmrg # We should set the runpath_var. 894490b17f1bSmrg rpath= 894590b17f1bSmrg for dir in $finalize_perm_rpath; do 894690b17f1bSmrg func_append rpath "$dir:" 894790b17f1bSmrg done 894890b17f1bSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 89497e6fb56fSmrg fi 895090b17f1bSmrg fi 89517e6fb56fSmrg 8952983b4bf2Smrg if test "$no_install" = yes; then 895390b17f1bSmrg # We don't need to create a wrapper script. 8954983b4bf2Smrg link_command="$compile_var$compile_command$compile_rpath" 895590b17f1bSmrg # Replace the output file specification. 895690b17f1bSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 895790b17f1bSmrg # Delete the old output file. 895890b17f1bSmrg $opt_dry_run || $RM $output 895990b17f1bSmrg # Link the executable and exit 896090b17f1bSmrg func_show_eval "$link_command" 'exit $?' 89617e6fb56fSmrg 896290b17f1bSmrg if test -n "$postlink_cmds"; then 896390b17f1bSmrg func_to_tool_file "$output" 896490b17f1bSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 896590b17f1bSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 89667e6fb56fSmrg fi 896790b17f1bSmrg 89687e6fb56fSmrg exit $EXIT_SUCCESS 896990b17f1bSmrg fi 89707e6fb56fSmrg 8971983b4bf2Smrg if test "$hardcode_action" = relink; then 8972983b4bf2Smrg # Fast installation is not supported 8973983b4bf2Smrg link_command="$compile_var$compile_command$compile_rpath" 8974983b4bf2Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 897590b17f1bSmrg 8976983b4bf2Smrg func_warning "this platform does not like uninstalled shared libraries" 8977983b4bf2Smrg func_warning "\`$output' will be relinked during installation" 8978983b4bf2Smrg else 8979983b4bf2Smrg if test "$fast_install" != no; then 8980983b4bf2Smrg link_command="$finalize_var$compile_command$finalize_rpath" 8981983b4bf2Smrg if test "$fast_install" = yes; then 8982983b4bf2Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 8983983b4bf2Smrg else 8984983b4bf2Smrg # fast_install is set to needless 8985983b4bf2Smrg relink_command= 8986983b4bf2Smrg fi 8987983b4bf2Smrg else 8988983b4bf2Smrg link_command="$compile_var$compile_command$compile_rpath" 8989983b4bf2Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8990983b4bf2Smrg fi 8991983b4bf2Smrg fi 89927e6fb56fSmrg 899390b17f1bSmrg # Replace the output file specification. 899490b17f1bSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 89957e6fb56fSmrg 899690b17f1bSmrg # Delete the old output files. 899790b17f1bSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 89987e6fb56fSmrg 899990b17f1bSmrg func_show_eval "$link_command" 'exit $?' 90007e6fb56fSmrg 900190b17f1bSmrg if test -n "$postlink_cmds"; then 900290b17f1bSmrg func_to_tool_file "$output_objdir/$outputname" 900390b17f1bSmrg 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'` 900490b17f1bSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 900590b17f1bSmrg fi 90067e6fb56fSmrg 900790b17f1bSmrg # Now create the wrapper script. 900890b17f1bSmrg func_verbose "creating $output" 90097e6fb56fSmrg 901090b17f1bSmrg # Quote the relink command for shipping. 901190b17f1bSmrg if test -n "$relink_command"; then 901290b17f1bSmrg # Preserve any variables that may affect compiler behavior 901390b17f1bSmrg for var in $variables_saved_for_relink; do 901490b17f1bSmrg if eval test -z \"\${$var+set}\"; then 901590b17f1bSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 901690b17f1bSmrg elif eval var_value=\$$var; test -z "$var_value"; then 901790b17f1bSmrg relink_command="$var=; export $var; $relink_command" 90187e6fb56fSmrg else 901990b17f1bSmrg func_quote_for_eval "$var_value" 902090b17f1bSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 90217e6fb56fSmrg fi 902290b17f1bSmrg done 902390b17f1bSmrg relink_command="(cd `pwd`; $relink_command)" 902490b17f1bSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 902590b17f1bSmrg fi 902690b17f1bSmrg 902790b17f1bSmrg # Only actually do things if not in dry run mode. 902890b17f1bSmrg $opt_dry_run || { 902990b17f1bSmrg # win32 will think the script is a binary if it has 903090b17f1bSmrg # a .exe suffix, so we strip it off here. 903190b17f1bSmrg case $output in 903290b17f1bSmrg *.exe) func_stripname '' '.exe' "$output" 903390b17f1bSmrg output=$func_stripname_result ;; 90347e6fb56fSmrg esac 903590b17f1bSmrg # test for cygwin because mv fails w/o .exe extensions 903690b17f1bSmrg case $host in 903790b17f1bSmrg *cygwin*) 903890b17f1bSmrg exeext=.exe 903990b17f1bSmrg func_stripname '' '.exe' "$outputname" 904090b17f1bSmrg outputname=$func_stripname_result ;; 904190b17f1bSmrg *) exeext= ;; 904290b17f1bSmrg esac 904390b17f1bSmrg case $host in 904490b17f1bSmrg *cygwin* | *mingw* ) 904590b17f1bSmrg func_dirname_and_basename "$output" "" "." 904690b17f1bSmrg output_name=$func_basename_result 904790b17f1bSmrg output_path=$func_dirname_result 9048983b4bf2Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 9049983b4bf2Smrg cwrapper="$output_path/$output_name.exe" 905090b17f1bSmrg $RM $cwrappersource $cwrapper 905190b17f1bSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 905290b17f1bSmrg 905390b17f1bSmrg func_emit_cwrapperexe_src > $cwrappersource 905490b17f1bSmrg 905590b17f1bSmrg # The wrapper executable is built using the $host compiler, 905690b17f1bSmrg # because it contains $host paths and files. If cross- 905790b17f1bSmrg # compiling, it, like the target executable, must be 905890b17f1bSmrg # executed on the $host or under an emulation environment. 905990b17f1bSmrg $opt_dry_run || { 906090b17f1bSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 906190b17f1bSmrg $STRIP $cwrapper 906290b17f1bSmrg } 90637e6fb56fSmrg 906490b17f1bSmrg # Now, create the wrapper script for func_source use: 906590b17f1bSmrg func_ltwrapper_scriptname $cwrapper 906690b17f1bSmrg $RM $func_ltwrapper_scriptname_result 906790b17f1bSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 906890b17f1bSmrg $opt_dry_run || { 906990b17f1bSmrg # note: this script will not be executed, so do not chmod. 9070983b4bf2Smrg if test "x$build" = "x$host" ; then 907190b17f1bSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 907290b17f1bSmrg else 907390b17f1bSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 907490b17f1bSmrg fi 907590b17f1bSmrg } 907690b17f1bSmrg ;; 907790b17f1bSmrg * ) 907890b17f1bSmrg $RM $output 907990b17f1bSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 90807e6fb56fSmrg 908190b17f1bSmrg func_emit_wrapper no > $output 908290b17f1bSmrg chmod +x $output 908390b17f1bSmrg ;; 908490b17f1bSmrg esac 908590b17f1bSmrg } 908690b17f1bSmrg exit $EXIT_SUCCESS 908790b17f1bSmrg ;; 908890b17f1bSmrg esac 90897e6fb56fSmrg 909090b17f1bSmrg # See if we need to build an old-fashioned archive. 909190b17f1bSmrg for oldlib in $oldlibs; do 90927e6fb56fSmrg 9093983b4bf2Smrg if test "$build_libtool_libs" = convenience; then 9094983b4bf2Smrg oldobjs="$libobjs_save $symfileobj" 9095983b4bf2Smrg addlibs="$convenience" 9096983b4bf2Smrg build_libtool_libs=no 9097983b4bf2Smrg else 9098983b4bf2Smrg if test "$build_libtool_libs" = module; then 9099983b4bf2Smrg oldobjs="$libobjs_save" 9100963d66acSmrg build_libtool_libs=no 9101983b4bf2Smrg else 910290b17f1bSmrg oldobjs="$old_deplibs $non_pic_objects" 9103983b4bf2Smrg if test "$preload" = yes && test -f "$symfileobj"; then 9104983b4bf2Smrg func_append oldobjs " $symfileobj" 9105983b4bf2Smrg fi 9106983b4bf2Smrg fi 9107983b4bf2Smrg addlibs="$old_convenience" 9108983b4bf2Smrg fi 91097e6fb56fSmrg 911090b17f1bSmrg if test -n "$addlibs"; then 9111983b4bf2Smrg gentop="$output_objdir/${outputname}x" 911290b17f1bSmrg func_append generated " $gentop" 91137e6fb56fSmrg 911490b17f1bSmrg func_extract_archives $gentop $addlibs 911590b17f1bSmrg func_append oldobjs " $func_extract_archives_result" 911690b17f1bSmrg fi 91177e6fb56fSmrg 911890b17f1bSmrg # Do each command in the archive commands. 9119983b4bf2Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 912090b17f1bSmrg cmds=$old_archive_from_new_cmds 912190b17f1bSmrg else 91227e6fb56fSmrg 912390b17f1bSmrg # Add any objects from preloaded convenience libraries 912490b17f1bSmrg if test -n "$dlprefiles"; then 9125983b4bf2Smrg gentop="$output_objdir/${outputname}x" 912690b17f1bSmrg func_append generated " $gentop" 91277e6fb56fSmrg 912890b17f1bSmrg func_extract_archives $gentop $dlprefiles 912990b17f1bSmrg func_append oldobjs " $func_extract_archives_result" 913090b17f1bSmrg fi 91317e6fb56fSmrg 913290b17f1bSmrg # POSIX demands no paths to be encoded in archives. We have 913390b17f1bSmrg # to avoid creating archives with duplicate basenames if we 913490b17f1bSmrg # might have to extract them afterwards, e.g., when creating a 913590b17f1bSmrg # static archive out of a convenience library, or when linking 913690b17f1bSmrg # the entirety of a libtool archive into another (currently 913790b17f1bSmrg # not supported by libtool). 913890b17f1bSmrg if (for obj in $oldobjs 913990b17f1bSmrg do 914090b17f1bSmrg func_basename "$obj" 914190b17f1bSmrg $ECHO "$func_basename_result" 914290b17f1bSmrg done | sort | sort -uc >/dev/null 2>&1); then 914390b17f1bSmrg : 914490b17f1bSmrg else 914590b17f1bSmrg echo "copying selected object files to avoid basename conflicts..." 9146983b4bf2Smrg gentop="$output_objdir/${outputname}x" 914790b17f1bSmrg func_append generated " $gentop" 914890b17f1bSmrg func_mkdir_p "$gentop" 914990b17f1bSmrg save_oldobjs=$oldobjs 915090b17f1bSmrg oldobjs= 915190b17f1bSmrg counter=1 915290b17f1bSmrg for obj in $save_oldobjs 915390b17f1bSmrg do 915490b17f1bSmrg func_basename "$obj" 9155983b4bf2Smrg objbase="$func_basename_result" 915690b17f1bSmrg case " $oldobjs " in 915790b17f1bSmrg " ") oldobjs=$obj ;; 915890b17f1bSmrg *[\ /]"$objbase "*) 915990b17f1bSmrg while :; do 916090b17f1bSmrg # Make sure we don't pick an alternate name that also 916190b17f1bSmrg # overlaps. 916290b17f1bSmrg newobj=lt$counter-$objbase 916390b17f1bSmrg func_arith $counter + 1 916490b17f1bSmrg counter=$func_arith_result 916590b17f1bSmrg case " $oldobjs " in 916690b17f1bSmrg *[\ /]"$newobj "*) ;; 916790b17f1bSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 916890b17f1bSmrg esac 916990b17f1bSmrg done 917090b17f1bSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 917190b17f1bSmrg func_append oldobjs " $gentop/$newobj" 917290b17f1bSmrg ;; 917390b17f1bSmrg *) func_append oldobjs " $obj" ;; 917490b17f1bSmrg esac 91757e6fb56fSmrg done 91767e6fb56fSmrg fi 917790b17f1bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 917890b17f1bSmrg tool_oldlib=$func_to_tool_file_result 917990b17f1bSmrg eval cmds=\"$old_archive_cmds\" 91807e6fb56fSmrg 918190b17f1bSmrg func_len " $cmds" 918290b17f1bSmrg len=$func_len_result 918390b17f1bSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 918490b17f1bSmrg cmds=$old_archive_cmds 918590b17f1bSmrg elif test -n "$archiver_list_spec"; then 918690b17f1bSmrg func_verbose "using command file archive linking..." 918790b17f1bSmrg for obj in $oldobjs 918890b17f1bSmrg do 918990b17f1bSmrg func_to_tool_file "$obj" 919090b17f1bSmrg $ECHO "$func_to_tool_file_result" 919190b17f1bSmrg done > $output_objdir/$libname.libcmd 919290b17f1bSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 919390b17f1bSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 919490b17f1bSmrg cmds=$old_archive_cmds 919590b17f1bSmrg else 919690b17f1bSmrg # the command line is too long to link in one step, link in parts 919790b17f1bSmrg func_verbose "using piecewise archive linking..." 919890b17f1bSmrg save_RANLIB=$RANLIB 919990b17f1bSmrg RANLIB=: 920090b17f1bSmrg objlist= 920190b17f1bSmrg concat_cmds= 920290b17f1bSmrg save_oldobjs=$oldobjs 920390b17f1bSmrg oldobjs= 920490b17f1bSmrg # Is there a better way of finding the last object in the list? 920590b17f1bSmrg for obj in $save_oldobjs 920690b17f1bSmrg do 920790b17f1bSmrg last_oldobj=$obj 920890b17f1bSmrg done 920990b17f1bSmrg eval test_cmds=\"$old_archive_cmds\" 921090b17f1bSmrg func_len " $test_cmds" 921190b17f1bSmrg len0=$func_len_result 921290b17f1bSmrg len=$len0 921390b17f1bSmrg for obj in $save_oldobjs 921490b17f1bSmrg do 921590b17f1bSmrg func_len " $obj" 921690b17f1bSmrg func_arith $len + $func_len_result 921790b17f1bSmrg len=$func_arith_result 921890b17f1bSmrg func_append objlist " $obj" 921990b17f1bSmrg if test "$len" -lt "$max_cmd_len"; then 922090b17f1bSmrg : 922190b17f1bSmrg else 922290b17f1bSmrg # the above command should be used before it gets too long 922390b17f1bSmrg oldobjs=$objlist 9224983b4bf2Smrg if test "$obj" = "$last_oldobj" ; then 922590b17f1bSmrg RANLIB=$save_RANLIB 922690b17f1bSmrg fi 922790b17f1bSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9228983b4bf2Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 922990b17f1bSmrg objlist= 923090b17f1bSmrg len=$len0 923190b17f1bSmrg fi 923290b17f1bSmrg done 923390b17f1bSmrg RANLIB=$save_RANLIB 923490b17f1bSmrg oldobjs=$objlist 9235983b4bf2Smrg if test "X$oldobjs" = "X" ; then 923690b17f1bSmrg eval cmds=\"\$concat_cmds\" 923790b17f1bSmrg else 923890b17f1bSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 923990b17f1bSmrg fi 924090b17f1bSmrg fi 924190b17f1bSmrg fi 924290b17f1bSmrg func_execute_cmds "$cmds" 'exit $?' 92437e6fb56fSmrg done 92447e6fb56fSmrg 924590b17f1bSmrg test -n "$generated" && \ 924690b17f1bSmrg func_show_eval "${RM}r$generated" 92477e6fb56fSmrg 924890b17f1bSmrg # Now create the libtool archive. 924990b17f1bSmrg case $output in 925090b17f1bSmrg *.la) 925190b17f1bSmrg old_library= 9252983b4bf2Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 925390b17f1bSmrg func_verbose "creating $output" 92547e6fb56fSmrg 925590b17f1bSmrg # Preserve any variables that may affect compiler behavior 925690b17f1bSmrg for var in $variables_saved_for_relink; do 925790b17f1bSmrg if eval test -z \"\${$var+set}\"; then 925890b17f1bSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 925990b17f1bSmrg elif eval var_value=\$$var; test -z "$var_value"; then 926090b17f1bSmrg relink_command="$var=; export $var; $relink_command" 92617e6fb56fSmrg else 926290b17f1bSmrg func_quote_for_eval "$var_value" 926390b17f1bSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 92647e6fb56fSmrg fi 926590b17f1bSmrg done 926690b17f1bSmrg # Quote the link command for shipping. 9267983b4bf2Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 926890b17f1bSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9269983b4bf2Smrg if test "$hardcode_automatic" = yes ; then 927090b17f1bSmrg relink_command= 927190b17f1bSmrg fi 92727e6fb56fSmrg 927390b17f1bSmrg # Only create the output if not a dry run. 927490b17f1bSmrg $opt_dry_run || { 927590b17f1bSmrg for installed in no yes; do 9276983b4bf2Smrg if test "$installed" = yes; then 927790b17f1bSmrg if test -z "$install_libdir"; then 927890b17f1bSmrg break 927990b17f1bSmrg fi 9280983b4bf2Smrg output="$output_objdir/$outputname"i 928190b17f1bSmrg # Replace all uninstalled libtool libraries with the installed ones 928290b17f1bSmrg newdependency_libs= 928390b17f1bSmrg for deplib in $dependency_libs; do 928490b17f1bSmrg case $deplib in 928590b17f1bSmrg *.la) 928690b17f1bSmrg func_basename "$deplib" 9287983b4bf2Smrg name="$func_basename_result" 928890b17f1bSmrg func_resolve_sysroot "$deplib" 9289983b4bf2Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 929090b17f1bSmrg test -z "$libdir" && \ 9291983b4bf2Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 929290b17f1bSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 929390b17f1bSmrg ;; 929490b17f1bSmrg -L*) 929590b17f1bSmrg func_stripname -L '' "$deplib" 929690b17f1bSmrg func_replace_sysroot "$func_stripname_result" 929790b17f1bSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 929890b17f1bSmrg ;; 929990b17f1bSmrg -R*) 930090b17f1bSmrg func_stripname -R '' "$deplib" 930190b17f1bSmrg func_replace_sysroot "$func_stripname_result" 930290b17f1bSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 930390b17f1bSmrg ;; 930490b17f1bSmrg *) func_append newdependency_libs " $deplib" ;; 930590b17f1bSmrg esac 930690b17f1bSmrg done 9307983b4bf2Smrg dependency_libs="$newdependency_libs" 930890b17f1bSmrg newdlfiles= 930990b17f1bSmrg 931090b17f1bSmrg for lib in $dlfiles; do 931190b17f1bSmrg case $lib in 931290b17f1bSmrg *.la) 931390b17f1bSmrg func_basename "$lib" 9314983b4bf2Smrg name="$func_basename_result" 9315983b4bf2Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 931690b17f1bSmrg test -z "$libdir" && \ 9317983b4bf2Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 931890b17f1bSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 931990b17f1bSmrg ;; 932090b17f1bSmrg *) func_append newdlfiles " $lib" ;; 932190b17f1bSmrg esac 932290b17f1bSmrg done 9323983b4bf2Smrg dlfiles="$newdlfiles" 932490b17f1bSmrg newdlprefiles= 932590b17f1bSmrg for lib in $dlprefiles; do 932690b17f1bSmrg case $lib in 932790b17f1bSmrg *.la) 932890b17f1bSmrg # Only pass preopened files to the pseudo-archive (for 932990b17f1bSmrg # eventual linking with the app. that links it) if we 933090b17f1bSmrg # didn't already link the preopened objects directly into 933190b17f1bSmrg # the library: 933290b17f1bSmrg func_basename "$lib" 9333983b4bf2Smrg name="$func_basename_result" 9334983b4bf2Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 933590b17f1bSmrg test -z "$libdir" && \ 9336983b4bf2Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 933790b17f1bSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 933890b17f1bSmrg ;; 933990b17f1bSmrg esac 934090b17f1bSmrg done 9341983b4bf2Smrg dlprefiles="$newdlprefiles" 934290b17f1bSmrg else 934390b17f1bSmrg newdlfiles= 934490b17f1bSmrg for lib in $dlfiles; do 934590b17f1bSmrg case $lib in 9346983b4bf2Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 934790b17f1bSmrg *) abs=`pwd`"/$lib" ;; 934890b17f1bSmrg esac 934990b17f1bSmrg func_append newdlfiles " $abs" 935090b17f1bSmrg done 9351983b4bf2Smrg dlfiles="$newdlfiles" 935290b17f1bSmrg newdlprefiles= 935390b17f1bSmrg for lib in $dlprefiles; do 935490b17f1bSmrg case $lib in 9355983b4bf2Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 935690b17f1bSmrg *) abs=`pwd`"/$lib" ;; 935790b17f1bSmrg esac 935890b17f1bSmrg func_append newdlprefiles " $abs" 935990b17f1bSmrg done 9360983b4bf2Smrg dlprefiles="$newdlprefiles" 936190b17f1bSmrg fi 936290b17f1bSmrg $RM $output 936390b17f1bSmrg # place dlname in correct position for cygwin 936490b17f1bSmrg # In fact, it would be nice if we could use this code for all target 936590b17f1bSmrg # systems that can't hard-code library paths into their executables 936690b17f1bSmrg # and that have no shared library path variable independent of PATH, 936790b17f1bSmrg # but it turns out we can't easily determine that from inspecting 936890b17f1bSmrg # libtool variables, so we have to hard-code the OSs to which it 936990b17f1bSmrg # applies here; at the moment, that means platforms that use the PE 937090b17f1bSmrg # object format with DLL files. See the long comment at the top of 937190b17f1bSmrg # tests/bindir.at for full details. 937290b17f1bSmrg tdlname=$dlname 937390b17f1bSmrg case $host,$output,$installed,$module,$dlname in 937490b17f1bSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 937590b17f1bSmrg # If a -bindir argument was supplied, place the dll there. 9376983b4bf2Smrg if test "x$bindir" != x ; 9377983b4bf2Smrg then 937890b17f1bSmrg func_relative_path "$install_libdir" "$bindir" 9379983b4bf2Smrg tdlname=$func_relative_path_result$dlname 938090b17f1bSmrg else 938190b17f1bSmrg # Otherwise fall back on heuristic. 938290b17f1bSmrg tdlname=../bin/$dlname 938390b17f1bSmrg fi 938490b17f1bSmrg ;; 938590b17f1bSmrg esac 938690b17f1bSmrg $ECHO > $output "\ 938790b17f1bSmrg# $outputname - a libtool library file 9388983b4bf2Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 938990b17f1bSmrg# 939090b17f1bSmrg# Please DO NOT delete this file! 939190b17f1bSmrg# It is necessary for linking the library. 93927e6fb56fSmrg 939390b17f1bSmrg# The name that we can dlopen(3). 939490b17f1bSmrgdlname='$tdlname' 93957e6fb56fSmrg 939690b17f1bSmrg# Names of this library. 939790b17f1bSmrglibrary_names='$library_names' 93987e6fb56fSmrg 939990b17f1bSmrg# The name of the static archive. 940090b17f1bSmrgold_library='$old_library' 94017e6fb56fSmrg 9402983b4bf2Smrg# Linker flags that can not go in dependency_libs. 940390b17f1bSmrginherited_linker_flags='$new_inherited_linker_flags' 94047e6fb56fSmrg 940590b17f1bSmrg# Libraries that this one depends upon. 940690b17f1bSmrgdependency_libs='$dependency_libs' 94077e6fb56fSmrg 940890b17f1bSmrg# Names of additional weak libraries provided by this library 940990b17f1bSmrgweak_library_names='$weak_libs' 94107e6fb56fSmrg 941190b17f1bSmrg# Version information for $libname. 941290b17f1bSmrgcurrent=$current 941390b17f1bSmrgage=$age 941490b17f1bSmrgrevision=$revision 94157e6fb56fSmrg 941690b17f1bSmrg# Is this an already installed library? 941790b17f1bSmrginstalled=$installed 94187e6fb56fSmrg 941990b17f1bSmrg# Should we warn about portability when linking against -modules? 942090b17f1bSmrgshouldnotlink=$module 94217e6fb56fSmrg 942290b17f1bSmrg# Files to dlopen/dlpreopen 942390b17f1bSmrgdlopen='$dlfiles' 942490b17f1bSmrgdlpreopen='$dlprefiles' 94257e6fb56fSmrg 942690b17f1bSmrg# Directory that this library needs to be installed in: 942790b17f1bSmrglibdir='$install_libdir'" 9428983b4bf2Smrg if test "$installed" = no && test "$need_relink" = yes; then 942990b17f1bSmrg $ECHO >> $output "\ 943090b17f1bSmrgrelink_command=\"$relink_command\"" 943190b17f1bSmrg fi 943290b17f1bSmrg done 943390b17f1bSmrg } 94347e6fb56fSmrg 943590b17f1bSmrg # Do a symbolic link so that the libtool archive can be found in 943690b17f1bSmrg # LD_LIBRARY_PATH before the program is installed. 943790b17f1bSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 943890b17f1bSmrg ;; 943990b17f1bSmrg esac 944090b17f1bSmrg exit $EXIT_SUCCESS 944190b17f1bSmrg} 94427e6fb56fSmrg 9443983b4bf2Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 9444983b4bf2Smrg func_mode_link ${1+"$@"} 94457e6fb56fSmrg 94467e6fb56fSmrg 944790b17f1bSmrg# func_mode_uninstall arg... 944890b17f1bSmrgfunc_mode_uninstall () 944990b17f1bSmrg{ 9450983b4bf2Smrg $opt_debug 9451983b4bf2Smrg RM="$nonopt" 94527e6fb56fSmrg files= 9453983b4bf2Smrg rmforce= 94547e6fb56fSmrg exit_status=0 94557e6fb56fSmrg 94567e6fb56fSmrg # This variable tells wrapper scripts just to set variables rather 94577e6fb56fSmrg # than running their programs. 9458983b4bf2Smrg libtool_install_magic="$magic" 94597e6fb56fSmrg 94607e6fb56fSmrg for arg 94617e6fb56fSmrg do 94627e6fb56fSmrg case $arg in 9463983b4bf2Smrg -f) func_append RM " $arg"; rmforce=yes ;; 946490b17f1bSmrg -*) func_append RM " $arg" ;; 946590b17f1bSmrg *) func_append files " $arg" ;; 94667e6fb56fSmrg esac 94677e6fb56fSmrg done 94687e6fb56fSmrg 946990b17f1bSmrg test -z "$RM" && \ 947090b17f1bSmrg func_fatal_help "you must specify an RM program" 94717e6fb56fSmrg 94727e6fb56fSmrg rmdirs= 94737e6fb56fSmrg 94747e6fb56fSmrg for file in $files; do 947590b17f1bSmrg func_dirname "$file" "" "." 9476983b4bf2Smrg dir="$func_dirname_result" 9477983b4bf2Smrg if test "X$dir" = X.; then 9478983b4bf2Smrg odir="$objdir" 94797e6fb56fSmrg else 9480983b4bf2Smrg odir="$dir/$objdir" 94817e6fb56fSmrg fi 948290b17f1bSmrg func_basename "$file" 9483983b4bf2Smrg name="$func_basename_result" 9484983b4bf2Smrg test "$opt_mode" = uninstall && odir="$dir" 94857e6fb56fSmrg 948690b17f1bSmrg # Remember odir for removal later, being careful to avoid duplicates 9487983b4bf2Smrg if test "$opt_mode" = clean; then 94887e6fb56fSmrg case " $rmdirs " in 948990b17f1bSmrg *" $odir "*) ;; 949090b17f1bSmrg *) func_append rmdirs " $odir" ;; 94917e6fb56fSmrg esac 94927e6fb56fSmrg fi 94937e6fb56fSmrg 94947e6fb56fSmrg # Don't error if the file doesn't exist and rm -f was used. 949590b17f1bSmrg if { test -L "$file"; } >/dev/null 2>&1 || 949690b17f1bSmrg { test -h "$file"; } >/dev/null 2>&1 || 949790b17f1bSmrg test -f "$file"; then 94987e6fb56fSmrg : 94997e6fb56fSmrg elif test -d "$file"; then 95007e6fb56fSmrg exit_status=1 95017e6fb56fSmrg continue 9502983b4bf2Smrg elif test "$rmforce" = yes; then 95037e6fb56fSmrg continue 95047e6fb56fSmrg fi 95057e6fb56fSmrg 9506983b4bf2Smrg rmfiles="$file" 95077e6fb56fSmrg 95087e6fb56fSmrg case $name in 95097e6fb56fSmrg *.la) 95107e6fb56fSmrg # Possibly a libtool archive, so verify it. 951190b17f1bSmrg if func_lalib_p "$file"; then 951290b17f1bSmrg func_source $dir/$name 95137e6fb56fSmrg 95147e6fb56fSmrg # Delete the libtool libraries and symlinks. 95157e6fb56fSmrg for n in $library_names; do 951690b17f1bSmrg func_append rmfiles " $odir/$n" 95177e6fb56fSmrg done 951890b17f1bSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 95197e6fb56fSmrg 9520983b4bf2Smrg case "$opt_mode" in 95217e6fb56fSmrg clean) 952290b17f1bSmrg case " $library_names " in 95237e6fb56fSmrg *" $dlname "*) ;; 952490b17f1bSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 95257e6fb56fSmrg esac 952690b17f1bSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 95277e6fb56fSmrg ;; 95287e6fb56fSmrg uninstall) 95297e6fb56fSmrg if test -n "$library_names"; then 95307e6fb56fSmrg # Do each command in the postuninstall commands. 9531983b4bf2Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 95327e6fb56fSmrg fi 95337e6fb56fSmrg 95347e6fb56fSmrg if test -n "$old_library"; then 95357e6fb56fSmrg # Do each command in the old_postuninstall commands. 9536983b4bf2Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 95377e6fb56fSmrg fi 95387e6fb56fSmrg # FIXME: should reinstall the best remaining shared library. 95397e6fb56fSmrg ;; 95407e6fb56fSmrg esac 95417e6fb56fSmrg fi 95427e6fb56fSmrg ;; 95437e6fb56fSmrg 95447e6fb56fSmrg *.lo) 95457e6fb56fSmrg # Possibly a libtool object, so verify it. 954690b17f1bSmrg if func_lalib_p "$file"; then 95477e6fb56fSmrg 95487e6fb56fSmrg # Read the .lo file 954990b17f1bSmrg func_source $dir/$name 95507e6fb56fSmrg 95517e6fb56fSmrg # Add PIC object to the list of files to remove. 9552983b4bf2Smrg if test -n "$pic_object" && 9553983b4bf2Smrg test "$pic_object" != none; then 955490b17f1bSmrg func_append rmfiles " $dir/$pic_object" 95557e6fb56fSmrg fi 95567e6fb56fSmrg 95577e6fb56fSmrg # Add non-PIC object to the list of files to remove. 9558983b4bf2Smrg if test -n "$non_pic_object" && 9559983b4bf2Smrg test "$non_pic_object" != none; then 956090b17f1bSmrg func_append rmfiles " $dir/$non_pic_object" 95617e6fb56fSmrg fi 95627e6fb56fSmrg fi 95637e6fb56fSmrg ;; 95647e6fb56fSmrg 95657e6fb56fSmrg *) 9566983b4bf2Smrg if test "$opt_mode" = clean ; then 95677e6fb56fSmrg noexename=$name 95687e6fb56fSmrg case $file in 95697e6fb56fSmrg *.exe) 957090b17f1bSmrg func_stripname '' '.exe' "$file" 957190b17f1bSmrg file=$func_stripname_result 957290b17f1bSmrg func_stripname '' '.exe' "$name" 957390b17f1bSmrg noexename=$func_stripname_result 95747e6fb56fSmrg # $file with .exe has already been added to rmfiles, 95757e6fb56fSmrg # add $file without .exe 957690b17f1bSmrg func_append rmfiles " $file" 95777e6fb56fSmrg ;; 95787e6fb56fSmrg esac 95797e6fb56fSmrg # Do a test to see if this is a libtool program. 958090b17f1bSmrg if func_ltwrapper_p "$file"; then 958190b17f1bSmrg if func_ltwrapper_executable_p "$file"; then 958290b17f1bSmrg func_ltwrapper_scriptname "$file" 958390b17f1bSmrg relink_command= 958490b17f1bSmrg func_source $func_ltwrapper_scriptname_result 958590b17f1bSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 958690b17f1bSmrg else 958790b17f1bSmrg relink_command= 958890b17f1bSmrg func_source $dir/$noexename 958990b17f1bSmrg fi 95907e6fb56fSmrg 95917e6fb56fSmrg # note $name still contains .exe if it was in $file originally 95927e6fb56fSmrg # as does the version of $file that was added into $rmfiles 9593983b4bf2Smrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9594983b4bf2Smrg if test "$fast_install" = yes && test -n "$relink_command"; then 959590b17f1bSmrg func_append rmfiles " $odir/lt-$name" 95967e6fb56fSmrg fi 9597983b4bf2Smrg if test "X$noexename" != "X$name" ; then 9598983b4bf2Smrg func_append rmfiles " $odir/lt-${noexename}.c" 95997e6fb56fSmrg fi 96007e6fb56fSmrg fi 96017e6fb56fSmrg fi 96027e6fb56fSmrg ;; 96037e6fb56fSmrg esac 960490b17f1bSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 96057e6fb56fSmrg done 96067e6fb56fSmrg 9607983b4bf2Smrg # Try to remove the ${objdir}s in the directories where we deleted files 96087e6fb56fSmrg for dir in $rmdirs; do 96097e6fb56fSmrg if test -d "$dir"; then 961090b17f1bSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 96117e6fb56fSmrg fi 96127e6fb56fSmrg done 96137e6fb56fSmrg 96147e6fb56fSmrg exit $exit_status 961590b17f1bSmrg} 96167e6fb56fSmrg 9617983b4bf2Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 9618983b4bf2Smrg func_mode_uninstall ${1+"$@"} 96197e6fb56fSmrg 962090b17f1bSmrgtest -z "$opt_mode" && { 9621983b4bf2Smrg help="$generic_help" 962290b17f1bSmrg func_fatal_help "you must specify a MODE" 962390b17f1bSmrg} 962490b17f1bSmrg 962590b17f1bSmrgtest -z "$exec_cmd" && \ 9626983b4bf2Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 96277e6fb56fSmrg 96287e6fb56fSmrgif test -n "$exec_cmd"; then 962990b17f1bSmrg eval exec "$exec_cmd" 96307e6fb56fSmrg exit $EXIT_FAILURE 96317e6fb56fSmrgfi 96327e6fb56fSmrg 963390b17f1bSmrgexit $exit_status 96347e6fb56fSmrg 96357e6fb56fSmrg 96367e6fb56fSmrg# The TAGs below are defined such that we never get into a situation 9637983b4bf2Smrg# in which we disable both kinds of libraries. Given conflicting 96387e6fb56fSmrg# choices, we go for a static library, that is the most portable, 96397e6fb56fSmrg# since we can't tell whether shared libraries were disabled because 96407e6fb56fSmrg# the user asked for that or because the platform doesn't support 96417e6fb56fSmrg# them. This is particularly important on AIX, because we don't 96427e6fb56fSmrg# support having both static and shared libraries enabled at the same 96437e6fb56fSmrg# time on that platform, so we default to a shared-only configuration. 96447e6fb56fSmrg# If a disable-shared tag is given, we'll fallback to a static-only 96457e6fb56fSmrg# configuration. But we'll never go from static-only to shared-only. 96467e6fb56fSmrg 96477e6fb56fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 964890b17f1bSmrgbuild_libtool_libs=no 964990b17f1bSmrgbuild_old_libs=yes 96507e6fb56fSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 96517e6fb56fSmrg 96527e6fb56fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 965390b17f1bSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 96547e6fb56fSmrg# ### END LIBTOOL TAG CONFIG: disable-static 96557e6fb56fSmrg 96567e6fb56fSmrg# Local Variables: 96577e6fb56fSmrg# mode:shell-script 96587e6fb56fSmrg# sh-indentation:2 96597e6fb56fSmrg# End: 9660983b4bf2Smrg# vi:sw=2 9661983b4bf2Smrg 9662