1aee7dae4Smrg 2aee7dae4Smrg# libtool (GNU libtool) 2.4.2 3aee7dae4Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 4aee7dae4Smrg 5aee7dae4Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 6aee7dae4Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 7aee7dae4Smrg# This is free software; see the source for copying conditions. There is NO 8aee7dae4Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9aee7dae4Smrg 10aee7dae4Smrg# GNU Libtool is free software; you can redistribute it and/or modify 11ba0eab60Smacallan# it under the terms of the GNU General Public License as published by 12ba0eab60Smacallan# the Free Software Foundation; either version 2 of the License, or 13ba0eab60Smacallan# (at your option) any later version. 14ba0eab60Smacallan# 15aee7dae4Smrg# As a special exception to the GNU General Public License, 16aee7dae4Smrg# if you distribute this file as part of a program or library that 17aee7dae4Smrg# is built using GNU Libtool, you may include this file under the 18aee7dae4Smrg# same distribution terms that you use for the rest of that program. 19aee7dae4Smrg# 20aee7dae4Smrg# GNU Libtool is distributed in the hope that it will be useful, but 21ba0eab60Smacallan# WITHOUT ANY WARRANTY; without even the implied warranty of 22ba0eab60Smacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23ba0eab60Smacallan# General Public License for more details. 24ba0eab60Smacallan# 25ba0eab60Smacallan# You should have received a copy of the GNU General Public License 26aee7dae4Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 27aee7dae4Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 28aee7dae4Smrg# or obtained by writing to the Free Software Foundation, Inc., 29aee7dae4Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30aee7dae4Smrg 31aee7dae4Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 32aee7dae4Smrg# 33aee7dae4Smrg# Provide generalized library-building support services. 34ba0eab60Smacallan# 35aee7dae4Smrg# --config show all configuration variables 36aee7dae4Smrg# --debug enable verbose shell tracing 37aee7dae4Smrg# -n, --dry-run display commands without modifying any files 38aee7dae4Smrg# --features display basic configuration information and exit 39aee7dae4Smrg# --mode=MODE use operation mode MODE 40aee7dae4Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 41aee7dae4Smrg# --quiet, --silent don't print informational messages 42aee7dae4Smrg# --no-quiet, --no-silent 43aee7dae4Smrg# print informational messages (default) 44aee7dae4Smrg# --no-warn don't display warning messages 45aee7dae4Smrg# --tag=TAG use configuration variables from tag TAG 46aee7dae4Smrg# -v, --verbose print more informational messages than default 47aee7dae4Smrg# --no-verbose don't print the extra informational messages 48aee7dae4Smrg# --version print version information 49aee7dae4Smrg# -h, --help, --help-all print short, long, or detailed help message 50aee7dae4Smrg# 51aee7dae4Smrg# MODE must be one of the following: 52aee7dae4Smrg# 53aee7dae4Smrg# clean remove files from the build directory 54aee7dae4Smrg# compile compile a source file into a libtool object 55aee7dae4Smrg# execute automatically set library path, then run a program 56aee7dae4Smrg# finish complete the installation of libtool libraries 57aee7dae4Smrg# install install libraries or executables 58aee7dae4Smrg# link create a library or an executable 59aee7dae4Smrg# uninstall remove libraries from an installed directory 60aee7dae4Smrg# 61aee7dae4Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 62aee7dae4Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 63aee7dae4Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 64aee7dae4Smrg# 65aee7dae4Smrg# When reporting a bug, please describe a test case to reproduce it and 66aee7dae4Smrg# include the following information: 67aee7dae4Smrg# 68aee7dae4Smrg# host-triplet: $host 69aee7dae4Smrg# shell: $SHELL 70aee7dae4Smrg# compiler: $LTCC 71aee7dae4Smrg# compiler flags: $LTCFLAGS 72aee7dae4Smrg# linker: $LD (gnu? $with_gnu_ld) 73aee7dae4Smrg# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1 74aee7dae4Smrg# automake: $automake_version 75aee7dae4Smrg# autoconf: $autoconf_version 76aee7dae4Smrg# 77aee7dae4Smrg# Report bugs to <bug-libtool@gnu.org>. 78aee7dae4Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 79aee7dae4Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 80aee7dae4Smrg 81aee7dae4SmrgPROGRAM=libtool 82aee7dae4SmrgPACKAGE=libtool 83aee7dae4SmrgVERSION="2.4.2 Debian-2.4.2-1" 84aee7dae4SmrgTIMESTAMP="" 85aee7dae4Smrgpackage_revision=1.3337 86aee7dae4Smrg 87aee7dae4Smrg# Be Bourne compatible 88aee7dae4Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 89aee7dae4Smrg emulate sh 90aee7dae4Smrg NULLCMD=: 91aee7dae4Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 92aee7dae4Smrg # is contrary to our usage. Disable this feature. 93aee7dae4Smrg alias -g '${1+"$@"}'='"$@"' 94aee7dae4Smrg setopt NO_GLOB_SUBST 95aee7dae4Smrgelse 96aee7dae4Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 97aee7dae4Smrgfi 98aee7dae4SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 99aee7dae4SmrgDUALCASE=1; export DUALCASE # for MKS sh 100aee7dae4Smrg 101aee7dae4Smrg# A function that is used when there is no print builtin or printf. 102aee7dae4Smrgfunc_fallback_echo () 103aee7dae4Smrg{ 104aee7dae4Smrg eval 'cat <<_LTECHO_EOF 105aee7dae4Smrg$1 106aee7dae4Smrg_LTECHO_EOF' 107aee7dae4Smrg} 108aee7dae4Smrg 109aee7dae4Smrg# NLS nuisances: We save the old values to restore during execute mode. 110aee7dae4Smrglt_user_locale= 111aee7dae4Smrglt_safe_locale= 112aee7dae4Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 113aee7dae4Smrgdo 114aee7dae4Smrg eval "if test \"\${$lt_var+set}\" = set; then 115aee7dae4Smrg save_$lt_var=\$$lt_var 116aee7dae4Smrg $lt_var=C 117aee7dae4Smrg export $lt_var 118aee7dae4Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 119aee7dae4Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 120aee7dae4Smrg fi" 121aee7dae4Smrgdone 122aee7dae4SmrgLC_ALL=C 123aee7dae4SmrgLANGUAGE=C 124aee7dae4Smrgexport LANGUAGE LC_ALL 125aee7dae4Smrg 126aee7dae4Smrg$lt_unset CDPATH 127ba0eab60Smacallan 128ba0eab60Smacallan 129ba0eab60Smacallan# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 130ba0eab60Smacallan# is ksh but when the shell is invoked as "sh" and the current value of 131ba0eab60Smacallan# the _XPG environment variable is not equal to 1 (one), the special 132ba0eab60Smacallan# positional parameter $0, within a function call, is the name of the 133ba0eab60Smacallan# function. 134ba0eab60Smacallanprogpath="$0" 135ba0eab60Smacallan 136aee7dae4Smrg 137aee7dae4Smrg 138aee7dae4Smrg: ${CP="cp -f"} 139aee7dae4Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 140aee7dae4Smrg: ${MAKE="make"} 141aee7dae4Smrg: ${MKDIR="mkdir"} 142aee7dae4Smrg: ${MV="mv -f"} 143aee7dae4Smrg: ${RM="rm -f"} 144aee7dae4Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 145aee7dae4Smrg: ${Xsed="$SED -e 1s/^X//"} 146ba0eab60Smacallan 147ba0eab60Smacallan# Global variables: 148ba0eab60SmacallanEXIT_SUCCESS=0 149ba0eab60SmacallanEXIT_FAILURE=1 150aee7dae4SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 151aee7dae4SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 152ba0eab60Smacallan 153aee7dae4Smrgexit_status=$EXIT_SUCCESS 154ba0eab60Smacallan 155aee7dae4Smrg# Make sure IFS has a sensible default 156aee7dae4Smrglt_nl=' 157aee7dae4Smrg' 158aee7dae4SmrgIFS=" $lt_nl" 159ba0eab60Smacallan 160aee7dae4Smrgdirname="s,/[^/]*$,," 161aee7dae4Smrgbasename="s,^.*/,," 162ba0eab60Smacallan 163aee7dae4Smrg# func_dirname file append nondir_replacement 164aee7dae4Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 165aee7dae4Smrg# otherwise set result to NONDIR_REPLACEMENT. 166aee7dae4Smrgfunc_dirname () 167aee7dae4Smrg{ 168aee7dae4Smrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 169aee7dae4Smrg if test "X$func_dirname_result" = "X${1}"; then 170aee7dae4Smrg func_dirname_result="${3}" 171aee7dae4Smrg else 172aee7dae4Smrg func_dirname_result="$func_dirname_result${2}" 173aee7dae4Smrg fi 174aee7dae4Smrg} # func_dirname may be replaced by extended shell implementation 175ba0eab60Smacallan 176aee7dae4Smrg 177aee7dae4Smrg# func_basename file 178aee7dae4Smrgfunc_basename () 179aee7dae4Smrg{ 180aee7dae4Smrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 181aee7dae4Smrg} # func_basename may be replaced by extended shell implementation 182aee7dae4Smrg 183aee7dae4Smrg 184aee7dae4Smrg# func_dirname_and_basename file append nondir_replacement 185aee7dae4Smrg# perform func_basename and func_dirname in a single function 186aee7dae4Smrg# call: 187aee7dae4Smrg# dirname: Compute the dirname of FILE. If nonempty, 188aee7dae4Smrg# add APPEND to the result, otherwise set result 189aee7dae4Smrg# to NONDIR_REPLACEMENT. 190aee7dae4Smrg# value returned in "$func_dirname_result" 191aee7dae4Smrg# basename: Compute filename of FILE. 192aee7dae4Smrg# value retuned in "$func_basename_result" 193aee7dae4Smrg# Implementation must be kept synchronized with func_dirname 194aee7dae4Smrg# and func_basename. For efficiency, we do not delegate to 195aee7dae4Smrg# those functions but instead duplicate the functionality here. 196aee7dae4Smrgfunc_dirname_and_basename () 197aee7dae4Smrg{ 198aee7dae4Smrg # Extract subdirectory from the argument. 199aee7dae4Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 200aee7dae4Smrg if test "X$func_dirname_result" = "X${1}"; then 201aee7dae4Smrg func_dirname_result="${3}" 202aee7dae4Smrg else 203aee7dae4Smrg func_dirname_result="$func_dirname_result${2}" 204aee7dae4Smrg fi 205aee7dae4Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 206aee7dae4Smrg} # func_dirname_and_basename may be replaced by extended shell implementation 207aee7dae4Smrg 208aee7dae4Smrg 209aee7dae4Smrg# func_stripname prefix suffix name 210aee7dae4Smrg# strip PREFIX and SUFFIX off of NAME. 211aee7dae4Smrg# PREFIX and SUFFIX must not contain globbing or regex special 212aee7dae4Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 213aee7dae4Smrg# dot (in which case that matches only a dot). 214aee7dae4Smrg# func_strip_suffix prefix name 215aee7dae4Smrgfunc_stripname () 216aee7dae4Smrg{ 217aee7dae4Smrg case ${2} in 218aee7dae4Smrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 219aee7dae4Smrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 220aee7dae4Smrg esac 221aee7dae4Smrg} # func_stripname may be replaced by extended shell implementation 222aee7dae4Smrg 223aee7dae4Smrg 224aee7dae4Smrg# These SED scripts presuppose an absolute path with a trailing slash. 225aee7dae4Smrgpathcar='s,^/\([^/]*\).*$,\1,' 226aee7dae4Smrgpathcdr='s,^/[^/]*,,' 227aee7dae4Smrgremovedotparts=':dotsl 228aee7dae4Smrg s@/\./@/@g 229aee7dae4Smrg t dotsl 230aee7dae4Smrg s,/\.$,/,' 231aee7dae4Smrgcollapseslashes='s@/\{1,\}@/@g' 232aee7dae4Smrgfinalslash='s,/*$,/,' 233aee7dae4Smrg 234aee7dae4Smrg# func_normal_abspath PATH 235aee7dae4Smrg# Remove doubled-up and trailing slashes, "." path components, 236aee7dae4Smrg# and cancel out any ".." path components in PATH after making 237aee7dae4Smrg# it an absolute path. 238aee7dae4Smrg# value returned in "$func_normal_abspath_result" 239aee7dae4Smrgfunc_normal_abspath () 240aee7dae4Smrg{ 241aee7dae4Smrg # Start from root dir and reassemble the path. 242aee7dae4Smrg func_normal_abspath_result= 243aee7dae4Smrg func_normal_abspath_tpath=$1 244aee7dae4Smrg func_normal_abspath_altnamespace= 245aee7dae4Smrg case $func_normal_abspath_tpath in 246aee7dae4Smrg "") 247aee7dae4Smrg # Empty path, that just means $cwd. 248aee7dae4Smrg func_stripname '' '/' "`pwd`" 249aee7dae4Smrg func_normal_abspath_result=$func_stripname_result 250aee7dae4Smrg return 251aee7dae4Smrg ;; 252aee7dae4Smrg # The next three entries are used to spot a run of precisely 253aee7dae4Smrg # two leading slashes without using negated character classes; 254aee7dae4Smrg # we take advantage of case's first-match behaviour. 255aee7dae4Smrg ///*) 256aee7dae4Smrg # Unusual form of absolute path, do nothing. 257aee7dae4Smrg ;; 258aee7dae4Smrg //*) 259aee7dae4Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 260aee7dae4Smrg # and for example Cygwin uses it to access remote file shares 261aee7dae4Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 262aee7dae4Smrg func_normal_abspath_altnamespace=/ 263aee7dae4Smrg ;; 264aee7dae4Smrg /*) 265aee7dae4Smrg # Absolute path, do nothing. 266aee7dae4Smrg ;; 267aee7dae4Smrg *) 268aee7dae4Smrg # Relative path, prepend $cwd. 269aee7dae4Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 270aee7dae4Smrg ;; 271aee7dae4Smrg esac 272aee7dae4Smrg # Cancel out all the simple stuff to save iterations. We also want 273aee7dae4Smrg # the path to end with a slash for ease of parsing, so make sure 274aee7dae4Smrg # there is one (and only one) here. 275aee7dae4Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 276aee7dae4Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 277aee7dae4Smrg while :; do 278aee7dae4Smrg # Processed it all yet? 279aee7dae4Smrg if test "$func_normal_abspath_tpath" = / ; then 280aee7dae4Smrg # If we ascended to the root using ".." the result may be empty now. 281aee7dae4Smrg if test -z "$func_normal_abspath_result" ; then 282aee7dae4Smrg func_normal_abspath_result=/ 283aee7dae4Smrg fi 284aee7dae4Smrg break 285aee7dae4Smrg fi 286aee7dae4Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 287aee7dae4Smrg -e "$pathcar"` 288aee7dae4Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 289aee7dae4Smrg -e "$pathcdr"` 290aee7dae4Smrg # Figure out what to do with it 291aee7dae4Smrg case $func_normal_abspath_tcomponent in 292aee7dae4Smrg "") 293aee7dae4Smrg # Trailing empty path component, ignore it. 294aee7dae4Smrg ;; 295aee7dae4Smrg ..) 296aee7dae4Smrg # Parent dir; strip last assembled component from result. 297aee7dae4Smrg func_dirname "$func_normal_abspath_result" 298aee7dae4Smrg func_normal_abspath_result=$func_dirname_result 299aee7dae4Smrg ;; 300aee7dae4Smrg *) 301aee7dae4Smrg # Actual path component, append it. 302aee7dae4Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 303aee7dae4Smrg ;; 304aee7dae4Smrg esac 305aee7dae4Smrg done 306aee7dae4Smrg # Restore leading double-slash if one was found on entry. 307aee7dae4Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 308aee7dae4Smrg} 309aee7dae4Smrg 310aee7dae4Smrg# func_relative_path SRCDIR DSTDIR 311aee7dae4Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 312aee7dae4Smrg# slash if non-empty, suitable for immediately appending a filename 313aee7dae4Smrg# without needing to append a separator. 314aee7dae4Smrg# value returned in "$func_relative_path_result" 315aee7dae4Smrgfunc_relative_path () 316aee7dae4Smrg{ 317aee7dae4Smrg func_relative_path_result= 318aee7dae4Smrg func_normal_abspath "$1" 319aee7dae4Smrg func_relative_path_tlibdir=$func_normal_abspath_result 320aee7dae4Smrg func_normal_abspath "$2" 321aee7dae4Smrg func_relative_path_tbindir=$func_normal_abspath_result 322aee7dae4Smrg 323aee7dae4Smrg # Ascend the tree starting from libdir 324aee7dae4Smrg while :; do 325aee7dae4Smrg # check if we have found a prefix of bindir 326aee7dae4Smrg case $func_relative_path_tbindir in 327aee7dae4Smrg $func_relative_path_tlibdir) 328aee7dae4Smrg # found an exact match 329aee7dae4Smrg func_relative_path_tcancelled= 330aee7dae4Smrg break 331aee7dae4Smrg ;; 332aee7dae4Smrg $func_relative_path_tlibdir*) 333aee7dae4Smrg # found a matching prefix 334aee7dae4Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 335aee7dae4Smrg func_relative_path_tcancelled=$func_stripname_result 336aee7dae4Smrg if test -z "$func_relative_path_result"; then 337aee7dae4Smrg func_relative_path_result=. 338aee7dae4Smrg fi 339aee7dae4Smrg break 340aee7dae4Smrg ;; 341aee7dae4Smrg *) 342aee7dae4Smrg func_dirname $func_relative_path_tlibdir 343aee7dae4Smrg func_relative_path_tlibdir=${func_dirname_result} 344aee7dae4Smrg if test "x$func_relative_path_tlibdir" = x ; then 345aee7dae4Smrg # Have to descend all the way to the root! 346aee7dae4Smrg func_relative_path_result=../$func_relative_path_result 347aee7dae4Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 348aee7dae4Smrg break 349aee7dae4Smrg fi 350aee7dae4Smrg func_relative_path_result=../$func_relative_path_result 351aee7dae4Smrg ;; 352aee7dae4Smrg esac 353aee7dae4Smrg done 354aee7dae4Smrg 355aee7dae4Smrg # Now calculate path; take care to avoid doubling-up slashes. 356aee7dae4Smrg func_stripname '' '/' "$func_relative_path_result" 357aee7dae4Smrg func_relative_path_result=$func_stripname_result 358aee7dae4Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 359aee7dae4Smrg if test "x$func_stripname_result" != x ; then 360aee7dae4Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 361aee7dae4Smrg fi 362aee7dae4Smrg 363aee7dae4Smrg # Normalisation. If bindir is libdir, return empty string, 364aee7dae4Smrg # else relative path ending with a slash; either way, target 365aee7dae4Smrg # file name can be directly appended. 366aee7dae4Smrg if test ! -z "$func_relative_path_result"; then 367aee7dae4Smrg func_stripname './' '' "$func_relative_path_result/" 368aee7dae4Smrg func_relative_path_result=$func_stripname_result 369aee7dae4Smrg fi 370aee7dae4Smrg} 371aee7dae4Smrg 372aee7dae4Smrg# The name of this program: 373aee7dae4Smrgfunc_dirname_and_basename "$progpath" 374aee7dae4Smrgprogname=$func_basename_result 375aee7dae4Smrg 376aee7dae4Smrg# Make sure we have an absolute path for reexecution: 377aee7dae4Smrgcase $progpath in 378aee7dae4Smrg [\\/]*|[A-Za-z]:\\*) ;; 379aee7dae4Smrg *[\\/]*) 380aee7dae4Smrg progdir=$func_dirname_result 381aee7dae4Smrg progdir=`cd "$progdir" && pwd` 382aee7dae4Smrg progpath="$progdir/$progname" 383aee7dae4Smrg ;; 384aee7dae4Smrg *) 385aee7dae4Smrg save_IFS="$IFS" 386aee7dae4Smrg IFS=${PATH_SEPARATOR-:} 387aee7dae4Smrg for progdir in $PATH; do 388aee7dae4Smrg IFS="$save_IFS" 389aee7dae4Smrg test -x "$progdir/$progname" && break 390aee7dae4Smrg done 391aee7dae4Smrg IFS="$save_IFS" 392aee7dae4Smrg test -n "$progdir" || progdir=`pwd` 393aee7dae4Smrg progpath="$progdir/$progname" 394aee7dae4Smrg ;; 395aee7dae4Smrgesac 396ba0eab60Smacallan 397ba0eab60Smacallan# Sed substitution that helps us do robust quoting. It backslashifies 398ba0eab60Smacallan# metacharacters that are still active within double-quoted strings. 399ba0eab60SmacallanXsed="${SED}"' -e 1s/^X//' 400aee7dae4Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 401aee7dae4Smrg 402aee7dae4Smrg# Same as above, but do not quote variable references. 403aee7dae4Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 404aee7dae4Smrg 405aee7dae4Smrg# Sed substitution that turns a string into a regex matching for the 406aee7dae4Smrg# string literally. 407aee7dae4Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 408aee7dae4Smrg 409aee7dae4Smrg# Sed substitution that converts a w32 file name or path 410aee7dae4Smrg# which contains forward slashes, into one that contains 411aee7dae4Smrg# (escaped) backslashes. A very naive implementation. 412aee7dae4Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 413aee7dae4Smrg 414aee7dae4Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 415aee7dae4Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 416aee7dae4Smrg# in input to double_quote_subst, that '$' was protected from expansion. 417aee7dae4Smrg# Since each input `\' is now two `\'s, look for any number of runs of 418aee7dae4Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 419aee7dae4Smrgbs='\\' 420aee7dae4Smrgbs2='\\\\' 421aee7dae4Smrgbs4='\\\\\\\\' 422aee7dae4Smrgdollar='\$' 423aee7dae4Smrgsed_double_backslash="\ 424aee7dae4Smrg s/$bs4/&\\ 425aee7dae4Smrg/g 426aee7dae4Smrg s/^$bs2$dollar/$bs&/ 427aee7dae4Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 428aee7dae4Smrg s/\n//g" 429aee7dae4Smrg 430aee7dae4Smrg# Standard options: 431aee7dae4Smrgopt_dry_run=false 432aee7dae4Smrgopt_help=false 433aee7dae4Smrgopt_quiet=false 434aee7dae4Smrgopt_verbose=false 435aee7dae4Smrgopt_warning=: 436aee7dae4Smrg 437aee7dae4Smrg# func_echo arg... 438aee7dae4Smrg# Echo program name prefixed message, along with the current mode 439aee7dae4Smrg# name if it has been set yet. 440aee7dae4Smrgfunc_echo () 441aee7dae4Smrg{ 442aee7dae4Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 443aee7dae4Smrg} 444ba0eab60Smacallan 445aee7dae4Smrg# func_verbose arg... 446aee7dae4Smrg# Echo program name prefixed message in verbose mode only. 447aee7dae4Smrgfunc_verbose () 448aee7dae4Smrg{ 449aee7dae4Smrg $opt_verbose && func_echo ${1+"$@"} 450ba0eab60Smacallan 451aee7dae4Smrg # A bug in bash halts the script if the last line of a function 452aee7dae4Smrg # fails when set -e is in force, so we need another command to 453aee7dae4Smrg # work around that: 454aee7dae4Smrg : 455aee7dae4Smrg} 456ba0eab60Smacallan 457aee7dae4Smrg# func_echo_all arg... 458aee7dae4Smrg# Invoke $ECHO with all args, space-separated. 459aee7dae4Smrgfunc_echo_all () 460aee7dae4Smrg{ 461aee7dae4Smrg $ECHO "$*" 462aee7dae4Smrg} 463ba0eab60Smacallan 464aee7dae4Smrg# func_error arg... 465aee7dae4Smrg# Echo program name prefixed message to standard error. 466aee7dae4Smrgfunc_error () 467aee7dae4Smrg{ 468aee7dae4Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 469aee7dae4Smrg} 470aee7dae4Smrg 471aee7dae4Smrg# func_warning arg... 472aee7dae4Smrg# Echo program name prefixed warning message to standard error. 473aee7dae4Smrgfunc_warning () 474aee7dae4Smrg{ 475aee7dae4Smrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 476aee7dae4Smrg 477aee7dae4Smrg # bash bug again: 478aee7dae4Smrg : 479aee7dae4Smrg} 480aee7dae4Smrg 481aee7dae4Smrg# func_fatal_error arg... 482aee7dae4Smrg# Echo program name prefixed message to standard error, and exit. 483aee7dae4Smrgfunc_fatal_error () 484aee7dae4Smrg{ 485aee7dae4Smrg func_error ${1+"$@"} 486aee7dae4Smrg exit $EXIT_FAILURE 487aee7dae4Smrg} 488aee7dae4Smrg 489aee7dae4Smrg# func_fatal_help arg... 490aee7dae4Smrg# Echo program name prefixed message to standard error, followed by 491aee7dae4Smrg# a help hint, and exit. 492aee7dae4Smrgfunc_fatal_help () 493aee7dae4Smrg{ 494aee7dae4Smrg func_error ${1+"$@"} 495aee7dae4Smrg func_fatal_error "$help" 496aee7dae4Smrg} 497aee7dae4Smrghelp="Try \`$progname --help' for more information." ## default 498aee7dae4Smrg 499aee7dae4Smrg 500aee7dae4Smrg# func_grep expression filename 501aee7dae4Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 502aee7dae4Smrgfunc_grep () 503aee7dae4Smrg{ 504aee7dae4Smrg $GREP "$1" "$2" >/dev/null 2>&1 505aee7dae4Smrg} 506aee7dae4Smrg 507aee7dae4Smrg 508aee7dae4Smrg# func_mkdir_p directory-path 509aee7dae4Smrg# Make sure the entire path to DIRECTORY-PATH is available. 510aee7dae4Smrgfunc_mkdir_p () 511aee7dae4Smrg{ 512aee7dae4Smrg my_directory_path="$1" 513aee7dae4Smrg my_dir_list= 514aee7dae4Smrg 515aee7dae4Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 516aee7dae4Smrg 517aee7dae4Smrg # Protect directory names starting with `-' 518aee7dae4Smrg case $my_directory_path in 519aee7dae4Smrg -*) my_directory_path="./$my_directory_path" ;; 520aee7dae4Smrg esac 521aee7dae4Smrg 522aee7dae4Smrg # While some portion of DIR does not yet exist... 523aee7dae4Smrg while test ! -d "$my_directory_path"; do 524aee7dae4Smrg # ...make a list in topmost first order. Use a colon delimited 525aee7dae4Smrg # list incase some portion of path contains whitespace. 526aee7dae4Smrg my_dir_list="$my_directory_path:$my_dir_list" 527aee7dae4Smrg 528aee7dae4Smrg # If the last portion added has no slash in it, the list is done 529aee7dae4Smrg case $my_directory_path in */*) ;; *) break ;; esac 530aee7dae4Smrg 531aee7dae4Smrg # ...otherwise throw away the child directory and loop 532aee7dae4Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 533aee7dae4Smrg done 534aee7dae4Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 535aee7dae4Smrg 536aee7dae4Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 537aee7dae4Smrg for my_dir in $my_dir_list; do 538aee7dae4Smrg IFS="$save_mkdir_p_IFS" 539aee7dae4Smrg # mkdir can fail with a `File exist' error if two processes 540aee7dae4Smrg # try to create one of the directories concurrently. Don't 541aee7dae4Smrg # stop in that case! 542aee7dae4Smrg $MKDIR "$my_dir" 2>/dev/null || : 543aee7dae4Smrg done 544aee7dae4Smrg IFS="$save_mkdir_p_IFS" 545aee7dae4Smrg 546aee7dae4Smrg # Bail out if we (or some other process) failed to create a directory. 547aee7dae4Smrg test -d "$my_directory_path" || \ 548aee7dae4Smrg func_fatal_error "Failed to create \`$1'" 549aee7dae4Smrg fi 550aee7dae4Smrg} 551ba0eab60Smacallan 552ba0eab60Smacallan 553ba0eab60Smacallan# func_mktempdir [string] 554ba0eab60Smacallan# Make a temporary directory that won't clash with other running 555ba0eab60Smacallan# libtool processes, and avoids race conditions if possible. If 556ba0eab60Smacallan# given, STRING is the basename for that directory. 557ba0eab60Smacallanfunc_mktempdir () 558ba0eab60Smacallan{ 559ba0eab60Smacallan my_template="${TMPDIR-/tmp}/${1-$progname}" 560ba0eab60Smacallan 561aee7dae4Smrg if test "$opt_dry_run" = ":"; then 562ba0eab60Smacallan # Return a directory name, but don't create it in dry-run mode 563ba0eab60Smacallan my_tmpdir="${my_template}-$$" 564ba0eab60Smacallan else 565ba0eab60Smacallan 566ba0eab60Smacallan # If mktemp works, use that first and foremost 567ba0eab60Smacallan my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 568ba0eab60Smacallan 569ba0eab60Smacallan if test ! -d "$my_tmpdir"; then 570aee7dae4Smrg # Failing that, at least try and use $RANDOM to avoid a race 571aee7dae4Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 572ba0eab60Smacallan 573aee7dae4Smrg save_mktempdir_umask=`umask` 574aee7dae4Smrg umask 0077 575aee7dae4Smrg $MKDIR "$my_tmpdir" 576aee7dae4Smrg umask $save_mktempdir_umask 577ba0eab60Smacallan fi 578ba0eab60Smacallan 579ba0eab60Smacallan # If we're not in dry-run mode, bomb out on failure 580aee7dae4Smrg test -d "$my_tmpdir" || \ 581aee7dae4Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 582ba0eab60Smacallan fi 583ba0eab60Smacallan 584aee7dae4Smrg $ECHO "$my_tmpdir" 585ba0eab60Smacallan} 586ba0eab60Smacallan 587ba0eab60Smacallan 588aee7dae4Smrg# func_quote_for_eval arg 589aee7dae4Smrg# Aesthetically quote ARG to be evaled later. 590aee7dae4Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 591aee7dae4Smrg# is double-quoted, suitable for a subsequent eval, whereas 592aee7dae4Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 593aee7dae4Smrg# which are still active within double quotes backslashified. 594aee7dae4Smrgfunc_quote_for_eval () 595ba0eab60Smacallan{ 596aee7dae4Smrg case $1 in 597aee7dae4Smrg *[\\\`\"\$]*) 598aee7dae4Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 599aee7dae4Smrg *) 600aee7dae4Smrg func_quote_for_eval_unquoted_result="$1" ;; 601aee7dae4Smrg esac 602aee7dae4Smrg 603aee7dae4Smrg case $func_quote_for_eval_unquoted_result in 604aee7dae4Smrg # Double-quote args containing shell metacharacters to delay 605aee7dae4Smrg # word splitting, command substitution and and variable 606aee7dae4Smrg # expansion for a subsequent eval. 607aee7dae4Smrg # Many Bourne shells cannot handle close brackets correctly 608aee7dae4Smrg # in scan sets, so we specify it separately. 609aee7dae4Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 610aee7dae4Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 611aee7dae4Smrg ;; 612aee7dae4Smrg *) 613aee7dae4Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 614ba0eab60Smacallan esac 615ba0eab60Smacallan} 616ba0eab60Smacallan 617ba0eab60Smacallan 618aee7dae4Smrg# func_quote_for_expand arg 619aee7dae4Smrg# Aesthetically quote ARG to be evaled later; same as above, 620aee7dae4Smrg# but do not quote variable references. 621aee7dae4Smrgfunc_quote_for_expand () 622ba0eab60Smacallan{ 623aee7dae4Smrg case $1 in 624aee7dae4Smrg *[\\\`\"]*) 625aee7dae4Smrg my_arg=`$ECHO "$1" | $SED \ 626aee7dae4Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 627ba0eab60Smacallan *) 628aee7dae4Smrg my_arg="$1" ;; 629aee7dae4Smrg esac 630aee7dae4Smrg 631aee7dae4Smrg case $my_arg in 632aee7dae4Smrg # Double-quote args containing shell metacharacters to delay 633aee7dae4Smrg # word splitting and command substitution for a subsequent eval. 634aee7dae4Smrg # Many Bourne shells cannot handle close brackets correctly 635aee7dae4Smrg # in scan sets, so we specify it separately. 636aee7dae4Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 637aee7dae4Smrg my_arg="\"$my_arg\"" 638aee7dae4Smrg ;; 639aee7dae4Smrg esac 640aee7dae4Smrg 641aee7dae4Smrg func_quote_for_expand_result="$my_arg" 642ba0eab60Smacallan} 643ba0eab60Smacallan 644ba0eab60Smacallan 645aee7dae4Smrg# func_show_eval cmd [fail_exp] 646aee7dae4Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 647aee7dae4Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 648aee7dae4Smrg# is given, then evaluate it. 649aee7dae4Smrgfunc_show_eval () 650ba0eab60Smacallan{ 651aee7dae4Smrg my_cmd="$1" 652aee7dae4Smrg my_fail_exp="${2-:}" 653ba0eab60Smacallan 654aee7dae4Smrg ${opt_silent-false} || { 655aee7dae4Smrg func_quote_for_expand "$my_cmd" 656aee7dae4Smrg eval "func_echo $func_quote_for_expand_result" 657aee7dae4Smrg } 658aee7dae4Smrg 659aee7dae4Smrg if ${opt_dry_run-false}; then :; else 660aee7dae4Smrg eval "$my_cmd" 661aee7dae4Smrg my_status=$? 662aee7dae4Smrg if test "$my_status" -eq 0; then :; else 663aee7dae4Smrg eval "(exit $my_status); $my_fail_exp" 664aee7dae4Smrg fi 665ba0eab60Smacallan fi 666ba0eab60Smacallan} 667ba0eab60Smacallan 668aee7dae4Smrg 669aee7dae4Smrg# func_show_eval_locale cmd [fail_exp] 670aee7dae4Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 671aee7dae4Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 672aee7dae4Smrg# is given, then evaluate it. Use the saved locale for evaluation. 673aee7dae4Smrgfunc_show_eval_locale () 674ba0eab60Smacallan{ 675aee7dae4Smrg my_cmd="$1" 676aee7dae4Smrg my_fail_exp="${2-:}" 677ba0eab60Smacallan 678aee7dae4Smrg ${opt_silent-false} || { 679aee7dae4Smrg func_quote_for_expand "$my_cmd" 680aee7dae4Smrg eval "func_echo $func_quote_for_expand_result" 681aee7dae4Smrg } 682ba0eab60Smacallan 683aee7dae4Smrg if ${opt_dry_run-false}; then :; else 684aee7dae4Smrg eval "$lt_user_locale 685aee7dae4Smrg $my_cmd" 686aee7dae4Smrg my_status=$? 687aee7dae4Smrg eval "$lt_safe_locale" 688aee7dae4Smrg if test "$my_status" -eq 0; then :; else 689aee7dae4Smrg eval "(exit $my_status); $my_fail_exp" 690ba0eab60Smacallan fi 691aee7dae4Smrg fi 692ba0eab60Smacallan} 693ba0eab60Smacallan 694aee7dae4Smrg# func_tr_sh 695aee7dae4Smrg# Turn $1 into a string suitable for a shell variable name. 696aee7dae4Smrg# Result is stored in $func_tr_sh_result. All characters 697aee7dae4Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 698aee7dae4Smrg# if $1 begins with a digit, a '_' is prepended as well. 699aee7dae4Smrgfunc_tr_sh () 700aee7dae4Smrg{ 701aee7dae4Smrg case $1 in 702aee7dae4Smrg [0-9]* | *[!a-zA-Z0-9_]*) 703aee7dae4Smrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 704aee7dae4Smrg ;; 705aee7dae4Smrg * ) 706aee7dae4Smrg func_tr_sh_result=$1 707aee7dae4Smrg ;; 708ba0eab60Smacallan esac 709aee7dae4Smrg} 710ba0eab60Smacallan 711ba0eab60Smacallan 712aee7dae4Smrg# func_version 713aee7dae4Smrg# Echo version message to standard output and exit. 714aee7dae4Smrgfunc_version () 715aee7dae4Smrg{ 716aee7dae4Smrg $opt_debug 717aee7dae4Smrg 718aee7dae4Smrg $SED -n '/(C)/!b go 719aee7dae4Smrg :more 720aee7dae4Smrg /\./!{ 721aee7dae4Smrg N 722aee7dae4Smrg s/\n# / / 723aee7dae4Smrg b more 724aee7dae4Smrg } 725aee7dae4Smrg :go 726aee7dae4Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 727aee7dae4Smrg s/^# // 728aee7dae4Smrg s/^# *$// 729aee7dae4Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 730aee7dae4Smrg p 731aee7dae4Smrg }' < "$progpath" 732aee7dae4Smrg exit $? 733aee7dae4Smrg} 734ba0eab60Smacallan 735aee7dae4Smrg# func_usage 736aee7dae4Smrg# Echo short help message to standard output and exit. 737aee7dae4Smrgfunc_usage () 738aee7dae4Smrg{ 739aee7dae4Smrg $opt_debug 740aee7dae4Smrg 741aee7dae4Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 742aee7dae4Smrg s/^# // 743aee7dae4Smrg s/^# *$// 744aee7dae4Smrg s/\$progname/'$progname'/ 745aee7dae4Smrg p 746aee7dae4Smrg }' < "$progpath" 747aee7dae4Smrg echo 748aee7dae4Smrg $ECHO "run \`$progname --help | more' for full usage" 749aee7dae4Smrg exit $? 750aee7dae4Smrg} 751ba0eab60Smacallan 752aee7dae4Smrg# func_help [NOEXIT] 753aee7dae4Smrg# Echo long help message to standard output and exit, 754aee7dae4Smrg# unless 'noexit' is passed as argument. 755aee7dae4Smrgfunc_help () 756aee7dae4Smrg{ 757aee7dae4Smrg $opt_debug 758aee7dae4Smrg 759aee7dae4Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 760aee7dae4Smrg :print 761aee7dae4Smrg s/^# // 762aee7dae4Smrg s/^# *$// 763aee7dae4Smrg s*\$progname*'$progname'* 764aee7dae4Smrg s*\$host*'"$host"'* 765aee7dae4Smrg s*\$SHELL*'"$SHELL"'* 766aee7dae4Smrg s*\$LTCC*'"$LTCC"'* 767aee7dae4Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 768aee7dae4Smrg s*\$LD*'"$LD"'* 769aee7dae4Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 770aee7dae4Smrg s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 771aee7dae4Smrg s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 772aee7dae4Smrg p 773aee7dae4Smrg d 774aee7dae4Smrg } 775aee7dae4Smrg /^# .* home page:/b print 776aee7dae4Smrg /^# General help using/b print 777aee7dae4Smrg ' < "$progpath" 778aee7dae4Smrg ret=$? 779aee7dae4Smrg if test -z "$1"; then 780aee7dae4Smrg exit $ret 781aee7dae4Smrg fi 782aee7dae4Smrg} 783ba0eab60Smacallan 784aee7dae4Smrg# func_missing_arg argname 785aee7dae4Smrg# Echo program name prefixed message to standard error and set global 786aee7dae4Smrg# exit_cmd. 787aee7dae4Smrgfunc_missing_arg () 788aee7dae4Smrg{ 789aee7dae4Smrg $opt_debug 790ba0eab60Smacallan 791aee7dae4Smrg func_error "missing argument for $1." 792aee7dae4Smrg exit_cmd=exit 793aee7dae4Smrg} 794ba0eab60Smacallan 795ba0eab60Smacallan 796aee7dae4Smrg# func_split_short_opt shortopt 797aee7dae4Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 798aee7dae4Smrg# variables after splitting SHORTOPT after the 2nd character. 799aee7dae4Smrgfunc_split_short_opt () 800aee7dae4Smrg{ 801aee7dae4Smrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 802aee7dae4Smrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 803ba0eab60Smacallan 804aee7dae4Smrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 805aee7dae4Smrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 806aee7dae4Smrg} # func_split_short_opt may be replaced by extended shell implementation 807ba0eab60Smacallan 808ba0eab60Smacallan 809aee7dae4Smrg# func_split_long_opt longopt 810aee7dae4Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 811aee7dae4Smrg# variables after splitting LONGOPT at the `=' sign. 812aee7dae4Smrgfunc_split_long_opt () 813aee7dae4Smrg{ 814aee7dae4Smrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 815aee7dae4Smrg my_sed_long_arg='1s/^--[^=]*=//' 816ba0eab60Smacallan 817aee7dae4Smrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 818aee7dae4Smrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 819aee7dae4Smrg} # func_split_long_opt may be replaced by extended shell implementation 820ba0eab60Smacallan 821aee7dae4Smrgexit_cmd=: 822ba0eab60Smacallan 823ba0eab60Smacallan 824ba0eab60Smacallan 825ba0eab60Smacallan 826ba0eab60Smacallan 827aee7dae4Smrgmagic="%%%MAGIC variable%%%" 828aee7dae4Smrgmagic_exe="%%%MAGIC EXE variable%%%" 829ba0eab60Smacallan 830aee7dae4Smrg# Global variables. 831aee7dae4Smrgnonopt= 832aee7dae4Smrgpreserve_args= 833aee7dae4Smrglo2o="s/\\.lo\$/.${objext}/" 834aee7dae4Smrgo2lo="s/\\.${objext}\$/.lo/" 835aee7dae4Smrgextracted_archives= 836aee7dae4Smrgextracted_serial=0 837ba0eab60Smacallan 838ba0eab60Smacallan# If this variable is set in any of the actions, the command in it 839ba0eab60Smacallan# will be execed at the end. This prevents here-documents from being 840ba0eab60Smacallan# left over by shells. 841ba0eab60Smacallanexec_cmd= 842ba0eab60Smacallan 843aee7dae4Smrg# func_append var value 844aee7dae4Smrg# Append VALUE to the end of shell variable VAR. 845aee7dae4Smrgfunc_append () 846aee7dae4Smrg{ 847aee7dae4Smrg eval "${1}=\$${1}\${2}" 848aee7dae4Smrg} # func_append may be replaced by extended shell implementation 849ba0eab60Smacallan 850aee7dae4Smrg# func_append_quoted var value 851aee7dae4Smrg# Quote VALUE and append to the end of shell variable VAR, separated 852aee7dae4Smrg# by a space. 853aee7dae4Smrgfunc_append_quoted () 854aee7dae4Smrg{ 855aee7dae4Smrg func_quote_for_eval "${2}" 856aee7dae4Smrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 857aee7dae4Smrg} # func_append_quoted may be replaced by extended shell implementation 858ba0eab60Smacallan 859ba0eab60Smacallan 860aee7dae4Smrg# func_arith arithmetic-term... 861aee7dae4Smrgfunc_arith () 862aee7dae4Smrg{ 863aee7dae4Smrg func_arith_result=`expr "${@}"` 864aee7dae4Smrg} # func_arith may be replaced by extended shell implementation 865ba0eab60Smacallan 866ba0eab60Smacallan 867aee7dae4Smrg# func_len string 868aee7dae4Smrg# STRING may not start with a hyphen. 869aee7dae4Smrgfunc_len () 870aee7dae4Smrg{ 871aee7dae4Smrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 872aee7dae4Smrg} # func_len may be replaced by extended shell implementation 873ba0eab60Smacallan 874ba0eab60Smacallan 875aee7dae4Smrg# func_lo2o object 876aee7dae4Smrgfunc_lo2o () 877aee7dae4Smrg{ 878aee7dae4Smrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 879aee7dae4Smrg} # func_lo2o may be replaced by extended shell implementation 880ba0eab60Smacallan 881ba0eab60Smacallan 882aee7dae4Smrg# func_xform libobj-or-source 883aee7dae4Smrgfunc_xform () 884aee7dae4Smrg{ 885aee7dae4Smrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 886aee7dae4Smrg} # func_xform may be replaced by extended shell implementation 887ba0eab60Smacallan 888ba0eab60Smacallan 889aee7dae4Smrg# func_fatal_configuration arg... 890aee7dae4Smrg# Echo program name prefixed message to standard error, followed by 891aee7dae4Smrg# a configuration failure hint, and exit. 892aee7dae4Smrgfunc_fatal_configuration () 893aee7dae4Smrg{ 894aee7dae4Smrg func_error ${1+"$@"} 895aee7dae4Smrg func_error "See the $PACKAGE documentation for more information." 896aee7dae4Smrg func_fatal_error "Fatal configuration error." 897aee7dae4Smrg} 898ba0eab60Smacallan 899ba0eab60Smacallan 900aee7dae4Smrg# func_config 901aee7dae4Smrg# Display the configuration for all the tags in this script. 902aee7dae4Smrgfunc_config () 903aee7dae4Smrg{ 904aee7dae4Smrg re_begincf='^# ### BEGIN LIBTOOL' 905aee7dae4Smrg re_endcf='^# ### END LIBTOOL' 906ba0eab60Smacallan 907aee7dae4Smrg # Default configuration. 908aee7dae4Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 909ba0eab60Smacallan 910aee7dae4Smrg # Now print the configurations for the tags. 911aee7dae4Smrg for tagname in $taglist; do 912aee7dae4Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 913aee7dae4Smrg done 914ba0eab60Smacallan 915aee7dae4Smrg exit $? 916aee7dae4Smrg} 917ba0eab60Smacallan 918aee7dae4Smrg# func_features 919aee7dae4Smrg# Display the features supported by this script. 920aee7dae4Smrgfunc_features () 921aee7dae4Smrg{ 922aee7dae4Smrg echo "host: $host" 923aee7dae4Smrg if test "$build_libtool_libs" = yes; then 924aee7dae4Smrg echo "enable shared libraries" 925aee7dae4Smrg else 926aee7dae4Smrg echo "disable shared libraries" 927aee7dae4Smrg fi 928aee7dae4Smrg if test "$build_old_libs" = yes; then 929aee7dae4Smrg echo "enable static libraries" 930aee7dae4Smrg else 931aee7dae4Smrg echo "disable static libraries" 932aee7dae4Smrg fi 933ba0eab60Smacallan 934aee7dae4Smrg exit $? 935aee7dae4Smrg} 936ba0eab60Smacallan 937aee7dae4Smrg# func_enable_tag tagname 938aee7dae4Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 939aee7dae4Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 940aee7dae4Smrg# variable here. 941aee7dae4Smrgfunc_enable_tag () 942aee7dae4Smrg{ 943aee7dae4Smrg # Global variable: 944aee7dae4Smrg tagname="$1" 945aee7dae4Smrg 946aee7dae4Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 947aee7dae4Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 948aee7dae4Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 949aee7dae4Smrg 950aee7dae4Smrg # Validate tagname. 951aee7dae4Smrg case $tagname in 952aee7dae4Smrg *[!-_A-Za-z0-9,/]*) 953aee7dae4Smrg func_fatal_error "invalid tag name: $tagname" 954ba0eab60Smacallan ;; 955aee7dae4Smrg esac 956ba0eab60Smacallan 957aee7dae4Smrg # Don't test for the "default" C tag, as we know it's 958aee7dae4Smrg # there but not specially marked. 959aee7dae4Smrg case $tagname in 960aee7dae4Smrg CC) ;; 961ba0eab60Smacallan *) 962aee7dae4Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 963aee7dae4Smrg taglist="$taglist $tagname" 964aee7dae4Smrg 965aee7dae4Smrg # Evaluate the configuration. Be careful to quote the path 966aee7dae4Smrg # and the sed script, to avoid splitting on whitespace, but 967aee7dae4Smrg # also don't use non-portable quotes within backquotes within 968aee7dae4Smrg # quotes we have to do it in 2 steps: 969aee7dae4Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 970aee7dae4Smrg eval "$extractedcf" 971aee7dae4Smrg else 972aee7dae4Smrg func_error "ignoring unknown tag $tagname" 973aee7dae4Smrg fi 974ba0eab60Smacallan ;; 975aee7dae4Smrg esac 976aee7dae4Smrg} 977ba0eab60Smacallan 978aee7dae4Smrg# func_check_version_match 979aee7dae4Smrg# Ensure that we are using m4 macros, and libtool script from the same 980aee7dae4Smrg# release of libtool. 981aee7dae4Smrgfunc_check_version_match () 982aee7dae4Smrg{ 983aee7dae4Smrg if test "$package_revision" != "$macro_revision"; then 984aee7dae4Smrg if test "$VERSION" != "$macro_version"; then 985aee7dae4Smrg if test -z "$macro_version"; then 986aee7dae4Smrg cat >&2 <<_LT_EOF 987aee7dae4Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 988aee7dae4Smrg$progname: definition of this LT_INIT comes from an older release. 989aee7dae4Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 990aee7dae4Smrg$progname: and run autoconf again. 991aee7dae4Smrg_LT_EOF 992aee7dae4Smrg else 993aee7dae4Smrg cat >&2 <<_LT_EOF 994aee7dae4Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 995aee7dae4Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 996aee7dae4Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 997aee7dae4Smrg$progname: and run autoconf again. 998aee7dae4Smrg_LT_EOF 999aee7dae4Smrg fi 1000ba0eab60Smacallan else 1001aee7dae4Smrg cat >&2 <<_LT_EOF 1002aee7dae4Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 1003aee7dae4Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 1004aee7dae4Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 1005aee7dae4Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 1006aee7dae4Smrg_LT_EOF 1007ba0eab60Smacallan fi 1008ba0eab60Smacallan 1009aee7dae4Smrg exit $EXIT_MISMATCH 1010aee7dae4Smrg fi 1011aee7dae4Smrg} 1012ba0eab60Smacallan 1013ba0eab60Smacallan 1014aee7dae4Smrg# Shorthand for --mode=foo, only valid as the first argument 1015aee7dae4Smrgcase $1 in 1016aee7dae4Smrgclean|clea|cle|cl) 1017aee7dae4Smrg shift; set dummy --mode clean ${1+"$@"}; shift 1018aee7dae4Smrg ;; 1019aee7dae4Smrgcompile|compil|compi|comp|com|co|c) 1020aee7dae4Smrg shift; set dummy --mode compile ${1+"$@"}; shift 1021aee7dae4Smrg ;; 1022aee7dae4Smrgexecute|execut|execu|exec|exe|ex|e) 1023aee7dae4Smrg shift; set dummy --mode execute ${1+"$@"}; shift 1024aee7dae4Smrg ;; 1025aee7dae4Smrgfinish|finis|fini|fin|fi|f) 1026aee7dae4Smrg shift; set dummy --mode finish ${1+"$@"}; shift 1027aee7dae4Smrg ;; 1028aee7dae4Smrginstall|instal|insta|inst|ins|in|i) 1029aee7dae4Smrg shift; set dummy --mode install ${1+"$@"}; shift 1030aee7dae4Smrg ;; 1031aee7dae4Smrglink|lin|li|l) 1032aee7dae4Smrg shift; set dummy --mode link ${1+"$@"}; shift 1033aee7dae4Smrg ;; 1034aee7dae4Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 1035aee7dae4Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 1036aee7dae4Smrg ;; 1037aee7dae4Smrgesac 1038ba0eab60Smacallan 1039ba0eab60Smacallan 1040ba0eab60Smacallan 1041aee7dae4Smrg# Option defaults: 1042aee7dae4Smrgopt_debug=: 1043aee7dae4Smrgopt_dry_run=false 1044aee7dae4Smrgopt_config=false 1045aee7dae4Smrgopt_preserve_dup_deps=false 1046aee7dae4Smrgopt_features=false 1047aee7dae4Smrgopt_finish=false 1048aee7dae4Smrgopt_help=false 1049aee7dae4Smrgopt_help_all=false 1050aee7dae4Smrgopt_silent=: 1051aee7dae4Smrgopt_warning=: 1052aee7dae4Smrgopt_verbose=: 1053aee7dae4Smrgopt_silent=false 1054aee7dae4Smrgopt_verbose=false 1055ba0eab60Smacallan 1056ba0eab60Smacallan 1057aee7dae4Smrg# Parse options once, thoroughly. This comes as soon as possible in the 1058aee7dae4Smrg# script to make things like `--version' happen as quickly as we can. 1059aee7dae4Smrg{ 1060aee7dae4Smrg # this just eases exit handling 1061aee7dae4Smrg while test $# -gt 0; do 1062aee7dae4Smrg opt="$1" 1063aee7dae4Smrg shift 1064aee7dae4Smrg case $opt in 1065aee7dae4Smrg --debug|-x) opt_debug='set -x' 1066aee7dae4Smrg func_echo "enabling shell trace mode" 1067aee7dae4Smrg $opt_debug 1068aee7dae4Smrg ;; 1069aee7dae4Smrg --dry-run|--dryrun|-n) 1070aee7dae4Smrg opt_dry_run=: 1071aee7dae4Smrg ;; 1072aee7dae4Smrg --config) 1073aee7dae4Smrg opt_config=: 1074aee7dae4Smrgfunc_config 1075aee7dae4Smrg ;; 1076aee7dae4Smrg --dlopen|-dlopen) 1077aee7dae4Smrg optarg="$1" 1078aee7dae4Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 1079aee7dae4Smrg}$optarg" 1080aee7dae4Smrg shift 1081aee7dae4Smrg ;; 1082aee7dae4Smrg --preserve-dup-deps) 1083aee7dae4Smrg opt_preserve_dup_deps=: 1084aee7dae4Smrg ;; 1085aee7dae4Smrg --features) 1086aee7dae4Smrg opt_features=: 1087aee7dae4Smrgfunc_features 1088aee7dae4Smrg ;; 1089aee7dae4Smrg --finish) 1090aee7dae4Smrg opt_finish=: 1091aee7dae4Smrgset dummy --mode finish ${1+"$@"}; shift 1092aee7dae4Smrg ;; 1093aee7dae4Smrg --help) 1094aee7dae4Smrg opt_help=: 1095aee7dae4Smrg ;; 1096aee7dae4Smrg --help-all) 1097aee7dae4Smrg opt_help_all=: 1098aee7dae4Smrgopt_help=': help-all' 1099aee7dae4Smrg ;; 1100aee7dae4Smrg --mode) 1101aee7dae4Smrg test $# = 0 && func_missing_arg $opt && break 1102aee7dae4Smrg optarg="$1" 1103aee7dae4Smrg opt_mode="$optarg" 1104aee7dae4Smrgcase $optarg in 1105aee7dae4Smrg # Valid mode arguments: 1106aee7dae4Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 1107aee7dae4Smrg 1108aee7dae4Smrg # Catch anything else as an error 1109aee7dae4Smrg *) func_error "invalid argument for $opt" 1110aee7dae4Smrg exit_cmd=exit 1111aee7dae4Smrg break 1112aee7dae4Smrg ;; 1113aee7dae4Smrgesac 1114aee7dae4Smrg shift 1115aee7dae4Smrg ;; 1116aee7dae4Smrg --no-silent|--no-quiet) 1117aee7dae4Smrg opt_silent=false 1118aee7dae4Smrgfunc_append preserve_args " $opt" 1119aee7dae4Smrg ;; 1120aee7dae4Smrg --no-warning|--no-warn) 1121aee7dae4Smrg opt_warning=false 1122aee7dae4Smrgfunc_append preserve_args " $opt" 1123aee7dae4Smrg ;; 1124aee7dae4Smrg --no-verbose) 1125aee7dae4Smrg opt_verbose=false 1126aee7dae4Smrgfunc_append preserve_args " $opt" 1127aee7dae4Smrg ;; 1128aee7dae4Smrg --silent|--quiet) 1129aee7dae4Smrg opt_silent=: 1130aee7dae4Smrgfunc_append preserve_args " $opt" 1131aee7dae4Smrg opt_verbose=false 1132aee7dae4Smrg ;; 1133aee7dae4Smrg --verbose|-v) 1134aee7dae4Smrg opt_verbose=: 1135aee7dae4Smrgfunc_append preserve_args " $opt" 1136aee7dae4Smrgopt_silent=false 1137aee7dae4Smrg ;; 1138aee7dae4Smrg --tag) 1139aee7dae4Smrg test $# = 0 && func_missing_arg $opt && break 1140aee7dae4Smrg optarg="$1" 1141aee7dae4Smrg opt_tag="$optarg" 1142aee7dae4Smrgfunc_append preserve_args " $opt $optarg" 1143aee7dae4Smrgfunc_enable_tag "$optarg" 1144aee7dae4Smrg shift 1145aee7dae4Smrg ;; 1146ba0eab60Smacallan 1147aee7dae4Smrg -\?|-h) func_usage ;; 1148aee7dae4Smrg --help) func_help ;; 1149aee7dae4Smrg --version) func_version ;; 1150ba0eab60Smacallan 1151aee7dae4Smrg # Separate optargs to long options: 1152aee7dae4Smrg --*=*) 1153aee7dae4Smrg func_split_long_opt "$opt" 1154aee7dae4Smrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 1155aee7dae4Smrg shift 1156aee7dae4Smrg ;; 1157ba0eab60Smacallan 1158aee7dae4Smrg # Separate non-argument short options: 1159aee7dae4Smrg -\?*|-h*|-n*|-v*) 1160aee7dae4Smrg func_split_short_opt "$opt" 1161aee7dae4Smrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 1162aee7dae4Smrg shift 1163aee7dae4Smrg ;; 1164ba0eab60Smacallan 1165aee7dae4Smrg --) break ;; 1166aee7dae4Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 1167aee7dae4Smrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1168aee7dae4Smrg esac 1169aee7dae4Smrg done 1170ba0eab60Smacallan 1171aee7dae4Smrg # Validate options: 1172ba0eab60Smacallan 1173aee7dae4Smrg # save first non-option argument 1174aee7dae4Smrg if test "$#" -gt 0; then 1175aee7dae4Smrg nonopt="$opt" 1176aee7dae4Smrg shift 1177aee7dae4Smrg fi 1178ba0eab60Smacallan 1179aee7dae4Smrg # preserve --debug 1180aee7dae4Smrg test "$opt_debug" = : || func_append preserve_args " --debug" 1181ba0eab60Smacallan 1182aee7dae4Smrg case $host in 1183aee7dae4Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 1184aee7dae4Smrg # don't eliminate duplications in $postdeps and $predeps 1185aee7dae4Smrg opt_duplicate_compiler_generated_deps=: 1186aee7dae4Smrg ;; 1187aee7dae4Smrg *) 1188aee7dae4Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 1189aee7dae4Smrg ;; 1190aee7dae4Smrg esac 1191ba0eab60Smacallan 1192aee7dae4Smrg $opt_help || { 1193aee7dae4Smrg # Sanity checks first: 1194aee7dae4Smrg func_check_version_match 1195ba0eab60Smacallan 1196aee7dae4Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 1197aee7dae4Smrg func_fatal_configuration "not configured to build any kind of library" 1198aee7dae4Smrg fi 1199ba0eab60Smacallan 1200aee7dae4Smrg # Darwin sucks 1201aee7dae4Smrg eval std_shrext=\"$shrext_cmds\" 1202ba0eab60Smacallan 1203aee7dae4Smrg # Only execute mode is allowed to have -dlopen flags. 1204aee7dae4Smrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 1205aee7dae4Smrg func_error "unrecognized option \`-dlopen'" 1206aee7dae4Smrg $ECHO "$help" 1>&2 1207aee7dae4Smrg exit $EXIT_FAILURE 1208aee7dae4Smrg fi 1209ba0eab60Smacallan 1210aee7dae4Smrg # Change the help message to a mode-specific one. 1211aee7dae4Smrg generic_help="$help" 1212aee7dae4Smrg help="Try \`$progname --help --mode=$opt_mode' for more information." 1213aee7dae4Smrg } 1214ba0eab60Smacallan 1215ba0eab60Smacallan 1216aee7dae4Smrg # Bail if the options were screwed 1217aee7dae4Smrg $exit_cmd $EXIT_FAILURE 1218aee7dae4Smrg} 1219ba0eab60Smacallan 1220ba0eab60Smacallan 1221ba0eab60Smacallan 1222ba0eab60Smacallan 1223aee7dae4Smrg## ----------- ## 1224aee7dae4Smrg## Main. ## 1225aee7dae4Smrg## ----------- ## 1226ba0eab60Smacallan 1227aee7dae4Smrg# func_lalib_p file 1228aee7dae4Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1229aee7dae4Smrg# This function is only a basic sanity check; it will hardly flush out 1230aee7dae4Smrg# determined imposters. 1231aee7dae4Smrgfunc_lalib_p () 1232aee7dae4Smrg{ 1233aee7dae4Smrg test -f "$1" && 1234aee7dae4Smrg $SED -e 4q "$1" 2>/dev/null \ 1235aee7dae4Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 1236aee7dae4Smrg} 1237ba0eab60Smacallan 1238aee7dae4Smrg# func_lalib_unsafe_p file 1239aee7dae4Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 1240aee7dae4Smrg# This function implements the same check as func_lalib_p without 1241aee7dae4Smrg# resorting to external programs. To this end, it redirects stdin and 1242aee7dae4Smrg# closes it afterwards, without saving the original file descriptor. 1243aee7dae4Smrg# As a safety measure, use it only where a negative result would be 1244aee7dae4Smrg# fatal anyway. Works if `file' does not exist. 1245aee7dae4Smrgfunc_lalib_unsafe_p () 1246aee7dae4Smrg{ 1247aee7dae4Smrg lalib_p=no 1248aee7dae4Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 1249aee7dae4Smrg for lalib_p_l in 1 2 3 4 1250aee7dae4Smrg do 1251aee7dae4Smrg read lalib_p_line 1252aee7dae4Smrg case "$lalib_p_line" in 1253aee7dae4Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 1254aee7dae4Smrg esac 1255aee7dae4Smrg done 1256aee7dae4Smrg exec 0<&5 5<&- 1257aee7dae4Smrg fi 1258aee7dae4Smrg test "$lalib_p" = yes 1259aee7dae4Smrg} 1260ba0eab60Smacallan 1261aee7dae4Smrg# func_ltwrapper_script_p file 1262aee7dae4Smrg# True iff FILE is a libtool wrapper script 1263aee7dae4Smrg# This function is only a basic sanity check; it will hardly flush out 1264aee7dae4Smrg# determined imposters. 1265aee7dae4Smrgfunc_ltwrapper_script_p () 1266aee7dae4Smrg{ 1267aee7dae4Smrg func_lalib_p "$1" 1268aee7dae4Smrg} 1269ba0eab60Smacallan 1270aee7dae4Smrg# func_ltwrapper_executable_p file 1271aee7dae4Smrg# True iff FILE is a libtool wrapper executable 1272aee7dae4Smrg# This function is only a basic sanity check; it will hardly flush out 1273aee7dae4Smrg# determined imposters. 1274aee7dae4Smrgfunc_ltwrapper_executable_p () 1275aee7dae4Smrg{ 1276aee7dae4Smrg func_ltwrapper_exec_suffix= 1277aee7dae4Smrg case $1 in 1278aee7dae4Smrg *.exe) ;; 1279aee7dae4Smrg *) func_ltwrapper_exec_suffix=.exe ;; 1280aee7dae4Smrg esac 1281aee7dae4Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 1282aee7dae4Smrg} 1283ba0eab60Smacallan 1284aee7dae4Smrg# func_ltwrapper_scriptname file 1285aee7dae4Smrg# Assumes file is an ltwrapper_executable 1286aee7dae4Smrg# uses $file to determine the appropriate filename for a 1287aee7dae4Smrg# temporary ltwrapper_script. 1288aee7dae4Smrgfunc_ltwrapper_scriptname () 1289aee7dae4Smrg{ 1290aee7dae4Smrg func_dirname_and_basename "$1" "" "." 1291aee7dae4Smrg func_stripname '' '.exe' "$func_basename_result" 1292aee7dae4Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 1293aee7dae4Smrg} 1294ba0eab60Smacallan 1295aee7dae4Smrg# func_ltwrapper_p file 1296aee7dae4Smrg# True iff FILE is a libtool wrapper script or wrapper executable 1297aee7dae4Smrg# This function is only a basic sanity check; it will hardly flush out 1298aee7dae4Smrg# determined imposters. 1299aee7dae4Smrgfunc_ltwrapper_p () 1300aee7dae4Smrg{ 1301aee7dae4Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 1302aee7dae4Smrg} 1303ba0eab60Smacallan 1304ba0eab60Smacallan 1305aee7dae4Smrg# func_execute_cmds commands fail_cmd 1306aee7dae4Smrg# Execute tilde-delimited COMMANDS. 1307aee7dae4Smrg# If FAIL_CMD is given, eval that upon failure. 1308aee7dae4Smrg# FAIL_CMD may read-access the current command in variable CMD! 1309aee7dae4Smrgfunc_execute_cmds () 1310aee7dae4Smrg{ 1311aee7dae4Smrg $opt_debug 1312aee7dae4Smrg save_ifs=$IFS; IFS='~' 1313aee7dae4Smrg for cmd in $1; do 1314aee7dae4Smrg IFS=$save_ifs 1315aee7dae4Smrg eval cmd=\"$cmd\" 1316aee7dae4Smrg func_show_eval "$cmd" "${2-:}" 1317aee7dae4Smrg done 1318aee7dae4Smrg IFS=$save_ifs 1319aee7dae4Smrg} 1320ba0eab60Smacallan 1321ba0eab60Smacallan 1322aee7dae4Smrg# func_source file 1323aee7dae4Smrg# Source FILE, adding directory component if necessary. 1324aee7dae4Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 1325aee7dae4Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 1326aee7dae4Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 1327aee7dae4Smrg# `FILE.' does not work on cygwin managed mounts. 1328aee7dae4Smrgfunc_source () 1329aee7dae4Smrg{ 1330aee7dae4Smrg $opt_debug 1331aee7dae4Smrg case $1 in 1332aee7dae4Smrg */* | *\\*) . "$1" ;; 1333aee7dae4Smrg *) . "./$1" ;; 1334aee7dae4Smrg esac 1335aee7dae4Smrg} 1336ba0eab60Smacallan 1337ba0eab60Smacallan 1338aee7dae4Smrg# func_resolve_sysroot PATH 1339aee7dae4Smrg# Replace a leading = in PATH with a sysroot. Store the result into 1340aee7dae4Smrg# func_resolve_sysroot_result 1341aee7dae4Smrgfunc_resolve_sysroot () 1342aee7dae4Smrg{ 1343aee7dae4Smrg func_resolve_sysroot_result=$1 1344aee7dae4Smrg case $func_resolve_sysroot_result in 1345aee7dae4Smrg =*) 1346aee7dae4Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 1347aee7dae4Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 1348ba0eab60Smacallan ;; 1349aee7dae4Smrg esac 1350aee7dae4Smrg} 1351ba0eab60Smacallan 1352aee7dae4Smrg# func_replace_sysroot PATH 1353aee7dae4Smrg# If PATH begins with the sysroot, replace it with = and 1354aee7dae4Smrg# store the result into func_replace_sysroot_result. 1355aee7dae4Smrgfunc_replace_sysroot () 1356aee7dae4Smrg{ 1357aee7dae4Smrg case "$lt_sysroot:$1" in 1358aee7dae4Smrg ?*:"$lt_sysroot"*) 1359aee7dae4Smrg func_stripname "$lt_sysroot" '' "$1" 1360aee7dae4Smrg func_replace_sysroot_result="=$func_stripname_result" 1361aee7dae4Smrg ;; 1362aee7dae4Smrg *) 1363aee7dae4Smrg # Including no sysroot. 1364aee7dae4Smrg func_replace_sysroot_result=$1 1365aee7dae4Smrg ;; 1366aee7dae4Smrg esac 1367aee7dae4Smrg} 1368ba0eab60Smacallan 1369aee7dae4Smrg# func_infer_tag arg 1370aee7dae4Smrg# Infer tagged configuration to use if any are available and 1371aee7dae4Smrg# if one wasn't chosen via the "--tag" command line option. 1372aee7dae4Smrg# Only attempt this if the compiler in the base compile 1373aee7dae4Smrg# command doesn't match the default compiler. 1374aee7dae4Smrg# arg is usually of the form 'gcc ...' 1375aee7dae4Smrgfunc_infer_tag () 1376aee7dae4Smrg{ 1377aee7dae4Smrg $opt_debug 1378aee7dae4Smrg if test -n "$available_tags" && test -z "$tagname"; then 1379aee7dae4Smrg CC_quoted= 1380aee7dae4Smrg for arg in $CC; do 1381aee7dae4Smrg func_append_quoted CC_quoted "$arg" 1382aee7dae4Smrg done 1383aee7dae4Smrg CC_expanded=`func_echo_all $CC` 1384aee7dae4Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1385aee7dae4Smrg case $@ in 1386aee7dae4Smrg # Blanks in the command may have been stripped by the calling shell, 1387aee7dae4Smrg # but not from the CC environment variable when configure was run. 1388aee7dae4Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1389aee7dae4Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 1390aee7dae4Smrg # Blanks at the start of $base_compile will cause this to fail 1391aee7dae4Smrg # if we don't check for them as well. 1392aee7dae4Smrg *) 1393aee7dae4Smrg for z in $available_tags; do 1394aee7dae4Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 1395aee7dae4Smrg # Evaluate the configuration. 1396aee7dae4Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 1397aee7dae4Smrg CC_quoted= 1398aee7dae4Smrg for arg in $CC; do 1399aee7dae4Smrg # Double-quote args containing other shell metacharacters. 1400aee7dae4Smrg func_append_quoted CC_quoted "$arg" 1401aee7dae4Smrg done 1402aee7dae4Smrg CC_expanded=`func_echo_all $CC` 1403aee7dae4Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 1404aee7dae4Smrg case "$@ " in 1405aee7dae4Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1406aee7dae4Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 1407aee7dae4Smrg # The compiler in the base compile command matches 1408aee7dae4Smrg # the one in the tagged configuration. 1409aee7dae4Smrg # Assume this is the tagged configuration we want. 1410aee7dae4Smrg tagname=$z 1411aee7dae4Smrg break 1412aee7dae4Smrg ;; 1413aee7dae4Smrg esac 1414ba0eab60Smacallan fi 1415aee7dae4Smrg done 1416aee7dae4Smrg # If $tagname still isn't set, then no tagged configuration 1417aee7dae4Smrg # was found and let the user know that the "--tag" command 1418aee7dae4Smrg # line option must be used. 1419aee7dae4Smrg if test -z "$tagname"; then 1420aee7dae4Smrg func_echo "unable to infer tagged configuration" 1421aee7dae4Smrg func_fatal_error "specify a tag with \`--tag'" 1422aee7dae4Smrg# else 1423aee7dae4Smrg# func_verbose "using $tagname tagged configuration" 1424aee7dae4Smrg fi 1425ba0eab60Smacallan ;; 1426ba0eab60Smacallan esac 1427aee7dae4Smrg fi 1428aee7dae4Smrg} 1429ba0eab60Smacallan 1430ba0eab60Smacallan 1431ba0eab60Smacallan 1432aee7dae4Smrg# func_write_libtool_object output_name pic_name nonpic_name 1433aee7dae4Smrg# Create a libtool object file (analogous to a ".la" file), 1434aee7dae4Smrg# but don't create it if we're doing a dry run. 1435aee7dae4Smrgfunc_write_libtool_object () 1436aee7dae4Smrg{ 1437aee7dae4Smrg write_libobj=${1} 1438aee7dae4Smrg if test "$build_libtool_libs" = yes; then 1439aee7dae4Smrg write_lobj=\'${2}\' 1440aee7dae4Smrg else 1441aee7dae4Smrg write_lobj=none 1442aee7dae4Smrg fi 1443ba0eab60Smacallan 1444aee7dae4Smrg if test "$build_old_libs" = yes; then 1445aee7dae4Smrg write_oldobj=\'${3}\' 1446aee7dae4Smrg else 1447aee7dae4Smrg write_oldobj=none 1448aee7dae4Smrg fi 1449ba0eab60Smacallan 1450aee7dae4Smrg $opt_dry_run || { 1451aee7dae4Smrg cat >${write_libobj}T <<EOF 1452aee7dae4Smrg# $write_libobj - a libtool object file 1453aee7dae4Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1454aee7dae4Smrg# 1455aee7dae4Smrg# Please DO NOT delete this file! 1456aee7dae4Smrg# It is necessary for linking the library. 1457ba0eab60Smacallan 1458aee7dae4Smrg# Name of the PIC object. 1459aee7dae4Smrgpic_object=$write_lobj 1460ba0eab60Smacallan 1461aee7dae4Smrg# Name of the non-PIC object 1462aee7dae4Smrgnon_pic_object=$write_oldobj 1463ba0eab60Smacallan 1464aee7dae4SmrgEOF 1465aee7dae4Smrg $MV "${write_libobj}T" "${write_libobj}" 1466aee7dae4Smrg } 1467aee7dae4Smrg} 1468ba0eab60Smacallan 1469ba0eab60Smacallan 1470aee7dae4Smrg################################################## 1471aee7dae4Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 1472aee7dae4Smrg################################################## 1473ba0eab60Smacallan 1474aee7dae4Smrg# func_convert_core_file_wine_to_w32 ARG 1475aee7dae4Smrg# Helper function used by file name conversion functions when $build is *nix, 1476aee7dae4Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 1477aee7dae4Smrg# correctly configured wine environment available, with the winepath program 1478aee7dae4Smrg# in $build's $PATH. 1479aee7dae4Smrg# 1480aee7dae4Smrg# ARG is the $build file name to be converted to w32 format. 1481aee7dae4Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 1482aee7dae4Smrg# be empty on error (or when ARG is empty) 1483aee7dae4Smrgfunc_convert_core_file_wine_to_w32 () 1484aee7dae4Smrg{ 1485aee7dae4Smrg $opt_debug 1486aee7dae4Smrg func_convert_core_file_wine_to_w32_result="$1" 1487aee7dae4Smrg if test -n "$1"; then 1488aee7dae4Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 1489aee7dae4Smrg # are forced to check the contents of stdout. On the other hand, if the 1490aee7dae4Smrg # command is not found, the shell will set an exit code of 127 and print 1491aee7dae4Smrg # *an error message* to stdout. So we must check for both error code of 1492aee7dae4Smrg # zero AND non-empty stdout, which explains the odd construction: 1493aee7dae4Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 1494aee7dae4Smrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 1495aee7dae4Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 1496aee7dae4Smrg $SED -e "$lt_sed_naive_backslashify"` 1497aee7dae4Smrg else 1498aee7dae4Smrg func_convert_core_file_wine_to_w32_result= 1499aee7dae4Smrg fi 1500aee7dae4Smrg fi 1501aee7dae4Smrg} 1502aee7dae4Smrg# end: func_convert_core_file_wine_to_w32 1503ba0eab60Smacallan 1504ba0eab60Smacallan 1505aee7dae4Smrg# func_convert_core_path_wine_to_w32 ARG 1506aee7dae4Smrg# Helper function used by path conversion functions when $build is *nix, and 1507aee7dae4Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 1508aee7dae4Smrg# configured wine environment available, with the winepath program in $build's 1509aee7dae4Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 1510aee7dae4Smrg# 1511aee7dae4Smrg# ARG is path to be converted from $build format to win32. 1512aee7dae4Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 1513aee7dae4Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 1514aee7dae4Smrg# are convertible, then the result may be empty. 1515aee7dae4Smrgfunc_convert_core_path_wine_to_w32 () 1516aee7dae4Smrg{ 1517aee7dae4Smrg $opt_debug 1518aee7dae4Smrg # unfortunately, winepath doesn't convert paths, only file names 1519aee7dae4Smrg func_convert_core_path_wine_to_w32_result="" 1520aee7dae4Smrg if test -n "$1"; then 1521aee7dae4Smrg oldIFS=$IFS 1522aee7dae4Smrg IFS=: 1523aee7dae4Smrg for func_convert_core_path_wine_to_w32_f in $1; do 1524aee7dae4Smrg IFS=$oldIFS 1525aee7dae4Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 1526aee7dae4Smrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 1527aee7dae4Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 1528aee7dae4Smrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 1529aee7dae4Smrg else 1530aee7dae4Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 1531aee7dae4Smrg fi 1532aee7dae4Smrg fi 1533aee7dae4Smrg done 1534aee7dae4Smrg IFS=$oldIFS 1535aee7dae4Smrg fi 1536aee7dae4Smrg} 1537aee7dae4Smrg# end: func_convert_core_path_wine_to_w32 1538aee7dae4Smrg 1539aee7dae4Smrg 1540aee7dae4Smrg# func_cygpath ARGS... 1541aee7dae4Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 1542aee7dae4Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 1543aee7dae4Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 1544aee7dae4Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 1545aee7dae4Smrg# file name or path is assumed to be in w32 format, as previously converted 1546aee7dae4Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 1547aee7dae4Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 1548aee7dae4Smrg# Cygwin format). Returns an empty string on error. 1549aee7dae4Smrg# 1550aee7dae4Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 1551aee7dae4Smrg# be converted. 1552aee7dae4Smrg# 1553aee7dae4Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 1554aee7dae4Smrg# environment variable; do not put it in $PATH. 1555aee7dae4Smrgfunc_cygpath () 1556aee7dae4Smrg{ 1557aee7dae4Smrg $opt_debug 1558aee7dae4Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 1559aee7dae4Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 1560aee7dae4Smrg if test "$?" -ne 0; then 1561aee7dae4Smrg # on failure, ensure result is empty 1562aee7dae4Smrg func_cygpath_result= 1563aee7dae4Smrg fi 1564aee7dae4Smrg else 1565aee7dae4Smrg func_cygpath_result= 1566aee7dae4Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 1567aee7dae4Smrg fi 1568aee7dae4Smrg} 1569aee7dae4Smrg#end: func_cygpath 1570ba0eab60Smacallan 1571ba0eab60Smacallan 1572aee7dae4Smrg# func_convert_core_msys_to_w32 ARG 1573aee7dae4Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 1574aee7dae4Smrg# result in func_convert_core_msys_to_w32_result. 1575aee7dae4Smrgfunc_convert_core_msys_to_w32 () 1576aee7dae4Smrg{ 1577aee7dae4Smrg $opt_debug 1578aee7dae4Smrg # awkward: cmd appends spaces to result 1579aee7dae4Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 1580aee7dae4Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 1581aee7dae4Smrg} 1582aee7dae4Smrg#end: func_convert_core_msys_to_w32 1583ba0eab60Smacallan 1584ba0eab60Smacallan 1585aee7dae4Smrg# func_convert_file_check ARG1 ARG2 1586aee7dae4Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 1587aee7dae4Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 1588aee7dae4Smrg# func_to_host_file_result to ARG1). 1589aee7dae4Smrgfunc_convert_file_check () 1590aee7dae4Smrg{ 1591aee7dae4Smrg $opt_debug 1592aee7dae4Smrg if test -z "$2" && test -n "$1" ; then 1593aee7dae4Smrg func_error "Could not determine host file name corresponding to" 1594aee7dae4Smrg func_error " \`$1'" 1595aee7dae4Smrg func_error "Continuing, but uninstalled executables may not work." 1596aee7dae4Smrg # Fallback: 1597aee7dae4Smrg func_to_host_file_result="$1" 1598aee7dae4Smrg fi 1599aee7dae4Smrg} 1600aee7dae4Smrg# end func_convert_file_check 1601ba0eab60Smacallan 1602ba0eab60Smacallan 1603aee7dae4Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 1604aee7dae4Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 1605aee7dae4Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 1606aee7dae4Smrg# func_to_host_file_result to a simplistic fallback value (see below). 1607aee7dae4Smrgfunc_convert_path_check () 1608aee7dae4Smrg{ 1609aee7dae4Smrg $opt_debug 1610aee7dae4Smrg if test -z "$4" && test -n "$3"; then 1611aee7dae4Smrg func_error "Could not determine the host path corresponding to" 1612aee7dae4Smrg func_error " \`$3'" 1613aee7dae4Smrg func_error "Continuing, but uninstalled executables may not work." 1614aee7dae4Smrg # Fallback. This is a deliberately simplistic "conversion" and 1615aee7dae4Smrg # should not be "improved". See libtool.info. 1616aee7dae4Smrg if test "x$1" != "x$2"; then 1617aee7dae4Smrg lt_replace_pathsep_chars="s|$1|$2|g" 1618aee7dae4Smrg func_to_host_path_result=`echo "$3" | 1619aee7dae4Smrg $SED -e "$lt_replace_pathsep_chars"` 1620aee7dae4Smrg else 1621aee7dae4Smrg func_to_host_path_result="$3" 1622aee7dae4Smrg fi 1623aee7dae4Smrg fi 1624aee7dae4Smrg} 1625aee7dae4Smrg# end func_convert_path_check 1626ba0eab60Smacallan 1627ba0eab60Smacallan 1628aee7dae4Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 1629aee7dae4Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 1630aee7dae4Smrg# and appending REPL if ORIG matches BACKPAT. 1631aee7dae4Smrgfunc_convert_path_front_back_pathsep () 1632aee7dae4Smrg{ 1633aee7dae4Smrg $opt_debug 1634aee7dae4Smrg case $4 in 1635aee7dae4Smrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 1636aee7dae4Smrg ;; 1637aee7dae4Smrg esac 1638aee7dae4Smrg case $4 in 1639aee7dae4Smrg $2 ) func_append func_to_host_path_result "$3" 1640aee7dae4Smrg ;; 1641aee7dae4Smrg esac 1642aee7dae4Smrg} 1643aee7dae4Smrg# end func_convert_path_front_back_pathsep 1644ba0eab60Smacallan 1645ba0eab60Smacallan 1646aee7dae4Smrg################################################## 1647aee7dae4Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 1648aee7dae4Smrg################################################## 1649aee7dae4Smrg# invoked via `$to_host_file_cmd ARG' 1650aee7dae4Smrg# 1651aee7dae4Smrg# In each case, ARG is the path to be converted from $build to $host format. 1652aee7dae4Smrg# Result will be available in $func_to_host_file_result. 1653ba0eab60Smacallan 1654ba0eab60Smacallan 1655aee7dae4Smrg# func_to_host_file ARG 1656aee7dae4Smrg# Converts the file name ARG from $build format to $host format. Return result 1657aee7dae4Smrg# in func_to_host_file_result. 1658aee7dae4Smrgfunc_to_host_file () 1659aee7dae4Smrg{ 1660aee7dae4Smrg $opt_debug 1661aee7dae4Smrg $to_host_file_cmd "$1" 1662aee7dae4Smrg} 1663aee7dae4Smrg# end func_to_host_file 1664ba0eab60Smacallan 1665ba0eab60Smacallan 1666aee7dae4Smrg# func_to_tool_file ARG LAZY 1667aee7dae4Smrg# converts the file name ARG from $build format to toolchain format. Return 1668aee7dae4Smrg# result in func_to_tool_file_result. If the conversion in use is listed 1669aee7dae4Smrg# in (the comma separated) LAZY, no conversion takes place. 1670aee7dae4Smrgfunc_to_tool_file () 1671aee7dae4Smrg{ 1672aee7dae4Smrg $opt_debug 1673aee7dae4Smrg case ,$2, in 1674aee7dae4Smrg *,"$to_tool_file_cmd",*) 1675aee7dae4Smrg func_to_tool_file_result=$1 1676aee7dae4Smrg ;; 1677aee7dae4Smrg *) 1678aee7dae4Smrg $to_tool_file_cmd "$1" 1679aee7dae4Smrg func_to_tool_file_result=$func_to_host_file_result 1680aee7dae4Smrg ;; 1681aee7dae4Smrg esac 1682aee7dae4Smrg} 1683aee7dae4Smrg# end func_to_tool_file 1684ba0eab60Smacallan 1685ba0eab60Smacallan 1686aee7dae4Smrg# func_convert_file_noop ARG 1687aee7dae4Smrg# Copy ARG to func_to_host_file_result. 1688aee7dae4Smrgfunc_convert_file_noop () 1689aee7dae4Smrg{ 1690aee7dae4Smrg func_to_host_file_result="$1" 1691aee7dae4Smrg} 1692aee7dae4Smrg# end func_convert_file_noop 1693ba0eab60Smacallan 1694ba0eab60Smacallan 1695aee7dae4Smrg# func_convert_file_msys_to_w32 ARG 1696aee7dae4Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 1697aee7dae4Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 1698aee7dae4Smrg# func_to_host_file_result. 1699aee7dae4Smrgfunc_convert_file_msys_to_w32 () 1700aee7dae4Smrg{ 1701aee7dae4Smrg $opt_debug 1702aee7dae4Smrg func_to_host_file_result="$1" 1703aee7dae4Smrg if test -n "$1"; then 1704aee7dae4Smrg func_convert_core_msys_to_w32 "$1" 1705aee7dae4Smrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 1706aee7dae4Smrg fi 1707aee7dae4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1708aee7dae4Smrg} 1709aee7dae4Smrg# end func_convert_file_msys_to_w32 1710ba0eab60Smacallan 1711ba0eab60Smacallan 1712aee7dae4Smrg# func_convert_file_cygwin_to_w32 ARG 1713aee7dae4Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 1714aee7dae4Smrg# func_to_host_file_result. 1715aee7dae4Smrgfunc_convert_file_cygwin_to_w32 () 1716aee7dae4Smrg{ 1717aee7dae4Smrg $opt_debug 1718aee7dae4Smrg func_to_host_file_result="$1" 1719aee7dae4Smrg if test -n "$1"; then 1720aee7dae4Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 1721aee7dae4Smrg # LT_CYGPATH in this case. 1722aee7dae4Smrg func_to_host_file_result=`cygpath -m "$1"` 1723aee7dae4Smrg fi 1724aee7dae4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1725aee7dae4Smrg} 1726aee7dae4Smrg# end func_convert_file_cygwin_to_w32 1727ba0eab60Smacallan 1728ba0eab60Smacallan 1729aee7dae4Smrg# func_convert_file_nix_to_w32 ARG 1730aee7dae4Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 1731aee7dae4Smrg# and a working winepath. Returns result in func_to_host_file_result. 1732aee7dae4Smrgfunc_convert_file_nix_to_w32 () 1733aee7dae4Smrg{ 1734aee7dae4Smrg $opt_debug 1735aee7dae4Smrg func_to_host_file_result="$1" 1736aee7dae4Smrg if test -n "$1"; then 1737aee7dae4Smrg func_convert_core_file_wine_to_w32 "$1" 1738aee7dae4Smrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 1739aee7dae4Smrg fi 1740aee7dae4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1741aee7dae4Smrg} 1742aee7dae4Smrg# end func_convert_file_nix_to_w32 1743ba0eab60Smacallan 1744ba0eab60Smacallan 1745aee7dae4Smrg# func_convert_file_msys_to_cygwin ARG 1746aee7dae4Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1747aee7dae4Smrg# Returns result in func_to_host_file_result. 1748aee7dae4Smrgfunc_convert_file_msys_to_cygwin () 1749aee7dae4Smrg{ 1750aee7dae4Smrg $opt_debug 1751aee7dae4Smrg func_to_host_file_result="$1" 1752aee7dae4Smrg if test -n "$1"; then 1753aee7dae4Smrg func_convert_core_msys_to_w32 "$1" 1754aee7dae4Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 1755aee7dae4Smrg func_to_host_file_result="$func_cygpath_result" 1756aee7dae4Smrg fi 1757aee7dae4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1758aee7dae4Smrg} 1759aee7dae4Smrg# end func_convert_file_msys_to_cygwin 1760ba0eab60Smacallan 1761ba0eab60Smacallan 1762aee7dae4Smrg# func_convert_file_nix_to_cygwin ARG 1763aee7dae4Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 1764aee7dae4Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 1765aee7dae4Smrg# in func_to_host_file_result. 1766aee7dae4Smrgfunc_convert_file_nix_to_cygwin () 1767aee7dae4Smrg{ 1768aee7dae4Smrg $opt_debug 1769aee7dae4Smrg func_to_host_file_result="$1" 1770aee7dae4Smrg if test -n "$1"; then 1771aee7dae4Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 1772aee7dae4Smrg func_convert_core_file_wine_to_w32 "$1" 1773aee7dae4Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 1774aee7dae4Smrg func_to_host_file_result="$func_cygpath_result" 1775aee7dae4Smrg fi 1776aee7dae4Smrg func_convert_file_check "$1" "$func_to_host_file_result" 1777aee7dae4Smrg} 1778aee7dae4Smrg# end func_convert_file_nix_to_cygwin 1779ba0eab60Smacallan 1780ba0eab60Smacallan 1781aee7dae4Smrg############################################# 1782aee7dae4Smrg# $build to $host PATH CONVERSION FUNCTIONS # 1783aee7dae4Smrg############################################# 1784aee7dae4Smrg# invoked via `$to_host_path_cmd ARG' 1785aee7dae4Smrg# 1786aee7dae4Smrg# In each case, ARG is the path to be converted from $build to $host format. 1787aee7dae4Smrg# The result will be available in $func_to_host_path_result. 1788aee7dae4Smrg# 1789aee7dae4Smrg# Path separators are also converted from $build format to $host format. If 1790aee7dae4Smrg# ARG begins or ends with a path separator character, it is preserved (but 1791aee7dae4Smrg# converted to $host format) on output. 1792aee7dae4Smrg# 1793aee7dae4Smrg# All path conversion functions are named using the following convention: 1794aee7dae4Smrg# file name conversion function : func_convert_file_X_to_Y () 1795aee7dae4Smrg# path conversion function : func_convert_path_X_to_Y () 1796aee7dae4Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 1797aee7dae4Smrg# same. If conversion functions are added for new $build/$host combinations, 1798aee7dae4Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 1799aee7dae4Smrg# will break. 1800aee7dae4Smrg 1801aee7dae4Smrg 1802aee7dae4Smrg# func_init_to_host_path_cmd 1803aee7dae4Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 1804aee7dae4Smrg# appropriate value, based on the value of $to_host_file_cmd. 1805aee7dae4Smrgto_host_path_cmd= 1806aee7dae4Smrgfunc_init_to_host_path_cmd () 1807aee7dae4Smrg{ 1808aee7dae4Smrg $opt_debug 1809aee7dae4Smrg if test -z "$to_host_path_cmd"; then 1810aee7dae4Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 1811aee7dae4Smrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 1812aee7dae4Smrg fi 1813aee7dae4Smrg} 1814ba0eab60Smacallan 1815ba0eab60Smacallan 1816aee7dae4Smrg# func_to_host_path ARG 1817aee7dae4Smrg# Converts the path ARG from $build format to $host format. Return result 1818aee7dae4Smrg# in func_to_host_path_result. 1819aee7dae4Smrgfunc_to_host_path () 1820aee7dae4Smrg{ 1821aee7dae4Smrg $opt_debug 1822aee7dae4Smrg func_init_to_host_path_cmd 1823aee7dae4Smrg $to_host_path_cmd "$1" 1824aee7dae4Smrg} 1825aee7dae4Smrg# end func_to_host_path 1826ba0eab60Smacallan 1827ba0eab60Smacallan 1828aee7dae4Smrg# func_convert_path_noop ARG 1829aee7dae4Smrg# Copy ARG to func_to_host_path_result. 1830aee7dae4Smrgfunc_convert_path_noop () 1831aee7dae4Smrg{ 1832aee7dae4Smrg func_to_host_path_result="$1" 1833aee7dae4Smrg} 1834aee7dae4Smrg# end func_convert_path_noop 1835ba0eab60Smacallan 1836ba0eab60Smacallan 1837aee7dae4Smrg# func_convert_path_msys_to_w32 ARG 1838aee7dae4Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 1839aee7dae4Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 1840aee7dae4Smrg# func_to_host_path_result. 1841aee7dae4Smrgfunc_convert_path_msys_to_w32 () 1842aee7dae4Smrg{ 1843aee7dae4Smrg $opt_debug 1844aee7dae4Smrg func_to_host_path_result="$1" 1845aee7dae4Smrg if test -n "$1"; then 1846aee7dae4Smrg # Remove leading and trailing path separator characters from ARG. MSYS 1847aee7dae4Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 1848aee7dae4Smrg # and winepath ignores them completely. 1849aee7dae4Smrg func_stripname : : "$1" 1850aee7dae4Smrg func_to_host_path_tmp1=$func_stripname_result 1851aee7dae4Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1852aee7dae4Smrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 1853aee7dae4Smrg func_convert_path_check : ";" \ 1854aee7dae4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1855aee7dae4Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1856aee7dae4Smrg fi 1857aee7dae4Smrg} 1858aee7dae4Smrg# end func_convert_path_msys_to_w32 1859ba0eab60Smacallan 1860ba0eab60Smacallan 1861aee7dae4Smrg# func_convert_path_cygwin_to_w32 ARG 1862aee7dae4Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 1863aee7dae4Smrg# func_to_host_file_result. 1864aee7dae4Smrgfunc_convert_path_cygwin_to_w32 () 1865aee7dae4Smrg{ 1866aee7dae4Smrg $opt_debug 1867aee7dae4Smrg func_to_host_path_result="$1" 1868aee7dae4Smrg if test -n "$1"; then 1869aee7dae4Smrg # See func_convert_path_msys_to_w32: 1870aee7dae4Smrg func_stripname : : "$1" 1871aee7dae4Smrg func_to_host_path_tmp1=$func_stripname_result 1872aee7dae4Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 1873aee7dae4Smrg func_convert_path_check : ";" \ 1874aee7dae4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1875aee7dae4Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1876aee7dae4Smrg fi 1877aee7dae4Smrg} 1878aee7dae4Smrg# end func_convert_path_cygwin_to_w32 1879ba0eab60Smacallan 1880ba0eab60Smacallan 1881aee7dae4Smrg# func_convert_path_nix_to_w32 ARG 1882aee7dae4Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 1883aee7dae4Smrg# a working winepath. Returns result in func_to_host_file_result. 1884aee7dae4Smrgfunc_convert_path_nix_to_w32 () 1885aee7dae4Smrg{ 1886aee7dae4Smrg $opt_debug 1887aee7dae4Smrg func_to_host_path_result="$1" 1888aee7dae4Smrg if test -n "$1"; then 1889aee7dae4Smrg # See func_convert_path_msys_to_w32: 1890aee7dae4Smrg func_stripname : : "$1" 1891aee7dae4Smrg func_to_host_path_tmp1=$func_stripname_result 1892aee7dae4Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1893aee7dae4Smrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 1894aee7dae4Smrg func_convert_path_check : ";" \ 1895aee7dae4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1896aee7dae4Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1897aee7dae4Smrg fi 1898aee7dae4Smrg} 1899aee7dae4Smrg# end func_convert_path_nix_to_w32 1900ba0eab60Smacallan 1901aee7dae4Smrg 1902aee7dae4Smrg# func_convert_path_msys_to_cygwin ARG 1903aee7dae4Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1904aee7dae4Smrg# Returns result in func_to_host_file_result. 1905aee7dae4Smrgfunc_convert_path_msys_to_cygwin () 1906aee7dae4Smrg{ 1907aee7dae4Smrg $opt_debug 1908aee7dae4Smrg func_to_host_path_result="$1" 1909aee7dae4Smrg if test -n "$1"; then 1910aee7dae4Smrg # See func_convert_path_msys_to_w32: 1911aee7dae4Smrg func_stripname : : "$1" 1912aee7dae4Smrg func_to_host_path_tmp1=$func_stripname_result 1913aee7dae4Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1914aee7dae4Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 1915aee7dae4Smrg func_to_host_path_result="$func_cygpath_result" 1916aee7dae4Smrg func_convert_path_check : : \ 1917aee7dae4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1918aee7dae4Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1919aee7dae4Smrg fi 1920aee7dae4Smrg} 1921aee7dae4Smrg# end func_convert_path_msys_to_cygwin 1922aee7dae4Smrg 1923aee7dae4Smrg 1924aee7dae4Smrg# func_convert_path_nix_to_cygwin ARG 1925aee7dae4Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 1926aee7dae4Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 1927aee7dae4Smrg# func_to_host_file_result. 1928aee7dae4Smrgfunc_convert_path_nix_to_cygwin () 1929aee7dae4Smrg{ 1930aee7dae4Smrg $opt_debug 1931aee7dae4Smrg func_to_host_path_result="$1" 1932aee7dae4Smrg if test -n "$1"; then 1933aee7dae4Smrg # Remove leading and trailing path separator characters from 1934aee7dae4Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 1935aee7dae4Smrg # into '.;' and ';.', and winepath ignores them completely. 1936aee7dae4Smrg func_stripname : : "$1" 1937aee7dae4Smrg func_to_host_path_tmp1=$func_stripname_result 1938aee7dae4Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1939aee7dae4Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 1940aee7dae4Smrg func_to_host_path_result="$func_cygpath_result" 1941aee7dae4Smrg func_convert_path_check : : \ 1942aee7dae4Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 1943aee7dae4Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1944aee7dae4Smrg fi 1945aee7dae4Smrg} 1946aee7dae4Smrg# end func_convert_path_nix_to_cygwin 1947aee7dae4Smrg 1948aee7dae4Smrg 1949aee7dae4Smrg# func_mode_compile arg... 1950aee7dae4Smrgfunc_mode_compile () 1951aee7dae4Smrg{ 1952aee7dae4Smrg $opt_debug 1953aee7dae4Smrg # Get the compilation command and the source file. 1954aee7dae4Smrg base_compile= 1955aee7dae4Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 1956aee7dae4Smrg suppress_opt=yes 1957aee7dae4Smrg suppress_output= 1958aee7dae4Smrg arg_mode=normal 1959aee7dae4Smrg libobj= 1960aee7dae4Smrg later= 1961aee7dae4Smrg pie_flag= 1962aee7dae4Smrg 1963aee7dae4Smrg for arg 1964aee7dae4Smrg do 1965aee7dae4Smrg case $arg_mode in 1966aee7dae4Smrg arg ) 1967aee7dae4Smrg # do not "continue". Instead, add this to base_compile 1968aee7dae4Smrg lastarg="$arg" 1969aee7dae4Smrg arg_mode=normal 1970ba0eab60Smacallan ;; 1971ba0eab60Smacallan 1972aee7dae4Smrg target ) 1973aee7dae4Smrg libobj="$arg" 1974aee7dae4Smrg arg_mode=normal 1975ba0eab60Smacallan continue 1976ba0eab60Smacallan ;; 1977ba0eab60Smacallan 1978aee7dae4Smrg normal ) 1979aee7dae4Smrg # Accept any command-line options. 1980ba0eab60Smacallan case $arg in 1981aee7dae4Smrg -o) 1982aee7dae4Smrg test -n "$libobj" && \ 1983aee7dae4Smrg func_fatal_error "you cannot specify \`-o' more than once" 1984aee7dae4Smrg arg_mode=target 1985aee7dae4Smrg continue 1986ba0eab60Smacallan ;; 1987ba0eab60Smacallan 1988aee7dae4Smrg -pie | -fpie | -fPIE) 1989aee7dae4Smrg func_append pie_flag " $arg" 1990aee7dae4Smrg continue 1991aee7dae4Smrg ;; 1992ba0eab60Smacallan 1993aee7dae4Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 1994aee7dae4Smrg func_append later " $arg" 1995aee7dae4Smrg continue 1996aee7dae4Smrg ;; 1997ba0eab60Smacallan 1998aee7dae4Smrg -no-suppress) 1999aee7dae4Smrg suppress_opt=no 2000aee7dae4Smrg continue 2001aee7dae4Smrg ;; 2002ba0eab60Smacallan 2003aee7dae4Smrg -Xcompiler) 2004aee7dae4Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 2005aee7dae4Smrg continue # The current "srcfile" will either be retained or 2006aee7dae4Smrg ;; # replaced later. I would guess that would be a bug. 2007ba0eab60Smacallan 2008aee7dae4Smrg -Wc,*) 2009aee7dae4Smrg func_stripname '-Wc,' '' "$arg" 2010aee7dae4Smrg args=$func_stripname_result 2011aee7dae4Smrg lastarg= 2012aee7dae4Smrg save_ifs="$IFS"; IFS=',' 2013aee7dae4Smrg for arg in $args; do 2014aee7dae4Smrg IFS="$save_ifs" 2015aee7dae4Smrg func_append_quoted lastarg "$arg" 2016aee7dae4Smrg done 2017aee7dae4Smrg IFS="$save_ifs" 2018aee7dae4Smrg func_stripname ' ' '' "$lastarg" 2019aee7dae4Smrg lastarg=$func_stripname_result 2020ba0eab60Smacallan 2021aee7dae4Smrg # Add the arguments to base_compile. 2022aee7dae4Smrg func_append base_compile " $lastarg" 2023aee7dae4Smrg continue 2024aee7dae4Smrg ;; 2025ba0eab60Smacallan 2026aee7dae4Smrg *) 2027aee7dae4Smrg # Accept the current argument as the source file. 2028aee7dae4Smrg # The previous "srcfile" becomes the current argument. 2029aee7dae4Smrg # 2030aee7dae4Smrg lastarg="$srcfile" 2031aee7dae4Smrg srcfile="$arg" 2032aee7dae4Smrg ;; 2033aee7dae4Smrg esac # case $arg 2034aee7dae4Smrg ;; 2035aee7dae4Smrg esac # case $arg_mode 2036ba0eab60Smacallan 2037aee7dae4Smrg # Aesthetically quote the previous argument. 2038aee7dae4Smrg func_append_quoted base_compile "$lastarg" 2039aee7dae4Smrg done # for arg 2040ba0eab60Smacallan 2041aee7dae4Smrg case $arg_mode in 2042aee7dae4Smrg arg) 2043aee7dae4Smrg func_fatal_error "you must specify an argument for -Xcompile" 2044aee7dae4Smrg ;; 2045aee7dae4Smrg target) 2046aee7dae4Smrg func_fatal_error "you must specify a target with \`-o'" 2047aee7dae4Smrg ;; 2048aee7dae4Smrg *) 2049aee7dae4Smrg # Get the name of the library object. 2050aee7dae4Smrg test -z "$libobj" && { 2051aee7dae4Smrg func_basename "$srcfile" 2052aee7dae4Smrg libobj="$func_basename_result" 2053aee7dae4Smrg } 2054aee7dae4Smrg ;; 2055aee7dae4Smrg esac 2056ba0eab60Smacallan 2057aee7dae4Smrg # Recognize several different file suffixes. 2058aee7dae4Smrg # If the user specifies -o file.o, it is replaced with file.lo 2059aee7dae4Smrg case $libobj in 2060aee7dae4Smrg *.[cCFSifmso] | \ 2061aee7dae4Smrg *.ada | *.adb | *.ads | *.asm | \ 2062aee7dae4Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 2063aee7dae4Smrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 2064aee7dae4Smrg func_xform "$libobj" 2065aee7dae4Smrg libobj=$func_xform_result 2066aee7dae4Smrg ;; 2067aee7dae4Smrg esac 2068ba0eab60Smacallan 2069aee7dae4Smrg case $libobj in 2070aee7dae4Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2071aee7dae4Smrg *) 2072aee7dae4Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 2073aee7dae4Smrg ;; 2074aee7dae4Smrg esac 2075ba0eab60Smacallan 2076aee7dae4Smrg func_infer_tag $base_compile 2077ba0eab60Smacallan 2078aee7dae4Smrg for arg in $later; do 2079aee7dae4Smrg case $arg in 2080aee7dae4Smrg -shared) 2081aee7dae4Smrg test "$build_libtool_libs" != yes && \ 2082aee7dae4Smrg func_fatal_configuration "can not build a shared library" 2083aee7dae4Smrg build_old_libs=no 2084ba0eab60Smacallan continue 2085ba0eab60Smacallan ;; 2086ba0eab60Smacallan 2087aee7dae4Smrg -static) 2088aee7dae4Smrg build_libtool_libs=no 2089aee7dae4Smrg build_old_libs=yes 2090aee7dae4Smrg continue 2091aee7dae4Smrg ;; 2092ba0eab60Smacallan 2093aee7dae4Smrg -prefer-pic) 2094aee7dae4Smrg pic_mode=yes 2095ba0eab60Smacallan continue 2096ba0eab60Smacallan ;; 2097ba0eab60Smacallan 2098aee7dae4Smrg -prefer-non-pic) 2099aee7dae4Smrg pic_mode=no 2100aee7dae4Smrg continue 2101ba0eab60Smacallan ;; 2102aee7dae4Smrg esac 2103aee7dae4Smrg done 2104ba0eab60Smacallan 2105aee7dae4Smrg func_quote_for_eval "$libobj" 2106aee7dae4Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 2107aee7dae4Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 2108aee7dae4Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 2109aee7dae4Smrg func_dirname_and_basename "$obj" "/" "" 2110aee7dae4Smrg objname="$func_basename_result" 2111aee7dae4Smrg xdir="$func_dirname_result" 2112aee7dae4Smrg lobj=${xdir}$objdir/$objname 2113ba0eab60Smacallan 2114aee7dae4Smrg test -z "$base_compile" && \ 2115aee7dae4Smrg func_fatal_help "you must specify a compilation command" 2116ba0eab60Smacallan 2117aee7dae4Smrg # Delete any leftover library objects. 2118aee7dae4Smrg if test "$build_old_libs" = yes; then 2119aee7dae4Smrg removelist="$obj $lobj $libobj ${libobj}T" 2120aee7dae4Smrg else 2121aee7dae4Smrg removelist="$lobj $libobj ${libobj}T" 2122ba0eab60Smacallan fi 2123ba0eab60Smacallan 2124aee7dae4Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 2125aee7dae4Smrg case $host_os in 2126aee7dae4Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 2127aee7dae4Smrg pic_mode=default 2128aee7dae4Smrg ;; 2129aee7dae4Smrg esac 2130aee7dae4Smrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2131aee7dae4Smrg # non-PIC code in shared libraries is not supported 2132aee7dae4Smrg pic_mode=default 2133ba0eab60Smacallan fi 2134ba0eab60Smacallan 2135aee7dae4Smrg # Calculate the filename of the output object if compiler does 2136aee7dae4Smrg # not support -o with -c 2137aee7dae4Smrg if test "$compiler_c_o" = no; then 2138aee7dae4Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2139aee7dae4Smrg lockfile="$output_obj.lock" 2140ba0eab60Smacallan else 2141aee7dae4Smrg output_obj= 2142aee7dae4Smrg need_locks=no 2143aee7dae4Smrg lockfile= 2144ba0eab60Smacallan fi 2145aee7dae4Smrg 2146aee7dae4Smrg # Lock this critical section if it is needed 2147aee7dae4Smrg # We use this script file to make the link, it avoids creating a new file 2148aee7dae4Smrg if test "$need_locks" = yes; then 2149aee7dae4Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 2150aee7dae4Smrg func_echo "Waiting for $lockfile to be removed" 2151aee7dae4Smrg sleep 2 2152aee7dae4Smrg done 2153aee7dae4Smrg elif test "$need_locks" = warn; then 2154aee7dae4Smrg if test -f "$lockfile"; then 2155aee7dae4Smrg $ECHO "\ 2156aee7dae4Smrg*** ERROR, $lockfile exists and contains: 2157aee7dae4Smrg`cat $lockfile 2>/dev/null` 2158aee7dae4Smrg 2159aee7dae4SmrgThis indicates that another process is trying to use the same 2160aee7dae4Smrgtemporary object file, and libtool could not work around it because 2161aee7dae4Smrgyour compiler does not support \`-c' and \`-o' together. If you 2162aee7dae4Smrgrepeat this compilation, it may succeed, by chance, but you had better 2163aee7dae4Smrgavoid parallel builds (make -j) in this platform, or get a better 2164aee7dae4Smrgcompiler." 2165aee7dae4Smrg 2166aee7dae4Smrg $opt_dry_run || $RM $removelist 2167aee7dae4Smrg exit $EXIT_FAILURE 2168ba0eab60Smacallan fi 2169aee7dae4Smrg func_append removelist " $output_obj" 2170aee7dae4Smrg $ECHO "$srcfile" > "$lockfile" 2171ba0eab60Smacallan fi 2172ba0eab60Smacallan 2173aee7dae4Smrg $opt_dry_run || $RM $removelist 2174aee7dae4Smrg func_append removelist " $lockfile" 2175aee7dae4Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 2176ba0eab60Smacallan 2177aee7dae4Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 2178aee7dae4Smrg srcfile=$func_to_tool_file_result 2179aee7dae4Smrg func_quote_for_eval "$srcfile" 2180aee7dae4Smrg qsrcfile=$func_quote_for_eval_result 2181ba0eab60Smacallan 2182aee7dae4Smrg # Only build a PIC object if we are building libtool libraries. 2183aee7dae4Smrg if test "$build_libtool_libs" = yes; then 2184aee7dae4Smrg # Without this assignment, base_compile gets emptied. 2185aee7dae4Smrg fbsd_hideous_sh_bug=$base_compile 2186aee7dae4Smrg 2187aee7dae4Smrg if test "$pic_mode" != no; then 2188aee7dae4Smrg command="$base_compile $qsrcfile $pic_flag" 2189aee7dae4Smrg else 2190aee7dae4Smrg # Don't build PIC code 2191aee7dae4Smrg command="$base_compile $qsrcfile" 2192ba0eab60Smacallan fi 2193ba0eab60Smacallan 2194aee7dae4Smrg func_mkdir_p "$xdir$objdir" 2195ba0eab60Smacallan 2196aee7dae4Smrg if test -z "$output_obj"; then 2197aee7dae4Smrg # Place PIC objects in $objdir 2198aee7dae4Smrg func_append command " -o $lobj" 2199ba0eab60Smacallan fi 2200ba0eab60Smacallan 2201aee7dae4Smrg func_show_eval_locale "$command" \ 2202aee7dae4Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2203aee7dae4Smrg 2204aee7dae4Smrg if test "$need_locks" = warn && 2205aee7dae4Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2206aee7dae4Smrg $ECHO "\ 2207aee7dae4Smrg*** ERROR, $lockfile contains: 2208aee7dae4Smrg`cat $lockfile 2>/dev/null` 2209aee7dae4Smrg 2210aee7dae4Smrgbut it should contain: 2211aee7dae4Smrg$srcfile 2212aee7dae4Smrg 2213aee7dae4SmrgThis indicates that another process is trying to use the same 2214aee7dae4Smrgtemporary object file, and libtool could not work around it because 2215aee7dae4Smrgyour compiler does not support \`-c' and \`-o' together. If you 2216aee7dae4Smrgrepeat this compilation, it may succeed, by chance, but you had better 2217aee7dae4Smrgavoid parallel builds (make -j) in this platform, or get a better 2218aee7dae4Smrgcompiler." 2219aee7dae4Smrg 2220aee7dae4Smrg $opt_dry_run || $RM $removelist 2221aee7dae4Smrg exit $EXIT_FAILURE 2222ba0eab60Smacallan fi 2223aee7dae4Smrg 2224aee7dae4Smrg # Just move the object if needed, then go on to compile the next one 2225aee7dae4Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 2226aee7dae4Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 2227aee7dae4Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2228ba0eab60Smacallan fi 2229aee7dae4Smrg 2230aee7dae4Smrg # Allow error messages only from the first compilation. 2231aee7dae4Smrg if test "$suppress_opt" = yes; then 2232aee7dae4Smrg suppress_output=' >/dev/null 2>&1' 2233ba0eab60Smacallan fi 2234aee7dae4Smrg fi 2235ba0eab60Smacallan 2236aee7dae4Smrg # Only build a position-dependent object if we build old libraries. 2237aee7dae4Smrg if test "$build_old_libs" = yes; then 2238aee7dae4Smrg if test "$pic_mode" != yes; then 2239aee7dae4Smrg # Don't build PIC code 2240aee7dae4Smrg command="$base_compile $qsrcfile$pie_flag" 2241aee7dae4Smrg else 2242aee7dae4Smrg command="$base_compile $qsrcfile $pic_flag" 2243aee7dae4Smrg fi 2244aee7dae4Smrg if test "$compiler_c_o" = yes; then 2245aee7dae4Smrg func_append command " -o $obj" 2246aee7dae4Smrg fi 2247ba0eab60Smacallan 2248aee7dae4Smrg # Suppress compiler output if we already did a PIC compilation. 2249aee7dae4Smrg func_append command "$suppress_output" 2250aee7dae4Smrg func_show_eval_locale "$command" \ 2251aee7dae4Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2252ba0eab60Smacallan 2253aee7dae4Smrg if test "$need_locks" = warn && 2254aee7dae4Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2255aee7dae4Smrg $ECHO "\ 2256aee7dae4Smrg*** ERROR, $lockfile contains: 2257aee7dae4Smrg`cat $lockfile 2>/dev/null` 2258ba0eab60Smacallan 2259aee7dae4Smrgbut it should contain: 2260aee7dae4Smrg$srcfile 2261ba0eab60Smacallan 2262aee7dae4SmrgThis indicates that another process is trying to use the same 2263aee7dae4Smrgtemporary object file, and libtool could not work around it because 2264aee7dae4Smrgyour compiler does not support \`-c' and \`-o' together. If you 2265aee7dae4Smrgrepeat this compilation, it may succeed, by chance, but you had better 2266aee7dae4Smrgavoid parallel builds (make -j) in this platform, or get a better 2267aee7dae4Smrgcompiler." 2268ba0eab60Smacallan 2269aee7dae4Smrg $opt_dry_run || $RM $removelist 2270aee7dae4Smrg exit $EXIT_FAILURE 2271aee7dae4Smrg fi 2272ba0eab60Smacallan 2273aee7dae4Smrg # Just move the object if needed 2274aee7dae4Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 2275aee7dae4Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 2276aee7dae4Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2277aee7dae4Smrg fi 2278aee7dae4Smrg fi 2279ba0eab60Smacallan 2280aee7dae4Smrg $opt_dry_run || { 2281aee7dae4Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2282ba0eab60Smacallan 2283aee7dae4Smrg # Unlock the critical section if it was locked 2284aee7dae4Smrg if test "$need_locks" != no; then 2285aee7dae4Smrg removelist=$lockfile 2286aee7dae4Smrg $RM "$lockfile" 2287aee7dae4Smrg fi 2288aee7dae4Smrg } 2289ba0eab60Smacallan 2290aee7dae4Smrg exit $EXIT_SUCCESS 2291aee7dae4Smrg} 2292ba0eab60Smacallan 2293aee7dae4Smrg$opt_help || { 2294aee7dae4Smrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 2295aee7dae4Smrg} 2296ba0eab60Smacallan 2297aee7dae4Smrgfunc_mode_help () 2298aee7dae4Smrg{ 2299aee7dae4Smrg # We need to display help for each of the modes. 2300aee7dae4Smrg case $opt_mode in 2301aee7dae4Smrg "") 2302aee7dae4Smrg # Generic help is extracted from the usage comments 2303aee7dae4Smrg # at the start of this file. 2304aee7dae4Smrg func_help 2305aee7dae4Smrg ;; 2306ba0eab60Smacallan 2307aee7dae4Smrg clean) 2308aee7dae4Smrg $ECHO \ 2309aee7dae4Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2310ba0eab60Smacallan 2311aee7dae4SmrgRemove files from the build directory. 2312ba0eab60Smacallan 2313aee7dae4SmrgRM is the name of the program to use to delete files associated with each FILE 2314aee7dae4Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2315aee7dae4Smrgto RM. 2316ba0eab60Smacallan 2317aee7dae4SmrgIf FILE is a libtool library, object or program, all the files associated 2318aee7dae4Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 2319aee7dae4Smrg ;; 2320ba0eab60Smacallan 2321aee7dae4Smrg compile) 2322aee7dae4Smrg $ECHO \ 2323aee7dae4Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2324ba0eab60Smacallan 2325aee7dae4SmrgCompile a source file into a libtool library object. 2326ba0eab60Smacallan 2327aee7dae4SmrgThis mode accepts the following additional options: 2328ba0eab60Smacallan 2329aee7dae4Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 2330aee7dae4Smrg -no-suppress do not suppress compiler output for multiple passes 2331aee7dae4Smrg -prefer-pic try to build PIC objects only 2332aee7dae4Smrg -prefer-non-pic try to build non-PIC objects only 2333aee7dae4Smrg -shared do not build a \`.o' file suitable for static linking 2334aee7dae4Smrg -static only build a \`.o' file suitable for static linking 2335aee7dae4Smrg -Wc,FLAG pass FLAG directly to the compiler 2336ba0eab60Smacallan 2337aee7dae4SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 2338aee7dae4Smrgfrom the given SOURCEFILE. 2339ba0eab60Smacallan 2340aee7dae4SmrgThe output file name is determined by removing the directory component from 2341aee7dae4SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 2342aee7dae4Smrglibrary object suffix, \`.lo'." 2343aee7dae4Smrg ;; 2344ba0eab60Smacallan 2345aee7dae4Smrg execute) 2346aee7dae4Smrg $ECHO \ 2347aee7dae4Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2348ba0eab60Smacallan 2349aee7dae4SmrgAutomatically set library path, then run a program. 2350ba0eab60Smacallan 2351aee7dae4SmrgThis mode accepts the following additional options: 2352ba0eab60Smacallan 2353aee7dae4Smrg -dlopen FILE add the directory containing FILE to the library path 2354ba0eab60Smacallan 2355aee7dae4SmrgThis mode sets the library path environment variable according to \`-dlopen' 2356aee7dae4Smrgflags. 2357ba0eab60Smacallan 2358aee7dae4SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 2359aee7dae4Smrginto their corresponding uninstalled binary, and any of their required library 2360aee7dae4Smrgdirectories are added to the library path. 2361ba0eab60Smacallan 2362aee7dae4SmrgThen, COMMAND is executed, with ARGS as arguments." 2363aee7dae4Smrg ;; 2364ba0eab60Smacallan 2365aee7dae4Smrg finish) 2366aee7dae4Smrg $ECHO \ 2367aee7dae4Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2368ba0eab60Smacallan 2369aee7dae4SmrgComplete the installation of libtool libraries. 2370ba0eab60Smacallan 2371aee7dae4SmrgEach LIBDIR is a directory that contains libtool libraries. 2372ba0eab60Smacallan 2373aee7dae4SmrgThe commands that this mode executes may require superuser privileges. Use 2374aee7dae4Smrgthe \`--dry-run' option if you just want to see what would be executed." 2375aee7dae4Smrg ;; 2376ba0eab60Smacallan 2377aee7dae4Smrg install) 2378aee7dae4Smrg $ECHO \ 2379aee7dae4Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2380ba0eab60Smacallan 2381aee7dae4SmrgInstall executables or libraries. 2382ba0eab60Smacallan 2383aee7dae4SmrgINSTALL-COMMAND is the installation command. The first component should be 2384aee7dae4Smrgeither the \`install' or \`cp' program. 2385ba0eab60Smacallan 2386aee7dae4SmrgThe following components of INSTALL-COMMAND are treated specially: 2387aee7dae4Smrg 2388aee7dae4Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2389aee7dae4Smrg 2390aee7dae4SmrgThe rest of the components are interpreted as arguments to that command (only 2391aee7dae4SmrgBSD-compatible install options are recognized)." 2392aee7dae4Smrg ;; 2393aee7dae4Smrg 2394aee7dae4Smrg link) 2395aee7dae4Smrg $ECHO \ 2396aee7dae4Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2397aee7dae4Smrg 2398aee7dae4SmrgLink object files or libraries together to form another library, or to 2399aee7dae4Smrgcreate an executable program. 2400aee7dae4Smrg 2401aee7dae4SmrgLINK-COMMAND is a command using the C compiler that you would use to create 2402aee7dae4Smrga program from several object files. 2403aee7dae4Smrg 2404aee7dae4SmrgThe following components of LINK-COMMAND are treated specially: 2405aee7dae4Smrg 2406aee7dae4Smrg -all-static do not do any dynamic linking at all 2407aee7dae4Smrg -avoid-version do not add a version suffix if possible 2408aee7dae4Smrg -bindir BINDIR specify path to binaries directory (for systems where 2409aee7dae4Smrg libraries must be found in the PATH setting at runtime) 2410aee7dae4Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 2411aee7dae4Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 2412aee7dae4Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 2413aee7dae4Smrg -export-symbols SYMFILE 2414aee7dae4Smrg try to export only the symbols listed in SYMFILE 2415aee7dae4Smrg -export-symbols-regex REGEX 2416aee7dae4Smrg try to export only the symbols matching REGEX 2417aee7dae4Smrg -LLIBDIR search LIBDIR for required installed libraries 2418aee7dae4Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 2419aee7dae4Smrg -module build a library that can dlopened 2420aee7dae4Smrg -no-fast-install disable the fast-install mode 2421aee7dae4Smrg -no-install link a not-installable executable 2422aee7dae4Smrg -no-undefined declare that a library does not refer to external symbols 2423aee7dae4Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 2424aee7dae4Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 2425aee7dae4Smrg -precious-files-regex REGEX 2426aee7dae4Smrg don't remove output files matching REGEX 2427aee7dae4Smrg -release RELEASE specify package release information 2428aee7dae4Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 2429aee7dae4Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 2430aee7dae4Smrg -shared only do dynamic linking of libtool libraries 2431aee7dae4Smrg -shrext SUFFIX override the standard shared library file extension 2432aee7dae4Smrg -static do not do any dynamic linking of uninstalled libtool libraries 2433aee7dae4Smrg -static-libtool-libs 2434aee7dae4Smrg do not do any dynamic linking of libtool libraries 2435aee7dae4Smrg -version-info CURRENT[:REVISION[:AGE]] 2436aee7dae4Smrg specify library version info [each variable defaults to 0] 2437aee7dae4Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 2438aee7dae4Smrg -Wc,FLAG 2439aee7dae4Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 2440aee7dae4Smrg -Wl,FLAG 2441aee7dae4Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 2442aee7dae4Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2443aee7dae4Smrg 2444aee7dae4SmrgAll other options (arguments beginning with \`-') are ignored. 2445aee7dae4Smrg 2446aee7dae4SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 2447aee7dae4Smrgtreated as uninstalled libtool libraries, other files are standard or library 2448aee7dae4Smrgobject files. 2449aee7dae4Smrg 2450aee7dae4SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 2451aee7dae4Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 2452aee7dae4Smrgrequired, except when creating a convenience library. 2453aee7dae4Smrg 2454aee7dae4SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 2455aee7dae4Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 2456aee7dae4Smrg 2457aee7dae4SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 2458aee7dae4Smrgis created, otherwise an executable program is created." 2459aee7dae4Smrg ;; 2460aee7dae4Smrg 2461aee7dae4Smrg uninstall) 2462aee7dae4Smrg $ECHO \ 2463aee7dae4Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2464aee7dae4Smrg 2465aee7dae4SmrgRemove libraries from an installation directory. 2466aee7dae4Smrg 2467aee7dae4SmrgRM is the name of the program to use to delete files associated with each FILE 2468aee7dae4Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2469aee7dae4Smrgto RM. 2470aee7dae4Smrg 2471aee7dae4SmrgIf FILE is a libtool library, all the files associated with it are deleted. 2472aee7dae4SmrgOtherwise, only FILE itself is deleted using RM." 2473aee7dae4Smrg ;; 2474aee7dae4Smrg 2475aee7dae4Smrg *) 2476aee7dae4Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 2477aee7dae4Smrg ;; 2478aee7dae4Smrg esac 2479aee7dae4Smrg 2480aee7dae4Smrg echo 2481aee7dae4Smrg $ECHO "Try \`$progname --help' for more information about other modes." 2482aee7dae4Smrg} 2483aee7dae4Smrg 2484aee7dae4Smrg# Now that we've collected a possible --mode arg, show help if necessary 2485aee7dae4Smrgif $opt_help; then 2486aee7dae4Smrg if test "$opt_help" = :; then 2487aee7dae4Smrg func_mode_help 2488aee7dae4Smrg else 2489aee7dae4Smrg { 2490aee7dae4Smrg func_help noexit 2491aee7dae4Smrg for opt_mode in compile link execute install finish uninstall clean; do 2492aee7dae4Smrg func_mode_help 2493aee7dae4Smrg done 2494aee7dae4Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 2495aee7dae4Smrg { 2496aee7dae4Smrg func_help noexit 2497aee7dae4Smrg for opt_mode in compile link execute install finish uninstall clean; do 2498aee7dae4Smrg echo 2499aee7dae4Smrg func_mode_help 2500aee7dae4Smrg done 2501aee7dae4Smrg } | 2502aee7dae4Smrg sed '1d 2503aee7dae4Smrg /^When reporting/,/^Report/{ 2504aee7dae4Smrg H 2505aee7dae4Smrg d 2506aee7dae4Smrg } 2507aee7dae4Smrg $x 2508aee7dae4Smrg /information about other modes/d 2509aee7dae4Smrg /more detailed .*MODE/d 2510aee7dae4Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 2511aee7dae4Smrg fi 2512aee7dae4Smrg exit $? 2513aee7dae4Smrgfi 2514aee7dae4Smrg 2515aee7dae4Smrg 2516aee7dae4Smrg# func_mode_execute arg... 2517aee7dae4Smrgfunc_mode_execute () 2518aee7dae4Smrg{ 2519aee7dae4Smrg $opt_debug 2520aee7dae4Smrg # The first argument is the command name. 2521aee7dae4Smrg cmd="$nonopt" 2522aee7dae4Smrg test -z "$cmd" && \ 2523aee7dae4Smrg func_fatal_help "you must specify a COMMAND" 2524aee7dae4Smrg 2525aee7dae4Smrg # Handle -dlopen flags immediately. 2526aee7dae4Smrg for file in $opt_dlopen; do 2527aee7dae4Smrg test -f "$file" \ 2528aee7dae4Smrg || func_fatal_help "\`$file' is not a file" 2529aee7dae4Smrg 2530aee7dae4Smrg dir= 2531aee7dae4Smrg case $file in 2532aee7dae4Smrg *.la) 2533aee7dae4Smrg func_resolve_sysroot "$file" 2534aee7dae4Smrg file=$func_resolve_sysroot_result 2535aee7dae4Smrg 2536aee7dae4Smrg # Check to see that this really is a libtool archive. 2537aee7dae4Smrg func_lalib_unsafe_p "$file" \ 2538aee7dae4Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 2539aee7dae4Smrg 2540aee7dae4Smrg # Read the libtool library. 2541aee7dae4Smrg dlname= 2542aee7dae4Smrg library_names= 2543aee7dae4Smrg func_source "$file" 2544aee7dae4Smrg 2545aee7dae4Smrg # Skip this library if it cannot be dlopened. 2546aee7dae4Smrg if test -z "$dlname"; then 2547aee7dae4Smrg # Warn if it was a shared library. 2548aee7dae4Smrg test -n "$library_names" && \ 2549aee7dae4Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 2550aee7dae4Smrg continue 2551aee7dae4Smrg fi 2552aee7dae4Smrg 2553aee7dae4Smrg func_dirname "$file" "" "." 2554aee7dae4Smrg dir="$func_dirname_result" 2555aee7dae4Smrg 2556aee7dae4Smrg if test -f "$dir/$objdir/$dlname"; then 2557aee7dae4Smrg func_append dir "/$objdir" 2558aee7dae4Smrg else 2559aee7dae4Smrg if test ! -f "$dir/$dlname"; then 2560aee7dae4Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 2561aee7dae4Smrg fi 2562aee7dae4Smrg fi 2563aee7dae4Smrg ;; 2564aee7dae4Smrg 2565aee7dae4Smrg *.lo) 2566aee7dae4Smrg # Just add the directory containing the .lo file. 2567aee7dae4Smrg func_dirname "$file" "" "." 2568aee7dae4Smrg dir="$func_dirname_result" 2569aee7dae4Smrg ;; 2570aee7dae4Smrg 2571aee7dae4Smrg *) 2572aee7dae4Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 2573aee7dae4Smrg continue 2574aee7dae4Smrg ;; 2575aee7dae4Smrg esac 2576aee7dae4Smrg 2577aee7dae4Smrg # Get the absolute pathname. 2578aee7dae4Smrg absdir=`cd "$dir" && pwd` 2579aee7dae4Smrg test -n "$absdir" && dir="$absdir" 2580aee7dae4Smrg 2581aee7dae4Smrg # Now add the directory to shlibpath_var. 2582aee7dae4Smrg if eval "test -z \"\$$shlibpath_var\""; then 2583aee7dae4Smrg eval "$shlibpath_var=\"\$dir\"" 2584aee7dae4Smrg else 2585aee7dae4Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2586aee7dae4Smrg fi 2587aee7dae4Smrg done 2588aee7dae4Smrg 2589aee7dae4Smrg # This variable tells wrapper scripts just to set shlibpath_var 2590aee7dae4Smrg # rather than running their programs. 2591aee7dae4Smrg libtool_execute_magic="$magic" 2592aee7dae4Smrg 2593aee7dae4Smrg # Check if any of the arguments is a wrapper script. 2594aee7dae4Smrg args= 2595aee7dae4Smrg for file 2596aee7dae4Smrg do 2597aee7dae4Smrg case $file in 2598aee7dae4Smrg -* | *.la | *.lo ) ;; 2599aee7dae4Smrg *) 2600aee7dae4Smrg # Do a test to see if this is really a libtool program. 2601aee7dae4Smrg if func_ltwrapper_script_p "$file"; then 2602aee7dae4Smrg func_source "$file" 2603aee7dae4Smrg # Transform arg to wrapped name. 2604aee7dae4Smrg file="$progdir/$program" 2605aee7dae4Smrg elif func_ltwrapper_executable_p "$file"; then 2606aee7dae4Smrg func_ltwrapper_scriptname "$file" 2607aee7dae4Smrg func_source "$func_ltwrapper_scriptname_result" 2608aee7dae4Smrg # Transform arg to wrapped name. 2609aee7dae4Smrg file="$progdir/$program" 2610aee7dae4Smrg fi 2611aee7dae4Smrg ;; 2612aee7dae4Smrg esac 2613aee7dae4Smrg # Quote arguments (to preserve shell metacharacters). 2614aee7dae4Smrg func_append_quoted args "$file" 2615aee7dae4Smrg done 2616aee7dae4Smrg 2617aee7dae4Smrg if test "X$opt_dry_run" = Xfalse; then 2618aee7dae4Smrg if test -n "$shlibpath_var"; then 2619aee7dae4Smrg # Export the shlibpath_var. 2620aee7dae4Smrg eval "export $shlibpath_var" 2621aee7dae4Smrg fi 2622aee7dae4Smrg 2623aee7dae4Smrg # Restore saved environment variables 2624aee7dae4Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 2625aee7dae4Smrg do 2626aee7dae4Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 2627aee7dae4Smrg $lt_var=\$save_$lt_var; export $lt_var 2628aee7dae4Smrg else 2629aee7dae4Smrg $lt_unset $lt_var 2630aee7dae4Smrg fi" 2631aee7dae4Smrg done 2632aee7dae4Smrg 2633aee7dae4Smrg # Now prepare to actually exec the command. 2634aee7dae4Smrg exec_cmd="\$cmd$args" 2635aee7dae4Smrg else 2636aee7dae4Smrg # Display what would be done. 2637aee7dae4Smrg if test -n "$shlibpath_var"; then 2638aee7dae4Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 2639aee7dae4Smrg echo "export $shlibpath_var" 2640aee7dae4Smrg fi 2641aee7dae4Smrg $ECHO "$cmd$args" 2642aee7dae4Smrg exit $EXIT_SUCCESS 2643aee7dae4Smrg fi 2644aee7dae4Smrg} 2645aee7dae4Smrg 2646aee7dae4Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2647aee7dae4Smrg 2648aee7dae4Smrg 2649aee7dae4Smrg# func_mode_finish arg... 2650aee7dae4Smrgfunc_mode_finish () 2651aee7dae4Smrg{ 2652aee7dae4Smrg $opt_debug 2653aee7dae4Smrg libs= 2654aee7dae4Smrg libdirs= 2655aee7dae4Smrg admincmds= 2656aee7dae4Smrg 2657aee7dae4Smrg for opt in "$nonopt" ${1+"$@"} 2658aee7dae4Smrg do 2659aee7dae4Smrg if test -d "$opt"; then 2660aee7dae4Smrg func_append libdirs " $opt" 2661aee7dae4Smrg 2662aee7dae4Smrg elif test -f "$opt"; then 2663aee7dae4Smrg if func_lalib_unsafe_p "$opt"; then 2664aee7dae4Smrg func_append libs " $opt" 2665aee7dae4Smrg else 2666aee7dae4Smrg func_warning "\`$opt' is not a valid libtool archive" 2667aee7dae4Smrg fi 2668aee7dae4Smrg 2669aee7dae4Smrg else 2670aee7dae4Smrg func_fatal_error "invalid argument \`$opt'" 2671aee7dae4Smrg fi 2672aee7dae4Smrg done 2673aee7dae4Smrg 2674aee7dae4Smrg if test -n "$libs"; then 2675aee7dae4Smrg if test -n "$lt_sysroot"; then 2676aee7dae4Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 2677aee7dae4Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 2678aee7dae4Smrg else 2679aee7dae4Smrg sysroot_cmd= 2680aee7dae4Smrg fi 2681aee7dae4Smrg 2682aee7dae4Smrg # Remove sysroot references 2683aee7dae4Smrg if $opt_dry_run; then 2684aee7dae4Smrg for lib in $libs; do 2685aee7dae4Smrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 2686aee7dae4Smrg done 2687aee7dae4Smrg else 2688aee7dae4Smrg tmpdir=`func_mktempdir` 2689aee7dae4Smrg for lib in $libs; do 2690aee7dae4Smrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 2691aee7dae4Smrg > $tmpdir/tmp-la 2692aee7dae4Smrg mv -f $tmpdir/tmp-la $lib 2693aee7dae4Smrg done 2694aee7dae4Smrg ${RM}r "$tmpdir" 2695aee7dae4Smrg fi 2696aee7dae4Smrg fi 2697aee7dae4Smrg 2698aee7dae4Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2699aee7dae4Smrg for libdir in $libdirs; do 2700aee7dae4Smrg if test -n "$finish_cmds"; then 2701aee7dae4Smrg # Do each command in the finish commands. 2702aee7dae4Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 2703aee7dae4Smrg'"$cmd"'"' 2704aee7dae4Smrg fi 2705aee7dae4Smrg if test -n "$finish_eval"; then 2706aee7dae4Smrg # Do the single finish_eval. 2707aee7dae4Smrg eval cmds=\"$finish_eval\" 2708aee7dae4Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 2709aee7dae4Smrg $cmds" 2710aee7dae4Smrg fi 2711aee7dae4Smrg done 2712aee7dae4Smrg fi 2713aee7dae4Smrg 2714aee7dae4Smrg # Exit here if they wanted silent mode. 2715aee7dae4Smrg $opt_silent && exit $EXIT_SUCCESS 2716aee7dae4Smrg 2717aee7dae4Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2718aee7dae4Smrg echo "----------------------------------------------------------------------" 2719aee7dae4Smrg echo "Libraries have been installed in:" 2720aee7dae4Smrg for libdir in $libdirs; do 2721aee7dae4Smrg $ECHO " $libdir" 2722aee7dae4Smrg done 2723aee7dae4Smrg echo 2724aee7dae4Smrg echo "If you ever happen to want to link against installed libraries" 2725aee7dae4Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 2726aee7dae4Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 2727aee7dae4Smrg echo "flag during linking and do at least one of the following:" 2728aee7dae4Smrg if test -n "$shlibpath_var"; then 2729aee7dae4Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 2730aee7dae4Smrg echo " during execution" 2731aee7dae4Smrg fi 2732aee7dae4Smrg if test -n "$runpath_var"; then 2733aee7dae4Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 2734aee7dae4Smrg echo " during linking" 2735aee7dae4Smrg fi 2736aee7dae4Smrg if test -n "$hardcode_libdir_flag_spec"; then 2737aee7dae4Smrg libdir=LIBDIR 2738aee7dae4Smrg eval flag=\"$hardcode_libdir_flag_spec\" 2739aee7dae4Smrg 2740aee7dae4Smrg $ECHO " - use the \`$flag' linker flag" 2741aee7dae4Smrg fi 2742aee7dae4Smrg if test -n "$admincmds"; then 2743aee7dae4Smrg $ECHO " - have your system administrator run these commands:$admincmds" 2744aee7dae4Smrg fi 2745aee7dae4Smrg if test -f /etc/ld.so.conf; then 2746aee7dae4Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 2747aee7dae4Smrg fi 2748aee7dae4Smrg echo 2749aee7dae4Smrg 2750aee7dae4Smrg echo "See any operating system documentation about shared libraries for" 2751aee7dae4Smrg case $host in 2752aee7dae4Smrg solaris2.[6789]|solaris2.1[0-9]) 2753aee7dae4Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 2754aee7dae4Smrg echo "pages." 2755aee7dae4Smrg ;; 2756aee7dae4Smrg *) 2757aee7dae4Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 2758aee7dae4Smrg ;; 2759aee7dae4Smrg esac 2760aee7dae4Smrg echo "----------------------------------------------------------------------" 2761aee7dae4Smrg fi 2762aee7dae4Smrg exit $EXIT_SUCCESS 2763aee7dae4Smrg} 2764aee7dae4Smrg 2765aee7dae4Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2766aee7dae4Smrg 2767aee7dae4Smrg 2768aee7dae4Smrg# func_mode_install arg... 2769aee7dae4Smrgfunc_mode_install () 2770aee7dae4Smrg{ 2771aee7dae4Smrg $opt_debug 2772aee7dae4Smrg # There may be an optional sh(1) argument at the beginning of 2773aee7dae4Smrg # install_prog (especially on Windows NT). 2774aee7dae4Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 2775aee7dae4Smrg # Allow the use of GNU shtool's install command. 2776aee7dae4Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 2777aee7dae4Smrg # Aesthetically quote it. 2778aee7dae4Smrg func_quote_for_eval "$nonopt" 2779aee7dae4Smrg install_prog="$func_quote_for_eval_result " 2780aee7dae4Smrg arg=$1 2781aee7dae4Smrg shift 2782aee7dae4Smrg else 2783aee7dae4Smrg install_prog= 2784aee7dae4Smrg arg=$nonopt 2785aee7dae4Smrg fi 2786aee7dae4Smrg 2787aee7dae4Smrg # The real first argument should be the name of the installation program. 2788aee7dae4Smrg # Aesthetically quote it. 2789aee7dae4Smrg func_quote_for_eval "$arg" 2790aee7dae4Smrg func_append install_prog "$func_quote_for_eval_result" 2791aee7dae4Smrg install_shared_prog=$install_prog 2792aee7dae4Smrg case " $install_prog " in 2793aee7dae4Smrg *[\\\ /]cp\ *) install_cp=: ;; 2794aee7dae4Smrg *) install_cp=false ;; 2795aee7dae4Smrg esac 2796aee7dae4Smrg 2797aee7dae4Smrg # We need to accept at least all the BSD install flags. 2798aee7dae4Smrg dest= 2799aee7dae4Smrg files= 2800aee7dae4Smrg opts= 2801aee7dae4Smrg prev= 2802aee7dae4Smrg install_type= 2803aee7dae4Smrg isdir=no 2804aee7dae4Smrg stripme= 2805aee7dae4Smrg no_mode=: 2806aee7dae4Smrg for arg 2807aee7dae4Smrg do 2808aee7dae4Smrg arg2= 2809aee7dae4Smrg if test -n "$dest"; then 2810aee7dae4Smrg func_append files " $dest" 2811aee7dae4Smrg dest=$arg 2812aee7dae4Smrg continue 2813aee7dae4Smrg fi 2814aee7dae4Smrg 2815aee7dae4Smrg case $arg in 2816aee7dae4Smrg -d) isdir=yes ;; 2817aee7dae4Smrg -f) 2818aee7dae4Smrg if $install_cp; then :; else 2819aee7dae4Smrg prev=$arg 2820aee7dae4Smrg fi 2821aee7dae4Smrg ;; 2822aee7dae4Smrg -g | -m | -o) 2823aee7dae4Smrg prev=$arg 2824aee7dae4Smrg ;; 2825aee7dae4Smrg -s) 2826aee7dae4Smrg stripme=" -s" 2827aee7dae4Smrg continue 2828aee7dae4Smrg ;; 2829aee7dae4Smrg -*) 2830aee7dae4Smrg ;; 2831aee7dae4Smrg *) 2832aee7dae4Smrg # If the previous option needed an argument, then skip it. 2833aee7dae4Smrg if test -n "$prev"; then 2834aee7dae4Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 2835aee7dae4Smrg arg2=$install_override_mode 2836aee7dae4Smrg no_mode=false 2837aee7dae4Smrg fi 2838aee7dae4Smrg prev= 2839aee7dae4Smrg else 2840aee7dae4Smrg dest=$arg 2841aee7dae4Smrg continue 2842aee7dae4Smrg fi 2843aee7dae4Smrg ;; 2844aee7dae4Smrg esac 2845aee7dae4Smrg 2846aee7dae4Smrg # Aesthetically quote the argument. 2847aee7dae4Smrg func_quote_for_eval "$arg" 2848aee7dae4Smrg func_append install_prog " $func_quote_for_eval_result" 2849aee7dae4Smrg if test -n "$arg2"; then 2850aee7dae4Smrg func_quote_for_eval "$arg2" 2851aee7dae4Smrg fi 2852aee7dae4Smrg func_append install_shared_prog " $func_quote_for_eval_result" 2853aee7dae4Smrg done 2854aee7dae4Smrg 2855aee7dae4Smrg test -z "$install_prog" && \ 2856aee7dae4Smrg func_fatal_help "you must specify an install program" 2857aee7dae4Smrg 2858aee7dae4Smrg test -n "$prev" && \ 2859aee7dae4Smrg func_fatal_help "the \`$prev' option requires an argument" 2860aee7dae4Smrg 2861aee7dae4Smrg if test -n "$install_override_mode" && $no_mode; then 2862aee7dae4Smrg if $install_cp; then :; else 2863aee7dae4Smrg func_quote_for_eval "$install_override_mode" 2864aee7dae4Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 2865aee7dae4Smrg fi 2866aee7dae4Smrg fi 2867aee7dae4Smrg 2868aee7dae4Smrg if test -z "$files"; then 2869aee7dae4Smrg if test -z "$dest"; then 2870aee7dae4Smrg func_fatal_help "no file or destination specified" 2871aee7dae4Smrg else 2872aee7dae4Smrg func_fatal_help "you must specify a destination" 2873aee7dae4Smrg fi 2874aee7dae4Smrg fi 2875aee7dae4Smrg 2876aee7dae4Smrg # Strip any trailing slash from the destination. 2877aee7dae4Smrg func_stripname '' '/' "$dest" 2878aee7dae4Smrg dest=$func_stripname_result 2879aee7dae4Smrg 2880aee7dae4Smrg # Check to see that the destination is a directory. 2881aee7dae4Smrg test -d "$dest" && isdir=yes 2882aee7dae4Smrg if test "$isdir" = yes; then 2883aee7dae4Smrg destdir="$dest" 2884aee7dae4Smrg destname= 2885aee7dae4Smrg else 2886aee7dae4Smrg func_dirname_and_basename "$dest" "" "." 2887aee7dae4Smrg destdir="$func_dirname_result" 2888aee7dae4Smrg destname="$func_basename_result" 2889aee7dae4Smrg 2890aee7dae4Smrg # Not a directory, so check to see that there is only one file specified. 2891aee7dae4Smrg set dummy $files; shift 2892aee7dae4Smrg test "$#" -gt 1 && \ 2893aee7dae4Smrg func_fatal_help "\`$dest' is not a directory" 2894aee7dae4Smrg fi 2895aee7dae4Smrg case $destdir in 2896aee7dae4Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 2897aee7dae4Smrg *) 2898aee7dae4Smrg for file in $files; do 2899aee7dae4Smrg case $file in 2900aee7dae4Smrg *.lo) ;; 2901aee7dae4Smrg *) 2902aee7dae4Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 2903aee7dae4Smrg ;; 2904aee7dae4Smrg esac 2905aee7dae4Smrg done 2906aee7dae4Smrg ;; 2907aee7dae4Smrg esac 2908aee7dae4Smrg 2909aee7dae4Smrg # This variable tells wrapper scripts just to set variables rather 2910aee7dae4Smrg # than running their programs. 2911aee7dae4Smrg libtool_install_magic="$magic" 2912aee7dae4Smrg 2913aee7dae4Smrg staticlibs= 2914aee7dae4Smrg future_libdirs= 2915aee7dae4Smrg current_libdirs= 2916aee7dae4Smrg for file in $files; do 2917aee7dae4Smrg 2918aee7dae4Smrg # Do each installation. 2919aee7dae4Smrg case $file in 2920aee7dae4Smrg *.$libext) 2921aee7dae4Smrg # Do the static libraries later. 2922aee7dae4Smrg func_append staticlibs " $file" 2923aee7dae4Smrg ;; 2924aee7dae4Smrg 2925aee7dae4Smrg *.la) 2926aee7dae4Smrg func_resolve_sysroot "$file" 2927aee7dae4Smrg file=$func_resolve_sysroot_result 2928aee7dae4Smrg 2929aee7dae4Smrg # Check to see that this really is a libtool archive. 2930aee7dae4Smrg func_lalib_unsafe_p "$file" \ 2931aee7dae4Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 2932aee7dae4Smrg 2933aee7dae4Smrg library_names= 2934aee7dae4Smrg old_library= 2935aee7dae4Smrg relink_command= 2936aee7dae4Smrg func_source "$file" 2937aee7dae4Smrg 2938aee7dae4Smrg # Add the libdir to current_libdirs if it is the destination. 2939aee7dae4Smrg if test "X$destdir" = "X$libdir"; then 2940aee7dae4Smrg case "$current_libdirs " in 2941aee7dae4Smrg *" $libdir "*) ;; 2942aee7dae4Smrg *) func_append current_libdirs " $libdir" ;; 2943aee7dae4Smrg esac 2944aee7dae4Smrg else 2945aee7dae4Smrg # Note the libdir as a future libdir. 2946aee7dae4Smrg case "$future_libdirs " in 2947aee7dae4Smrg *" $libdir "*) ;; 2948aee7dae4Smrg *) func_append future_libdirs " $libdir" ;; 2949aee7dae4Smrg esac 2950aee7dae4Smrg fi 2951aee7dae4Smrg 2952aee7dae4Smrg func_dirname "$file" "/" "" 2953aee7dae4Smrg dir="$func_dirname_result" 2954aee7dae4Smrg func_append dir "$objdir" 2955aee7dae4Smrg 2956aee7dae4Smrg if test -n "$relink_command"; then 2957aee7dae4Smrg # Determine the prefix the user has applied to our future dir. 2958aee7dae4Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2959aee7dae4Smrg 2960aee7dae4Smrg # Don't allow the user to place us outside of our expected 2961aee7dae4Smrg # location b/c this prevents finding dependent libraries that 2962aee7dae4Smrg # are installed to the same prefix. 2963aee7dae4Smrg # At present, this check doesn't affect windows .dll's that 2964aee7dae4Smrg # are installed into $libdir/../bin (currently, that works fine) 2965aee7dae4Smrg # but it's something to keep an eye on. 2966aee7dae4Smrg test "$inst_prefix_dir" = "$destdir" && \ 2967aee7dae4Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 2968aee7dae4Smrg 2969aee7dae4Smrg if test -n "$inst_prefix_dir"; then 2970aee7dae4Smrg # Stick the inst_prefix_dir data into the link command. 2971aee7dae4Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2972aee7dae4Smrg else 2973aee7dae4Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2974aee7dae4Smrg fi 2975aee7dae4Smrg 2976aee7dae4Smrg func_warning "relinking \`$file'" 2977aee7dae4Smrg func_show_eval "$relink_command" \ 2978aee7dae4Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 2979aee7dae4Smrg fi 2980aee7dae4Smrg 2981aee7dae4Smrg # See the names of the shared library. 2982aee7dae4Smrg set dummy $library_names; shift 2983aee7dae4Smrg if test -n "$1"; then 2984aee7dae4Smrg realname="$1" 2985aee7dae4Smrg shift 2986aee7dae4Smrg 2987aee7dae4Smrg srcname="$realname" 2988aee7dae4Smrg test -n "$relink_command" && srcname="$realname"T 2989aee7dae4Smrg 2990aee7dae4Smrg # Install the shared library and build the symlinks. 2991aee7dae4Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 2992aee7dae4Smrg 'exit $?' 2993aee7dae4Smrg tstripme="$stripme" 2994aee7dae4Smrg case $host_os in 2995aee7dae4Smrg cygwin* | mingw* | pw32* | cegcc*) 2996aee7dae4Smrg case $realname in 2997aee7dae4Smrg *.dll.a) 2998aee7dae4Smrg tstripme="" 2999aee7dae4Smrg ;; 3000aee7dae4Smrg esac 3001aee7dae4Smrg ;; 3002aee7dae4Smrg esac 3003aee7dae4Smrg if test -n "$tstripme" && test -n "$striplib"; then 3004aee7dae4Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 3005aee7dae4Smrg fi 3006aee7dae4Smrg 3007aee7dae4Smrg if test "$#" -gt 0; then 3008aee7dae4Smrg # Delete the old symlinks, and create new ones. 3009aee7dae4Smrg # Try `ln -sf' first, because the `ln' binary might depend on 3010aee7dae4Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 3011aee7dae4Smrg # so we also need to try rm && ln -s. 3012aee7dae4Smrg for linkname 3013aee7dae4Smrg do 3014aee7dae4Smrg test "$linkname" != "$realname" \ 3015aee7dae4Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3016aee7dae4Smrg done 3017aee7dae4Smrg fi 3018aee7dae4Smrg 3019aee7dae4Smrg # Do each command in the postinstall commands. 3020aee7dae4Smrg lib="$destdir/$realname" 3021aee7dae4Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 3022aee7dae4Smrg fi 3023aee7dae4Smrg 3024aee7dae4Smrg # Install the pseudo-library for information purposes. 3025aee7dae4Smrg func_basename "$file" 3026aee7dae4Smrg name="$func_basename_result" 3027aee7dae4Smrg instname="$dir/$name"i 3028aee7dae4Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3029aee7dae4Smrg 3030aee7dae4Smrg # Maybe install the static library, too. 3031aee7dae4Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 3032aee7dae4Smrg ;; 3033aee7dae4Smrg 3034aee7dae4Smrg *.lo) 3035aee7dae4Smrg # Install (i.e. copy) a libtool object. 3036aee7dae4Smrg 3037aee7dae4Smrg # Figure out destination file name, if it wasn't already specified. 3038aee7dae4Smrg if test -n "$destname"; then 3039aee7dae4Smrg destfile="$destdir/$destname" 3040aee7dae4Smrg else 3041aee7dae4Smrg func_basename "$file" 3042aee7dae4Smrg destfile="$func_basename_result" 3043aee7dae4Smrg destfile="$destdir/$destfile" 3044aee7dae4Smrg fi 3045aee7dae4Smrg 3046aee7dae4Smrg # Deduce the name of the destination old-style object file. 3047aee7dae4Smrg case $destfile in 3048aee7dae4Smrg *.lo) 3049aee7dae4Smrg func_lo2o "$destfile" 3050aee7dae4Smrg staticdest=$func_lo2o_result 3051aee7dae4Smrg ;; 3052aee7dae4Smrg *.$objext) 3053aee7dae4Smrg staticdest="$destfile" 3054aee7dae4Smrg destfile= 3055aee7dae4Smrg ;; 3056aee7dae4Smrg *) 3057aee7dae4Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 3058aee7dae4Smrg ;; 3059aee7dae4Smrg esac 3060aee7dae4Smrg 3061aee7dae4Smrg # Install the libtool object if requested. 3062aee7dae4Smrg test -n "$destfile" && \ 3063aee7dae4Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 3064aee7dae4Smrg 3065aee7dae4Smrg # Install the old object if enabled. 3066aee7dae4Smrg if test "$build_old_libs" = yes; then 3067aee7dae4Smrg # Deduce the name of the old-style object file. 3068aee7dae4Smrg func_lo2o "$file" 3069aee7dae4Smrg staticobj=$func_lo2o_result 3070aee7dae4Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3071aee7dae4Smrg fi 3072aee7dae4Smrg exit $EXIT_SUCCESS 3073aee7dae4Smrg ;; 3074aee7dae4Smrg 3075aee7dae4Smrg *) 3076aee7dae4Smrg # Figure out destination file name, if it wasn't already specified. 3077aee7dae4Smrg if test -n "$destname"; then 3078aee7dae4Smrg destfile="$destdir/$destname" 3079aee7dae4Smrg else 3080aee7dae4Smrg func_basename "$file" 3081aee7dae4Smrg destfile="$func_basename_result" 3082aee7dae4Smrg destfile="$destdir/$destfile" 3083aee7dae4Smrg fi 3084aee7dae4Smrg 3085aee7dae4Smrg # If the file is missing, and there is a .exe on the end, strip it 3086aee7dae4Smrg # because it is most likely a libtool script we actually want to 3087aee7dae4Smrg # install 3088aee7dae4Smrg stripped_ext="" 3089aee7dae4Smrg case $file in 3090aee7dae4Smrg *.exe) 3091aee7dae4Smrg if test ! -f "$file"; then 3092aee7dae4Smrg func_stripname '' '.exe' "$file" 3093aee7dae4Smrg file=$func_stripname_result 3094aee7dae4Smrg stripped_ext=".exe" 3095aee7dae4Smrg fi 3096aee7dae4Smrg ;; 3097aee7dae4Smrg esac 3098aee7dae4Smrg 3099aee7dae4Smrg # Do a test to see if this is really a libtool program. 3100aee7dae4Smrg case $host in 3101aee7dae4Smrg *cygwin* | *mingw*) 3102aee7dae4Smrg if func_ltwrapper_executable_p "$file"; then 3103aee7dae4Smrg func_ltwrapper_scriptname "$file" 3104aee7dae4Smrg wrapper=$func_ltwrapper_scriptname_result 3105aee7dae4Smrg else 3106aee7dae4Smrg func_stripname '' '.exe' "$file" 3107aee7dae4Smrg wrapper=$func_stripname_result 3108aee7dae4Smrg fi 3109aee7dae4Smrg ;; 3110aee7dae4Smrg *) 3111aee7dae4Smrg wrapper=$file 3112aee7dae4Smrg ;; 3113aee7dae4Smrg esac 3114aee7dae4Smrg if func_ltwrapper_script_p "$wrapper"; then 3115aee7dae4Smrg notinst_deplibs= 3116aee7dae4Smrg relink_command= 3117aee7dae4Smrg 3118aee7dae4Smrg func_source "$wrapper" 3119aee7dae4Smrg 3120aee7dae4Smrg # Check the variables that should have been set. 3121aee7dae4Smrg test -z "$generated_by_libtool_version" && \ 3122aee7dae4Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3123aee7dae4Smrg 3124aee7dae4Smrg finalize=yes 3125aee7dae4Smrg for lib in $notinst_deplibs; do 3126aee7dae4Smrg # Check to see that each library is installed. 3127aee7dae4Smrg libdir= 3128aee7dae4Smrg if test -f "$lib"; then 3129aee7dae4Smrg func_source "$lib" 3130aee7dae4Smrg fi 3131aee7dae4Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 3132aee7dae4Smrg if test -n "$libdir" && test ! -f "$libfile"; then 3133aee7dae4Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 3134aee7dae4Smrg finalize=no 3135aee7dae4Smrg fi 3136aee7dae4Smrg done 3137aee7dae4Smrg 3138aee7dae4Smrg relink_command= 3139aee7dae4Smrg func_source "$wrapper" 3140aee7dae4Smrg 3141aee7dae4Smrg outputname= 3142aee7dae4Smrg if test "$fast_install" = no && test -n "$relink_command"; then 3143aee7dae4Smrg $opt_dry_run || { 3144aee7dae4Smrg if test "$finalize" = yes; then 3145aee7dae4Smrg tmpdir=`func_mktempdir` 3146aee7dae4Smrg func_basename "$file$stripped_ext" 3147aee7dae4Smrg file="$func_basename_result" 3148aee7dae4Smrg outputname="$tmpdir/$file" 3149aee7dae4Smrg # Replace the output file specification. 3150aee7dae4Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 3151aee7dae4Smrg 3152aee7dae4Smrg $opt_silent || { 3153aee7dae4Smrg func_quote_for_expand "$relink_command" 3154aee7dae4Smrg eval "func_echo $func_quote_for_expand_result" 3155aee7dae4Smrg } 3156aee7dae4Smrg if eval "$relink_command"; then : 3157aee7dae4Smrg else 3158aee7dae4Smrg func_error "error: relink \`$file' with the above command before installing it" 3159aee7dae4Smrg $opt_dry_run || ${RM}r "$tmpdir" 3160aee7dae4Smrg continue 3161aee7dae4Smrg fi 3162aee7dae4Smrg file="$outputname" 3163aee7dae4Smrg else 3164aee7dae4Smrg func_warning "cannot relink \`$file'" 3165aee7dae4Smrg fi 3166aee7dae4Smrg } 3167aee7dae4Smrg else 3168aee7dae4Smrg # Install the binary that we compiled earlier. 3169aee7dae4Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 3170aee7dae4Smrg fi 3171aee7dae4Smrg fi 3172aee7dae4Smrg 3173aee7dae4Smrg # remove .exe since cygwin /usr/bin/install will append another 3174aee7dae4Smrg # one anyway 3175aee7dae4Smrg case $install_prog,$host in 3176aee7dae4Smrg */usr/bin/install*,*cygwin*) 3177aee7dae4Smrg case $file:$destfile in 3178aee7dae4Smrg *.exe:*.exe) 3179aee7dae4Smrg # this is ok 3180aee7dae4Smrg ;; 3181aee7dae4Smrg *.exe:*) 3182aee7dae4Smrg destfile=$destfile.exe 3183aee7dae4Smrg ;; 3184aee7dae4Smrg *:*.exe) 3185aee7dae4Smrg func_stripname '' '.exe' "$destfile" 3186aee7dae4Smrg destfile=$func_stripname_result 3187aee7dae4Smrg ;; 3188aee7dae4Smrg esac 3189aee7dae4Smrg ;; 3190aee7dae4Smrg esac 3191aee7dae4Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 3192aee7dae4Smrg $opt_dry_run || if test -n "$outputname"; then 3193aee7dae4Smrg ${RM}r "$tmpdir" 3194aee7dae4Smrg fi 3195aee7dae4Smrg ;; 3196aee7dae4Smrg esac 3197aee7dae4Smrg done 3198aee7dae4Smrg 3199aee7dae4Smrg for file in $staticlibs; do 3200aee7dae4Smrg func_basename "$file" 3201aee7dae4Smrg name="$func_basename_result" 3202aee7dae4Smrg 3203aee7dae4Smrg # Set up the ranlib parameters. 3204aee7dae4Smrg oldlib="$destdir/$name" 3205aee7dae4Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 3206aee7dae4Smrg tool_oldlib=$func_to_tool_file_result 3207aee7dae4Smrg 3208aee7dae4Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 3209aee7dae4Smrg 3210aee7dae4Smrg if test -n "$stripme" && test -n "$old_striplib"; then 3211aee7dae4Smrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 3212aee7dae4Smrg fi 3213aee7dae4Smrg 3214aee7dae4Smrg # Do each command in the postinstall commands. 3215aee7dae4Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 3216aee7dae4Smrg done 3217aee7dae4Smrg 3218aee7dae4Smrg test -n "$future_libdirs" && \ 3219aee7dae4Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 3220aee7dae4Smrg 3221aee7dae4Smrg if test -n "$current_libdirs"; then 3222aee7dae4Smrg # Maybe just do a dry run. 3223aee7dae4Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 3224aee7dae4Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 3225aee7dae4Smrg else 3226aee7dae4Smrg exit $EXIT_SUCCESS 3227aee7dae4Smrg fi 3228aee7dae4Smrg} 3229aee7dae4Smrg 3230aee7dae4Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 3231aee7dae4Smrg 3232aee7dae4Smrg 3233aee7dae4Smrg# func_generate_dlsyms outputname originator pic_p 3234aee7dae4Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 3235aee7dae4Smrg# a dlpreopen symbol table. 3236aee7dae4Smrgfunc_generate_dlsyms () 3237aee7dae4Smrg{ 3238aee7dae4Smrg $opt_debug 3239aee7dae4Smrg my_outputname="$1" 3240aee7dae4Smrg my_originator="$2" 3241aee7dae4Smrg my_pic_p="${3-no}" 3242aee7dae4Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 3243aee7dae4Smrg my_dlsyms= 3244aee7dae4Smrg 3245aee7dae4Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 3246aee7dae4Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 3247aee7dae4Smrg my_dlsyms="${my_outputname}S.c" 3248aee7dae4Smrg else 3249aee7dae4Smrg func_error "not configured to extract global symbols from dlpreopened files" 3250aee7dae4Smrg fi 3251aee7dae4Smrg fi 3252aee7dae4Smrg 3253aee7dae4Smrg if test -n "$my_dlsyms"; then 3254aee7dae4Smrg case $my_dlsyms in 3255aee7dae4Smrg "") ;; 3256aee7dae4Smrg *.c) 3257aee7dae4Smrg # Discover the nlist of each of the dlfiles. 3258aee7dae4Smrg nlist="$output_objdir/${my_outputname}.nm" 3259aee7dae4Smrg 3260aee7dae4Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3261aee7dae4Smrg 3262aee7dae4Smrg # Parse the name list into a source file. 3263aee7dae4Smrg func_verbose "creating $output_objdir/$my_dlsyms" 3264aee7dae4Smrg 3265aee7dae4Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 3266aee7dae4Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 3267aee7dae4Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3268aee7dae4Smrg 3269aee7dae4Smrg#ifdef __cplusplus 3270aee7dae4Smrgextern \"C\" { 3271aee7dae4Smrg#endif 3272aee7dae4Smrg 3273aee7dae4Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 3274aee7dae4Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 3275aee7dae4Smrg#endif 3276aee7dae4Smrg 3277aee7dae4Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 3278aee7dae4Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 3279aee7dae4Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 3280aee7dae4Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 3281aee7dae4Smrg# define LT_DLSYM_CONST 3282aee7dae4Smrg#elif defined(__osf__) 3283aee7dae4Smrg/* This system does not cope well with relocations in const data. */ 3284aee7dae4Smrg# define LT_DLSYM_CONST 3285aee7dae4Smrg#else 3286aee7dae4Smrg# define LT_DLSYM_CONST const 3287aee7dae4Smrg#endif 3288aee7dae4Smrg 3289aee7dae4Smrg/* External symbol declarations for the compiler. */\ 3290aee7dae4Smrg" 3291aee7dae4Smrg 3292aee7dae4Smrg if test "$dlself" = yes; then 3293aee7dae4Smrg func_verbose "generating symbol list for \`$output'" 3294aee7dae4Smrg 3295aee7dae4Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3296aee7dae4Smrg 3297aee7dae4Smrg # Add our own program objects to the symbol list. 3298aee7dae4Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 3299aee7dae4Smrg for progfile in $progfiles; do 3300aee7dae4Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 3301aee7dae4Smrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 3302aee7dae4Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3303aee7dae4Smrg done 3304aee7dae4Smrg 3305aee7dae4Smrg if test -n "$exclude_expsyms"; then 3306aee7dae4Smrg $opt_dry_run || { 3307aee7dae4Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 3308aee7dae4Smrg eval '$MV "$nlist"T "$nlist"' 3309aee7dae4Smrg } 3310aee7dae4Smrg fi 3311aee7dae4Smrg 3312aee7dae4Smrg if test -n "$export_symbols_regex"; then 3313aee7dae4Smrg $opt_dry_run || { 3314aee7dae4Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 3315aee7dae4Smrg eval '$MV "$nlist"T "$nlist"' 3316aee7dae4Smrg } 3317aee7dae4Smrg fi 3318aee7dae4Smrg 3319aee7dae4Smrg # Prepare the list of exported symbols 3320aee7dae4Smrg if test -z "$export_symbols"; then 3321aee7dae4Smrg export_symbols="$output_objdir/$outputname.exp" 3322aee7dae4Smrg $opt_dry_run || { 3323aee7dae4Smrg $RM $export_symbols 3324aee7dae4Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 3325aee7dae4Smrg case $host in 3326aee7dae4Smrg *cygwin* | *mingw* | *cegcc* ) 3327aee7dae4Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3328aee7dae4Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 3329aee7dae4Smrg ;; 3330aee7dae4Smrg esac 3331aee7dae4Smrg } 3332aee7dae4Smrg else 3333aee7dae4Smrg $opt_dry_run || { 3334aee7dae4Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 3335aee7dae4Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 3336aee7dae4Smrg eval '$MV "$nlist"T "$nlist"' 3337aee7dae4Smrg case $host in 3338aee7dae4Smrg *cygwin* | *mingw* | *cegcc* ) 3339aee7dae4Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3340aee7dae4Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 3341aee7dae4Smrg ;; 3342aee7dae4Smrg esac 3343aee7dae4Smrg } 3344aee7dae4Smrg fi 3345aee7dae4Smrg fi 3346aee7dae4Smrg 3347aee7dae4Smrg for dlprefile in $dlprefiles; do 3348aee7dae4Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 3349aee7dae4Smrg func_basename "$dlprefile" 3350aee7dae4Smrg name="$func_basename_result" 3351aee7dae4Smrg case $host in 3352aee7dae4Smrg *cygwin* | *mingw* | *cegcc* ) 3353aee7dae4Smrg # if an import library, we need to obtain dlname 3354aee7dae4Smrg if func_win32_import_lib_p "$dlprefile"; then 3355aee7dae4Smrg func_tr_sh "$dlprefile" 3356aee7dae4Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 3357aee7dae4Smrg dlprefile_dlbasename="" 3358aee7dae4Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 3359aee7dae4Smrg # Use subshell, to avoid clobbering current variable values 3360aee7dae4Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 3361aee7dae4Smrg if test -n "$dlprefile_dlname" ; then 3362aee7dae4Smrg func_basename "$dlprefile_dlname" 3363aee7dae4Smrg dlprefile_dlbasename="$func_basename_result" 3364aee7dae4Smrg else 3365aee7dae4Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 3366aee7dae4Smrg $sharedlib_from_linklib_cmd "$dlprefile" 3367aee7dae4Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 3368aee7dae4Smrg fi 3369aee7dae4Smrg fi 3370aee7dae4Smrg $opt_dry_run || { 3371aee7dae4Smrg if test -n "$dlprefile_dlbasename" ; then 3372aee7dae4Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 3373aee7dae4Smrg else 3374aee7dae4Smrg func_warning "Could not compute DLL name from $name" 3375aee7dae4Smrg eval '$ECHO ": $name " >> "$nlist"' 3376aee7dae4Smrg fi 3377aee7dae4Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3378aee7dae4Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 3379aee7dae4Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 3380aee7dae4Smrg } 3381aee7dae4Smrg else # not an import lib 3382aee7dae4Smrg $opt_dry_run || { 3383aee7dae4Smrg eval '$ECHO ": $name " >> "$nlist"' 3384aee7dae4Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3385aee7dae4Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3386aee7dae4Smrg } 3387aee7dae4Smrg fi 3388aee7dae4Smrg ;; 3389aee7dae4Smrg *) 3390aee7dae4Smrg $opt_dry_run || { 3391aee7dae4Smrg eval '$ECHO ": $name " >> "$nlist"' 3392aee7dae4Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3393aee7dae4Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3394aee7dae4Smrg } 3395aee7dae4Smrg ;; 3396aee7dae4Smrg esac 3397aee7dae4Smrg done 3398aee7dae4Smrg 3399aee7dae4Smrg $opt_dry_run || { 3400aee7dae4Smrg # Make sure we have at least an empty file. 3401aee7dae4Smrg test -f "$nlist" || : > "$nlist" 3402aee7dae4Smrg 3403aee7dae4Smrg if test -n "$exclude_expsyms"; then 3404aee7dae4Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 3405aee7dae4Smrg $MV "$nlist"T "$nlist" 3406aee7dae4Smrg fi 3407aee7dae4Smrg 3408aee7dae4Smrg # Try sorting and uniquifying the output. 3409aee7dae4Smrg if $GREP -v "^: " < "$nlist" | 3410aee7dae4Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 3411aee7dae4Smrg sort -k 3 3412aee7dae4Smrg else 3413aee7dae4Smrg sort +2 3414aee7dae4Smrg fi | 3415aee7dae4Smrg uniq > "$nlist"S; then 3416aee7dae4Smrg : 3417aee7dae4Smrg else 3418aee7dae4Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 3419aee7dae4Smrg fi 3420aee7dae4Smrg 3421aee7dae4Smrg if test -f "$nlist"S; then 3422aee7dae4Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 3423aee7dae4Smrg else 3424aee7dae4Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 3425aee7dae4Smrg fi 3426aee7dae4Smrg 3427aee7dae4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3428aee7dae4Smrg 3429aee7dae4Smrg/* The mapping between symbol names and symbols. */ 3430aee7dae4Smrgtypedef struct { 3431aee7dae4Smrg const char *name; 3432aee7dae4Smrg void *address; 3433aee7dae4Smrg} lt_dlsymlist; 3434aee7dae4Smrgextern LT_DLSYM_CONST lt_dlsymlist 3435aee7dae4Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 3436aee7dae4SmrgLT_DLSYM_CONST lt_dlsymlist 3437aee7dae4Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 3438aee7dae4Smrg{\ 3439aee7dae4Smrg { \"$my_originator\", (void *) 0 }," 3440aee7dae4Smrg 3441aee7dae4Smrg case $need_lib_prefix in 3442aee7dae4Smrg no) 3443aee7dae4Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3444aee7dae4Smrg ;; 3445aee7dae4Smrg *) 3446aee7dae4Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3447aee7dae4Smrg ;; 3448aee7dae4Smrg esac 3449aee7dae4Smrg echo >> "$output_objdir/$my_dlsyms" "\ 3450aee7dae4Smrg {0, (void *) 0} 3451aee7dae4Smrg}; 3452aee7dae4Smrg 3453aee7dae4Smrg/* This works around a problem in FreeBSD linker */ 3454aee7dae4Smrg#ifdef FREEBSD_WORKAROUND 3455aee7dae4Smrgstatic const void *lt_preloaded_setup() { 3456aee7dae4Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 3457aee7dae4Smrg} 3458aee7dae4Smrg#endif 3459aee7dae4Smrg 3460aee7dae4Smrg#ifdef __cplusplus 3461aee7dae4Smrg} 3462aee7dae4Smrg#endif\ 3463aee7dae4Smrg" 3464aee7dae4Smrg } # !$opt_dry_run 3465aee7dae4Smrg 3466aee7dae4Smrg pic_flag_for_symtable= 3467aee7dae4Smrg case "$compile_command " in 3468aee7dae4Smrg *" -static "*) ;; 3469aee7dae4Smrg *) 3470aee7dae4Smrg case $host in 3471aee7dae4Smrg # compiling the symbol table file with pic_flag works around 3472aee7dae4Smrg # a FreeBSD bug that causes programs to crash when -lm is 3473aee7dae4Smrg # linked before any other PIC object. But we must not use 3474aee7dae4Smrg # pic_flag when linking with -static. The problem exists in 3475aee7dae4Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 3476aee7dae4Smrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 3477aee7dae4Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 3478aee7dae4Smrg *-*-hpux*) 3479aee7dae4Smrg pic_flag_for_symtable=" $pic_flag" ;; 3480aee7dae4Smrg *) 3481aee7dae4Smrg if test "X$my_pic_p" != Xno; then 3482aee7dae4Smrg pic_flag_for_symtable=" $pic_flag" 3483aee7dae4Smrg fi 3484aee7dae4Smrg ;; 3485aee7dae4Smrg esac 3486aee7dae4Smrg ;; 3487aee7dae4Smrg esac 3488aee7dae4Smrg symtab_cflags= 3489aee7dae4Smrg for arg in $LTCFLAGS; do 3490aee7dae4Smrg case $arg in 3491aee7dae4Smrg -pie | -fpie | -fPIE) ;; 3492aee7dae4Smrg *) func_append symtab_cflags " $arg" ;; 3493aee7dae4Smrg esac 3494aee7dae4Smrg done 3495aee7dae4Smrg 3496aee7dae4Smrg # Now compile the dynamic symbol file. 3497aee7dae4Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3498aee7dae4Smrg 3499aee7dae4Smrg # Clean up the generated files. 3500aee7dae4Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3501aee7dae4Smrg 3502aee7dae4Smrg # Transform the symbol file into the correct name. 3503aee7dae4Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 3504aee7dae4Smrg case $host in 3505aee7dae4Smrg *cygwin* | *mingw* | *cegcc* ) 3506aee7dae4Smrg if test -f "$output_objdir/$my_outputname.def"; then 3507aee7dae4Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3508aee7dae4Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3509aee7dae4Smrg else 3510aee7dae4Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3511aee7dae4Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3512aee7dae4Smrg fi 3513aee7dae4Smrg ;; 3514aee7dae4Smrg *) 3515aee7dae4Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3516aee7dae4Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3517aee7dae4Smrg ;; 3518aee7dae4Smrg esac 3519aee7dae4Smrg ;; 3520aee7dae4Smrg *) 3521aee7dae4Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 3522aee7dae4Smrg ;; 3523aee7dae4Smrg esac 3524aee7dae4Smrg else 3525aee7dae4Smrg # We keep going just in case the user didn't refer to 3526aee7dae4Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 3527aee7dae4Smrg # really was required. 3528aee7dae4Smrg 3529aee7dae4Smrg # Nullify the symbol file. 3530aee7dae4Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 3531aee7dae4Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 3532aee7dae4Smrg fi 3533aee7dae4Smrg} 3534aee7dae4Smrg 3535aee7dae4Smrg# func_win32_libid arg 3536aee7dae4Smrg# return the library type of file 'arg' 3537aee7dae4Smrg# 3538aee7dae4Smrg# Need a lot of goo to handle *both* DLLs and import libs 3539aee7dae4Smrg# Has to be a shell function in order to 'eat' the argument 3540aee7dae4Smrg# that is supplied when $file_magic_command is called. 3541aee7dae4Smrg# Despite the name, also deal with 64 bit binaries. 3542aee7dae4Smrgfunc_win32_libid () 3543aee7dae4Smrg{ 3544aee7dae4Smrg $opt_debug 3545aee7dae4Smrg win32_libid_type="unknown" 3546aee7dae4Smrg win32_fileres=`file -L $1 2>/dev/null` 3547aee7dae4Smrg case $win32_fileres in 3548aee7dae4Smrg *ar\ archive\ import\ library*) # definitely import 3549aee7dae4Smrg win32_libid_type="x86 archive import" 3550aee7dae4Smrg ;; 3551aee7dae4Smrg *ar\ archive*) # could be an import, or static 3552aee7dae4Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 3553aee7dae4Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 3554aee7dae4Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 3555aee7dae4Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3556aee7dae4Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 3557aee7dae4Smrg $SED -n -e ' 3558aee7dae4Smrg 1,100{ 3559aee7dae4Smrg / I /{ 3560aee7dae4Smrg s,.*,import, 3561aee7dae4Smrg p 3562aee7dae4Smrg q 3563aee7dae4Smrg } 3564aee7dae4Smrg }'` 3565aee7dae4Smrg case $win32_nmres in 3566aee7dae4Smrg import*) win32_libid_type="x86 archive import";; 3567aee7dae4Smrg *) win32_libid_type="x86 archive static";; 3568aee7dae4Smrg esac 3569aee7dae4Smrg fi 3570aee7dae4Smrg ;; 3571aee7dae4Smrg *DLL*) 3572aee7dae4Smrg win32_libid_type="x86 DLL" 3573aee7dae4Smrg ;; 3574aee7dae4Smrg *executable*) # but shell scripts are "executable" too... 3575aee7dae4Smrg case $win32_fileres in 3576aee7dae4Smrg *MS\ Windows\ PE\ Intel*) 3577aee7dae4Smrg win32_libid_type="x86 DLL" 3578aee7dae4Smrg ;; 3579aee7dae4Smrg esac 3580aee7dae4Smrg ;; 3581aee7dae4Smrg esac 3582aee7dae4Smrg $ECHO "$win32_libid_type" 3583aee7dae4Smrg} 3584aee7dae4Smrg 3585aee7dae4Smrg# func_cygming_dll_for_implib ARG 3586aee7dae4Smrg# 3587aee7dae4Smrg# Platform-specific function to extract the 3588aee7dae4Smrg# name of the DLL associated with the specified 3589aee7dae4Smrg# import library ARG. 3590aee7dae4Smrg# Invoked by eval'ing the libtool variable 3591aee7dae4Smrg# $sharedlib_from_linklib_cmd 3592aee7dae4Smrg# Result is available in the variable 3593aee7dae4Smrg# $sharedlib_from_linklib_result 3594aee7dae4Smrgfunc_cygming_dll_for_implib () 3595aee7dae4Smrg{ 3596aee7dae4Smrg $opt_debug 3597aee7dae4Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 3598aee7dae4Smrg} 3599aee7dae4Smrg 3600aee7dae4Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 3601aee7dae4Smrg# 3602aee7dae4Smrg# The is the core of a fallback implementation of a 3603aee7dae4Smrg# platform-specific function to extract the name of the 3604aee7dae4Smrg# DLL associated with the specified import library LIBNAME. 3605aee7dae4Smrg# 3606aee7dae4Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 3607aee7dae4Smrg# on the platform and compiler that created the implib. 3608aee7dae4Smrg# 3609aee7dae4Smrg# Echos the name of the DLL associated with the 3610aee7dae4Smrg# specified import library. 3611aee7dae4Smrgfunc_cygming_dll_for_implib_fallback_core () 3612aee7dae4Smrg{ 3613aee7dae4Smrg $opt_debug 3614aee7dae4Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 3615aee7dae4Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 3616aee7dae4Smrg $SED '/^Contents of section '"$match_literal"':/{ 3617aee7dae4Smrg # Place marker at beginning of archive member dllname section 3618aee7dae4Smrg s/.*/====MARK====/ 3619aee7dae4Smrg p 3620aee7dae4Smrg d 3621aee7dae4Smrg } 3622aee7dae4Smrg # These lines can sometimes be longer than 43 characters, but 3623aee7dae4Smrg # are always uninteresting 3624aee7dae4Smrg /:[ ]*file format pe[i]\{,1\}-/d 3625aee7dae4Smrg /^In archive [^:]*:/d 3626aee7dae4Smrg # Ensure marker is printed 3627aee7dae4Smrg /^====MARK====/p 3628aee7dae4Smrg # Remove all lines with less than 43 characters 3629aee7dae4Smrg /^.\{43\}/!d 3630aee7dae4Smrg # From remaining lines, remove first 43 characters 3631aee7dae4Smrg s/^.\{43\}//' | 3632aee7dae4Smrg $SED -n ' 3633aee7dae4Smrg # Join marker and all lines until next marker into a single line 3634aee7dae4Smrg /^====MARK====/ b para 3635aee7dae4Smrg H 3636aee7dae4Smrg $ b para 3637aee7dae4Smrg b 3638aee7dae4Smrg :para 3639aee7dae4Smrg x 3640aee7dae4Smrg s/\n//g 3641aee7dae4Smrg # Remove the marker 3642aee7dae4Smrg s/^====MARK====// 3643aee7dae4Smrg # Remove trailing dots and whitespace 3644aee7dae4Smrg s/[\. \t]*$// 3645aee7dae4Smrg # Print 3646aee7dae4Smrg /./p' | 3647aee7dae4Smrg # we now have a list, one entry per line, of the stringified 3648aee7dae4Smrg # contents of the appropriate section of all members of the 3649aee7dae4Smrg # archive which possess that section. Heuristic: eliminate 3650aee7dae4Smrg # all those which have a first or second character that is 3651aee7dae4Smrg # a '.' (that is, objdump's representation of an unprintable 3652aee7dae4Smrg # character.) This should work for all archives with less than 3653aee7dae4Smrg # 0x302f exports -- but will fail for DLLs whose name actually 3654aee7dae4Smrg # begins with a literal '.' or a single character followed by 3655aee7dae4Smrg # a '.'. 3656aee7dae4Smrg # 3657aee7dae4Smrg # Of those that remain, print the first one. 3658aee7dae4Smrg $SED -e '/^\./d;/^.\./d;q' 3659aee7dae4Smrg} 3660aee7dae4Smrg 3661aee7dae4Smrg# func_cygming_gnu_implib_p ARG 3662aee7dae4Smrg# This predicate returns with zero status (TRUE) if 3663aee7dae4Smrg# ARG is a GNU/binutils-style import library. Returns 3664aee7dae4Smrg# with nonzero status (FALSE) otherwise. 3665aee7dae4Smrgfunc_cygming_gnu_implib_p () 3666aee7dae4Smrg{ 3667aee7dae4Smrg $opt_debug 3668aee7dae4Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3669aee7dae4Smrg 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)$'` 3670aee7dae4Smrg test -n "$func_cygming_gnu_implib_tmp" 3671aee7dae4Smrg} 3672aee7dae4Smrg 3673aee7dae4Smrg# func_cygming_ms_implib_p ARG 3674aee7dae4Smrg# This predicate returns with zero status (TRUE) if 3675aee7dae4Smrg# ARG is an MS-style import library. Returns 3676aee7dae4Smrg# with nonzero status (FALSE) otherwise. 3677aee7dae4Smrgfunc_cygming_ms_implib_p () 3678aee7dae4Smrg{ 3679aee7dae4Smrg $opt_debug 3680aee7dae4Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 3681aee7dae4Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 3682aee7dae4Smrg test -n "$func_cygming_ms_implib_tmp" 3683aee7dae4Smrg} 3684aee7dae4Smrg 3685aee7dae4Smrg# func_cygming_dll_for_implib_fallback ARG 3686aee7dae4Smrg# Platform-specific function to extract the 3687aee7dae4Smrg# name of the DLL associated with the specified 3688aee7dae4Smrg# import library ARG. 3689aee7dae4Smrg# 3690aee7dae4Smrg# This fallback implementation is for use when $DLLTOOL 3691aee7dae4Smrg# does not support the --identify-strict option. 3692aee7dae4Smrg# Invoked by eval'ing the libtool variable 3693aee7dae4Smrg# $sharedlib_from_linklib_cmd 3694aee7dae4Smrg# Result is available in the variable 3695aee7dae4Smrg# $sharedlib_from_linklib_result 3696aee7dae4Smrgfunc_cygming_dll_for_implib_fallback () 3697aee7dae4Smrg{ 3698aee7dae4Smrg $opt_debug 3699aee7dae4Smrg if func_cygming_gnu_implib_p "$1" ; then 3700aee7dae4Smrg # binutils import library 3701aee7dae4Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 3702aee7dae4Smrg elif func_cygming_ms_implib_p "$1" ; then 3703aee7dae4Smrg # ms-generated import library 3704aee7dae4Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 3705aee7dae4Smrg else 3706aee7dae4Smrg # unknown 3707aee7dae4Smrg sharedlib_from_linklib_result="" 3708aee7dae4Smrg fi 3709aee7dae4Smrg} 3710aee7dae4Smrg 3711aee7dae4Smrg 3712aee7dae4Smrg# func_extract_an_archive dir oldlib 3713aee7dae4Smrgfunc_extract_an_archive () 3714aee7dae4Smrg{ 3715aee7dae4Smrg $opt_debug 3716aee7dae4Smrg f_ex_an_ar_dir="$1"; shift 3717aee7dae4Smrg f_ex_an_ar_oldlib="$1" 3718aee7dae4Smrg if test "$lock_old_archive_extraction" = yes; then 3719aee7dae4Smrg lockfile=$f_ex_an_ar_oldlib.lock 3720aee7dae4Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3721aee7dae4Smrg func_echo "Waiting for $lockfile to be removed" 3722aee7dae4Smrg sleep 2 3723aee7dae4Smrg done 3724aee7dae4Smrg fi 3725aee7dae4Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 3726aee7dae4Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 3727aee7dae4Smrg if test "$lock_old_archive_extraction" = yes; then 3728aee7dae4Smrg $opt_dry_run || rm -f "$lockfile" 3729aee7dae4Smrg fi 3730aee7dae4Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 3731aee7dae4Smrg : 3732aee7dae4Smrg else 3733aee7dae4Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 3734aee7dae4Smrg fi 3735aee7dae4Smrg} 3736aee7dae4Smrg 3737aee7dae4Smrg 3738aee7dae4Smrg# func_extract_archives gentop oldlib ... 3739aee7dae4Smrgfunc_extract_archives () 3740aee7dae4Smrg{ 3741aee7dae4Smrg $opt_debug 3742aee7dae4Smrg my_gentop="$1"; shift 3743aee7dae4Smrg my_oldlibs=${1+"$@"} 3744aee7dae4Smrg my_oldobjs="" 3745aee7dae4Smrg my_xlib="" 3746aee7dae4Smrg my_xabs="" 3747aee7dae4Smrg my_xdir="" 3748aee7dae4Smrg 3749aee7dae4Smrg for my_xlib in $my_oldlibs; do 3750aee7dae4Smrg # Extract the objects. 3751aee7dae4Smrg case $my_xlib in 3752aee7dae4Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 3753aee7dae4Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 3754aee7dae4Smrg esac 3755aee7dae4Smrg func_basename "$my_xlib" 3756aee7dae4Smrg my_xlib="$func_basename_result" 3757aee7dae4Smrg my_xlib_u=$my_xlib 3758aee7dae4Smrg while :; do 3759aee7dae4Smrg case " $extracted_archives " in 3760aee7dae4Smrg *" $my_xlib_u "*) 3761aee7dae4Smrg func_arith $extracted_serial + 1 3762aee7dae4Smrg extracted_serial=$func_arith_result 3763aee7dae4Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 3764aee7dae4Smrg *) break ;; 3765aee7dae4Smrg esac 3766aee7dae4Smrg done 3767aee7dae4Smrg extracted_archives="$extracted_archives $my_xlib_u" 3768aee7dae4Smrg my_xdir="$my_gentop/$my_xlib_u" 3769aee7dae4Smrg 3770aee7dae4Smrg func_mkdir_p "$my_xdir" 3771aee7dae4Smrg 3772aee7dae4Smrg case $host in 3773aee7dae4Smrg *-darwin*) 3774aee7dae4Smrg func_verbose "Extracting $my_xabs" 3775aee7dae4Smrg # Do not bother doing anything if just a dry run 3776aee7dae4Smrg $opt_dry_run || { 3777aee7dae4Smrg darwin_orig_dir=`pwd` 3778aee7dae4Smrg cd $my_xdir || exit $? 3779aee7dae4Smrg darwin_archive=$my_xabs 3780aee7dae4Smrg darwin_curdir=`pwd` 3781aee7dae4Smrg darwin_base_archive=`basename "$darwin_archive"` 3782aee7dae4Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 3783aee7dae4Smrg if test -n "$darwin_arches"; then 3784aee7dae4Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 3785aee7dae4Smrg darwin_arch= 3786aee7dae4Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 3787aee7dae4Smrg for darwin_arch in $darwin_arches ; do 3788aee7dae4Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3789aee7dae4Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 3790aee7dae4Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3791aee7dae4Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 3792aee7dae4Smrg cd "$darwin_curdir" 3793aee7dae4Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 3794aee7dae4Smrg done # $darwin_arches 3795aee7dae4Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 3796aee7dae4Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 3797aee7dae4Smrg darwin_file= 3798aee7dae4Smrg darwin_files= 3799aee7dae4Smrg for darwin_file in $darwin_filelist; do 3800aee7dae4Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 3801aee7dae4Smrg $LIPO -create -output "$darwin_file" $darwin_files 3802aee7dae4Smrg done # $darwin_filelist 3803aee7dae4Smrg $RM -rf unfat-$$ 3804aee7dae4Smrg cd "$darwin_orig_dir" 3805aee7dae4Smrg else 3806aee7dae4Smrg cd $darwin_orig_dir 3807aee7dae4Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 3808aee7dae4Smrg fi # $darwin_arches 3809aee7dae4Smrg } # !$opt_dry_run 3810aee7dae4Smrg ;; 3811aee7dae4Smrg *) 3812aee7dae4Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 3813aee7dae4Smrg ;; 3814aee7dae4Smrg esac 3815aee7dae4Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 3816aee7dae4Smrg done 3817aee7dae4Smrg 3818aee7dae4Smrg func_extract_archives_result="$my_oldobjs" 3819aee7dae4Smrg} 3820aee7dae4Smrg 3821aee7dae4Smrg 3822aee7dae4Smrg# func_emit_wrapper [arg=no] 3823aee7dae4Smrg# 3824aee7dae4Smrg# Emit a libtool wrapper script on stdout. 3825aee7dae4Smrg# Don't directly open a file because we may want to 3826aee7dae4Smrg# incorporate the script contents within a cygwin/mingw 3827aee7dae4Smrg# wrapper executable. Must ONLY be called from within 3828aee7dae4Smrg# func_mode_link because it depends on a number of variables 3829aee7dae4Smrg# set therein. 3830aee7dae4Smrg# 3831aee7dae4Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 3832aee7dae4Smrg# variable will take. If 'yes', then the emitted script 3833aee7dae4Smrg# will assume that the directory in which it is stored is 3834aee7dae4Smrg# the $objdir directory. This is a cygwin/mingw-specific 3835aee7dae4Smrg# behavior. 3836aee7dae4Smrgfunc_emit_wrapper () 3837aee7dae4Smrg{ 3838aee7dae4Smrg func_emit_wrapper_arg1=${1-no} 3839aee7dae4Smrg 3840aee7dae4Smrg $ECHO "\ 3841aee7dae4Smrg#! $SHELL 3842aee7dae4Smrg 3843aee7dae4Smrg# $output - temporary wrapper script for $objdir/$outputname 3844aee7dae4Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3845aee7dae4Smrg# 3846aee7dae4Smrg# The $output program cannot be directly executed until all the libtool 3847aee7dae4Smrg# libraries that it depends on are installed. 3848aee7dae4Smrg# 3849aee7dae4Smrg# This wrapper script should never be moved out of the build directory. 3850aee7dae4Smrg# If it is, it will not operate correctly. 3851aee7dae4Smrg 3852aee7dae4Smrg# Sed substitution that helps us do robust quoting. It backslashifies 3853aee7dae4Smrg# metacharacters that are still active within double-quoted strings. 3854aee7dae4Smrgsed_quote_subst='$sed_quote_subst' 3855aee7dae4Smrg 3856aee7dae4Smrg# Be Bourne compatible 3857aee7dae4Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 3858aee7dae4Smrg emulate sh 3859aee7dae4Smrg NULLCMD=: 3860aee7dae4Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 3861aee7dae4Smrg # is contrary to our usage. Disable this feature. 3862aee7dae4Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 3863aee7dae4Smrg setopt NO_GLOB_SUBST 3864aee7dae4Smrgelse 3865aee7dae4Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 3866aee7dae4Smrgfi 3867aee7dae4SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 3868aee7dae4SmrgDUALCASE=1; export DUALCASE # for MKS sh 3869aee7dae4Smrg 3870aee7dae4Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 3871aee7dae4Smrg# if CDPATH is set. 3872aee7dae4Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3873aee7dae4Smrg 3874aee7dae4Smrgrelink_command=\"$relink_command\" 3875aee7dae4Smrg 3876aee7dae4Smrg# This environment variable determines our operation mode. 3877aee7dae4Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 3878aee7dae4Smrg # install mode needs the following variables: 3879aee7dae4Smrg generated_by_libtool_version='$macro_version' 3880aee7dae4Smrg notinst_deplibs='$notinst_deplibs' 3881aee7dae4Smrgelse 3882aee7dae4Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 3883aee7dae4Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 3884aee7dae4Smrg file=\"\$0\"" 3885aee7dae4Smrg 3886aee7dae4Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 3887aee7dae4Smrg $ECHO "\ 3888aee7dae4Smrg 3889aee7dae4Smrg# A function that is used when there is no print builtin or printf. 3890aee7dae4Smrgfunc_fallback_echo () 3891aee7dae4Smrg{ 3892aee7dae4Smrg eval 'cat <<_LTECHO_EOF 3893aee7dae4Smrg\$1 3894aee7dae4Smrg_LTECHO_EOF' 3895aee7dae4Smrg} 3896aee7dae4Smrg ECHO=\"$qECHO\" 3897aee7dae4Smrg fi 3898aee7dae4Smrg 3899aee7dae4Smrg# Very basic option parsing. These options are (a) specific to 3900aee7dae4Smrg# the libtool wrapper, (b) are identical between the wrapper 3901aee7dae4Smrg# /script/ and the wrapper /executable/ which is used only on 3902aee7dae4Smrg# windows platforms, and (c) all begin with the string "--lt-" 3903aee7dae4Smrg# (application programs are unlikely to have options which match 3904aee7dae4Smrg# this pattern). 3905aee7dae4Smrg# 3906aee7dae4Smrg# There are only two supported options: --lt-debug and 3907aee7dae4Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 3908aee7dae4Smrg# 3909aee7dae4Smrg# The first argument to this parsing function should be the 3910aee7dae4Smrg# script's $0 value, followed by "$@". 3911aee7dae4Smrglt_option_debug= 3912aee7dae4Smrgfunc_parse_lt_options () 3913aee7dae4Smrg{ 3914aee7dae4Smrg lt_script_arg0=\$0 3915aee7dae4Smrg shift 3916aee7dae4Smrg for lt_opt 3917aee7dae4Smrg do 3918aee7dae4Smrg case \"\$lt_opt\" in 3919aee7dae4Smrg --lt-debug) lt_option_debug=1 ;; 3920aee7dae4Smrg --lt-dump-script) 3921aee7dae4Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 3922aee7dae4Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 3923aee7dae4Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 3924aee7dae4Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 3925aee7dae4Smrg exit 0 3926aee7dae4Smrg ;; 3927aee7dae4Smrg --lt-*) 3928aee7dae4Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 3929aee7dae4Smrg exit 1 3930aee7dae4Smrg ;; 3931aee7dae4Smrg esac 3932aee7dae4Smrg done 3933aee7dae4Smrg 3934aee7dae4Smrg # Print the debug banner immediately: 3935aee7dae4Smrg if test -n \"\$lt_option_debug\"; then 3936aee7dae4Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 3937aee7dae4Smrg fi 3938aee7dae4Smrg} 3939aee7dae4Smrg 3940aee7dae4Smrg# Used when --lt-debug. Prints its arguments to stdout 3941aee7dae4Smrg# (redirection is the responsibility of the caller) 3942aee7dae4Smrgfunc_lt_dump_args () 3943aee7dae4Smrg{ 3944aee7dae4Smrg lt_dump_args_N=1; 3945aee7dae4Smrg for lt_arg 3946aee7dae4Smrg do 3947aee7dae4Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 3948aee7dae4Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 3949aee7dae4Smrg done 3950aee7dae4Smrg} 3951aee7dae4Smrg 3952aee7dae4Smrg# Core function for launching the target application 3953aee7dae4Smrgfunc_exec_program_core () 3954aee7dae4Smrg{ 3955aee7dae4Smrg" 3956aee7dae4Smrg case $host in 3957aee7dae4Smrg # Backslashes separate directories on plain windows 3958aee7dae4Smrg *-*-mingw | *-*-os2* | *-cegcc*) 3959aee7dae4Smrg $ECHO "\ 3960aee7dae4Smrg if test -n \"\$lt_option_debug\"; then 3961aee7dae4Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 3962aee7dae4Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3963aee7dae4Smrg fi 3964aee7dae4Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 3965aee7dae4Smrg" 3966aee7dae4Smrg ;; 3967aee7dae4Smrg 3968aee7dae4Smrg *) 3969aee7dae4Smrg $ECHO "\ 3970aee7dae4Smrg if test -n \"\$lt_option_debug\"; then 3971aee7dae4Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 3972aee7dae4Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 3973aee7dae4Smrg fi 3974aee7dae4Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 3975aee7dae4Smrg" 3976aee7dae4Smrg ;; 3977aee7dae4Smrg esac 3978aee7dae4Smrg $ECHO "\ 3979aee7dae4Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 3980aee7dae4Smrg exit 1 3981aee7dae4Smrg} 3982aee7dae4Smrg 3983aee7dae4Smrg# A function to encapsulate launching the target application 3984aee7dae4Smrg# Strips options in the --lt-* namespace from \$@ and 3985aee7dae4Smrg# launches target application with the remaining arguments. 3986aee7dae4Smrgfunc_exec_program () 3987aee7dae4Smrg{ 3988aee7dae4Smrg case \" \$* \" in 3989aee7dae4Smrg *\\ --lt-*) 3990aee7dae4Smrg for lt_wr_arg 3991aee7dae4Smrg do 3992aee7dae4Smrg case \$lt_wr_arg in 3993aee7dae4Smrg --lt-*) ;; 3994aee7dae4Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 3995aee7dae4Smrg esac 3996aee7dae4Smrg shift 3997aee7dae4Smrg done ;; 3998aee7dae4Smrg esac 3999aee7dae4Smrg func_exec_program_core \${1+\"\$@\"} 4000aee7dae4Smrg} 4001aee7dae4Smrg 4002aee7dae4Smrg # Parse options 4003aee7dae4Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 4004aee7dae4Smrg 4005aee7dae4Smrg # Find the directory that this script lives in. 4006aee7dae4Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 4007aee7dae4Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4008aee7dae4Smrg 4009aee7dae4Smrg # Follow symbolic links until we get to the real thisdir. 4010aee7dae4Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 4011aee7dae4Smrg while test -n \"\$file\"; do 4012aee7dae4Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4013aee7dae4Smrg 4014aee7dae4Smrg # If there was a directory component, then change thisdir. 4015aee7dae4Smrg if test \"x\$destdir\" != \"x\$file\"; then 4016aee7dae4Smrg case \"\$destdir\" in 4017aee7dae4Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 4018aee7dae4Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 4019aee7dae4Smrg esac 4020aee7dae4Smrg fi 4021aee7dae4Smrg 4022aee7dae4Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 4023aee7dae4Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 4024aee7dae4Smrg done 4025aee7dae4Smrg 4026aee7dae4Smrg # Usually 'no', except on cygwin/mingw when embedded into 4027aee7dae4Smrg # the cwrapper. 4028aee7dae4Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 4029aee7dae4Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 4030aee7dae4Smrg # special case for '.' 4031aee7dae4Smrg if test \"\$thisdir\" = \".\"; then 4032aee7dae4Smrg thisdir=\`pwd\` 4033aee7dae4Smrg fi 4034aee7dae4Smrg # remove .libs from thisdir 4035aee7dae4Smrg case \"\$thisdir\" in 4036aee7dae4Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 4037aee7dae4Smrg $objdir ) thisdir=. ;; 4038aee7dae4Smrg esac 4039aee7dae4Smrg fi 4040aee7dae4Smrg 4041aee7dae4Smrg # Try to get the absolute directory name. 4042aee7dae4Smrg absdir=\`cd \"\$thisdir\" && pwd\` 4043aee7dae4Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 4044aee7dae4Smrg" 4045aee7dae4Smrg 4046aee7dae4Smrg if test "$fast_install" = yes; then 4047aee7dae4Smrg $ECHO "\ 4048aee7dae4Smrg program=lt-'$outputname'$exeext 4049aee7dae4Smrg progdir=\"\$thisdir/$objdir\" 4050aee7dae4Smrg 4051aee7dae4Smrg if test ! -f \"\$progdir/\$program\" || 4052aee7dae4Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 4053aee7dae4Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4054aee7dae4Smrg 4055aee7dae4Smrg file=\"\$\$-\$program\" 4056aee7dae4Smrg 4057aee7dae4Smrg if test ! -d \"\$progdir\"; then 4058aee7dae4Smrg $MKDIR \"\$progdir\" 4059aee7dae4Smrg else 4060aee7dae4Smrg $RM \"\$progdir/\$file\" 4061aee7dae4Smrg fi" 4062aee7dae4Smrg 4063aee7dae4Smrg $ECHO "\ 4064aee7dae4Smrg 4065aee7dae4Smrg # relink executable if necessary 4066aee7dae4Smrg if test -n \"\$relink_command\"; then 4067aee7dae4Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 4068aee7dae4Smrg else 4069aee7dae4Smrg $ECHO \"\$relink_command_output\" >&2 4070aee7dae4Smrg $RM \"\$progdir/\$file\" 4071aee7dae4Smrg exit 1 4072aee7dae4Smrg fi 4073aee7dae4Smrg fi 4074aee7dae4Smrg 4075aee7dae4Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 4076aee7dae4Smrg { $RM \"\$progdir/\$program\"; 4077aee7dae4Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 4078aee7dae4Smrg $RM \"\$progdir/\$file\" 4079aee7dae4Smrg fi" 4080aee7dae4Smrg else 4081aee7dae4Smrg $ECHO "\ 4082aee7dae4Smrg program='$outputname' 4083aee7dae4Smrg progdir=\"\$thisdir/$objdir\" 4084aee7dae4Smrg" 4085aee7dae4Smrg fi 4086aee7dae4Smrg 4087aee7dae4Smrg $ECHO "\ 4088aee7dae4Smrg 4089aee7dae4Smrg if test -f \"\$progdir/\$program\"; then" 4090aee7dae4Smrg 4091aee7dae4Smrg # fixup the dll searchpath if we need to. 4092aee7dae4Smrg # 4093aee7dae4Smrg # Fix the DLL searchpath if we need to. Do this before prepending 4094aee7dae4Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 4095aee7dae4Smrg # libraries must come first. 4096aee7dae4Smrg if test -n "$dllsearchpath"; then 4097aee7dae4Smrg $ECHO "\ 4098aee7dae4Smrg # Add the dll search path components to the executable PATH 4099aee7dae4Smrg PATH=$dllsearchpath:\$PATH 4100aee7dae4Smrg" 4101aee7dae4Smrg fi 4102aee7dae4Smrg 4103aee7dae4Smrg # Export our shlibpath_var if we have one. 4104aee7dae4Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4105aee7dae4Smrg $ECHO "\ 4106aee7dae4Smrg # Add our own library path to $shlibpath_var 4107aee7dae4Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4108aee7dae4Smrg 4109aee7dae4Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 4110aee7dae4Smrg # The second colon is a workaround for a bug in BeOS R4 sed 4111aee7dae4Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4112aee7dae4Smrg 4113aee7dae4Smrg export $shlibpath_var 4114aee7dae4Smrg" 4115aee7dae4Smrg fi 4116aee7dae4Smrg 4117aee7dae4Smrg $ECHO "\ 4118aee7dae4Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 4119aee7dae4Smrg # Run the actual program with our arguments. 4120aee7dae4Smrg func_exec_program \${1+\"\$@\"} 4121aee7dae4Smrg fi 4122aee7dae4Smrg else 4123aee7dae4Smrg # The program doesn't exist. 4124aee7dae4Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 4125aee7dae4Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 4126aee7dae4Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 4127aee7dae4Smrg exit 1 4128aee7dae4Smrg fi 4129aee7dae4Smrgfi\ 4130aee7dae4Smrg" 4131aee7dae4Smrg} 4132aee7dae4Smrg 4133aee7dae4Smrg 4134aee7dae4Smrg# func_emit_cwrapperexe_src 4135aee7dae4Smrg# emit the source code for a wrapper executable on stdout 4136aee7dae4Smrg# Must ONLY be called from within func_mode_link because 4137aee7dae4Smrg# it depends on a number of variable set therein. 4138aee7dae4Smrgfunc_emit_cwrapperexe_src () 4139aee7dae4Smrg{ 4140aee7dae4Smrg cat <<EOF 4141aee7dae4Smrg 4142aee7dae4Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4143aee7dae4Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4144aee7dae4Smrg 4145aee7dae4Smrg The $output program cannot be directly executed until all the libtool 4146aee7dae4Smrg libraries that it depends on are installed. 4147aee7dae4Smrg 4148aee7dae4Smrg This wrapper executable should never be moved out of the build directory. 4149aee7dae4Smrg If it is, it will not operate correctly. 4150aee7dae4Smrg*/ 4151aee7dae4SmrgEOF 4152aee7dae4Smrg cat <<"EOF" 4153aee7dae4Smrg#ifdef _MSC_VER 4154aee7dae4Smrg# define _CRT_SECURE_NO_DEPRECATE 1 4155aee7dae4Smrg#endif 4156aee7dae4Smrg#include <stdio.h> 4157aee7dae4Smrg#include <stdlib.h> 4158aee7dae4Smrg#ifdef _MSC_VER 4159aee7dae4Smrg# include <direct.h> 4160aee7dae4Smrg# include <process.h> 4161aee7dae4Smrg# include <io.h> 4162aee7dae4Smrg#else 4163aee7dae4Smrg# include <unistd.h> 4164aee7dae4Smrg# include <stdint.h> 4165aee7dae4Smrg# ifdef __CYGWIN__ 4166aee7dae4Smrg# include <io.h> 4167aee7dae4Smrg# endif 4168aee7dae4Smrg#endif 4169aee7dae4Smrg#include <malloc.h> 4170aee7dae4Smrg#include <stdarg.h> 4171aee7dae4Smrg#include <assert.h> 4172aee7dae4Smrg#include <string.h> 4173aee7dae4Smrg#include <ctype.h> 4174aee7dae4Smrg#include <errno.h> 4175aee7dae4Smrg#include <fcntl.h> 4176aee7dae4Smrg#include <sys/stat.h> 4177aee7dae4Smrg 4178aee7dae4Smrg/* declarations of non-ANSI functions */ 4179aee7dae4Smrg#if defined(__MINGW32__) 4180aee7dae4Smrg# ifdef __STRICT_ANSI__ 4181aee7dae4Smrgint _putenv (const char *); 4182aee7dae4Smrg# endif 4183aee7dae4Smrg#elif defined(__CYGWIN__) 4184aee7dae4Smrg# ifdef __STRICT_ANSI__ 4185aee7dae4Smrgchar *realpath (const char *, char *); 4186aee7dae4Smrgint putenv (char *); 4187aee7dae4Smrgint setenv (const char *, const char *, int); 4188aee7dae4Smrg# endif 4189aee7dae4Smrg/* #elif defined (other platforms) ... */ 4190aee7dae4Smrg#endif 4191aee7dae4Smrg 4192aee7dae4Smrg/* portability defines, excluding path handling macros */ 4193aee7dae4Smrg#if defined(_MSC_VER) 4194aee7dae4Smrg# define setmode _setmode 4195aee7dae4Smrg# define stat _stat 4196aee7dae4Smrg# define chmod _chmod 4197aee7dae4Smrg# define getcwd _getcwd 4198aee7dae4Smrg# define putenv _putenv 4199aee7dae4Smrg# define S_IXUSR _S_IEXEC 4200aee7dae4Smrg# ifndef _INTPTR_T_DEFINED 4201aee7dae4Smrg# define _INTPTR_T_DEFINED 4202aee7dae4Smrg# define intptr_t int 4203aee7dae4Smrg# endif 4204aee7dae4Smrg#elif defined(__MINGW32__) 4205aee7dae4Smrg# define setmode _setmode 4206aee7dae4Smrg# define stat _stat 4207aee7dae4Smrg# define chmod _chmod 4208aee7dae4Smrg# define getcwd _getcwd 4209aee7dae4Smrg# define putenv _putenv 4210aee7dae4Smrg#elif defined(__CYGWIN__) 4211aee7dae4Smrg# define HAVE_SETENV 4212aee7dae4Smrg# define FOPEN_WB "wb" 4213aee7dae4Smrg/* #elif defined (other platforms) ... */ 4214aee7dae4Smrg#endif 4215aee7dae4Smrg 4216aee7dae4Smrg#if defined(PATH_MAX) 4217aee7dae4Smrg# define LT_PATHMAX PATH_MAX 4218aee7dae4Smrg#elif defined(MAXPATHLEN) 4219aee7dae4Smrg# define LT_PATHMAX MAXPATHLEN 4220aee7dae4Smrg#else 4221aee7dae4Smrg# define LT_PATHMAX 1024 4222aee7dae4Smrg#endif 4223aee7dae4Smrg 4224aee7dae4Smrg#ifndef S_IXOTH 4225aee7dae4Smrg# define S_IXOTH 0 4226aee7dae4Smrg#endif 4227aee7dae4Smrg#ifndef S_IXGRP 4228aee7dae4Smrg# define S_IXGRP 0 4229aee7dae4Smrg#endif 4230aee7dae4Smrg 4231aee7dae4Smrg/* path handling portability macros */ 4232aee7dae4Smrg#ifndef DIR_SEPARATOR 4233aee7dae4Smrg# define DIR_SEPARATOR '/' 4234aee7dae4Smrg# define PATH_SEPARATOR ':' 4235aee7dae4Smrg#endif 4236aee7dae4Smrg 4237aee7dae4Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4238aee7dae4Smrg defined (__OS2__) 4239aee7dae4Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 4240aee7dae4Smrg# define FOPEN_WB "wb" 4241aee7dae4Smrg# ifndef DIR_SEPARATOR_2 4242aee7dae4Smrg# define DIR_SEPARATOR_2 '\\' 4243aee7dae4Smrg# endif 4244aee7dae4Smrg# ifndef PATH_SEPARATOR_2 4245aee7dae4Smrg# define PATH_SEPARATOR_2 ';' 4246aee7dae4Smrg# endif 4247aee7dae4Smrg#endif 4248aee7dae4Smrg 4249aee7dae4Smrg#ifndef DIR_SEPARATOR_2 4250aee7dae4Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 4251aee7dae4Smrg#else /* DIR_SEPARATOR_2 */ 4252aee7dae4Smrg# define IS_DIR_SEPARATOR(ch) \ 4253aee7dae4Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 4254aee7dae4Smrg#endif /* DIR_SEPARATOR_2 */ 4255aee7dae4Smrg 4256aee7dae4Smrg#ifndef PATH_SEPARATOR_2 4257aee7dae4Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 4258aee7dae4Smrg#else /* PATH_SEPARATOR_2 */ 4259aee7dae4Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 4260aee7dae4Smrg#endif /* PATH_SEPARATOR_2 */ 4261aee7dae4Smrg 4262aee7dae4Smrg#ifndef FOPEN_WB 4263aee7dae4Smrg# define FOPEN_WB "w" 4264aee7dae4Smrg#endif 4265aee7dae4Smrg#ifndef _O_BINARY 4266aee7dae4Smrg# define _O_BINARY 0 4267aee7dae4Smrg#endif 4268aee7dae4Smrg 4269aee7dae4Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 4270aee7dae4Smrg#define XFREE(stale) do { \ 4271aee7dae4Smrg if (stale) { free ((void *) stale); stale = 0; } \ 4272aee7dae4Smrg} while (0) 4273aee7dae4Smrg 4274aee7dae4Smrg#if defined(LT_DEBUGWRAPPER) 4275aee7dae4Smrgstatic int lt_debug = 1; 4276aee7dae4Smrg#else 4277aee7dae4Smrgstatic int lt_debug = 0; 4278aee7dae4Smrg#endif 4279aee7dae4Smrg 4280aee7dae4Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4281aee7dae4Smrg 4282aee7dae4Smrgvoid *xmalloc (size_t num); 4283aee7dae4Smrgchar *xstrdup (const char *string); 4284aee7dae4Smrgconst char *base_name (const char *name); 4285aee7dae4Smrgchar *find_executable (const char *wrapper); 4286aee7dae4Smrgchar *chase_symlinks (const char *pathspec); 4287aee7dae4Smrgint make_executable (const char *path); 4288aee7dae4Smrgint check_executable (const char *path); 4289aee7dae4Smrgchar *strendzap (char *str, const char *pat); 4290aee7dae4Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 4291aee7dae4Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 4292aee7dae4Smrgstatic const char *nonnull (const char *s); 4293aee7dae4Smrgstatic const char *nonempty (const char *s); 4294aee7dae4Smrgvoid lt_setenv (const char *name, const char *value); 4295aee7dae4Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 4296aee7dae4Smrgvoid lt_update_exe_path (const char *name, const char *value); 4297aee7dae4Smrgvoid lt_update_lib_path (const char *name, const char *value); 4298aee7dae4Smrgchar **prepare_spawn (char **argv); 4299aee7dae4Smrgvoid lt_dump_script (FILE *f); 4300aee7dae4SmrgEOF 4301aee7dae4Smrg 4302aee7dae4Smrg cat <<EOF 4303aee7dae4Smrgvolatile const char * MAGIC_EXE = "$magic_exe"; 4304aee7dae4Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 4305aee7dae4SmrgEOF 4306aee7dae4Smrg 4307aee7dae4Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4308aee7dae4Smrg func_to_host_path "$temp_rpath" 4309aee7dae4Smrg cat <<EOF 4310aee7dae4Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 4311aee7dae4SmrgEOF 4312aee7dae4Smrg else 4313aee7dae4Smrg cat <<"EOF" 4314aee7dae4Smrgconst char * LIB_PATH_VALUE = ""; 4315aee7dae4SmrgEOF 4316aee7dae4Smrg fi 4317aee7dae4Smrg 4318aee7dae4Smrg if test -n "$dllsearchpath"; then 4319aee7dae4Smrg func_to_host_path "$dllsearchpath:" 4320aee7dae4Smrg cat <<EOF 4321aee7dae4Smrgconst char * EXE_PATH_VARNAME = "PATH"; 4322aee7dae4Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 4323aee7dae4SmrgEOF 4324aee7dae4Smrg else 4325aee7dae4Smrg cat <<"EOF" 4326aee7dae4Smrgconst char * EXE_PATH_VARNAME = ""; 4327aee7dae4Smrgconst char * EXE_PATH_VALUE = ""; 4328aee7dae4SmrgEOF 4329aee7dae4Smrg fi 4330aee7dae4Smrg 4331aee7dae4Smrg if test "$fast_install" = yes; then 4332aee7dae4Smrg cat <<EOF 4333aee7dae4Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 4334aee7dae4SmrgEOF 4335aee7dae4Smrg else 4336aee7dae4Smrg cat <<EOF 4337aee7dae4Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 4338aee7dae4SmrgEOF 4339aee7dae4Smrg fi 4340aee7dae4Smrg 4341aee7dae4Smrg 4342aee7dae4Smrg cat <<"EOF" 4343aee7dae4Smrg 4344aee7dae4Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 4345aee7dae4Smrg 4346aee7dae4Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 4347aee7dae4Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 4348aee7dae4Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4349aee7dae4Smrg 4350aee7dae4Smrgint 4351aee7dae4Smrgmain (int argc, char *argv[]) 4352aee7dae4Smrg{ 4353aee7dae4Smrg char **newargz; 4354aee7dae4Smrg int newargc; 4355aee7dae4Smrg char *tmp_pathspec; 4356aee7dae4Smrg char *actual_cwrapper_path; 4357aee7dae4Smrg char *actual_cwrapper_name; 4358aee7dae4Smrg char *target_name; 4359aee7dae4Smrg char *lt_argv_zero; 4360aee7dae4Smrg intptr_t rval = 127; 4361aee7dae4Smrg 4362aee7dae4Smrg int i; 4363aee7dae4Smrg 4364aee7dae4Smrg program_name = (char *) xstrdup (base_name (argv[0])); 4365aee7dae4Smrg newargz = XMALLOC (char *, argc + 1); 4366aee7dae4Smrg 4367aee7dae4Smrg /* very simple arg parsing; don't want to rely on getopt 4368aee7dae4Smrg * also, copy all non cwrapper options to newargz, except 4369aee7dae4Smrg * argz[0], which is handled differently 4370aee7dae4Smrg */ 4371aee7dae4Smrg newargc=0; 4372aee7dae4Smrg for (i = 1; i < argc; i++) 4373aee7dae4Smrg { 4374aee7dae4Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 4375aee7dae4Smrg { 4376aee7dae4SmrgEOF 4377aee7dae4Smrg case "$host" in 4378aee7dae4Smrg *mingw* | *cygwin* ) 4379aee7dae4Smrg # make stdout use "unix" line endings 4380aee7dae4Smrg echo " setmode(1,_O_BINARY);" 4381aee7dae4Smrg ;; 4382aee7dae4Smrg esac 4383aee7dae4Smrg 4384aee7dae4Smrg cat <<"EOF" 4385aee7dae4Smrg lt_dump_script (stdout); 4386aee7dae4Smrg return 0; 4387aee7dae4Smrg } 4388aee7dae4Smrg if (strcmp (argv[i], debug_opt) == 0) 4389aee7dae4Smrg { 4390aee7dae4Smrg lt_debug = 1; 4391aee7dae4Smrg continue; 4392aee7dae4Smrg } 4393aee7dae4Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 4394aee7dae4Smrg { 4395aee7dae4Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4396aee7dae4Smrg namespace, but it is not one of the ones we know about and 4397aee7dae4Smrg have already dealt with, above (inluding dump-script), then 4398aee7dae4Smrg report an error. Otherwise, targets might begin to believe 4399aee7dae4Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4400aee7dae4Smrg namespace. The first time any user complains about this, we'll 4401aee7dae4Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 4402aee7dae4Smrg or a configure.ac-settable value. 4403aee7dae4Smrg */ 4404aee7dae4Smrg lt_fatal (__FILE__, __LINE__, 4405aee7dae4Smrg "unrecognized %s option: '%s'", 4406aee7dae4Smrg ltwrapper_option_prefix, argv[i]); 4407aee7dae4Smrg } 4408aee7dae4Smrg /* otherwise ... */ 4409aee7dae4Smrg newargz[++newargc] = xstrdup (argv[i]); 4410aee7dae4Smrg } 4411aee7dae4Smrg newargz[++newargc] = NULL; 4412aee7dae4Smrg 4413aee7dae4SmrgEOF 4414aee7dae4Smrg cat <<EOF 4415aee7dae4Smrg /* The GNU banner must be the first non-error debug message */ 4416aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 4417aee7dae4SmrgEOF 4418aee7dae4Smrg cat <<"EOF" 4419aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 4420aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4421aee7dae4Smrg 4422aee7dae4Smrg tmp_pathspec = find_executable (argv[0]); 4423aee7dae4Smrg if (tmp_pathspec == NULL) 4424aee7dae4Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 4425aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, 4426aee7dae4Smrg "(main) found exe (before symlink chase) at: %s\n", 4427aee7dae4Smrg tmp_pathspec); 4428aee7dae4Smrg 4429aee7dae4Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 4430aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, 4431aee7dae4Smrg "(main) found exe (after symlink chase) at: %s\n", 4432aee7dae4Smrg actual_cwrapper_path); 4433aee7dae4Smrg XFREE (tmp_pathspec); 4434aee7dae4Smrg 4435aee7dae4Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 4436aee7dae4Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 4437aee7dae4Smrg 4438aee7dae4Smrg /* wrapper name transforms */ 4439aee7dae4Smrg strendzap (actual_cwrapper_name, ".exe"); 4440aee7dae4Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 4441aee7dae4Smrg XFREE (actual_cwrapper_name); 4442aee7dae4Smrg actual_cwrapper_name = tmp_pathspec; 4443aee7dae4Smrg tmp_pathspec = 0; 4444aee7dae4Smrg 4445aee7dae4Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 4446aee7dae4Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 4447aee7dae4Smrg strendzap (target_name, ".exe"); 4448aee7dae4Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 4449aee7dae4Smrg XFREE (target_name); 4450aee7dae4Smrg target_name = tmp_pathspec; 4451aee7dae4Smrg tmp_pathspec = 0; 4452aee7dae4Smrg 4453aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, 4454aee7dae4Smrg "(main) libtool target name: %s\n", 4455aee7dae4Smrg target_name); 4456aee7dae4SmrgEOF 4457aee7dae4Smrg 4458aee7dae4Smrg cat <<EOF 4459aee7dae4Smrg newargz[0] = 4460aee7dae4Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 4461aee7dae4Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 4462aee7dae4Smrg strcpy (newargz[0], actual_cwrapper_path); 4463aee7dae4Smrg strcat (newargz[0], "$objdir"); 4464aee7dae4Smrg strcat (newargz[0], "/"); 4465aee7dae4SmrgEOF 4466aee7dae4Smrg 4467aee7dae4Smrg cat <<"EOF" 4468aee7dae4Smrg /* stop here, and copy so we don't have to do this twice */ 4469aee7dae4Smrg tmp_pathspec = xstrdup (newargz[0]); 4470aee7dae4Smrg 4471aee7dae4Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 4472aee7dae4Smrg strcat (newargz[0], actual_cwrapper_name); 4473aee7dae4Smrg 4474aee7dae4Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 4475aee7dae4Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 4476aee7dae4Smrg XFREE (tmp_pathspec); 4477aee7dae4Smrg tmp_pathspec = NULL; 4478aee7dae4SmrgEOF 4479aee7dae4Smrg 4480aee7dae4Smrg case $host_os in 4481aee7dae4Smrg mingw*) 4482aee7dae4Smrg cat <<"EOF" 4483aee7dae4Smrg { 4484aee7dae4Smrg char* p; 4485aee7dae4Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 4486aee7dae4Smrg { 4487aee7dae4Smrg *p = '/'; 4488aee7dae4Smrg } 4489aee7dae4Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 4490aee7dae4Smrg { 4491aee7dae4Smrg *p = '/'; 4492aee7dae4Smrg } 4493aee7dae4Smrg } 4494aee7dae4SmrgEOF 4495aee7dae4Smrg ;; 4496aee7dae4Smrg esac 4497aee7dae4Smrg 4498aee7dae4Smrg cat <<"EOF" 4499aee7dae4Smrg XFREE (target_name); 4500aee7dae4Smrg XFREE (actual_cwrapper_path); 4501aee7dae4Smrg XFREE (actual_cwrapper_name); 4502aee7dae4Smrg 4503aee7dae4Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 4504aee7dae4Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 4505aee7dae4Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 4506aee7dae4Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 4507aee7dae4Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 4508aee7dae4Smrg libraries must come first. */ 4509aee7dae4Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 4510aee7dae4Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4511aee7dae4Smrg 4512aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 4513aee7dae4Smrg nonnull (lt_argv_zero)); 4514aee7dae4Smrg for (i = 0; i < newargc; i++) 4515aee7dae4Smrg { 4516aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 4517aee7dae4Smrg i, nonnull (newargz[i])); 4518aee7dae4Smrg } 4519aee7dae4Smrg 4520aee7dae4SmrgEOF 4521aee7dae4Smrg 4522aee7dae4Smrg case $host_os in 4523aee7dae4Smrg mingw*) 4524aee7dae4Smrg cat <<"EOF" 4525aee7dae4Smrg /* execv doesn't actually work on mingw as expected on unix */ 4526aee7dae4Smrg newargz = prepare_spawn (newargz); 4527aee7dae4Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 4528aee7dae4Smrg if (rval == -1) 4529aee7dae4Smrg { 4530aee7dae4Smrg /* failed to start process */ 4531aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, 4532aee7dae4Smrg "(main) failed to launch target \"%s\": %s\n", 4533aee7dae4Smrg lt_argv_zero, nonnull (strerror (errno))); 4534aee7dae4Smrg return 127; 4535aee7dae4Smrg } 4536aee7dae4Smrg return rval; 4537aee7dae4SmrgEOF 4538aee7dae4Smrg ;; 4539aee7dae4Smrg *) 4540aee7dae4Smrg cat <<"EOF" 4541aee7dae4Smrg execv (lt_argv_zero, newargz); 4542aee7dae4Smrg return rval; /* =127, but avoids unused variable warning */ 4543aee7dae4SmrgEOF 4544aee7dae4Smrg ;; 4545aee7dae4Smrg esac 4546aee7dae4Smrg 4547aee7dae4Smrg cat <<"EOF" 4548aee7dae4Smrg} 4549aee7dae4Smrg 4550aee7dae4Smrgvoid * 4551aee7dae4Smrgxmalloc (size_t num) 4552aee7dae4Smrg{ 4553aee7dae4Smrg void *p = (void *) malloc (num); 4554aee7dae4Smrg if (!p) 4555aee7dae4Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4556aee7dae4Smrg 4557aee7dae4Smrg return p; 4558aee7dae4Smrg} 4559aee7dae4Smrg 4560aee7dae4Smrgchar * 4561aee7dae4Smrgxstrdup (const char *string) 4562aee7dae4Smrg{ 4563aee7dae4Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 4564aee7dae4Smrg string) : NULL; 4565aee7dae4Smrg} 4566aee7dae4Smrg 4567aee7dae4Smrgconst char * 4568aee7dae4Smrgbase_name (const char *name) 4569aee7dae4Smrg{ 4570aee7dae4Smrg const char *base; 4571aee7dae4Smrg 4572aee7dae4Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4573aee7dae4Smrg /* Skip over the disk name in MSDOS pathnames. */ 4574aee7dae4Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 4575aee7dae4Smrg name += 2; 4576aee7dae4Smrg#endif 4577aee7dae4Smrg 4578aee7dae4Smrg for (base = name; *name; name++) 4579aee7dae4Smrg if (IS_DIR_SEPARATOR (*name)) 4580aee7dae4Smrg base = name + 1; 4581aee7dae4Smrg return base; 4582aee7dae4Smrg} 4583aee7dae4Smrg 4584aee7dae4Smrgint 4585aee7dae4Smrgcheck_executable (const char *path) 4586aee7dae4Smrg{ 4587aee7dae4Smrg struct stat st; 4588aee7dae4Smrg 4589aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 4590aee7dae4Smrg nonempty (path)); 4591aee7dae4Smrg if ((!path) || (!*path)) 4592aee7dae4Smrg return 0; 4593aee7dae4Smrg 4594aee7dae4Smrg if ((stat (path, &st) >= 0) 4595aee7dae4Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 4596aee7dae4Smrg return 1; 4597aee7dae4Smrg else 4598aee7dae4Smrg return 0; 4599aee7dae4Smrg} 4600aee7dae4Smrg 4601aee7dae4Smrgint 4602aee7dae4Smrgmake_executable (const char *path) 4603aee7dae4Smrg{ 4604aee7dae4Smrg int rval = 0; 4605aee7dae4Smrg struct stat st; 4606aee7dae4Smrg 4607aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 4608aee7dae4Smrg nonempty (path)); 4609aee7dae4Smrg if ((!path) || (!*path)) 4610aee7dae4Smrg return 0; 4611aee7dae4Smrg 4612aee7dae4Smrg if (stat (path, &st) >= 0) 4613aee7dae4Smrg { 4614aee7dae4Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 4615aee7dae4Smrg } 4616aee7dae4Smrg return rval; 4617aee7dae4Smrg} 4618aee7dae4Smrg 4619aee7dae4Smrg/* Searches for the full path of the wrapper. Returns 4620aee7dae4Smrg newly allocated full path name if found, NULL otherwise 4621aee7dae4Smrg Does not chase symlinks, even on platforms that support them. 4622aee7dae4Smrg*/ 4623aee7dae4Smrgchar * 4624aee7dae4Smrgfind_executable (const char *wrapper) 4625aee7dae4Smrg{ 4626aee7dae4Smrg int has_slash = 0; 4627aee7dae4Smrg const char *p; 4628aee7dae4Smrg const char *p_next; 4629aee7dae4Smrg /* static buffer for getcwd */ 4630aee7dae4Smrg char tmp[LT_PATHMAX + 1]; 4631aee7dae4Smrg int tmp_len; 4632aee7dae4Smrg char *concat_name; 4633aee7dae4Smrg 4634aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 4635aee7dae4Smrg nonempty (wrapper)); 4636aee7dae4Smrg 4637aee7dae4Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 4638aee7dae4Smrg return NULL; 4639aee7dae4Smrg 4640aee7dae4Smrg /* Absolute path? */ 4641aee7dae4Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4642aee7dae4Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 4643aee7dae4Smrg { 4644aee7dae4Smrg concat_name = xstrdup (wrapper); 4645aee7dae4Smrg if (check_executable (concat_name)) 4646aee7dae4Smrg return concat_name; 4647aee7dae4Smrg XFREE (concat_name); 4648aee7dae4Smrg } 4649aee7dae4Smrg else 4650aee7dae4Smrg { 4651aee7dae4Smrg#endif 4652aee7dae4Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 4653aee7dae4Smrg { 4654aee7dae4Smrg concat_name = xstrdup (wrapper); 4655aee7dae4Smrg if (check_executable (concat_name)) 4656aee7dae4Smrg return concat_name; 4657aee7dae4Smrg XFREE (concat_name); 4658aee7dae4Smrg } 4659aee7dae4Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4660aee7dae4Smrg } 4661aee7dae4Smrg#endif 4662aee7dae4Smrg 4663aee7dae4Smrg for (p = wrapper; *p; p++) 4664aee7dae4Smrg if (*p == '/') 4665aee7dae4Smrg { 4666aee7dae4Smrg has_slash = 1; 4667aee7dae4Smrg break; 4668aee7dae4Smrg } 4669aee7dae4Smrg if (!has_slash) 4670aee7dae4Smrg { 4671aee7dae4Smrg /* no slashes; search PATH */ 4672aee7dae4Smrg const char *path = getenv ("PATH"); 4673aee7dae4Smrg if (path != NULL) 4674aee7dae4Smrg { 4675aee7dae4Smrg for (p = path; *p; p = p_next) 4676aee7dae4Smrg { 4677aee7dae4Smrg const char *q; 4678aee7dae4Smrg size_t p_len; 4679aee7dae4Smrg for (q = p; *q; q++) 4680aee7dae4Smrg if (IS_PATH_SEPARATOR (*q)) 4681aee7dae4Smrg break; 4682aee7dae4Smrg p_len = q - p; 4683aee7dae4Smrg p_next = (*q == '\0' ? q : q + 1); 4684aee7dae4Smrg if (p_len == 0) 4685aee7dae4Smrg { 4686aee7dae4Smrg /* empty path: current directory */ 4687aee7dae4Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4688aee7dae4Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4689aee7dae4Smrg nonnull (strerror (errno))); 4690aee7dae4Smrg tmp_len = strlen (tmp); 4691aee7dae4Smrg concat_name = 4692aee7dae4Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4693aee7dae4Smrg memcpy (concat_name, tmp, tmp_len); 4694aee7dae4Smrg concat_name[tmp_len] = '/'; 4695aee7dae4Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4696aee7dae4Smrg } 4697aee7dae4Smrg else 4698aee7dae4Smrg { 4699aee7dae4Smrg concat_name = 4700aee7dae4Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 4701aee7dae4Smrg memcpy (concat_name, p, p_len); 4702aee7dae4Smrg concat_name[p_len] = '/'; 4703aee7dae4Smrg strcpy (concat_name + p_len + 1, wrapper); 4704aee7dae4Smrg } 4705aee7dae4Smrg if (check_executable (concat_name)) 4706aee7dae4Smrg return concat_name; 4707aee7dae4Smrg XFREE (concat_name); 4708aee7dae4Smrg } 4709aee7dae4Smrg } 4710aee7dae4Smrg /* not found in PATH; assume curdir */ 4711aee7dae4Smrg } 4712aee7dae4Smrg /* Relative path | not found in path: prepend cwd */ 4713aee7dae4Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 4714aee7dae4Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4715aee7dae4Smrg nonnull (strerror (errno))); 4716aee7dae4Smrg tmp_len = strlen (tmp); 4717aee7dae4Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4718aee7dae4Smrg memcpy (concat_name, tmp, tmp_len); 4719aee7dae4Smrg concat_name[tmp_len] = '/'; 4720aee7dae4Smrg strcpy (concat_name + tmp_len + 1, wrapper); 4721aee7dae4Smrg 4722aee7dae4Smrg if (check_executable (concat_name)) 4723aee7dae4Smrg return concat_name; 4724aee7dae4Smrg XFREE (concat_name); 4725aee7dae4Smrg return NULL; 4726aee7dae4Smrg} 4727aee7dae4Smrg 4728aee7dae4Smrgchar * 4729aee7dae4Smrgchase_symlinks (const char *pathspec) 4730aee7dae4Smrg{ 4731aee7dae4Smrg#ifndef S_ISLNK 4732aee7dae4Smrg return xstrdup (pathspec); 4733aee7dae4Smrg#else 4734aee7dae4Smrg char buf[LT_PATHMAX]; 4735aee7dae4Smrg struct stat s; 4736aee7dae4Smrg char *tmp_pathspec = xstrdup (pathspec); 4737aee7dae4Smrg char *p; 4738aee7dae4Smrg int has_symlinks = 0; 4739aee7dae4Smrg while (strlen (tmp_pathspec) && !has_symlinks) 4740aee7dae4Smrg { 4741aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, 4742aee7dae4Smrg "checking path component for symlinks: %s\n", 4743aee7dae4Smrg tmp_pathspec); 4744aee7dae4Smrg if (lstat (tmp_pathspec, &s) == 0) 4745aee7dae4Smrg { 4746aee7dae4Smrg if (S_ISLNK (s.st_mode) != 0) 4747aee7dae4Smrg { 4748aee7dae4Smrg has_symlinks = 1; 4749aee7dae4Smrg break; 4750aee7dae4Smrg } 4751aee7dae4Smrg 4752aee7dae4Smrg /* search backwards for last DIR_SEPARATOR */ 4753aee7dae4Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 4754aee7dae4Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4755aee7dae4Smrg p--; 4756aee7dae4Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4757aee7dae4Smrg { 4758aee7dae4Smrg /* no more DIR_SEPARATORS left */ 4759aee7dae4Smrg break; 4760aee7dae4Smrg } 4761aee7dae4Smrg *p = '\0'; 4762aee7dae4Smrg } 4763aee7dae4Smrg else 4764aee7dae4Smrg { 4765aee7dae4Smrg lt_fatal (__FILE__, __LINE__, 4766aee7dae4Smrg "error accessing file \"%s\": %s", 4767aee7dae4Smrg tmp_pathspec, nonnull (strerror (errno))); 4768aee7dae4Smrg } 4769aee7dae4Smrg } 4770aee7dae4Smrg XFREE (tmp_pathspec); 4771aee7dae4Smrg 4772aee7dae4Smrg if (!has_symlinks) 4773aee7dae4Smrg { 4774aee7dae4Smrg return xstrdup (pathspec); 4775aee7dae4Smrg } 4776aee7dae4Smrg 4777aee7dae4Smrg tmp_pathspec = realpath (pathspec, buf); 4778aee7dae4Smrg if (tmp_pathspec == 0) 4779aee7dae4Smrg { 4780aee7dae4Smrg lt_fatal (__FILE__, __LINE__, 4781aee7dae4Smrg "could not follow symlinks for %s", pathspec); 4782aee7dae4Smrg } 4783aee7dae4Smrg return xstrdup (tmp_pathspec); 4784aee7dae4Smrg#endif 4785aee7dae4Smrg} 4786aee7dae4Smrg 4787aee7dae4Smrgchar * 4788aee7dae4Smrgstrendzap (char *str, const char *pat) 4789aee7dae4Smrg{ 4790aee7dae4Smrg size_t len, patlen; 4791aee7dae4Smrg 4792aee7dae4Smrg assert (str != NULL); 4793aee7dae4Smrg assert (pat != NULL); 4794aee7dae4Smrg 4795aee7dae4Smrg len = strlen (str); 4796aee7dae4Smrg patlen = strlen (pat); 4797aee7dae4Smrg 4798aee7dae4Smrg if (patlen <= len) 4799aee7dae4Smrg { 4800aee7dae4Smrg str += len - patlen; 4801aee7dae4Smrg if (strcmp (str, pat) == 0) 4802aee7dae4Smrg *str = '\0'; 4803aee7dae4Smrg } 4804aee7dae4Smrg return str; 4805aee7dae4Smrg} 4806aee7dae4Smrg 4807aee7dae4Smrgvoid 4808aee7dae4Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 4809aee7dae4Smrg{ 4810aee7dae4Smrg va_list args; 4811aee7dae4Smrg if (lt_debug) 4812aee7dae4Smrg { 4813aee7dae4Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 4814aee7dae4Smrg va_start (args, fmt); 4815aee7dae4Smrg (void) vfprintf (stderr, fmt, args); 4816aee7dae4Smrg va_end (args); 4817aee7dae4Smrg } 4818aee7dae4Smrg} 4819aee7dae4Smrg 4820aee7dae4Smrgstatic void 4821aee7dae4Smrglt_error_core (int exit_status, const char *file, 4822aee7dae4Smrg int line, const char *mode, 4823aee7dae4Smrg const char *message, va_list ap) 4824aee7dae4Smrg{ 4825aee7dae4Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 4826aee7dae4Smrg vfprintf (stderr, message, ap); 4827aee7dae4Smrg fprintf (stderr, ".\n"); 4828aee7dae4Smrg 4829aee7dae4Smrg if (exit_status >= 0) 4830aee7dae4Smrg exit (exit_status); 4831aee7dae4Smrg} 4832aee7dae4Smrg 4833aee7dae4Smrgvoid 4834aee7dae4Smrglt_fatal (const char *file, int line, const char *message, ...) 4835aee7dae4Smrg{ 4836aee7dae4Smrg va_list ap; 4837aee7dae4Smrg va_start (ap, message); 4838aee7dae4Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 4839aee7dae4Smrg va_end (ap); 4840aee7dae4Smrg} 4841aee7dae4Smrg 4842aee7dae4Smrgstatic const char * 4843aee7dae4Smrgnonnull (const char *s) 4844aee7dae4Smrg{ 4845aee7dae4Smrg return s ? s : "(null)"; 4846aee7dae4Smrg} 4847aee7dae4Smrg 4848aee7dae4Smrgstatic const char * 4849aee7dae4Smrgnonempty (const char *s) 4850aee7dae4Smrg{ 4851aee7dae4Smrg return (s && !*s) ? "(empty)" : nonnull (s); 4852aee7dae4Smrg} 4853aee7dae4Smrg 4854aee7dae4Smrgvoid 4855aee7dae4Smrglt_setenv (const char *name, const char *value) 4856aee7dae4Smrg{ 4857aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, 4858aee7dae4Smrg "(lt_setenv) setting '%s' to '%s'\n", 4859aee7dae4Smrg nonnull (name), nonnull (value)); 4860aee7dae4Smrg { 4861aee7dae4Smrg#ifdef HAVE_SETENV 4862aee7dae4Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 4863aee7dae4Smrg char *str = xstrdup (value); 4864aee7dae4Smrg setenv (name, str, 1); 4865aee7dae4Smrg#else 4866aee7dae4Smrg int len = strlen (name) + 1 + strlen (value) + 1; 4867aee7dae4Smrg char *str = XMALLOC (char, len); 4868aee7dae4Smrg sprintf (str, "%s=%s", name, value); 4869aee7dae4Smrg if (putenv (str) != EXIT_SUCCESS) 4870aee7dae4Smrg { 4871aee7dae4Smrg XFREE (str); 4872aee7dae4Smrg } 4873aee7dae4Smrg#endif 4874aee7dae4Smrg } 4875aee7dae4Smrg} 4876aee7dae4Smrg 4877aee7dae4Smrgchar * 4878aee7dae4Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 4879aee7dae4Smrg{ 4880aee7dae4Smrg char *new_value; 4881aee7dae4Smrg if (orig_value && *orig_value) 4882aee7dae4Smrg { 4883aee7dae4Smrg int orig_value_len = strlen (orig_value); 4884aee7dae4Smrg int add_len = strlen (add); 4885aee7dae4Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 4886aee7dae4Smrg if (to_end) 4887aee7dae4Smrg { 4888aee7dae4Smrg strcpy (new_value, orig_value); 4889aee7dae4Smrg strcpy (new_value + orig_value_len, add); 4890aee7dae4Smrg } 4891aee7dae4Smrg else 4892aee7dae4Smrg { 4893aee7dae4Smrg strcpy (new_value, add); 4894aee7dae4Smrg strcpy (new_value + add_len, orig_value); 4895aee7dae4Smrg } 4896aee7dae4Smrg } 4897aee7dae4Smrg else 4898aee7dae4Smrg { 4899aee7dae4Smrg new_value = xstrdup (add); 4900aee7dae4Smrg } 4901aee7dae4Smrg return new_value; 4902aee7dae4Smrg} 4903aee7dae4Smrg 4904aee7dae4Smrgvoid 4905aee7dae4Smrglt_update_exe_path (const char *name, const char *value) 4906aee7dae4Smrg{ 4907aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, 4908aee7dae4Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 4909aee7dae4Smrg nonnull (name), nonnull (value)); 4910aee7dae4Smrg 4911aee7dae4Smrg if (name && *name && value && *value) 4912aee7dae4Smrg { 4913aee7dae4Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4914aee7dae4Smrg /* some systems can't cope with a ':'-terminated path #' */ 4915aee7dae4Smrg int len = strlen (new_value); 4916aee7dae4Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 4917aee7dae4Smrg { 4918aee7dae4Smrg new_value[len-1] = '\0'; 4919aee7dae4Smrg } 4920aee7dae4Smrg lt_setenv (name, new_value); 4921aee7dae4Smrg XFREE (new_value); 4922aee7dae4Smrg } 4923aee7dae4Smrg} 4924aee7dae4Smrg 4925aee7dae4Smrgvoid 4926aee7dae4Smrglt_update_lib_path (const char *name, const char *value) 4927aee7dae4Smrg{ 4928aee7dae4Smrg lt_debugprintf (__FILE__, __LINE__, 4929aee7dae4Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 4930aee7dae4Smrg nonnull (name), nonnull (value)); 4931aee7dae4Smrg 4932aee7dae4Smrg if (name && *name && value && *value) 4933aee7dae4Smrg { 4934aee7dae4Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 4935aee7dae4Smrg lt_setenv (name, new_value); 4936aee7dae4Smrg XFREE (new_value); 4937aee7dae4Smrg } 4938aee7dae4Smrg} 4939aee7dae4Smrg 4940aee7dae4SmrgEOF 4941aee7dae4Smrg case $host_os in 4942aee7dae4Smrg mingw*) 4943aee7dae4Smrg cat <<"EOF" 4944aee7dae4Smrg 4945aee7dae4Smrg/* Prepares an argument vector before calling spawn(). 4946aee7dae4Smrg Note that spawn() does not by itself call the command interpreter 4947aee7dae4Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 4948aee7dae4Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 4949aee7dae4Smrg GetVersionEx(&v); 4950aee7dae4Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 4951aee7dae4Smrg }) ? "cmd.exe" : "command.com"). 4952aee7dae4Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 4953aee7dae4Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 4954aee7dae4Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 4955aee7dae4Smrg special way: 4956aee7dae4Smrg - Space and tab are interpreted as delimiters. They are not treated as 4957aee7dae4Smrg delimiters if they are surrounded by double quotes: "...". 4958aee7dae4Smrg - Unescaped double quotes are removed from the input. Their only effect is 4959aee7dae4Smrg that within double quotes, space and tab are treated like normal 4960aee7dae4Smrg characters. 4961aee7dae4Smrg - Backslashes not followed by double quotes are not special. 4962aee7dae4Smrg - But 2*n+1 backslashes followed by a double quote become 4963aee7dae4Smrg n backslashes followed by a double quote (n >= 0): 4964aee7dae4Smrg \" -> " 4965aee7dae4Smrg \\\" -> \" 4966aee7dae4Smrg \\\\\" -> \\" 4967aee7dae4Smrg */ 4968aee7dae4Smrg#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" 4969aee7dae4Smrg#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" 4970aee7dae4Smrgchar ** 4971aee7dae4Smrgprepare_spawn (char **argv) 4972aee7dae4Smrg{ 4973aee7dae4Smrg size_t argc; 4974aee7dae4Smrg char **new_argv; 4975aee7dae4Smrg size_t i; 4976aee7dae4Smrg 4977aee7dae4Smrg /* Count number of arguments. */ 4978aee7dae4Smrg for (argc = 0; argv[argc] != NULL; argc++) 4979aee7dae4Smrg ; 4980aee7dae4Smrg 4981aee7dae4Smrg /* Allocate new argument vector. */ 4982aee7dae4Smrg new_argv = XMALLOC (char *, argc + 1); 4983aee7dae4Smrg 4984aee7dae4Smrg /* Put quoted arguments into the new argument vector. */ 4985aee7dae4Smrg for (i = 0; i < argc; i++) 4986aee7dae4Smrg { 4987aee7dae4Smrg const char *string = argv[i]; 4988aee7dae4Smrg 4989aee7dae4Smrg if (string[0] == '\0') 4990aee7dae4Smrg new_argv[i] = xstrdup ("\"\""); 4991aee7dae4Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 4992aee7dae4Smrg { 4993aee7dae4Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 4994aee7dae4Smrg size_t length; 4995aee7dae4Smrg unsigned int backslashes; 4996aee7dae4Smrg const char *s; 4997aee7dae4Smrg char *quoted_string; 4998aee7dae4Smrg char *p; 4999aee7dae4Smrg 5000aee7dae4Smrg length = 0; 5001aee7dae4Smrg backslashes = 0; 5002aee7dae4Smrg if (quote_around) 5003aee7dae4Smrg length++; 5004aee7dae4Smrg for (s = string; *s != '\0'; s++) 5005aee7dae4Smrg { 5006aee7dae4Smrg char c = *s; 5007aee7dae4Smrg if (c == '"') 5008aee7dae4Smrg length += backslashes + 1; 5009aee7dae4Smrg length++; 5010aee7dae4Smrg if (c == '\\') 5011aee7dae4Smrg backslashes++; 5012aee7dae4Smrg else 5013aee7dae4Smrg backslashes = 0; 5014aee7dae4Smrg } 5015aee7dae4Smrg if (quote_around) 5016aee7dae4Smrg length += backslashes + 1; 5017aee7dae4Smrg 5018aee7dae4Smrg quoted_string = XMALLOC (char, length + 1); 5019aee7dae4Smrg 5020aee7dae4Smrg p = quoted_string; 5021aee7dae4Smrg backslashes = 0; 5022aee7dae4Smrg if (quote_around) 5023aee7dae4Smrg *p++ = '"'; 5024aee7dae4Smrg for (s = string; *s != '\0'; s++) 5025aee7dae4Smrg { 5026aee7dae4Smrg char c = *s; 5027aee7dae4Smrg if (c == '"') 5028aee7dae4Smrg { 5029aee7dae4Smrg unsigned int j; 5030aee7dae4Smrg for (j = backslashes + 1; j > 0; j--) 5031aee7dae4Smrg *p++ = '\\'; 5032aee7dae4Smrg } 5033aee7dae4Smrg *p++ = c; 5034aee7dae4Smrg if (c == '\\') 5035aee7dae4Smrg backslashes++; 5036aee7dae4Smrg else 5037aee7dae4Smrg backslashes = 0; 5038aee7dae4Smrg } 5039aee7dae4Smrg if (quote_around) 5040aee7dae4Smrg { 5041aee7dae4Smrg unsigned int j; 5042aee7dae4Smrg for (j = backslashes; j > 0; j--) 5043aee7dae4Smrg *p++ = '\\'; 5044aee7dae4Smrg *p++ = '"'; 5045aee7dae4Smrg } 5046aee7dae4Smrg *p = '\0'; 5047aee7dae4Smrg 5048aee7dae4Smrg new_argv[i] = quoted_string; 5049aee7dae4Smrg } 5050aee7dae4Smrg else 5051aee7dae4Smrg new_argv[i] = (char *) string; 5052aee7dae4Smrg } 5053aee7dae4Smrg new_argv[argc] = NULL; 5054aee7dae4Smrg 5055aee7dae4Smrg return new_argv; 5056aee7dae4Smrg} 5057aee7dae4SmrgEOF 5058aee7dae4Smrg ;; 5059aee7dae4Smrg esac 5060aee7dae4Smrg 5061aee7dae4Smrg cat <<"EOF" 5062aee7dae4Smrgvoid lt_dump_script (FILE* f) 5063aee7dae4Smrg{ 5064aee7dae4SmrgEOF 5065aee7dae4Smrg func_emit_wrapper yes | 5066aee7dae4Smrg $SED -n -e ' 5067aee7dae4Smrgs/^\(.\{79\}\)\(..*\)/\1\ 5068aee7dae4Smrg\2/ 5069aee7dae4Smrgh 5070aee7dae4Smrgs/\([\\"]\)/\\\1/g 5071aee7dae4Smrgs/$/\\n/ 5072aee7dae4Smrgs/\([^\n]*\).*/ fputs ("\1", f);/p 5073aee7dae4Smrgg 5074aee7dae4SmrgD' 5075aee7dae4Smrg cat <<"EOF" 5076aee7dae4Smrg} 5077aee7dae4SmrgEOF 5078aee7dae4Smrg} 5079aee7dae4Smrg# end: func_emit_cwrapperexe_src 5080aee7dae4Smrg 5081aee7dae4Smrg# func_win32_import_lib_p ARG 5082aee7dae4Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 5083aee7dae4Smrgfunc_win32_import_lib_p () 5084aee7dae4Smrg{ 5085aee7dae4Smrg $opt_debug 5086aee7dae4Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 5087aee7dae4Smrg *import*) : ;; 5088aee7dae4Smrg *) false ;; 5089aee7dae4Smrg esac 5090aee7dae4Smrg} 5091aee7dae4Smrg 5092aee7dae4Smrg# func_mode_link arg... 5093aee7dae4Smrgfunc_mode_link () 5094aee7dae4Smrg{ 5095aee7dae4Smrg $opt_debug 5096aee7dae4Smrg case $host in 5097aee7dae4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5098aee7dae4Smrg # It is impossible to link a dll without this setting, and 5099aee7dae4Smrg # we shouldn't force the makefile maintainer to figure out 5100aee7dae4Smrg # which system we are compiling for in order to pass an extra 5101aee7dae4Smrg # flag for every libtool invocation. 5102aee7dae4Smrg # allow_undefined=no 5103aee7dae4Smrg 5104aee7dae4Smrg # FIXME: Unfortunately, there are problems with the above when trying 5105aee7dae4Smrg # to make a dll which has undefined symbols, in which case not 5106aee7dae4Smrg # even a static library is built. For now, we need to specify 5107aee7dae4Smrg # -no-undefined on the libtool link line when we can be certain 5108aee7dae4Smrg # that all symbols are satisfied, otherwise we get a static library. 5109aee7dae4Smrg allow_undefined=yes 5110aee7dae4Smrg ;; 5111aee7dae4Smrg *) 5112aee7dae4Smrg allow_undefined=yes 5113aee7dae4Smrg ;; 5114aee7dae4Smrg esac 5115aee7dae4Smrg libtool_args=$nonopt 5116aee7dae4Smrg base_compile="$nonopt $@" 5117aee7dae4Smrg compile_command=$nonopt 5118aee7dae4Smrg finalize_command=$nonopt 5119aee7dae4Smrg 5120aee7dae4Smrg compile_rpath= 5121aee7dae4Smrg finalize_rpath= 5122aee7dae4Smrg compile_shlibpath= 5123aee7dae4Smrg finalize_shlibpath= 5124aee7dae4Smrg convenience= 5125aee7dae4Smrg old_convenience= 5126aee7dae4Smrg deplibs= 5127aee7dae4Smrg old_deplibs= 5128aee7dae4Smrg compiler_flags= 5129aee7dae4Smrg linker_flags= 5130aee7dae4Smrg dllsearchpath= 5131aee7dae4Smrg lib_search_path=`pwd` 5132aee7dae4Smrg inst_prefix_dir= 5133aee7dae4Smrg new_inherited_linker_flags= 5134aee7dae4Smrg 5135aee7dae4Smrg avoid_version=no 5136aee7dae4Smrg bindir= 5137aee7dae4Smrg dlfiles= 5138aee7dae4Smrg dlprefiles= 5139aee7dae4Smrg dlself=no 5140aee7dae4Smrg export_dynamic=no 5141aee7dae4Smrg export_symbols= 5142aee7dae4Smrg export_symbols_regex= 5143aee7dae4Smrg generated= 5144aee7dae4Smrg libobjs= 5145aee7dae4Smrg ltlibs= 5146aee7dae4Smrg module=no 5147aee7dae4Smrg no_install=no 5148aee7dae4Smrg objs= 5149aee7dae4Smrg non_pic_objects= 5150aee7dae4Smrg precious_files_regex= 5151aee7dae4Smrg prefer_static_libs=no 5152aee7dae4Smrg preload=no 5153aee7dae4Smrg prev= 5154aee7dae4Smrg prevarg= 5155aee7dae4Smrg release= 5156aee7dae4Smrg rpath= 5157aee7dae4Smrg xrpath= 5158aee7dae4Smrg perm_rpath= 5159aee7dae4Smrg temp_rpath= 5160aee7dae4Smrg thread_safe=no 5161aee7dae4Smrg vinfo= 5162aee7dae4Smrg vinfo_number=no 5163aee7dae4Smrg weak_libs= 5164aee7dae4Smrg single_module="${wl}-single_module" 5165aee7dae4Smrg func_infer_tag $base_compile 5166aee7dae4Smrg 5167aee7dae4Smrg # We need to know -static, to get the right output filenames. 5168aee7dae4Smrg for arg 5169aee7dae4Smrg do 5170aee7dae4Smrg case $arg in 5171aee7dae4Smrg -shared) 5172aee7dae4Smrg test "$build_libtool_libs" != yes && \ 5173aee7dae4Smrg func_fatal_configuration "can not build a shared library" 5174aee7dae4Smrg build_old_libs=no 5175aee7dae4Smrg break 5176aee7dae4Smrg ;; 5177aee7dae4Smrg -all-static | -static | -static-libtool-libs) 5178aee7dae4Smrg case $arg in 5179aee7dae4Smrg -all-static) 5180aee7dae4Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 5181aee7dae4Smrg func_warning "complete static linking is impossible in this configuration" 5182aee7dae4Smrg fi 5183aee7dae4Smrg if test -n "$link_static_flag"; then 5184aee7dae4Smrg dlopen_self=$dlopen_self_static 5185aee7dae4Smrg fi 5186aee7dae4Smrg prefer_static_libs=yes 5187aee7dae4Smrg ;; 5188aee7dae4Smrg -static) 5189aee7dae4Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5190aee7dae4Smrg dlopen_self=$dlopen_self_static 5191aee7dae4Smrg fi 5192aee7dae4Smrg prefer_static_libs=built 5193aee7dae4Smrg ;; 5194aee7dae4Smrg -static-libtool-libs) 5195aee7dae4Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 5196aee7dae4Smrg dlopen_self=$dlopen_self_static 5197aee7dae4Smrg fi 5198aee7dae4Smrg prefer_static_libs=yes 5199ba0eab60Smacallan ;; 5200ba0eab60Smacallan esac 5201aee7dae4Smrg build_libtool_libs=no 5202aee7dae4Smrg build_old_libs=yes 5203aee7dae4Smrg break 5204aee7dae4Smrg ;; 5205aee7dae4Smrg esac 5206aee7dae4Smrg done 5207ba0eab60Smacallan 5208aee7dae4Smrg # See if our shared archives depend on static archives. 5209aee7dae4Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5210ba0eab60Smacallan 5211aee7dae4Smrg # Go through the arguments, transforming them on the way. 5212aee7dae4Smrg while test "$#" -gt 0; do 5213aee7dae4Smrg arg="$1" 5214aee7dae4Smrg shift 5215aee7dae4Smrg func_quote_for_eval "$arg" 5216aee7dae4Smrg qarg=$func_quote_for_eval_unquoted_result 5217aee7dae4Smrg func_append libtool_args " $func_quote_for_eval_result" 5218ba0eab60Smacallan 5219aee7dae4Smrg # If the previous option needs an argument, assign it. 5220aee7dae4Smrg if test -n "$prev"; then 5221aee7dae4Smrg case $prev in 5222aee7dae4Smrg output) 5223aee7dae4Smrg func_append compile_command " @OUTPUT@" 5224aee7dae4Smrg func_append finalize_command " @OUTPUT@" 5225aee7dae4Smrg ;; 5226aee7dae4Smrg esac 5227ba0eab60Smacallan 5228aee7dae4Smrg case $prev in 5229aee7dae4Smrg bindir) 5230aee7dae4Smrg bindir="$arg" 5231aee7dae4Smrg prev= 5232aee7dae4Smrg continue 5233aee7dae4Smrg ;; 5234aee7dae4Smrg dlfiles|dlprefiles) 5235aee7dae4Smrg if test "$preload" = no; then 5236aee7dae4Smrg # Add the symbol object into the linking commands. 5237aee7dae4Smrg func_append compile_command " @SYMFILE@" 5238aee7dae4Smrg func_append finalize_command " @SYMFILE@" 5239aee7dae4Smrg preload=yes 5240aee7dae4Smrg fi 5241aee7dae4Smrg case $arg in 5242aee7dae4Smrg *.la | *.lo) ;; # We handle these cases below. 5243aee7dae4Smrg force) 5244aee7dae4Smrg if test "$dlself" = no; then 5245aee7dae4Smrg dlself=needless 5246aee7dae4Smrg export_dynamic=yes 5247aee7dae4Smrg fi 5248aee7dae4Smrg prev= 5249aee7dae4Smrg continue 5250aee7dae4Smrg ;; 5251aee7dae4Smrg self) 5252aee7dae4Smrg if test "$prev" = dlprefiles; then 5253aee7dae4Smrg dlself=yes 5254aee7dae4Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 5255aee7dae4Smrg dlself=yes 5256aee7dae4Smrg else 5257aee7dae4Smrg dlself=needless 5258aee7dae4Smrg export_dynamic=yes 5259aee7dae4Smrg fi 5260aee7dae4Smrg prev= 5261aee7dae4Smrg continue 5262aee7dae4Smrg ;; 5263aee7dae4Smrg *) 5264aee7dae4Smrg if test "$prev" = dlfiles; then 5265aee7dae4Smrg func_append dlfiles " $arg" 5266aee7dae4Smrg else 5267aee7dae4Smrg func_append dlprefiles " $arg" 5268aee7dae4Smrg fi 5269aee7dae4Smrg prev= 5270aee7dae4Smrg continue 5271aee7dae4Smrg ;; 5272aee7dae4Smrg esac 5273aee7dae4Smrg ;; 5274aee7dae4Smrg expsyms) 5275aee7dae4Smrg export_symbols="$arg" 5276aee7dae4Smrg test -f "$arg" \ 5277aee7dae4Smrg || func_fatal_error "symbol file \`$arg' does not exist" 5278aee7dae4Smrg prev= 5279aee7dae4Smrg continue 5280aee7dae4Smrg ;; 5281aee7dae4Smrg expsyms_regex) 5282aee7dae4Smrg export_symbols_regex="$arg" 5283aee7dae4Smrg prev= 5284aee7dae4Smrg continue 5285aee7dae4Smrg ;; 5286aee7dae4Smrg framework) 5287aee7dae4Smrg case $host in 5288aee7dae4Smrg *-*-darwin*) 5289aee7dae4Smrg case "$deplibs " in 5290aee7dae4Smrg *" $qarg.ltframework "*) ;; 5291aee7dae4Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 5292aee7dae4Smrg ;; 5293aee7dae4Smrg esac 5294aee7dae4Smrg ;; 5295aee7dae4Smrg esac 5296aee7dae4Smrg prev= 5297aee7dae4Smrg continue 5298aee7dae4Smrg ;; 5299aee7dae4Smrg inst_prefix) 5300aee7dae4Smrg inst_prefix_dir="$arg" 5301aee7dae4Smrg prev= 5302aee7dae4Smrg continue 5303aee7dae4Smrg ;; 5304aee7dae4Smrg objectlist) 5305aee7dae4Smrg if test -f "$arg"; then 5306aee7dae4Smrg save_arg=$arg 5307aee7dae4Smrg moreargs= 5308aee7dae4Smrg for fil in `cat "$save_arg"` 5309aee7dae4Smrg do 5310aee7dae4Smrg# func_append moreargs " $fil" 5311aee7dae4Smrg arg=$fil 5312aee7dae4Smrg # A libtool-controlled object. 5313ba0eab60Smacallan 5314aee7dae4Smrg # Check to see that this really is a libtool object. 5315aee7dae4Smrg if func_lalib_unsafe_p "$arg"; then 5316aee7dae4Smrg pic_object= 5317aee7dae4Smrg non_pic_object= 5318ba0eab60Smacallan 5319aee7dae4Smrg # Read the .lo file 5320aee7dae4Smrg func_source "$arg" 5321ba0eab60Smacallan 5322aee7dae4Smrg if test -z "$pic_object" || 5323aee7dae4Smrg test -z "$non_pic_object" || 5324aee7dae4Smrg test "$pic_object" = none && 5325aee7dae4Smrg test "$non_pic_object" = none; then 5326aee7dae4Smrg func_fatal_error "cannot find name of object for \`$arg'" 5327aee7dae4Smrg fi 5328ba0eab60Smacallan 5329aee7dae4Smrg # Extract subdirectory from the argument. 5330aee7dae4Smrg func_dirname "$arg" "/" "" 5331aee7dae4Smrg xdir="$func_dirname_result" 5332ba0eab60Smacallan 5333aee7dae4Smrg if test "$pic_object" != none; then 5334aee7dae4Smrg # Prepend the subdirectory the object is found in. 5335aee7dae4Smrg pic_object="$xdir$pic_object" 5336ba0eab60Smacallan 5337aee7dae4Smrg if test "$prev" = dlfiles; then 5338aee7dae4Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5339aee7dae4Smrg func_append dlfiles " $pic_object" 5340aee7dae4Smrg prev= 5341aee7dae4Smrg continue 5342aee7dae4Smrg else 5343aee7dae4Smrg # If libtool objects are unsupported, then we need to preload. 5344aee7dae4Smrg prev=dlprefiles 5345aee7dae4Smrg fi 5346aee7dae4Smrg fi 5347ba0eab60Smacallan 5348aee7dae4Smrg # CHECK ME: I think I busted this. -Ossama 5349aee7dae4Smrg if test "$prev" = dlprefiles; then 5350aee7dae4Smrg # Preload the old-style object. 5351aee7dae4Smrg func_append dlprefiles " $pic_object" 5352aee7dae4Smrg prev= 5353aee7dae4Smrg fi 5354ba0eab60Smacallan 5355aee7dae4Smrg # A PIC object. 5356aee7dae4Smrg func_append libobjs " $pic_object" 5357aee7dae4Smrg arg="$pic_object" 5358aee7dae4Smrg fi 5359ba0eab60Smacallan 5360aee7dae4Smrg # Non-PIC object. 5361aee7dae4Smrg if test "$non_pic_object" != none; then 5362aee7dae4Smrg # Prepend the subdirectory the object is found in. 5363aee7dae4Smrg non_pic_object="$xdir$non_pic_object" 5364ba0eab60Smacallan 5365aee7dae4Smrg # A standard non-PIC object 5366aee7dae4Smrg func_append non_pic_objects " $non_pic_object" 5367aee7dae4Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5368aee7dae4Smrg arg="$non_pic_object" 5369aee7dae4Smrg fi 5370aee7dae4Smrg else 5371aee7dae4Smrg # If the PIC object exists, use it instead. 5372aee7dae4Smrg # $xdir was prepended to $pic_object above. 5373aee7dae4Smrg non_pic_object="$pic_object" 5374aee7dae4Smrg func_append non_pic_objects " $non_pic_object" 5375aee7dae4Smrg fi 5376aee7dae4Smrg else 5377aee7dae4Smrg # Only an error if not doing a dry-run. 5378aee7dae4Smrg if $opt_dry_run; then 5379aee7dae4Smrg # Extract subdirectory from the argument. 5380aee7dae4Smrg func_dirname "$arg" "/" "" 5381aee7dae4Smrg xdir="$func_dirname_result" 5382aee7dae4Smrg 5383aee7dae4Smrg func_lo2o "$arg" 5384aee7dae4Smrg pic_object=$xdir$objdir/$func_lo2o_result 5385aee7dae4Smrg non_pic_object=$xdir$func_lo2o_result 5386aee7dae4Smrg func_append libobjs " $pic_object" 5387aee7dae4Smrg func_append non_pic_objects " $non_pic_object" 5388aee7dae4Smrg else 5389aee7dae4Smrg func_fatal_error "\`$arg' is not a valid libtool object" 5390aee7dae4Smrg fi 5391aee7dae4Smrg fi 5392aee7dae4Smrg done 5393aee7dae4Smrg else 5394aee7dae4Smrg func_fatal_error "link input file \`$arg' does not exist" 5395aee7dae4Smrg fi 5396aee7dae4Smrg arg=$save_arg 5397aee7dae4Smrg prev= 5398aee7dae4Smrg continue 5399aee7dae4Smrg ;; 5400aee7dae4Smrg precious_regex) 5401aee7dae4Smrg precious_files_regex="$arg" 5402aee7dae4Smrg prev= 5403aee7dae4Smrg continue 5404aee7dae4Smrg ;; 5405aee7dae4Smrg release) 5406aee7dae4Smrg release="-$arg" 5407aee7dae4Smrg prev= 5408aee7dae4Smrg continue 5409aee7dae4Smrg ;; 5410aee7dae4Smrg rpath | xrpath) 5411aee7dae4Smrg # We need an absolute path. 5412aee7dae4Smrg case $arg in 5413aee7dae4Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5414aee7dae4Smrg *) 5415aee7dae4Smrg func_fatal_error "only absolute run-paths are allowed" 5416ba0eab60Smacallan ;; 5417ba0eab60Smacallan esac 5418aee7dae4Smrg if test "$prev" = rpath; then 5419aee7dae4Smrg case "$rpath " in 5420aee7dae4Smrg *" $arg "*) ;; 5421aee7dae4Smrg *) func_append rpath " $arg" ;; 5422aee7dae4Smrg esac 5423aee7dae4Smrg else 5424aee7dae4Smrg case "$xrpath " in 5425aee7dae4Smrg *" $arg "*) ;; 5426aee7dae4Smrg *) func_append xrpath " $arg" ;; 5427aee7dae4Smrg esac 5428aee7dae4Smrg fi 5429aee7dae4Smrg prev= 5430aee7dae4Smrg continue 5431ba0eab60Smacallan ;; 5432aee7dae4Smrg shrext) 5433aee7dae4Smrg shrext_cmds="$arg" 5434aee7dae4Smrg prev= 5435aee7dae4Smrg continue 5436ba0eab60Smacallan ;; 5437aee7dae4Smrg weak) 5438aee7dae4Smrg func_append weak_libs " $arg" 5439aee7dae4Smrg prev= 5440aee7dae4Smrg continue 5441ba0eab60Smacallan ;; 5442aee7dae4Smrg xcclinker) 5443aee7dae4Smrg func_append linker_flags " $qarg" 5444aee7dae4Smrg func_append compiler_flags " $qarg" 5445aee7dae4Smrg prev= 5446aee7dae4Smrg func_append compile_command " $qarg" 5447aee7dae4Smrg func_append finalize_command " $qarg" 5448aee7dae4Smrg continue 5449ba0eab60Smacallan ;; 5450aee7dae4Smrg xcompiler) 5451aee7dae4Smrg func_append compiler_flags " $qarg" 5452aee7dae4Smrg prev= 5453aee7dae4Smrg func_append compile_command " $qarg" 5454aee7dae4Smrg func_append finalize_command " $qarg" 5455aee7dae4Smrg continue 5456ba0eab60Smacallan ;; 5457aee7dae4Smrg xlinker) 5458aee7dae4Smrg func_append linker_flags " $qarg" 5459aee7dae4Smrg func_append compiler_flags " $wl$qarg" 5460aee7dae4Smrg prev= 5461aee7dae4Smrg func_append compile_command " $wl$qarg" 5462aee7dae4Smrg func_append finalize_command " $wl$qarg" 5463aee7dae4Smrg continue 5464ba0eab60Smacallan ;; 5465aee7dae4Smrg *) 5466aee7dae4Smrg eval "$prev=\"\$arg\"" 5467aee7dae4Smrg prev= 5468aee7dae4Smrg continue 5469ba0eab60Smacallan ;; 5470aee7dae4Smrg esac 5471aee7dae4Smrg fi # test -n "$prev" 5472ba0eab60Smacallan 5473aee7dae4Smrg prevarg="$arg" 5474ba0eab60Smacallan 5475aee7dae4Smrg case $arg in 5476aee7dae4Smrg -all-static) 5477aee7dae4Smrg if test -n "$link_static_flag"; then 5478aee7dae4Smrg # See comment for -static flag below, for more details. 5479aee7dae4Smrg func_append compile_command " $link_static_flag" 5480aee7dae4Smrg func_append finalize_command " $link_static_flag" 5481aee7dae4Smrg fi 5482aee7dae4Smrg continue 5483aee7dae4Smrg ;; 5484ba0eab60Smacallan 5485aee7dae4Smrg -allow-undefined) 5486aee7dae4Smrg # FIXME: remove this flag sometime in the future. 5487aee7dae4Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 5488aee7dae4Smrg ;; 5489ba0eab60Smacallan 5490aee7dae4Smrg -avoid-version) 5491aee7dae4Smrg avoid_version=yes 5492aee7dae4Smrg continue 5493aee7dae4Smrg ;; 5494ba0eab60Smacallan 5495aee7dae4Smrg -bindir) 5496aee7dae4Smrg prev=bindir 5497aee7dae4Smrg continue 5498aee7dae4Smrg ;; 5499ba0eab60Smacallan 5500aee7dae4Smrg -dlopen) 5501aee7dae4Smrg prev=dlfiles 5502aee7dae4Smrg continue 5503aee7dae4Smrg ;; 5504ba0eab60Smacallan 5505aee7dae4Smrg -dlpreopen) 5506aee7dae4Smrg prev=dlprefiles 5507aee7dae4Smrg continue 5508aee7dae4Smrg ;; 5509ba0eab60Smacallan 5510aee7dae4Smrg -export-dynamic) 5511aee7dae4Smrg export_dynamic=yes 5512aee7dae4Smrg continue 5513aee7dae4Smrg ;; 5514ba0eab60Smacallan 5515aee7dae4Smrg -export-symbols | -export-symbols-regex) 5516aee7dae4Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 5517aee7dae4Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 5518aee7dae4Smrg fi 5519aee7dae4Smrg if test "X$arg" = "X-export-symbols"; then 5520aee7dae4Smrg prev=expsyms 5521aee7dae4Smrg else 5522aee7dae4Smrg prev=expsyms_regex 5523aee7dae4Smrg fi 5524aee7dae4Smrg continue 5525aee7dae4Smrg ;; 5526ba0eab60Smacallan 5527aee7dae4Smrg -framework) 5528aee7dae4Smrg prev=framework 5529aee7dae4Smrg continue 5530aee7dae4Smrg ;; 5531ba0eab60Smacallan 5532aee7dae4Smrg -inst-prefix-dir) 5533aee7dae4Smrg prev=inst_prefix 5534aee7dae4Smrg continue 5535aee7dae4Smrg ;; 5536ba0eab60Smacallan 5537aee7dae4Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 5538aee7dae4Smrg # so, if we see these flags be careful not to treat them like -L 5539aee7dae4Smrg -L[A-Z][A-Z]*:*) 5540aee7dae4Smrg case $with_gcc/$host in 5541aee7dae4Smrg no/*-*-irix* | /*-*-irix*) 5542aee7dae4Smrg func_append compile_command " $arg" 5543aee7dae4Smrg func_append finalize_command " $arg" 5544ba0eab60Smacallan ;; 5545ba0eab60Smacallan esac 5546aee7dae4Smrg continue 5547aee7dae4Smrg ;; 5548ba0eab60Smacallan 5549aee7dae4Smrg -L*) 5550aee7dae4Smrg func_stripname "-L" '' "$arg" 5551aee7dae4Smrg if test -z "$func_stripname_result"; then 5552aee7dae4Smrg if test "$#" -gt 0; then 5553aee7dae4Smrg func_fatal_error "require no space between \`-L' and \`$1'" 5554ba0eab60Smacallan else 5555aee7dae4Smrg func_fatal_error "need path for \`-L' option" 5556ba0eab60Smacallan fi 5557ba0eab60Smacallan fi 5558aee7dae4Smrg func_resolve_sysroot "$func_stripname_result" 5559aee7dae4Smrg dir=$func_resolve_sysroot_result 5560aee7dae4Smrg # We need an absolute path. 5561aee7dae4Smrg case $dir in 5562aee7dae4Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5563aee7dae4Smrg *) 5564aee7dae4Smrg absdir=`cd "$dir" && pwd` 5565aee7dae4Smrg test -z "$absdir" && \ 5566aee7dae4Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 5567aee7dae4Smrg dir="$absdir" 5568aee7dae4Smrg ;; 5569aee7dae4Smrg esac 5570aee7dae4Smrg case "$deplibs " in 5571aee7dae4Smrg *" -L$dir "* | *" $arg "*) 5572aee7dae4Smrg # Will only happen for absolute or sysroot arguments 5573aee7dae4Smrg ;; 5574aee7dae4Smrg *) 5575aee7dae4Smrg # Preserve sysroot, but never include relative directories 5576aee7dae4Smrg case $dir in 5577aee7dae4Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 5578aee7dae4Smrg *) func_append deplibs " -L$dir" ;; 5579aee7dae4Smrg esac 5580aee7dae4Smrg func_append lib_search_path " $dir" 5581aee7dae4Smrg ;; 5582ba0eab60Smacallan esac 5583aee7dae4Smrg case $host in 5584aee7dae4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5585aee7dae4Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 5586aee7dae4Smrg case :$dllsearchpath: in 5587aee7dae4Smrg *":$dir:"*) ;; 5588aee7dae4Smrg ::) dllsearchpath=$dir;; 5589aee7dae4Smrg *) func_append dllsearchpath ":$dir";; 5590aee7dae4Smrg esac 5591aee7dae4Smrg case :$dllsearchpath: in 5592aee7dae4Smrg *":$testbindir:"*) ;; 5593aee7dae4Smrg ::) dllsearchpath=$testbindir;; 5594aee7dae4Smrg *) func_append dllsearchpath ":$testbindir";; 5595aee7dae4Smrg esac 5596aee7dae4Smrg ;; 5597ba0eab60Smacallan esac 5598aee7dae4Smrg continue 5599aee7dae4Smrg ;; 5600ba0eab60Smacallan 5601aee7dae4Smrg -l*) 5602aee7dae4Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 5603ba0eab60Smacallan case $host in 5604aee7dae4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 5605aee7dae4Smrg # These systems don't actually have a C or math library (as such) 5606aee7dae4Smrg continue 5607ba0eab60Smacallan ;; 5608aee7dae4Smrg *-*-os2*) 5609aee7dae4Smrg # These systems don't actually have a C library (as such) 5610aee7dae4Smrg test "X$arg" = "X-lc" && continue 5611ba0eab60Smacallan ;; 5612ba0eab60Smacallan *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5613ba0eab60Smacallan # Do not include libc due to us having libc/libc_r. 5614aee7dae4Smrg test "X$arg" = "X-lc" && continue 5615aee7dae4Smrg ;; 5616aee7dae4Smrg *-*-rhapsody* | *-*-darwin1.[012]) 5617aee7dae4Smrg # Rhapsody C and math libraries are in the System framework 5618aee7dae4Smrg func_append deplibs " System.ltframework" 5619aee7dae4Smrg continue 5620ba0eab60Smacallan ;; 5621ba0eab60Smacallan *-*-sco3.2v5* | *-*-sco5v6*) 5622ba0eab60Smacallan # Causes problems with __ctype 5623aee7dae4Smrg test "X$arg" = "X-lc" && continue 5624ba0eab60Smacallan ;; 5625ba0eab60Smacallan *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 5626ba0eab60Smacallan # Compiler inserts libc in the correct place for threads to work 5627aee7dae4Smrg test "X$arg" = "X-lc" && continue 5628ba0eab60Smacallan ;; 5629ba0eab60Smacallan esac 5630aee7dae4Smrg elif test "X$arg" = "X-lc_r"; then 5631aee7dae4Smrg case $host in 5632aee7dae4Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5633aee7dae4Smrg # Do not include libc_r directly, use -pthread flag. 5634aee7dae4Smrg continue 5635aee7dae4Smrg ;; 5636aee7dae4Smrg esac 5637ba0eab60Smacallan fi 5638aee7dae4Smrg func_append deplibs " $arg" 5639aee7dae4Smrg continue 5640aee7dae4Smrg ;; 5641ba0eab60Smacallan 5642aee7dae4Smrg -module) 5643aee7dae4Smrg module=yes 5644aee7dae4Smrg continue 5645aee7dae4Smrg ;; 5646aee7dae4Smrg 5647aee7dae4Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 5648aee7dae4Smrg # classes, name mangling, and exception handling. 5649aee7dae4Smrg # Darwin uses the -arch flag to determine output architecture. 5650aee7dae4Smrg -model|-arch|-isysroot|--sysroot) 5651aee7dae4Smrg func_append compiler_flags " $arg" 5652aee7dae4Smrg func_append compile_command " $arg" 5653aee7dae4Smrg func_append finalize_command " $arg" 5654aee7dae4Smrg prev=xcompiler 5655aee7dae4Smrg continue 5656aee7dae4Smrg ;; 5657aee7dae4Smrg 5658aee7dae4Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 5659aee7dae4Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 5660aee7dae4Smrg func_append compiler_flags " $arg" 5661aee7dae4Smrg func_append compile_command " $arg" 5662aee7dae4Smrg func_append finalize_command " $arg" 5663aee7dae4Smrg case "$new_inherited_linker_flags " in 5664aee7dae4Smrg *" $arg "*) ;; 5665aee7dae4Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 5666ba0eab60Smacallan esac 5667aee7dae4Smrg continue 5668aee7dae4Smrg ;; 5669aee7dae4Smrg 5670aee7dae4Smrg -multi_module) 5671aee7dae4Smrg single_module="${wl}-multi_module" 5672aee7dae4Smrg continue 5673aee7dae4Smrg ;; 5674aee7dae4Smrg 5675aee7dae4Smrg -no-fast-install) 5676aee7dae4Smrg fast_install=no 5677aee7dae4Smrg continue 5678aee7dae4Smrg ;; 5679ba0eab60Smacallan 5680aee7dae4Smrg -no-install) 5681ba0eab60Smacallan case $host in 5682aee7dae4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 5683aee7dae4Smrg # The PATH hackery in wrapper scripts is required on Windows 5684aee7dae4Smrg # and Darwin in order for the loader to find any dlls it needs. 5685aee7dae4Smrg func_warning "\`-no-install' is ignored for $host" 5686aee7dae4Smrg func_warning "assuming \`-no-fast-install' instead" 5687aee7dae4Smrg fast_install=no 5688ba0eab60Smacallan ;; 5689aee7dae4Smrg *) no_install=yes ;; 5690ba0eab60Smacallan esac 5691aee7dae4Smrg continue 5692aee7dae4Smrg ;; 5693ba0eab60Smacallan 5694aee7dae4Smrg -no-undefined) 5695aee7dae4Smrg allow_undefined=no 5696aee7dae4Smrg continue 5697aee7dae4Smrg ;; 5698ba0eab60Smacallan 5699aee7dae4Smrg -objectlist) 5700aee7dae4Smrg prev=objectlist 5701aee7dae4Smrg continue 5702aee7dae4Smrg ;; 5703ba0eab60Smacallan 5704aee7dae4Smrg -o) prev=output ;; 5705ba0eab60Smacallan 5706aee7dae4Smrg -precious-files-regex) 5707aee7dae4Smrg prev=precious_regex 5708aee7dae4Smrg continue 5709aee7dae4Smrg ;; 5710aee7dae4Smrg 5711aee7dae4Smrg -release) 5712aee7dae4Smrg prev=release 5713aee7dae4Smrg continue 5714aee7dae4Smrg ;; 5715aee7dae4Smrg 5716aee7dae4Smrg -rpath) 5717aee7dae4Smrg prev=rpath 5718aee7dae4Smrg continue 5719aee7dae4Smrg ;; 5720aee7dae4Smrg 5721aee7dae4Smrg -R) 5722aee7dae4Smrg prev=xrpath 5723aee7dae4Smrg continue 5724aee7dae4Smrg ;; 5725aee7dae4Smrg 5726aee7dae4Smrg -R*) 5727aee7dae4Smrg func_stripname '-R' '' "$arg" 5728aee7dae4Smrg dir=$func_stripname_result 5729aee7dae4Smrg # We need an absolute path. 5730aee7dae4Smrg case $dir in 5731aee7dae4Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 5732aee7dae4Smrg =*) 5733aee7dae4Smrg func_stripname '=' '' "$dir" 5734aee7dae4Smrg dir=$lt_sysroot$func_stripname_result 5735aee7dae4Smrg ;; 5736ba0eab60Smacallan *) 5737aee7dae4Smrg func_fatal_error "only absolute run-paths are allowed" 5738ba0eab60Smacallan ;; 5739ba0eab60Smacallan esac 5740aee7dae4Smrg case "$xrpath " in 5741aee7dae4Smrg *" $dir "*) ;; 5742aee7dae4Smrg *) func_append xrpath " $dir" ;; 5743ba0eab60Smacallan esac 5744aee7dae4Smrg continue 5745aee7dae4Smrg ;; 5746ba0eab60Smacallan 5747aee7dae4Smrg -shared) 5748aee7dae4Smrg # The effects of -shared are defined in a previous loop. 5749aee7dae4Smrg continue 5750aee7dae4Smrg ;; 5751ba0eab60Smacallan 5752aee7dae4Smrg -shrext) 5753aee7dae4Smrg prev=shrext 5754aee7dae4Smrg continue 5755aee7dae4Smrg ;; 5756ba0eab60Smacallan 5757aee7dae4Smrg -static | -static-libtool-libs) 5758aee7dae4Smrg # The effects of -static are defined in a previous loop. 5759aee7dae4Smrg # We used to do the same as -all-static on platforms that 5760aee7dae4Smrg # didn't have a PIC flag, but the assumption that the effects 5761aee7dae4Smrg # would be equivalent was wrong. It would break on at least 5762aee7dae4Smrg # Digital Unix and AIX. 5763aee7dae4Smrg continue 5764aee7dae4Smrg ;; 5765aee7dae4Smrg 5766aee7dae4Smrg -thread-safe) 5767aee7dae4Smrg thread_safe=yes 5768aee7dae4Smrg continue 5769aee7dae4Smrg ;; 5770aee7dae4Smrg 5771aee7dae4Smrg -version-info) 5772aee7dae4Smrg prev=vinfo 5773aee7dae4Smrg continue 5774aee7dae4Smrg ;; 5775aee7dae4Smrg 5776aee7dae4Smrg -version-number) 5777aee7dae4Smrg prev=vinfo 5778aee7dae4Smrg vinfo_number=yes 5779aee7dae4Smrg continue 5780aee7dae4Smrg ;; 5781aee7dae4Smrg 5782aee7dae4Smrg -weak) 5783aee7dae4Smrg prev=weak 5784aee7dae4Smrg continue 5785aee7dae4Smrg ;; 5786aee7dae4Smrg 5787aee7dae4Smrg -Wc,*) 5788aee7dae4Smrg func_stripname '-Wc,' '' "$arg" 5789aee7dae4Smrg args=$func_stripname_result 5790aee7dae4Smrg arg= 5791aee7dae4Smrg save_ifs="$IFS"; IFS=',' 5792aee7dae4Smrg for flag in $args; do 5793aee7dae4Smrg IFS="$save_ifs" 5794aee7dae4Smrg func_quote_for_eval "$flag" 5795aee7dae4Smrg func_append arg " $func_quote_for_eval_result" 5796aee7dae4Smrg func_append compiler_flags " $func_quote_for_eval_result" 5797aee7dae4Smrg done 5798aee7dae4Smrg IFS="$save_ifs" 5799aee7dae4Smrg func_stripname ' ' '' "$arg" 5800aee7dae4Smrg arg=$func_stripname_result 5801aee7dae4Smrg ;; 5802aee7dae4Smrg 5803aee7dae4Smrg -Wl,*) 5804aee7dae4Smrg func_stripname '-Wl,' '' "$arg" 5805aee7dae4Smrg args=$func_stripname_result 5806aee7dae4Smrg arg= 5807aee7dae4Smrg save_ifs="$IFS"; IFS=',' 5808aee7dae4Smrg for flag in $args; do 5809aee7dae4Smrg IFS="$save_ifs" 5810aee7dae4Smrg func_quote_for_eval "$flag" 5811aee7dae4Smrg func_append arg " $wl$func_quote_for_eval_result" 5812aee7dae4Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 5813aee7dae4Smrg func_append linker_flags " $func_quote_for_eval_result" 5814aee7dae4Smrg done 5815aee7dae4Smrg IFS="$save_ifs" 5816aee7dae4Smrg func_stripname ' ' '' "$arg" 5817aee7dae4Smrg arg=$func_stripname_result 5818aee7dae4Smrg ;; 5819aee7dae4Smrg 5820aee7dae4Smrg -Xcompiler) 5821aee7dae4Smrg prev=xcompiler 5822aee7dae4Smrg continue 5823aee7dae4Smrg ;; 5824aee7dae4Smrg 5825aee7dae4Smrg -Xlinker) 5826aee7dae4Smrg prev=xlinker 5827aee7dae4Smrg continue 5828aee7dae4Smrg ;; 5829aee7dae4Smrg 5830aee7dae4Smrg -XCClinker) 5831aee7dae4Smrg prev=xcclinker 5832aee7dae4Smrg continue 5833aee7dae4Smrg ;; 5834aee7dae4Smrg 5835aee7dae4Smrg # -msg_* for osf cc 5836aee7dae4Smrg -msg_*) 5837aee7dae4Smrg func_quote_for_eval "$arg" 5838aee7dae4Smrg arg="$func_quote_for_eval_result" 5839aee7dae4Smrg ;; 5840aee7dae4Smrg 5841aee7dae4Smrg # Flags to be passed through unchanged, with rationale: 5842aee7dae4Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 5843aee7dae4Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 5844aee7dae4Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 5845aee7dae4Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 5846aee7dae4Smrg # -q* compiler args for the IBM compiler 5847aee7dae4Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 5848aee7dae4Smrg # -F/path path to uninstalled frameworks, gcc on darwin 5849aee7dae4Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 5850aee7dae4Smrg # @file GCC response files 5851aee7dae4Smrg # -tp=* Portland pgcc target processor selection 5852aee7dae4Smrg # --sysroot=* for sysroot support 5853aee7dae4Smrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 5854aee7dae4Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 5855aee7dae4Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 5856aee7dae4Smrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 5857aee7dae4Smrg func_quote_for_eval "$arg" 5858aee7dae4Smrg arg="$func_quote_for_eval_result" 5859aee7dae4Smrg func_append compile_command " $arg" 5860aee7dae4Smrg func_append finalize_command " $arg" 5861aee7dae4Smrg func_append compiler_flags " $arg" 5862aee7dae4Smrg continue 5863aee7dae4Smrg ;; 5864aee7dae4Smrg 5865aee7dae4Smrg # Some other compiler flag. 5866aee7dae4Smrg -* | +*) 5867aee7dae4Smrg func_quote_for_eval "$arg" 5868aee7dae4Smrg arg="$func_quote_for_eval_result" 5869aee7dae4Smrg ;; 5870aee7dae4Smrg 5871aee7dae4Smrg *.$objext) 5872aee7dae4Smrg # A standard object. 5873aee7dae4Smrg func_append objs " $arg" 5874aee7dae4Smrg ;; 5875aee7dae4Smrg 5876aee7dae4Smrg *.lo) 5877aee7dae4Smrg # A libtool-controlled object. 5878aee7dae4Smrg 5879aee7dae4Smrg # Check to see that this really is a libtool object. 5880aee7dae4Smrg if func_lalib_unsafe_p "$arg"; then 5881aee7dae4Smrg pic_object= 5882aee7dae4Smrg non_pic_object= 5883aee7dae4Smrg 5884aee7dae4Smrg # Read the .lo file 5885aee7dae4Smrg func_source "$arg" 5886aee7dae4Smrg 5887aee7dae4Smrg if test -z "$pic_object" || 5888aee7dae4Smrg test -z "$non_pic_object" || 5889aee7dae4Smrg test "$pic_object" = none && 5890aee7dae4Smrg test "$non_pic_object" = none; then 5891aee7dae4Smrg func_fatal_error "cannot find name of object for \`$arg'" 5892aee7dae4Smrg fi 5893aee7dae4Smrg 5894aee7dae4Smrg # Extract subdirectory from the argument. 5895aee7dae4Smrg func_dirname "$arg" "/" "" 5896aee7dae4Smrg xdir="$func_dirname_result" 5897aee7dae4Smrg 5898aee7dae4Smrg if test "$pic_object" != none; then 5899aee7dae4Smrg # Prepend the subdirectory the object is found in. 5900aee7dae4Smrg pic_object="$xdir$pic_object" 5901aee7dae4Smrg 5902aee7dae4Smrg if test "$prev" = dlfiles; then 5903aee7dae4Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5904aee7dae4Smrg func_append dlfiles " $pic_object" 5905aee7dae4Smrg prev= 5906aee7dae4Smrg continue 5907ba0eab60Smacallan else 5908aee7dae4Smrg # If libtool objects are unsupported, then we need to preload. 5909aee7dae4Smrg prev=dlprefiles 5910ba0eab60Smacallan fi 5911ba0eab60Smacallan fi 5912aee7dae4Smrg 5913aee7dae4Smrg # CHECK ME: I think I busted this. -Ossama 5914aee7dae4Smrg if test "$prev" = dlprefiles; then 5915aee7dae4Smrg # Preload the old-style object. 5916aee7dae4Smrg func_append dlprefiles " $pic_object" 5917aee7dae4Smrg prev= 5918ba0eab60Smacallan fi 5919aee7dae4Smrg 5920aee7dae4Smrg # A PIC object. 5921aee7dae4Smrg func_append libobjs " $pic_object" 5922aee7dae4Smrg arg="$pic_object" 5923ba0eab60Smacallan fi 5924aee7dae4Smrg 5925aee7dae4Smrg # Non-PIC object. 5926aee7dae4Smrg if test "$non_pic_object" != none; then 5927aee7dae4Smrg # Prepend the subdirectory the object is found in. 5928aee7dae4Smrg non_pic_object="$xdir$non_pic_object" 5929aee7dae4Smrg 5930aee7dae4Smrg # A standard non-PIC object 5931aee7dae4Smrg func_append non_pic_objects " $non_pic_object" 5932aee7dae4Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 5933aee7dae4Smrg arg="$non_pic_object" 5934aee7dae4Smrg fi 5935aee7dae4Smrg else 5936aee7dae4Smrg # If the PIC object exists, use it instead. 5937aee7dae4Smrg # $xdir was prepended to $pic_object above. 5938aee7dae4Smrg non_pic_object="$pic_object" 5939aee7dae4Smrg func_append non_pic_objects " $non_pic_object" 5940aee7dae4Smrg fi 5941aee7dae4Smrg else 5942aee7dae4Smrg # Only an error if not doing a dry-run. 5943aee7dae4Smrg if $opt_dry_run; then 5944aee7dae4Smrg # Extract subdirectory from the argument. 5945aee7dae4Smrg func_dirname "$arg" "/" "" 5946aee7dae4Smrg xdir="$func_dirname_result" 5947aee7dae4Smrg 5948aee7dae4Smrg func_lo2o "$arg" 5949aee7dae4Smrg pic_object=$xdir$objdir/$func_lo2o_result 5950aee7dae4Smrg non_pic_object=$xdir$func_lo2o_result 5951aee7dae4Smrg func_append libobjs " $pic_object" 5952aee7dae4Smrg func_append non_pic_objects " $non_pic_object" 5953aee7dae4Smrg else 5954aee7dae4Smrg func_fatal_error "\`$arg' is not a valid libtool object" 5955ba0eab60Smacallan fi 5956ba0eab60Smacallan fi 5957aee7dae4Smrg ;; 5958ba0eab60Smacallan 5959aee7dae4Smrg *.$libext) 5960aee7dae4Smrg # An archive. 5961aee7dae4Smrg func_append deplibs " $arg" 5962aee7dae4Smrg func_append old_deplibs " $arg" 5963aee7dae4Smrg continue 5964aee7dae4Smrg ;; 5965ba0eab60Smacallan 5966aee7dae4Smrg *.la) 5967aee7dae4Smrg # A libtool-controlled library. 5968ba0eab60Smacallan 5969aee7dae4Smrg func_resolve_sysroot "$arg" 5970aee7dae4Smrg if test "$prev" = dlfiles; then 5971aee7dae4Smrg # This library was specified with -dlopen. 5972aee7dae4Smrg func_append dlfiles " $func_resolve_sysroot_result" 5973aee7dae4Smrg prev= 5974aee7dae4Smrg elif test "$prev" = dlprefiles; then 5975aee7dae4Smrg # The library was specified with -dlpreopen. 5976aee7dae4Smrg func_append dlprefiles " $func_resolve_sysroot_result" 5977aee7dae4Smrg prev= 5978ba0eab60Smacallan else 5979aee7dae4Smrg func_append deplibs " $func_resolve_sysroot_result" 5980ba0eab60Smacallan fi 5981aee7dae4Smrg continue 5982aee7dae4Smrg ;; 5983ba0eab60Smacallan 5984aee7dae4Smrg # Some other compiler argument. 5985aee7dae4Smrg *) 5986aee7dae4Smrg # Unknown arguments in both finalize_command and compile_command need 5987aee7dae4Smrg # to be aesthetically quoted because they are evaled later. 5988aee7dae4Smrg func_quote_for_eval "$arg" 5989aee7dae4Smrg arg="$func_quote_for_eval_result" 5990aee7dae4Smrg ;; 5991aee7dae4Smrg esac # arg 5992ba0eab60Smacallan 5993aee7dae4Smrg # Now actually substitute the argument into the commands. 5994aee7dae4Smrg if test -n "$arg"; then 5995aee7dae4Smrg func_append compile_command " $arg" 5996aee7dae4Smrg func_append finalize_command " $arg" 5997aee7dae4Smrg fi 5998aee7dae4Smrg done # argument parsing loop 5999ba0eab60Smacallan 6000aee7dae4Smrg test -n "$prev" && \ 6001aee7dae4Smrg func_fatal_help "the \`$prevarg' option requires an argument" 6002ba0eab60Smacallan 6003aee7dae4Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 6004aee7dae4Smrg eval arg=\"$export_dynamic_flag_spec\" 6005aee7dae4Smrg func_append compile_command " $arg" 6006aee7dae4Smrg func_append finalize_command " $arg" 6007aee7dae4Smrg fi 6008ba0eab60Smacallan 6009aee7dae4Smrg oldlibs= 6010aee7dae4Smrg # calculate the name of the file, without its directory 6011aee7dae4Smrg func_basename "$output" 6012aee7dae4Smrg outputname="$func_basename_result" 6013aee7dae4Smrg libobjs_save="$libobjs" 6014aee7dae4Smrg 6015aee7dae4Smrg if test -n "$shlibpath_var"; then 6016aee7dae4Smrg # get the directories listed in $shlibpath_var 6017aee7dae4Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 6018aee7dae4Smrg else 6019aee7dae4Smrg shlib_search_path= 6020aee7dae4Smrg fi 6021aee7dae4Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 6022aee7dae4Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 6023aee7dae4Smrg 6024aee7dae4Smrg func_dirname "$output" "/" "" 6025aee7dae4Smrg output_objdir="$func_dirname_result$objdir" 6026aee7dae4Smrg func_to_tool_file "$output_objdir/" 6027aee7dae4Smrg tool_output_objdir=$func_to_tool_file_result 6028aee7dae4Smrg # Create the object directory. 6029aee7dae4Smrg func_mkdir_p "$output_objdir" 6030aee7dae4Smrg 6031aee7dae4Smrg # Determine the type of output 6032aee7dae4Smrg case $output in 6033aee7dae4Smrg "") 6034aee7dae4Smrg func_fatal_help "you must specify an output file" 6035aee7dae4Smrg ;; 6036aee7dae4Smrg *.$libext) linkmode=oldlib ;; 6037aee7dae4Smrg *.lo | *.$objext) linkmode=obj ;; 6038aee7dae4Smrg *.la) linkmode=lib ;; 6039aee7dae4Smrg *) linkmode=prog ;; # Anything else should be a program. 6040aee7dae4Smrg esac 6041aee7dae4Smrg 6042aee7dae4Smrg specialdeplibs= 6043aee7dae4Smrg 6044aee7dae4Smrg libs= 6045aee7dae4Smrg # Find all interdependent deplibs by searching for libraries 6046aee7dae4Smrg # that are linked more than once (e.g. -la -lb -la) 6047aee7dae4Smrg for deplib in $deplibs; do 6048aee7dae4Smrg if $opt_preserve_dup_deps ; then 6049aee7dae4Smrg case "$libs " in 6050aee7dae4Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6051aee7dae4Smrg esac 6052aee7dae4Smrg fi 6053aee7dae4Smrg func_append libs " $deplib" 6054aee7dae4Smrg done 6055aee7dae4Smrg 6056aee7dae4Smrg if test "$linkmode" = lib; then 6057aee7dae4Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 6058aee7dae4Smrg 6059aee7dae4Smrg # Compute libraries that are listed more than once in $predeps 6060aee7dae4Smrg # $postdeps and mark them as special (i.e., whose duplicates are 6061aee7dae4Smrg # not to be eliminated). 6062aee7dae4Smrg pre_post_deps= 6063aee7dae4Smrg if $opt_duplicate_compiler_generated_deps; then 6064aee7dae4Smrg for pre_post_dep in $predeps $postdeps; do 6065aee7dae4Smrg case "$pre_post_deps " in 6066aee7dae4Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 6067aee7dae4Smrg esac 6068aee7dae4Smrg func_append pre_post_deps " $pre_post_dep" 6069ba0eab60Smacallan done 6070aee7dae4Smrg fi 6071aee7dae4Smrg pre_post_deps= 6072aee7dae4Smrg fi 6073ba0eab60Smacallan 6074aee7dae4Smrg deplibs= 6075aee7dae4Smrg newdependency_libs= 6076aee7dae4Smrg newlib_search_path= 6077aee7dae4Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 6078aee7dae4Smrg notinst_deplibs= # not-installed libtool libraries 6079aee7dae4Smrg notinst_path= # paths that contain not-installed libtool libraries 6080ba0eab60Smacallan 6081aee7dae4Smrg case $linkmode in 6082aee7dae4Smrg lib) 6083aee7dae4Smrg passes="conv dlpreopen link" 6084aee7dae4Smrg for file in $dlfiles $dlprefiles; do 6085aee7dae4Smrg case $file in 6086aee7dae4Smrg *.la) ;; 6087aee7dae4Smrg *) 6088aee7dae4Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 6089aee7dae4Smrg ;; 6090aee7dae4Smrg esac 6091aee7dae4Smrg done 6092aee7dae4Smrg ;; 6093aee7dae4Smrg prog) 6094aee7dae4Smrg compile_deplibs= 6095aee7dae4Smrg finalize_deplibs= 6096aee7dae4Smrg alldeplibs=no 6097aee7dae4Smrg newdlfiles= 6098aee7dae4Smrg newdlprefiles= 6099aee7dae4Smrg passes="conv scan dlopen dlpreopen link" 6100aee7dae4Smrg ;; 6101aee7dae4Smrg *) passes="conv" 6102aee7dae4Smrg ;; 6103aee7dae4Smrg esac 6104ba0eab60Smacallan 6105aee7dae4Smrg for pass in $passes; do 6106aee7dae4Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 6107aee7dae4Smrg # so that -L comes before libs that need it for instance... 6108aee7dae4Smrg if test "$linkmode,$pass" = "lib,link"; then 6109aee7dae4Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 6110aee7dae4Smrg ## order, and fix it there properly 6111aee7dae4Smrg tmp_deplibs= 6112aee7dae4Smrg for deplib in $deplibs; do 6113aee7dae4Smrg tmp_deplibs="$deplib $tmp_deplibs" 6114aee7dae4Smrg done 6115aee7dae4Smrg deplibs="$tmp_deplibs" 6116aee7dae4Smrg fi 6117ba0eab60Smacallan 6118aee7dae4Smrg if test "$linkmode,$pass" = "lib,link" || 6119aee7dae4Smrg test "$linkmode,$pass" = "prog,scan"; then 6120aee7dae4Smrg libs="$deplibs" 6121aee7dae4Smrg deplibs= 6122aee7dae4Smrg fi 6123aee7dae4Smrg if test "$linkmode" = prog; then 6124aee7dae4Smrg case $pass in 6125aee7dae4Smrg dlopen) libs="$dlfiles" ;; 6126aee7dae4Smrg dlpreopen) libs="$dlprefiles" ;; 6127aee7dae4Smrg link) 6128aee7dae4Smrg libs="$deplibs %DEPLIBS%" 6129aee7dae4Smrg test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" 6130aee7dae4Smrg ;; 6131aee7dae4Smrg esac 6132aee7dae4Smrg fi 6133aee7dae4Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 6134aee7dae4Smrg # Collect and forward deplibs of preopened libtool libs 6135aee7dae4Smrg for lib in $dlprefiles; do 6136aee7dae4Smrg # Ignore non-libtool-libs 6137aee7dae4Smrg dependency_libs= 6138aee7dae4Smrg func_resolve_sysroot "$lib" 6139aee7dae4Smrg case $lib in 6140aee7dae4Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 6141aee7dae4Smrg esac 6142aee7dae4Smrg 6143aee7dae4Smrg # Collect preopened libtool deplibs, except any this library 6144aee7dae4Smrg # has declared as weak libs 6145aee7dae4Smrg for deplib in $dependency_libs; do 6146aee7dae4Smrg func_basename "$deplib" 6147aee7dae4Smrg deplib_base=$func_basename_result 6148aee7dae4Smrg case " $weak_libs " in 6149aee7dae4Smrg *" $deplib_base "*) ;; 6150aee7dae4Smrg *) func_append deplibs " $deplib" ;; 6151aee7dae4Smrg esac 6152aee7dae4Smrg done 6153aee7dae4Smrg done 6154aee7dae4Smrg libs="$dlprefiles" 6155aee7dae4Smrg fi 6156aee7dae4Smrg if test "$pass" = dlopen; then 6157aee7dae4Smrg # Collect dlpreopened libraries 6158aee7dae4Smrg save_deplibs="$deplibs" 6159aee7dae4Smrg deplibs= 6160aee7dae4Smrg fi 6161aee7dae4Smrg 6162aee7dae4Smrg for deplib in $libs; do 6163aee7dae4Smrg lib= 6164aee7dae4Smrg found=no 6165aee7dae4Smrg case $deplib in 6166aee7dae4Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 6167aee7dae4Smrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 6168aee7dae4Smrg if test "$linkmode,$pass" = "prog,link"; then 6169aee7dae4Smrg compile_deplibs="$deplib $compile_deplibs" 6170aee7dae4Smrg finalize_deplibs="$deplib $finalize_deplibs" 6171ba0eab60Smacallan else 6172aee7dae4Smrg func_append compiler_flags " $deplib" 6173aee7dae4Smrg if test "$linkmode" = lib ; then 6174aee7dae4Smrg case "$new_inherited_linker_flags " in 6175aee7dae4Smrg *" $deplib "*) ;; 6176aee7dae4Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6177aee7dae4Smrg esac 6178aee7dae4Smrg fi 6179ba0eab60Smacallan fi 6180aee7dae4Smrg continue 6181aee7dae4Smrg ;; 6182aee7dae4Smrg -l*) 6183aee7dae4Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 6184aee7dae4Smrg func_warning "\`-l' is ignored for archives/objects" 6185aee7dae4Smrg continue 6186ba0eab60Smacallan fi 6187aee7dae4Smrg func_stripname '-l' '' "$deplib" 6188aee7dae4Smrg name=$func_stripname_result 6189aee7dae4Smrg if test "$linkmode" = lib; then 6190aee7dae4Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 6191aee7dae4Smrg else 6192aee7dae4Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 6193ba0eab60Smacallan fi 6194aee7dae4Smrg for searchdir in $searchdirs; do 6195aee7dae4Smrg for search_ext in .la $std_shrext .so .a; do 6196aee7dae4Smrg # Search the libtool library 6197aee7dae4Smrg lib="$searchdir/lib${name}${search_ext}" 6198aee7dae4Smrg if test -f "$lib"; then 6199aee7dae4Smrg if test "$search_ext" = ".la"; then 6200aee7dae4Smrg found=yes 6201aee7dae4Smrg else 6202aee7dae4Smrg found=no 6203aee7dae4Smrg fi 6204aee7dae4Smrg break 2 6205ba0eab60Smacallan fi 6206aee7dae4Smrg done 6207ba0eab60Smacallan done 6208aee7dae4Smrg if test "$found" != yes; then 6209aee7dae4Smrg # deplib doesn't seem to be a libtool library 6210aee7dae4Smrg if test "$linkmode,$pass" = "prog,link"; then 6211aee7dae4Smrg compile_deplibs="$deplib $compile_deplibs" 6212aee7dae4Smrg finalize_deplibs="$deplib $finalize_deplibs" 6213ba0eab60Smacallan else 6214aee7dae4Smrg deplibs="$deplib $deplibs" 6215aee7dae4Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6216ba0eab60Smacallan fi 6217aee7dae4Smrg continue 6218aee7dae4Smrg else # deplib is a libtool library 6219aee7dae4Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 6220aee7dae4Smrg # We need to do some special things here, and not later. 6221aee7dae4Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6222aee7dae4Smrg case " $predeps $postdeps " in 6223aee7dae4Smrg *" $deplib "*) 6224aee7dae4Smrg if func_lalib_p "$lib"; then 6225aee7dae4Smrg library_names= 6226aee7dae4Smrg old_library= 6227aee7dae4Smrg func_source "$lib" 6228aee7dae4Smrg for l in $old_library $library_names; do 6229aee7dae4Smrg ll="$l" 6230aee7dae4Smrg done 6231aee7dae4Smrg if test "X$ll" = "X$old_library" ; then # only static version available 6232aee7dae4Smrg found=no 6233aee7dae4Smrg func_dirname "$lib" "" "." 6234aee7dae4Smrg ladir="$func_dirname_result" 6235aee7dae4Smrg lib=$ladir/$old_library 6236aee7dae4Smrg if test "$linkmode,$pass" = "prog,link"; then 6237aee7dae4Smrg compile_deplibs="$deplib $compile_deplibs" 6238aee7dae4Smrg finalize_deplibs="$deplib $finalize_deplibs" 6239aee7dae4Smrg else 6240aee7dae4Smrg deplibs="$deplib $deplibs" 6241aee7dae4Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6242aee7dae4Smrg fi 6243aee7dae4Smrg continue 6244aee7dae4Smrg fi 6245aee7dae4Smrg fi 6246aee7dae4Smrg ;; 6247aee7dae4Smrg *) ;; 6248aee7dae4Smrg esac 6249aee7dae4Smrg fi 6250aee7dae4Smrg fi 6251aee7dae4Smrg ;; # -l 6252aee7dae4Smrg *.ltframework) 6253aee7dae4Smrg if test "$linkmode,$pass" = "prog,link"; then 6254aee7dae4Smrg compile_deplibs="$deplib $compile_deplibs" 6255aee7dae4Smrg finalize_deplibs="$deplib $finalize_deplibs" 6256ba0eab60Smacallan else 6257aee7dae4Smrg deplibs="$deplib $deplibs" 6258aee7dae4Smrg if test "$linkmode" = lib ; then 6259aee7dae4Smrg case "$new_inherited_linker_flags " in 6260aee7dae4Smrg *" $deplib "*) ;; 6261aee7dae4Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 6262aee7dae4Smrg esac 6263ba0eab60Smacallan fi 6264ba0eab60Smacallan fi 6265aee7dae4Smrg continue 6266aee7dae4Smrg ;; 6267aee7dae4Smrg -L*) 6268aee7dae4Smrg case $linkmode in 6269aee7dae4Smrg lib) 6270aee7dae4Smrg deplibs="$deplib $deplibs" 6271aee7dae4Smrg test "$pass" = conv && continue 6272aee7dae4Smrg newdependency_libs="$deplib $newdependency_libs" 6273aee7dae4Smrg func_stripname '-L' '' "$deplib" 6274aee7dae4Smrg func_resolve_sysroot "$func_stripname_result" 6275aee7dae4Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 6276aee7dae4Smrg ;; 6277aee7dae4Smrg prog) 6278aee7dae4Smrg if test "$pass" = conv; then 6279aee7dae4Smrg deplibs="$deplib $deplibs" 6280aee7dae4Smrg continue 6281ba0eab60Smacallan fi 6282aee7dae4Smrg if test "$pass" = scan; then 6283aee7dae4Smrg deplibs="$deplib $deplibs" 6284aee7dae4Smrg else 6285aee7dae4Smrg compile_deplibs="$deplib $compile_deplibs" 6286aee7dae4Smrg finalize_deplibs="$deplib $finalize_deplibs" 6287ba0eab60Smacallan fi 6288aee7dae4Smrg func_stripname '-L' '' "$deplib" 6289aee7dae4Smrg func_resolve_sysroot "$func_stripname_result" 6290aee7dae4Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 6291aee7dae4Smrg ;; 6292aee7dae4Smrg *) 6293aee7dae4Smrg func_warning "\`-L' is ignored for archives/objects" 6294aee7dae4Smrg ;; 6295aee7dae4Smrg esac # linkmode 6296aee7dae4Smrg continue 6297aee7dae4Smrg ;; # -L 6298aee7dae4Smrg -R*) 6299aee7dae4Smrg if test "$pass" = link; then 6300aee7dae4Smrg func_stripname '-R' '' "$deplib" 6301aee7dae4Smrg func_resolve_sysroot "$func_stripname_result" 6302aee7dae4Smrg dir=$func_resolve_sysroot_result 6303aee7dae4Smrg # Make sure the xrpath contains only unique directories. 6304aee7dae4Smrg case "$xrpath " in 6305aee7dae4Smrg *" $dir "*) ;; 6306aee7dae4Smrg *) func_append xrpath " $dir" ;; 6307aee7dae4Smrg esac 6308ba0eab60Smacallan fi 6309aee7dae4Smrg deplibs="$deplib $deplibs" 6310aee7dae4Smrg continue 6311aee7dae4Smrg ;; 6312aee7dae4Smrg *.la) 6313aee7dae4Smrg func_resolve_sysroot "$deplib" 6314aee7dae4Smrg lib=$func_resolve_sysroot_result 6315aee7dae4Smrg ;; 6316aee7dae4Smrg *.$libext) 6317aee7dae4Smrg if test "$pass" = conv; then 6318aee7dae4Smrg deplibs="$deplib $deplibs" 6319aee7dae4Smrg continue 6320ba0eab60Smacallan fi 6321aee7dae4Smrg case $linkmode in 6322aee7dae4Smrg lib) 6323aee7dae4Smrg # Linking convenience modules into shared libraries is allowed, 6324aee7dae4Smrg # but linking other static libraries is non-portable. 6325aee7dae4Smrg case " $dlpreconveniencelibs " in 6326aee7dae4Smrg *" $deplib "*) ;; 6327aee7dae4Smrg *) 6328aee7dae4Smrg valid_a_lib=no 6329aee7dae4Smrg case $deplibs_check_method in 6330aee7dae4Smrg match_pattern*) 6331aee7dae4Smrg set dummy $deplibs_check_method; shift 6332aee7dae4Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 6333aee7dae4Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 6334aee7dae4Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 6335aee7dae4Smrg valid_a_lib=yes 6336aee7dae4Smrg fi 6337aee7dae4Smrg ;; 6338aee7dae4Smrg pass_all) 6339aee7dae4Smrg valid_a_lib=yes 6340aee7dae4Smrg ;; 6341aee7dae4Smrg esac 6342aee7dae4Smrg if test "$valid_a_lib" != yes; then 6343aee7dae4Smrg echo 6344aee7dae4Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 6345aee7dae4Smrg echo "*** I have the capability to make that library automatically link in when" 6346aee7dae4Smrg echo "*** you link to this library. But I can only do this if you have a" 6347aee7dae4Smrg echo "*** shared version of the library, which you do not appear to have" 6348aee7dae4Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 6349aee7dae4Smrg echo "*** that it is just a static archive that I should not use here." 6350aee7dae4Smrg else 6351aee7dae4Smrg echo 6352aee7dae4Smrg $ECHO "*** Warning: Linking the shared library $output against the" 6353aee7dae4Smrg $ECHO "*** static library $deplib is not portable!" 6354aee7dae4Smrg deplibs="$deplib $deplibs" 6355aee7dae4Smrg fi 6356aee7dae4Smrg ;; 6357aee7dae4Smrg esac 6358aee7dae4Smrg continue 6359aee7dae4Smrg ;; 6360aee7dae4Smrg prog) 6361aee7dae4Smrg if test "$pass" != link; then 6362aee7dae4Smrg deplibs="$deplib $deplibs" 6363aee7dae4Smrg else 6364aee7dae4Smrg compile_deplibs="$deplib $compile_deplibs" 6365aee7dae4Smrg finalize_deplibs="$deplib $finalize_deplibs" 6366aee7dae4Smrg fi 6367aee7dae4Smrg continue 6368aee7dae4Smrg ;; 6369aee7dae4Smrg esac # linkmode 6370aee7dae4Smrg ;; # *.$libext 6371aee7dae4Smrg *.lo | *.$objext) 6372aee7dae4Smrg if test "$pass" = conv; then 6373aee7dae4Smrg deplibs="$deplib $deplibs" 6374aee7dae4Smrg elif test "$linkmode" = prog; then 6375aee7dae4Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 6376aee7dae4Smrg # If there is no dlopen support or we're linking statically, 6377aee7dae4Smrg # we need to preload. 6378aee7dae4Smrg func_append newdlprefiles " $deplib" 6379aee7dae4Smrg compile_deplibs="$deplib $compile_deplibs" 6380aee7dae4Smrg finalize_deplibs="$deplib $finalize_deplibs" 6381aee7dae4Smrg else 6382aee7dae4Smrg func_append newdlfiles " $deplib" 6383aee7dae4Smrg fi 6384aee7dae4Smrg fi 6385aee7dae4Smrg continue 6386aee7dae4Smrg ;; 6387aee7dae4Smrg %DEPLIBS%) 6388aee7dae4Smrg alldeplibs=yes 6389aee7dae4Smrg continue 6390aee7dae4Smrg ;; 6391aee7dae4Smrg esac # case $deplib 6392ba0eab60Smacallan 6393aee7dae4Smrg if test "$found" = yes || test -f "$lib"; then : 6394aee7dae4Smrg else 6395aee7dae4Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 6396ba0eab60Smacallan fi 6397ba0eab60Smacallan 6398aee7dae4Smrg # Check to see that this really is a libtool archive. 6399aee7dae4Smrg func_lalib_unsafe_p "$lib" \ 6400aee7dae4Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 6401ba0eab60Smacallan 6402aee7dae4Smrg func_dirname "$lib" "" "." 6403aee7dae4Smrg ladir="$func_dirname_result" 6404ba0eab60Smacallan 6405aee7dae4Smrg dlname= 6406aee7dae4Smrg dlopen= 6407aee7dae4Smrg dlpreopen= 6408aee7dae4Smrg libdir= 6409aee7dae4Smrg library_names= 6410aee7dae4Smrg old_library= 6411aee7dae4Smrg inherited_linker_flags= 6412aee7dae4Smrg # If the library was installed with an old release of libtool, 6413aee7dae4Smrg # it will not redefine variables installed, or shouldnotlink 6414aee7dae4Smrg installed=yes 6415aee7dae4Smrg shouldnotlink=no 6416aee7dae4Smrg avoidtemprpath= 6417ba0eab60Smacallan 6418ba0eab60Smacallan 6419aee7dae4Smrg # Read the .la file 6420aee7dae4Smrg func_source "$lib" 6421aee7dae4Smrg 6422aee7dae4Smrg # Convert "-framework foo" to "foo.ltframework" 6423aee7dae4Smrg if test -n "$inherited_linker_flags"; then 6424aee7dae4Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 6425aee7dae4Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 6426aee7dae4Smrg case " $new_inherited_linker_flags " in 6427aee7dae4Smrg *" $tmp_inherited_linker_flag "*) ;; 6428aee7dae4Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 6429aee7dae4Smrg esac 6430aee7dae4Smrg done 6431aee7dae4Smrg fi 6432aee7dae4Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 6433aee7dae4Smrg if test "$linkmode,$pass" = "lib,link" || 6434aee7dae4Smrg test "$linkmode,$pass" = "prog,scan" || 6435aee7dae4Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 6436aee7dae4Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 6437aee7dae4Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 6438ba0eab60Smacallan fi 6439ba0eab60Smacallan 6440aee7dae4Smrg if test "$pass" = conv; then 6441aee7dae4Smrg # Only check for convenience libraries 6442aee7dae4Smrg deplibs="$lib $deplibs" 6443aee7dae4Smrg if test -z "$libdir"; then 6444aee7dae4Smrg if test -z "$old_library"; then 6445aee7dae4Smrg func_fatal_error "cannot find name of link library for \`$lib'" 6446aee7dae4Smrg fi 6447aee7dae4Smrg # It is a libtool convenience library, so add in its objects. 6448aee7dae4Smrg func_append convenience " $ladir/$objdir/$old_library" 6449aee7dae4Smrg func_append old_convenience " $ladir/$objdir/$old_library" 6450aee7dae4Smrg tmp_libs= 6451aee7dae4Smrg for deplib in $dependency_libs; do 6452aee7dae4Smrg deplibs="$deplib $deplibs" 6453aee7dae4Smrg if $opt_preserve_dup_deps ; then 6454aee7dae4Smrg case "$tmp_libs " in 6455aee7dae4Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6456aee7dae4Smrg esac 6457aee7dae4Smrg fi 6458aee7dae4Smrg func_append tmp_libs " $deplib" 6459aee7dae4Smrg done 6460aee7dae4Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 6461aee7dae4Smrg func_fatal_error "\`$lib' is not a convenience library" 6462aee7dae4Smrg fi 6463aee7dae4Smrg continue 6464aee7dae4Smrg fi # $pass = conv 6465ba0eab60Smacallan 6466ba0eab60Smacallan 6467aee7dae4Smrg # Get the name of the library we link against. 6468aee7dae4Smrg linklib= 6469aee7dae4Smrg if test -n "$old_library" && 6470aee7dae4Smrg { test "$prefer_static_libs" = yes || 6471aee7dae4Smrg test "$prefer_static_libs,$installed" = "built,no"; }; then 6472aee7dae4Smrg linklib=$old_library 6473aee7dae4Smrg else 6474aee7dae4Smrg for l in $old_library $library_names; do 6475aee7dae4Smrg linklib="$l" 6476aee7dae4Smrg done 6477aee7dae4Smrg fi 6478aee7dae4Smrg if test -z "$linklib"; then 6479aee7dae4Smrg func_fatal_error "cannot find name of link library for \`$lib'" 6480aee7dae4Smrg fi 6481ba0eab60Smacallan 6482aee7dae4Smrg # This library was specified with -dlopen. 6483aee7dae4Smrg if test "$pass" = dlopen; then 6484aee7dae4Smrg if test -z "$libdir"; then 6485aee7dae4Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 6486aee7dae4Smrg fi 6487aee7dae4Smrg if test -z "$dlname" || 6488aee7dae4Smrg test "$dlopen_support" != yes || 6489aee7dae4Smrg test "$build_libtool_libs" = no; then 6490aee7dae4Smrg # If there is no dlname, no dlopen support or we're linking 6491aee7dae4Smrg # statically, we need to preload. We also need to preload any 6492aee7dae4Smrg # dependent libraries so libltdl's deplib preloader doesn't 6493aee7dae4Smrg # bomb out in the load deplibs phase. 6494aee7dae4Smrg func_append dlprefiles " $lib $dependency_libs" 6495aee7dae4Smrg else 6496aee7dae4Smrg func_append newdlfiles " $lib" 6497aee7dae4Smrg fi 6498aee7dae4Smrg continue 6499aee7dae4Smrg fi # $pass = dlopen 6500aee7dae4Smrg 6501aee7dae4Smrg # We need an absolute path. 6502aee7dae4Smrg case $ladir in 6503aee7dae4Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 6504ba0eab60Smacallan *) 6505aee7dae4Smrg abs_ladir=`cd "$ladir" && pwd` 6506aee7dae4Smrg if test -z "$abs_ladir"; then 6507aee7dae4Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 6508aee7dae4Smrg func_warning "passing it literally to the linker, although it might fail" 6509aee7dae4Smrg abs_ladir="$ladir" 6510aee7dae4Smrg fi 6511ba0eab60Smacallan ;; 6512ba0eab60Smacallan esac 6513aee7dae4Smrg func_basename "$lib" 6514aee7dae4Smrg laname="$func_basename_result" 6515ba0eab60Smacallan 6516aee7dae4Smrg # Find the relevant object directory and library name. 6517aee7dae4Smrg if test "X$installed" = Xyes; then 6518aee7dae4Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6519aee7dae4Smrg func_warning "library \`$lib' was moved." 6520aee7dae4Smrg dir="$ladir" 6521aee7dae4Smrg absdir="$abs_ladir" 6522aee7dae4Smrg libdir="$abs_ladir" 6523aee7dae4Smrg else 6524aee7dae4Smrg dir="$lt_sysroot$libdir" 6525aee7dae4Smrg absdir="$lt_sysroot$libdir" 6526aee7dae4Smrg fi 6527aee7dae4Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 6528aee7dae4Smrg else 6529aee7dae4Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6530aee7dae4Smrg dir="$ladir" 6531aee7dae4Smrg absdir="$abs_ladir" 6532aee7dae4Smrg # Remove this search path later 6533aee7dae4Smrg func_append notinst_path " $abs_ladir" 6534aee7dae4Smrg else 6535aee7dae4Smrg dir="$ladir/$objdir" 6536aee7dae4Smrg absdir="$abs_ladir/$objdir" 6537aee7dae4Smrg # Remove this search path later 6538aee7dae4Smrg func_append notinst_path " $abs_ladir" 6539aee7dae4Smrg fi 6540aee7dae4Smrg fi # $installed = yes 6541aee7dae4Smrg func_stripname 'lib' '.la' "$laname" 6542aee7dae4Smrg name=$func_stripname_result 6543ba0eab60Smacallan 6544aee7dae4Smrg # This library was specified with -dlpreopen. 6545aee7dae4Smrg if test "$pass" = dlpreopen; then 6546aee7dae4Smrg if test -z "$libdir" && test "$linkmode" = prog; then 6547aee7dae4Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 6548aee7dae4Smrg fi 6549aee7dae4Smrg case "$host" in 6550aee7dae4Smrg # special handling for platforms with PE-DLLs. 6551aee7dae4Smrg *cygwin* | *mingw* | *cegcc* ) 6552aee7dae4Smrg # Linker will automatically link against shared library if both 6553aee7dae4Smrg # static and shared are present. Therefore, ensure we extract 6554aee7dae4Smrg # symbols from the import library if a shared library is present 6555aee7dae4Smrg # (otherwise, the dlopen module name will be incorrect). We do 6556aee7dae4Smrg # this by putting the import library name into $newdlprefiles. 6557aee7dae4Smrg # We recover the dlopen module name by 'saving' the la file 6558aee7dae4Smrg # name in a special purpose variable, and (later) extracting the 6559aee7dae4Smrg # dlname from the la file. 6560aee7dae4Smrg if test -n "$dlname"; then 6561aee7dae4Smrg func_tr_sh "$dir/$linklib" 6562aee7dae4Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 6563aee7dae4Smrg func_append newdlprefiles " $dir/$linklib" 6564aee7dae4Smrg else 6565aee7dae4Smrg func_append newdlprefiles " $dir/$old_library" 6566aee7dae4Smrg # Keep a list of preopened convenience libraries to check 6567aee7dae4Smrg # that they are being used correctly in the link pass. 6568aee7dae4Smrg test -z "$libdir" && \ 6569aee7dae4Smrg func_append dlpreconveniencelibs " $dir/$old_library" 6570aee7dae4Smrg fi 6571aee7dae4Smrg ;; 6572aee7dae4Smrg * ) 6573aee7dae4Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 6574aee7dae4Smrg # are required to link). 6575aee7dae4Smrg if test -n "$old_library"; then 6576aee7dae4Smrg func_append newdlprefiles " $dir/$old_library" 6577aee7dae4Smrg # Keep a list of preopened convenience libraries to check 6578aee7dae4Smrg # that they are being used correctly in the link pass. 6579aee7dae4Smrg test -z "$libdir" && \ 6580aee7dae4Smrg func_append dlpreconveniencelibs " $dir/$old_library" 6581aee7dae4Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 6582aee7dae4Smrg elif test -n "$dlname"; then 6583aee7dae4Smrg func_append newdlprefiles " $dir/$dlname" 6584aee7dae4Smrg else 6585aee7dae4Smrg func_append newdlprefiles " $dir/$linklib" 6586aee7dae4Smrg fi 6587aee7dae4Smrg ;; 6588ba0eab60Smacallan esac 6589aee7dae4Smrg fi # $pass = dlpreopen 6590ba0eab60Smacallan 6591aee7dae4Smrg if test -z "$libdir"; then 6592aee7dae4Smrg # Link the convenience library 6593aee7dae4Smrg if test "$linkmode" = lib; then 6594aee7dae4Smrg deplibs="$dir/$old_library $deplibs" 6595aee7dae4Smrg elif test "$linkmode,$pass" = "prog,link"; then 6596aee7dae4Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 6597aee7dae4Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 6598ba0eab60Smacallan else 6599aee7dae4Smrg deplibs="$lib $deplibs" # used for prog,scan pass 6600ba0eab60Smacallan fi 6601aee7dae4Smrg continue 6602ba0eab60Smacallan fi 6603ba0eab60Smacallan 6604aee7dae4Smrg 6605aee7dae4Smrg if test "$linkmode" = prog && test "$pass" != link; then 6606aee7dae4Smrg func_append newlib_search_path " $ladir" 6607aee7dae4Smrg deplibs="$lib $deplibs" 6608aee7dae4Smrg 6609aee7dae4Smrg linkalldeplibs=no 6610aee7dae4Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 6611aee7dae4Smrg test "$build_libtool_libs" = no; then 6612aee7dae4Smrg linkalldeplibs=yes 6613aee7dae4Smrg fi 6614aee7dae4Smrg 6615aee7dae4Smrg tmp_libs= 6616aee7dae4Smrg for deplib in $dependency_libs; do 6617aee7dae4Smrg case $deplib in 6618aee7dae4Smrg -L*) func_stripname '-L' '' "$deplib" 6619aee7dae4Smrg func_resolve_sysroot "$func_stripname_result" 6620aee7dae4Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 6621aee7dae4Smrg ;; 6622aee7dae4Smrg esac 6623aee7dae4Smrg # Need to link against all dependency_libs? 6624aee7dae4Smrg if test "$linkalldeplibs" = yes; then 6625aee7dae4Smrg deplibs="$deplib $deplibs" 6626ba0eab60Smacallan else 6627aee7dae4Smrg # Need to hardcode shared library paths 6628aee7dae4Smrg # or/and link against static libraries 6629aee7dae4Smrg newdependency_libs="$deplib $newdependency_libs" 6630aee7dae4Smrg fi 6631aee7dae4Smrg if $opt_preserve_dup_deps ; then 6632aee7dae4Smrg case "$tmp_libs " in 6633aee7dae4Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6634aee7dae4Smrg esac 6635aee7dae4Smrg fi 6636aee7dae4Smrg func_append tmp_libs " $deplib" 6637aee7dae4Smrg done # for deplib 6638aee7dae4Smrg continue 6639aee7dae4Smrg fi # $linkmode = prog... 6640aee7dae4Smrg 6641aee7dae4Smrg if test "$linkmode,$pass" = "prog,link"; then 6642aee7dae4Smrg if test -n "$library_names" && 6643aee7dae4Smrg { { test "$prefer_static_libs" = no || 6644aee7dae4Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 6645aee7dae4Smrg test -z "$old_library"; }; then 6646aee7dae4Smrg # We need to hardcode the library path 6647aee7dae4Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 6648aee7dae4Smrg # Make sure the rpath contains only unique directories. 6649aee7dae4Smrg case "$temp_rpath:" in 6650aee7dae4Smrg *"$absdir:"*) ;; 6651aee7dae4Smrg *) func_append temp_rpath "$absdir:" ;; 6652ba0eab60Smacallan esac 6653ba0eab60Smacallan fi 6654ba0eab60Smacallan 6655aee7dae4Smrg # Hardcode the library path. 6656aee7dae4Smrg # Skip directories that are in the system default run-time 6657aee7dae4Smrg # search path. 6658aee7dae4Smrg case " $sys_lib_dlsearch_path " in 6659aee7dae4Smrg *" $absdir "*) ;; 6660aee7dae4Smrg *) 6661aee7dae4Smrg case "$compile_rpath " in 6662aee7dae4Smrg *" $absdir "*) ;; 6663aee7dae4Smrg *) func_append compile_rpath " $absdir" ;; 6664aee7dae4Smrg esac 6665aee7dae4Smrg ;; 6666aee7dae4Smrg esac 6667aee7dae4Smrg case " $sys_lib_dlsearch_path " in 6668aee7dae4Smrg *" $libdir "*) ;; 6669aee7dae4Smrg *) 6670aee7dae4Smrg case "$finalize_rpath " in 6671aee7dae4Smrg *" $libdir "*) ;; 6672aee7dae4Smrg *) func_append finalize_rpath " $libdir" ;; 6673aee7dae4Smrg esac 6674aee7dae4Smrg ;; 6675aee7dae4Smrg esac 6676aee7dae4Smrg fi # $linkmode,$pass = prog,link... 6677ba0eab60Smacallan 6678aee7dae4Smrg if test "$alldeplibs" = yes && 6679aee7dae4Smrg { test "$deplibs_check_method" = pass_all || 6680aee7dae4Smrg { test "$build_libtool_libs" = yes && 6681aee7dae4Smrg test -n "$library_names"; }; }; then 6682aee7dae4Smrg # We only need to search for static libraries 6683aee7dae4Smrg continue 6684aee7dae4Smrg fi 6685ba0eab60Smacallan fi 6686ba0eab60Smacallan 6687aee7dae4Smrg link_static=no # Whether the deplib will be linked statically 6688aee7dae4Smrg use_static_libs=$prefer_static_libs 6689aee7dae4Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 6690aee7dae4Smrg use_static_libs=no 6691aee7dae4Smrg fi 6692aee7dae4Smrg if test -n "$library_names" && 6693aee7dae4Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 6694aee7dae4Smrg case $host in 6695aee7dae4Smrg *cygwin* | *mingw* | *cegcc*) 6696aee7dae4Smrg # No point in relinking DLLs because paths are not encoded 6697aee7dae4Smrg func_append notinst_deplibs " $lib" 6698aee7dae4Smrg need_relink=no 6699aee7dae4Smrg ;; 6700aee7dae4Smrg *) 6701aee7dae4Smrg if test "$installed" = no; then 6702aee7dae4Smrg func_append notinst_deplibs " $lib" 6703aee7dae4Smrg need_relink=yes 6704aee7dae4Smrg fi 6705aee7dae4Smrg ;; 6706aee7dae4Smrg esac 6707aee7dae4Smrg # This is a shared library 6708ba0eab60Smacallan 6709aee7dae4Smrg # Warn about portability, can't link against -module's on some 6710aee7dae4Smrg # systems (darwin). Don't bleat about dlopened modules though! 6711aee7dae4Smrg dlopenmodule="" 6712aee7dae4Smrg for dlpremoduletest in $dlprefiles; do 6713aee7dae4Smrg if test "X$dlpremoduletest" = "X$lib"; then 6714aee7dae4Smrg dlopenmodule="$dlpremoduletest" 6715aee7dae4Smrg break 6716aee7dae4Smrg fi 6717aee7dae4Smrg done 6718aee7dae4Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 6719aee7dae4Smrg echo 6720aee7dae4Smrg if test "$linkmode" = prog; then 6721aee7dae4Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 6722aee7dae4Smrg else 6723aee7dae4Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 6724aee7dae4Smrg fi 6725aee7dae4Smrg $ECHO "*** $linklib is not portable!" 6726aee7dae4Smrg fi 6727aee7dae4Smrg if test "$linkmode" = lib && 6728aee7dae4Smrg test "$hardcode_into_libs" = yes; then 6729aee7dae4Smrg # Hardcode the library path. 6730aee7dae4Smrg # Skip directories that are in the system default run-time 6731aee7dae4Smrg # search path. 6732aee7dae4Smrg case " $sys_lib_dlsearch_path " in 6733aee7dae4Smrg *" $absdir "*) ;; 6734aee7dae4Smrg *) 6735aee7dae4Smrg case "$compile_rpath " in 6736aee7dae4Smrg *" $absdir "*) ;; 6737aee7dae4Smrg *) func_append compile_rpath " $absdir" ;; 6738aee7dae4Smrg esac 6739aee7dae4Smrg ;; 6740aee7dae4Smrg esac 6741aee7dae4Smrg case " $sys_lib_dlsearch_path " in 6742aee7dae4Smrg *" $libdir "*) ;; 6743aee7dae4Smrg *) 6744aee7dae4Smrg case "$finalize_rpath " in 6745aee7dae4Smrg *" $libdir "*) ;; 6746aee7dae4Smrg *) func_append finalize_rpath " $libdir" ;; 6747aee7dae4Smrg esac 6748aee7dae4Smrg ;; 6749aee7dae4Smrg esac 6750aee7dae4Smrg fi 6751ba0eab60Smacallan 6752aee7dae4Smrg if test -n "$old_archive_from_expsyms_cmds"; then 6753aee7dae4Smrg # figure out the soname 6754aee7dae4Smrg set dummy $library_names 6755aee7dae4Smrg shift 6756aee7dae4Smrg realname="$1" 6757aee7dae4Smrg shift 6758aee7dae4Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 6759aee7dae4Smrg # use dlname if we got it. it's perfectly good, no? 6760aee7dae4Smrg if test -n "$dlname"; then 6761aee7dae4Smrg soname="$dlname" 6762aee7dae4Smrg elif test -n "$soname_spec"; then 6763aee7dae4Smrg # bleh windows 6764aee7dae4Smrg case $host in 6765aee7dae4Smrg *cygwin* | mingw* | *cegcc*) 6766aee7dae4Smrg func_arith $current - $age 6767aee7dae4Smrg major=$func_arith_result 6768aee7dae4Smrg versuffix="-$major" 6769aee7dae4Smrg ;; 6770aee7dae4Smrg esac 6771aee7dae4Smrg eval soname=\"$soname_spec\" 6772aee7dae4Smrg else 6773aee7dae4Smrg soname="$realname" 6774aee7dae4Smrg fi 6775ba0eab60Smacallan 6776aee7dae4Smrg # Make a new name for the extract_expsyms_cmds to use 6777aee7dae4Smrg soroot="$soname" 6778aee7dae4Smrg func_basename "$soroot" 6779aee7dae4Smrg soname="$func_basename_result" 6780aee7dae4Smrg func_stripname 'lib' '.dll' "$soname" 6781aee7dae4Smrg newlib=libimp-$func_stripname_result.a 6782ba0eab60Smacallan 6783aee7dae4Smrg # If the library has no export list, then create one now 6784aee7dae4Smrg if test -f "$output_objdir/$soname-def"; then : 6785aee7dae4Smrg else 6786aee7dae4Smrg func_verbose "extracting exported symbol list from \`$soname'" 6787aee7dae4Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 6788aee7dae4Smrg fi 6789ba0eab60Smacallan 6790aee7dae4Smrg # Create $newlib 6791aee7dae4Smrg if test -f "$output_objdir/$newlib"; then :; else 6792aee7dae4Smrg func_verbose "generating import library for \`$soname'" 6793aee7dae4Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 6794aee7dae4Smrg fi 6795aee7dae4Smrg # make sure the library variables are pointing to the new library 6796aee7dae4Smrg dir=$output_objdir 6797aee7dae4Smrg linklib=$newlib 6798aee7dae4Smrg fi # test -n "$old_archive_from_expsyms_cmds" 6799ba0eab60Smacallan 6800aee7dae4Smrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 6801aee7dae4Smrg add_shlibpath= 6802aee7dae4Smrg add_dir= 6803aee7dae4Smrg add= 6804aee7dae4Smrg lib_linked=yes 6805aee7dae4Smrg case $hardcode_action in 6806aee7dae4Smrg immediate | unsupported) 6807aee7dae4Smrg if test "$hardcode_direct" = no; then 6808aee7dae4Smrg add="$dir/$linklib" 6809aee7dae4Smrg case $host in 6810aee7dae4Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6811aee7dae4Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 6812aee7dae4Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6813aee7dae4Smrg *-*-unixware7*) add_dir="-L$dir" ;; 6814aee7dae4Smrg *-*-darwin* ) 6815aee7dae4Smrg # if the lib is a (non-dlopened) module then we can not 6816aee7dae4Smrg # link against it, someone is ignoring the earlier warnings 6817aee7dae4Smrg if /usr/bin/file -L $add 2> /dev/null | 6818aee7dae4Smrg $GREP ": [^:]* bundle" >/dev/null ; then 6819aee7dae4Smrg if test "X$dlopenmodule" != "X$lib"; then 6820aee7dae4Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6821aee7dae4Smrg if test -z "$old_library" ; then 6822aee7dae4Smrg echo 6823aee7dae4Smrg echo "*** And there doesn't seem to be a static archive available" 6824aee7dae4Smrg echo "*** The link will probably fail, sorry" 6825aee7dae4Smrg else 6826aee7dae4Smrg add="$dir/$old_library" 6827aee7dae4Smrg fi 6828aee7dae4Smrg elif test -n "$old_library"; then 6829aee7dae4Smrg add="$dir/$old_library" 6830aee7dae4Smrg fi 6831aee7dae4Smrg fi 6832aee7dae4Smrg esac 6833aee7dae4Smrg elif test "$hardcode_minus_L" = no; then 6834aee7dae4Smrg case $host in 6835aee7dae4Smrg *-*-sunos*) add_shlibpath="$dir" ;; 6836aee7dae4Smrg esac 6837aee7dae4Smrg add_dir="-L$dir" 6838aee7dae4Smrg add="-l$name" 6839aee7dae4Smrg elif test "$hardcode_shlibpath_var" = no; then 6840aee7dae4Smrg add_shlibpath="$dir" 6841aee7dae4Smrg add="-l$name" 6842aee7dae4Smrg else 6843aee7dae4Smrg lib_linked=no 6844aee7dae4Smrg fi 6845aee7dae4Smrg ;; 6846aee7dae4Smrg relink) 6847aee7dae4Smrg if test "$hardcode_direct" = yes && 6848aee7dae4Smrg test "$hardcode_direct_absolute" = no; then 6849aee7dae4Smrg add="$dir/$linklib" 6850aee7dae4Smrg elif test "$hardcode_minus_L" = yes; then 6851aee7dae4Smrg add_dir="-L$absdir" 6852aee7dae4Smrg # Try looking first in the location we're being installed to. 6853aee7dae4Smrg if test -n "$inst_prefix_dir"; then 6854aee7dae4Smrg case $libdir in 6855aee7dae4Smrg [\\/]*) 6856aee7dae4Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 6857aee7dae4Smrg ;; 6858aee7dae4Smrg esac 6859aee7dae4Smrg fi 6860aee7dae4Smrg add="-l$name" 6861aee7dae4Smrg elif test "$hardcode_shlibpath_var" = yes; then 6862aee7dae4Smrg add_shlibpath="$dir" 6863aee7dae4Smrg add="-l$name" 6864aee7dae4Smrg else 6865aee7dae4Smrg lib_linked=no 6866aee7dae4Smrg fi 6867aee7dae4Smrg ;; 6868aee7dae4Smrg *) lib_linked=no ;; 6869aee7dae4Smrg esac 6870ba0eab60Smacallan 6871aee7dae4Smrg if test "$lib_linked" != yes; then 6872aee7dae4Smrg func_fatal_configuration "unsupported hardcode properties" 6873aee7dae4Smrg fi 6874ba0eab60Smacallan 6875aee7dae4Smrg if test -n "$add_shlibpath"; then 6876aee7dae4Smrg case :$compile_shlibpath: in 6877aee7dae4Smrg *":$add_shlibpath:"*) ;; 6878aee7dae4Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 6879aee7dae4Smrg esac 6880aee7dae4Smrg fi 6881aee7dae4Smrg if test "$linkmode" = prog; then 6882aee7dae4Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 6883aee7dae4Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 6884aee7dae4Smrg else 6885aee7dae4Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6886aee7dae4Smrg test -n "$add" && deplibs="$add $deplibs" 6887aee7dae4Smrg if test "$hardcode_direct" != yes && 6888aee7dae4Smrg test "$hardcode_minus_L" != yes && 6889aee7dae4Smrg test "$hardcode_shlibpath_var" = yes; then 6890aee7dae4Smrg case :$finalize_shlibpath: in 6891aee7dae4Smrg *":$libdir:"*) ;; 6892aee7dae4Smrg *) func_append finalize_shlibpath "$libdir:" ;; 6893aee7dae4Smrg esac 6894aee7dae4Smrg fi 6895aee7dae4Smrg fi 6896aee7dae4Smrg fi 6897ba0eab60Smacallan 6898aee7dae4Smrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 6899aee7dae4Smrg add_shlibpath= 6900aee7dae4Smrg add_dir= 6901aee7dae4Smrg add= 6902aee7dae4Smrg # Finalize command for both is simple: just hardcode it. 6903aee7dae4Smrg if test "$hardcode_direct" = yes && 6904aee7dae4Smrg test "$hardcode_direct_absolute" = no; then 6905aee7dae4Smrg add="$libdir/$linklib" 6906aee7dae4Smrg elif test "$hardcode_minus_L" = yes; then 6907aee7dae4Smrg add_dir="-L$libdir" 6908aee7dae4Smrg add="-l$name" 6909aee7dae4Smrg elif test "$hardcode_shlibpath_var" = yes; then 6910aee7dae4Smrg case :$finalize_shlibpath: in 6911aee7dae4Smrg *":$libdir:"*) ;; 6912aee7dae4Smrg *) func_append finalize_shlibpath "$libdir:" ;; 6913aee7dae4Smrg esac 6914aee7dae4Smrg add="-l$name" 6915aee7dae4Smrg elif test "$hardcode_automatic" = yes; then 6916aee7dae4Smrg if test -n "$inst_prefix_dir" && 6917aee7dae4Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 6918aee7dae4Smrg add="$inst_prefix_dir$libdir/$linklib" 6919aee7dae4Smrg else 6920aee7dae4Smrg add="$libdir/$linklib" 6921aee7dae4Smrg fi 6922aee7dae4Smrg else 6923aee7dae4Smrg # We cannot seem to hardcode it, guess we'll fake it. 6924aee7dae4Smrg add_dir="-L$libdir" 6925aee7dae4Smrg # Try looking first in the location we're being installed to. 6926aee7dae4Smrg if test -n "$inst_prefix_dir"; then 6927aee7dae4Smrg case $libdir in 6928aee7dae4Smrg [\\/]*) 6929aee7dae4Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 6930aee7dae4Smrg ;; 6931aee7dae4Smrg esac 6932aee7dae4Smrg fi 6933aee7dae4Smrg add="-l$name" 6934ba0eab60Smacallan fi 6935ba0eab60Smacallan 6936aee7dae4Smrg if test "$linkmode" = prog; then 6937aee7dae4Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 6938aee7dae4Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 6939aee7dae4Smrg else 6940aee7dae4Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 6941aee7dae4Smrg test -n "$add" && deplibs="$add $deplibs" 6942ba0eab60Smacallan fi 6943aee7dae4Smrg fi 6944aee7dae4Smrg elif test "$linkmode" = prog; then 6945aee7dae4Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 6946aee7dae4Smrg # is not unsupported. This is valid on all known static and 6947aee7dae4Smrg # shared platforms. 6948aee7dae4Smrg if test "$hardcode_direct" != unsupported; then 6949aee7dae4Smrg test -n "$old_library" && linklib="$old_library" 6950aee7dae4Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 6951aee7dae4Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 6952aee7dae4Smrg else 6953aee7dae4Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 6954aee7dae4Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 6955aee7dae4Smrg fi 6956aee7dae4Smrg elif test "$build_libtool_libs" = yes; then 6957aee7dae4Smrg # Not a shared library 6958aee7dae4Smrg if test "$deplibs_check_method" != pass_all; then 6959aee7dae4Smrg # We're trying link a shared library against a static one 6960aee7dae4Smrg # but the system doesn't support it. 6961ba0eab60Smacallan 6962aee7dae4Smrg # Just print a warning and add the library to dependency_libs so 6963aee7dae4Smrg # that the program can be linked against the static library. 6964aee7dae4Smrg echo 6965aee7dae4Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 6966aee7dae4Smrg echo "*** I have the capability to make that library automatically link in when" 6967aee7dae4Smrg echo "*** you link to this library. But I can only do this if you have a" 6968aee7dae4Smrg echo "*** shared version of the library, which you do not appear to have." 6969aee7dae4Smrg if test "$module" = yes; then 6970aee7dae4Smrg echo "*** But as you try to build a module library, libtool will still create " 6971aee7dae4Smrg echo "*** a static module, that should work as long as the dlopening application" 6972aee7dae4Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 6973aee7dae4Smrg if test -z "$global_symbol_pipe"; then 6974aee7dae4Smrg echo 6975aee7dae4Smrg echo "*** However, this would only work if libtool was able to extract symbol" 6976aee7dae4Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 6977aee7dae4Smrg echo "*** not find such a program. So, this module is probably useless." 6978aee7dae4Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 6979aee7dae4Smrg fi 6980aee7dae4Smrg if test "$build_old_libs" = no; then 6981aee7dae4Smrg build_libtool_libs=module 6982aee7dae4Smrg build_old_libs=yes 6983aee7dae4Smrg else 6984aee7dae4Smrg build_libtool_libs=no 6985aee7dae4Smrg fi 6986ba0eab60Smacallan fi 6987aee7dae4Smrg else 6988aee7dae4Smrg deplibs="$dir/$old_library $deplibs" 6989aee7dae4Smrg link_static=yes 6990ba0eab60Smacallan fi 6991aee7dae4Smrg fi # link shared/static library? 6992ba0eab60Smacallan 6993aee7dae4Smrg if test "$linkmode" = lib; then 6994aee7dae4Smrg if test -n "$dependency_libs" && 6995aee7dae4Smrg { test "$hardcode_into_libs" != yes || 6996aee7dae4Smrg test "$build_old_libs" = yes || 6997aee7dae4Smrg test "$link_static" = yes; }; then 6998aee7dae4Smrg # Extract -R from dependency_libs 6999aee7dae4Smrg temp_deplibs= 7000aee7dae4Smrg for libdir in $dependency_libs; do 7001aee7dae4Smrg case $libdir in 7002aee7dae4Smrg -R*) func_stripname '-R' '' "$libdir" 7003aee7dae4Smrg temp_xrpath=$func_stripname_result 7004aee7dae4Smrg case " $xrpath " in 7005aee7dae4Smrg *" $temp_xrpath "*) ;; 7006aee7dae4Smrg *) func_append xrpath " $temp_xrpath";; 7007aee7dae4Smrg esac;; 7008aee7dae4Smrg *) func_append temp_deplibs " $libdir";; 7009aee7dae4Smrg esac 7010aee7dae4Smrg done 7011aee7dae4Smrg dependency_libs="$temp_deplibs" 7012aee7dae4Smrg fi 7013ba0eab60Smacallan 7014aee7dae4Smrg func_append newlib_search_path " $absdir" 7015aee7dae4Smrg # Link against this library 7016aee7dae4Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 7017aee7dae4Smrg # ... and its dependency_libs 7018aee7dae4Smrg tmp_libs= 7019aee7dae4Smrg for deplib in $dependency_libs; do 7020aee7dae4Smrg newdependency_libs="$deplib $newdependency_libs" 7021aee7dae4Smrg case $deplib in 7022aee7dae4Smrg -L*) func_stripname '-L' '' "$deplib" 7023aee7dae4Smrg func_resolve_sysroot "$func_stripname_result";; 7024aee7dae4Smrg *) func_resolve_sysroot "$deplib" ;; 7025aee7dae4Smrg esac 7026aee7dae4Smrg if $opt_preserve_dup_deps ; then 7027aee7dae4Smrg case "$tmp_libs " in 7028aee7dae4Smrg *" $func_resolve_sysroot_result "*) 7029aee7dae4Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 7030aee7dae4Smrg esac 7031ba0eab60Smacallan fi 7032aee7dae4Smrg func_append tmp_libs " $func_resolve_sysroot_result" 7033aee7dae4Smrg done 7034ba0eab60Smacallan 7035aee7dae4Smrg if test "$link_all_deplibs" != no; then 7036aee7dae4Smrg # Add the search paths of all dependency libraries 7037aee7dae4Smrg for deplib in $dependency_libs; do 7038aee7dae4Smrg path= 7039aee7dae4Smrg case $deplib in 7040aee7dae4Smrg -L*) path="$deplib" ;; 7041aee7dae4Smrg *.la) 7042aee7dae4Smrg func_resolve_sysroot "$deplib" 7043aee7dae4Smrg deplib=$func_resolve_sysroot_result 7044aee7dae4Smrg func_dirname "$deplib" "" "." 7045aee7dae4Smrg dir=$func_dirname_result 7046aee7dae4Smrg # We need an absolute path. 7047aee7dae4Smrg case $dir in 7048aee7dae4Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 7049aee7dae4Smrg *) 7050aee7dae4Smrg absdir=`cd "$dir" && pwd` 7051aee7dae4Smrg if test -z "$absdir"; then 7052aee7dae4Smrg func_warning "cannot determine absolute directory name of \`$dir'" 7053aee7dae4Smrg absdir="$dir" 7054aee7dae4Smrg fi 7055aee7dae4Smrg ;; 7056aee7dae4Smrg esac 7057aee7dae4Smrg if $GREP "^installed=no" $deplib > /dev/null; then 7058aee7dae4Smrg case $host in 7059aee7dae4Smrg *-*-darwin*) 7060aee7dae4Smrg depdepl= 7061aee7dae4Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 7062aee7dae4Smrg if test -n "$deplibrary_names" ; then 7063aee7dae4Smrg for tmp in $deplibrary_names ; do 7064aee7dae4Smrg depdepl=$tmp 7065aee7dae4Smrg done 7066aee7dae4Smrg if test -f "$absdir/$objdir/$depdepl" ; then 7067aee7dae4Smrg depdepl="$absdir/$objdir/$depdepl" 7068aee7dae4Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7069aee7dae4Smrg if test -z "$darwin_install_name"; then 7070aee7dae4Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7071aee7dae4Smrg fi 7072aee7dae4Smrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 7073aee7dae4Smrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 7074aee7dae4Smrg path= 7075aee7dae4Smrg fi 7076aee7dae4Smrg fi 7077aee7dae4Smrg ;; 7078aee7dae4Smrg *) 7079aee7dae4Smrg path="-L$absdir/$objdir" 7080aee7dae4Smrg ;; 7081aee7dae4Smrg esac 7082ba0eab60Smacallan else 7083aee7dae4Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 7084aee7dae4Smrg test -z "$libdir" && \ 7085aee7dae4Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 7086aee7dae4Smrg test "$absdir" != "$libdir" && \ 7087aee7dae4Smrg func_warning "\`$deplib' seems to be moved" 7088ba0eab60Smacallan 7089aee7dae4Smrg path="-L$absdir" 7090aee7dae4Smrg fi 7091aee7dae4Smrg ;; 7092aee7dae4Smrg esac 7093aee7dae4Smrg case " $deplibs " in 7094aee7dae4Smrg *" $path "*) ;; 7095aee7dae4Smrg *) deplibs="$path $deplibs" ;; 7096aee7dae4Smrg esac 7097aee7dae4Smrg done 7098aee7dae4Smrg fi # link_all_deplibs != no 7099aee7dae4Smrg fi # linkmode = lib 7100aee7dae4Smrg done # for deplib in $libs 7101aee7dae4Smrg if test "$pass" = link; then 7102aee7dae4Smrg if test "$linkmode" = "prog"; then 7103aee7dae4Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 7104aee7dae4Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 7105aee7dae4Smrg else 7106aee7dae4Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7107ba0eab60Smacallan fi 7108ba0eab60Smacallan fi 7109aee7dae4Smrg dependency_libs="$newdependency_libs" 7110aee7dae4Smrg if test "$pass" = dlpreopen; then 7111aee7dae4Smrg # Link the dlpreopened libraries before other libraries 7112aee7dae4Smrg for deplib in $save_deplibs; do 7113aee7dae4Smrg deplibs="$deplib $deplibs" 7114ba0eab60Smacallan done 7115ba0eab60Smacallan fi 7116aee7dae4Smrg if test "$pass" != dlopen; then 7117aee7dae4Smrg if test "$pass" != conv; then 7118aee7dae4Smrg # Make sure lib_search_path contains only unique directories. 7119aee7dae4Smrg lib_search_path= 7120aee7dae4Smrg for dir in $newlib_search_path; do 7121aee7dae4Smrg case "$lib_search_path " in 7122aee7dae4Smrg *" $dir "*) ;; 7123aee7dae4Smrg *) func_append lib_search_path " $dir" ;; 7124aee7dae4Smrg esac 7125ba0eab60Smacallan done 7126aee7dae4Smrg newlib_search_path= 7127ba0eab60Smacallan fi 7128aee7dae4Smrg 7129aee7dae4Smrg if test "$linkmode,$pass" != "prog,link"; then 7130aee7dae4Smrg vars="deplibs" 7131aee7dae4Smrg else 7132aee7dae4Smrg vars="compile_deplibs finalize_deplibs" 7133aee7dae4Smrg fi 7134aee7dae4Smrg for var in $vars dependency_libs; do 7135aee7dae4Smrg # Add libraries to $var in reverse order 7136aee7dae4Smrg eval tmp_libs=\"\$$var\" 7137aee7dae4Smrg new_libs= 7138aee7dae4Smrg for deplib in $tmp_libs; do 7139aee7dae4Smrg # FIXME: Pedantically, this is the right thing to do, so 7140aee7dae4Smrg # that some nasty dependency loop isn't accidentally 7141aee7dae4Smrg # broken: 7142aee7dae4Smrg #new_libs="$deplib $new_libs" 7143aee7dae4Smrg # Pragmatically, this seems to cause very few problems in 7144aee7dae4Smrg # practice: 7145aee7dae4Smrg case $deplib in 7146aee7dae4Smrg -L*) new_libs="$deplib $new_libs" ;; 7147aee7dae4Smrg -R*) ;; 7148aee7dae4Smrg *) 7149aee7dae4Smrg # And here is the reason: when a library appears more 7150aee7dae4Smrg # than once as an explicit dependence of a library, or 7151aee7dae4Smrg # is implicitly linked in more than once by the 7152aee7dae4Smrg # compiler, it is considered special, and multiple 7153aee7dae4Smrg # occurrences thereof are not removed. Compare this 7154aee7dae4Smrg # with having the same library being listed as a 7155aee7dae4Smrg # dependency of multiple other libraries: in this case, 7156aee7dae4Smrg # we know (pedantically, we assume) the library does not 7157aee7dae4Smrg # need to be listed more than once, so we keep only the 7158aee7dae4Smrg # last copy. This is not always right, but it is rare 7159aee7dae4Smrg # enough that we require users that really mean to play 7160aee7dae4Smrg # such unportable linking tricks to link the library 7161aee7dae4Smrg # using -Wl,-lname, so that libtool does not consider it 7162aee7dae4Smrg # for duplicate removal. 7163aee7dae4Smrg case " $specialdeplibs " in 7164aee7dae4Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 7165aee7dae4Smrg *) 7166aee7dae4Smrg case " $new_libs " in 7167aee7dae4Smrg *" $deplib "*) ;; 7168aee7dae4Smrg *) new_libs="$deplib $new_libs" ;; 7169aee7dae4Smrg esac 7170aee7dae4Smrg ;; 7171aee7dae4Smrg esac 7172aee7dae4Smrg ;; 7173aee7dae4Smrg esac 7174aee7dae4Smrg done 7175aee7dae4Smrg tmp_libs= 7176aee7dae4Smrg for deplib in $new_libs; do 7177aee7dae4Smrg case $deplib in 7178aee7dae4Smrg -L*) 7179aee7dae4Smrg case " $tmp_libs " in 7180aee7dae4Smrg *" $deplib "*) ;; 7181aee7dae4Smrg *) func_append tmp_libs " $deplib" ;; 7182aee7dae4Smrg esac 7183aee7dae4Smrg ;; 7184aee7dae4Smrg *) func_append tmp_libs " $deplib" ;; 7185aee7dae4Smrg esac 7186ba0eab60Smacallan done 7187aee7dae4Smrg eval $var=\"$tmp_libs\" 7188aee7dae4Smrg done # for var 7189ba0eab60Smacallan fi 7190aee7dae4Smrg # Last step: remove runtime libs from dependency_libs 7191aee7dae4Smrg # (they stay in deplibs) 7192aee7dae4Smrg tmp_libs= 7193aee7dae4Smrg for i in $dependency_libs ; do 7194aee7dae4Smrg case " $predeps $postdeps $compiler_lib_search_path " in 7195aee7dae4Smrg *" $i "*) 7196aee7dae4Smrg i="" 7197aee7dae4Smrg ;; 7198aee7dae4Smrg esac 7199aee7dae4Smrg if test -n "$i" ; then 7200aee7dae4Smrg func_append tmp_libs " $i" 7201ba0eab60Smacallan fi 7202aee7dae4Smrg done 7203aee7dae4Smrg dependency_libs=$tmp_libs 7204aee7dae4Smrg done # for pass 7205aee7dae4Smrg if test "$linkmode" = prog; then 7206aee7dae4Smrg dlfiles="$newdlfiles" 7207aee7dae4Smrg fi 7208aee7dae4Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 7209aee7dae4Smrg dlprefiles="$newdlprefiles" 7210aee7dae4Smrg fi 7211ba0eab60Smacallan 7212aee7dae4Smrg case $linkmode in 7213aee7dae4Smrg oldlib) 7214aee7dae4Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7215aee7dae4Smrg func_warning "\`-dlopen' is ignored for archives" 7216ba0eab60Smacallan fi 7217ba0eab60Smacallan 7218aee7dae4Smrg case " $deplibs" in 7219aee7dae4Smrg *\ -l* | *\ -L*) 7220aee7dae4Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 7221aee7dae4Smrg esac 7222ba0eab60Smacallan 7223aee7dae4Smrg test -n "$rpath" && \ 7224aee7dae4Smrg func_warning "\`-rpath' is ignored for archives" 7225ba0eab60Smacallan 7226aee7dae4Smrg test -n "$xrpath" && \ 7227aee7dae4Smrg func_warning "\`-R' is ignored for archives" 7228ba0eab60Smacallan 7229aee7dae4Smrg test -n "$vinfo" && \ 7230aee7dae4Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 7231ba0eab60Smacallan 7232aee7dae4Smrg test -n "$release" && \ 7233aee7dae4Smrg func_warning "\`-release' is ignored for archives" 7234ba0eab60Smacallan 7235aee7dae4Smrg test -n "$export_symbols$export_symbols_regex" && \ 7236aee7dae4Smrg func_warning "\`-export-symbols' is ignored for archives" 7237ba0eab60Smacallan 7238aee7dae4Smrg # Now set the variables for building old libraries. 7239aee7dae4Smrg build_libtool_libs=no 7240aee7dae4Smrg oldlibs="$output" 7241aee7dae4Smrg func_append objs "$old_deplibs" 7242aee7dae4Smrg ;; 7243ba0eab60Smacallan 7244aee7dae4Smrg lib) 7245aee7dae4Smrg # Make sure we only generate libraries of the form `libNAME.la'. 7246aee7dae4Smrg case $outputname in 7247aee7dae4Smrg lib*) 7248aee7dae4Smrg func_stripname 'lib' '.la' "$outputname" 7249aee7dae4Smrg name=$func_stripname_result 7250aee7dae4Smrg eval shared_ext=\"$shrext_cmds\" 7251aee7dae4Smrg eval libname=\"$libname_spec\" 7252aee7dae4Smrg ;; 7253aee7dae4Smrg *) 7254aee7dae4Smrg test "$module" = no && \ 7255aee7dae4Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 7256ba0eab60Smacallan 7257aee7dae4Smrg if test "$need_lib_prefix" != no; then 7258aee7dae4Smrg # Add the "lib" prefix for modules if required 7259aee7dae4Smrg func_stripname '' '.la' "$outputname" 7260aee7dae4Smrg name=$func_stripname_result 7261aee7dae4Smrg eval shared_ext=\"$shrext_cmds\" 7262aee7dae4Smrg eval libname=\"$libname_spec\" 7263aee7dae4Smrg else 7264aee7dae4Smrg func_stripname '' '.la' "$outputname" 7265aee7dae4Smrg libname=$func_stripname_result 7266aee7dae4Smrg fi 7267aee7dae4Smrg ;; 7268aee7dae4Smrg esac 7269ba0eab60Smacallan 7270aee7dae4Smrg if test -n "$objs"; then 7271aee7dae4Smrg if test "$deplibs_check_method" != pass_all; then 7272aee7dae4Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 7273aee7dae4Smrg else 7274aee7dae4Smrg echo 7275aee7dae4Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 7276aee7dae4Smrg $ECHO "*** objects $objs is not portable!" 7277aee7dae4Smrg func_append libobjs " $objs" 7278aee7dae4Smrg fi 7279aee7dae4Smrg fi 7280ba0eab60Smacallan 7281aee7dae4Smrg test "$dlself" != no && \ 7282aee7dae4Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 7283ba0eab60Smacallan 7284aee7dae4Smrg set dummy $rpath 7285aee7dae4Smrg shift 7286aee7dae4Smrg test "$#" -gt 1 && \ 7287aee7dae4Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 7288ba0eab60Smacallan 7289aee7dae4Smrg install_libdir="$1" 7290ba0eab60Smacallan 7291aee7dae4Smrg oldlibs= 7292aee7dae4Smrg if test -z "$rpath"; then 7293aee7dae4Smrg if test "$build_libtool_libs" = yes; then 7294aee7dae4Smrg # Building a libtool convenience library. 7295aee7dae4Smrg # Some compilers have problems with a `.al' extension so 7296aee7dae4Smrg # convenience libraries should have the same extension an 7297aee7dae4Smrg # archive normally would. 7298aee7dae4Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 7299aee7dae4Smrg build_libtool_libs=convenience 7300aee7dae4Smrg build_old_libs=yes 7301aee7dae4Smrg fi 7302ba0eab60Smacallan 7303aee7dae4Smrg test -n "$vinfo" && \ 7304aee7dae4Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 7305ba0eab60Smacallan 7306aee7dae4Smrg test -n "$release" && \ 7307aee7dae4Smrg func_warning "\`-release' is ignored for convenience libraries" 7308aee7dae4Smrg else 7309ba0eab60Smacallan 7310aee7dae4Smrg # Parse the version information argument. 7311aee7dae4Smrg save_ifs="$IFS"; IFS=':' 7312aee7dae4Smrg set dummy $vinfo 0 0 0 7313aee7dae4Smrg shift 7314aee7dae4Smrg IFS="$save_ifs" 7315ba0eab60Smacallan 7316aee7dae4Smrg test -n "$7" && \ 7317aee7dae4Smrg func_fatal_help "too many parameters to \`-version-info'" 7318ba0eab60Smacallan 7319aee7dae4Smrg # convert absolute version numbers to libtool ages 7320aee7dae4Smrg # this retains compatibility with .la files and attempts 7321aee7dae4Smrg # to make the code below a bit more comprehensible 7322ba0eab60Smacallan 7323aee7dae4Smrg case $vinfo_number in 7324aee7dae4Smrg yes) 7325aee7dae4Smrg number_major="$1" 7326aee7dae4Smrg number_minor="$2" 7327aee7dae4Smrg number_revision="$3" 7328aee7dae4Smrg # 7329aee7dae4Smrg # There are really only two kinds -- those that 7330aee7dae4Smrg # use the current revision as the major version 7331aee7dae4Smrg # and those that subtract age and use age as 7332aee7dae4Smrg # a minor version. But, then there is irix 7333aee7dae4Smrg # which has an extra 1 added just for fun 7334aee7dae4Smrg # 7335aee7dae4Smrg case $version_type in 7336aee7dae4Smrg # correct linux to gnu/linux during the next big refactor 7337aee7dae4Smrg darwin|linux|osf|windows|none) 7338aee7dae4Smrg func_arith $number_major + $number_minor 7339aee7dae4Smrg current=$func_arith_result 7340aee7dae4Smrg age="$number_minor" 7341aee7dae4Smrg revision="$number_revision" 7342aee7dae4Smrg ;; 7343aee7dae4Smrg freebsd-aout|freebsd-elf|qnx|sunos) 7344aee7dae4Smrg current="$number_major" 7345aee7dae4Smrg revision="$number_minor" 7346aee7dae4Smrg age="0" 7347aee7dae4Smrg ;; 7348aee7dae4Smrg irix|nonstopux) 7349aee7dae4Smrg func_arith $number_major + $number_minor 7350aee7dae4Smrg current=$func_arith_result 7351aee7dae4Smrg age="$number_minor" 7352aee7dae4Smrg revision="$number_minor" 7353aee7dae4Smrg lt_irix_increment=no 7354aee7dae4Smrg ;; 7355aee7dae4Smrg *) 7356aee7dae4Smrg func_fatal_configuration "$modename: unknown library version type \`$version_type'" 7357aee7dae4Smrg ;; 7358aee7dae4Smrg esac 7359aee7dae4Smrg ;; 7360aee7dae4Smrg no) 7361aee7dae4Smrg current="$1" 7362aee7dae4Smrg revision="$2" 7363aee7dae4Smrg age="$3" 7364aee7dae4Smrg ;; 7365aee7dae4Smrg esac 7366ba0eab60Smacallan 7367aee7dae4Smrg # Check that each of the things are valid numbers. 7368aee7dae4Smrg case $current in 7369aee7dae4Smrg 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]) ;; 7370aee7dae4Smrg *) 7371aee7dae4Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 7372aee7dae4Smrg func_fatal_error "\`$vinfo' is not valid version information" 7373aee7dae4Smrg ;; 7374aee7dae4Smrg esac 7375ba0eab60Smacallan 7376aee7dae4Smrg case $revision in 7377aee7dae4Smrg 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]) ;; 7378aee7dae4Smrg *) 7379aee7dae4Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 7380aee7dae4Smrg func_fatal_error "\`$vinfo' is not valid version information" 7381aee7dae4Smrg ;; 7382aee7dae4Smrg esac 7383ba0eab60Smacallan 7384aee7dae4Smrg case $age in 7385aee7dae4Smrg 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]) ;; 7386aee7dae4Smrg *) 7387aee7dae4Smrg func_error "AGE \`$age' must be a nonnegative integer" 7388aee7dae4Smrg func_fatal_error "\`$vinfo' is not valid version information" 7389aee7dae4Smrg ;; 7390aee7dae4Smrg esac 7391ba0eab60Smacallan 7392aee7dae4Smrg if test "$age" -gt "$current"; then 7393aee7dae4Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 7394aee7dae4Smrg func_fatal_error "\`$vinfo' is not valid version information" 7395aee7dae4Smrg fi 7396ba0eab60Smacallan 7397aee7dae4Smrg # Calculate the version variables. 7398aee7dae4Smrg major= 7399aee7dae4Smrg versuffix= 7400aee7dae4Smrg verstring= 7401aee7dae4Smrg case $version_type in 7402aee7dae4Smrg none) ;; 7403ba0eab60Smacallan 7404aee7dae4Smrg darwin) 7405aee7dae4Smrg # Like Linux, but with the current version available in 7406aee7dae4Smrg # verstring for coding it into the library header 7407aee7dae4Smrg func_arith $current - $age 7408aee7dae4Smrg major=.$func_arith_result 7409aee7dae4Smrg versuffix="$major.$age.$revision" 7410aee7dae4Smrg # Darwin ld doesn't like 0 for these options... 7411aee7dae4Smrg func_arith $current + 1 7412aee7dae4Smrg minor_current=$func_arith_result 7413aee7dae4Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 7414aee7dae4Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 7415aee7dae4Smrg ;; 7416ba0eab60Smacallan 7417aee7dae4Smrg freebsd-aout) 7418aee7dae4Smrg major=".$current" 7419aee7dae4Smrg versuffix=".$current.$revision"; 7420aee7dae4Smrg ;; 7421ba0eab60Smacallan 7422aee7dae4Smrg freebsd-elf) 7423aee7dae4Smrg major=".$current" 7424aee7dae4Smrg versuffix=".$current" 7425aee7dae4Smrg ;; 7426ba0eab60Smacallan 7427aee7dae4Smrg irix | nonstopux) 7428aee7dae4Smrg if test "X$lt_irix_increment" = "Xno"; then 7429aee7dae4Smrg func_arith $current - $age 7430aee7dae4Smrg else 7431aee7dae4Smrg func_arith $current - $age + 1 7432aee7dae4Smrg fi 7433aee7dae4Smrg major=$func_arith_result 7434ba0eab60Smacallan 7435aee7dae4Smrg case $version_type in 7436aee7dae4Smrg nonstopux) verstring_prefix=nonstopux ;; 7437aee7dae4Smrg *) verstring_prefix=sgi ;; 7438aee7dae4Smrg esac 7439aee7dae4Smrg verstring="$verstring_prefix$major.$revision" 7440ba0eab60Smacallan 7441aee7dae4Smrg # Add in all the interfaces that we are compatible with. 7442aee7dae4Smrg loop=$revision 7443aee7dae4Smrg while test "$loop" -ne 0; do 7444aee7dae4Smrg func_arith $revision - $loop 7445aee7dae4Smrg iface=$func_arith_result 7446aee7dae4Smrg func_arith $loop - 1 7447aee7dae4Smrg loop=$func_arith_result 7448aee7dae4Smrg verstring="$verstring_prefix$major.$iface:$verstring" 7449aee7dae4Smrg done 7450ba0eab60Smacallan 7451aee7dae4Smrg # Before this point, $major must not contain `.'. 7452aee7dae4Smrg major=.$major 7453aee7dae4Smrg versuffix="$major.$revision" 7454aee7dae4Smrg ;; 7455ba0eab60Smacallan 7456aee7dae4Smrg linux) # correct to gnu/linux during the next big refactor 7457aee7dae4Smrg func_arith $current - $age 7458aee7dae4Smrg major=.$func_arith_result 7459aee7dae4Smrg versuffix="$major.$age.$revision" 7460aee7dae4Smrg ;; 7461ba0eab60Smacallan 7462aee7dae4Smrg osf) 7463aee7dae4Smrg func_arith $current - $age 7464aee7dae4Smrg major=.$func_arith_result 7465aee7dae4Smrg versuffix=".$current.$age.$revision" 7466aee7dae4Smrg verstring="$current.$age.$revision" 7467ba0eab60Smacallan 7468aee7dae4Smrg # Add in all the interfaces that we are compatible with. 7469aee7dae4Smrg loop=$age 7470aee7dae4Smrg while test "$loop" -ne 0; do 7471aee7dae4Smrg func_arith $current - $loop 7472aee7dae4Smrg iface=$func_arith_result 7473aee7dae4Smrg func_arith $loop - 1 7474aee7dae4Smrg loop=$func_arith_result 7475aee7dae4Smrg verstring="$verstring:${iface}.0" 7476aee7dae4Smrg done 7477ba0eab60Smacallan 7478aee7dae4Smrg # Make executables depend on our current version. 7479aee7dae4Smrg func_append verstring ":${current}.0" 7480aee7dae4Smrg ;; 7481ba0eab60Smacallan 7482aee7dae4Smrg qnx) 7483aee7dae4Smrg major=".$current" 7484aee7dae4Smrg versuffix=".$current" 7485aee7dae4Smrg ;; 7486ba0eab60Smacallan 7487aee7dae4Smrg sunos) 7488aee7dae4Smrg major=".$current" 7489aee7dae4Smrg versuffix=".$current.$revision" 7490aee7dae4Smrg ;; 7491ba0eab60Smacallan 7492aee7dae4Smrg windows) 7493aee7dae4Smrg # Use '-' rather than '.', since we only want one 7494aee7dae4Smrg # extension on DOS 8.3 filesystems. 7495aee7dae4Smrg func_arith $current - $age 7496aee7dae4Smrg major=$func_arith_result 7497aee7dae4Smrg versuffix="-$major" 7498aee7dae4Smrg ;; 7499ba0eab60Smacallan 7500aee7dae4Smrg *) 7501aee7dae4Smrg func_fatal_configuration "unknown library version type \`$version_type'" 7502aee7dae4Smrg ;; 7503aee7dae4Smrg esac 7504ba0eab60Smacallan 7505aee7dae4Smrg # Clear the version info if we defaulted, and they specified a release. 7506aee7dae4Smrg if test -z "$vinfo" && test -n "$release"; then 7507aee7dae4Smrg major= 7508aee7dae4Smrg case $version_type in 7509aee7dae4Smrg darwin) 7510aee7dae4Smrg # we can't check for "0.0" in archive_cmds due to quoting 7511aee7dae4Smrg # problems, so we reset it completely 7512aee7dae4Smrg verstring= 7513aee7dae4Smrg ;; 7514aee7dae4Smrg *) 7515aee7dae4Smrg verstring="0.0" 7516aee7dae4Smrg ;; 7517aee7dae4Smrg esac 7518aee7dae4Smrg if test "$need_version" = no; then 7519aee7dae4Smrg versuffix= 7520aee7dae4Smrg else 7521aee7dae4Smrg versuffix=".0.0" 7522aee7dae4Smrg fi 7523aee7dae4Smrg fi 7524ba0eab60Smacallan 7525aee7dae4Smrg # Remove version info from name if versioning should be avoided 7526aee7dae4Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 7527aee7dae4Smrg major= 7528aee7dae4Smrg versuffix= 7529aee7dae4Smrg verstring="" 7530aee7dae4Smrg fi 7531ba0eab60Smacallan 7532aee7dae4Smrg # Check to see if the archive will have undefined symbols. 7533aee7dae4Smrg if test "$allow_undefined" = yes; then 7534aee7dae4Smrg if test "$allow_undefined_flag" = unsupported; then 7535aee7dae4Smrg func_warning "undefined symbols not allowed in $host shared libraries" 7536aee7dae4Smrg build_libtool_libs=no 7537aee7dae4Smrg build_old_libs=yes 7538aee7dae4Smrg fi 7539aee7dae4Smrg else 7540aee7dae4Smrg # Don't allow undefined symbols. 7541aee7dae4Smrg allow_undefined_flag="$no_undefined_flag" 7542aee7dae4Smrg fi 7543ba0eab60Smacallan 7544aee7dae4Smrg fi 7545ba0eab60Smacallan 7546aee7dae4Smrg func_generate_dlsyms "$libname" "$libname" "yes" 7547aee7dae4Smrg func_append libobjs " $symfileobj" 7548aee7dae4Smrg test "X$libobjs" = "X " && libobjs= 7549ba0eab60Smacallan 7550aee7dae4Smrg if test "$opt_mode" != relink; then 7551aee7dae4Smrg # Remove our outputs, but don't remove object files since they 7552aee7dae4Smrg # may have been created when compiling PIC objects. 7553aee7dae4Smrg removelist= 7554aee7dae4Smrg tempremovelist=`$ECHO "$output_objdir/*"` 7555aee7dae4Smrg for p in $tempremovelist; do 7556aee7dae4Smrg case $p in 7557aee7dae4Smrg *.$objext | *.gcno) 7558aee7dae4Smrg ;; 7559aee7dae4Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 7560aee7dae4Smrg if test "X$precious_files_regex" != "X"; then 7561aee7dae4Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 7562aee7dae4Smrg then 7563aee7dae4Smrg continue 7564aee7dae4Smrg fi 7565aee7dae4Smrg fi 7566aee7dae4Smrg func_append removelist " $p" 7567aee7dae4Smrg ;; 7568aee7dae4Smrg *) ;; 7569aee7dae4Smrg esac 7570aee7dae4Smrg done 7571aee7dae4Smrg test -n "$removelist" && \ 7572aee7dae4Smrg func_show_eval "${RM}r \$removelist" 7573aee7dae4Smrg fi 7574ba0eab60Smacallan 7575aee7dae4Smrg # Now set the variables for building old libraries. 7576aee7dae4Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 7577aee7dae4Smrg func_append oldlibs " $output_objdir/$libname.$libext" 7578ba0eab60Smacallan 7579aee7dae4Smrg # Transform .lo files to .o files. 7580aee7dae4Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 7581aee7dae4Smrg fi 7582ba0eab60Smacallan 7583aee7dae4Smrg # Eliminate all temporary directories. 7584aee7dae4Smrg #for path in $notinst_path; do 7585aee7dae4Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 7586aee7dae4Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 7587aee7dae4Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 7588aee7dae4Smrg #done 7589ba0eab60Smacallan 7590aee7dae4Smrg if test -n "$xrpath"; then 7591aee7dae4Smrg # If the user specified any rpath flags, then add them. 7592aee7dae4Smrg temp_xrpath= 7593aee7dae4Smrg for libdir in $xrpath; do 7594aee7dae4Smrg func_replace_sysroot "$libdir" 7595aee7dae4Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 7596aee7dae4Smrg case "$finalize_rpath " in 7597aee7dae4Smrg *" $libdir "*) ;; 7598aee7dae4Smrg *) func_append finalize_rpath " $libdir" ;; 7599aee7dae4Smrg esac 7600aee7dae4Smrg done 7601aee7dae4Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 7602aee7dae4Smrg dependency_libs="$temp_xrpath $dependency_libs" 7603aee7dae4Smrg fi 7604aee7dae4Smrg fi 7605ba0eab60Smacallan 7606aee7dae4Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 7607aee7dae4Smrg old_dlfiles="$dlfiles" 7608aee7dae4Smrg dlfiles= 7609aee7dae4Smrg for lib in $old_dlfiles; do 7610aee7dae4Smrg case " $dlprefiles $dlfiles " in 7611aee7dae4Smrg *" $lib "*) ;; 7612aee7dae4Smrg *) func_append dlfiles " $lib" ;; 7613aee7dae4Smrg esac 7614aee7dae4Smrg done 7615ba0eab60Smacallan 7616aee7dae4Smrg # Make sure dlprefiles contains only unique files 7617aee7dae4Smrg old_dlprefiles="$dlprefiles" 7618aee7dae4Smrg dlprefiles= 7619aee7dae4Smrg for lib in $old_dlprefiles; do 7620aee7dae4Smrg case "$dlprefiles " in 7621aee7dae4Smrg *" $lib "*) ;; 7622aee7dae4Smrg *) func_append dlprefiles " $lib" ;; 7623aee7dae4Smrg esac 7624aee7dae4Smrg done 7625ba0eab60Smacallan 7626aee7dae4Smrg if test "$build_libtool_libs" = yes; then 7627aee7dae4Smrg if test -n "$rpath"; then 7628aee7dae4Smrg case $host in 7629aee7dae4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 7630aee7dae4Smrg # these systems don't actually have a c library (as such)! 7631aee7dae4Smrg ;; 7632aee7dae4Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7633aee7dae4Smrg # Rhapsody C library is in the System framework 7634aee7dae4Smrg func_append deplibs " System.ltframework" 7635aee7dae4Smrg ;; 7636aee7dae4Smrg *-*-netbsd*) 7637aee7dae4Smrg # Don't link with libc until the a.out ld.so is fixed. 7638aee7dae4Smrg ;; 7639aee7dae4Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 7640aee7dae4Smrg # Do not include libc due to us having libc/libc_r. 7641aee7dae4Smrg ;; 7642aee7dae4Smrg *-*-sco3.2v5* | *-*-sco5v6*) 7643aee7dae4Smrg # Causes problems with __ctype 7644aee7dae4Smrg ;; 7645aee7dae4Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7646aee7dae4Smrg # Compiler inserts libc in the correct place for threads to work 7647aee7dae4Smrg ;; 7648aee7dae4Smrg *) 7649aee7dae4Smrg # Add libc to deplibs on all other systems if necessary. 7650aee7dae4Smrg if test "$build_libtool_need_lc" = "yes"; then 7651aee7dae4Smrg func_append deplibs " -lc" 7652aee7dae4Smrg fi 7653aee7dae4Smrg ;; 7654aee7dae4Smrg esac 7655aee7dae4Smrg fi 7656ba0eab60Smacallan 7657aee7dae4Smrg # Transform deplibs into only deplibs that can be linked in shared. 7658aee7dae4Smrg name_save=$name 7659aee7dae4Smrg libname_save=$libname 7660aee7dae4Smrg release_save=$release 7661aee7dae4Smrg versuffix_save=$versuffix 7662aee7dae4Smrg major_save=$major 7663aee7dae4Smrg # I'm not sure if I'm treating the release correctly. I think 7664aee7dae4Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 7665aee7dae4Smrg # add it in twice. Is that correct? 7666aee7dae4Smrg release="" 7667aee7dae4Smrg versuffix="" 7668aee7dae4Smrg major="" 7669aee7dae4Smrg newdeplibs= 7670aee7dae4Smrg droppeddeps=no 7671aee7dae4Smrg case $deplibs_check_method in 7672aee7dae4Smrg pass_all) 7673aee7dae4Smrg # Don't check for shared/static. Everything works. 7674aee7dae4Smrg # This might be a little naive. We might want to check 7675aee7dae4Smrg # whether the library exists or not. But this is on 7676aee7dae4Smrg # osf3 & osf4 and I'm not really sure... Just 7677aee7dae4Smrg # implementing what was already the behavior. 7678aee7dae4Smrg newdeplibs=$deplibs 7679aee7dae4Smrg ;; 7680aee7dae4Smrg test_compile) 7681aee7dae4Smrg # This code stresses the "libraries are programs" paradigm to its 7682aee7dae4Smrg # limits. Maybe even breaks it. We compile a program, linking it 7683aee7dae4Smrg # against the deplibs as a proxy for the library. Then we can check 7684aee7dae4Smrg # whether they linked in statically or dynamically with ldd. 7685aee7dae4Smrg $opt_dry_run || $RM conftest.c 7686aee7dae4Smrg cat > conftest.c <<EOF 7687aee7dae4Smrg int main() { return 0; } 7688aee7dae4SmrgEOF 7689aee7dae4Smrg $opt_dry_run || $RM conftest 7690aee7dae4Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 7691aee7dae4Smrg ldd_output=`ldd conftest` 7692aee7dae4Smrg for i in $deplibs; do 7693aee7dae4Smrg case $i in 7694aee7dae4Smrg -l*) 7695aee7dae4Smrg func_stripname -l '' "$i" 7696aee7dae4Smrg name=$func_stripname_result 7697aee7dae4Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7698aee7dae4Smrg case " $predeps $postdeps " in 7699aee7dae4Smrg *" $i "*) 7700aee7dae4Smrg func_append newdeplibs " $i" 7701aee7dae4Smrg i="" 7702aee7dae4Smrg ;; 7703aee7dae4Smrg esac 7704aee7dae4Smrg fi 7705aee7dae4Smrg if test -n "$i" ; then 7706aee7dae4Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7707aee7dae4Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7708aee7dae4Smrg set dummy $deplib_matches; shift 7709aee7dae4Smrg deplib_match=$1 7710aee7dae4Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7711aee7dae4Smrg func_append newdeplibs " $i" 7712aee7dae4Smrg else 7713aee7dae4Smrg droppeddeps=yes 7714aee7dae4Smrg echo 7715aee7dae4Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7716aee7dae4Smrg echo "*** I have the capability to make that library automatically link in when" 7717aee7dae4Smrg echo "*** you link to this library. But I can only do this if you have a" 7718aee7dae4Smrg echo "*** shared version of the library, which I believe you do not have" 7719aee7dae4Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 7720aee7dae4Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 7721aee7dae4Smrg fi 7722aee7dae4Smrg fi 7723aee7dae4Smrg ;; 7724aee7dae4Smrg *) 7725aee7dae4Smrg func_append newdeplibs " $i" 7726aee7dae4Smrg ;; 7727aee7dae4Smrg esac 7728aee7dae4Smrg done 7729aee7dae4Smrg else 7730aee7dae4Smrg # Error occurred in the first compile. Let's try to salvage 7731aee7dae4Smrg # the situation: Compile a separate program for each library. 7732aee7dae4Smrg for i in $deplibs; do 7733aee7dae4Smrg case $i in 7734aee7dae4Smrg -l*) 7735aee7dae4Smrg func_stripname -l '' "$i" 7736aee7dae4Smrg name=$func_stripname_result 7737aee7dae4Smrg $opt_dry_run || $RM conftest 7738aee7dae4Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 7739aee7dae4Smrg ldd_output=`ldd conftest` 7740aee7dae4Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7741aee7dae4Smrg case " $predeps $postdeps " in 7742aee7dae4Smrg *" $i "*) 7743aee7dae4Smrg func_append newdeplibs " $i" 7744aee7dae4Smrg i="" 7745aee7dae4Smrg ;; 7746aee7dae4Smrg esac 7747aee7dae4Smrg fi 7748aee7dae4Smrg if test -n "$i" ; then 7749aee7dae4Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7750aee7dae4Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7751aee7dae4Smrg set dummy $deplib_matches; shift 7752aee7dae4Smrg deplib_match=$1 7753aee7dae4Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7754aee7dae4Smrg func_append newdeplibs " $i" 7755aee7dae4Smrg else 7756aee7dae4Smrg droppeddeps=yes 7757aee7dae4Smrg echo 7758aee7dae4Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7759aee7dae4Smrg echo "*** I have the capability to make that library automatically link in when" 7760aee7dae4Smrg echo "*** you link to this library. But I can only do this if you have a" 7761aee7dae4Smrg echo "*** shared version of the library, which you do not appear to have" 7762aee7dae4Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 7763aee7dae4Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 7764aee7dae4Smrg fi 7765aee7dae4Smrg fi 7766aee7dae4Smrg else 7767aee7dae4Smrg droppeddeps=yes 7768aee7dae4Smrg echo 7769aee7dae4Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 7770aee7dae4Smrg echo "*** make it link in! You will probably need to install it or some" 7771aee7dae4Smrg echo "*** library that it depends on before this library will be fully" 7772aee7dae4Smrg echo "*** functional. Installing it before continuing would be even better." 7773aee7dae4Smrg fi 7774aee7dae4Smrg ;; 7775aee7dae4Smrg *) 7776aee7dae4Smrg func_append newdeplibs " $i" 7777aee7dae4Smrg ;; 7778aee7dae4Smrg esac 7779aee7dae4Smrg done 7780aee7dae4Smrg fi 7781aee7dae4Smrg ;; 7782aee7dae4Smrg file_magic*) 7783aee7dae4Smrg set dummy $deplibs_check_method; shift 7784aee7dae4Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7785aee7dae4Smrg for a_deplib in $deplibs; do 7786aee7dae4Smrg case $a_deplib in 7787aee7dae4Smrg -l*) 7788aee7dae4Smrg func_stripname -l '' "$a_deplib" 7789aee7dae4Smrg name=$func_stripname_result 7790aee7dae4Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7791aee7dae4Smrg case " $predeps $postdeps " in 7792aee7dae4Smrg *" $a_deplib "*) 7793aee7dae4Smrg func_append newdeplibs " $a_deplib" 7794aee7dae4Smrg a_deplib="" 7795aee7dae4Smrg ;; 7796aee7dae4Smrg esac 7797aee7dae4Smrg fi 7798aee7dae4Smrg if test -n "$a_deplib" ; then 7799aee7dae4Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7800aee7dae4Smrg if test -n "$file_magic_glob"; then 7801aee7dae4Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 7802aee7dae4Smrg else 7803aee7dae4Smrg libnameglob=$libname 7804aee7dae4Smrg fi 7805aee7dae4Smrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 7806aee7dae4Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7807aee7dae4Smrg if test "$want_nocaseglob" = yes; then 7808aee7dae4Smrg shopt -s nocaseglob 7809aee7dae4Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7810aee7dae4Smrg $nocaseglob 7811aee7dae4Smrg else 7812aee7dae4Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7813aee7dae4Smrg fi 7814aee7dae4Smrg for potent_lib in $potential_libs; do 7815aee7dae4Smrg # Follow soft links. 7816aee7dae4Smrg if ls -lLd "$potent_lib" 2>/dev/null | 7817aee7dae4Smrg $GREP " -> " >/dev/null; then 7818aee7dae4Smrg continue 7819aee7dae4Smrg fi 7820aee7dae4Smrg # The statement above tries to avoid entering an 7821aee7dae4Smrg # endless loop below, in case of cyclic links. 7822aee7dae4Smrg # We might still enter an endless loop, since a link 7823aee7dae4Smrg # loop can be closed while we follow links, 7824aee7dae4Smrg # but so what? 7825aee7dae4Smrg potlib="$potent_lib" 7826aee7dae4Smrg while test -h "$potlib" 2>/dev/null; do 7827aee7dae4Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 7828aee7dae4Smrg case $potliblink in 7829aee7dae4Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 7830aee7dae4Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 7831aee7dae4Smrg esac 7832aee7dae4Smrg done 7833aee7dae4Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 7834aee7dae4Smrg $SED -e 10q | 7835aee7dae4Smrg $EGREP "$file_magic_regex" > /dev/null; then 7836aee7dae4Smrg func_append newdeplibs " $a_deplib" 7837aee7dae4Smrg a_deplib="" 7838aee7dae4Smrg break 2 7839aee7dae4Smrg fi 7840aee7dae4Smrg done 7841aee7dae4Smrg done 7842aee7dae4Smrg fi 7843aee7dae4Smrg if test -n "$a_deplib" ; then 7844aee7dae4Smrg droppeddeps=yes 7845aee7dae4Smrg echo 7846aee7dae4Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7847aee7dae4Smrg echo "*** I have the capability to make that library automatically link in when" 7848aee7dae4Smrg echo "*** you link to this library. But I can only do this if you have a" 7849aee7dae4Smrg echo "*** shared version of the library, which you do not appear to have" 7850aee7dae4Smrg echo "*** because I did check the linker path looking for a file starting" 7851aee7dae4Smrg if test -z "$potlib" ; then 7852aee7dae4Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 7853aee7dae4Smrg else 7854aee7dae4Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7855aee7dae4Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 7856aee7dae4Smrg fi 7857aee7dae4Smrg fi 7858aee7dae4Smrg ;; 7859aee7dae4Smrg *) 7860aee7dae4Smrg # Add a -L argument. 7861aee7dae4Smrg func_append newdeplibs " $a_deplib" 7862aee7dae4Smrg ;; 7863aee7dae4Smrg esac 7864aee7dae4Smrg done # Gone through all deplibs. 7865aee7dae4Smrg ;; 7866aee7dae4Smrg match_pattern*) 7867aee7dae4Smrg set dummy $deplibs_check_method; shift 7868aee7dae4Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7869aee7dae4Smrg for a_deplib in $deplibs; do 7870aee7dae4Smrg case $a_deplib in 7871aee7dae4Smrg -l*) 7872aee7dae4Smrg func_stripname -l '' "$a_deplib" 7873aee7dae4Smrg name=$func_stripname_result 7874aee7dae4Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7875aee7dae4Smrg case " $predeps $postdeps " in 7876aee7dae4Smrg *" $a_deplib "*) 7877aee7dae4Smrg func_append newdeplibs " $a_deplib" 7878aee7dae4Smrg a_deplib="" 7879aee7dae4Smrg ;; 7880aee7dae4Smrg esac 7881aee7dae4Smrg fi 7882aee7dae4Smrg if test -n "$a_deplib" ; then 7883aee7dae4Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 7884aee7dae4Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7885aee7dae4Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 7886aee7dae4Smrg for potent_lib in $potential_libs; do 7887aee7dae4Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 7888aee7dae4Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 7889aee7dae4Smrg $EGREP "$match_pattern_regex" > /dev/null; then 7890aee7dae4Smrg func_append newdeplibs " $a_deplib" 7891aee7dae4Smrg a_deplib="" 7892aee7dae4Smrg break 2 7893aee7dae4Smrg fi 7894aee7dae4Smrg done 7895aee7dae4Smrg done 7896aee7dae4Smrg fi 7897aee7dae4Smrg if test -n "$a_deplib" ; then 7898aee7dae4Smrg droppeddeps=yes 7899aee7dae4Smrg echo 7900aee7dae4Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7901aee7dae4Smrg echo "*** I have the capability to make that library automatically link in when" 7902aee7dae4Smrg echo "*** you link to this library. But I can only do this if you have a" 7903aee7dae4Smrg echo "*** shared version of the library, which you do not appear to have" 7904aee7dae4Smrg echo "*** because I did check the linker path looking for a file starting" 7905aee7dae4Smrg if test -z "$potlib" ; then 7906aee7dae4Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 7907aee7dae4Smrg else 7908aee7dae4Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 7909aee7dae4Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 7910aee7dae4Smrg fi 7911aee7dae4Smrg fi 7912aee7dae4Smrg ;; 7913aee7dae4Smrg *) 7914aee7dae4Smrg # Add a -L argument. 7915aee7dae4Smrg func_append newdeplibs " $a_deplib" 7916aee7dae4Smrg ;; 7917aee7dae4Smrg esac 7918aee7dae4Smrg done # Gone through all deplibs. 7919aee7dae4Smrg ;; 7920aee7dae4Smrg none | unknown | *) 7921aee7dae4Smrg newdeplibs="" 7922aee7dae4Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7923aee7dae4Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7924aee7dae4Smrg for i in $predeps $postdeps ; do 7925aee7dae4Smrg # can't use Xsed below, because $i might contain '/' 7926aee7dae4Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 7927aee7dae4Smrg done 7928aee7dae4Smrg fi 7929aee7dae4Smrg case $tmp_deplibs in 7930aee7dae4Smrg *[!\ \ ]*) 7931aee7dae4Smrg echo 7932aee7dae4Smrg if test "X$deplibs_check_method" = "Xnone"; then 7933aee7dae4Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 7934aee7dae4Smrg else 7935aee7dae4Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 7936aee7dae4Smrg fi 7937aee7dae4Smrg echo "*** All declared inter-library dependencies are being dropped." 7938aee7dae4Smrg droppeddeps=yes 7939aee7dae4Smrg ;; 7940aee7dae4Smrg esac 7941aee7dae4Smrg ;; 7942aee7dae4Smrg esac 7943aee7dae4Smrg versuffix=$versuffix_save 7944aee7dae4Smrg major=$major_save 7945aee7dae4Smrg release=$release_save 7946aee7dae4Smrg libname=$libname_save 7947aee7dae4Smrg name=$name_save 7948ba0eab60Smacallan 7949aee7dae4Smrg case $host in 7950aee7dae4Smrg *-*-rhapsody* | *-*-darwin1.[012]) 7951aee7dae4Smrg # On Rhapsody replace the C library with the System framework 7952aee7dae4Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 7953aee7dae4Smrg ;; 7954aee7dae4Smrg esac 7955ba0eab60Smacallan 7956aee7dae4Smrg if test "$droppeddeps" = yes; then 7957aee7dae4Smrg if test "$module" = yes; then 7958aee7dae4Smrg echo 7959aee7dae4Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 7960aee7dae4Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 7961aee7dae4Smrg echo "*** a static module, that should work as long as the dlopening" 7962aee7dae4Smrg echo "*** application is linked with the -dlopen flag." 7963aee7dae4Smrg if test -z "$global_symbol_pipe"; then 7964aee7dae4Smrg echo 7965aee7dae4Smrg echo "*** However, this would only work if libtool was able to extract symbol" 7966aee7dae4Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 7967aee7dae4Smrg echo "*** not find such a program. So, this module is probably useless." 7968aee7dae4Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 7969aee7dae4Smrg fi 7970aee7dae4Smrg if test "$build_old_libs" = no; then 7971aee7dae4Smrg oldlibs="$output_objdir/$libname.$libext" 7972aee7dae4Smrg build_libtool_libs=module 7973aee7dae4Smrg build_old_libs=yes 7974aee7dae4Smrg else 7975aee7dae4Smrg build_libtool_libs=no 7976aee7dae4Smrg fi 7977aee7dae4Smrg else 7978aee7dae4Smrg echo "*** The inter-library dependencies that have been dropped here will be" 7979aee7dae4Smrg echo "*** automatically added whenever a program is linked with this library" 7980aee7dae4Smrg echo "*** or is declared to -dlopen it." 7981ba0eab60Smacallan 7982aee7dae4Smrg if test "$allow_undefined" = no; then 7983aee7dae4Smrg echo 7984aee7dae4Smrg echo "*** Since this library must not contain undefined symbols," 7985aee7dae4Smrg echo "*** because either the platform does not support them or" 7986aee7dae4Smrg echo "*** it was explicitly requested with -no-undefined," 7987aee7dae4Smrg echo "*** libtool will only create a static version of it." 7988aee7dae4Smrg if test "$build_old_libs" = no; then 7989aee7dae4Smrg oldlibs="$output_objdir/$libname.$libext" 7990aee7dae4Smrg build_libtool_libs=module 7991aee7dae4Smrg build_old_libs=yes 7992aee7dae4Smrg else 7993aee7dae4Smrg build_libtool_libs=no 7994aee7dae4Smrg fi 7995aee7dae4Smrg fi 7996aee7dae4Smrg fi 7997ba0eab60Smacallan fi 7998aee7dae4Smrg # Done checking deplibs! 7999aee7dae4Smrg deplibs=$newdeplibs 8000aee7dae4Smrg fi 8001aee7dae4Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8002aee7dae4Smrg case $host in 8003aee7dae4Smrg *-*-darwin*) 8004aee7dae4Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8005aee7dae4Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8006aee7dae4Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8007aee7dae4Smrg ;; 8008aee7dae4Smrg esac 8009ba0eab60Smacallan 8010aee7dae4Smrg # move library search paths that coincide with paths to not yet 8011aee7dae4Smrg # installed libraries to the beginning of the library search list 8012aee7dae4Smrg new_libs= 8013aee7dae4Smrg for path in $notinst_path; do 8014aee7dae4Smrg case " $new_libs " in 8015aee7dae4Smrg *" -L$path/$objdir "*) ;; 8016aee7dae4Smrg *) 8017aee7dae4Smrg case " $deplibs " in 8018aee7dae4Smrg *" -L$path/$objdir "*) 8019aee7dae4Smrg func_append new_libs " -L$path/$objdir" ;; 8020aee7dae4Smrg esac 8021aee7dae4Smrg ;; 8022aee7dae4Smrg esac 8023aee7dae4Smrg done 8024aee7dae4Smrg for deplib in $deplibs; do 8025aee7dae4Smrg case $deplib in 8026aee7dae4Smrg -L*) 8027aee7dae4Smrg case " $new_libs " in 8028aee7dae4Smrg *" $deplib "*) ;; 8029aee7dae4Smrg *) func_append new_libs " $deplib" ;; 8030aee7dae4Smrg esac 8031aee7dae4Smrg ;; 8032aee7dae4Smrg *) func_append new_libs " $deplib" ;; 8033aee7dae4Smrg esac 8034aee7dae4Smrg done 8035aee7dae4Smrg deplibs="$new_libs" 8036ba0eab60Smacallan 8037aee7dae4Smrg # All the library-specific variables (install_libdir is set above). 8038aee7dae4Smrg library_names= 8039aee7dae4Smrg old_library= 8040aee7dae4Smrg dlname= 8041ba0eab60Smacallan 8042aee7dae4Smrg # Test again, we may have decided not to build it any more 8043aee7dae4Smrg if test "$build_libtool_libs" = yes; then 8044aee7dae4Smrg # Remove ${wl} instances when linking with ld. 8045aee7dae4Smrg # FIXME: should test the right _cmds variable. 8046aee7dae4Smrg case $archive_cmds in 8047aee7dae4Smrg *\$LD\ *) wl= ;; 8048aee7dae4Smrg esac 8049aee7dae4Smrg if test "$hardcode_into_libs" = yes; then 8050aee7dae4Smrg # Hardcode the library paths 8051aee7dae4Smrg hardcode_libdirs= 8052aee7dae4Smrg dep_rpath= 8053aee7dae4Smrg rpath="$finalize_rpath" 8054aee7dae4Smrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 8055aee7dae4Smrg for libdir in $rpath; do 8056aee7dae4Smrg if test -n "$hardcode_libdir_flag_spec"; then 8057aee7dae4Smrg if test -n "$hardcode_libdir_separator"; then 8058aee7dae4Smrg func_replace_sysroot "$libdir" 8059aee7dae4Smrg libdir=$func_replace_sysroot_result 8060aee7dae4Smrg if test -z "$hardcode_libdirs"; then 8061aee7dae4Smrg hardcode_libdirs="$libdir" 8062aee7dae4Smrg else 8063aee7dae4Smrg # Just accumulate the unique libdirs. 8064aee7dae4Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8065aee7dae4Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8066aee7dae4Smrg ;; 8067aee7dae4Smrg *) 8068aee7dae4Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8069aee7dae4Smrg ;; 8070aee7dae4Smrg esac 8071aee7dae4Smrg fi 8072aee7dae4Smrg else 8073aee7dae4Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8074aee7dae4Smrg func_append dep_rpath " $flag" 8075aee7dae4Smrg fi 8076aee7dae4Smrg elif test -n "$runpath_var"; then 8077aee7dae4Smrg case "$perm_rpath " in 8078aee7dae4Smrg *" $libdir "*) ;; 8079aee7dae4Smrg *) func_append perm_rpath " $libdir" ;; 8080aee7dae4Smrg esac 8081aee7dae4Smrg fi 8082aee7dae4Smrg done 8083aee7dae4Smrg # Substitute the hardcoded libdirs into the rpath. 8084aee7dae4Smrg if test -n "$hardcode_libdir_separator" && 8085aee7dae4Smrg test -n "$hardcode_libdirs"; then 8086aee7dae4Smrg libdir="$hardcode_libdirs" 8087aee7dae4Smrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 8088aee7dae4Smrg fi 8089aee7dae4Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 8090aee7dae4Smrg # We should set the runpath_var. 8091aee7dae4Smrg rpath= 8092aee7dae4Smrg for dir in $perm_rpath; do 8093aee7dae4Smrg func_append rpath "$dir:" 8094aee7dae4Smrg done 8095aee7dae4Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 8096aee7dae4Smrg fi 8097aee7dae4Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 8098ba0eab60Smacallan fi 8099ba0eab60Smacallan 8100aee7dae4Smrg shlibpath="$finalize_shlibpath" 8101aee7dae4Smrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 8102aee7dae4Smrg if test -n "$shlibpath"; then 8103aee7dae4Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 8104ba0eab60Smacallan fi 8105ba0eab60Smacallan 8106aee7dae4Smrg # Get the real and link names of the library. 8107aee7dae4Smrg eval shared_ext=\"$shrext_cmds\" 8108aee7dae4Smrg eval library_names=\"$library_names_spec\" 8109aee7dae4Smrg set dummy $library_names 8110aee7dae4Smrg shift 8111aee7dae4Smrg realname="$1" 8112aee7dae4Smrg shift 8113ba0eab60Smacallan 8114aee7dae4Smrg if test -n "$soname_spec"; then 8115aee7dae4Smrg eval soname=\"$soname_spec\" 8116ba0eab60Smacallan else 8117aee7dae4Smrg soname="$realname" 8118aee7dae4Smrg fi 8119aee7dae4Smrg if test -z "$dlname"; then 8120aee7dae4Smrg dlname=$soname 8121ba0eab60Smacallan fi 8122ba0eab60Smacallan 8123aee7dae4Smrg lib="$output_objdir/$realname" 8124aee7dae4Smrg linknames= 8125aee7dae4Smrg for link 8126aee7dae4Smrg do 8127aee7dae4Smrg func_append linknames " $link" 8128aee7dae4Smrg done 8129ba0eab60Smacallan 8130aee7dae4Smrg # Use standard objects if they are pic 8131aee7dae4Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 8132aee7dae4Smrg test "X$libobjs" = "X " && libobjs= 8133ba0eab60Smacallan 8134aee7dae4Smrg delfiles= 8135aee7dae4Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8136aee7dae4Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 8137aee7dae4Smrg export_symbols="$output_objdir/$libname.uexp" 8138aee7dae4Smrg func_append delfiles " $export_symbols" 8139aee7dae4Smrg fi 8140ba0eab60Smacallan 8141aee7dae4Smrg orig_export_symbols= 8142aee7dae4Smrg case $host_os in 8143aee7dae4Smrg cygwin* | mingw* | cegcc*) 8144aee7dae4Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 8145aee7dae4Smrg # exporting using user supplied symfile 8146aee7dae4Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 8147aee7dae4Smrg # and it's NOT already a .def file. Must figure out 8148aee7dae4Smrg # which of the given symbols are data symbols and tag 8149aee7dae4Smrg # them as such. So, trigger use of export_symbols_cmds. 8150aee7dae4Smrg # export_symbols gets reassigned inside the "prepare 8151aee7dae4Smrg # the list of exported symbols" if statement, so the 8152aee7dae4Smrg # include_expsyms logic still works. 8153aee7dae4Smrg orig_export_symbols="$export_symbols" 8154aee7dae4Smrg export_symbols= 8155aee7dae4Smrg always_export_symbols=yes 8156ba0eab60Smacallan fi 8157ba0eab60Smacallan fi 8158aee7dae4Smrg ;; 8159aee7dae4Smrg esac 8160ba0eab60Smacallan 8161aee7dae4Smrg # Prepare the list of exported symbols 8162aee7dae4Smrg if test -z "$export_symbols"; then 8163aee7dae4Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 8164aee7dae4Smrg func_verbose "generating symbol list for \`$libname.la'" 8165aee7dae4Smrg export_symbols="$output_objdir/$libname.exp" 8166aee7dae4Smrg $opt_dry_run || $RM $export_symbols 8167aee7dae4Smrg cmds=$export_symbols_cmds 8168aee7dae4Smrg save_ifs="$IFS"; IFS='~' 8169aee7dae4Smrg for cmd1 in $cmds; do 8170aee7dae4Smrg IFS="$save_ifs" 8171aee7dae4Smrg # Take the normal branch if the nm_file_list_spec branch 8172aee7dae4Smrg # doesn't work or if tool conversion is not needed. 8173aee7dae4Smrg case $nm_file_list_spec~$to_tool_file_cmd in 8174aee7dae4Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 8175aee7dae4Smrg try_normal_branch=yes 8176aee7dae4Smrg eval cmd=\"$cmd1\" 8177aee7dae4Smrg func_len " $cmd" 8178aee7dae4Smrg len=$func_len_result 8179aee7dae4Smrg ;; 8180aee7dae4Smrg *) 8181aee7dae4Smrg try_normal_branch=no 8182aee7dae4Smrg ;; 8183aee7dae4Smrg esac 8184aee7dae4Smrg if test "$try_normal_branch" = yes \ 8185aee7dae4Smrg && { test "$len" -lt "$max_cmd_len" \ 8186aee7dae4Smrg || test "$max_cmd_len" -le -1; } 8187aee7dae4Smrg then 8188aee7dae4Smrg func_show_eval "$cmd" 'exit $?' 8189aee7dae4Smrg skipped_export=false 8190aee7dae4Smrg elif test -n "$nm_file_list_spec"; then 8191aee7dae4Smrg func_basename "$output" 8192aee7dae4Smrg output_la=$func_basename_result 8193aee7dae4Smrg save_libobjs=$libobjs 8194aee7dae4Smrg save_output=$output 8195aee7dae4Smrg output=${output_objdir}/${output_la}.nm 8196aee7dae4Smrg func_to_tool_file "$output" 8197aee7dae4Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 8198aee7dae4Smrg func_append delfiles " $output" 8199aee7dae4Smrg func_verbose "creating $NM input file list: $output" 8200aee7dae4Smrg for obj in $save_libobjs; do 8201aee7dae4Smrg func_to_tool_file "$obj" 8202aee7dae4Smrg $ECHO "$func_to_tool_file_result" 8203aee7dae4Smrg done > "$output" 8204aee7dae4Smrg eval cmd=\"$cmd1\" 8205aee7dae4Smrg func_show_eval "$cmd" 'exit $?' 8206aee7dae4Smrg output=$save_output 8207aee7dae4Smrg libobjs=$save_libobjs 8208aee7dae4Smrg skipped_export=false 8209aee7dae4Smrg else 8210aee7dae4Smrg # The command line is too long to execute in one step. 8211aee7dae4Smrg func_verbose "using reloadable object file for export list..." 8212aee7dae4Smrg skipped_export=: 8213aee7dae4Smrg # Break out early, otherwise skipped_export may be 8214aee7dae4Smrg # set to false by a later but shorter cmd. 8215aee7dae4Smrg break 8216aee7dae4Smrg fi 8217aee7dae4Smrg done 8218aee7dae4Smrg IFS="$save_ifs" 8219aee7dae4Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 8220aee7dae4Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8221aee7dae4Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8222aee7dae4Smrg fi 8223aee7dae4Smrg fi 8224ba0eab60Smacallan fi 8225ba0eab60Smacallan 8226aee7dae4Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8227aee7dae4Smrg tmp_export_symbols="$export_symbols" 8228aee7dae4Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8229aee7dae4Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8230aee7dae4Smrg fi 8231ba0eab60Smacallan 8232aee7dae4Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 8233aee7dae4Smrg # The given exports_symbols file has to be filtered, so filter it. 8234aee7dae4Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8235aee7dae4Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8236aee7dae4Smrg # 's' commands which not all seds can handle. GNU sed should be fine 8237aee7dae4Smrg # though. Also, the filter scales superlinearly with the number of 8238aee7dae4Smrg # global variables. join(1) would be nice here, but unfortunately 8239aee7dae4Smrg # isn't a blessed tool. 8240aee7dae4Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8241aee7dae4Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8242aee7dae4Smrg export_symbols=$output_objdir/$libname.def 8243aee7dae4Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8244aee7dae4Smrg fi 8245ba0eab60Smacallan 8246aee7dae4Smrg tmp_deplibs= 8247aee7dae4Smrg for test_deplib in $deplibs; do 8248aee7dae4Smrg case " $convenience " in 8249aee7dae4Smrg *" $test_deplib "*) ;; 8250aee7dae4Smrg *) 8251aee7dae4Smrg func_append tmp_deplibs " $test_deplib" 8252aee7dae4Smrg ;; 8253aee7dae4Smrg esac 8254aee7dae4Smrg done 8255aee7dae4Smrg deplibs="$tmp_deplibs" 8256aee7dae4Smrg 8257aee7dae4Smrg if test -n "$convenience"; then 8258aee7dae4Smrg if test -n "$whole_archive_flag_spec" && 8259aee7dae4Smrg test "$compiler_needs_object" = yes && 8260aee7dae4Smrg test -z "$libobjs"; then 8261aee7dae4Smrg # extract the archives, so we have objects to list. 8262aee7dae4Smrg # TODO: could optimize this to just extract one archive. 8263aee7dae4Smrg whole_archive_flag_spec= 8264aee7dae4Smrg fi 8265aee7dae4Smrg if test -n "$whole_archive_flag_spec"; then 8266aee7dae4Smrg save_libobjs=$libobjs 8267aee7dae4Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8268aee7dae4Smrg test "X$libobjs" = "X " && libobjs= 8269ba0eab60Smacallan else 8270aee7dae4Smrg gentop="$output_objdir/${outputname}x" 8271aee7dae4Smrg func_append generated " $gentop" 8272aee7dae4Smrg 8273aee7dae4Smrg func_extract_archives $gentop $convenience 8274aee7dae4Smrg func_append libobjs " $func_extract_archives_result" 8275aee7dae4Smrg test "X$libobjs" = "X " && libobjs= 8276ba0eab60Smacallan fi 8277ba0eab60Smacallan fi 8278ba0eab60Smacallan 8279aee7dae4Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 8280aee7dae4Smrg eval flag=\"$thread_safe_flag_spec\" 8281aee7dae4Smrg func_append linker_flags " $flag" 8282aee7dae4Smrg fi 8283ba0eab60Smacallan 8284aee7dae4Smrg # Make a backup of the uninstalled library when relinking 8285aee7dae4Smrg if test "$opt_mode" = relink; then 8286aee7dae4Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 8287aee7dae4Smrg fi 8288ba0eab60Smacallan 8289aee7dae4Smrg # Do each of the archive commands. 8290aee7dae4Smrg if test "$module" = yes && test -n "$module_cmds" ; then 8291aee7dae4Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8292aee7dae4Smrg eval test_cmds=\"$module_expsym_cmds\" 8293aee7dae4Smrg cmds=$module_expsym_cmds 8294aee7dae4Smrg else 8295aee7dae4Smrg eval test_cmds=\"$module_cmds\" 8296aee7dae4Smrg cmds=$module_cmds 8297aee7dae4Smrg fi 8298ba0eab60Smacallan else 8299aee7dae4Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8300aee7dae4Smrg eval test_cmds=\"$archive_expsym_cmds\" 8301aee7dae4Smrg cmds=$archive_expsym_cmds 8302aee7dae4Smrg else 8303aee7dae4Smrg eval test_cmds=\"$archive_cmds\" 8304aee7dae4Smrg cmds=$archive_cmds 8305aee7dae4Smrg fi 8306ba0eab60Smacallan fi 8307ba0eab60Smacallan 8308aee7dae4Smrg if test "X$skipped_export" != "X:" && 8309aee7dae4Smrg func_len " $test_cmds" && 8310aee7dae4Smrg len=$func_len_result && 8311aee7dae4Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8312aee7dae4Smrg : 8313aee7dae4Smrg else 8314aee7dae4Smrg # The command line is too long to link in one step, link piecewise 8315aee7dae4Smrg # or, if using GNU ld and skipped_export is not :, use a linker 8316aee7dae4Smrg # script. 8317aee7dae4Smrg 8318aee7dae4Smrg # Save the value of $output and $libobjs because we want to 8319aee7dae4Smrg # use them later. If we have whole_archive_flag_spec, we 8320aee7dae4Smrg # want to use save_libobjs as it was before 8321aee7dae4Smrg # whole_archive_flag_spec was expanded, because we can't 8322aee7dae4Smrg # assume the linker understands whole_archive_flag_spec. 8323aee7dae4Smrg # This may have to be revisited, in case too many 8324aee7dae4Smrg # convenience libraries get linked in and end up exceeding 8325aee7dae4Smrg # the spec. 8326aee7dae4Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 8327aee7dae4Smrg save_libobjs=$libobjs 8328aee7dae4Smrg fi 8329aee7dae4Smrg save_output=$output 8330aee7dae4Smrg func_basename "$output" 8331aee7dae4Smrg output_la=$func_basename_result 8332ba0eab60Smacallan 8333aee7dae4Smrg # Clear the reloadable object creation command queue and 8334aee7dae4Smrg # initialize k to one. 8335aee7dae4Smrg test_cmds= 8336aee7dae4Smrg concat_cmds= 8337aee7dae4Smrg objlist= 8338aee7dae4Smrg last_robj= 8339aee7dae4Smrg k=1 8340aee7dae4Smrg 8341aee7dae4Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 8342aee7dae4Smrg output=${output_objdir}/${output_la}.lnkscript 8343aee7dae4Smrg func_verbose "creating GNU ld script: $output" 8344aee7dae4Smrg echo 'INPUT (' > $output 8345aee7dae4Smrg for obj in $save_libobjs 8346aee7dae4Smrg do 8347aee7dae4Smrg func_to_tool_file "$obj" 8348aee7dae4Smrg $ECHO "$func_to_tool_file_result" >> $output 8349aee7dae4Smrg done 8350aee7dae4Smrg echo ')' >> $output 8351aee7dae4Smrg func_append delfiles " $output" 8352aee7dae4Smrg func_to_tool_file "$output" 8353aee7dae4Smrg output=$func_to_tool_file_result 8354aee7dae4Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 8355aee7dae4Smrg output=${output_objdir}/${output_la}.lnk 8356aee7dae4Smrg func_verbose "creating linker input file list: $output" 8357aee7dae4Smrg : > $output 8358aee7dae4Smrg set x $save_libobjs 8359aee7dae4Smrg shift 8360aee7dae4Smrg firstobj= 8361aee7dae4Smrg if test "$compiler_needs_object" = yes; then 8362aee7dae4Smrg firstobj="$1 " 8363aee7dae4Smrg shift 8364ba0eab60Smacallan fi 8365aee7dae4Smrg for obj 8366aee7dae4Smrg do 8367aee7dae4Smrg func_to_tool_file "$obj" 8368aee7dae4Smrg $ECHO "$func_to_tool_file_result" >> $output 8369ba0eab60Smacallan done 8370aee7dae4Smrg func_append delfiles " $output" 8371aee7dae4Smrg func_to_tool_file "$output" 8372aee7dae4Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 8373aee7dae4Smrg else 8374aee7dae4Smrg if test -n "$save_libobjs"; then 8375aee7dae4Smrg func_verbose "creating reloadable object files..." 8376aee7dae4Smrg output=$output_objdir/$output_la-${k}.$objext 8377aee7dae4Smrg eval test_cmds=\"$reload_cmds\" 8378aee7dae4Smrg func_len " $test_cmds" 8379aee7dae4Smrg len0=$func_len_result 8380aee7dae4Smrg len=$len0 8381aee7dae4Smrg 8382aee7dae4Smrg # Loop over the list of objects to be linked. 8383aee7dae4Smrg for obj in $save_libobjs 8384aee7dae4Smrg do 8385aee7dae4Smrg func_len " $obj" 8386aee7dae4Smrg func_arith $len + $func_len_result 8387aee7dae4Smrg len=$func_arith_result 8388aee7dae4Smrg if test "X$objlist" = X || 8389aee7dae4Smrg test "$len" -lt "$max_cmd_len"; then 8390aee7dae4Smrg func_append objlist " $obj" 8391aee7dae4Smrg else 8392aee7dae4Smrg # The command $test_cmds is almost too long, add a 8393aee7dae4Smrg # command to the queue. 8394aee7dae4Smrg if test "$k" -eq 1 ; then 8395aee7dae4Smrg # The first file doesn't have a previous command to add. 8396aee7dae4Smrg reload_objs=$objlist 8397aee7dae4Smrg eval concat_cmds=\"$reload_cmds\" 8398aee7dae4Smrg else 8399aee7dae4Smrg # All subsequent reloadable object files will link in 8400aee7dae4Smrg # the last one created. 8401aee7dae4Smrg reload_objs="$objlist $last_robj" 8402aee7dae4Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 8403aee7dae4Smrg fi 8404aee7dae4Smrg last_robj=$output_objdir/$output_la-${k}.$objext 8405aee7dae4Smrg func_arith $k + 1 8406aee7dae4Smrg k=$func_arith_result 8407aee7dae4Smrg output=$output_objdir/$output_la-${k}.$objext 8408aee7dae4Smrg objlist=" $obj" 8409aee7dae4Smrg func_len " $last_robj" 8410aee7dae4Smrg func_arith $len0 + $func_len_result 8411aee7dae4Smrg len=$func_arith_result 8412aee7dae4Smrg fi 8413aee7dae4Smrg done 8414aee7dae4Smrg # Handle the remaining objects by creating one last 8415aee7dae4Smrg # reloadable object file. All subsequent reloadable object 8416aee7dae4Smrg # files will link in the last one created. 8417aee7dae4Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8418aee7dae4Smrg reload_objs="$objlist $last_robj" 8419aee7dae4Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 8420aee7dae4Smrg if test -n "$last_robj"; then 8421aee7dae4Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8422ba0eab60Smacallan fi 8423aee7dae4Smrg func_append delfiles " $output" 8424aee7dae4Smrg 8425aee7dae4Smrg else 8426aee7dae4Smrg output= 8427aee7dae4Smrg fi 8428aee7dae4Smrg 8429aee7dae4Smrg if ${skipped_export-false}; then 8430aee7dae4Smrg func_verbose "generating symbol list for \`$libname.la'" 8431aee7dae4Smrg export_symbols="$output_objdir/$libname.exp" 8432aee7dae4Smrg $opt_dry_run || $RM $export_symbols 8433aee7dae4Smrg libobjs=$output 8434aee7dae4Smrg # Append the command to create the export file. 8435aee7dae4Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8436aee7dae4Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 8437aee7dae4Smrg if test -n "$last_robj"; then 8438aee7dae4Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8439ba0eab60Smacallan fi 8440aee7dae4Smrg fi 8441aee7dae4Smrg 8442aee7dae4Smrg test -n "$save_libobjs" && 8443aee7dae4Smrg func_verbose "creating a temporary reloadable object file: $output" 8444aee7dae4Smrg 8445aee7dae4Smrg # Loop through the commands generated above and execute them. 8446aee7dae4Smrg save_ifs="$IFS"; IFS='~' 8447aee7dae4Smrg for cmd in $concat_cmds; do 8448aee7dae4Smrg IFS="$save_ifs" 8449aee7dae4Smrg $opt_silent || { 8450aee7dae4Smrg func_quote_for_expand "$cmd" 8451aee7dae4Smrg eval "func_echo $func_quote_for_expand_result" 8452aee7dae4Smrg } 8453aee7dae4Smrg $opt_dry_run || eval "$cmd" || { 8454aee7dae4Smrg lt_exit=$? 8455aee7dae4Smrg 8456aee7dae4Smrg # Restore the uninstalled library and exit 8457aee7dae4Smrg if test "$opt_mode" = relink; then 8458aee7dae4Smrg ( cd "$output_objdir" && \ 8459aee7dae4Smrg $RM "${realname}T" && \ 8460aee7dae4Smrg $MV "${realname}U" "$realname" ) 8461aee7dae4Smrg fi 8462aee7dae4Smrg 8463aee7dae4Smrg exit $lt_exit 8464aee7dae4Smrg } 8465ba0eab60Smacallan done 8466aee7dae4Smrg IFS="$save_ifs" 8467aee7dae4Smrg 8468aee7dae4Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 8469aee7dae4Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8470aee7dae4Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8471aee7dae4Smrg fi 8472aee7dae4Smrg fi 8473aee7dae4Smrg 8474aee7dae4Smrg if ${skipped_export-false}; then 8475aee7dae4Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 8476aee7dae4Smrg tmp_export_symbols="$export_symbols" 8477aee7dae4Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8478aee7dae4Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8479aee7dae4Smrg fi 8480aee7dae4Smrg 8481aee7dae4Smrg if test -n "$orig_export_symbols"; then 8482aee7dae4Smrg # The given exports_symbols file has to be filtered, so filter it. 8483aee7dae4Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8484aee7dae4Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 8485aee7dae4Smrg # 's' commands which not all seds can handle. GNU sed should be fine 8486aee7dae4Smrg # though. Also, the filter scales superlinearly with the number of 8487aee7dae4Smrg # global variables. join(1) would be nice here, but unfortunately 8488aee7dae4Smrg # isn't a blessed tool. 8489aee7dae4Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8490aee7dae4Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8491aee7dae4Smrg export_symbols=$output_objdir/$libname.def 8492aee7dae4Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8493aee7dae4Smrg fi 8494aee7dae4Smrg fi 8495aee7dae4Smrg 8496aee7dae4Smrg libobjs=$output 8497aee7dae4Smrg # Restore the value of output. 8498aee7dae4Smrg output=$save_output 8499aee7dae4Smrg 8500aee7dae4Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 8501aee7dae4Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8502aee7dae4Smrg test "X$libobjs" = "X " && libobjs= 8503aee7dae4Smrg fi 8504aee7dae4Smrg # Expand the library linking commands again to reset the 8505aee7dae4Smrg # value of $libobjs for piecewise linking. 8506aee7dae4Smrg 8507aee7dae4Smrg # Do each of the archive commands. 8508aee7dae4Smrg if test "$module" = yes && test -n "$module_cmds" ; then 8509aee7dae4Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8510aee7dae4Smrg cmds=$module_expsym_cmds 8511aee7dae4Smrg else 8512aee7dae4Smrg cmds=$module_cmds 8513aee7dae4Smrg fi 8514ba0eab60Smacallan else 8515aee7dae4Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8516aee7dae4Smrg cmds=$archive_expsym_cmds 8517aee7dae4Smrg else 8518aee7dae4Smrg cmds=$archive_cmds 8519aee7dae4Smrg fi 8520ba0eab60Smacallan fi 8521aee7dae4Smrg fi 8522ba0eab60Smacallan 8523aee7dae4Smrg if test -n "$delfiles"; then 8524aee7dae4Smrg # Append the command to remove temporary files to $cmds. 8525aee7dae4Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 8526aee7dae4Smrg fi 8527ba0eab60Smacallan 8528aee7dae4Smrg # Add any objects from preloaded convenience libraries 8529aee7dae4Smrg if test -n "$dlprefiles"; then 8530aee7dae4Smrg gentop="$output_objdir/${outputname}x" 8531aee7dae4Smrg func_append generated " $gentop" 8532ba0eab60Smacallan 8533aee7dae4Smrg func_extract_archives $gentop $dlprefiles 8534aee7dae4Smrg func_append libobjs " $func_extract_archives_result" 8535aee7dae4Smrg test "X$libobjs" = "X " && libobjs= 8536aee7dae4Smrg fi 8537ba0eab60Smacallan 8538aee7dae4Smrg save_ifs="$IFS"; IFS='~' 8539aee7dae4Smrg for cmd in $cmds; do 8540aee7dae4Smrg IFS="$save_ifs" 8541aee7dae4Smrg eval cmd=\"$cmd\" 8542aee7dae4Smrg $opt_silent || { 8543aee7dae4Smrg func_quote_for_expand "$cmd" 8544aee7dae4Smrg eval "func_echo $func_quote_for_expand_result" 8545aee7dae4Smrg } 8546aee7dae4Smrg $opt_dry_run || eval "$cmd" || { 8547aee7dae4Smrg lt_exit=$? 8548ba0eab60Smacallan 8549aee7dae4Smrg # Restore the uninstalled library and exit 8550aee7dae4Smrg if test "$opt_mode" = relink; then 8551aee7dae4Smrg ( cd "$output_objdir" && \ 8552aee7dae4Smrg $RM "${realname}T" && \ 8553aee7dae4Smrg $MV "${realname}U" "$realname" ) 8554aee7dae4Smrg fi 8555ba0eab60Smacallan 8556aee7dae4Smrg exit $lt_exit 8557aee7dae4Smrg } 8558aee7dae4Smrg done 8559aee7dae4Smrg IFS="$save_ifs" 8560ba0eab60Smacallan 8561aee7dae4Smrg # Restore the uninstalled library and exit 8562aee7dae4Smrg if test "$opt_mode" = relink; then 8563aee7dae4Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8564ba0eab60Smacallan 8565aee7dae4Smrg if test -n "$convenience"; then 8566aee7dae4Smrg if test -z "$whole_archive_flag_spec"; then 8567aee7dae4Smrg func_show_eval '${RM}r "$gentop"' 8568aee7dae4Smrg fi 8569aee7dae4Smrg fi 8570ba0eab60Smacallan 8571aee7dae4Smrg exit $EXIT_SUCCESS 8572aee7dae4Smrg fi 8573aee7dae4Smrg 8574aee7dae4Smrg # Create links to the real library. 8575aee7dae4Smrg for linkname in $linknames; do 8576aee7dae4Smrg if test "$realname" != "$linkname"; then 8577aee7dae4Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8578ba0eab60Smacallan fi 8579ba0eab60Smacallan done 8580ba0eab60Smacallan 8581aee7dae4Smrg # If -module or -export-dynamic was specified, set the dlname. 8582aee7dae4Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 8583aee7dae4Smrg # On all known operating systems, these are identical. 8584aee7dae4Smrg dlname="$soname" 8585aee7dae4Smrg fi 8586aee7dae4Smrg fi 8587ba0eab60Smacallan ;; 8588ba0eab60Smacallan 8589aee7dae4Smrg obj) 8590aee7dae4Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 8591aee7dae4Smrg func_warning "\`-dlopen' is ignored for objects" 8592aee7dae4Smrg fi 8593ba0eab60Smacallan 8594aee7dae4Smrg case " $deplibs" in 8595aee7dae4Smrg *\ -l* | *\ -L*) 8596aee7dae4Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 8597ba0eab60Smacallan esac 8598ba0eab60Smacallan 8599aee7dae4Smrg test -n "$rpath" && \ 8600aee7dae4Smrg func_warning "\`-rpath' is ignored for objects" 8601ba0eab60Smacallan 8602aee7dae4Smrg test -n "$xrpath" && \ 8603aee7dae4Smrg func_warning "\`-R' is ignored for objects" 8604ba0eab60Smacallan 8605aee7dae4Smrg test -n "$vinfo" && \ 8606aee7dae4Smrg func_warning "\`-version-info' is ignored for objects" 8607aee7dae4Smrg 8608aee7dae4Smrg test -n "$release" && \ 8609aee7dae4Smrg func_warning "\`-release' is ignored for objects" 8610aee7dae4Smrg 8611aee7dae4Smrg case $output in 8612aee7dae4Smrg *.lo) 8613aee7dae4Smrg test -n "$objs$old_deplibs" && \ 8614aee7dae4Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 8615aee7dae4Smrg 8616aee7dae4Smrg libobj=$output 8617aee7dae4Smrg func_lo2o "$libobj" 8618aee7dae4Smrg obj=$func_lo2o_result 8619ba0eab60Smacallan ;; 8620ba0eab60Smacallan *) 8621aee7dae4Smrg libobj= 8622aee7dae4Smrg obj="$output" 8623ba0eab60Smacallan ;; 8624ba0eab60Smacallan esac 8625ba0eab60Smacallan 8626aee7dae4Smrg # Delete the old objects. 8627aee7dae4Smrg $opt_dry_run || $RM $obj $libobj 8628ba0eab60Smacallan 8629aee7dae4Smrg # Objects from convenience libraries. This assumes 8630aee7dae4Smrg # single-version convenience libraries. Whenever we create 8631aee7dae4Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 8632aee7dae4Smrg # the extraction. 8633aee7dae4Smrg reload_conv_objs= 8634aee7dae4Smrg gentop= 8635aee7dae4Smrg # reload_cmds runs $LD directly, so let us get rid of 8636aee7dae4Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 8637aee7dae4Smrg # turning comma into space.. 8638aee7dae4Smrg wl= 8639ba0eab60Smacallan 8640aee7dae4Smrg if test -n "$convenience"; then 8641aee7dae4Smrg if test -n "$whole_archive_flag_spec"; then 8642aee7dae4Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 8643aee7dae4Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 8644aee7dae4Smrg else 8645aee7dae4Smrg gentop="$output_objdir/${obj}x" 8646aee7dae4Smrg func_append generated " $gentop" 8647ba0eab60Smacallan 8648aee7dae4Smrg func_extract_archives $gentop $convenience 8649aee7dae4Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 8650aee7dae4Smrg fi 8651ba0eab60Smacallan fi 8652ba0eab60Smacallan 8653aee7dae4Smrg # If we're not building shared, we need to use non_pic_objs 8654aee7dae4Smrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8655ba0eab60Smacallan 8656aee7dae4Smrg # Create the old-style object. 8657aee7dae4Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8658ba0eab60Smacallan 8659aee7dae4Smrg output="$obj" 8660aee7dae4Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8661aee7dae4Smrg 8662aee7dae4Smrg # Exit if we aren't doing a library object file. 8663aee7dae4Smrg if test -z "$libobj"; then 8664aee7dae4Smrg if test -n "$gentop"; then 8665aee7dae4Smrg func_show_eval '${RM}r "$gentop"' 8666aee7dae4Smrg fi 8667aee7dae4Smrg 8668aee7dae4Smrg exit $EXIT_SUCCESS 8669ba0eab60Smacallan fi 8670aee7dae4Smrg 8671aee7dae4Smrg if test "$build_libtool_libs" != yes; then 8672aee7dae4Smrg if test -n "$gentop"; then 8673aee7dae4Smrg func_show_eval '${RM}r "$gentop"' 8674aee7dae4Smrg fi 8675aee7dae4Smrg 8676aee7dae4Smrg # Create an invalid libtool object if no PIC, so that we don't 8677aee7dae4Smrg # accidentally link it into a program. 8678aee7dae4Smrg # $show "echo timestamp > $libobj" 8679aee7dae4Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 8680aee7dae4Smrg exit $EXIT_SUCCESS 8681aee7dae4Smrg fi 8682aee7dae4Smrg 8683aee7dae4Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 8684aee7dae4Smrg # Only do commands if we really have different PIC objects. 8685aee7dae4Smrg reload_objs="$libobjs $reload_conv_objs" 8686aee7dae4Smrg output="$libobj" 8687aee7dae4Smrg func_execute_cmds "$reload_cmds" 'exit $?' 8688aee7dae4Smrg fi 8689aee7dae4Smrg 8690aee7dae4Smrg if test -n "$gentop"; then 8691aee7dae4Smrg func_show_eval '${RM}r "$gentop"' 8692aee7dae4Smrg fi 8693aee7dae4Smrg 8694aee7dae4Smrg exit $EXIT_SUCCESS 8695ba0eab60Smacallan ;; 8696ba0eab60Smacallan 8697aee7dae4Smrg prog) 8698aee7dae4Smrg case $host in 8699aee7dae4Smrg *cygwin*) func_stripname '' '.exe' "$output" 8700aee7dae4Smrg output=$func_stripname_result.exe;; 8701aee7dae4Smrg esac 8702aee7dae4Smrg test -n "$vinfo" && \ 8703aee7dae4Smrg func_warning "\`-version-info' is ignored for programs" 8704ba0eab60Smacallan 8705aee7dae4Smrg test -n "$release" && \ 8706aee7dae4Smrg func_warning "\`-release' is ignored for programs" 8707ba0eab60Smacallan 8708aee7dae4Smrg test "$preload" = yes \ 8709aee7dae4Smrg && test "$dlopen_support" = unknown \ 8710aee7dae4Smrg && test "$dlopen_self" = unknown \ 8711aee7dae4Smrg && test "$dlopen_self_static" = unknown && \ 8712aee7dae4Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 8713aee7dae4Smrg 8714aee7dae4Smrg case $host in 8715aee7dae4Smrg *-*-rhapsody* | *-*-darwin1.[012]) 8716aee7dae4Smrg # On Rhapsody replace the C library is the System framework 8717aee7dae4Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 8718aee7dae4Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8719ba0eab60Smacallan ;; 8720aee7dae4Smrg esac 8721ba0eab60Smacallan 8722aee7dae4Smrg case $host in 8723aee7dae4Smrg *-*-darwin*) 8724aee7dae4Smrg # Don't allow lazy linking, it breaks C++ global constructors 8725aee7dae4Smrg # But is supposedly fixed on 10.4 or later (yay!). 8726aee7dae4Smrg if test "$tagname" = CXX ; then 8727aee7dae4Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 8728aee7dae4Smrg 10.[0123]) 8729aee7dae4Smrg func_append compile_command " ${wl}-bind_at_load" 8730aee7dae4Smrg func_append finalize_command " ${wl}-bind_at_load" 8731aee7dae4Smrg ;; 8732aee7dae4Smrg esac 8733ba0eab60Smacallan fi 8734aee7dae4Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8735aee7dae4Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8736aee7dae4Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8737aee7dae4Smrg ;; 8738aee7dae4Smrg esac 8739ba0eab60Smacallan 8740aee7dae4Smrg 8741aee7dae4Smrg # move library search paths that coincide with paths to not yet 8742aee7dae4Smrg # installed libraries to the beginning of the library search list 8743aee7dae4Smrg new_libs= 8744aee7dae4Smrg for path in $notinst_path; do 8745aee7dae4Smrg case " $new_libs " in 8746aee7dae4Smrg *" -L$path/$objdir "*) ;; 8747aee7dae4Smrg *) 8748aee7dae4Smrg case " $compile_deplibs " in 8749aee7dae4Smrg *" -L$path/$objdir "*) 8750aee7dae4Smrg func_append new_libs " -L$path/$objdir" ;; 8751aee7dae4Smrg esac 8752aee7dae4Smrg ;; 8753ba0eab60Smacallan esac 8754aee7dae4Smrg done 8755aee7dae4Smrg for deplib in $compile_deplibs; do 8756aee7dae4Smrg case $deplib in 8757aee7dae4Smrg -L*) 8758aee7dae4Smrg case " $new_libs " in 8759aee7dae4Smrg *" $deplib "*) ;; 8760aee7dae4Smrg *) func_append new_libs " $deplib" ;; 8761aee7dae4Smrg esac 8762aee7dae4Smrg ;; 8763aee7dae4Smrg *) func_append new_libs " $deplib" ;; 8764aee7dae4Smrg esac 8765aee7dae4Smrg done 8766aee7dae4Smrg compile_deplibs="$new_libs" 8767ba0eab60Smacallan 8768aee7dae4Smrg 8769aee7dae4Smrg func_append compile_command " $compile_deplibs" 8770aee7dae4Smrg func_append finalize_command " $finalize_deplibs" 8771aee7dae4Smrg 8772aee7dae4Smrg if test -n "$rpath$xrpath"; then 8773aee7dae4Smrg # If the user specified any rpath flags, then add them. 8774aee7dae4Smrg for libdir in $rpath $xrpath; do 8775aee7dae4Smrg # This is the magic to use -rpath. 8776aee7dae4Smrg case "$finalize_rpath " in 8777ba0eab60Smacallan *" $libdir "*) ;; 8778aee7dae4Smrg *) func_append finalize_rpath " $libdir" ;; 8779ba0eab60Smacallan esac 8780aee7dae4Smrg done 8781aee7dae4Smrg fi 8782aee7dae4Smrg 8783aee7dae4Smrg # Now hardcode the library paths 8784aee7dae4Smrg rpath= 8785aee7dae4Smrg hardcode_libdirs= 8786aee7dae4Smrg for libdir in $compile_rpath $finalize_rpath; do 8787aee7dae4Smrg if test -n "$hardcode_libdir_flag_spec"; then 8788aee7dae4Smrg if test -n "$hardcode_libdir_separator"; then 8789aee7dae4Smrg if test -z "$hardcode_libdirs"; then 8790aee7dae4Smrg hardcode_libdirs="$libdir" 8791aee7dae4Smrg else 8792aee7dae4Smrg # Just accumulate the unique libdirs. 8793aee7dae4Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8794aee7dae4Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8795aee7dae4Smrg ;; 8796aee7dae4Smrg *) 8797aee7dae4Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8798aee7dae4Smrg ;; 8799aee7dae4Smrg esac 8800aee7dae4Smrg fi 8801aee7dae4Smrg else 8802aee7dae4Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8803aee7dae4Smrg func_append rpath " $flag" 8804aee7dae4Smrg fi 8805aee7dae4Smrg elif test -n "$runpath_var"; then 8806aee7dae4Smrg case "$perm_rpath " in 8807ba0eab60Smacallan *" $libdir "*) ;; 8808aee7dae4Smrg *) func_append perm_rpath " $libdir" ;; 8809ba0eab60Smacallan esac 8810ba0eab60Smacallan fi 8811aee7dae4Smrg case $host in 8812aee7dae4Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 8813aee7dae4Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 8814aee7dae4Smrg case :$dllsearchpath: in 8815aee7dae4Smrg *":$libdir:"*) ;; 8816aee7dae4Smrg ::) dllsearchpath=$libdir;; 8817aee7dae4Smrg *) func_append dllsearchpath ":$libdir";; 8818aee7dae4Smrg esac 8819aee7dae4Smrg case :$dllsearchpath: in 8820aee7dae4Smrg *":$testbindir:"*) ;; 8821aee7dae4Smrg ::) dllsearchpath=$testbindir;; 8822aee7dae4Smrg *) func_append dllsearchpath ":$testbindir";; 8823aee7dae4Smrg esac 8824aee7dae4Smrg ;; 8825aee7dae4Smrg esac 8826aee7dae4Smrg done 8827aee7dae4Smrg # Substitute the hardcoded libdirs into the rpath. 8828aee7dae4Smrg if test -n "$hardcode_libdir_separator" && 8829aee7dae4Smrg test -n "$hardcode_libdirs"; then 8830aee7dae4Smrg libdir="$hardcode_libdirs" 8831aee7dae4Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 8832aee7dae4Smrg fi 8833aee7dae4Smrg compile_rpath="$rpath" 8834ba0eab60Smacallan 8835aee7dae4Smrg rpath= 8836aee7dae4Smrg hardcode_libdirs= 8837aee7dae4Smrg for libdir in $finalize_rpath; do 8838aee7dae4Smrg if test -n "$hardcode_libdir_flag_spec"; then 8839aee7dae4Smrg if test -n "$hardcode_libdir_separator"; then 8840aee7dae4Smrg if test -z "$hardcode_libdirs"; then 8841aee7dae4Smrg hardcode_libdirs="$libdir" 8842aee7dae4Smrg else 8843aee7dae4Smrg # Just accumulate the unique libdirs. 8844aee7dae4Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8845aee7dae4Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8846aee7dae4Smrg ;; 8847aee7dae4Smrg *) 8848aee7dae4Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8849aee7dae4Smrg ;; 8850aee7dae4Smrg esac 8851aee7dae4Smrg fi 8852ba0eab60Smacallan else 8853aee7dae4Smrg eval flag=\"$hardcode_libdir_flag_spec\" 8854aee7dae4Smrg func_append rpath " $flag" 8855ba0eab60Smacallan fi 8856aee7dae4Smrg elif test -n "$runpath_var"; then 8857aee7dae4Smrg case "$finalize_perm_rpath " in 8858aee7dae4Smrg *" $libdir "*) ;; 8859aee7dae4Smrg *) func_append finalize_perm_rpath " $libdir" ;; 8860aee7dae4Smrg esac 8861ba0eab60Smacallan fi 8862aee7dae4Smrg done 8863aee7dae4Smrg # Substitute the hardcoded libdirs into the rpath. 8864aee7dae4Smrg if test -n "$hardcode_libdir_separator" && 8865aee7dae4Smrg test -n "$hardcode_libdirs"; then 8866aee7dae4Smrg libdir="$hardcode_libdirs" 8867aee7dae4Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 8868aee7dae4Smrg fi 8869aee7dae4Smrg finalize_rpath="$rpath" 8870ba0eab60Smacallan 8871aee7dae4Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 8872aee7dae4Smrg # Transform all the library objects into standard objects. 8873aee7dae4Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8874aee7dae4Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8875aee7dae4Smrg fi 8876ba0eab60Smacallan 8877aee7dae4Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8878ba0eab60Smacallan 8879aee7dae4Smrg # template prelinking step 8880aee7dae4Smrg if test -n "$prelink_cmds"; then 8881aee7dae4Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 8882aee7dae4Smrg fi 8883ba0eab60Smacallan 8884aee7dae4Smrg wrappers_required=yes 8885aee7dae4Smrg case $host in 8886aee7dae4Smrg *cegcc* | *mingw32ce*) 8887aee7dae4Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 8888aee7dae4Smrg wrappers_required=no 8889aee7dae4Smrg ;; 8890aee7dae4Smrg *cygwin* | *mingw* ) 8891aee7dae4Smrg if test "$build_libtool_libs" != yes; then 8892aee7dae4Smrg wrappers_required=no 8893aee7dae4Smrg fi 8894aee7dae4Smrg ;; 8895aee7dae4Smrg *) 8896aee7dae4Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8897aee7dae4Smrg wrappers_required=no 8898aee7dae4Smrg fi 8899aee7dae4Smrg ;; 8900aee7dae4Smrg esac 8901aee7dae4Smrg if test "$wrappers_required" = no; then 8902aee7dae4Smrg # Replace the output file specification. 8903aee7dae4Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8904aee7dae4Smrg link_command="$compile_command$compile_rpath" 8905ba0eab60Smacallan 8906aee7dae4Smrg # We have no uninstalled library dependencies, so finalize right now. 8907aee7dae4Smrg exit_status=0 8908aee7dae4Smrg func_show_eval "$link_command" 'exit_status=$?' 8909ba0eab60Smacallan 8910aee7dae4Smrg if test -n "$postlink_cmds"; then 8911aee7dae4Smrg func_to_tool_file "$output" 8912aee7dae4Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8913aee7dae4Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8914ba0eab60Smacallan fi 8915ba0eab60Smacallan 8916aee7dae4Smrg # Delete the generated files. 8917aee7dae4Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 8918aee7dae4Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8919aee7dae4Smrg fi 8920ba0eab60Smacallan 8921aee7dae4Smrg exit $exit_status 8922aee7dae4Smrg fi 8923ba0eab60Smacallan 8924aee7dae4Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 8925aee7dae4Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 8926aee7dae4Smrg fi 8927aee7dae4Smrg if test -n "$finalize_shlibpath"; then 8928aee7dae4Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 8929aee7dae4Smrg fi 8930ba0eab60Smacallan 8931aee7dae4Smrg compile_var= 8932aee7dae4Smrg finalize_var= 8933aee7dae4Smrg if test -n "$runpath_var"; then 8934aee7dae4Smrg if test -n "$perm_rpath"; then 8935aee7dae4Smrg # We should set the runpath_var. 8936aee7dae4Smrg rpath= 8937aee7dae4Smrg for dir in $perm_rpath; do 8938aee7dae4Smrg func_append rpath "$dir:" 8939aee7dae4Smrg done 8940aee7dae4Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8941ba0eab60Smacallan fi 8942aee7dae4Smrg if test -n "$finalize_perm_rpath"; then 8943aee7dae4Smrg # We should set the runpath_var. 8944aee7dae4Smrg rpath= 8945aee7dae4Smrg for dir in $finalize_perm_rpath; do 8946aee7dae4Smrg func_append rpath "$dir:" 8947aee7dae4Smrg done 8948aee7dae4Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8949ba0eab60Smacallan fi 8950aee7dae4Smrg fi 8951ba0eab60Smacallan 8952aee7dae4Smrg if test "$no_install" = yes; then 8953aee7dae4Smrg # We don't need to create a wrapper script. 8954aee7dae4Smrg link_command="$compile_var$compile_command$compile_rpath" 8955aee7dae4Smrg # Replace the output file specification. 8956aee7dae4Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8957aee7dae4Smrg # Delete the old output file. 8958aee7dae4Smrg $opt_dry_run || $RM $output 8959aee7dae4Smrg # Link the executable and exit 8960aee7dae4Smrg func_show_eval "$link_command" 'exit $?' 8961ba0eab60Smacallan 8962aee7dae4Smrg if test -n "$postlink_cmds"; then 8963aee7dae4Smrg func_to_tool_file "$output" 8964aee7dae4Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8965aee7dae4Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 8966ba0eab60Smacallan fi 8967aee7dae4Smrg 8968ba0eab60Smacallan exit $EXIT_SUCCESS 8969aee7dae4Smrg fi 8970ba0eab60Smacallan 8971aee7dae4Smrg if test "$hardcode_action" = relink; then 8972aee7dae4Smrg # Fast installation is not supported 8973aee7dae4Smrg link_command="$compile_var$compile_command$compile_rpath" 8974aee7dae4Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8975aee7dae4Smrg 8976aee7dae4Smrg func_warning "this platform does not like uninstalled shared libraries" 8977aee7dae4Smrg func_warning "\`$output' will be relinked during installation" 8978aee7dae4Smrg else 8979aee7dae4Smrg if test "$fast_install" != no; then 8980aee7dae4Smrg link_command="$finalize_var$compile_command$finalize_rpath" 8981aee7dae4Smrg if test "$fast_install" = yes; then 8982aee7dae4Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 8983aee7dae4Smrg else 8984aee7dae4Smrg # fast_install is set to needless 8985aee7dae4Smrg relink_command= 8986aee7dae4Smrg fi 8987ba0eab60Smacallan else 8988aee7dae4Smrg link_command="$compile_var$compile_command$compile_rpath" 8989aee7dae4Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 8990ba0eab60Smacallan fi 8991aee7dae4Smrg fi 8992ba0eab60Smacallan 8993aee7dae4Smrg # Replace the output file specification. 8994aee7dae4Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8995ba0eab60Smacallan 8996aee7dae4Smrg # Delete the old output files. 8997aee7dae4Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8998ba0eab60Smacallan 8999aee7dae4Smrg func_show_eval "$link_command" 'exit $?' 9000ba0eab60Smacallan 9001aee7dae4Smrg if test -n "$postlink_cmds"; then 9002aee7dae4Smrg func_to_tool_file "$output_objdir/$outputname" 9003aee7dae4Smrg 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'` 9004aee7dae4Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 9005aee7dae4Smrg fi 9006ba0eab60Smacallan 9007aee7dae4Smrg # Now create the wrapper script. 9008aee7dae4Smrg func_verbose "creating $output" 9009ba0eab60Smacallan 9010aee7dae4Smrg # Quote the relink command for shipping. 9011aee7dae4Smrg if test -n "$relink_command"; then 9012aee7dae4Smrg # Preserve any variables that may affect compiler behavior 9013aee7dae4Smrg for var in $variables_saved_for_relink; do 9014aee7dae4Smrg if eval test -z \"\${$var+set}\"; then 9015aee7dae4Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9016aee7dae4Smrg elif eval var_value=\$$var; test -z "$var_value"; then 9017aee7dae4Smrg relink_command="$var=; export $var; $relink_command" 9018aee7dae4Smrg else 9019aee7dae4Smrg func_quote_for_eval "$var_value" 9020aee7dae4Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9021aee7dae4Smrg fi 9022aee7dae4Smrg done 9023aee7dae4Smrg relink_command="(cd `pwd`; $relink_command)" 9024aee7dae4Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9025aee7dae4Smrg fi 9026aee7dae4Smrg 9027aee7dae4Smrg # Only actually do things if not in dry run mode. 9028aee7dae4Smrg $opt_dry_run || { 9029aee7dae4Smrg # win32 will think the script is a binary if it has 9030aee7dae4Smrg # a .exe suffix, so we strip it off here. 9031aee7dae4Smrg case $output in 9032aee7dae4Smrg *.exe) func_stripname '' '.exe' "$output" 9033aee7dae4Smrg output=$func_stripname_result ;; 9034aee7dae4Smrg esac 9035aee7dae4Smrg # test for cygwin because mv fails w/o .exe extensions 9036aee7dae4Smrg case $host in 9037aee7dae4Smrg *cygwin*) 9038aee7dae4Smrg exeext=.exe 9039aee7dae4Smrg func_stripname '' '.exe' "$outputname" 9040aee7dae4Smrg outputname=$func_stripname_result ;; 9041aee7dae4Smrg *) exeext= ;; 9042aee7dae4Smrg esac 9043aee7dae4Smrg case $host in 9044aee7dae4Smrg *cygwin* | *mingw* ) 9045aee7dae4Smrg func_dirname_and_basename "$output" "" "." 9046aee7dae4Smrg output_name=$func_basename_result 9047aee7dae4Smrg output_path=$func_dirname_result 9048aee7dae4Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 9049aee7dae4Smrg cwrapper="$output_path/$output_name.exe" 9050aee7dae4Smrg $RM $cwrappersource $cwrapper 9051aee7dae4Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 9052aee7dae4Smrg 9053aee7dae4Smrg func_emit_cwrapperexe_src > $cwrappersource 9054aee7dae4Smrg 9055aee7dae4Smrg # The wrapper executable is built using the $host compiler, 9056aee7dae4Smrg # because it contains $host paths and files. If cross- 9057aee7dae4Smrg # compiling, it, like the target executable, must be 9058aee7dae4Smrg # executed on the $host or under an emulation environment. 9059aee7dae4Smrg $opt_dry_run || { 9060aee7dae4Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 9061aee7dae4Smrg $STRIP $cwrapper 9062aee7dae4Smrg } 9063ba0eab60Smacallan 9064aee7dae4Smrg # Now, create the wrapper script for func_source use: 9065aee7dae4Smrg func_ltwrapper_scriptname $cwrapper 9066aee7dae4Smrg $RM $func_ltwrapper_scriptname_result 9067aee7dae4Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 9068aee7dae4Smrg $opt_dry_run || { 9069aee7dae4Smrg # note: this script will not be executed, so do not chmod. 9070aee7dae4Smrg if test "x$build" = "x$host" ; then 9071aee7dae4Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 9072ba0eab60Smacallan else 9073aee7dae4Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 9074ba0eab60Smacallan fi 9075aee7dae4Smrg } 9076aee7dae4Smrg ;; 9077aee7dae4Smrg * ) 9078aee7dae4Smrg $RM $output 9079aee7dae4Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9080ba0eab60Smacallan 9081aee7dae4Smrg func_emit_wrapper no > $output 9082aee7dae4Smrg chmod +x $output 9083ba0eab60Smacallan ;; 9084ba0eab60Smacallan esac 9085aee7dae4Smrg } 9086aee7dae4Smrg exit $EXIT_SUCCESS 9087aee7dae4Smrg ;; 9088aee7dae4Smrg esac 9089ba0eab60Smacallan 9090aee7dae4Smrg # See if we need to build an old-fashioned archive. 9091aee7dae4Smrg for oldlib in $oldlibs; do 9092ba0eab60Smacallan 9093aee7dae4Smrg if test "$build_libtool_libs" = convenience; then 9094aee7dae4Smrg oldobjs="$libobjs_save $symfileobj" 9095aee7dae4Smrg addlibs="$convenience" 9096aee7dae4Smrg build_libtool_libs=no 9097aee7dae4Smrg else 9098aee7dae4Smrg if test "$build_libtool_libs" = module; then 9099aee7dae4Smrg oldobjs="$libobjs_save" 9100aee7dae4Smrg build_libtool_libs=no 9101aee7dae4Smrg else 9102aee7dae4Smrg oldobjs="$old_deplibs $non_pic_objects" 9103aee7dae4Smrg if test "$preload" = yes && test -f "$symfileobj"; then 9104aee7dae4Smrg func_append oldobjs " $symfileobj" 9105aee7dae4Smrg fi 9106aee7dae4Smrg fi 9107aee7dae4Smrg addlibs="$old_convenience" 9108ba0eab60Smacallan fi 9109ba0eab60Smacallan 9110aee7dae4Smrg if test -n "$addlibs"; then 9111aee7dae4Smrg gentop="$output_objdir/${outputname}x" 9112aee7dae4Smrg func_append generated " $gentop" 9113ba0eab60Smacallan 9114aee7dae4Smrg func_extract_archives $gentop $addlibs 9115aee7dae4Smrg func_append oldobjs " $func_extract_archives_result" 9116aee7dae4Smrg fi 9117ba0eab60Smacallan 9118aee7dae4Smrg # Do each command in the archive commands. 9119aee7dae4Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 9120aee7dae4Smrg cmds=$old_archive_from_new_cmds 9121aee7dae4Smrg else 9122ba0eab60Smacallan 9123aee7dae4Smrg # Add any objects from preloaded convenience libraries 9124aee7dae4Smrg if test -n "$dlprefiles"; then 9125aee7dae4Smrg gentop="$output_objdir/${outputname}x" 9126aee7dae4Smrg func_append generated " $gentop" 9127ba0eab60Smacallan 9128aee7dae4Smrg func_extract_archives $gentop $dlprefiles 9129aee7dae4Smrg func_append oldobjs " $func_extract_archives_result" 9130aee7dae4Smrg fi 9131ba0eab60Smacallan 9132aee7dae4Smrg # POSIX demands no paths to be encoded in archives. We have 9133aee7dae4Smrg # to avoid creating archives with duplicate basenames if we 9134aee7dae4Smrg # might have to extract them afterwards, e.g., when creating a 9135aee7dae4Smrg # static archive out of a convenience library, or when linking 9136aee7dae4Smrg # the entirety of a libtool archive into another (currently 9137aee7dae4Smrg # not supported by libtool). 9138aee7dae4Smrg if (for obj in $oldobjs 9139aee7dae4Smrg do 9140aee7dae4Smrg func_basename "$obj" 9141aee7dae4Smrg $ECHO "$func_basename_result" 9142aee7dae4Smrg done | sort | sort -uc >/dev/null 2>&1); then 9143aee7dae4Smrg : 9144aee7dae4Smrg else 9145aee7dae4Smrg echo "copying selected object files to avoid basename conflicts..." 9146aee7dae4Smrg gentop="$output_objdir/${outputname}x" 9147aee7dae4Smrg func_append generated " $gentop" 9148aee7dae4Smrg func_mkdir_p "$gentop" 9149aee7dae4Smrg save_oldobjs=$oldobjs 9150aee7dae4Smrg oldobjs= 9151aee7dae4Smrg counter=1 9152aee7dae4Smrg for obj in $save_oldobjs 9153aee7dae4Smrg do 9154aee7dae4Smrg func_basename "$obj" 9155aee7dae4Smrg objbase="$func_basename_result" 9156aee7dae4Smrg case " $oldobjs " in 9157aee7dae4Smrg " ") oldobjs=$obj ;; 9158aee7dae4Smrg *[\ /]"$objbase "*) 9159aee7dae4Smrg while :; do 9160aee7dae4Smrg # Make sure we don't pick an alternate name that also 9161aee7dae4Smrg # overlaps. 9162aee7dae4Smrg newobj=lt$counter-$objbase 9163aee7dae4Smrg func_arith $counter + 1 9164aee7dae4Smrg counter=$func_arith_result 9165aee7dae4Smrg case " $oldobjs " in 9166aee7dae4Smrg *[\ /]"$newobj "*) ;; 9167aee7dae4Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 9168aee7dae4Smrg esac 9169aee7dae4Smrg done 9170aee7dae4Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 9171aee7dae4Smrg func_append oldobjs " $gentop/$newobj" 9172aee7dae4Smrg ;; 9173aee7dae4Smrg *) func_append oldobjs " $obj" ;; 9174aee7dae4Smrg esac 9175ba0eab60Smacallan done 9176ba0eab60Smacallan fi 9177aee7dae4Smrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 9178aee7dae4Smrg tool_oldlib=$func_to_tool_file_result 9179aee7dae4Smrg eval cmds=\"$old_archive_cmds\" 9180ba0eab60Smacallan 9181aee7dae4Smrg func_len " $cmds" 9182aee7dae4Smrg len=$func_len_result 9183aee7dae4Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9184aee7dae4Smrg cmds=$old_archive_cmds 9185aee7dae4Smrg elif test -n "$archiver_list_spec"; then 9186aee7dae4Smrg func_verbose "using command file archive linking..." 9187aee7dae4Smrg for obj in $oldobjs 9188aee7dae4Smrg do 9189aee7dae4Smrg func_to_tool_file "$obj" 9190aee7dae4Smrg $ECHO "$func_to_tool_file_result" 9191aee7dae4Smrg done > $output_objdir/$libname.libcmd 9192aee7dae4Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 9193aee7dae4Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 9194aee7dae4Smrg cmds=$old_archive_cmds 9195aee7dae4Smrg else 9196aee7dae4Smrg # the command line is too long to link in one step, link in parts 9197aee7dae4Smrg func_verbose "using piecewise archive linking..." 9198aee7dae4Smrg save_RANLIB=$RANLIB 9199aee7dae4Smrg RANLIB=: 9200aee7dae4Smrg objlist= 9201aee7dae4Smrg concat_cmds= 9202aee7dae4Smrg save_oldobjs=$oldobjs 9203aee7dae4Smrg oldobjs= 9204aee7dae4Smrg # Is there a better way of finding the last object in the list? 9205aee7dae4Smrg for obj in $save_oldobjs 9206aee7dae4Smrg do 9207aee7dae4Smrg last_oldobj=$obj 9208aee7dae4Smrg done 9209aee7dae4Smrg eval test_cmds=\"$old_archive_cmds\" 9210aee7dae4Smrg func_len " $test_cmds" 9211aee7dae4Smrg len0=$func_len_result 9212aee7dae4Smrg len=$len0 9213aee7dae4Smrg for obj in $save_oldobjs 9214aee7dae4Smrg do 9215aee7dae4Smrg func_len " $obj" 9216aee7dae4Smrg func_arith $len + $func_len_result 9217aee7dae4Smrg len=$func_arith_result 9218aee7dae4Smrg func_append objlist " $obj" 9219aee7dae4Smrg if test "$len" -lt "$max_cmd_len"; then 9220aee7dae4Smrg : 9221aee7dae4Smrg else 9222aee7dae4Smrg # the above command should be used before it gets too long 9223aee7dae4Smrg oldobjs=$objlist 9224aee7dae4Smrg if test "$obj" = "$last_oldobj" ; then 9225aee7dae4Smrg RANLIB=$save_RANLIB 9226aee7dae4Smrg fi 9227aee7dae4Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9228aee7dae4Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 9229aee7dae4Smrg objlist= 9230aee7dae4Smrg len=$len0 9231aee7dae4Smrg fi 9232aee7dae4Smrg done 9233aee7dae4Smrg RANLIB=$save_RANLIB 9234aee7dae4Smrg oldobjs=$objlist 9235aee7dae4Smrg if test "X$oldobjs" = "X" ; then 9236aee7dae4Smrg eval cmds=\"\$concat_cmds\" 9237aee7dae4Smrg else 9238aee7dae4Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 9239aee7dae4Smrg fi 9240aee7dae4Smrg fi 9241aee7dae4Smrg fi 9242aee7dae4Smrg func_execute_cmds "$cmds" 'exit $?' 9243ba0eab60Smacallan done 9244ba0eab60Smacallan 9245aee7dae4Smrg test -n "$generated" && \ 9246aee7dae4Smrg func_show_eval "${RM}r$generated" 9247ba0eab60Smacallan 9248aee7dae4Smrg # Now create the libtool archive. 9249aee7dae4Smrg case $output in 9250aee7dae4Smrg *.la) 9251aee7dae4Smrg old_library= 9252aee7dae4Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 9253aee7dae4Smrg func_verbose "creating $output" 9254ba0eab60Smacallan 9255aee7dae4Smrg # Preserve any variables that may affect compiler behavior 9256aee7dae4Smrg for var in $variables_saved_for_relink; do 9257aee7dae4Smrg if eval test -z \"\${$var+set}\"; then 9258aee7dae4Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9259aee7dae4Smrg elif eval var_value=\$$var; test -z "$var_value"; then 9260aee7dae4Smrg relink_command="$var=; export $var; $relink_command" 9261ba0eab60Smacallan else 9262aee7dae4Smrg func_quote_for_eval "$var_value" 9263aee7dae4Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9264ba0eab60Smacallan fi 9265aee7dae4Smrg done 9266aee7dae4Smrg # Quote the link command for shipping. 9267aee7dae4Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 9268aee7dae4Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9269aee7dae4Smrg if test "$hardcode_automatic" = yes ; then 9270aee7dae4Smrg relink_command= 9271aee7dae4Smrg fi 9272ba0eab60Smacallan 9273aee7dae4Smrg # Only create the output if not a dry run. 9274aee7dae4Smrg $opt_dry_run || { 9275aee7dae4Smrg for installed in no yes; do 9276aee7dae4Smrg if test "$installed" = yes; then 9277aee7dae4Smrg if test -z "$install_libdir"; then 9278aee7dae4Smrg break 9279aee7dae4Smrg fi 9280aee7dae4Smrg output="$output_objdir/$outputname"i 9281aee7dae4Smrg # Replace all uninstalled libtool libraries with the installed ones 9282aee7dae4Smrg newdependency_libs= 9283aee7dae4Smrg for deplib in $dependency_libs; do 9284aee7dae4Smrg case $deplib in 9285aee7dae4Smrg *.la) 9286aee7dae4Smrg func_basename "$deplib" 9287aee7dae4Smrg name="$func_basename_result" 9288aee7dae4Smrg func_resolve_sysroot "$deplib" 9289aee7dae4Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 9290aee7dae4Smrg test -z "$libdir" && \ 9291aee7dae4Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 9292aee7dae4Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 9293aee7dae4Smrg ;; 9294aee7dae4Smrg -L*) 9295aee7dae4Smrg func_stripname -L '' "$deplib" 9296aee7dae4Smrg func_replace_sysroot "$func_stripname_result" 9297aee7dae4Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 9298aee7dae4Smrg ;; 9299aee7dae4Smrg -R*) 9300aee7dae4Smrg func_stripname -R '' "$deplib" 9301aee7dae4Smrg func_replace_sysroot "$func_stripname_result" 9302aee7dae4Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 9303aee7dae4Smrg ;; 9304aee7dae4Smrg *) func_append newdependency_libs " $deplib" ;; 9305aee7dae4Smrg esac 9306aee7dae4Smrg done 9307aee7dae4Smrg dependency_libs="$newdependency_libs" 9308aee7dae4Smrg newdlfiles= 9309ba0eab60Smacallan 9310aee7dae4Smrg for lib in $dlfiles; do 9311aee7dae4Smrg case $lib in 9312aee7dae4Smrg *.la) 9313aee7dae4Smrg func_basename "$lib" 9314aee7dae4Smrg name="$func_basename_result" 9315aee7dae4Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9316aee7dae4Smrg test -z "$libdir" && \ 9317aee7dae4Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 9318aee7dae4Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 9319aee7dae4Smrg ;; 9320aee7dae4Smrg *) func_append newdlfiles " $lib" ;; 9321aee7dae4Smrg esac 9322aee7dae4Smrg done 9323aee7dae4Smrg dlfiles="$newdlfiles" 9324aee7dae4Smrg newdlprefiles= 9325aee7dae4Smrg for lib in $dlprefiles; do 9326aee7dae4Smrg case $lib in 9327aee7dae4Smrg *.la) 9328aee7dae4Smrg # Only pass preopened files to the pseudo-archive (for 9329aee7dae4Smrg # eventual linking with the app. that links it) if we 9330aee7dae4Smrg # didn't already link the preopened objects directly into 9331aee7dae4Smrg # the library: 9332aee7dae4Smrg func_basename "$lib" 9333aee7dae4Smrg name="$func_basename_result" 9334aee7dae4Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9335aee7dae4Smrg test -z "$libdir" && \ 9336aee7dae4Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 9337aee7dae4Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 9338aee7dae4Smrg ;; 9339aee7dae4Smrg esac 9340aee7dae4Smrg done 9341aee7dae4Smrg dlprefiles="$newdlprefiles" 9342aee7dae4Smrg else 9343aee7dae4Smrg newdlfiles= 9344aee7dae4Smrg for lib in $dlfiles; do 9345aee7dae4Smrg case $lib in 9346aee7dae4Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9347aee7dae4Smrg *) abs=`pwd`"/$lib" ;; 9348aee7dae4Smrg esac 9349aee7dae4Smrg func_append newdlfiles " $abs" 9350aee7dae4Smrg done 9351aee7dae4Smrg dlfiles="$newdlfiles" 9352aee7dae4Smrg newdlprefiles= 9353aee7dae4Smrg for lib in $dlprefiles; do 9354aee7dae4Smrg case $lib in 9355aee7dae4Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9356aee7dae4Smrg *) abs=`pwd`"/$lib" ;; 9357aee7dae4Smrg esac 9358aee7dae4Smrg func_append newdlprefiles " $abs" 9359aee7dae4Smrg done 9360aee7dae4Smrg dlprefiles="$newdlprefiles" 9361aee7dae4Smrg fi 9362aee7dae4Smrg $RM $output 9363aee7dae4Smrg # place dlname in correct position for cygwin 9364aee7dae4Smrg # In fact, it would be nice if we could use this code for all target 9365aee7dae4Smrg # systems that can't hard-code library paths into their executables 9366aee7dae4Smrg # and that have no shared library path variable independent of PATH, 9367aee7dae4Smrg # but it turns out we can't easily determine that from inspecting 9368aee7dae4Smrg # libtool variables, so we have to hard-code the OSs to which it 9369aee7dae4Smrg # applies here; at the moment, that means platforms that use the PE 9370aee7dae4Smrg # object format with DLL files. See the long comment at the top of 9371aee7dae4Smrg # tests/bindir.at for full details. 9372aee7dae4Smrg tdlname=$dlname 9373aee7dae4Smrg case $host,$output,$installed,$module,$dlname in 9374aee7dae4Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 9375aee7dae4Smrg # If a -bindir argument was supplied, place the dll there. 9376aee7dae4Smrg if test "x$bindir" != x ; 9377aee7dae4Smrg then 9378aee7dae4Smrg func_relative_path "$install_libdir" "$bindir" 9379aee7dae4Smrg tdlname=$func_relative_path_result$dlname 9380aee7dae4Smrg else 9381aee7dae4Smrg # Otherwise fall back on heuristic. 9382aee7dae4Smrg tdlname=../bin/$dlname 9383aee7dae4Smrg fi 9384aee7dae4Smrg ;; 9385aee7dae4Smrg esac 9386aee7dae4Smrg $ECHO > $output "\ 9387aee7dae4Smrg# $outputname - a libtool library file 9388aee7dae4Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 9389aee7dae4Smrg# 9390aee7dae4Smrg# Please DO NOT delete this file! 9391aee7dae4Smrg# It is necessary for linking the library. 9392ba0eab60Smacallan 9393aee7dae4Smrg# The name that we can dlopen(3). 9394aee7dae4Smrgdlname='$tdlname' 9395ba0eab60Smacallan 9396aee7dae4Smrg# Names of this library. 9397aee7dae4Smrglibrary_names='$library_names' 9398ba0eab60Smacallan 9399aee7dae4Smrg# The name of the static archive. 9400aee7dae4Smrgold_library='$old_library' 9401ba0eab60Smacallan 9402aee7dae4Smrg# Linker flags that can not go in dependency_libs. 9403aee7dae4Smrginherited_linker_flags='$new_inherited_linker_flags' 9404ba0eab60Smacallan 9405aee7dae4Smrg# Libraries that this one depends upon. 9406aee7dae4Smrgdependency_libs='$dependency_libs' 9407ba0eab60Smacallan 9408aee7dae4Smrg# Names of additional weak libraries provided by this library 9409aee7dae4Smrgweak_library_names='$weak_libs' 9410ba0eab60Smacallan 9411aee7dae4Smrg# Version information for $libname. 9412aee7dae4Smrgcurrent=$current 9413aee7dae4Smrgage=$age 9414aee7dae4Smrgrevision=$revision 9415ba0eab60Smacallan 9416aee7dae4Smrg# Is this an already installed library? 9417aee7dae4Smrginstalled=$installed 9418ba0eab60Smacallan 9419aee7dae4Smrg# Should we warn about portability when linking against -modules? 9420aee7dae4Smrgshouldnotlink=$module 9421ba0eab60Smacallan 9422aee7dae4Smrg# Files to dlopen/dlpreopen 9423aee7dae4Smrgdlopen='$dlfiles' 9424aee7dae4Smrgdlpreopen='$dlprefiles' 9425ba0eab60Smacallan 9426aee7dae4Smrg# Directory that this library needs to be installed in: 9427aee7dae4Smrglibdir='$install_libdir'" 9428aee7dae4Smrg if test "$installed" = no && test "$need_relink" = yes; then 9429aee7dae4Smrg $ECHO >> $output "\ 9430aee7dae4Smrgrelink_command=\"$relink_command\"" 9431aee7dae4Smrg fi 9432aee7dae4Smrg done 9433aee7dae4Smrg } 9434ba0eab60Smacallan 9435aee7dae4Smrg # Do a symbolic link so that the libtool archive can be found in 9436aee7dae4Smrg # LD_LIBRARY_PATH before the program is installed. 9437aee7dae4Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 9438aee7dae4Smrg ;; 9439aee7dae4Smrg esac 9440aee7dae4Smrg exit $EXIT_SUCCESS 9441aee7dae4Smrg} 9442ba0eab60Smacallan 9443aee7dae4Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 9444aee7dae4Smrg func_mode_link ${1+"$@"} 9445ba0eab60Smacallan 9446ba0eab60Smacallan 9447aee7dae4Smrg# func_mode_uninstall arg... 9448aee7dae4Smrgfunc_mode_uninstall () 9449aee7dae4Smrg{ 9450aee7dae4Smrg $opt_debug 9451aee7dae4Smrg RM="$nonopt" 9452ba0eab60Smacallan files= 9453ba0eab60Smacallan rmforce= 9454ba0eab60Smacallan exit_status=0 9455ba0eab60Smacallan 9456ba0eab60Smacallan # This variable tells wrapper scripts just to set variables rather 9457ba0eab60Smacallan # than running their programs. 9458ba0eab60Smacallan libtool_install_magic="$magic" 9459ba0eab60Smacallan 9460ba0eab60Smacallan for arg 9461ba0eab60Smacallan do 9462ba0eab60Smacallan case $arg in 9463aee7dae4Smrg -f) func_append RM " $arg"; rmforce=yes ;; 9464aee7dae4Smrg -*) func_append RM " $arg" ;; 9465aee7dae4Smrg *) func_append files " $arg" ;; 9466ba0eab60Smacallan esac 9467ba0eab60Smacallan done 9468ba0eab60Smacallan 9469aee7dae4Smrg test -z "$RM" && \ 9470aee7dae4Smrg func_fatal_help "you must specify an RM program" 9471ba0eab60Smacallan 9472ba0eab60Smacallan rmdirs= 9473ba0eab60Smacallan 9474ba0eab60Smacallan for file in $files; do 9475aee7dae4Smrg func_dirname "$file" "" "." 9476aee7dae4Smrg dir="$func_dirname_result" 9477aee7dae4Smrg if test "X$dir" = X.; then 9478aee7dae4Smrg odir="$objdir" 9479ba0eab60Smacallan else 9480aee7dae4Smrg odir="$dir/$objdir" 9481ba0eab60Smacallan fi 9482aee7dae4Smrg func_basename "$file" 9483aee7dae4Smrg name="$func_basename_result" 9484aee7dae4Smrg test "$opt_mode" = uninstall && odir="$dir" 9485ba0eab60Smacallan 9486aee7dae4Smrg # Remember odir for removal later, being careful to avoid duplicates 9487aee7dae4Smrg if test "$opt_mode" = clean; then 9488ba0eab60Smacallan case " $rmdirs " in 9489aee7dae4Smrg *" $odir "*) ;; 9490aee7dae4Smrg *) func_append rmdirs " $odir" ;; 9491ba0eab60Smacallan esac 9492ba0eab60Smacallan fi 9493ba0eab60Smacallan 9494ba0eab60Smacallan # Don't error if the file doesn't exist and rm -f was used. 9495aee7dae4Smrg if { test -L "$file"; } >/dev/null 2>&1 || 9496aee7dae4Smrg { test -h "$file"; } >/dev/null 2>&1 || 9497aee7dae4Smrg test -f "$file"; then 9498ba0eab60Smacallan : 9499ba0eab60Smacallan elif test -d "$file"; then 9500ba0eab60Smacallan exit_status=1 9501ba0eab60Smacallan continue 9502ba0eab60Smacallan elif test "$rmforce" = yes; then 9503ba0eab60Smacallan continue 9504ba0eab60Smacallan fi 9505ba0eab60Smacallan 9506ba0eab60Smacallan rmfiles="$file" 9507ba0eab60Smacallan 9508ba0eab60Smacallan case $name in 9509ba0eab60Smacallan *.la) 9510ba0eab60Smacallan # Possibly a libtool archive, so verify it. 9511aee7dae4Smrg if func_lalib_p "$file"; then 9512aee7dae4Smrg func_source $dir/$name 9513ba0eab60Smacallan 9514ba0eab60Smacallan # Delete the libtool libraries and symlinks. 9515ba0eab60Smacallan for n in $library_names; do 9516aee7dae4Smrg func_append rmfiles " $odir/$n" 9517ba0eab60Smacallan done 9518aee7dae4Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9519ba0eab60Smacallan 9520aee7dae4Smrg case "$opt_mode" in 9521ba0eab60Smacallan clean) 9522aee7dae4Smrg case " $library_names " in 9523ba0eab60Smacallan *" $dlname "*) ;; 9524aee7dae4Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9525ba0eab60Smacallan esac 9526aee7dae4Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9527ba0eab60Smacallan ;; 9528ba0eab60Smacallan uninstall) 9529ba0eab60Smacallan if test -n "$library_names"; then 9530ba0eab60Smacallan # Do each command in the postuninstall commands. 9531aee7dae4Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9532ba0eab60Smacallan fi 9533ba0eab60Smacallan 9534ba0eab60Smacallan if test -n "$old_library"; then 9535ba0eab60Smacallan # Do each command in the old_postuninstall commands. 9536aee7dae4Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9537ba0eab60Smacallan fi 9538ba0eab60Smacallan # FIXME: should reinstall the best remaining shared library. 9539ba0eab60Smacallan ;; 9540ba0eab60Smacallan esac 9541ba0eab60Smacallan fi 9542ba0eab60Smacallan ;; 9543ba0eab60Smacallan 9544ba0eab60Smacallan *.lo) 9545ba0eab60Smacallan # Possibly a libtool object, so verify it. 9546aee7dae4Smrg if func_lalib_p "$file"; then 9547ba0eab60Smacallan 9548ba0eab60Smacallan # Read the .lo file 9549aee7dae4Smrg func_source $dir/$name 9550ba0eab60Smacallan 9551ba0eab60Smacallan # Add PIC object to the list of files to remove. 9552aee7dae4Smrg if test -n "$pic_object" && 9553aee7dae4Smrg test "$pic_object" != none; then 9554aee7dae4Smrg func_append rmfiles " $dir/$pic_object" 9555ba0eab60Smacallan fi 9556ba0eab60Smacallan 9557ba0eab60Smacallan # Add non-PIC object to the list of files to remove. 9558aee7dae4Smrg if test -n "$non_pic_object" && 9559aee7dae4Smrg test "$non_pic_object" != none; then 9560aee7dae4Smrg func_append rmfiles " $dir/$non_pic_object" 9561ba0eab60Smacallan fi 9562ba0eab60Smacallan fi 9563ba0eab60Smacallan ;; 9564ba0eab60Smacallan 9565ba0eab60Smacallan *) 9566aee7dae4Smrg if test "$opt_mode" = clean ; then 9567ba0eab60Smacallan noexename=$name 9568ba0eab60Smacallan case $file in 9569ba0eab60Smacallan *.exe) 9570aee7dae4Smrg func_stripname '' '.exe' "$file" 9571aee7dae4Smrg file=$func_stripname_result 9572aee7dae4Smrg func_stripname '' '.exe' "$name" 9573aee7dae4Smrg noexename=$func_stripname_result 9574ba0eab60Smacallan # $file with .exe has already been added to rmfiles, 9575ba0eab60Smacallan # add $file without .exe 9576aee7dae4Smrg func_append rmfiles " $file" 9577ba0eab60Smacallan ;; 9578ba0eab60Smacallan esac 9579ba0eab60Smacallan # Do a test to see if this is a libtool program. 9580aee7dae4Smrg if func_ltwrapper_p "$file"; then 9581aee7dae4Smrg if func_ltwrapper_executable_p "$file"; then 9582aee7dae4Smrg func_ltwrapper_scriptname "$file" 9583aee7dae4Smrg relink_command= 9584aee7dae4Smrg func_source $func_ltwrapper_scriptname_result 9585aee7dae4Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 9586aee7dae4Smrg else 9587aee7dae4Smrg relink_command= 9588aee7dae4Smrg func_source $dir/$noexename 9589aee7dae4Smrg fi 9590ba0eab60Smacallan 9591ba0eab60Smacallan # note $name still contains .exe if it was in $file originally 9592ba0eab60Smacallan # as does the version of $file that was added into $rmfiles 9593aee7dae4Smrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9594ba0eab60Smacallan if test "$fast_install" = yes && test -n "$relink_command"; then 9595aee7dae4Smrg func_append rmfiles " $odir/lt-$name" 9596ba0eab60Smacallan fi 9597ba0eab60Smacallan if test "X$noexename" != "X$name" ; then 9598aee7dae4Smrg func_append rmfiles " $odir/lt-${noexename}.c" 9599ba0eab60Smacallan fi 9600ba0eab60Smacallan fi 9601ba0eab60Smacallan fi 9602ba0eab60Smacallan ;; 9603ba0eab60Smacallan esac 9604aee7dae4Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 9605ba0eab60Smacallan done 9606ba0eab60Smacallan 9607ba0eab60Smacallan # Try to remove the ${objdir}s in the directories where we deleted files 9608ba0eab60Smacallan for dir in $rmdirs; do 9609ba0eab60Smacallan if test -d "$dir"; then 9610aee7dae4Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 9611ba0eab60Smacallan fi 9612ba0eab60Smacallan done 9613ba0eab60Smacallan 9614ba0eab60Smacallan exit $exit_status 9615aee7dae4Smrg} 9616ba0eab60Smacallan 9617aee7dae4Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 9618aee7dae4Smrg func_mode_uninstall ${1+"$@"} 9619ba0eab60Smacallan 9620aee7dae4Smrgtest -z "$opt_mode" && { 9621aee7dae4Smrg help="$generic_help" 9622aee7dae4Smrg func_fatal_help "you must specify a MODE" 9623aee7dae4Smrg} 9624aee7dae4Smrg 9625aee7dae4Smrgtest -z "$exec_cmd" && \ 9626aee7dae4Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 9627ba0eab60Smacallan 9628ba0eab60Smacallanif test -n "$exec_cmd"; then 9629aee7dae4Smrg eval exec "$exec_cmd" 9630ba0eab60Smacallan exit $EXIT_FAILURE 9631ba0eab60Smacallanfi 9632ba0eab60Smacallan 9633aee7dae4Smrgexit $exit_status 9634ba0eab60Smacallan 9635ba0eab60Smacallan 9636ba0eab60Smacallan# The TAGs below are defined such that we never get into a situation 9637ba0eab60Smacallan# in which we disable both kinds of libraries. Given conflicting 9638ba0eab60Smacallan# choices, we go for a static library, that is the most portable, 9639ba0eab60Smacallan# since we can't tell whether shared libraries were disabled because 9640ba0eab60Smacallan# the user asked for that or because the platform doesn't support 9641ba0eab60Smacallan# them. This is particularly important on AIX, because we don't 9642ba0eab60Smacallan# support having both static and shared libraries enabled at the same 9643ba0eab60Smacallan# time on that platform, so we default to a shared-only configuration. 9644ba0eab60Smacallan# If a disable-shared tag is given, we'll fallback to a static-only 9645ba0eab60Smacallan# configuration. But we'll never go from static-only to shared-only. 9646ba0eab60Smacallan 9647ba0eab60Smacallan# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 9648aee7dae4Smrgbuild_libtool_libs=no 9649aee7dae4Smrgbuild_old_libs=yes 9650ba0eab60Smacallan# ### END LIBTOOL TAG CONFIG: disable-shared 9651ba0eab60Smacallan 9652ba0eab60Smacallan# ### BEGIN LIBTOOL TAG CONFIG: disable-static 9653aee7dae4Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9654ba0eab60Smacallan# ### END LIBTOOL TAG CONFIG: disable-static 9655ba0eab60Smacallan 9656ba0eab60Smacallan# Local Variables: 9657ba0eab60Smacallan# mode:shell-script 9658ba0eab60Smacallan# sh-indentation:2 9659ba0eab60Smacallan# End: 9660aee7dae4Smrg# vi:sw=2 9661aee7dae4Smrg 9662