1243750Srwatson 2243750Srwatson# libtool (GNU libtool) 2.4.2 3243750Srwatson# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 4243750Srwatson 5173143Srwatson# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 6243750Srwatson# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 7243750Srwatson# This is free software; see the source for copying conditions. There is NO 8243750Srwatson# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9243750Srwatson 10243750Srwatson# GNU Libtool is free software; you can redistribute it and/or modify 11156283Srwatson# it under the terms of the GNU General Public License as published by 12156283Srwatson# the Free Software Foundation; either version 2 of the License, or 13156283Srwatson# (at your option) any later version. 14156283Srwatson# 15243750Srwatson# As a special exception to the GNU General Public License, 16243750Srwatson# if you distribute this file as part of a program or library that 17243750Srwatson# is built using GNU Libtool, you may include this file under the 18243750Srwatson# same distribution terms that you use for the rest of that program. 19243750Srwatson# 20243750Srwatson# GNU Libtool is distributed in the hope that it will be useful, but 21156283Srwatson# WITHOUT ANY WARRANTY; without even the implied warranty of 22156283Srwatson# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23156283Srwatson# General Public License for more details. 24156283Srwatson# 25156283Srwatson# You should have received a copy of the GNU General Public License 26243750Srwatson# along with GNU Libtool; see the file COPYING. If not, a copy 27243750Srwatson# can be downloaded from http://www.gnu.org/licenses/gpl.html, 28243750Srwatson# or obtained by writing to the Free Software Foundation, Inc., 29243750Srwatson# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30243750Srwatson 31243750Srwatson# Usage: $progname [OPTION]... [MODE-ARG]... 32156283Srwatson# 33243750Srwatson# Provide generalized library-building support services. 34243750Srwatson# 35243750Srwatson# --config show all configuration variables 36243750Srwatson# --debug enable verbose shell tracing 37243750Srwatson# -n, --dry-run display commands without modifying any files 38243750Srwatson# --features display basic configuration information and exit 39243750Srwatson# --mode=MODE use operation mode MODE 40243750Srwatson# --preserve-dup-deps don't remove duplicate dependency libraries 41243750Srwatson# --quiet, --silent don't print informational messages 42243750Srwatson# --no-quiet, --no-silent 43243750Srwatson# print informational messages (default) 44243750Srwatson# --no-warn don't display warning messages 45243750Srwatson# --tag=TAG use configuration variables from tag TAG 46243750Srwatson# -v, --verbose print more informational messages than default 47243750Srwatson# --no-verbose don't print the extra informational messages 48243750Srwatson# --version print version information 49243750Srwatson# -h, --help, --help-all print short, long, or detailed help message 50243750Srwatson# 51243750Srwatson# MODE must be one of the following: 52243750Srwatson# 53243750Srwatson# clean remove files from the build directory 54243750Srwatson# compile compile a source file into a libtool object 55243750Srwatson# execute automatically set library path, then run a program 56243750Srwatson# finish complete the installation of libtool libraries 57243750Srwatson# install install libraries or executables 58243750Srwatson# link create a library or an executable 59243750Srwatson# uninstall remove libraries from an installed directory 60243750Srwatson# 61243750Srwatson# MODE-ARGS vary depending on the MODE. When passed as first option, 62243750Srwatson# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 63243750Srwatson# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 64243750Srwatson# 65243750Srwatson# When reporting a bug, please describe a test case to reproduce it and 66243750Srwatson# include the following information: 67243750Srwatson# 68243750Srwatson# host-triplet: $host 69243750Srwatson# shell: $SHELL 70243750Srwatson# compiler: $LTCC 71243750Srwatson# compiler flags: $LTCFLAGS 72243750Srwatson# linker: $LD (gnu? $with_gnu_ld) 73243750Srwatson# $progname: (GNU libtool) 2.4.2 74243750Srwatson# automake: $automake_version 75243750Srwatson# autoconf: $autoconf_version 76243750Srwatson# 77243750Srwatson# Report bugs to <bug-libtool@gnu.org>. 78243750Srwatson# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 79243750Srwatson# General help using GNU software: <http://www.gnu.org/gethelp/>. 80156283Srwatson 81243750SrwatsonPROGRAM=libtool 82156283SrwatsonPACKAGE=libtool 83243750SrwatsonVERSION=2.4.2 84243750SrwatsonTIMESTAMP="" 85243750Srwatsonpackage_revision=1.3337 86156283Srwatson 87243750Srwatson# Be Bourne compatible 88173143Srwatsonif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 89173143Srwatson emulate sh 90173143Srwatson NULLCMD=: 91173143Srwatson # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 92173143Srwatson # is contrary to our usage. Disable this feature. 93173143Srwatson alias -g '${1+"$@"}'='"$@"' 94156283Srwatson setopt NO_GLOB_SUBST 95173143Srwatsonelse 96173143Srwatson case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 97156283Srwatsonfi 98173143SrwatsonBIN_SH=xpg4; export BIN_SH # for Tru64 99173143SrwatsonDUALCASE=1; export DUALCASE # for MKS sh 100156283Srwatson 101243750Srwatson# A function that is used when there is no print builtin or printf. 102243750Srwatsonfunc_fallback_echo () 103243750Srwatson{ 104243750Srwatson eval 'cat <<_LTECHO_EOF 105243750Srwatson$1 106243750Srwatson_LTECHO_EOF' 107243750Srwatson} 108156283Srwatson 109243750Srwatson# NLS nuisances: We save the old values to restore during execute mode. 110243750Srwatsonlt_user_locale= 111243750Srwatsonlt_safe_locale= 112191273Srwatsonfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 113173143Srwatsondo 114173143Srwatson eval "if test \"\${$lt_var+set}\" = set; then 115243750Srwatson save_$lt_var=\$$lt_var 116243750Srwatson $lt_var=C 117173143Srwatson export $lt_var 118243750Srwatson lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 119243750Srwatson lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 120173143Srwatson fi" 121173143Srwatsondone 122243750SrwatsonLC_ALL=C 123243750SrwatsonLANGUAGE=C 124243750Srwatsonexport LANGUAGE LC_ALL 125156283Srwatson 126243750Srwatson$lt_unset CDPATH 127191273Srwatson 128243750Srwatson 129243750Srwatson# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 130243750Srwatson# is ksh but when the shell is invoked as "sh" and the current value of 131243750Srwatson# the _XPG environment variable is not equal to 1 (one), the special 132243750Srwatson# positional parameter $0, within a function call, is the name of the 133243750Srwatson# function. 134243750Srwatsonprogpath="$0" 135243750Srwatson 136243750Srwatson 137243750Srwatson 138243750Srwatson: ${CP="cp -f"} 139243750Srwatsontest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 140243750Srwatson: ${MAKE="make"} 141243750Srwatson: ${MKDIR="mkdir"} 142243750Srwatson: ${MV="mv -f"} 143243750Srwatson: ${RM="rm -f"} 144243750Srwatson: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 145243750Srwatson: ${Xsed="$SED -e 1s/^X//"} 146243750Srwatson 147243750Srwatson# Global variables: 148243750SrwatsonEXIT_SUCCESS=0 149243750SrwatsonEXIT_FAILURE=1 150243750SrwatsonEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 151243750SrwatsonEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 152243750Srwatson 153243750Srwatsonexit_status=$EXIT_SUCCESS 154243750Srwatson 155156283Srwatson# Make sure IFS has a sensible default 156156283Srwatsonlt_nl=' 157156283Srwatson' 158156283SrwatsonIFS=" $lt_nl" 159156283Srwatson 160243750Srwatsondirname="s,/[^/]*$,," 161243750Srwatsonbasename="s,^.*/,," 162156283Srwatson 163243750Srwatson# func_dirname file append nondir_replacement 164243750Srwatson# Compute the dirname of FILE. If nonempty, add APPEND to the result, 165243750Srwatson# otherwise set result to NONDIR_REPLACEMENT. 166243750Srwatsonfunc_dirname () 167243750Srwatson{ 168243750Srwatson func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 169243750Srwatson if test "X$func_dirname_result" = "X${1}"; then 170243750Srwatson func_dirname_result="${3}" 171243750Srwatson else 172243750Srwatson func_dirname_result="$func_dirname_result${2}" 173243750Srwatson fi 174243750Srwatson} # func_dirname may be replaced by extended shell implementation 175156283Srwatson 176156283Srwatson 177243750Srwatson# func_basename file 178243750Srwatsonfunc_basename () 179243750Srwatson{ 180243750Srwatson func_basename_result=`$ECHO "${1}" | $SED "$basename"` 181243750Srwatson} # func_basename may be replaced by extended shell implementation 182243750Srwatson 183243750Srwatson 184243750Srwatson# func_dirname_and_basename file append nondir_replacement 185243750Srwatson# perform func_basename and func_dirname in a single function 186243750Srwatson# call: 187243750Srwatson# dirname: Compute the dirname of FILE. If nonempty, 188243750Srwatson# add APPEND to the result, otherwise set result 189243750Srwatson# to NONDIR_REPLACEMENT. 190243750Srwatson# value returned in "$func_dirname_result" 191243750Srwatson# basename: Compute filename of FILE. 192243750Srwatson# value retuned in "$func_basename_result" 193243750Srwatson# Implementation must be kept synchronized with func_dirname 194243750Srwatson# and func_basename. For efficiency, we do not delegate to 195243750Srwatson# those functions but instead duplicate the functionality here. 196243750Srwatsonfunc_dirname_and_basename () 197243750Srwatson{ 198243750Srwatson # Extract subdirectory from the argument. 199243750Srwatson func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 200243750Srwatson if test "X$func_dirname_result" = "X${1}"; then 201243750Srwatson func_dirname_result="${3}" 202243750Srwatson else 203243750Srwatson func_dirname_result="$func_dirname_result${2}" 204243750Srwatson fi 205243750Srwatson func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 206243750Srwatson} # func_dirname_and_basename may be replaced by extended shell implementation 207243750Srwatson 208243750Srwatson 209243750Srwatson# func_stripname prefix suffix name 210243750Srwatson# strip PREFIX and SUFFIX off of NAME. 211243750Srwatson# PREFIX and SUFFIX must not contain globbing or regex special 212243750Srwatson# characters, hashes, percent signs, but SUFFIX may contain a leading 213243750Srwatson# dot (in which case that matches only a dot). 214243750Srwatson# func_strip_suffix prefix name 215243750Srwatsonfunc_stripname () 216243750Srwatson{ 217243750Srwatson case ${2} in 218243750Srwatson .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 219243750Srwatson *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 220243750Srwatson esac 221243750Srwatson} # func_stripname may be replaced by extended shell implementation 222243750Srwatson 223243750Srwatson 224243750Srwatson# These SED scripts presuppose an absolute path with a trailing slash. 225243750Srwatsonpathcar='s,^/\([^/]*\).*$,\1,' 226243750Srwatsonpathcdr='s,^/[^/]*,,' 227243750Srwatsonremovedotparts=':dotsl 228243750Srwatson s@/\./@/@g 229243750Srwatson t dotsl 230243750Srwatson s,/\.$,/,' 231243750Srwatsoncollapseslashes='s@/\{1,\}@/@g' 232243750Srwatsonfinalslash='s,/*$,/,' 233243750Srwatson 234243750Srwatson# func_normal_abspath PATH 235243750Srwatson# Remove doubled-up and trailing slashes, "." path components, 236243750Srwatson# and cancel out any ".." path components in PATH after making 237243750Srwatson# it an absolute path. 238243750Srwatson# value returned in "$func_normal_abspath_result" 239243750Srwatsonfunc_normal_abspath () 240243750Srwatson{ 241243750Srwatson # Start from root dir and reassemble the path. 242243750Srwatson func_normal_abspath_result= 243243750Srwatson func_normal_abspath_tpath=$1 244243750Srwatson func_normal_abspath_altnamespace= 245243750Srwatson case $func_normal_abspath_tpath in 246243750Srwatson "") 247243750Srwatson # Empty path, that just means $cwd. 248243750Srwatson func_stripname '' '/' "`pwd`" 249243750Srwatson func_normal_abspath_result=$func_stripname_result 250243750Srwatson return 251243750Srwatson ;; 252243750Srwatson # The next three entries are used to spot a run of precisely 253243750Srwatson # two leading slashes without using negated character classes; 254243750Srwatson # we take advantage of case's first-match behaviour. 255243750Srwatson ///*) 256243750Srwatson # Unusual form of absolute path, do nothing. 257243750Srwatson ;; 258243750Srwatson //*) 259243750Srwatson # Not necessarily an ordinary path; POSIX reserves leading '//' 260243750Srwatson # and for example Cygwin uses it to access remote file shares 261243750Srwatson # over CIFS/SMB, so we conserve a leading double slash if found. 262243750Srwatson func_normal_abspath_altnamespace=/ 263243750Srwatson ;; 264243750Srwatson /*) 265243750Srwatson # Absolute path, do nothing. 266243750Srwatson ;; 267243750Srwatson *) 268243750Srwatson # Relative path, prepend $cwd. 269243750Srwatson func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 270243750Srwatson ;; 271243750Srwatson esac 272243750Srwatson # Cancel out all the simple stuff to save iterations. We also want 273243750Srwatson # the path to end with a slash for ease of parsing, so make sure 274243750Srwatson # there is one (and only one) here. 275243750Srwatson func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 276243750Srwatson -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 277243750Srwatson while :; do 278243750Srwatson # Processed it all yet? 279243750Srwatson if test "$func_normal_abspath_tpath" = / ; then 280243750Srwatson # If we ascended to the root using ".." the result may be empty now. 281243750Srwatson if test -z "$func_normal_abspath_result" ; then 282243750Srwatson func_normal_abspath_result=/ 283243750Srwatson fi 284243750Srwatson break 285243750Srwatson fi 286243750Srwatson func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 287243750Srwatson -e "$pathcar"` 288243750Srwatson func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 289243750Srwatson -e "$pathcdr"` 290243750Srwatson # Figure out what to do with it 291243750Srwatson case $func_normal_abspath_tcomponent in 292243750Srwatson "") 293243750Srwatson # Trailing empty path component, ignore it. 294243750Srwatson ;; 295243750Srwatson ..) 296243750Srwatson # Parent dir; strip last assembled component from result. 297243750Srwatson func_dirname "$func_normal_abspath_result" 298243750Srwatson func_normal_abspath_result=$func_dirname_result 299243750Srwatson ;; 300243750Srwatson *) 301243750Srwatson # Actual path component, append it. 302243750Srwatson func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 303243750Srwatson ;; 304243750Srwatson esac 305243750Srwatson done 306243750Srwatson # Restore leading double-slash if one was found on entry. 307243750Srwatson func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 308243750Srwatson} 309243750Srwatson 310243750Srwatson# func_relative_path SRCDIR DSTDIR 311243750Srwatson# generates a relative path from SRCDIR to DSTDIR, with a trailing 312243750Srwatson# slash if non-empty, suitable for immediately appending a filename 313243750Srwatson# without needing to append a separator. 314243750Srwatson# value returned in "$func_relative_path_result" 315243750Srwatsonfunc_relative_path () 316243750Srwatson{ 317243750Srwatson func_relative_path_result= 318243750Srwatson func_normal_abspath "$1" 319243750Srwatson func_relative_path_tlibdir=$func_normal_abspath_result 320243750Srwatson func_normal_abspath "$2" 321243750Srwatson func_relative_path_tbindir=$func_normal_abspath_result 322243750Srwatson 323243750Srwatson # Ascend the tree starting from libdir 324243750Srwatson while :; do 325243750Srwatson # check if we have found a prefix of bindir 326243750Srwatson case $func_relative_path_tbindir in 327243750Srwatson $func_relative_path_tlibdir) 328243750Srwatson # found an exact match 329243750Srwatson func_relative_path_tcancelled= 330243750Srwatson break 331243750Srwatson ;; 332243750Srwatson $func_relative_path_tlibdir*) 333243750Srwatson # found a matching prefix 334243750Srwatson func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 335243750Srwatson func_relative_path_tcancelled=$func_stripname_result 336243750Srwatson if test -z "$func_relative_path_result"; then 337243750Srwatson func_relative_path_result=. 338243750Srwatson fi 339243750Srwatson break 340243750Srwatson ;; 341243750Srwatson *) 342243750Srwatson func_dirname $func_relative_path_tlibdir 343243750Srwatson func_relative_path_tlibdir=${func_dirname_result} 344243750Srwatson if test "x$func_relative_path_tlibdir" = x ; then 345243750Srwatson # Have to descend all the way to the root! 346243750Srwatson func_relative_path_result=../$func_relative_path_result 347243750Srwatson func_relative_path_tcancelled=$func_relative_path_tbindir 348243750Srwatson break 349243750Srwatson fi 350243750Srwatson func_relative_path_result=../$func_relative_path_result 351243750Srwatson ;; 352243750Srwatson esac 353243750Srwatson done 354243750Srwatson 355243750Srwatson # Now calculate path; take care to avoid doubling-up slashes. 356243750Srwatson func_stripname '' '/' "$func_relative_path_result" 357243750Srwatson func_relative_path_result=$func_stripname_result 358243750Srwatson func_stripname '/' '/' "$func_relative_path_tcancelled" 359243750Srwatson if test "x$func_stripname_result" != x ; then 360243750Srwatson func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 361243750Srwatson fi 362243750Srwatson 363243750Srwatson # Normalisation. If bindir is libdir, return empty string, 364243750Srwatson # else relative path ending with a slash; either way, target 365243750Srwatson # file name can be directly appended. 366243750Srwatson if test ! -z "$func_relative_path_result"; then 367243750Srwatson func_stripname './' '' "$func_relative_path_result/" 368243750Srwatson func_relative_path_result=$func_stripname_result 369243750Srwatson fi 370243750Srwatson} 371243750Srwatson 372243750Srwatson# The name of this program: 373243750Srwatsonfunc_dirname_and_basename "$progpath" 374243750Srwatsonprogname=$func_basename_result 375243750Srwatson 376243750Srwatson# Make sure we have an absolute path for reexecution: 377243750Srwatsoncase $progpath in 378243750Srwatson [\\/]*|[A-Za-z]:\\*) ;; 379243750Srwatson *[\\/]*) 380243750Srwatson progdir=$func_dirname_result 381243750Srwatson progdir=`cd "$progdir" && pwd` 382243750Srwatson progpath="$progdir/$progname" 383243750Srwatson ;; 384243750Srwatson *) 385243750Srwatson save_IFS="$IFS" 386243750Srwatson IFS=${PATH_SEPARATOR-:} 387243750Srwatson for progdir in $PATH; do 388243750Srwatson IFS="$save_IFS" 389243750Srwatson test -x "$progdir/$progname" && break 390243750Srwatson done 391243750Srwatson IFS="$save_IFS" 392243750Srwatson test -n "$progdir" || progdir=`pwd` 393243750Srwatson progpath="$progdir/$progname" 394243750Srwatson ;; 395243750Srwatsonesac 396243750Srwatson 397243750Srwatson# Sed substitution that helps us do robust quoting. It backslashifies 398243750Srwatson# metacharacters that are still active within double-quoted strings. 399243750SrwatsonXsed="${SED}"' -e 1s/^X//' 400243750Srwatsonsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 401243750Srwatson 402243750Srwatson# Same as above, but do not quote variable references. 403243750Srwatsondouble_quote_subst='s/\(["`\\]\)/\\\1/g' 404243750Srwatson 405243750Srwatson# Sed substitution that turns a string into a regex matching for the 406243750Srwatson# string literally. 407243750Srwatsonsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 408243750Srwatson 409243750Srwatson# Sed substitution that converts a w32 file name or path 410243750Srwatson# which contains forward slashes, into one that contains 411243750Srwatson# (escaped) backslashes. A very naive implementation. 412243750Srwatsonlt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 413243750Srwatson 414243750Srwatson# Re-`\' parameter expansions in output of double_quote_subst that were 415243750Srwatson# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 416243750Srwatson# in input to double_quote_subst, that '$' was protected from expansion. 417243750Srwatson# Since each input `\' is now two `\'s, look for any number of runs of 418243750Srwatson# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 419243750Srwatsonbs='\\' 420243750Srwatsonbs2='\\\\' 421243750Srwatsonbs4='\\\\\\\\' 422243750Srwatsondollar='\$' 423243750Srwatsonsed_double_backslash="\ 424243750Srwatson s/$bs4/&\\ 425243750Srwatson/g 426243750Srwatson s/^$bs2$dollar/$bs&/ 427243750Srwatson s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 428243750Srwatson s/\n//g" 429243750Srwatson 430243750Srwatson# Standard options: 431243750Srwatsonopt_dry_run=false 432243750Srwatsonopt_help=false 433243750Srwatsonopt_quiet=false 434243750Srwatsonopt_verbose=false 435243750Srwatsonopt_warning=: 436243750Srwatson 437243750Srwatson# func_echo arg... 438243750Srwatson# Echo program name prefixed message, along with the current mode 439243750Srwatson# name if it has been set yet. 440243750Srwatsonfunc_echo () 441243750Srwatson{ 442243750Srwatson $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 443243750Srwatson} 444243750Srwatson 445243750Srwatson# func_verbose arg... 446243750Srwatson# Echo program name prefixed message in verbose mode only. 447243750Srwatsonfunc_verbose () 448243750Srwatson{ 449243750Srwatson $opt_verbose && func_echo ${1+"$@"} 450243750Srwatson 451243750Srwatson # A bug in bash halts the script if the last line of a function 452243750Srwatson # fails when set -e is in force, so we need another command to 453243750Srwatson # work around that: 454243750Srwatson : 455243750Srwatson} 456243750Srwatson 457243750Srwatson# func_echo_all arg... 458243750Srwatson# Invoke $ECHO with all args, space-separated. 459243750Srwatsonfunc_echo_all () 460243750Srwatson{ 461243750Srwatson $ECHO "$*" 462243750Srwatson} 463243750Srwatson 464243750Srwatson# func_error arg... 465243750Srwatson# Echo program name prefixed message to standard error. 466243750Srwatsonfunc_error () 467243750Srwatson{ 468243750Srwatson $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 469243750Srwatson} 470243750Srwatson 471243750Srwatson# func_warning arg... 472243750Srwatson# Echo program name prefixed warning message to standard error. 473243750Srwatsonfunc_warning () 474243750Srwatson{ 475243750Srwatson $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 476243750Srwatson 477243750Srwatson # bash bug again: 478243750Srwatson : 479243750Srwatson} 480243750Srwatson 481243750Srwatson# func_fatal_error arg... 482243750Srwatson# Echo program name prefixed message to standard error, and exit. 483243750Srwatsonfunc_fatal_error () 484243750Srwatson{ 485243750Srwatson func_error ${1+"$@"} 486243750Srwatson exit $EXIT_FAILURE 487243750Srwatson} 488243750Srwatson 489243750Srwatson# func_fatal_help arg... 490243750Srwatson# Echo program name prefixed message to standard error, followed by 491243750Srwatson# a help hint, and exit. 492243750Srwatsonfunc_fatal_help () 493243750Srwatson{ 494243750Srwatson func_error ${1+"$@"} 495243750Srwatson func_fatal_error "$help" 496243750Srwatson} 497243750Srwatsonhelp="Try \`$progname --help' for more information." ## default 498243750Srwatson 499243750Srwatson 500243750Srwatson# func_grep expression filename 501243750Srwatson# Check whether EXPRESSION matches any line of FILENAME, without output. 502243750Srwatsonfunc_grep () 503243750Srwatson{ 504243750Srwatson $GREP "$1" "$2" >/dev/null 2>&1 505243750Srwatson} 506243750Srwatson 507243750Srwatson 508243750Srwatson# func_mkdir_p directory-path 509243750Srwatson# Make sure the entire path to DIRECTORY-PATH is available. 510243750Srwatsonfunc_mkdir_p () 511243750Srwatson{ 512243750Srwatson my_directory_path="$1" 513243750Srwatson my_dir_list= 514243750Srwatson 515243750Srwatson if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 516243750Srwatson 517243750Srwatson # Protect directory names starting with `-' 518243750Srwatson case $my_directory_path in 519243750Srwatson -*) my_directory_path="./$my_directory_path" ;; 520243750Srwatson esac 521243750Srwatson 522243750Srwatson # While some portion of DIR does not yet exist... 523243750Srwatson while test ! -d "$my_directory_path"; do 524243750Srwatson # ...make a list in topmost first order. Use a colon delimited 525243750Srwatson # list incase some portion of path contains whitespace. 526243750Srwatson my_dir_list="$my_directory_path:$my_dir_list" 527243750Srwatson 528243750Srwatson # If the last portion added has no slash in it, the list is done 529243750Srwatson case $my_directory_path in */*) ;; *) break ;; esac 530243750Srwatson 531243750Srwatson # ...otherwise throw away the child directory and loop 532243750Srwatson my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 533243750Srwatson done 534243750Srwatson my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 535243750Srwatson 536243750Srwatson save_mkdir_p_IFS="$IFS"; IFS=':' 537243750Srwatson for my_dir in $my_dir_list; do 538243750Srwatson IFS="$save_mkdir_p_IFS" 539243750Srwatson # mkdir can fail with a `File exist' error if two processes 540243750Srwatson # try to create one of the directories concurrently. Don't 541243750Srwatson # stop in that case! 542243750Srwatson $MKDIR "$my_dir" 2>/dev/null || : 543243750Srwatson done 544243750Srwatson IFS="$save_mkdir_p_IFS" 545243750Srwatson 546243750Srwatson # Bail out if we (or some other process) failed to create a directory. 547243750Srwatson test -d "$my_directory_path" || \ 548243750Srwatson func_fatal_error "Failed to create \`$1'" 549243750Srwatson fi 550243750Srwatson} 551243750Srwatson 552243750Srwatson 553159985Srwatson# func_mktempdir [string] 554159985Srwatson# Make a temporary directory that won't clash with other running 555159985Srwatson# libtool processes, and avoids race conditions if possible. If 556159985Srwatson# given, STRING is the basename for that directory. 557159985Srwatsonfunc_mktempdir () 558159985Srwatson{ 559159985Srwatson my_template="${TMPDIR-/tmp}/${1-$progname}" 560159985Srwatson 561243750Srwatson if test "$opt_dry_run" = ":"; then 562159985Srwatson # Return a directory name, but don't create it in dry-run mode 563159985Srwatson my_tmpdir="${my_template}-$$" 564159985Srwatson else 565159985Srwatson 566159985Srwatson # If mktemp works, use that first and foremost 567159985Srwatson my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 568159985Srwatson 569159985Srwatson if test ! -d "$my_tmpdir"; then 570243750Srwatson # Failing that, at least try and use $RANDOM to avoid a race 571243750Srwatson my_tmpdir="${my_template}-${RANDOM-0}$$" 572159985Srwatson 573243750Srwatson save_mktempdir_umask=`umask` 574243750Srwatson umask 0077 575243750Srwatson $MKDIR "$my_tmpdir" 576243750Srwatson umask $save_mktempdir_umask 577159985Srwatson fi 578159985Srwatson 579159985Srwatson # If we're not in dry-run mode, bomb out on failure 580243750Srwatson test -d "$my_tmpdir" || \ 581243750Srwatson func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 582159985Srwatson fi 583159985Srwatson 584243750Srwatson $ECHO "$my_tmpdir" 585159985Srwatson} 586159985Srwatson 587159985Srwatson 588243750Srwatson# func_quote_for_eval arg 589243750Srwatson# Aesthetically quote ARG to be evaled later. 590243750Srwatson# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 591243750Srwatson# is double-quoted, suitable for a subsequent eval, whereas 592243750Srwatson# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 593243750Srwatson# which are still active within double quotes backslashified. 594243750Srwatsonfunc_quote_for_eval () 595156283Srwatson{ 596243750Srwatson case $1 in 597243750Srwatson *[\\\`\"\$]*) 598243750Srwatson func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 599243750Srwatson *) 600243750Srwatson func_quote_for_eval_unquoted_result="$1" ;; 601243750Srwatson esac 602243750Srwatson 603243750Srwatson case $func_quote_for_eval_unquoted_result in 604243750Srwatson # Double-quote args containing shell metacharacters to delay 605243750Srwatson # word splitting, command substitution and and variable 606243750Srwatson # expansion for a subsequent eval. 607243750Srwatson # Many Bourne shells cannot handle close brackets correctly 608243750Srwatson # in scan sets, so we specify it separately. 609243750Srwatson *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 610243750Srwatson func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 611243750Srwatson ;; 612243750Srwatson *) 613243750Srwatson func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 614243750Srwatson esac 615243750Srwatson} 616243750Srwatson 617243750Srwatson 618243750Srwatson# func_quote_for_expand arg 619243750Srwatson# Aesthetically quote ARG to be evaled later; same as above, 620243750Srwatson# but do not quote variable references. 621243750Srwatsonfunc_quote_for_expand () 622243750Srwatson{ 623243750Srwatson case $1 in 624243750Srwatson *[\\\`\"]*) 625243750Srwatson my_arg=`$ECHO "$1" | $SED \ 626243750Srwatson -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 627243750Srwatson *) 628243750Srwatson my_arg="$1" ;; 629243750Srwatson esac 630243750Srwatson 631243750Srwatson case $my_arg in 632243750Srwatson # Double-quote args containing shell metacharacters to delay 633243750Srwatson # word splitting and command substitution for a subsequent eval. 634243750Srwatson # Many Bourne shells cannot handle close brackets correctly 635243750Srwatson # in scan sets, so we specify it separately. 636243750Srwatson *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 637243750Srwatson my_arg="\"$my_arg\"" 638243750Srwatson ;; 639243750Srwatson esac 640243750Srwatson 641243750Srwatson func_quote_for_expand_result="$my_arg" 642243750Srwatson} 643243750Srwatson 644243750Srwatson 645243750Srwatson# func_show_eval cmd [fail_exp] 646243750Srwatson# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 647243750Srwatson# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 648243750Srwatson# is given, then evaluate it. 649243750Srwatsonfunc_show_eval () 650243750Srwatson{ 651243750Srwatson my_cmd="$1" 652243750Srwatson my_fail_exp="${2-:}" 653243750Srwatson 654243750Srwatson ${opt_silent-false} || { 655243750Srwatson func_quote_for_expand "$my_cmd" 656243750Srwatson eval "func_echo $func_quote_for_expand_result" 657243750Srwatson } 658243750Srwatson 659243750Srwatson if ${opt_dry_run-false}; then :; else 660243750Srwatson eval "$my_cmd" 661243750Srwatson my_status=$? 662243750Srwatson if test "$my_status" -eq 0; then :; else 663243750Srwatson eval "(exit $my_status); $my_fail_exp" 664243750Srwatson fi 665156283Srwatson fi 666243750Srwatson} 667243750Srwatson 668243750Srwatson 669243750Srwatson# func_show_eval_locale cmd [fail_exp] 670243750Srwatson# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 671243750Srwatson# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 672243750Srwatson# is given, then evaluate it. Use the saved locale for evaluation. 673243750Srwatsonfunc_show_eval_locale () 674243750Srwatson{ 675243750Srwatson my_cmd="$1" 676243750Srwatson my_fail_exp="${2-:}" 677243750Srwatson 678243750Srwatson ${opt_silent-false} || { 679243750Srwatson func_quote_for_expand "$my_cmd" 680243750Srwatson eval "func_echo $func_quote_for_expand_result" 681243750Srwatson } 682243750Srwatson 683243750Srwatson if ${opt_dry_run-false}; then :; else 684243750Srwatson eval "$lt_user_locale 685243750Srwatson $my_cmd" 686243750Srwatson my_status=$? 687243750Srwatson eval "$lt_safe_locale" 688243750Srwatson if test "$my_status" -eq 0; then :; else 689243750Srwatson eval "(exit $my_status); $my_fail_exp" 690243750Srwatson fi 691243750Srwatson fi 692243750Srwatson} 693243750Srwatson 694243750Srwatson# func_tr_sh 695243750Srwatson# Turn $1 into a string suitable for a shell variable name. 696243750Srwatson# Result is stored in $func_tr_sh_result. All characters 697243750Srwatson# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 698243750Srwatson# if $1 begins with a digit, a '_' is prepended as well. 699243750Srwatsonfunc_tr_sh () 700243750Srwatson{ 701243750Srwatson case $1 in 702243750Srwatson [0-9]* | *[!a-zA-Z0-9_]*) 703243750Srwatson func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 704156283Srwatson ;; 705243750Srwatson * ) 706243750Srwatson func_tr_sh_result=$1 707156283Srwatson ;; 708243750Srwatson esac 709243750Srwatson} 710243750Srwatson 711243750Srwatson 712243750Srwatson# func_version 713243750Srwatson# Echo version message to standard output and exit. 714243750Srwatsonfunc_version () 715243750Srwatson{ 716243750Srwatson $opt_debug 717243750Srwatson 718243750Srwatson $SED -n '/(C)/!b go 719243750Srwatson :more 720243750Srwatson /\./!{ 721243750Srwatson N 722243750Srwatson s/\n# / / 723243750Srwatson b more 724243750Srwatson } 725243750Srwatson :go 726243750Srwatson /^# '$PROGRAM' (GNU /,/# warranty; / { 727243750Srwatson s/^# // 728243750Srwatson s/^# *$// 729243750Srwatson s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 730243750Srwatson p 731243750Srwatson }' < "$progpath" 732243750Srwatson exit $? 733243750Srwatson} 734243750Srwatson 735243750Srwatson# func_usage 736243750Srwatson# Echo short help message to standard output and exit. 737243750Srwatsonfunc_usage () 738243750Srwatson{ 739243750Srwatson $opt_debug 740243750Srwatson 741243750Srwatson $SED -n '/^# Usage:/,/^# *.*--help/ { 742243750Srwatson s/^# // 743243750Srwatson s/^# *$// 744243750Srwatson s/\$progname/'$progname'/ 745243750Srwatson p 746243750Srwatson }' < "$progpath" 747243750Srwatson echo 748243750Srwatson $ECHO "run \`$progname --help | more' for full usage" 749243750Srwatson exit $? 750243750Srwatson} 751243750Srwatson 752243750Srwatson# func_help [NOEXIT] 753243750Srwatson# Echo long help message to standard output and exit, 754243750Srwatson# unless 'noexit' is passed as argument. 755243750Srwatsonfunc_help () 756243750Srwatson{ 757243750Srwatson $opt_debug 758243750Srwatson 759243750Srwatson $SED -n '/^# Usage:/,/# Report bugs to/ { 760243750Srwatson :print 761243750Srwatson s/^# // 762243750Srwatson s/^# *$// 763243750Srwatson s*\$progname*'$progname'* 764243750Srwatson s*\$host*'"$host"'* 765243750Srwatson s*\$SHELL*'"$SHELL"'* 766243750Srwatson s*\$LTCC*'"$LTCC"'* 767243750Srwatson s*\$LTCFLAGS*'"$LTCFLAGS"'* 768243750Srwatson s*\$LD*'"$LD"'* 769243750Srwatson s/\$with_gnu_ld/'"$with_gnu_ld"'/ 770243750Srwatson s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 771243750Srwatson s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 772243750Srwatson p 773243750Srwatson d 774243750Srwatson } 775243750Srwatson /^# .* home page:/b print 776243750Srwatson /^# General help using/b print 777243750Srwatson ' < "$progpath" 778243750Srwatson ret=$? 779243750Srwatson if test -z "$1"; then 780243750Srwatson exit $ret 781243750Srwatson fi 782243750Srwatson} 783243750Srwatson 784243750Srwatson# func_missing_arg argname 785243750Srwatson# Echo program name prefixed message to standard error and set global 786243750Srwatson# exit_cmd. 787243750Srwatsonfunc_missing_arg () 788243750Srwatson{ 789243750Srwatson $opt_debug 790243750Srwatson 791243750Srwatson func_error "missing argument for $1." 792243750Srwatson exit_cmd=exit 793243750Srwatson} 794243750Srwatson 795243750Srwatson 796243750Srwatson# func_split_short_opt shortopt 797243750Srwatson# Set func_split_short_opt_name and func_split_short_opt_arg shell 798243750Srwatson# variables after splitting SHORTOPT after the 2nd character. 799243750Srwatsonfunc_split_short_opt () 800243750Srwatson{ 801243750Srwatson my_sed_short_opt='1s/^\(..\).*$/\1/;q' 802243750Srwatson my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 803243750Srwatson 804243750Srwatson func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 805243750Srwatson func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 806243750Srwatson} # func_split_short_opt may be replaced by extended shell implementation 807243750Srwatson 808243750Srwatson 809243750Srwatson# func_split_long_opt longopt 810243750Srwatson# Set func_split_long_opt_name and func_split_long_opt_arg shell 811243750Srwatson# variables after splitting LONGOPT at the `=' sign. 812243750Srwatsonfunc_split_long_opt () 813243750Srwatson{ 814243750Srwatson my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 815243750Srwatson my_sed_long_arg='1s/^--[^=]*=//' 816243750Srwatson 817243750Srwatson func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 818243750Srwatson func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 819243750Srwatson} # func_split_long_opt may be replaced by extended shell implementation 820243750Srwatson 821243750Srwatsonexit_cmd=: 822243750Srwatson 823243750Srwatson 824243750Srwatson 825243750Srwatson 826243750Srwatson 827243750Srwatsonmagic="%%%MAGIC variable%%%" 828243750Srwatsonmagic_exe="%%%MAGIC EXE variable%%%" 829243750Srwatson 830243750Srwatson# Global variables. 831243750Srwatsonnonopt= 832243750Srwatsonpreserve_args= 833243750Srwatsonlo2o="s/\\.lo\$/.${objext}/" 834243750Srwatsono2lo="s/\\.${objext}\$/.lo/" 835243750Srwatsonextracted_archives= 836243750Srwatsonextracted_serial=0 837243750Srwatson 838243750Srwatson# If this variable is set in any of the actions, the command in it 839243750Srwatson# will be execed at the end. This prevents here-documents from being 840243750Srwatson# left over by shells. 841243750Srwatsonexec_cmd= 842243750Srwatson 843243750Srwatson# func_append var value 844243750Srwatson# Append VALUE to the end of shell variable VAR. 845243750Srwatsonfunc_append () 846243750Srwatson{ 847243750Srwatson eval "${1}=\$${1}\${2}" 848243750Srwatson} # func_append may be replaced by extended shell implementation 849243750Srwatson 850243750Srwatson# func_append_quoted var value 851243750Srwatson# Quote VALUE and append to the end of shell variable VAR, separated 852243750Srwatson# by a space. 853243750Srwatsonfunc_append_quoted () 854243750Srwatson{ 855243750Srwatson func_quote_for_eval "${2}" 856243750Srwatson eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 857243750Srwatson} # func_append_quoted may be replaced by extended shell implementation 858243750Srwatson 859243750Srwatson 860243750Srwatson# func_arith arithmetic-term... 861243750Srwatsonfunc_arith () 862243750Srwatson{ 863243750Srwatson func_arith_result=`expr "${@}"` 864243750Srwatson} # func_arith may be replaced by extended shell implementation 865243750Srwatson 866243750Srwatson 867243750Srwatson# func_len string 868243750Srwatson# STRING may not start with a hyphen. 869243750Srwatsonfunc_len () 870243750Srwatson{ 871243750Srwatson func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 872243750Srwatson} # func_len may be replaced by extended shell implementation 873243750Srwatson 874243750Srwatson 875243750Srwatson# func_lo2o object 876243750Srwatsonfunc_lo2o () 877243750Srwatson{ 878243750Srwatson func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 879243750Srwatson} # func_lo2o may be replaced by extended shell implementation 880243750Srwatson 881243750Srwatson 882243750Srwatson# func_xform libobj-or-source 883243750Srwatsonfunc_xform () 884243750Srwatson{ 885243750Srwatson func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 886243750Srwatson} # func_xform may be replaced by extended shell implementation 887243750Srwatson 888243750Srwatson 889243750Srwatson# func_fatal_configuration arg... 890243750Srwatson# Echo program name prefixed message to standard error, followed by 891243750Srwatson# a configuration failure hint, and exit. 892243750Srwatsonfunc_fatal_configuration () 893243750Srwatson{ 894243750Srwatson func_error ${1+"$@"} 895243750Srwatson func_error "See the $PACKAGE documentation for more information." 896243750Srwatson func_fatal_error "Fatal configuration error." 897243750Srwatson} 898243750Srwatson 899243750Srwatson 900243750Srwatson# func_config 901243750Srwatson# Display the configuration for all the tags in this script. 902243750Srwatsonfunc_config () 903243750Srwatson{ 904243750Srwatson re_begincf='^# ### BEGIN LIBTOOL' 905243750Srwatson re_endcf='^# ### END LIBTOOL' 906243750Srwatson 907243750Srwatson # Default configuration. 908243750Srwatson $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 909243750Srwatson 910243750Srwatson # Now print the configurations for the tags. 911243750Srwatson for tagname in $taglist; do 912243750Srwatson $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 913243750Srwatson done 914243750Srwatson 915243750Srwatson exit $? 916243750Srwatson} 917243750Srwatson 918243750Srwatson# func_features 919243750Srwatson# Display the features supported by this script. 920243750Srwatsonfunc_features () 921243750Srwatson{ 922243750Srwatson echo "host: $host" 923243750Srwatson if test "$build_libtool_libs" = yes; then 924243750Srwatson echo "enable shared libraries" 925243750Srwatson else 926243750Srwatson echo "disable shared libraries" 927243750Srwatson fi 928243750Srwatson if test "$build_old_libs" = yes; then 929243750Srwatson echo "enable static libraries" 930243750Srwatson else 931243750Srwatson echo "disable static libraries" 932243750Srwatson fi 933243750Srwatson 934243750Srwatson exit $? 935243750Srwatson} 936243750Srwatson 937243750Srwatson# func_enable_tag tagname 938243750Srwatson# Verify that TAGNAME is valid, and either flag an error and exit, or 939243750Srwatson# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 940243750Srwatson# variable here. 941243750Srwatsonfunc_enable_tag () 942243750Srwatson{ 943243750Srwatson # Global variable: 944243750Srwatson tagname="$1" 945243750Srwatson 946243750Srwatson re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 947243750Srwatson re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 948243750Srwatson sed_extractcf="/$re_begincf/,/$re_endcf/p" 949243750Srwatson 950243750Srwatson # Validate tagname. 951243750Srwatson case $tagname in 952243750Srwatson *[!-_A-Za-z0-9,/]*) 953243750Srwatson func_fatal_error "invalid tag name: $tagname" 954156283Srwatson ;; 955243750Srwatson esac 956243750Srwatson 957243750Srwatson # Don't test for the "default" C tag, as we know it's 958243750Srwatson # there but not specially marked. 959243750Srwatson case $tagname in 960243750Srwatson CC) ;; 961243750Srwatson *) 962243750Srwatson if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 963243750Srwatson taglist="$taglist $tagname" 964243750Srwatson 965243750Srwatson # Evaluate the configuration. Be careful to quote the path 966243750Srwatson # and the sed script, to avoid splitting on whitespace, but 967243750Srwatson # also don't use non-portable quotes within backquotes within 968243750Srwatson # quotes we have to do it in 2 steps: 969243750Srwatson extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 970243750Srwatson eval "$extractedcf" 971243750Srwatson else 972243750Srwatson func_error "ignoring unknown tag $tagname" 973243750Srwatson fi 974243750Srwatson ;; 975243750Srwatson esac 976243750Srwatson} 977243750Srwatson 978243750Srwatson# func_check_version_match 979243750Srwatson# Ensure that we are using m4 macros, and libtool script from the same 980243750Srwatson# release of libtool. 981243750Srwatsonfunc_check_version_match () 982243750Srwatson{ 983243750Srwatson if test "$package_revision" != "$macro_revision"; then 984243750Srwatson if test "$VERSION" != "$macro_version"; then 985243750Srwatson if test -z "$macro_version"; then 986243750Srwatson cat >&2 <<_LT_EOF 987243750Srwatson$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 988243750Srwatson$progname: definition of this LT_INIT comes from an older release. 989243750Srwatson$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 990243750Srwatson$progname: and run autoconf again. 991243750Srwatson_LT_EOF 992243750Srwatson else 993243750Srwatson cat >&2 <<_LT_EOF 994243750Srwatson$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 995243750Srwatson$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 996243750Srwatson$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 997243750Srwatson$progname: and run autoconf again. 998243750Srwatson_LT_EOF 999243750Srwatson fi 1000243750Srwatson else 1001243750Srwatson cat >&2 <<_LT_EOF 1002243750Srwatson$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 1003243750Srwatson$progname: but the definition of this LT_INIT comes from revision $macro_revision. 1004243750Srwatson$progname: You should recreate aclocal.m4 with macros from revision $package_revision 1005243750Srwatson$progname: of $PACKAGE $VERSION and run autoconf again. 1006243750Srwatson_LT_EOF 1007243750Srwatson fi 1008243750Srwatson 1009243750Srwatson exit $EXIT_MISMATCH 1010243750Srwatson fi 1011243750Srwatson} 1012243750Srwatson 1013243750Srwatson 1014243750Srwatson# Shorthand for --mode=foo, only valid as the first argument 1015243750Srwatsoncase $1 in 1016243750Srwatsonclean|clea|cle|cl) 1017243750Srwatson shift; set dummy --mode clean ${1+"$@"}; shift 1018243750Srwatson ;; 1019243750Srwatsoncompile|compil|compi|comp|com|co|c) 1020243750Srwatson shift; set dummy --mode compile ${1+"$@"}; shift 1021243750Srwatson ;; 1022243750Srwatsonexecute|execut|execu|exec|exe|ex|e) 1023243750Srwatson shift; set dummy --mode execute ${1+"$@"}; shift 1024243750Srwatson ;; 1025243750Srwatsonfinish|finis|fini|fin|fi|f) 1026243750Srwatson shift; set dummy --mode finish ${1+"$@"}; shift 1027243750Srwatson ;; 1028243750Srwatsoninstall|instal|insta|inst|ins|in|i) 1029243750Srwatson shift; set dummy --mode install ${1+"$@"}; shift 1030243750Srwatson ;; 1031243750Srwatsonlink|lin|li|l) 1032243750Srwatson shift; set dummy --mode link ${1+"$@"}; shift 1033243750Srwatson ;; 1034243750Srwatsonuninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 1035243750Srwatson shift; set dummy --mode uninstall ${1+"$@"}; shift 1036243750Srwatson ;; 1037243750Srwatsonesac 1038243750Srwatson 1039243750Srwatson 1040243750Srwatson 1041243750Srwatson# Option defaults: 1042243750Srwatsonopt_debug=: 1043243750Srwatsonopt_dry_run=false 1044243750Srwatsonopt_config=false 1045243750Srwatsonopt_preserve_dup_deps=false 1046243750Srwatsonopt_features=false 1047243750Srwatsonopt_finish=false 1048243750Srwatsonopt_help=false 1049243750Srwatsonopt_help_all=false 1050243750Srwatsonopt_silent=: 1051243750Srwatsonopt_warning=: 1052243750Srwatsonopt_verbose=: 1053243750Srwatsonopt_silent=false 1054243750Srwatsonopt_verbose=false 1055243750Srwatson 1056243750Srwatson 1057243750Srwatson# Parse options once, thoroughly. This comes as soon as possible in the 1058243750Srwatson# script to make things like `--version' happen as quickly as we can. 1059243750Srwatson{ 1060243750Srwatson # this just eases exit handling 1061243750Srwatson while test $# -gt 0; do 1062243750Srwatson opt="$1" 1063243750Srwatson shift 1064243750Srwatson case $opt in 1065243750Srwatson --debug|-x) opt_debug='set -x' 1066243750Srwatson func_echo "enabling shell trace mode" 1067243750Srwatson $opt_debug 1068243750Srwatson ;; 1069243750Srwatson --dry-run|--dryrun|-n) 1070243750Srwatson opt_dry_run=: 1071243750Srwatson ;; 1072243750Srwatson --config) 1073243750Srwatson opt_config=: 1074243750Srwatsonfunc_config 1075243750Srwatson ;; 1076243750Srwatson --dlopen|-dlopen) 1077243750Srwatson optarg="$1" 1078243750Srwatson opt_dlopen="${opt_dlopen+$opt_dlopen 1079243750Srwatson}$optarg" 1080243750Srwatson shift 1081243750Srwatson ;; 1082243750Srwatson --preserve-dup-deps) 1083243750Srwatson opt_preserve_dup_deps=: 1084243750Srwatson ;; 1085243750Srwatson --features) 1086243750Srwatson opt_features=: 1087243750Srwatsonfunc_features 1088243750Srwatson ;; 1089243750Srwatson --finish) 1090243750Srwatson opt_finish=: 1091243750Srwatsonset dummy --mode finish ${1+"$@"}; shift 1092243750Srwatson ;; 1093243750Srwatson --help) 1094243750Srwatson opt_help=: 1095243750Srwatson ;; 1096243750Srwatson --help-all) 1097243750Srwatson opt_help_all=: 1098243750Srwatsonopt_help=': help-all' 1099243750Srwatson ;; 1100243750Srwatson --mode) 1101243750Srwatson test $# = 0 && func_missing_arg $opt && break 1102243750Srwatson optarg="$1" 1103243750Srwatson opt_mode="$optarg" 1104243750Srwatsoncase $optarg in 1105243750Srwatson # Valid mode arguments: 1106243750Srwatson clean|compile|execute|finish|install|link|relink|uninstall) ;; 1107243750Srwatson 1108243750Srwatson # Catch anything else as an error 1109243750Srwatson *) func_error "invalid argument for $opt" 1110243750Srwatson exit_cmd=exit 1111243750Srwatson break 1112243750Srwatson ;; 1113243750Srwatsonesac 1114243750Srwatson shift 1115243750Srwatson ;; 1116243750Srwatson --no-silent|--no-quiet) 1117243750Srwatson opt_silent=false 1118243750Srwatsonfunc_append preserve_args " $opt" 1119243750Srwatson ;; 1120243750Srwatson --no-warning|--no-warn) 1121243750Srwatson opt_warning=false 1122243750Srwatsonfunc_append preserve_args " $opt" 1123243750Srwatson ;; 1124243750Srwatson --no-verbose) 1125243750Srwatson opt_verbose=false 1126243750Srwatsonfunc_append preserve_args " $opt" 1127243750Srwatson ;; 1128243750Srwatson --silent|--quiet) 1129243750Srwatson opt_silent=: 1130243750Srwatsonfunc_append preserve_args " $opt" 1131243750Srwatson opt_verbose=false 1132243750Srwatson ;; 1133243750Srwatson --verbose|-v) 1134243750Srwatson opt_verbose=: 1135243750Srwatsonfunc_append preserve_args " $opt" 1136243750Srwatsonopt_silent=false 1137243750Srwatson ;; 1138243750Srwatson --tag) 1139243750Srwatson test $# = 0 && func_missing_arg $opt && break 1140243750Srwatson optarg="$1" 1141243750Srwatson opt_tag="$optarg" 1142243750Srwatsonfunc_append preserve_args " $opt $optarg" 1143243750Srwatsonfunc_enable_tag "$optarg" 1144243750Srwatson shift 1145243750Srwatson ;; 1146243750Srwatson 1147243750Srwatson -\?|-h) func_usage ;; 1148243750Srwatson --help) func_help ;; 1149243750Srwatson --version) func_version ;; 1150243750Srwatson 1151243750Srwatson # Separate optargs to long options: 1152243750Srwatson --*=*) 1153243750Srwatson func_split_long_opt "$opt" 1154243750Srwatson set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 1155243750Srwatson shift 1156243750Srwatson ;; 1157243750Srwatson 1158243750Srwatson # Separate non-argument short options: 1159243750Srwatson -\?*|-h*|-n*|-v*) 1160243750Srwatson func_split_short_opt "$opt" 1161243750Srwatson set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 1162243750Srwatson shift 1163243750Srwatson ;; 1164243750Srwatson 1165243750Srwatson --) break ;; 1166243750Srwatson -*) func_fatal_help "unrecognized option \`$opt'" ;; 1167243750Srwatson *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1168156283Srwatson esac 1169243750Srwatson done 1170243750Srwatson 1171243750Srwatson # Validate options: 1172243750Srwatson 1173243750Srwatson # save first non-option argument 1174243750Srwatson if test "$#" -gt 0; then 1175243750Srwatson nonopt="$opt" 1176243750Srwatson shift 1177243750Srwatson fi 1178243750Srwatson 1179243750Srwatson # preserve --debug 1180243750Srwatson test "$opt_debug" = : || func_append preserve_args " --debug" 1181243750Srwatson 1182243750Srwatson case $host in 1183243750Srwatson *cygwin* | *mingw* | *pw32* | *cegcc*) 1184243750Srwatson # don't eliminate duplications in $postdeps and $predeps 1185243750Srwatson opt_duplicate_compiler_generated_deps=: 1186243750Srwatson ;; 1187243750Srwatson *) 1188243750Srwatson opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 1189243750Srwatson ;; 1190243750Srwatson esac 1191243750Srwatson 1192243750Srwatson $opt_help || { 1193243750Srwatson # Sanity checks first: 1194243750Srwatson func_check_version_match 1195243750Srwatson 1196243750Srwatson if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 1197243750Srwatson func_fatal_configuration "not configured to build any kind of library" 1198243750Srwatson fi 1199243750Srwatson 1200243750Srwatson # Darwin sucks 1201243750Srwatson eval std_shrext=\"$shrext_cmds\" 1202243750Srwatson 1203243750Srwatson # Only execute mode is allowed to have -dlopen flags. 1204243750Srwatson if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 1205243750Srwatson func_error "unrecognized option \`-dlopen'" 1206243750Srwatson $ECHO "$help" 1>&2 1207243750Srwatson exit $EXIT_FAILURE 1208243750Srwatson fi 1209243750Srwatson 1210243750Srwatson # Change the help message to a mode-specific one. 1211243750Srwatson generic_help="$help" 1212243750Srwatson help="Try \`$progname --help --mode=$opt_mode' for more information." 1213243750Srwatson } 1214243750Srwatson 1215243750Srwatson 1216243750Srwatson # Bail if the options were screwed 1217243750Srwatson $exit_cmd $EXIT_FAILURE 1218243750Srwatson} 1219243750Srwatson 1220243750Srwatson 1221243750Srwatson 1222243750Srwatson 1223243750Srwatson## ----------- ## 1224243750Srwatson## Main. ## 1225243750Srwatson## ----------- ## 1226243750Srwatson 1227243750Srwatson# func_lalib_p file 1228243750Srwatson# True iff FILE is a libtool `.la' library or `.lo' object file. 1229243750Srwatson# This function is only a basic sanity check; it will hardly flush out 1230243750Srwatson# determined imposters. 1231243750Srwatsonfunc_lalib_p () 1232243750Srwatson{ 1233243750Srwatson test -f "$1" && 1234243750Srwatson $SED -e 4q "$1" 2>/dev/null \ 1235243750Srwatson | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 1236243750Srwatson} 1237243750Srwatson 1238243750Srwatson# func_lalib_unsafe_p file 1239243750Srwatson# True iff FILE is a libtool `.la' library or `.lo' object file. 1240243750Srwatson# This function implements the same check as func_lalib_p without 1241243750Srwatson# resorting to external programs. To this end, it redirects stdin and 1242243750Srwatson# closes it afterwards, without saving the original file descriptor. 1243243750Srwatson# As a safety measure, use it only where a negative result would be 1244243750Srwatson# fatal anyway. Works if `file' does not exist. 1245243750Srwatsonfunc_lalib_unsafe_p () 1246243750Srwatson{ 1247243750Srwatson lalib_p=no 1248243750Srwatson if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 1249243750Srwatson for lalib_p_l in 1 2 3 4 1250243750Srwatson do 1251243750Srwatson read lalib_p_line 1252243750Srwatson case "$lalib_p_line" in 1253243750Srwatson \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 1254243750Srwatson esac 1255243750Srwatson done 1256243750Srwatson exec 0<&5 5<&- 1257243750Srwatson fi 1258243750Srwatson test "$lalib_p" = yes 1259243750Srwatson} 1260243750Srwatson 1261243750Srwatson# func_ltwrapper_script_p file 1262243750Srwatson# True iff FILE is a libtool wrapper script 1263243750Srwatson# This function is only a basic sanity check; it will hardly flush out 1264243750Srwatson# determined imposters. 1265243750Srwatsonfunc_ltwrapper_script_p () 1266243750Srwatson{ 1267243750Srwatson func_lalib_p "$1" 1268243750Srwatson} 1269243750Srwatson 1270243750Srwatson# func_ltwrapper_executable_p file 1271243750Srwatson# True iff FILE is a libtool wrapper executable 1272243750Srwatson# This function is only a basic sanity check; it will hardly flush out 1273243750Srwatson# determined imposters. 1274243750Srwatsonfunc_ltwrapper_executable_p () 1275243750Srwatson{ 1276243750Srwatson func_ltwrapper_exec_suffix= 1277243750Srwatson case $1 in 1278243750Srwatson *.exe) ;; 1279243750Srwatson *) func_ltwrapper_exec_suffix=.exe ;; 1280243750Srwatson esac 1281243750Srwatson $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 1282243750Srwatson} 1283243750Srwatson 1284243750Srwatson# func_ltwrapper_scriptname file 1285243750Srwatson# Assumes file is an ltwrapper_executable 1286243750Srwatson# uses $file to determine the appropriate filename for a 1287243750Srwatson# temporary ltwrapper_script. 1288243750Srwatsonfunc_ltwrapper_scriptname () 1289243750Srwatson{ 1290243750Srwatson func_dirname_and_basename "$1" "" "." 1291243750Srwatson func_stripname '' '.exe' "$func_basename_result" 1292243750Srwatson func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 1293243750Srwatson} 1294243750Srwatson 1295243750Srwatson# func_ltwrapper_p file 1296243750Srwatson# True iff FILE is a libtool wrapper script or wrapper executable 1297243750Srwatson# This function is only a basic sanity check; it will hardly flush out 1298243750Srwatson# determined imposters. 1299243750Srwatsonfunc_ltwrapper_p () 1300243750Srwatson{ 1301243750Srwatson func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 1302243750Srwatson} 1303243750Srwatson 1304243750Srwatson 1305243750Srwatson# func_execute_cmds commands fail_cmd 1306243750Srwatson# Execute tilde-delimited COMMANDS. 1307243750Srwatson# If FAIL_CMD is given, eval that upon failure. 1308243750Srwatson# FAIL_CMD may read-access the current command in variable CMD! 1309243750Srwatsonfunc_execute_cmds () 1310243750Srwatson{ 1311243750Srwatson $opt_debug 1312243750Srwatson save_ifs=$IFS; IFS='~' 1313243750Srwatson for cmd in $1; do 1314243750Srwatson IFS=$save_ifs 1315243750Srwatson eval cmd=\"$cmd\" 1316243750Srwatson func_show_eval "$cmd" "${2-:}" 1317243750Srwatson done 1318243750Srwatson IFS=$save_ifs 1319243750Srwatson} 1320243750Srwatson 1321243750Srwatson 1322243750Srwatson# func_source file 1323243750Srwatson# Source FILE, adding directory component if necessary. 1324243750Srwatson# Note that it is not necessary on cygwin/mingw to append a dot to 1325243750Srwatson# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 1326243750Srwatson# behavior happens only for exec(3), not for open(2)! Also, sourcing 1327243750Srwatson# `FILE.' does not work on cygwin managed mounts. 1328243750Srwatsonfunc_source () 1329243750Srwatson{ 1330243750Srwatson $opt_debug 1331243750Srwatson case $1 in 1332243750Srwatson */* | *\\*) . "$1" ;; 1333243750Srwatson *) . "./$1" ;; 1334243750Srwatson esac 1335243750Srwatson} 1336243750Srwatson 1337243750Srwatson 1338243750Srwatson# func_resolve_sysroot PATH 1339243750Srwatson# Replace a leading = in PATH with a sysroot. Store the result into 1340243750Srwatson# func_resolve_sysroot_result 1341243750Srwatsonfunc_resolve_sysroot () 1342243750Srwatson{ 1343243750Srwatson func_resolve_sysroot_result=$1 1344243750Srwatson case $func_resolve_sysroot_result in 1345243750Srwatson =*) 1346243750Srwatson func_stripname '=' '' "$func_resolve_sysroot_result" 1347243750Srwatson func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 1348156283Srwatson ;; 1349156283Srwatson esac 1350156283Srwatson} 1351156283Srwatson 1352243750Srwatson# func_replace_sysroot PATH 1353243750Srwatson# If PATH begins with the sysroot, replace it with = and 1354243750Srwatson# store the result into func_replace_sysroot_result. 1355243750Srwatsonfunc_replace_sysroot () 1356243750Srwatson{ 1357243750Srwatson case "$lt_sysroot:$1" in 1358243750Srwatson ?*:"$lt_sysroot"*) 1359243750Srwatson func_stripname "$lt_sysroot" '' "$1" 1360243750Srwatson func_replace_sysroot_result="=$func_stripname_result" 1361243750Srwatson ;; 1362243750Srwatson *) 1363243750Srwatson # Including no sysroot. 1364243750Srwatson func_replace_sysroot_result=$1 1365243750Srwatson ;; 1366243750Srwatson esac 1367243750Srwatson} 1368156283Srwatson 1369156283Srwatson# func_infer_tag arg 1370156283Srwatson# Infer tagged configuration to use if any are available and 1371156283Srwatson# if one wasn't chosen via the "--tag" command line option. 1372156283Srwatson# Only attempt this if the compiler in the base compile 1373156283Srwatson# command doesn't match the default compiler. 1374156283Srwatson# arg is usually of the form 'gcc ...' 1375156283Srwatsonfunc_infer_tag () 1376156283Srwatson{ 1377243750Srwatson $opt_debug 1378243750Srwatson 1379159985Srwatson # FreeBSD-specific: where we install compilers with non-standard names 1380243750Srwatson tag_compilers_CC="*cc cc* *gcc gcc* clang" 1381243750Srwatson tag_compilers_CXX="*c++ c++* *g++ g++* clang++" 1382159985Srwatson base_compiler=`set -- "$@"; echo $1` 1383159985Srwatson 1384159985Srwatson # If $tagname isn't set, then try to infer if the default "CC" tag applies 1385159985Srwatson if test -z "$tagname"; then 1386159985Srwatson for zp in $tag_compilers_CC; do 1387159985Srwatson case $base_compiler in 1388159985Srwatson $zp) tagname="CC"; break;; 1389159985Srwatson esac 1390159985Srwatson done 1391159985Srwatson fi 1392159985Srwatson 1393156283Srwatson if test -n "$available_tags" && test -z "$tagname"; then 1394156283Srwatson CC_quoted= 1395156283Srwatson for arg in $CC; do 1396243750Srwatson func_append_quoted CC_quoted "$arg" 1397156283Srwatson done 1398243750Srwatson CC_expanded=`func_echo_all $CC` 1399243750Srwatson CC_quoted_expanded=`func_echo_all $CC_quoted` 1400156283Srwatson case $@ in 1401156283Srwatson # Blanks in the command may have been stripped by the calling shell, 1402156283Srwatson # but not from the CC environment variable when configure was run. 1403243750Srwatson " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1404243750Srwatson " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 1405156283Srwatson # Blanks at the start of $base_compile will cause this to fail 1406156283Srwatson # if we don't check for them as well. 1407156283Srwatson *) 1408156283Srwatson for z in $available_tags; do 1409243750Srwatson if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 1410156283Srwatson # Evaluate the configuration. 1411156283Srwatson eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 1412156283Srwatson CC_quoted= 1413156283Srwatson for arg in $CC; do 1414243750Srwatson # Double-quote args containing other shell metacharacters. 1415243750Srwatson func_append_quoted CC_quoted "$arg" 1416243750Srwatson done 1417243750Srwatson CC_expanded=`func_echo_all $CC` 1418243750Srwatson CC_quoted_expanded=`func_echo_all $CC_quoted` 1419156283Srwatson case "$@ " in 1420243750Srwatson " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1421243750Srwatson " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 1422156283Srwatson # The compiler in the base compile command matches 1423156283Srwatson # the one in the tagged configuration. 1424156283Srwatson # Assume this is the tagged configuration we want. 1425156283Srwatson tagname=$z 1426156283Srwatson break 1427156283Srwatson ;; 1428156283Srwatson esac 1429159985Srwatson 1430159985Srwatson # FreeBSD-specific: try compilers based on inferred tag 1431159985Srwatson if test -z "$tagname"; then 1432159985Srwatson eval "tag_compilers=\$tag_compilers_${z}" 1433159985Srwatson if test -n "$tag_compilers"; then 1434159985Srwatson for zp in $tag_compilers; do 1435159985Srwatson case $base_compiler in 1436159985Srwatson $zp) tagname=$z; break;; 1437159985Srwatson esac 1438159985Srwatson done 1439159985Srwatson if test -n "$tagname"; then 1440159985Srwatson break 1441159985Srwatson fi 1442159985Srwatson fi 1443159985Srwatson fi 1444159985Srwatson fi 1445156283Srwatson done 1446156283Srwatson # If $tagname still isn't set, then no tagged configuration 1447156283Srwatson # was found and let the user know that the "--tag" command 1448156283Srwatson # line option must be used. 1449156283Srwatson if test -z "$tagname"; then 1450243750Srwatson func_echo "unable to infer tagged configuration" 1451243750Srwatson func_fatal_error "specify a tag with \`--tag'" 1452243750Srwatson# else 1453243750Srwatson# func_verbose "using $tagname tagged configuration" 1454156283Srwatson fi 1455156283Srwatson ;; 1456156283Srwatson esac 1457156283Srwatson fi 1458156283Srwatson} 1459156283Srwatson 1460156283Srwatson 1461243750Srwatson 1462243750Srwatson# func_write_libtool_object output_name pic_name nonpic_name 1463243750Srwatson# Create a libtool object file (analogous to a ".la" file), 1464243750Srwatson# but don't create it if we're doing a dry run. 1465243750Srwatsonfunc_write_libtool_object () 1466156283Srwatson{ 1467243750Srwatson write_libobj=${1} 1468243750Srwatson if test "$build_libtool_libs" = yes; then 1469243750Srwatson write_lobj=\'${2}\' 1470243750Srwatson else 1471243750Srwatson write_lobj=none 1472243750Srwatson fi 1473156283Srwatson 1474243750Srwatson if test "$build_old_libs" = yes; then 1475243750Srwatson write_oldobj=\'${3}\' 1476156283Srwatson else 1477243750Srwatson write_oldobj=none 1478156283Srwatson fi 1479243750Srwatson 1480243750Srwatson $opt_dry_run || { 1481243750Srwatson cat >${write_libobj}T <<EOF 1482243750Srwatson# $write_libobj - a libtool object file 1483243750Srwatson# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1484243750Srwatson# 1485243750Srwatson# Please DO NOT delete this file! 1486243750Srwatson# It is necessary for linking the library. 1487243750Srwatson 1488243750Srwatson# Name of the PIC object. 1489243750Srwatsonpic_object=$write_lobj 1490243750Srwatson 1491243750Srwatson# Name of the non-PIC object 1492243750Srwatsonnon_pic_object=$write_oldobj 1493243750Srwatson 1494243750SrwatsonEOF 1495243750Srwatson $MV "${write_libobj}T" "${write_libobj}" 1496243750Srwatson } 1497156283Srwatson} 1498156283Srwatson 1499243750Srwatson 1500243750Srwatson################################################## 1501243750Srwatson# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 1502243750Srwatson################################################## 1503243750Srwatson 1504243750Srwatson# func_convert_core_file_wine_to_w32 ARG 1505243750Srwatson# Helper function used by file name conversion functions when $build is *nix, 1506243750Srwatson# and $host is mingw, cygwin, or some other w32 environment. Relies on a 1507243750Srwatson# correctly configured wine environment available, with the winepath program 1508243750Srwatson# in $build's $PATH. 1509243750Srwatson# 1510243750Srwatson# ARG is the $build file name to be converted to w32 format. 1511243750Srwatson# Result is available in $func_convert_core_file_wine_to_w32_result, and will 1512243750Srwatson# be empty on error (or when ARG is empty) 1513243750Srwatsonfunc_convert_core_file_wine_to_w32 () 1514156283Srwatson{ 1515243750Srwatson $opt_debug 1516243750Srwatson func_convert_core_file_wine_to_w32_result="$1" 1517243750Srwatson if test -n "$1"; then 1518243750Srwatson # Unfortunately, winepath does not exit with a non-zero error code, so we 1519243750Srwatson # are forced to check the contents of stdout. On the other hand, if the 1520243750Srwatson # command is not found, the shell will set an exit code of 127 and print 1521243750Srwatson # *an error message* to stdout. So we must check for both error code of 1522243750Srwatson # zero AND non-empty stdout, which explains the odd construction: 1523243750Srwatson func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 1524243750Srwatson if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 1525243750Srwatson func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 1526243750Srwatson $SED -e "$lt_sed_naive_backslashify"` 1527243750Srwatson else 1528243750Srwatson func_convert_core_file_wine_to_w32_result= 1529156283Srwatson fi 1530243750Srwatson fi 1531243750Srwatson} 1532243750Srwatson# end: func_convert_core_file_wine_to_w32 1533156283Srwatson 1534156283Srwatson 1535243750Srwatson# func_convert_core_path_wine_to_w32 ARG 1536243750Srwatson# Helper function used by path conversion functions when $build is *nix, and 1537243750Srwatson# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 1538243750Srwatson# configured wine environment available, with the winepath program in $build's 1539243750Srwatson# $PATH. Assumes ARG has no leading or trailing path separator characters. 1540243750Srwatson# 1541243750Srwatson# ARG is path to be converted from $build format to win32. 1542243750Srwatson# Result is available in $func_convert_core_path_wine_to_w32_result. 1543243750Srwatson# Unconvertible file (directory) names in ARG are skipped; if no directory names 1544243750Srwatson# are convertible, then the result may be empty. 1545243750Srwatsonfunc_convert_core_path_wine_to_w32 () 1546243750Srwatson{ 1547243750Srwatson $opt_debug 1548243750Srwatson # unfortunately, winepath doesn't convert paths, only file names 1549243750Srwatson func_convert_core_path_wine_to_w32_result="" 1550243750Srwatson if test -n "$1"; then 1551243750Srwatson oldIFS=$IFS 1552243750Srwatson IFS=: 1553243750Srwatson for func_convert_core_path_wine_to_w32_f in $1; do 1554243750Srwatson IFS=$oldIFS 1555243750Srwatson func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 1556243750Srwatson if test -n "$func_convert_core_file_wine_to_w32_result" ; then 1557243750Srwatson if test -z "$func_convert_core_path_wine_to_w32_result"; then 1558243750Srwatson func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 1559243750Srwatson else 1560243750Srwatson func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 1561243750Srwatson fi 1562156283Srwatson fi 1563156283Srwatson done 1564243750Srwatson IFS=$oldIFS 1565243750Srwatson fi 1566156283Srwatson} 1567243750Srwatson# end: func_convert_core_path_wine_to_w32 1568156283Srwatson 1569156283Srwatson 1570243750Srwatson# func_cygpath ARGS... 1571243750Srwatson# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 1572243750Srwatson# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 1573243750Srwatson# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 1574243750Srwatson# (2), returns the Cygwin file name or path in func_cygpath_result (input 1575243750Srwatson# file name or path is assumed to be in w32 format, as previously converted 1576243750Srwatson# from $build's *nix or MSYS format). In case (3), returns the w32 file name 1577243750Srwatson# or path in func_cygpath_result (input file name or path is assumed to be in 1578243750Srwatson# Cygwin format). Returns an empty string on error. 1579243750Srwatson# 1580243750Srwatson# ARGS are passed to cygpath, with the last one being the file name or path to 1581243750Srwatson# be converted. 1582243750Srwatson# 1583243750Srwatson# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 1584243750Srwatson# environment variable; do not put it in $PATH. 1585243750Srwatsonfunc_cygpath () 1586243750Srwatson{ 1587243750Srwatson $opt_debug 1588243750Srwatson if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 1589243750Srwatson func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 1590243750Srwatson if test "$?" -ne 0; then 1591243750Srwatson # on failure, ensure result is empty 1592243750Srwatson func_cygpath_result= 1593243750Srwatson fi 1594243750Srwatson else 1595243750Srwatson func_cygpath_result= 1596243750Srwatson func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 1597243750Srwatson fi 1598243750Srwatson} 1599243750Srwatson#end: func_cygpath 1600159985Srwatson 1601156283Srwatson 1602243750Srwatson# func_convert_core_msys_to_w32 ARG 1603243750Srwatson# Convert file name or path ARG from MSYS format to w32 format. Return 1604243750Srwatson# result in func_convert_core_msys_to_w32_result. 1605243750Srwatsonfunc_convert_core_msys_to_w32 () 1606243750Srwatson{ 1607243750Srwatson $opt_debug 1608243750Srwatson # awkward: cmd appends spaces to result 1609243750Srwatson func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 1610243750Srwatson $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 1611243750Srwatson} 1612243750Srwatson#end: func_convert_core_msys_to_w32 1613243750Srwatson 1614243750Srwatson 1615243750Srwatson# func_convert_file_check ARG1 ARG2 1616243750Srwatson# Verify that ARG1 (a file name in $build format) was converted to $host 1617243750Srwatson# format in ARG2. Otherwise, emit an error message, but continue (resetting 1618243750Srwatson# func_to_host_file_result to ARG1). 1619243750Srwatsonfunc_convert_file_check () 1620243750Srwatson{ 1621243750Srwatson $opt_debug 1622243750Srwatson if test -z "$2" && test -n "$1" ; then 1623243750Srwatson func_error "Could not determine host file name corresponding to" 1624243750Srwatson func_error " \`$1'" 1625243750Srwatson func_error "Continuing, but uninstalled executables may not work." 1626243750Srwatson # Fallback: 1627243750Srwatson func_to_host_file_result="$1" 1628243750Srwatson fi 1629243750Srwatson} 1630243750Srwatson# end func_convert_file_check 1631243750Srwatson 1632243750Srwatson 1633243750Srwatson# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 1634243750Srwatson# Verify that FROM_PATH (a path in $build format) was converted to $host 1635243750Srwatson# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 1636243750Srwatson# func_to_host_file_result to a simplistic fallback value (see below). 1637243750Srwatsonfunc_convert_path_check () 1638243750Srwatson{ 1639243750Srwatson $opt_debug 1640243750Srwatson if test -z "$4" && test -n "$3"; then 1641243750Srwatson func_error "Could not determine the host path corresponding to" 1642243750Srwatson func_error " \`$3'" 1643243750Srwatson func_error "Continuing, but uninstalled executables may not work." 1644243750Srwatson # Fallback. This is a deliberately simplistic "conversion" and 1645243750Srwatson # should not be "improved". See libtool.info. 1646243750Srwatson if test "x$1" != "x$2"; then 1647243750Srwatson lt_replace_pathsep_chars="s|$1|$2|g" 1648243750Srwatson func_to_host_path_result=`echo "$3" | 1649243750Srwatson $SED -e "$lt_replace_pathsep_chars"` 1650243750Srwatson else 1651243750Srwatson func_to_host_path_result="$3" 1652243750Srwatson fi 1653243750Srwatson fi 1654243750Srwatson} 1655243750Srwatson# end func_convert_path_check 1656243750Srwatson 1657243750Srwatson 1658243750Srwatson# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 1659243750Srwatson# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 1660243750Srwatson# and appending REPL if ORIG matches BACKPAT. 1661243750Srwatsonfunc_convert_path_front_back_pathsep () 1662243750Srwatson{ 1663243750Srwatson $opt_debug 1664243750Srwatson case $4 in 1665243750Srwatson $1 ) func_to_host_path_result="$3$func_to_host_path_result" 1666243750Srwatson ;; 1667156283Srwatson esac 1668243750Srwatson case $4 in 1669243750Srwatson $2 ) func_append func_to_host_path_result "$3" 1670243750Srwatson ;; 1671243750Srwatson esac 1672243750Srwatson} 1673243750Srwatson# end func_convert_path_front_back_pathsep 1674156283Srwatson 1675156283Srwatson 1676243750Srwatson################################################## 1677243750Srwatson# $build to $host FILE NAME CONVERSION FUNCTIONS # 1678243750Srwatson################################################## 1679243750Srwatson# invoked via `$to_host_file_cmd ARG' 1680243750Srwatson# 1681243750Srwatson# In each case, ARG is the path to be converted from $build to $host format. 1682243750Srwatson# Result will be available in $func_to_host_file_result. 1683156283Srwatson 1684243750Srwatson 1685243750Srwatson# func_to_host_file ARG 1686243750Srwatson# Converts the file name ARG from $build format to $host format. Return result 1687243750Srwatson# in func_to_host_file_result. 1688243750Srwatsonfunc_to_host_file () 1689243750Srwatson{ 1690243750Srwatson $opt_debug 1691243750Srwatson $to_host_file_cmd "$1" 1692243750Srwatson} 1693243750Srwatson# end func_to_host_file 1694243750Srwatson 1695243750Srwatson 1696243750Srwatson# func_to_tool_file ARG LAZY 1697243750Srwatson# converts the file name ARG from $build format to toolchain format. Return 1698243750Srwatson# result in func_to_tool_file_result. If the conversion in use is listed 1699243750Srwatson# in (the comma separated) LAZY, no conversion takes place. 1700243750Srwatsonfunc_to_tool_file () 1701243750Srwatson{ 1702243750Srwatson $opt_debug 1703243750Srwatson case ,$2, in 1704243750Srwatson *,"$to_tool_file_cmd",*) 1705243750Srwatson func_to_tool_file_result=$1 1706156283Srwatson ;; 1707156283Srwatson *) 1708243750Srwatson $to_tool_file_cmd "$1" 1709243750Srwatson func_to_tool_file_result=$func_to_host_file_result 1710156283Srwatson ;; 1711243750Srwatson esac 1712243750Srwatson} 1713243750Srwatson# end func_to_tool_file 1714156283Srwatson 1715243750Srwatson 1716243750Srwatson# func_convert_file_noop ARG 1717243750Srwatson# Copy ARG to func_to_host_file_result. 1718243750Srwatsonfunc_convert_file_noop () 1719243750Srwatson{ 1720243750Srwatson func_to_host_file_result="$1" 1721243750Srwatson} 1722243750Srwatson# end func_convert_file_noop 1723243750Srwatson 1724243750Srwatson 1725243750Srwatson# func_convert_file_msys_to_w32 ARG 1726243750Srwatson# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 1727243750Srwatson# conversion to w32 is not available inside the cwrapper. Returns result in 1728243750Srwatson# func_to_host_file_result. 1729243750Srwatsonfunc_convert_file_msys_to_w32 () 1730243750Srwatson{ 1731243750Srwatson $opt_debug 1732243750Srwatson func_to_host_file_result="$1" 1733243750Srwatson if test -n "$1"; then 1734243750Srwatson func_convert_core_msys_to_w32 "$1" 1735243750Srwatson func_to_host_file_result="$func_convert_core_msys_to_w32_result" 1736156283Srwatson fi 1737243750Srwatson func_convert_file_check "$1" "$func_to_host_file_result" 1738243750Srwatson} 1739243750Srwatson# end func_convert_file_msys_to_w32 1740156283Srwatson 1741156283Srwatson 1742243750Srwatson# func_convert_file_cygwin_to_w32 ARG 1743243750Srwatson# Convert file name ARG from Cygwin to w32 format. Returns result in 1744243750Srwatson# func_to_host_file_result. 1745243750Srwatsonfunc_convert_file_cygwin_to_w32 () 1746243750Srwatson{ 1747243750Srwatson $opt_debug 1748243750Srwatson func_to_host_file_result="$1" 1749243750Srwatson if test -n "$1"; then 1750243750Srwatson # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 1751243750Srwatson # LT_CYGPATH in this case. 1752243750Srwatson func_to_host_file_result=`cygpath -m "$1"` 1753243750Srwatson fi 1754243750Srwatson func_convert_file_check "$1" "$func_to_host_file_result" 1755243750Srwatson} 1756243750Srwatson# end func_convert_file_cygwin_to_w32 1757173143Srwatson 1758156283Srwatson 1759243750Srwatson# func_convert_file_nix_to_w32 ARG 1760243750Srwatson# Convert file name ARG from *nix to w32 format. Requires a wine environment 1761243750Srwatson# and a working winepath. Returns result in func_to_host_file_result. 1762243750Srwatsonfunc_convert_file_nix_to_w32 () 1763243750Srwatson{ 1764243750Srwatson $opt_debug 1765243750Srwatson func_to_host_file_result="$1" 1766243750Srwatson if test -n "$1"; then 1767243750Srwatson func_convert_core_file_wine_to_w32 "$1" 1768243750Srwatson func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 1769243750Srwatson fi 1770243750Srwatson func_convert_file_check "$1" "$func_to_host_file_result" 1771243750Srwatson} 1772243750Srwatson# end func_convert_file_nix_to_w32 1773156283Srwatson 1774156283Srwatson 1775243750Srwatson# func_convert_file_msys_to_cygwin ARG 1776243750Srwatson# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1777243750Srwatson# Returns result in func_to_host_file_result. 1778243750Srwatsonfunc_convert_file_msys_to_cygwin () 1779243750Srwatson{ 1780243750Srwatson $opt_debug 1781243750Srwatson func_to_host_file_result="$1" 1782243750Srwatson if test -n "$1"; then 1783243750Srwatson func_convert_core_msys_to_w32 "$1" 1784243750Srwatson func_cygpath -u "$func_convert_core_msys_to_w32_result" 1785243750Srwatson func_to_host_file_result="$func_cygpath_result" 1786243750Srwatson fi 1787243750Srwatson func_convert_file_check "$1" "$func_to_host_file_result" 1788243750Srwatson} 1789243750Srwatson# end func_convert_file_msys_to_cygwin 1790156283Srwatson 1791156283Srwatson 1792243750Srwatson# func_convert_file_nix_to_cygwin ARG 1793243750Srwatson# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 1794243750Srwatson# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 1795243750Srwatson# in func_to_host_file_result. 1796243750Srwatsonfunc_convert_file_nix_to_cygwin () 1797243750Srwatson{ 1798243750Srwatson $opt_debug 1799243750Srwatson func_to_host_file_result="$1" 1800243750Srwatson if test -n "$1"; then 1801243750Srwatson # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 1802243750Srwatson func_convert_core_file_wine_to_w32 "$1" 1803243750Srwatson func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 1804243750Srwatson func_to_host_file_result="$func_cygpath_result" 1805243750Srwatson fi 1806243750Srwatson func_convert_file_check "$1" "$func_to_host_file_result" 1807243750Srwatson} 1808243750Srwatson# end func_convert_file_nix_to_cygwin 1809156283Srwatson 1810156283Srwatson 1811243750Srwatson############################################# 1812243750Srwatson# $build to $host PATH CONVERSION FUNCTIONS # 1813243750Srwatson############################################# 1814243750Srwatson# invoked via `$to_host_path_cmd ARG' 1815243750Srwatson# 1816243750Srwatson# In each case, ARG is the path to be converted from $build to $host format. 1817243750Srwatson# The result will be available in $func_to_host_path_result. 1818243750Srwatson# 1819243750Srwatson# Path separators are also converted from $build format to $host format. If 1820243750Srwatson# ARG begins or ends with a path separator character, it is preserved (but 1821243750Srwatson# converted to $host format) on output. 1822243750Srwatson# 1823243750Srwatson# All path conversion functions are named using the following convention: 1824243750Srwatson# file name conversion function : func_convert_file_X_to_Y () 1825243750Srwatson# path conversion function : func_convert_path_X_to_Y () 1826243750Srwatson# where, for any given $build/$host combination the 'X_to_Y' value is the 1827243750Srwatson# same. If conversion functions are added for new $build/$host combinations, 1828243750Srwatson# the two new functions must follow this pattern, or func_init_to_host_path_cmd 1829243750Srwatson# will break. 1830156283Srwatson 1831156283Srwatson 1832243750Srwatson# func_init_to_host_path_cmd 1833243750Srwatson# Ensures that function "pointer" variable $to_host_path_cmd is set to the 1834243750Srwatson# appropriate value, based on the value of $to_host_file_cmd. 1835243750Srwatsonto_host_path_cmd= 1836243750Srwatsonfunc_init_to_host_path_cmd () 1837243750Srwatson{ 1838243750Srwatson $opt_debug 1839243750Srwatson if test -z "$to_host_path_cmd"; then 1840243750Srwatson func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 1841243750Srwatson to_host_path_cmd="func_convert_path_${func_stripname_result}" 1842243750Srwatson fi 1843243750Srwatson} 1844156283Srwatson 1845156283Srwatson 1846243750Srwatson# func_to_host_path ARG 1847243750Srwatson# Converts the path ARG from $build format to $host format. Return result 1848243750Srwatson# in func_to_host_path_result. 1849243750Srwatsonfunc_to_host_path () 1850243750Srwatson{ 1851243750Srwatson $opt_debug 1852243750Srwatson func_init_to_host_path_cmd 1853243750Srwatson $to_host_path_cmd "$1" 1854243750Srwatson} 1855243750Srwatson# end func_to_host_path 1856156283Srwatson 1857156283Srwatson 1858243750Srwatson# func_convert_path_noop ARG 1859243750Srwatson# Copy ARG to func_to_host_path_result. 1860243750Srwatsonfunc_convert_path_noop () 1861243750Srwatson{ 1862243750Srwatson func_to_host_path_result="$1" 1863243750Srwatson} 1864243750Srwatson# end func_convert_path_noop 1865156283Srwatson 1866159985Srwatson 1867243750Srwatson# func_convert_path_msys_to_w32 ARG 1868243750Srwatson# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 1869243750Srwatson# conversion to w32 is not available inside the cwrapper. Returns result in 1870243750Srwatson# func_to_host_path_result. 1871243750Srwatsonfunc_convert_path_msys_to_w32 () 1872243750Srwatson{ 1873243750Srwatson $opt_debug 1874243750Srwatson func_to_host_path_result="$1" 1875243750Srwatson if test -n "$1"; then 1876243750Srwatson # Remove leading and trailing path separator characters from ARG. MSYS 1877243750Srwatson # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 1878243750Srwatson # and winepath ignores them completely. 1879243750Srwatson func_stripname : : "$1" 1880243750Srwatson func_to_host_path_tmp1=$func_stripname_result 1881243750Srwatson func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1882243750Srwatson func_to_host_path_result="$func_convert_core_msys_to_w32_result" 1883243750Srwatson func_convert_path_check : ";" \ 1884243750Srwatson "$func_to_host_path_tmp1" "$func_to_host_path_result" 1885243750Srwatson func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1886243750Srwatson fi 1887243750Srwatson} 1888243750Srwatson# end func_convert_path_msys_to_w32 1889156283Srwatson 1890156283Srwatson 1891243750Srwatson# func_convert_path_cygwin_to_w32 ARG 1892243750Srwatson# Convert path ARG from Cygwin to w32 format. Returns result in 1893243750Srwatson# func_to_host_file_result. 1894243750Srwatsonfunc_convert_path_cygwin_to_w32 () 1895243750Srwatson{ 1896243750Srwatson $opt_debug 1897243750Srwatson func_to_host_path_result="$1" 1898243750Srwatson if test -n "$1"; then 1899243750Srwatson # See func_convert_path_msys_to_w32: 1900243750Srwatson func_stripname : : "$1" 1901243750Srwatson func_to_host_path_tmp1=$func_stripname_result 1902243750Srwatson func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 1903243750Srwatson func_convert_path_check : ";" \ 1904243750Srwatson "$func_to_host_path_tmp1" "$func_to_host_path_result" 1905243750Srwatson func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1906243750Srwatson fi 1907243750Srwatson} 1908243750Srwatson# end func_convert_path_cygwin_to_w32 1909156283Srwatson 1910243750Srwatson 1911243750Srwatson# func_convert_path_nix_to_w32 ARG 1912243750Srwatson# Convert path ARG from *nix to w32 format. Requires a wine environment and 1913243750Srwatson# a working winepath. Returns result in func_to_host_file_result. 1914243750Srwatsonfunc_convert_path_nix_to_w32 () 1915243750Srwatson{ 1916243750Srwatson $opt_debug 1917243750Srwatson func_to_host_path_result="$1" 1918243750Srwatson if test -n "$1"; then 1919243750Srwatson # See func_convert_path_msys_to_w32: 1920243750Srwatson func_stripname : : "$1" 1921243750Srwatson func_to_host_path_tmp1=$func_stripname_result 1922243750Srwatson func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1923243750Srwatson func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 1924243750Srwatson func_convert_path_check : ";" \ 1925243750Srwatson "$func_to_host_path_tmp1" "$func_to_host_path_result" 1926243750Srwatson func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1927156283Srwatson fi 1928243750Srwatson} 1929243750Srwatson# end func_convert_path_nix_to_w32 1930156283Srwatson 1931243750Srwatson 1932243750Srwatson# func_convert_path_msys_to_cygwin ARG 1933243750Srwatson# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1934243750Srwatson# Returns result in func_to_host_file_result. 1935243750Srwatsonfunc_convert_path_msys_to_cygwin () 1936243750Srwatson{ 1937243750Srwatson $opt_debug 1938243750Srwatson func_to_host_path_result="$1" 1939243750Srwatson if test -n "$1"; then 1940243750Srwatson # See func_convert_path_msys_to_w32: 1941243750Srwatson func_stripname : : "$1" 1942243750Srwatson func_to_host_path_tmp1=$func_stripname_result 1943243750Srwatson func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1944243750Srwatson func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 1945243750Srwatson func_to_host_path_result="$func_cygpath_result" 1946243750Srwatson func_convert_path_check : : \ 1947243750Srwatson "$func_to_host_path_tmp1" "$func_to_host_path_result" 1948243750Srwatson func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1949156283Srwatson fi 1950243750Srwatson} 1951243750Srwatson# end func_convert_path_msys_to_cygwin 1952156283Srwatson 1953156283Srwatson 1954243750Srwatson# func_convert_path_nix_to_cygwin ARG 1955243750Srwatson# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 1956243750Srwatson# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 1957243750Srwatson# func_to_host_file_result. 1958243750Srwatsonfunc_convert_path_nix_to_cygwin () 1959243750Srwatson{ 1960243750Srwatson $opt_debug 1961243750Srwatson func_to_host_path_result="$1" 1962243750Srwatson if test -n "$1"; then 1963243750Srwatson # Remove leading and trailing path separator characters from 1964243750Srwatson # ARG. msys behavior is inconsistent here, cygpath turns them 1965243750Srwatson # into '.;' and ';.', and winepath ignores them completely. 1966243750Srwatson func_stripname : : "$1" 1967243750Srwatson func_to_host_path_tmp1=$func_stripname_result 1968243750Srwatson func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1969243750Srwatson func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 1970243750Srwatson func_to_host_path_result="$func_cygpath_result" 1971243750Srwatson func_convert_path_check : : \ 1972243750Srwatson "$func_to_host_path_tmp1" "$func_to_host_path_result" 1973243750Srwatson func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1974243750Srwatson fi 1975243750Srwatson} 1976243750Srwatson# end func_convert_path_nix_to_cygwin 1977243750Srwatson 1978243750Srwatson 1979243750Srwatson# func_mode_compile arg... 1980243750Srwatsonfunc_mode_compile () 1981243750Srwatson{ 1982243750Srwatson $opt_debug 1983156283Srwatson # Get the compilation command and the source file. 1984156283Srwatson base_compile= 1985156283Srwatson srcfile="$nonopt" # always keep a non-empty value in "srcfile" 1986156283Srwatson suppress_opt=yes 1987156283Srwatson suppress_output= 1988156283Srwatson arg_mode=normal 1989156283Srwatson libobj= 1990156283Srwatson later= 1991243750Srwatson pie_flag= 1992156283Srwatson 1993156283Srwatson for arg 1994156283Srwatson do 1995156283Srwatson case $arg_mode in 1996156283Srwatson arg ) 1997156283Srwatson # do not "continue". Instead, add this to base_compile 1998156283Srwatson lastarg="$arg" 1999156283Srwatson arg_mode=normal 2000156283Srwatson ;; 2001156283Srwatson 2002156283Srwatson target ) 2003156283Srwatson libobj="$arg" 2004156283Srwatson arg_mode=normal 2005156283Srwatson continue 2006156283Srwatson ;; 2007156283Srwatson 2008156283Srwatson normal ) 2009156283Srwatson # Accept any command-line options. 2010156283Srwatson case $arg in 2011156283Srwatson -o) 2012243750Srwatson test -n "$libobj" && \ 2013243750Srwatson func_fatal_error "you cannot specify \`-o' more than once" 2014156283Srwatson arg_mode=target 2015156283Srwatson continue 2016156283Srwatson ;; 2017156283Srwatson 2018243750Srwatson -pie | -fpie | -fPIE) 2019243750Srwatson func_append pie_flag " $arg" 2020156283Srwatson continue 2021156283Srwatson ;; 2022156283Srwatson 2023243750Srwatson -shared | -static | -prefer-pic | -prefer-non-pic) 2024243750Srwatson func_append later " $arg" 2025243750Srwatson continue 2026243750Srwatson ;; 2027243750Srwatson 2028156283Srwatson -no-suppress) 2029156283Srwatson suppress_opt=no 2030156283Srwatson continue 2031156283Srwatson ;; 2032156283Srwatson 2033156283Srwatson -Xcompiler) 2034156283Srwatson arg_mode=arg # the next one goes into the "base_compile" arg list 2035156283Srwatson continue # The current "srcfile" will either be retained or 2036156283Srwatson ;; # replaced later. I would guess that would be a bug. 2037156283Srwatson 2038156283Srwatson -Wc,*) 2039243750Srwatson func_stripname '-Wc,' '' "$arg" 2040243750Srwatson args=$func_stripname_result 2041156283Srwatson lastarg= 2042156283Srwatson save_ifs="$IFS"; IFS=',' 2043243750Srwatson for arg in $args; do 2044156283Srwatson IFS="$save_ifs" 2045243750Srwatson func_append_quoted lastarg "$arg" 2046156283Srwatson done 2047156283Srwatson IFS="$save_ifs" 2048243750Srwatson func_stripname ' ' '' "$lastarg" 2049243750Srwatson lastarg=$func_stripname_result 2050156283Srwatson 2051156283Srwatson # Add the arguments to base_compile. 2052243750Srwatson func_append base_compile " $lastarg" 2053156283Srwatson continue 2054156283Srwatson ;; 2055156283Srwatson 2056243750Srwatson *) 2057156283Srwatson # Accept the current argument as the source file. 2058156283Srwatson # The previous "srcfile" becomes the current argument. 2059156283Srwatson # 2060156283Srwatson lastarg="$srcfile" 2061156283Srwatson srcfile="$arg" 2062156283Srwatson ;; 2063156283Srwatson esac # case $arg 2064156283Srwatson ;; 2065156283Srwatson esac # case $arg_mode 2066156283Srwatson 2067156283Srwatson # Aesthetically quote the previous argument. 2068243750Srwatson func_append_quoted base_compile "$lastarg" 2069156283Srwatson done # for arg 2070156283Srwatson 2071156283Srwatson case $arg_mode in 2072156283Srwatson arg) 2073243750Srwatson func_fatal_error "you must specify an argument for -Xcompile" 2074156283Srwatson ;; 2075156283Srwatson target) 2076243750Srwatson func_fatal_error "you must specify a target with \`-o'" 2077156283Srwatson ;; 2078156283Srwatson *) 2079156283Srwatson # Get the name of the library object. 2080243750Srwatson test -z "$libobj" && { 2081243750Srwatson func_basename "$srcfile" 2082243750Srwatson libobj="$func_basename_result" 2083243750Srwatson } 2084156283Srwatson ;; 2085156283Srwatson esac 2086156283Srwatson 2087156283Srwatson # Recognize several different file suffixes. 2088156283Srwatson # If the user specifies -o file.o, it is replaced with file.lo 2089156283Srwatson case $libobj in 2090243750Srwatson *.[cCFSifmso] | \ 2091243750Srwatson *.ada | *.adb | *.ads | *.asm | \ 2092243750Srwatson *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 2093243750Srwatson *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 2094243750Srwatson func_xform "$libobj" 2095243750Srwatson libobj=$func_xform_result 2096243750Srwatson ;; 2097156283Srwatson esac 2098156283Srwatson 2099156283Srwatson case $libobj in 2100243750Srwatson *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2101156283Srwatson *) 2102243750Srwatson func_fatal_error "cannot determine name of library object from \`$libobj'" 2103156283Srwatson ;; 2104156283Srwatson esac 2105156283Srwatson 2106156283Srwatson func_infer_tag $base_compile 2107156283Srwatson 2108156283Srwatson for arg in $later; do 2109156283Srwatson case $arg in 2110243750Srwatson -shared) 2111243750Srwatson test "$build_libtool_libs" != yes && \ 2112243750Srwatson func_fatal_configuration "can not build a shared library" 2113243750Srwatson build_old_libs=no 2114243750Srwatson continue 2115243750Srwatson ;; 2116243750Srwatson 2117156283Srwatson -static) 2118243750Srwatson build_libtool_libs=no 2119156283Srwatson build_old_libs=yes 2120156283Srwatson continue 2121156283Srwatson ;; 2122156283Srwatson 2123156283Srwatson -prefer-pic) 2124156283Srwatson pic_mode=yes 2125156283Srwatson continue 2126156283Srwatson ;; 2127156283Srwatson 2128156283Srwatson -prefer-non-pic) 2129156283Srwatson pic_mode=no 2130156283Srwatson continue 2131156283Srwatson ;; 2132156283Srwatson esac 2133156283Srwatson done 2134156283Srwatson 2135243750Srwatson func_quote_for_eval "$libobj" 2136243750Srwatson test "X$libobj" != "X$func_quote_for_eval_result" \ 2137243750Srwatson && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 2138243750Srwatson && func_warning "libobj name \`$libobj' may not contain shell special characters." 2139243750Srwatson func_dirname_and_basename "$obj" "/" "" 2140243750Srwatson objname="$func_basename_result" 2141243750Srwatson xdir="$func_dirname_result" 2142156283Srwatson lobj=${xdir}$objdir/$objname 2143156283Srwatson 2144243750Srwatson test -z "$base_compile" && \ 2145243750Srwatson func_fatal_help "you must specify a compilation command" 2146156283Srwatson 2147156283Srwatson # Delete any leftover library objects. 2148156283Srwatson if test "$build_old_libs" = yes; then 2149156283Srwatson removelist="$obj $lobj $libobj ${libobj}T" 2150156283Srwatson else 2151156283Srwatson removelist="$lobj $libobj ${libobj}T" 2152156283Srwatson fi 2153156283Srwatson 2154156283Srwatson # On Cygwin there's no "real" PIC flag so we must build both object types 2155156283Srwatson case $host_os in 2156243750Srwatson cygwin* | mingw* | pw32* | os2* | cegcc*) 2157156283Srwatson pic_mode=default 2158156283Srwatson ;; 2159156283Srwatson esac 2160156283Srwatson if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2161156283Srwatson # non-PIC code in shared libraries is not supported 2162156283Srwatson pic_mode=default 2163156283Srwatson fi 2164156283Srwatson 2165156283Srwatson # Calculate the filename of the output object if compiler does 2166156283Srwatson # not support -o with -c 2167156283Srwatson if test "$compiler_c_o" = no; then 2168243750Srwatson output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2169156283Srwatson lockfile="$output_obj.lock" 2170156283Srwatson else 2171156283Srwatson output_obj= 2172156283Srwatson need_locks=no 2173156283Srwatson lockfile= 2174156283Srwatson fi 2175156283Srwatson 2176156283Srwatson # Lock this critical section if it is needed 2177156283Srwatson # We use this script file to make the link, it avoids creating a new file 2178156283Srwatson if test "$need_locks" = yes; then 2179243750Srwatson until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 2180243750Srwatson func_echo "Waiting for $lockfile to be removed" 2181156283Srwatson sleep 2 2182156283Srwatson done 2183156283Srwatson elif test "$need_locks" = warn; then 2184156283Srwatson if test -f "$lockfile"; then 2185243750Srwatson $ECHO "\ 2186156283Srwatson*** ERROR, $lockfile exists and contains: 2187156283Srwatson`cat $lockfile 2>/dev/null` 2188156283Srwatson 2189156283SrwatsonThis indicates that another process is trying to use the same 2190156283Srwatsontemporary object file, and libtool could not work around it because 2191156283Srwatsonyour compiler does not support \`-c' and \`-o' together. If you 2192156283Srwatsonrepeat this compilation, it may succeed, by chance, but you had better 2193156283Srwatsonavoid parallel builds (make -j) in this platform, or get a better 2194156283Srwatsoncompiler." 2195156283Srwatson 2196243750Srwatson $opt_dry_run || $RM $removelist 2197156283Srwatson exit $EXIT_FAILURE 2198156283Srwatson fi 2199243750Srwatson func_append removelist " $output_obj" 2200243750Srwatson $ECHO "$srcfile" > "$lockfile" 2201156283Srwatson fi 2202156283Srwatson 2203243750Srwatson $opt_dry_run || $RM $removelist 2204243750Srwatson func_append removelist " $lockfile" 2205243750Srwatson trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 2206156283Srwatson 2207243750Srwatson func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 2208243750Srwatson srcfile=$func_to_tool_file_result 2209243750Srwatson func_quote_for_eval "$srcfile" 2210243750Srwatson qsrcfile=$func_quote_for_eval_result 2211156283Srwatson 2212156283Srwatson # Only build a PIC object if we are building libtool libraries. 2213156283Srwatson if test "$build_libtool_libs" = yes; then 2214156283Srwatson # Without this assignment, base_compile gets emptied. 2215156283Srwatson fbsd_hideous_sh_bug=$base_compile 2216156283Srwatson 2217156283Srwatson if test "$pic_mode" != no; then 2218156283Srwatson command="$base_compile $qsrcfile $pic_flag" 2219156283Srwatson else 2220156283Srwatson # Don't build PIC code 2221156283Srwatson command="$base_compile $qsrcfile" 2222156283Srwatson fi 2223156283Srwatson 2224243750Srwatson func_mkdir_p "$xdir$objdir" 2225156283Srwatson 2226156283Srwatson if test -z "$output_obj"; then 2227156283Srwatson # Place PIC objects in $objdir 2228243750Srwatson func_append command " -o $lobj" 2229156283Srwatson fi 2230156283Srwatson 2231243750Srwatson func_show_eval_locale "$command" \ 2232243750Srwatson 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2233156283Srwatson 2234156283Srwatson if test "$need_locks" = warn && 2235156283Srwatson test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2236243750Srwatson $ECHO "\ 2237156283Srwatson*** ERROR, $lockfile contains: 2238156283Srwatson`cat $lockfile 2>/dev/null` 2239156283Srwatson 2240156283Srwatsonbut it should contain: 2241156283Srwatson$srcfile 2242156283Srwatson 2243156283SrwatsonThis indicates that another process is trying to use the same 2244156283Srwatsontemporary object file, and libtool could not work around it because 2245156283Srwatsonyour compiler does not support \`-c' and \`-o' together. If you 2246156283Srwatsonrepeat this compilation, it may succeed, by chance, but you had better 2247156283Srwatsonavoid parallel builds (make -j) in this platform, or get a better 2248156283Srwatsoncompiler." 2249156283Srwatson 2250243750Srwatson $opt_dry_run || $RM $removelist 2251156283Srwatson exit $EXIT_FAILURE 2252156283Srwatson fi 2253156283Srwatson 2254156283Srwatson # Just move the object if needed, then go on to compile the next one 2255156283Srwatson if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 2256243750Srwatson func_show_eval '$MV "$output_obj" "$lobj"' \ 2257243750Srwatson 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2258156283Srwatson fi 2259156283Srwatson 2260156283Srwatson # Allow error messages only from the first compilation. 2261156283Srwatson if test "$suppress_opt" = yes; then 2262243750Srwatson suppress_output=' >/dev/null 2>&1' 2263156283Srwatson fi 2264156283Srwatson fi 2265156283Srwatson 2266156283Srwatson # Only build a position-dependent object if we build old libraries. 2267156283Srwatson if test "$build_old_libs" = yes; then 2268156283Srwatson if test "$pic_mode" != yes; then 2269156283Srwatson # Don't build PIC code 2270243750Srwatson command="$base_compile $qsrcfile$pie_flag" 2271156283Srwatson else 2272156283Srwatson command="$base_compile $qsrcfile $pic_flag" 2273156283Srwatson fi 2274156283Srwatson if test "$compiler_c_o" = yes; then 2275243750Srwatson func_append command " -o $obj" 2276156283Srwatson fi 2277156283Srwatson 2278156283Srwatson # Suppress compiler output if we already did a PIC compilation. 2279243750Srwatson func_append command "$suppress_output" 2280243750Srwatson func_show_eval_locale "$command" \ 2281243750Srwatson '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2282156283Srwatson 2283156283Srwatson if test "$need_locks" = warn && 2284156283Srwatson test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2285243750Srwatson $ECHO "\ 2286156283Srwatson*** ERROR, $lockfile contains: 2287156283Srwatson`cat $lockfile 2>/dev/null` 2288156283Srwatson 2289156283Srwatsonbut it should contain: 2290156283Srwatson$srcfile 2291156283Srwatson 2292156283SrwatsonThis indicates that another process is trying to use the same 2293156283Srwatsontemporary object file, and libtool could not work around it because 2294156283Srwatsonyour compiler does not support \`-c' and \`-o' together. If you 2295156283Srwatsonrepeat this compilation, it may succeed, by chance, but you had better 2296156283Srwatsonavoid parallel builds (make -j) in this platform, or get a better 2297156283Srwatsoncompiler." 2298156283Srwatson 2299243750Srwatson $opt_dry_run || $RM $removelist 2300156283Srwatson exit $EXIT_FAILURE 2301156283Srwatson fi 2302156283Srwatson 2303156283Srwatson # Just move the object if needed 2304156283Srwatson if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 2305243750Srwatson func_show_eval '$MV "$output_obj" "$obj"' \ 2306243750Srwatson 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2307243750Srwatson fi 2308243750Srwatson fi 2309243750Srwatson 2310243750Srwatson $opt_dry_run || { 2311243750Srwatson func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2312243750Srwatson 2313243750Srwatson # Unlock the critical section if it was locked 2314243750Srwatson if test "$need_locks" != no; then 2315243750Srwatson removelist=$lockfile 2316243750Srwatson $RM "$lockfile" 2317243750Srwatson fi 2318243750Srwatson } 2319243750Srwatson 2320243750Srwatson exit $EXIT_SUCCESS 2321243750Srwatson} 2322243750Srwatson 2323243750Srwatson$opt_help || { 2324243750Srwatson test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 2325243750Srwatson} 2326243750Srwatson 2327243750Srwatsonfunc_mode_help () 2328243750Srwatson{ 2329243750Srwatson # We need to display help for each of the modes. 2330243750Srwatson case $opt_mode in 2331243750Srwatson "") 2332243750Srwatson # Generic help is extracted from the usage comments 2333243750Srwatson # at the start of this file. 2334243750Srwatson func_help 2335243750Srwatson ;; 2336243750Srwatson 2337243750Srwatson clean) 2338243750Srwatson $ECHO \ 2339243750Srwatson"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2340243750Srwatson 2341243750SrwatsonRemove files from the build directory. 2342243750Srwatson 2343243750SrwatsonRM is the name of the program to use to delete files associated with each FILE 2344243750Srwatson(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2345243750Srwatsonto RM. 2346243750Srwatson 2347243750SrwatsonIf FILE is a libtool library, object or program, all the files associated 2348243750Srwatsonwith it are deleted. Otherwise, only FILE itself is deleted using RM." 2349243750Srwatson ;; 2350243750Srwatson 2351243750Srwatson compile) 2352243750Srwatson $ECHO \ 2353243750Srwatson"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2354243750Srwatson 2355243750SrwatsonCompile a source file into a libtool library object. 2356243750Srwatson 2357243750SrwatsonThis mode accepts the following additional options: 2358243750Srwatson 2359243750Srwatson -o OUTPUT-FILE set the output file name to OUTPUT-FILE 2360243750Srwatson -no-suppress do not suppress compiler output for multiple passes 2361243750Srwatson -prefer-pic try to build PIC objects only 2362243750Srwatson -prefer-non-pic try to build non-PIC objects only 2363243750Srwatson -shared do not build a \`.o' file suitable for static linking 2364243750Srwatson -static only build a \`.o' file suitable for static linking 2365243750Srwatson -Wc,FLAG pass FLAG directly to the compiler 2366243750Srwatson 2367243750SrwatsonCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 2368243750Srwatsonfrom the given SOURCEFILE. 2369243750Srwatson 2370243750SrwatsonThe output file name is determined by removing the directory component from 2371243750SrwatsonSOURCEFILE, then substituting the C source code suffix \`.c' with the 2372243750Srwatsonlibrary object suffix, \`.lo'." 2373243750Srwatson ;; 2374243750Srwatson 2375243750Srwatson execute) 2376243750Srwatson $ECHO \ 2377243750Srwatson"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2378243750Srwatson 2379243750SrwatsonAutomatically set library path, then run a program. 2380243750Srwatson 2381243750SrwatsonThis mode accepts the following additional options: 2382243750Srwatson 2383243750Srwatson -dlopen FILE add the directory containing FILE to the library path 2384243750Srwatson 2385243750SrwatsonThis mode sets the library path environment variable according to \`-dlopen' 2386243750Srwatsonflags. 2387243750Srwatson 2388243750SrwatsonIf any of the ARGS are libtool executable wrappers, then they are translated 2389243750Srwatsoninto their corresponding uninstalled binary, and any of their required library 2390243750Srwatsondirectories are added to the library path. 2391243750Srwatson 2392243750SrwatsonThen, COMMAND is executed, with ARGS as arguments." 2393243750Srwatson ;; 2394243750Srwatson 2395243750Srwatson finish) 2396243750Srwatson $ECHO \ 2397243750Srwatson"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2398243750Srwatson 2399243750SrwatsonComplete the installation of libtool libraries. 2400243750Srwatson 2401243750SrwatsonEach LIBDIR is a directory that contains libtool libraries. 2402243750Srwatson 2403243750SrwatsonThe commands that this mode executes may require superuser privileges. Use 2404243750Srwatsonthe \`--dry-run' option if you just want to see what would be executed." 2405243750Srwatson ;; 2406243750Srwatson 2407243750Srwatson install) 2408243750Srwatson $ECHO \ 2409243750Srwatson"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2410243750Srwatson 2411243750SrwatsonInstall executables or libraries. 2412243750Srwatson 2413243750SrwatsonINSTALL-COMMAND is the installation command. The first component should be 2414243750Srwatsoneither the \`install' or \`cp' program. 2415243750Srwatson 2416243750SrwatsonThe following components of INSTALL-COMMAND are treated specially: 2417243750Srwatson 2418243750Srwatson -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2419243750Srwatson 2420243750SrwatsonThe rest of the components are interpreted as arguments to that command (only 2421243750SrwatsonBSD-compatible install options are recognized)." 2422243750Srwatson ;; 2423243750Srwatson 2424243750Srwatson link) 2425243750Srwatson $ECHO \ 2426243750Srwatson"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2427243750Srwatson 2428243750SrwatsonLink object files or libraries together to form another library, or to 2429243750Srwatsoncreate an executable program. 2430243750Srwatson 2431243750SrwatsonLINK-COMMAND is a command using the C compiler that you would use to create 2432243750Srwatsona program from several object files. 2433243750Srwatson 2434243750SrwatsonThe following components of LINK-COMMAND are treated specially: 2435243750Srwatson 2436243750Srwatson -all-static do not do any dynamic linking at all 2437243750Srwatson -avoid-version do not add a version suffix if possible 2438243750Srwatson -bindir BINDIR specify path to binaries directory (for systems where 2439243750Srwatson libraries must be found in the PATH setting at runtime) 2440243750Srwatson -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 2441243750Srwatson -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 2442243750Srwatson -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 2443243750Srwatson -export-symbols SYMFILE 2444243750Srwatson try to export only the symbols listed in SYMFILE 2445243750Srwatson -export-symbols-regex REGEX 2446243750Srwatson try to export only the symbols matching REGEX 2447243750Srwatson -LLIBDIR search LIBDIR for required installed libraries 2448243750Srwatson -lNAME OUTPUT-FILE requires the installed library libNAME 2449243750Srwatson -module build a library that can dlopened 2450243750Srwatson -no-fast-install disable the fast-install mode 2451243750Srwatson -no-install link a not-installable executable 2452243750Srwatson -no-undefined declare that a library does not refer to external symbols 2453243750Srwatson -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 2454243750Srwatson -objectlist FILE Use a list of object files found in FILE to specify objects 2455243750Srwatson -precious-files-regex REGEX 2456243750Srwatson don't remove output files matching REGEX 2457243750Srwatson -release RELEASE specify package release information 2458243750Srwatson -rpath LIBDIR the created library will eventually be installed in LIBDIR 2459243750Srwatson -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 2460243750Srwatson -shared only do dynamic linking of libtool libraries 2461243750Srwatson -shrext SUFFIX override the standard shared library file extension 2462243750Srwatson -static do not do any dynamic linking of uninstalled libtool libraries 2463243750Srwatson -static-libtool-libs 2464243750Srwatson do not do any dynamic linking of libtool libraries 2465243750Srwatson -version-info CURRENT[:REVISION[:AGE]] 2466243750Srwatson specify library version info [each variable defaults to 0] 2467243750Srwatson -weak LIBNAME declare that the target provides the LIBNAME interface 2468243750Srwatson -Wc,FLAG 2469243750Srwatson -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 2470243750Srwatson -Wl,FLAG 2471243750Srwatson -Xlinker FLAG pass linker-specific FLAG directly to the linker 2472243750Srwatson -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2473243750Srwatson 2474243750SrwatsonAll other options (arguments beginning with \`-') are ignored. 2475243750Srwatson 2476243750SrwatsonEvery other argument is treated as a filename. Files ending in \`.la' are 2477243750Srwatsontreated as uninstalled libtool libraries, other files are standard or library 2478243750Srwatsonobject files. 2479243750Srwatson 2480243750SrwatsonIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 2481243750Srwatsononly library objects (\`.lo' files) may be specified, and \`-rpath' is 2482243750Srwatsonrequired, except when creating a convenience library. 2483243750Srwatson 2484243750SrwatsonIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 2485243750Srwatsonusing \`ar' and \`ranlib', or on Windows using \`lib'. 2486243750Srwatson 2487243750SrwatsonIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 2488243750Srwatsonis created, otherwise an executable program is created." 2489243750Srwatson ;; 2490243750Srwatson 2491243750Srwatson uninstall) 2492243750Srwatson $ECHO \ 2493243750Srwatson"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2494243750Srwatson 2495243750SrwatsonRemove libraries from an installation directory. 2496243750Srwatson 2497243750SrwatsonRM is the name of the program to use to delete files associated with each FILE 2498243750Srwatson(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2499243750Srwatsonto RM. 2500243750Srwatson 2501243750SrwatsonIf FILE is a libtool library, all the files associated with it are deleted. 2502243750SrwatsonOtherwise, only FILE itself is deleted using RM." 2503243750Srwatson ;; 2504243750Srwatson 2505243750Srwatson *) 2506243750Srwatson func_fatal_help "invalid operation mode \`$opt_mode'" 2507243750Srwatson ;; 2508243750Srwatson esac 2509243750Srwatson 2510243750Srwatson echo 2511243750Srwatson $ECHO "Try \`$progname --help' for more information about other modes." 2512243750Srwatson} 2513243750Srwatson 2514243750Srwatson# Now that we've collected a possible --mode arg, show help if necessary 2515243750Srwatsonif $opt_help; then 2516243750Srwatson if test "$opt_help" = :; then 2517243750Srwatson func_mode_help 2518243750Srwatson else 2519243750Srwatson { 2520243750Srwatson func_help noexit 2521243750Srwatson for opt_mode in compile link execute install finish uninstall clean; do 2522243750Srwatson func_mode_help 2523243750Srwatson done 2524243750Srwatson } | sed -n '1p; 2,$s/^Usage:/ or: /p' 2525243750Srwatson { 2526243750Srwatson func_help noexit 2527243750Srwatson for opt_mode in compile link execute install finish uninstall clean; do 2528243750Srwatson echo 2529243750Srwatson func_mode_help 2530243750Srwatson done 2531243750Srwatson } | 2532243750Srwatson sed '1d 2533243750Srwatson /^When reporting/,/^Report/{ 2534243750Srwatson H 2535243750Srwatson d 2536243750Srwatson } 2537243750Srwatson $x 2538243750Srwatson /information about other modes/d 2539243750Srwatson /more detailed .*MODE/d 2540243750Srwatson s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 2541243750Srwatson fi 2542243750Srwatson exit $? 2543243750Srwatsonfi 2544243750Srwatson 2545243750Srwatson 2546243750Srwatson# func_mode_execute arg... 2547243750Srwatsonfunc_mode_execute () 2548243750Srwatson{ 2549243750Srwatson $opt_debug 2550243750Srwatson # The first argument is the command name. 2551243750Srwatson cmd="$nonopt" 2552243750Srwatson test -z "$cmd" && \ 2553243750Srwatson func_fatal_help "you must specify a COMMAND" 2554243750Srwatson 2555243750Srwatson # Handle -dlopen flags immediately. 2556243750Srwatson for file in $opt_dlopen; do 2557243750Srwatson test -f "$file" \ 2558243750Srwatson || func_fatal_help "\`$file' is not a file" 2559243750Srwatson 2560243750Srwatson dir= 2561243750Srwatson case $file in 2562243750Srwatson *.la) 2563243750Srwatson func_resolve_sysroot "$file" 2564243750Srwatson file=$func_resolve_sysroot_result 2565243750Srwatson 2566243750Srwatson # Check to see that this really is a libtool archive. 2567243750Srwatson func_lalib_unsafe_p "$file" \ 2568243750Srwatson || func_fatal_help "\`$lib' is not a valid libtool archive" 2569243750Srwatson 2570243750Srwatson # Read the libtool library. 2571243750Srwatson dlname= 2572243750Srwatson library_names= 2573243750Srwatson func_source "$file" 2574243750Srwatson 2575243750Srwatson # Skip this library if it cannot be dlopened. 2576243750Srwatson if test -z "$dlname"; then 2577243750Srwatson # Warn if it was a shared library. 2578243750Srwatson test -n "$library_names" && \ 2579243750Srwatson func_warning "\`$file' was not linked with \`-export-dynamic'" 2580243750Srwatson continue 2581243750Srwatson fi 2582243750Srwatson 2583243750Srwatson func_dirname "$file" "" "." 2584243750Srwatson dir="$func_dirname_result" 2585243750Srwatson 2586243750Srwatson if test -f "$dir/$objdir/$dlname"; then 2587243750Srwatson func_append dir "/$objdir" 2588156283Srwatson else 2589243750Srwatson if test ! -f "$dir/$dlname"; then 2590243750Srwatson func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 2591243750Srwatson fi 2592156283Srwatson fi 2593243750Srwatson ;; 2594243750Srwatson 2595243750Srwatson *.lo) 2596243750Srwatson # Just add the directory containing the .lo file. 2597243750Srwatson func_dirname "$file" "" "." 2598243750Srwatson dir="$func_dirname_result" 2599243750Srwatson ;; 2600243750Srwatson 2601243750Srwatson *) 2602243750Srwatson func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 2603243750Srwatson continue 2604243750Srwatson ;; 2605243750Srwatson esac 2606243750Srwatson 2607243750Srwatson # Get the absolute pathname. 2608243750Srwatson absdir=`cd "$dir" && pwd` 2609243750Srwatson test -n "$absdir" && dir="$absdir" 2610243750Srwatson 2611243750Srwatson # Now add the directory to shlibpath_var. 2612243750Srwatson if eval "test -z \"\$$shlibpath_var\""; then 2613243750Srwatson eval "$shlibpath_var=\"\$dir\"" 2614243750Srwatson else 2615243750Srwatson eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2616156283Srwatson fi 2617243750Srwatson done 2618156283Srwatson 2619243750Srwatson # This variable tells wrapper scripts just to set shlibpath_var 2620243750Srwatson # rather than running their programs. 2621243750Srwatson libtool_execute_magic="$magic" 2622156283Srwatson 2623243750Srwatson # Check if any of the arguments is a wrapper script. 2624243750Srwatson args= 2625243750Srwatson for file 2626243750Srwatson do 2627243750Srwatson case $file in 2628243750Srwatson -* | *.la | *.lo ) ;; 2629243750Srwatson *) 2630243750Srwatson # Do a test to see if this is really a libtool program. 2631243750Srwatson if func_ltwrapper_script_p "$file"; then 2632243750Srwatson func_source "$file" 2633243750Srwatson # Transform arg to wrapped name. 2634243750Srwatson file="$progdir/$program" 2635243750Srwatson elif func_ltwrapper_executable_p "$file"; then 2636243750Srwatson func_ltwrapper_scriptname "$file" 2637243750Srwatson func_source "$func_ltwrapper_scriptname_result" 2638243750Srwatson # Transform arg to wrapped name. 2639243750Srwatson file="$progdir/$program" 2640243750Srwatson fi 2641243750Srwatson ;; 2642243750Srwatson esac 2643243750Srwatson # Quote arguments (to preserve shell metacharacters). 2644243750Srwatson func_append_quoted args "$file" 2645243750Srwatson done 2646243750Srwatson 2647243750Srwatson if test "X$opt_dry_run" = Xfalse; then 2648243750Srwatson if test -n "$shlibpath_var"; then 2649243750Srwatson # Export the shlibpath_var. 2650243750Srwatson eval "export $shlibpath_var" 2651243750Srwatson fi 2652243750Srwatson 2653243750Srwatson # Restore saved environment variables 2654243750Srwatson for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 2655243750Srwatson do 2656243750Srwatson eval "if test \"\${save_$lt_var+set}\" = set; then 2657243750Srwatson $lt_var=\$save_$lt_var; export $lt_var 2658243750Srwatson else 2659243750Srwatson $lt_unset $lt_var 2660243750Srwatson fi" 2661243750Srwatson done 2662243750Srwatson 2663243750Srwatson # Now prepare to actually exec the command. 2664243750Srwatson exec_cmd="\$cmd$args" 2665156283Srwatson else 2666243750Srwatson # Display what would be done. 2667243750Srwatson if test -n "$shlibpath_var"; then 2668243750Srwatson eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 2669243750Srwatson echo "export $shlibpath_var" 2670243750Srwatson fi 2671243750Srwatson $ECHO "$cmd$args" 2672243750Srwatson exit $EXIT_SUCCESS 2673243750Srwatson fi 2674243750Srwatson} 2675156283Srwatson 2676243750Srwatsontest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2677243750Srwatson 2678243750Srwatson 2679243750Srwatson# func_mode_finish arg... 2680243750Srwatsonfunc_mode_finish () 2681243750Srwatson{ 2682243750Srwatson $opt_debug 2683243750Srwatson libs= 2684243750Srwatson libdirs= 2685243750Srwatson admincmds= 2686243750Srwatson 2687243750Srwatson for opt in "$nonopt" ${1+"$@"} 2688243750Srwatson do 2689243750Srwatson if test -d "$opt"; then 2690243750Srwatson func_append libdirs " $opt" 2691243750Srwatson 2692243750Srwatson elif test -f "$opt"; then 2693243750Srwatson if func_lalib_unsafe_p "$opt"; then 2694243750Srwatson func_append libs " $opt" 2695243750Srwatson else 2696243750Srwatson func_warning "\`$opt' is not a valid libtool archive" 2697243750Srwatson fi 2698243750Srwatson 2699243750Srwatson else 2700243750Srwatson func_fatal_error "invalid argument \`$opt'" 2701243750Srwatson fi 2702243750Srwatson done 2703243750Srwatson 2704243750Srwatson if test -n "$libs"; then 2705243750Srwatson if test -n "$lt_sysroot"; then 2706243750Srwatson sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 2707243750Srwatson sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 2708243750Srwatson else 2709243750Srwatson sysroot_cmd= 2710243750Srwatson fi 2711243750Srwatson 2712243750Srwatson # Remove sysroot references 2713243750Srwatson if $opt_dry_run; then 2714243750Srwatson for lib in $libs; do 2715243750Srwatson echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 2716243750Srwatson done 2717243750Srwatson else 2718243750Srwatson tmpdir=`func_mktempdir` 2719243750Srwatson for lib in $libs; do 2720243750Srwatson sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 2721243750Srwatson > $tmpdir/tmp-la 2722243750Srwatson mv -f $tmpdir/tmp-la $lib 2723243750Srwatson done 2724243750Srwatson ${RM}r "$tmpdir" 2725243750Srwatson fi 2726156283Srwatson fi 2727156283Srwatson 2728243750Srwatson if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2729243750Srwatson for libdir in $libdirs; do 2730243750Srwatson if test -n "$finish_cmds"; then 2731243750Srwatson # Do each command in the finish commands. 2732243750Srwatson func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 2733243750Srwatson'"$cmd"'"' 2734243750Srwatson fi 2735243750Srwatson if test -n "$finish_eval"; then 2736243750Srwatson # Do the single finish_eval. 2737243750Srwatson eval cmds=\"$finish_eval\" 2738243750Srwatson $opt_dry_run || eval "$cmds" || func_append admincmds " 2739243750Srwatson $cmds" 2740243750Srwatson fi 2741243750Srwatson done 2742243750Srwatson fi 2743156283Srwatson 2744243750Srwatson # Exit here if they wanted silent mode. 2745243750Srwatson $opt_silent && exit $EXIT_SUCCESS 2746243750Srwatson 2747243750Srwatson if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2748243750Srwatson echo "----------------------------------------------------------------------" 2749243750Srwatson echo "Libraries have been installed in:" 2750243750Srwatson for libdir in $libdirs; do 2751243750Srwatson $ECHO " $libdir" 2752243750Srwatson done 2753243750Srwatson echo 2754243750Srwatson echo "If you ever happen to want to link against installed libraries" 2755243750Srwatson echo "in a given directory, LIBDIR, you must either use libtool, and" 2756243750Srwatson echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 2757243750Srwatson echo "flag during linking and do at least one of the following:" 2758243750Srwatson if test -n "$shlibpath_var"; then 2759243750Srwatson echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 2760243750Srwatson echo " during execution" 2761243750Srwatson fi 2762243750Srwatson if test -n "$runpath_var"; then 2763243750Srwatson echo " - add LIBDIR to the \`$runpath_var' environment variable" 2764243750Srwatson echo " during linking" 2765243750Srwatson fi 2766243750Srwatson if test -n "$hardcode_libdir_flag_spec"; then 2767243750Srwatson libdir=LIBDIR 2768243750Srwatson eval flag=\"$hardcode_libdir_flag_spec\" 2769243750Srwatson 2770243750Srwatson $ECHO " - use the \`$flag' linker flag" 2771243750Srwatson fi 2772243750Srwatson if test -n "$admincmds"; then 2773243750Srwatson $ECHO " - have your system administrator run these commands:$admincmds" 2774243750Srwatson fi 2775243750Srwatson if test -f /etc/ld.so.conf; then 2776243750Srwatson echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 2777243750Srwatson fi 2778243750Srwatson echo 2779243750Srwatson 2780243750Srwatson echo "See any operating system documentation about shared libraries for" 2781243750Srwatson case $host in 2782243750Srwatson solaris2.[6789]|solaris2.1[0-9]) 2783243750Srwatson echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 2784243750Srwatson echo "pages." 2785243750Srwatson ;; 2786243750Srwatson *) 2787243750Srwatson echo "more information, such as the ld(1) and ld.so(8) manual pages." 2788243750Srwatson ;; 2789243750Srwatson esac 2790243750Srwatson echo "----------------------------------------------------------------------" 2791156283Srwatson fi 2792243750Srwatson exit $EXIT_SUCCESS 2793243750Srwatson} 2794156283Srwatson 2795243750Srwatsontest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2796243750Srwatson 2797243750Srwatson 2798243750Srwatson# func_mode_install arg... 2799243750Srwatsonfunc_mode_install () 2800243750Srwatson{ 2801243750Srwatson $opt_debug 2802243750Srwatson # There may be an optional sh(1) argument at the beginning of 2803243750Srwatson # install_prog (especially on Windows NT). 2804243750Srwatson if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 2805243750Srwatson # Allow the use of GNU shtool's install command. 2806243750Srwatson case $nonopt in *shtool*) :;; *) false;; esac; then 2807243750Srwatson # Aesthetically quote it. 2808243750Srwatson func_quote_for_eval "$nonopt" 2809243750Srwatson install_prog="$func_quote_for_eval_result " 2810243750Srwatson arg=$1 2811243750Srwatson shift 2812243750Srwatson else 2813243750Srwatson install_prog= 2814243750Srwatson arg=$nonopt 2815243750Srwatson fi 2816243750Srwatson 2817243750Srwatson # The real first argument should be the name of the installation program. 2818243750Srwatson # Aesthetically quote it. 2819243750Srwatson func_quote_for_eval "$arg" 2820243750Srwatson func_append install_prog "$func_quote_for_eval_result" 2821243750Srwatson install_shared_prog=$install_prog 2822243750Srwatson case " $install_prog " in 2823243750Srwatson *[\\\ /]cp\ *) install_cp=: ;; 2824243750Srwatson *) install_cp=false ;; 2825243750Srwatson esac 2826243750Srwatson 2827243750Srwatson # We need to accept at least all the BSD install flags. 2828243750Srwatson dest= 2829243750Srwatson files= 2830243750Srwatson opts= 2831243750Srwatson prev= 2832243750Srwatson install_type= 2833243750Srwatson isdir=no 2834243750Srwatson stripme= 2835243750Srwatson no_mode=: 2836243750Srwatson for arg 2837243750Srwatson do 2838243750Srwatson arg2= 2839243750Srwatson if test -n "$dest"; then 2840243750Srwatson func_append files " $dest" 2841243750Srwatson dest=$arg 2842243750Srwatson continue 2843243750Srwatson fi 2844243750Srwatson 2845243750Srwatson case $arg in 2846243750Srwatson -d) isdir=yes ;; 2847243750Srwatson -f) 2848243750Srwatson if $install_cp; then :; else 2849243750Srwatson prev=$arg 2850243750Srwatson fi 2851243750Srwatson ;; 2852243750Srwatson -g | -m | -o) 2853243750Srwatson prev=$arg 2854243750Srwatson ;; 2855243750Srwatson -s) 2856243750Srwatson stripme=" -s" 2857243750Srwatson continue 2858243750Srwatson ;; 2859243750Srwatson -*) 2860243750Srwatson ;; 2861243750Srwatson *) 2862243750Srwatson # If the previous option needed an argument, then skip it. 2863243750Srwatson if test -n "$prev"; then 2864243750Srwatson if test "x$prev" = x-m && test -n "$install_override_mode"; then 2865243750Srwatson arg2=$install_override_mode 2866243750Srwatson no_mode=false 2867243750Srwatson fi 2868243750Srwatson prev= 2869243750Srwatson else 2870243750Srwatson dest=$arg 2871243750Srwatson continue 2872243750Srwatson fi 2873243750Srwatson ;; 2874243750Srwatson esac 2875243750Srwatson 2876243750Srwatson # Aesthetically quote the argument. 2877243750Srwatson func_quote_for_eval "$arg" 2878243750Srwatson func_append install_prog " $func_quote_for_eval_result" 2879243750Srwatson if test -n "$arg2"; then 2880243750Srwatson func_quote_for_eval "$arg2" 2881243750Srwatson fi 2882243750Srwatson func_append install_shared_prog " $func_quote_for_eval_result" 2883243750Srwatson done 2884243750Srwatson 2885243750Srwatson test -z "$install_prog" && \ 2886243750Srwatson func_fatal_help "you must specify an install program" 2887243750Srwatson 2888243750Srwatson test -n "$prev" && \ 2889243750Srwatson func_fatal_help "the \`$prev' option requires an argument" 2890243750Srwatson 2891243750Srwatson if test -n "$install_override_mode" && $no_mode; then 2892243750Srwatson if $install_cp; then :; else 2893243750Srwatson func_quote_for_eval "$install_override_mode" 2894243750Srwatson func_append install_shared_prog " -m $func_quote_for_eval_result" 2895243750Srwatson fi 2896243750Srwatson fi 2897243750Srwatson 2898243750Srwatson if test -z "$files"; then 2899243750Srwatson if test -z "$dest"; then 2900243750Srwatson func_fatal_help "no file or destination specified" 2901243750Srwatson else 2902243750Srwatson func_fatal_help "you must specify a destination" 2903243750Srwatson fi 2904243750Srwatson fi 2905243750Srwatson 2906243750Srwatson # Strip any trailing slash from the destination. 2907243750Srwatson func_stripname '' '/' "$dest" 2908243750Srwatson dest=$func_stripname_result 2909243750Srwatson 2910243750Srwatson # Check to see that the destination is a directory. 2911243750Srwatson test -d "$dest" && isdir=yes 2912243750Srwatson if test "$isdir" = yes; then 2913243750Srwatson destdir="$dest" 2914243750Srwatson destname= 2915243750Srwatson else 2916243750Srwatson func_dirname_and_basename "$dest" "" "." 2917243750Srwatson destdir="$func_dirname_result" 2918243750Srwatson destname="$func_basename_result" 2919243750Srwatson 2920243750Srwatson # Not a directory, so check to see that there is only one file specified. 2921243750Srwatson set dummy $files; shift 2922243750Srwatson test "$#" -gt 1 && \ 2923243750Srwatson func_fatal_help "\`$dest' is not a directory" 2924243750Srwatson fi 2925243750Srwatson case $destdir in 2926243750Srwatson [\\/]* | [A-Za-z]:[\\/]*) ;; 2927243750Srwatson *) 2928243750Srwatson for file in $files; do 2929243750Srwatson case $file in 2930243750Srwatson *.lo) ;; 2931243750Srwatson *) 2932243750Srwatson func_fatal_help "\`$destdir' must be an absolute directory name" 2933243750Srwatson ;; 2934243750Srwatson esac 2935243750Srwatson done 2936243750Srwatson ;; 2937243750Srwatson esac 2938243750Srwatson 2939243750Srwatson # This variable tells wrapper scripts just to set variables rather 2940243750Srwatson # than running their programs. 2941243750Srwatson libtool_install_magic="$magic" 2942243750Srwatson 2943243750Srwatson staticlibs= 2944243750Srwatson future_libdirs= 2945243750Srwatson current_libdirs= 2946243750Srwatson for file in $files; do 2947243750Srwatson 2948243750Srwatson # Do each installation. 2949243750Srwatson case $file in 2950243750Srwatson *.$libext) 2951243750Srwatson # Do the static libraries later. 2952243750Srwatson func_append staticlibs " $file" 2953243750Srwatson ;; 2954243750Srwatson 2955243750Srwatson *.la) 2956243750Srwatson func_resolve_sysroot "$file" 2957243750Srwatson file=$func_resolve_sysroot_result 2958243750Srwatson 2959243750Srwatson # Check to see that this really is a libtool archive. 2960243750Srwatson func_lalib_unsafe_p "$file" \ 2961243750Srwatson || func_fatal_help "\`$file' is not a valid libtool archive" 2962243750Srwatson 2963243750Srwatson library_names= 2964243750Srwatson old_library= 2965243750Srwatson relink_command= 2966243750Srwatson func_source "$file" 2967243750Srwatson 2968243750Srwatson # Add the libdir to current_libdirs if it is the destination. 2969243750Srwatson if test "X$destdir" = "X$libdir"; then 2970243750Srwatson case "$current_libdirs " in 2971243750Srwatson *" $libdir "*) ;; 2972243750Srwatson *) func_append current_libdirs " $libdir" ;; 2973243750Srwatson esac 2974243750Srwatson else 2975243750Srwatson # Note the libdir as a future libdir. 2976243750Srwatson case "$future_libdirs " in 2977243750Srwatson *" $libdir "*) ;; 2978243750Srwatson *) func_append future_libdirs " $libdir" ;; 2979243750Srwatson esac 2980243750Srwatson fi 2981243750Srwatson 2982243750Srwatson func_dirname "$file" "/" "" 2983243750Srwatson dir="$func_dirname_result" 2984243750Srwatson func_append dir "$objdir" 2985243750Srwatson 2986243750Srwatson if test -n "$relink_command"; then 2987243750Srwatson # Determine the prefix the user has applied to our future dir. 2988243750Srwatson inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2989243750Srwatson 2990243750Srwatson # Don't allow the user to place us outside of our expected 2991243750Srwatson # location b/c this prevents finding dependent libraries that 2992243750Srwatson # are installed to the same prefix. 2993243750Srwatson # At present, this check doesn't affect windows .dll's that 2994243750Srwatson # are installed into $libdir/../bin (currently, that works fine) 2995243750Srwatson # but it's something to keep an eye on. 2996243750Srwatson test "$inst_prefix_dir" = "$destdir" && \ 2997243750Srwatson func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 2998243750Srwatson 2999243750Srwatson if test -n "$inst_prefix_dir"; then 3000243750Srwatson # Stick the inst_prefix_dir data into the link command. 3001243750Srwatson relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 3002243750Srwatson else 3003243750Srwatson relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 3004243750Srwatson fi 3005243750Srwatson 3006243750Srwatson func_warning "relinking \`$file'" 3007243750Srwatson func_show_eval "$relink_command" \ 3008243750Srwatson 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 3009243750Srwatson fi 3010243750Srwatson 3011243750Srwatson # See the names of the shared library. 3012243750Srwatson set dummy $library_names; shift 3013243750Srwatson if test -n "$1"; then 3014243750Srwatson realname="$1" 3015243750Srwatson shift 3016243750Srwatson 3017243750Srwatson srcname="$realname" 3018243750Srwatson test -n "$relink_command" && srcname="$realname"T 3019243750Srwatson 3020243750Srwatson # Install the shared library and build the symlinks. 3021243750Srwatson func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 3022243750Srwatson 'exit $?' 3023243750Srwatson tstripme="$stripme" 3024243750Srwatson case $host_os in 3025243750Srwatson cygwin* | mingw* | pw32* | cegcc*) 3026243750Srwatson case $realname in 3027243750Srwatson *.dll.a) 3028243750Srwatson tstripme="" 3029243750Srwatson ;; 3030243750Srwatson esac 3031243750Srwatson ;; 3032243750Srwatson esac 3033243750Srwatson if test -n "$tstripme" && test -n "$striplib"; then 3034243750Srwatson func_show_eval "$striplib $destdir/$realname" 'exit $?' 3035243750Srwatson fi 3036243750Srwatson 3037243750Srwatson if test "$#" -gt 0; then 3038243750Srwatson # Delete the old symlinks, and create new ones. 3039243750Srwatson # Try `ln -sf' first, because the `ln' binary might depend on 3040243750Srwatson # the symlink we replace! Solaris /bin/ln does not understand -f, 3041243750Srwatson # so we also need to try rm && ln -s. 3042243750Srwatson for linkname 3043243750Srwatson do 3044243750Srwatson test "$linkname" != "$realname" \ 3045243750Srwatson && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3046243750Srwatson done 3047243750Srwatson fi 3048243750Srwatson 3049243750Srwatson # Do each command in the postinstall commands. 3050243750Srwatson lib="$destdir/$realname" 3051243750Srwatson func_execute_cmds "$postinstall_cmds" 'exit $?' 3052243750Srwatson fi 3053243750Srwatson 3054243750Srwatson # Install the pseudo-library for information purposes. 3055243750Srwatson func_basename "$file" 3056243750Srwatson name="$func_basename_result" 3057243750Srwatson instname="$dir/$name"i 3058243750Srwatson func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3059243750Srwatson 3060243750Srwatson # Maybe install the static library, too. 3061243750Srwatson test -n "$old_library" && func_append staticlibs " $dir/$old_library" 3062243750Srwatson ;; 3063243750Srwatson 3064243750Srwatson *.lo) 3065243750Srwatson # Install (i.e. copy) a libtool object. 3066243750Srwatson 3067243750Srwatson # Figure out destination file name, if it wasn't already specified. 3068243750Srwatson if test -n "$destname"; then 3069243750Srwatson destfile="$destdir/$destname" 3070243750Srwatson else 3071243750Srwatson func_basename "$file" 3072243750Srwatson destfile="$func_basename_result" 3073243750Srwatson destfile="$destdir/$destfile" 3074243750Srwatson fi 3075243750Srwatson 3076243750Srwatson # Deduce the name of the destination old-style object file. 3077243750Srwatson case $destfile in 3078243750Srwatson *.lo) 3079243750Srwatson func_lo2o "$destfile" 3080243750Srwatson staticdest=$func_lo2o_result 3081243750Srwatson ;; 3082243750Srwatson *.$objext) 3083243750Srwatson staticdest="$destfile" 3084243750Srwatson destfile= 3085243750Srwatson ;; 3086243750Srwatson *) 3087243750Srwatson func_fatal_help "cannot copy a libtool object to \`$destfile'" 3088243750Srwatson ;; 3089243750Srwatson esac 3090243750Srwatson 3091243750Srwatson # Install the libtool object if requested. 3092243750Srwatson test -n "$destfile" && \ 3093243750Srwatson func_show_eval "$install_prog $file $destfile" 'exit $?' 3094243750Srwatson 3095243750Srwatson # Install the old object if enabled. 3096243750Srwatson if test "$build_old_libs" = yes; then 3097243750Srwatson # Deduce the name of the old-style object file. 3098243750Srwatson func_lo2o "$file" 3099243750Srwatson staticobj=$func_lo2o_result 3100243750Srwatson func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3101243750Srwatson fi 3102243750Srwatson exit $EXIT_SUCCESS 3103243750Srwatson ;; 3104243750Srwatson 3105243750Srwatson *) 3106243750Srwatson # Figure out destination file name, if it wasn't already specified. 3107243750Srwatson if test -n "$destname"; then 3108243750Srwatson destfile="$destdir/$destname" 3109243750Srwatson else 3110243750Srwatson func_basename "$file" 3111243750Srwatson destfile="$func_basename_result" 3112243750Srwatson destfile="$destdir/$destfile" 3113243750Srwatson fi 3114243750Srwatson 3115243750Srwatson # If the file is missing, and there is a .exe on the end, strip it 3116243750Srwatson # because it is most likely a libtool script we actually want to 3117243750Srwatson # install 3118243750Srwatson stripped_ext="" 3119243750Srwatson case $file in 3120243750Srwatson *.exe) 3121243750Srwatson if test ! -f "$file"; then 3122243750Srwatson func_stripname '' '.exe' "$file" 3123243750Srwatson file=$func_stripname_result 3124243750Srwatson stripped_ext=".exe" 3125243750Srwatson fi 3126243750Srwatson ;; 3127243750Srwatson esac 3128243750Srwatson 3129243750Srwatson # Do a test to see if this is really a libtool program. 3130243750Srwatson case $host in 3131243750Srwatson *cygwin* | *mingw*) 3132243750Srwatson if func_ltwrapper_executable_p "$file"; then 3133243750Srwatson func_ltwrapper_scriptname "$file" 3134243750Srwatson wrapper=$func_ltwrapper_scriptname_result 3135243750Srwatson else 3136243750Srwatson func_stripname '' '.exe' "$file" 3137243750Srwatson wrapper=$func_stripname_result 3138243750Srwatson fi 3139243750Srwatson ;; 3140243750Srwatson *) 3141243750Srwatson wrapper=$file 3142243750Srwatson ;; 3143243750Srwatson esac 3144243750Srwatson if func_ltwrapper_script_p "$wrapper"; then 3145243750Srwatson notinst_deplibs= 3146243750Srwatson relink_command= 3147243750Srwatson 3148243750Srwatson func_source "$wrapper" 3149243750Srwatson 3150243750Srwatson # Check the variables that should have been set. 3151243750Srwatson test -z "$generated_by_libtool_version" && \ 3152243750Srwatson func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3153243750Srwatson 3154243750Srwatson finalize=yes 3155243750Srwatson for lib in $notinst_deplibs; do 3156243750Srwatson # Check to see that each library is installed. 3157243750Srwatson libdir= 3158243750Srwatson if test -f "$lib"; then 3159243750Srwatson func_source "$lib" 3160243750Srwatson fi 3161243750Srwatson libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 3162243750Srwatson if test -n "$libdir" && test ! -f "$libfile"; then 3163243750Srwatson func_warning "\`$lib' has not been installed in \`$libdir'" 3164243750Srwatson finalize=no 3165243750Srwatson fi 3166243750Srwatson done 3167243750Srwatson 3168243750Srwatson relink_command= 3169243750Srwatson func_source "$wrapper" 3170243750Srwatson 3171243750Srwatson outputname= 3172243750Srwatson if test "$fast_install" = no && test -n "$relink_command"; then 3173243750Srwatson $opt_dry_run || { 3174243750Srwatson if test "$finalize" = yes; then 3175243750Srwatson tmpdir=`func_mktempdir` 3176243750Srwatson func_basename "$file$stripped_ext" 3177243750Srwatson file="$func_basename_result" 3178243750Srwatson outputname="$tmpdir/$file" 3179243750Srwatson # Replace the output file specification. 3180243750Srwatson relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 3181243750Srwatson 3182243750Srwatson $opt_silent || { 3183243750Srwatson func_quote_for_expand "$relink_command" 3184243750Srwatson eval "func_echo $func_quote_for_expand_result" 3185243750Srwatson } 3186243750Srwatson if eval "$relink_command"; then : 3187243750Srwatson else 3188243750Srwatson func_error "error: relink \`$file' with the above command before installing it" 3189243750Srwatson $opt_dry_run || ${RM}r "$tmpdir" 3190243750Srwatson continue 3191243750Srwatson fi 3192243750Srwatson file="$outputname" 3193243750Srwatson else 3194243750Srwatson func_warning "cannot relink \`$file'" 3195243750Srwatson fi 3196243750Srwatson } 3197243750Srwatson else 3198243750Srwatson # Install the binary that we compiled earlier. 3199243750Srwatson file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 3200243750Srwatson fi 3201243750Srwatson fi 3202243750Srwatson 3203243750Srwatson # remove .exe since cygwin /usr/bin/install will append another 3204243750Srwatson # one anyway 3205243750Srwatson case $install_prog,$host in 3206243750Srwatson */usr/bin/install*,*cygwin*) 3207243750Srwatson case $file:$destfile in 3208243750Srwatson *.exe:*.exe) 3209243750Srwatson # this is ok 3210243750Srwatson ;; 3211243750Srwatson *.exe:*) 3212243750Srwatson destfile=$destfile.exe 3213243750Srwatson ;; 3214243750Srwatson *:*.exe) 3215243750Srwatson func_stripname '' '.exe' "$destfile" 3216243750Srwatson destfile=$func_stripname_result 3217243750Srwatson ;; 3218243750Srwatson esac 3219243750Srwatson ;; 3220243750Srwatson esac 3221243750Srwatson func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 3222243750Srwatson $opt_dry_run || if test -n "$outputname"; then 3223243750Srwatson ${RM}r "$tmpdir" 3224243750Srwatson fi 3225243750Srwatson ;; 3226243750Srwatson esac 3227243750Srwatson done 3228243750Srwatson 3229243750Srwatson for file in $staticlibs; do 3230243750Srwatson func_basename "$file" 3231243750Srwatson name="$func_basename_result" 3232243750Srwatson 3233243750Srwatson # Set up the ranlib parameters. 3234243750Srwatson oldlib="$destdir/$name" 3235243750Srwatson func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 3236243750Srwatson tool_oldlib=$func_to_tool_file_result 3237243750Srwatson 3238243750Srwatson func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 3239243750Srwatson 3240243750Srwatson if test -n "$stripme" && test -n "$old_striplib"; then 3241243750Srwatson func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 3242243750Srwatson fi 3243243750Srwatson 3244243750Srwatson # Do each command in the postinstall commands. 3245243750Srwatson func_execute_cmds "$old_postinstall_cmds" 'exit $?' 3246243750Srwatson done 3247243750Srwatson 3248243750Srwatson test -n "$future_libdirs" && \ 3249243750Srwatson func_warning "remember to run \`$progname --finish$future_libdirs'" 3250243750Srwatson 3251243750Srwatson if test -n "$current_libdirs"; then 3252243750Srwatson # Maybe just do a dry run. 3253243750Srwatson $opt_dry_run && current_libdirs=" -n$current_libdirs" 3254243750Srwatson exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 3255243750Srwatson else 3256243750Srwatson exit $EXIT_SUCCESS 3257243750Srwatson fi 3258243750Srwatson} 3259243750Srwatson 3260243750Srwatsontest "$opt_mode" = install && func_mode_install ${1+"$@"} 3261243750Srwatson 3262243750Srwatson 3263243750Srwatson# func_generate_dlsyms outputname originator pic_p 3264243750Srwatson# Extract symbols from dlprefiles and create ${outputname}S.o with 3265243750Srwatson# a dlpreopen symbol table. 3266243750Srwatsonfunc_generate_dlsyms () 3267243750Srwatson{ 3268243750Srwatson $opt_debug 3269243750Srwatson my_outputname="$1" 3270243750Srwatson my_originator="$2" 3271243750Srwatson my_pic_p="${3-no}" 3272243750Srwatson my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 3273243750Srwatson my_dlsyms= 3274243750Srwatson 3275243750Srwatson if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 3276243750Srwatson if test -n "$NM" && test -n "$global_symbol_pipe"; then 3277243750Srwatson my_dlsyms="${my_outputname}S.c" 3278243750Srwatson else 3279243750Srwatson func_error "not configured to extract global symbols from dlpreopened files" 3280243750Srwatson fi 3281243750Srwatson fi 3282243750Srwatson 3283243750Srwatson if test -n "$my_dlsyms"; then 3284243750Srwatson case $my_dlsyms in 3285243750Srwatson "") ;; 3286243750Srwatson *.c) 3287243750Srwatson # Discover the nlist of each of the dlfiles. 3288243750Srwatson nlist="$output_objdir/${my_outputname}.nm" 3289243750Srwatson 3290243750Srwatson func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3291243750Srwatson 3292243750Srwatson # Parse the name list into a source file. 3293243750Srwatson func_verbose "creating $output_objdir/$my_dlsyms" 3294243750Srwatson 3295243750Srwatson $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 3296243750Srwatson/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 3297243750Srwatson/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3298243750Srwatson 3299243750Srwatson#ifdef __cplusplus 3300243750Srwatsonextern \"C\" { 3301243750Srwatson#endif 3302243750Srwatson 3303243750Srwatson#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 3304243750Srwatson#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 3305243750Srwatson#endif 3306243750Srwatson 3307243750Srwatson/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 3308243750Srwatson#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 3309243750Srwatson/* DATA imports from DLLs on WIN32 con't be const, because runtime 3310243750Srwatson relocations are performed -- see ld's documentation on pseudo-relocs. */ 3311243750Srwatson# define LT_DLSYM_CONST 3312243750Srwatson#elif defined(__osf__) 3313243750Srwatson/* This system does not cope well with relocations in const data. */ 3314243750Srwatson# define LT_DLSYM_CONST 3315243750Srwatson#else 3316243750Srwatson# define LT_DLSYM_CONST const 3317243750Srwatson#endif 3318243750Srwatson 3319243750Srwatson/* External symbol declarations for the compiler. */\ 3320243750Srwatson" 3321243750Srwatson 3322243750Srwatson if test "$dlself" = yes; then 3323243750Srwatson func_verbose "generating symbol list for \`$output'" 3324243750Srwatson 3325243750Srwatson $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3326243750Srwatson 3327243750Srwatson # Add our own program objects to the symbol list. 3328243750Srwatson progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 3329243750Srwatson for progfile in $progfiles; do 3330243750Srwatson func_to_tool_file "$progfile" func_convert_file_msys_to_w32 3331243750Srwatson func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 3332243750Srwatson $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3333243750Srwatson done 3334243750Srwatson 3335243750Srwatson if test -n "$exclude_expsyms"; then 3336243750Srwatson $opt_dry_run || { 3337243750Srwatson eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 3338243750Srwatson eval '$MV "$nlist"T "$nlist"' 3339243750Srwatson } 3340243750Srwatson fi 3341243750Srwatson 3342243750Srwatson if test -n "$export_symbols_regex"; then 3343243750Srwatson $opt_dry_run || { 3344243750Srwatson eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 3345243750Srwatson eval '$MV "$nlist"T "$nlist"' 3346243750Srwatson } 3347243750Srwatson fi 3348243750Srwatson 3349243750Srwatson # Prepare the list of exported symbols 3350243750Srwatson if test -z "$export_symbols"; then 3351243750Srwatson export_symbols="$output_objdir/$outputname.exp" 3352243750Srwatson $opt_dry_run || { 3353243750Srwatson $RM $export_symbols 3354243750Srwatson eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 3355243750Srwatson case $host in 3356243750Srwatson *cygwin* | *mingw* | *cegcc* ) 3357243750Srwatson eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3358243750Srwatson eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 3359243750Srwatson ;; 3360243750Srwatson esac 3361243750Srwatson } 3362243750Srwatson else 3363243750Srwatson $opt_dry_run || { 3364243750Srwatson eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 3365243750Srwatson eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 3366243750Srwatson eval '$MV "$nlist"T "$nlist"' 3367243750Srwatson case $host in 3368243750Srwatson *cygwin* | *mingw* | *cegcc* ) 3369243750Srwatson eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3370243750Srwatson eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 3371243750Srwatson ;; 3372243750Srwatson esac 3373243750Srwatson } 3374243750Srwatson fi 3375243750Srwatson fi 3376243750Srwatson 3377243750Srwatson for dlprefile in $dlprefiles; do 3378243750Srwatson func_verbose "extracting global C symbols from \`$dlprefile'" 3379243750Srwatson func_basename "$dlprefile" 3380243750Srwatson name="$func_basename_result" 3381243750Srwatson case $host in 3382243750Srwatson *cygwin* | *mingw* | *cegcc* ) 3383243750Srwatson # if an import library, we need to obtain dlname 3384243750Srwatson if func_win32_import_lib_p "$dlprefile"; then 3385243750Srwatson func_tr_sh "$dlprefile" 3386243750Srwatson eval "curr_lafile=\$libfile_$func_tr_sh_result" 3387243750Srwatson dlprefile_dlbasename="" 3388243750Srwatson if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 3389243750Srwatson # Use subshell, to avoid clobbering current variable values 3390243750Srwatson dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 3391243750Srwatson if test -n "$dlprefile_dlname" ; then 3392243750Srwatson func_basename "$dlprefile_dlname" 3393243750Srwatson dlprefile_dlbasename="$func_basename_result" 3394243750Srwatson else 3395243750Srwatson # no lafile. user explicitly requested -dlpreopen <import library>. 3396243750Srwatson $sharedlib_from_linklib_cmd "$dlprefile" 3397243750Srwatson dlprefile_dlbasename=$sharedlib_from_linklib_result 3398243750Srwatson fi 3399243750Srwatson fi 3400243750Srwatson $opt_dry_run || { 3401243750Srwatson if test -n "$dlprefile_dlbasename" ; then 3402243750Srwatson eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 3403243750Srwatson else 3404243750Srwatson func_warning "Could not compute DLL name from $name" 3405243750Srwatson eval '$ECHO ": $name " >> "$nlist"' 3406243750Srwatson fi 3407243750Srwatson func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3408243750Srwatson eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 3409243750Srwatson $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 3410243750Srwatson } 3411243750Srwatson else # not an import lib 3412243750Srwatson $opt_dry_run || { 3413243750Srwatson eval '$ECHO ": $name " >> "$nlist"' 3414243750Srwatson func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3415243750Srwatson eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3416243750Srwatson } 3417243750Srwatson fi 3418243750Srwatson ;; 3419243750Srwatson *) 3420243750Srwatson $opt_dry_run || { 3421243750Srwatson eval '$ECHO ": $name " >> "$nlist"' 3422243750Srwatson func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3423243750Srwatson eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3424243750Srwatson } 3425243750Srwatson ;; 3426243750Srwatson esac 3427243750Srwatson done 3428243750Srwatson 3429243750Srwatson $opt_dry_run || { 3430243750Srwatson # Make sure we have at least an empty file. 3431243750Srwatson test -f "$nlist" || : > "$nlist" 3432243750Srwatson 3433243750Srwatson if test -n "$exclude_expsyms"; then 3434243750Srwatson $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 3435243750Srwatson $MV "$nlist"T "$nlist" 3436243750Srwatson fi 3437243750Srwatson 3438243750Srwatson # Try sorting and uniquifying the output. 3439243750Srwatson if $GREP -v "^: " < "$nlist" | 3440243750Srwatson if sort -k 3 </dev/null >/dev/null 2>&1; then 3441243750Srwatson sort -k 3 3442243750Srwatson else 3443243750Srwatson sort +2 3444243750Srwatson fi | 3445243750Srwatson uniq > "$nlist"S; then 3446243750Srwatson : 3447243750Srwatson else 3448243750Srwatson $GREP -v "^: " < "$nlist" > "$nlist"S 3449243750Srwatson fi 3450243750Srwatson 3451243750Srwatson if test -f "$nlist"S; then 3452243750Srwatson eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 3453243750Srwatson else 3454243750Srwatson echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 3455243750Srwatson fi 3456243750Srwatson 3457243750Srwatson echo >> "$output_objdir/$my_dlsyms" "\ 3458243750Srwatson 3459243750Srwatson/* The mapping between symbol names and symbols. */ 3460243750Srwatsontypedef struct { 3461243750Srwatson const char *name; 3462243750Srwatson void *address; 3463243750Srwatson} lt_dlsymlist; 3464243750Srwatsonextern LT_DLSYM_CONST lt_dlsymlist 3465243750Srwatsonlt_${my_prefix}_LTX_preloaded_symbols[]; 3466243750SrwatsonLT_DLSYM_CONST lt_dlsymlist 3467243750Srwatsonlt_${my_prefix}_LTX_preloaded_symbols[] = 3468243750Srwatson{\ 3469243750Srwatson { \"$my_originator\", (void *) 0 }," 3470243750Srwatson 3471243750Srwatson case $need_lib_prefix in 3472243750Srwatson no) 3473243750Srwatson eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3474243750Srwatson ;; 3475243750Srwatson *) 3476243750Srwatson eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3477243750Srwatson ;; 3478243750Srwatson esac 3479243750Srwatson echo >> "$output_objdir/$my_dlsyms" "\ 3480243750Srwatson {0, (void *) 0} 3481243750Srwatson}; 3482243750Srwatson 3483243750Srwatson/* This works around a problem in FreeBSD linker */ 3484243750Srwatson#ifdef FREEBSD_WORKAROUND 3485243750Srwatsonstatic const void *lt_preloaded_setup() { 3486243750Srwatson return lt_${my_prefix}_LTX_preloaded_symbols; 3487243750Srwatson} 3488243750Srwatson#endif 3489243750Srwatson 3490243750Srwatson#ifdef __cplusplus 3491243750Srwatson} 3492243750Srwatson#endif\ 3493243750Srwatson" 3494243750Srwatson } # !$opt_dry_run 3495243750Srwatson 3496243750Srwatson pic_flag_for_symtable= 3497243750Srwatson case "$compile_command " in 3498243750Srwatson *" -static "*) ;; 3499243750Srwatson *) 3500243750Srwatson case $host in 3501243750Srwatson # compiling the symbol table file with pic_flag works around 3502243750Srwatson # a FreeBSD bug that causes programs to crash when -lm is 3503243750Srwatson # linked before any other PIC object. But we must not use 3504243750Srwatson # pic_flag when linking with -static. The problem exists in 3505243750Srwatson # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 3506243750Srwatson *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 3507243750Srwatson pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 3508243750Srwatson *-*-hpux*) 3509243750Srwatson pic_flag_for_symtable=" $pic_flag" ;; 3510243750Srwatson *) 3511243750Srwatson if test "X$my_pic_p" != Xno; then 3512243750Srwatson pic_flag_for_symtable=" $pic_flag" 3513243750Srwatson fi 3514243750Srwatson ;; 3515243750Srwatson esac 3516243750Srwatson ;; 3517243750Srwatson esac 3518243750Srwatson symtab_cflags= 3519243750Srwatson for arg in $LTCFLAGS; do 3520243750Srwatson case $arg in 3521243750Srwatson -pie | -fpie | -fPIE) ;; 3522243750Srwatson *) func_append symtab_cflags " $arg" ;; 3523243750Srwatson esac 3524243750Srwatson done 3525243750Srwatson 3526243750Srwatson # Now compile the dynamic symbol file. 3527243750Srwatson func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3528243750Srwatson 3529243750Srwatson # Clean up the generated files. 3530243750Srwatson func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3531243750Srwatson 3532243750Srwatson # Transform the symbol file into the correct name. 3533243750Srwatson symfileobj="$output_objdir/${my_outputname}S.$objext" 3534243750Srwatson case $host in 3535243750Srwatson *cygwin* | *mingw* | *cegcc* ) 3536243750Srwatson if test -f "$output_objdir/$my_outputname.def"; then 3537243750Srwatson compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3538243750Srwatson finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3539243750Srwatson else 3540243750Srwatson compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3541243750Srwatson finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3542243750Srwatson fi 3543243750Srwatson ;; 3544243750Srwatson *) 3545243750Srwatson compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3546243750Srwatson finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3547243750Srwatson ;; 3548243750Srwatson esac 3549243750Srwatson ;; 3550243750Srwatson *-*-freebsd*) 3551243750Srwatson # FreeBSD doesn't need this... 3552243750Srwatson ;; 3553243750Srwatson *) 3554243750Srwatson func_fatal_error "unknown suffix for \`$my_dlsyms'" 3555243750Srwatson ;; 3556243750Srwatson esac 3557243750Srwatson else 3558243750Srwatson # We keep going just in case the user didn't refer to 3559243750Srwatson # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 3560243750Srwatson # really was required. 3561243750Srwatson 3562243750Srwatson # Nullify the symbol file. 3563243750Srwatson compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 3564243750Srwatson finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 3565243750Srwatson fi 3566243750Srwatson} 3567243750Srwatson 3568243750Srwatson# func_win32_libid arg 3569243750Srwatson# return the library type of file 'arg' 3570243750Srwatson# 3571243750Srwatson# Need a lot of goo to handle *both* DLLs and import libs 3572243750Srwatson# Has to be a shell function in order to 'eat' the argument 3573243750Srwatson# that is supplied when $file_magic_command is called. 3574243750Srwatson# Despite the name, also deal with 64 bit binaries. 3575243750Srwatsonfunc_win32_libid () 3576243750Srwatson{ 3577243750Srwatson $opt_debug 3578243750Srwatson win32_libid_type="unknown" 3579243750Srwatson win32_fileres=`file -L $1 2>/dev/null` 3580243750Srwatson case $win32_fileres in 3581243750Srwatson *ar\ archive\ import\ library*) # definitely import 3582243750Srwatson win32_libid_type="x86 archive import" 3583156283Srwatson ;; 3584243750Srwatson *ar\ archive*) # could be an import, or static 3585243750Srwatson # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 3586243750Srwatson if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 3587243750Srwatson $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 3588243750Srwatson func_to_tool_file "$1" func_convert_file_msys_to_w32 3589243750Srwatson win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 3590243750Srwatson $SED -n -e ' 3591243750Srwatson 1,100{ 3592243750Srwatson / I /{ 3593243750Srwatson s,.*,import, 3594243750Srwatson p 3595243750Srwatson q 3596243750Srwatson } 3597243750Srwatson }'` 3598243750Srwatson case $win32_nmres in 3599243750Srwatson import*) win32_libid_type="x86 archive import";; 3600243750Srwatson *) win32_libid_type="x86 archive static";; 3601243750Srwatson esac 3602243750Srwatson fi 3603243750Srwatson ;; 3604243750Srwatson *DLL*) 3605243750Srwatson win32_libid_type="x86 DLL" 3606243750Srwatson ;; 3607243750Srwatson *executable*) # but shell scripts are "executable" too... 3608243750Srwatson case $win32_fileres in 3609243750Srwatson *MS\ Windows\ PE\ Intel*) 3610243750Srwatson win32_libid_type="x86 DLL" 3611243750Srwatson ;; 3612243750Srwatson esac 3613243750Srwatson ;; 3614243750Srwatson esac 3615243750Srwatson $ECHO "$win32_libid_type" 3616243750Srwatson} 3617156283Srwatson 3618243750Srwatson# func_cygming_dll_for_implib ARG 3619243750Srwatson# 3620243750Srwatson# Platform-specific function to extract the 3621243750Srwatson# name of the DLL associated with the specified 3622243750Srwatson# import library ARG. 3623243750Srwatson# Invoked by eval'ing the libtool variable 3624243750Srwatson# $sharedlib_from_linklib_cmd 3625243750Srwatson# Result is available in the variable 3626243750Srwatson# $sharedlib_from_linklib_result 3627243750Srwatsonfunc_cygming_dll_for_implib () 3628243750Srwatson{ 3629243750Srwatson $opt_debug 3630243750Srwatson sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 3631243750Srwatson} 3632243750Srwatson 3633243750Srwatson# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 3634243750Srwatson# 3635243750Srwatson# The is the core of a fallback implementation of a 3636243750Srwatson# platform-specific function to extract the name of the 3637243750Srwatson# DLL associated with the specified import library LIBNAME. 3638243750Srwatson# 3639243750Srwatson# SECTION_NAME is either .idata$6 or .idata$7, depending 3640243750Srwatson# on the platform and compiler that created the implib. 3641243750Srwatson# 3642243750Srwatson# Echos the name of the DLL associated with the 3643243750Srwatson# specified import library. 3644243750Srwatsonfunc_cygming_dll_for_implib_fallback_core () 3645243750Srwatson{ 3646243750Srwatson $opt_debug 3647243750Srwatson match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 3648243750Srwatson $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 3649243750Srwatson $SED '/^Contents of section '"$match_literal"':/{ 3650243750Srwatson # Place marker at beginning of archive member dllname section 3651243750Srwatson s/.*/====MARK====/ 3652243750Srwatson p 3653243750Srwatson d 3654243750Srwatson } 3655243750Srwatson # These lines can sometimes be longer than 43 characters, but 3656243750Srwatson # are always uninteresting 3657243750Srwatson /:[ ]*file format pe[i]\{,1\}-/d 3658243750Srwatson /^In archive [^:]*:/d 3659243750Srwatson # Ensure marker is printed 3660243750Srwatson /^====MARK====/p 3661243750Srwatson # Remove all lines with less than 43 characters 3662243750Srwatson /^.\{43\}/!d 3663243750Srwatson # From remaining lines, remove first 43 characters 3664243750Srwatson s/^.\{43\}//' | 3665243750Srwatson $SED -n ' 3666243750Srwatson # Join marker and all lines until next marker into a single line 3667243750Srwatson /^====MARK====/ b para 3668243750Srwatson H 3669243750Srwatson $ b para 3670243750Srwatson b 3671243750Srwatson :para 3672243750Srwatson x 3673243750Srwatson s/\n//g 3674243750Srwatson # Remove the marker 3675243750Srwatson s/^====MARK====// 3676243750Srwatson # Remove trailing dots and whitespace 3677243750Srwatson s/[\. \t]*$// 3678243750Srwatson # Print 3679243750Srwatson /./p' | 3680243750Srwatson # we now have a list, one entry per line, of the stringified 3681243750Srwatson # contents of the appropriate section of all members of the 3682243750Srwatson # archive which possess that section. Heuristic: eliminate 3683243750Srwatson # all those which have a first or second character that is 3684243750Srwatson # a '.' (that is, objdump's representation of an unprintable 3685243750Srwatson # character.) This should work for all archives with less than 3686243750Srwatson # 0x302f exports -- but will fail for DLLs whose name actually 3687243750Srwatson # begins with a literal '.' or a single character followed by 3688243750Srwatson # a '.'. 3689243750Srwatson # 3690243750Srwatson # Of those that remain, print the first one. 3691243750Srwatson $SED -e '/^\./d;/^.\./d;q' 3692243750Srwatson} 3693243750Srwatson 3694243750Srwatson# func_cygming_gnu_implib_p ARG 3695243750Srwatson# This predicate returns with zero status (TRUE) if 3696243750Srwatson# ARG is a GNU/binutils-style import library. Returns 3697243750Srwatson# with nonzero status (FALSE) otherwise. 3698243750Srwatsonfunc_cygming_gnu_implib_p () 3699243750Srwatson{ 3700243750Srwatson $opt_debug 3701243750Srwatson func_to_tool_file "$1" func_convert_file_msys_to_w32 3702243750Srwatson 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)$'` 3703243750Srwatson test -n "$func_cygming_gnu_implib_tmp" 3704243750Srwatson} 3705243750Srwatson 3706243750Srwatson# func_cygming_ms_implib_p ARG 3707243750Srwatson# This predicate returns with zero status (TRUE) if 3708243750Srwatson# ARG is an MS-style import library. Returns 3709243750Srwatson# with nonzero status (FALSE) otherwise. 3710243750Srwatsonfunc_cygming_ms_implib_p () 3711243750Srwatson{ 3712243750Srwatson $opt_debug 3713243750Srwatson func_to_tool_file "$1" func_convert_file_msys_to_w32 3714243750Srwatson func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 3715243750Srwatson test -n "$func_cygming_ms_implib_tmp" 3716243750Srwatson} 3717243750Srwatson 3718243750Srwatson# func_cygming_dll_for_implib_fallback ARG 3719243750Srwatson# Platform-specific function to extract the 3720243750Srwatson# name of the DLL associated with the specified 3721243750Srwatson# import library ARG. 3722243750Srwatson# 3723243750Srwatson# This fallback implementation is for use when $DLLTOOL 3724243750Srwatson# does not support the --identify-strict option. 3725243750Srwatson# Invoked by eval'ing the libtool variable 3726243750Srwatson# $sharedlib_from_linklib_cmd 3727243750Srwatson# Result is available in the variable 3728243750Srwatson# $sharedlib_from_linklib_result 3729243750Srwatsonfunc_cygming_dll_for_implib_fallback () 3730243750Srwatson{ 3731243750Srwatson $opt_debug 3732243750Srwatson if func_cygming_gnu_implib_p "$1" ; then 3733243750Srwatson # binutils import library 3734243750Srwatson sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 3735243750Srwatson elif func_cygming_ms_implib_p "$1" ; then 3736243750Srwatson # ms-generated import library 3737243750Srwatson sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 3738243750Srwatson else 3739243750Srwatson # unknown 3740243750Srwatson sharedlib_from_linklib_result="" 3741243750Srwatson fi 3742243750Srwatson} 3743243750Srwatson 3744243750Srwatson 3745243750Srwatson# func_extract_an_archive dir oldlib 3746243750Srwatsonfunc_extract_an_archive () 3747243750Srwatson{ 3748243750Srwatson $opt_debug 3749243750Srwatson f_ex_an_ar_dir="$1"; shift 3750243750Srwatson f_ex_an_ar_oldlib="$1" 3751243750Srwatson if test "$lock_old_archive_extraction" = yes; then 3752243750Srwatson lockfile=$f_ex_an_ar_oldlib.lock 3753243750Srwatson until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3754243750Srwatson func_echo "Waiting for $lockfile to be removed" 3755243750Srwatson sleep 2 3756243750Srwatson done 3757243750Srwatson fi 3758243750Srwatson func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 3759243750Srwatson 'stat=$?; rm -f "$lockfile"; exit $stat' 3760243750Srwatson if test "$lock_old_archive_extraction" = yes; then 3761243750Srwatson $opt_dry_run || rm -f "$lockfile" 3762243750Srwatson fi 3763243750Srwatson if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 3764243750Srwatson : 3765243750Srwatson else 3766243750Srwatson func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 3767243750Srwatson fi 3768243750Srwatson} 3769243750Srwatson 3770243750Srwatson 3771243750Srwatson# func_extract_archives gentop oldlib ... 3772243750Srwatsonfunc_extract_archives () 3773243750Srwatson{ 3774243750Srwatson $opt_debug 3775243750Srwatson my_gentop="$1"; shift 3776243750Srwatson my_oldlibs=${1+"$@"} 3777243750Srwatson my_oldobjs="" 3778243750Srwatson my_xlib="" 3779243750Srwatson my_xabs="" 3780243750Srwatson my_xdir="" 3781243750Srwatson 3782243750Srwatson for my_xlib in $my_oldlibs; do 3783243750Srwatson # Extract the objects. 3784243750Srwatson case $my_xlib in 3785243750Srwatson [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 3786243750Srwatson *) my_xabs=`pwd`"/$my_xlib" ;; 3787243750Srwatson esac 3788243750Srwatson func_basename "$my_xlib" 3789243750Srwatson my_xlib="$func_basename_result" 3790243750Srwatson my_xlib_u=$my_xlib 3791243750Srwatson while :; do 3792243750Srwatson case " $extracted_archives " in 3793243750Srwatson *" $my_xlib_u "*) 3794243750Srwatson func_arith $extracted_serial + 1 3795243750Srwatson extracted_serial=$func_arith_result 3796243750Srwatson my_xlib_u=lt$extracted_serial-$my_xlib ;; 3797243750Srwatson *) break ;; 3798243750Srwatson esac 3799243750Srwatson done 3800243750Srwatson extracted_archives="$extracted_archives $my_xlib_u" 3801243750Srwatson my_xdir="$my_gentop/$my_xlib_u" 3802243750Srwatson 3803243750Srwatson func_mkdir_p "$my_xdir" 3804243750Srwatson 3805243750Srwatson case $host in 3806243750Srwatson *-darwin*) 3807243750Srwatson func_verbose "Extracting $my_xabs" 3808243750Srwatson # Do not bother doing anything if just a dry run 3809243750Srwatson $opt_dry_run || { 3810243750Srwatson darwin_orig_dir=`pwd` 3811243750Srwatson cd $my_xdir || exit $? 3812243750Srwatson darwin_archive=$my_xabs 3813243750Srwatson darwin_curdir=`pwd` 3814243750Srwatson darwin_base_archive=`basename "$darwin_archive"` 3815243750Srwatson darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 3816243750Srwatson if test -n "$darwin_arches"; then 3817243750Srwatson darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 3818243750Srwatson darwin_arch= 3819243750Srwatson func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 3820243750Srwatson for darwin_arch in $darwin_arches ; do 3821243750Srwatson func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3822243750Srwatson $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 3823243750Srwatson cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3824243750Srwatson func_extract_an_archive "`pwd`" "${darwin_base_archive}" 3825243750Srwatson cd "$darwin_curdir" 3826243750Srwatson $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 3827243750Srwatson done # $darwin_arches 3828243750Srwatson ## Okay now we've a bunch of thin objects, gotta fatten them up :) 3829243750Srwatson darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 3830243750Srwatson darwin_file= 3831243750Srwatson darwin_files= 3832243750Srwatson for darwin_file in $darwin_filelist; do 3833243750Srwatson darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 3834243750Srwatson $LIPO -create -output "$darwin_file" $darwin_files 3835243750Srwatson done # $darwin_filelist 3836243750Srwatson $RM -rf unfat-$$ 3837243750Srwatson cd "$darwin_orig_dir" 3838243750Srwatson else 3839243750Srwatson cd $darwin_orig_dir 3840243750Srwatson func_extract_an_archive "$my_xdir" "$my_xabs" 3841243750Srwatson fi # $darwin_arches 3842243750Srwatson } # !$opt_dry_run 3843243750Srwatson ;; 3844243750Srwatson *) 3845243750Srwatson func_extract_an_archive "$my_xdir" "$my_xabs" 3846243750Srwatson ;; 3847243750Srwatson esac 3848243750Srwatson my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 3849243750Srwatson done 3850243750Srwatson 3851243750Srwatson func_extract_archives_result="$my_oldobjs" 3852243750Srwatson} 3853243750Srwatson 3854243750Srwatson 3855243750Srwatson# func_emit_wrapper [arg=no] 3856243750Srwatson# 3857243750Srwatson# Emit a libtool wrapper script on stdout. 3858243750Srwatson# Don't directly open a file because we may want to 3859243750Srwatson# incorporate the script contents within a cygwin/mingw 3860243750Srwatson# wrapper executable. Must ONLY be called from within 3861243750Srwatson# func_mode_link because it depends on a number of variables 3862243750Srwatson# set therein. 3863243750Srwatson# 3864243750Srwatson# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 3865243750Srwatson# variable will take. If 'yes', then the emitted script 3866243750Srwatson# will assume that the directory in which it is stored is 3867243750Srwatson# the $objdir directory. This is a cygwin/mingw-specific 3868243750Srwatson# behavior. 3869243750Srwatsonfunc_emit_wrapper () 3870243750Srwatson{ 3871243750Srwatson func_emit_wrapper_arg1=${1-no} 3872243750Srwatson 3873243750Srwatson $ECHO "\ 3874243750Srwatson#! $SHELL 3875243750Srwatson 3876243750Srwatson# $output - temporary wrapper script for $objdir/$outputname 3877243750Srwatson# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3878243750Srwatson# 3879243750Srwatson# The $output program cannot be directly executed until all the libtool 3880243750Srwatson# libraries that it depends on are installed. 3881243750Srwatson# 3882243750Srwatson# This wrapper script should never be moved out of the build directory. 3883243750Srwatson# If it is, it will not operate correctly. 3884243750Srwatson 3885243750Srwatson# Sed substitution that helps us do robust quoting. It backslashifies 3886243750Srwatson# metacharacters that are still active within double-quoted strings. 3887243750Srwatsonsed_quote_subst='$sed_quote_subst' 3888243750Srwatson 3889243750Srwatson# Be Bourne compatible 3890243750Srwatsonif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 3891243750Srwatson emulate sh 3892243750Srwatson NULLCMD=: 3893243750Srwatson # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 3894243750Srwatson # is contrary to our usage. Disable this feature. 3895243750Srwatson alias -g '\${1+\"\$@\"}'='\"\$@\"' 3896243750Srwatson setopt NO_GLOB_SUBST 3897243750Srwatsonelse 3898243750Srwatson case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 3899243750Srwatsonfi 3900243750SrwatsonBIN_SH=xpg4; export BIN_SH # for Tru64 3901243750SrwatsonDUALCASE=1; export DUALCASE # for MKS sh 3902243750Srwatson 3903243750Srwatson# The HP-UX ksh and POSIX shell print the target directory to stdout 3904243750Srwatson# if CDPATH is set. 3905243750Srwatson(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3906243750Srwatson 3907243750Srwatsonrelink_command=\"$relink_command\" 3908243750Srwatson 3909243750Srwatson# This environment variable determines our operation mode. 3910243750Srwatsonif test \"\$libtool_install_magic\" = \"$magic\"; then 3911243750Srwatson # install mode needs the following variables: 3912243750Srwatson generated_by_libtool_version='$macro_version' 3913243750Srwatson notinst_deplibs='$notinst_deplibs' 3914243750Srwatsonelse 3915243750Srwatson # When we are sourced in execute mode, \$file and \$ECHO are already set. 3916243750Srwatson if test \"\$libtool_execute_magic\" != \"$magic\"; then 3917243750Srwatson file=\"\$0\"" 3918243750Srwatson 3919243750Srwatson qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 3920243750Srwatson $ECHO "\ 3921243750Srwatson 3922243750Srwatson# A function that is used when there is no print builtin or printf. 3923243750Srwatsonfunc_fallback_echo () 3924243750Srwatson{ 3925243750Srwatson eval 'cat <<_LTECHO_EOF 3926243750Srwatson\$1 3927243750Srwatson_LTECHO_EOF' 3928243750Srwatson} 3929243750Srwatson ECHO=\"$qECHO\" 3930243750Srwatson fi 3931243750Srwatson 3932243750Srwatson# Very basic option parsing. These options are (a) specific to 3933243750Srwatson# the libtool wrapper, (b) are identical between the wrapper 3934243750Srwatson# /script/ and the wrapper /executable/ which is used only on 3935243750Srwatson# windows platforms, and (c) all begin with the string "--lt-" 3936243750Srwatson# (application programs are unlikely to have options which match 3937243750Srwatson# this pattern). 3938243750Srwatson# 3939243750Srwatson# There are only two supported options: --lt-debug and 3940243750Srwatson# --lt-dump-script. There is, deliberately, no --lt-help. 3941243750Srwatson# 3942243750Srwatson# The first argument to this parsing function should be the 3943243750Srwatson# script's $0 value, followed by "$@". 3944243750Srwatsonlt_option_debug= 3945243750Srwatsonfunc_parse_lt_options () 3946243750Srwatson{ 3947243750Srwatson lt_script_arg0=\$0 3948243750Srwatson shift 3949243750Srwatson for lt_opt 3950243750Srwatson do 3951243750Srwatson case \"\$lt_opt\" in 3952243750Srwatson --lt-debug) lt_option_debug=1 ;; 3953243750Srwatson --lt-dump-script) 3954243750Srwatson lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 3955243750Srwatson test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 3956243750Srwatson lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 3957243750Srwatson cat \"\$lt_dump_D/\$lt_dump_F\" 3958243750Srwatson exit 0 3959243750Srwatson ;; 3960243750Srwatson --lt-*) 3961243750Srwatson \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 3962243750Srwatson exit 1 3963243750Srwatson ;; 3964243750Srwatson esac 3965243750Srwatson done 3966243750Srwatson 3967243750Srwatson # Print the debug banner immediately: 3968243750Srwatson if test -n \"\$lt_option_debug\"; then 3969243750Srwatson echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 3970243750Srwatson fi 3971243750Srwatson} 3972243750Srwatson 3973243750Srwatson# Used when --lt-debug. Prints its arguments to stdout 3974243750Srwatson# (redirection is the responsibility of the caller) 3975243750Srwatsonfunc_lt_dump_args () 3976243750Srwatson{ 3977243750Srwatson lt_dump_args_N=1; 3978243750Srwatson for lt_arg 3979243750Srwatson do 3980243750Srwatson \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 3981243750Srwatson lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 3982243750Srwatson done 3983243750Srwatson} 3984243750Srwatson 3985243750Srwatson# Core function for launching the target application 3986243750Srwatsonfunc_exec_program_core () 3987243750Srwatson{ 3988243750Srwatson" 3989243750Srwatson case $host in 3990243750Srwatson # Backslashes separate directories on plain windows 3991243750Srwatson *-*-mingw | *-*-os2* | *-cegcc*) 3992243750Srwatson $ECHO "\ 3993243750Srwatson if test -n \"\$lt_option_debug\"; then 3994243750Srwatson \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 3995243750Srwatson func_lt_dump_args \${1+\"\$@\"} 1>&2 3996243750Srwatson fi 3997243750Srwatson exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 3998243750Srwatson" 3999243750Srwatson ;; 4000243750Srwatson 4001243750Srwatson *) 4002243750Srwatson $ECHO "\ 4003243750Srwatson if test -n \"\$lt_option_debug\"; then 4004243750Srwatson \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 4005243750Srwatson func_lt_dump_args \${1+\"\$@\"} 1>&2 4006243750Srwatson fi 4007243750Srwatson exec \"\$progdir/\$program\" \${1+\"\$@\"} 4008243750Srwatson" 4009243750Srwatson ;; 4010243750Srwatson esac 4011243750Srwatson $ECHO "\ 4012243750Srwatson \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 4013243750Srwatson exit 1 4014243750Srwatson} 4015243750Srwatson 4016243750Srwatson# A function to encapsulate launching the target application 4017243750Srwatson# Strips options in the --lt-* namespace from \$@ and 4018243750Srwatson# launches target application with the remaining arguments. 4019243750Srwatsonfunc_exec_program () 4020243750Srwatson{ 4021243750Srwatson case \" \$* \" in 4022243750Srwatson *\\ --lt-*) 4023243750Srwatson for lt_wr_arg 4024243750Srwatson do 4025243750Srwatson case \$lt_wr_arg in 4026243750Srwatson --lt-*) ;; 4027243750Srwatson *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 4028243750Srwatson esac 4029243750Srwatson shift 4030243750Srwatson done ;; 4031243750Srwatson esac 4032243750Srwatson func_exec_program_core \${1+\"\$@\"} 4033243750Srwatson} 4034243750Srwatson 4035243750Srwatson # Parse options 4036243750Srwatson func_parse_lt_options \"\$0\" \${1+\"\$@\"} 4037243750Srwatson 4038243750Srwatson # Find the directory that this script lives in. 4039243750Srwatson thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 4040243750Srwatson test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4041243750Srwatson 4042243750Srwatson # Follow symbolic links until we get to the real thisdir. 4043243750Srwatson file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 4044243750Srwatson while test -n \"\$file\"; do 4045243750Srwatson destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4046243750Srwatson 4047243750Srwatson # If there was a directory component, then change thisdir. 4048243750Srwatson if test \"x\$destdir\" != \"x\$file\"; then 4049243750Srwatson case \"\$destdir\" in 4050243750Srwatson [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 4051243750Srwatson *) thisdir=\"\$thisdir/\$destdir\" ;; 4052243750Srwatson esac 4053243750Srwatson fi 4054243750Srwatson 4055243750Srwatson file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 4056243750Srwatson file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 4057243750Srwatson done 4058243750Srwatson 4059243750Srwatson # Usually 'no', except on cygwin/mingw when embedded into 4060243750Srwatson # the cwrapper. 4061243750Srwatson WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 4062243750Srwatson if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 4063243750Srwatson # special case for '.' 4064243750Srwatson if test \"\$thisdir\" = \".\"; then 4065243750Srwatson thisdir=\`pwd\` 4066243750Srwatson fi 4067243750Srwatson # remove .libs from thisdir 4068243750Srwatson case \"\$thisdir\" in 4069243750Srwatson *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 4070243750Srwatson $objdir ) thisdir=. ;; 4071243750Srwatson esac 4072243750Srwatson fi 4073243750Srwatson 4074243750Srwatson # Try to get the absolute directory name. 4075243750Srwatson absdir=\`cd \"\$thisdir\" && pwd\` 4076243750Srwatson test -n \"\$absdir\" && thisdir=\"\$absdir\" 4077243750Srwatson" 4078243750Srwatson 4079243750Srwatson if test "$fast_install" = yes; then 4080243750Srwatson $ECHO "\ 4081243750Srwatson program=lt-'$outputname'$exeext 4082243750Srwatson progdir=\"\$thisdir/$objdir\" 4083243750Srwatson 4084243750Srwatson if test ! -f \"\$progdir/\$program\" || 4085243750Srwatson { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 4086243750Srwatson test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4087243750Srwatson 4088243750Srwatson file=\"\$\$-\$program\" 4089243750Srwatson 4090243750Srwatson if test ! -d \"\$progdir\"; then 4091243750Srwatson $MKDIR \"\$progdir\" 4092243750Srwatson else 4093243750Srwatson $RM \"\$progdir/\$file\" 4094243750Srwatson fi" 4095243750Srwatson 4096243750Srwatson $ECHO "\ 4097243750Srwatson 4098243750Srwatson # relink executable if necessary 4099243750Srwatson if test -n \"\$relink_command\"; then 4100243750Srwatson if relink_command_output=\`eval \$relink_command 2>&1\`; then : 4101243750Srwatson else 4102243750Srwatson $ECHO \"\$relink_command_output\" >&2 4103243750Srwatson $RM \"\$progdir/\$file\" 4104243750Srwatson exit 1 4105243750Srwatson fi 4106243750Srwatson fi 4107243750Srwatson 4108243750Srwatson $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 4109243750Srwatson { $RM \"\$progdir/\$program\"; 4110243750Srwatson $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 4111243750Srwatson $RM \"\$progdir/\$file\" 4112243750Srwatson fi" 4113243750Srwatson else 4114243750Srwatson $ECHO "\ 4115243750Srwatson program='$outputname' 4116243750Srwatson progdir=\"\$thisdir/$objdir\" 4117243750Srwatson" 4118243750Srwatson fi 4119243750Srwatson 4120243750Srwatson $ECHO "\ 4121243750Srwatson 4122243750Srwatson if test -f \"\$progdir/\$program\"; then" 4123243750Srwatson 4124243750Srwatson # fixup the dll searchpath if we need to. 4125243750Srwatson # 4126243750Srwatson # Fix the DLL searchpath if we need to. Do this before prepending 4127243750Srwatson # to shlibpath, because on Windows, both are PATH and uninstalled 4128243750Srwatson # libraries must come first. 4129243750Srwatson if test -n "$dllsearchpath"; then 4130243750Srwatson $ECHO "\ 4131243750Srwatson # Add the dll search path components to the executable PATH 4132243750Srwatson PATH=$dllsearchpath:\$PATH 4133243750Srwatson" 4134243750Srwatson fi 4135243750Srwatson 4136243750Srwatson # Export our shlibpath_var if we have one. 4137243750Srwatson if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4138243750Srwatson $ECHO "\ 4139243750Srwatson # Add our own library path to $shlibpath_var 4140243750Srwatson $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4141243750Srwatson 4142243750Srwatson # Some systems cannot cope with colon-terminated $shlibpath_var 4143243750Srwatson # The second colon is a workaround for a bug in BeOS R4 sed 4144243750Srwatson $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4145243750Srwatson 4146243750Srwatson export $shlibpath_var 4147243750Srwatson" 4148243750Srwatson fi 4149243750Srwatson 4150243750Srwatson $ECHO "\ 4151243750Srwatson if test \"\$libtool_execute_magic\" != \"$magic\"; then 4152243750Srwatson # Run the actual program with our arguments. 4153243750Srwatson func_exec_program \${1+\"\$@\"} 4154243750Srwatson fi 4155243750Srwatson else 4156243750Srwatson # The program doesn't exist. 4157243750Srwatson \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 4158243750Srwatson \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 4159243750Srwatson \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 4160243750Srwatson exit 1 4161243750Srwatson fi 4162243750Srwatsonfi\ 4163243750Srwatson" 4164243750Srwatson} 4165243750Srwatson 4166243750Srwatson 4167243750Srwatson# func_emit_cwrapperexe_src 4168243750Srwatson# emit the source code for a wrapper executable on stdout 4169243750Srwatson# Must ONLY be called from within func_mode_link because 4170243750Srwatson# it depends on a number of variable set therein. 4171243750Srwatsonfunc_emit_cwrapperexe_src () 4172243750Srwatson{ 4173243750Srwatson cat <<EOF 4174243750Srwatson 4175243750Srwatson/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4176243750Srwatson Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4177243750Srwatson 4178243750Srwatson The $output program cannot be directly executed until all the libtool 4179243750Srwatson libraries that it depends on are installed. 4180243750Srwatson 4181243750Srwatson This wrapper executable should never be moved out of the build directory. 4182243750Srwatson If it is, it will not operate correctly. 4183243750Srwatson*/ 4184243750SrwatsonEOF 4185243750Srwatson cat <<"EOF" 4186243750Srwatson#ifdef _MSC_VER 4187243750Srwatson# define _CRT_SECURE_NO_DEPRECATE 1 4188243750Srwatson#endif 4189243750Srwatson#include <stdio.h> 4190243750Srwatson#include <stdlib.h> 4191243750Srwatson#ifdef _MSC_VER 4192243750Srwatson# include <direct.h> 4193243750Srwatson# include <process.h> 4194243750Srwatson# include <io.h> 4195243750Srwatson#else 4196243750Srwatson# include <unistd.h> 4197243750Srwatson# include <stdint.h> 4198243750Srwatson# ifdef __CYGWIN__ 4199243750Srwatson# include <io.h> 4200243750Srwatson# endif 4201243750Srwatson#endif 4202243750Srwatson#include <malloc.h> 4203243750Srwatson#include <stdarg.h> 4204243750Srwatson#include <assert.h> 4205243750Srwatson#include <string.h> 4206243750Srwatson#include <ctype.h> 4207243750Srwatson#include <errno.h> 4208243750Srwatson#include <fcntl.h> 4209243750Srwatson#include <sys/stat.h> 4210243750Srwatson 4211243750Srwatson/* declarations of non-ANSI functions */ 4212243750Srwatson#if defined(__MINGW32__) 4213243750Srwatson# ifdef __STRICT_ANSI__ 4214243750Srwatsonint _putenv (const char *); 4215243750Srwatson# endif 4216243750Srwatson#elif defined(__CYGWIN__) 4217243750Srwatson# ifdef __STRICT_ANSI__ 4218243750Srwatsonchar *realpath (const char *, char *); 4219243750Srwatsonint putenv (char *); 4220243750Srwatsonint setenv (const char *, const char *, int); 4221243750Srwatson# endif 4222243750Srwatson/* #elif defined (other platforms) ... */ 4223243750Srwatson#endif 4224243750Srwatson 4225243750Srwatson/* portability defines, excluding path handling macros */ 4226243750Srwatson#if defined(_MSC_VER) 4227243750Srwatson# define setmode _setmode 4228243750Srwatson# define stat _stat 4229243750Srwatson# define chmod _chmod 4230243750Srwatson# define getcwd _getcwd 4231243750Srwatson# define putenv _putenv 4232243750Srwatson# define S_IXUSR _S_IEXEC 4233243750Srwatson# ifndef _INTPTR_T_DEFINED 4234243750Srwatson# define _INTPTR_T_DEFINED 4235243750Srwatson# define intptr_t int 4236243750Srwatson# endif 4237243750Srwatson#elif defined(__MINGW32__) 4238243750Srwatson# define setmode _setmode 4239243750Srwatson# define stat _stat 4240243750Srwatson# define chmod _chmod 4241243750Srwatson# define getcwd _getcwd 4242243750Srwatson# define putenv _putenv 4243243750Srwatson#elif defined(__CYGWIN__) 4244243750Srwatson# define HAVE_SETENV 4245243750Srwatson# define FOPEN_WB "wb" 4246243750Srwatson/* #elif defined (other platforms) ... */ 4247243750Srwatson#endif 4248243750Srwatson 4249243750Srwatson#if defined(PATH_MAX) 4250243750Srwatson# define LT_PATHMAX PATH_MAX 4251243750Srwatson#elif defined(MAXPATHLEN) 4252243750Srwatson# define LT_PATHMAX MAXPATHLEN 4253243750Srwatson#else 4254243750Srwatson# define LT_PATHMAX 1024 4255243750Srwatson#endif 4256243750Srwatson 4257243750Srwatson#ifndef S_IXOTH 4258243750Srwatson# define S_IXOTH 0 4259243750Srwatson#endif 4260243750Srwatson#ifndef S_IXGRP 4261243750Srwatson# define S_IXGRP 0 4262243750Srwatson#endif 4263243750Srwatson 4264243750Srwatson/* path handling portability macros */ 4265243750Srwatson#ifndef DIR_SEPARATOR 4266243750Srwatson# define DIR_SEPARATOR '/' 4267243750Srwatson# define PATH_SEPARATOR ':' 4268243750Srwatson#endif 4269243750Srwatson 4270243750Srwatson#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4271243750Srwatson defined (__OS2__) 4272243750Srwatson# define HAVE_DOS_BASED_FILE_SYSTEM 4273243750Srwatson# define FOPEN_WB "wb" 4274243750Srwatson# ifndef DIR_SEPARATOR_2 4275243750Srwatson# define DIR_SEPARATOR_2 '\\' 4276243750Srwatson# endif 4277243750Srwatson# ifndef PATH_SEPARATOR_2 4278243750Srwatson# define PATH_SEPARATOR_2 ';' 4279243750Srwatson# endif 4280243750Srwatson#endif 4281243750Srwatson 4282243750Srwatson#ifndef DIR_SEPARATOR_2 4283243750Srwatson# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 4284243750Srwatson#else /* DIR_SEPARATOR_2 */ 4285243750Srwatson# define IS_DIR_SEPARATOR(ch) \ 4286243750Srwatson (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 4287243750Srwatson#endif /* DIR_SEPARATOR_2 */ 4288243750Srwatson 4289243750Srwatson#ifndef PATH_SEPARATOR_2 4290243750Srwatson# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 4291243750Srwatson#else /* PATH_SEPARATOR_2 */ 4292243750Srwatson# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 4293243750Srwatson#endif /* PATH_SEPARATOR_2 */ 4294243750Srwatson 4295243750Srwatson#ifndef FOPEN_WB 4296243750Srwatson# define FOPEN_WB "w" 4297243750Srwatson#endif 4298243750Srwatson#ifndef _O_BINARY 4299243750Srwatson# define _O_BINARY 0 4300243750Srwatson#endif 4301243750Srwatson 4302243750Srwatson#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 4303243750Srwatson#define XFREE(stale) do { \ 4304243750Srwatson if (stale) { free ((void *) stale); stale = 0; } \ 4305243750Srwatson} while (0) 4306243750Srwatson 4307243750Srwatson#if defined(LT_DEBUGWRAPPER) 4308243750Srwatsonstatic int lt_debug = 1; 4309243750Srwatson#else 4310243750Srwatsonstatic int lt_debug = 0; 4311243750Srwatson#endif 4312243750Srwatson 4313243750Srwatsonconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4314243750Srwatson 4315243750Srwatsonvoid *xmalloc (size_t num); 4316243750Srwatsonchar *xstrdup (const char *string); 4317243750Srwatsonconst char *base_name (const char *name); 4318243750Srwatsonchar *find_executable (const char *wrapper); 4319243750Srwatsonchar *chase_symlinks (const char *pathspec); 4320243750Srwatsonint make_executable (const char *path); 4321243750Srwatsonint check_executable (const char *path); 4322243750Srwatsonchar *strendzap (char *str, const char *pat); 4323243750Srwatsonvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 4324243750Srwatsonvoid lt_fatal (const char *file, int line, const char *message, ...); 4325243750Srwatsonstatic const char *nonnull (const char *s); 4326243750Srwatsonstatic const char *nonempty (const char *s); 4327243750Srwatsonvoid lt_setenv (const char *name, const char *value); 4328243750Srwatsonchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 4329243750Srwatsonvoid lt_update_exe_path (const char *name, const char *value); 4330243750Srwatsonvoid lt_update_lib_path (const char *name, const char *value); 4331243750Srwatsonchar **prepare_spawn (char **argv); 4332243750Srwatsonvoid lt_dump_script (FILE *f); 4333243750SrwatsonEOF 4334243750Srwatson 4335243750Srwatson cat <<EOF 4336243750Srwatsonvolatile const char * MAGIC_EXE = "$magic_exe"; 4337243750Srwatsonconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 4338243750SrwatsonEOF 4339243750Srwatson 4340243750Srwatson if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4341243750Srwatson func_to_host_path "$temp_rpath" 4342243750Srwatson cat <<EOF 4343243750Srwatsonconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 4344243750SrwatsonEOF 4345243750Srwatson else 4346243750Srwatson cat <<"EOF" 4347243750Srwatsonconst char * LIB_PATH_VALUE = ""; 4348243750SrwatsonEOF 4349243750Srwatson fi 4350243750Srwatson 4351243750Srwatson if test -n "$dllsearchpath"; then 4352243750Srwatson func_to_host_path "$dllsearchpath:" 4353243750Srwatson cat <<EOF 4354243750Srwatsonconst char * EXE_PATH_VARNAME = "PATH"; 4355243750Srwatsonconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 4356243750SrwatsonEOF 4357243750Srwatson else 4358243750Srwatson cat <<"EOF" 4359243750Srwatsonconst char * EXE_PATH_VARNAME = ""; 4360243750Srwatsonconst char * EXE_PATH_VALUE = ""; 4361243750SrwatsonEOF 4362243750Srwatson fi 4363243750Srwatson 4364243750Srwatson if test "$fast_install" = yes; then 4365243750Srwatson cat <<EOF 4366243750Srwatsonconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 4367243750SrwatsonEOF 4368243750Srwatson else 4369243750Srwatson cat <<EOF 4370243750Srwatsonconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 4371243750SrwatsonEOF 4372243750Srwatson fi 4373243750Srwatson 4374243750Srwatson 4375243750Srwatson cat <<"EOF" 4376243750Srwatson 4377243750Srwatson#define LTWRAPPER_OPTION_PREFIX "--lt-" 4378243750Srwatson 4379243750Srwatsonstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 4380243750Srwatsonstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 4381243750Srwatsonstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4382243750Srwatson 4383243750Srwatsonint 4384243750Srwatsonmain (int argc, char *argv[]) 4385243750Srwatson{ 4386243750Srwatson char **newargz; 4387243750Srwatson int newargc; 4388243750Srwatson char *tmp_pathspec; 4389243750Srwatson char *actual_cwrapper_path; 4390243750Srwatson char *actual_cwrapper_name; 4391243750Srwatson char *target_name; 4392243750Srwatson char *lt_argv_zero; 4393243750Srwatson intptr_t rval = 127; 4394243750Srwatson 4395243750Srwatson int i; 4396243750Srwatson 4397243750Srwatson program_name = (char *) xstrdup (base_name (argv[0])); 4398243750Srwatson newargz = XMALLOC (char *, argc + 1); 4399243750Srwatson 4400243750Srwatson /* very simple arg parsing; don't want to rely on getopt 4401243750Srwatson * also, copy all non cwrapper options to newargz, except 4402243750Srwatson * argz[0], which is handled differently 4403243750Srwatson */ 4404243750Srwatson newargc=0; 4405243750Srwatson for (i = 1; i < argc; i++) 4406243750Srwatson { 4407243750Srwatson if (strcmp (argv[i], dumpscript_opt) == 0) 4408243750Srwatson { 4409243750SrwatsonEOF 4410243750Srwatson case "$host" in 4411243750Srwatson *mingw* | *cygwin* ) 4412243750Srwatson # make stdout use "unix" line endings 4413243750Srwatson echo " setmode(1,_O_BINARY);" 4414243750Srwatson ;; 4415243750Srwatson esac 4416243750Srwatson 4417243750Srwatson cat <<"EOF" 4418243750Srwatson lt_dump_script (stdout); 4419243750Srwatson return 0; 4420243750Srwatson } 4421243750Srwatson if (strcmp (argv[i], debug_opt) == 0) 4422243750Srwatson { 4423243750Srwatson lt_debug = 1; 4424243750Srwatson continue; 4425243750Srwatson } 4426243750Srwatson if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 4427243750Srwatson { 4428243750Srwatson /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4429243750Srwatson namespace, but it is not one of the ones we know about and 4430243750Srwatson have already dealt with, above (inluding dump-script), then 4431243750Srwatson report an error. Otherwise, targets might begin to believe 4432243750Srwatson they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4433243750Srwatson namespace. The first time any user complains about this, we'll 4434243750Srwatson need to make LTWRAPPER_OPTION_PREFIX a configure-time option 4435243750Srwatson or a configure.ac-settable value. 4436243750Srwatson */ 4437243750Srwatson lt_fatal (__FILE__, __LINE__, 4438243750Srwatson "unrecognized %s option: '%s'", 4439243750Srwatson ltwrapper_option_prefix, argv[i]); 4440243750Srwatson } 4441243750Srwatson /* otherwise ... */ 4442243750Srwatson newargz[++newargc] = xstrdup (argv[i]); 4443243750Srwatson } 4444243750Srwatson newargz[++newargc] = NULL; 4445243750Srwatson 4446243750SrwatsonEOF 4447243750Srwatson cat <<EOF 4448243750Srwatson /* The GNU banner must be the first non-error debug message */ 4449243750Srwatson lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 4450243750SrwatsonEOF 4451243750Srwatson cat <<"EOF" 4452243750Srwatson lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 4453243750Srwatson lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4454243750Srwatson 4455243750Srwatson tmp_pathspec = find_executable (argv[0]); 4456243750Srwatson if (tmp_pathspec == NULL) 4457243750Srwatson lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 4458243750Srwatson lt_debugprintf (__FILE__, __LINE__, 4459243750Srwatson "(main) found exe (before symlink chase) at: %s\n", 4460243750Srwatson tmp_pathspec); 4461243750Srwatson 4462243750Srwatson actual_cwrapper_path = chase_symlinks (tmp_pathspec); 4463243750Srwatson lt_debugprintf (__FILE__, __LINE__, 4464243750Srwatson "(main) found exe (after symlink chase) at: %s\n", 4465243750Srwatson actual_cwrapper_path); 4466243750Srwatson XFREE (tmp_pathspec); 4467243750Srwatson 4468243750Srwatson actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 4469243750Srwatson strendzap (actual_cwrapper_path, actual_cwrapper_name); 4470243750Srwatson 4471243750Srwatson /* wrapper name transforms */ 4472243750Srwatson strendzap (actual_cwrapper_name, ".exe"); 4473243750Srwatson tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 4474243750Srwatson XFREE (actual_cwrapper_name); 4475243750Srwatson actual_cwrapper_name = tmp_pathspec; 4476243750Srwatson tmp_pathspec = 0; 4477243750Srwatson 4478243750Srwatson /* target_name transforms -- use actual target program name; might have lt- prefix */ 4479243750Srwatson target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 4480243750Srwatson strendzap (target_name, ".exe"); 4481243750Srwatson tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 4482243750Srwatson XFREE (target_name); 4483243750Srwatson target_name = tmp_pathspec; 4484243750Srwatson tmp_pathspec = 0; 4485243750Srwatson 4486243750Srwatson lt_debugprintf (__FILE__, __LINE__, 4487243750Srwatson "(main) libtool target name: %s\n", 4488243750Srwatson target_name); 4489243750SrwatsonEOF 4490243750Srwatson 4491243750Srwatson cat <<EOF 4492243750Srwatson newargz[0] = 4493243750Srwatson XMALLOC (char, (strlen (actual_cwrapper_path) + 4494243750Srwatson strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 4495243750Srwatson strcpy (newargz[0], actual_cwrapper_path); 4496243750Srwatson strcat (newargz[0], "$objdir"); 4497243750Srwatson strcat (newargz[0], "/"); 4498243750SrwatsonEOF 4499243750Srwatson 4500243750Srwatson cat <<"EOF" 4501243750Srwatson /* stop here, and copy so we don't have to do this twice */ 4502243750Srwatson tmp_pathspec = xstrdup (newargz[0]); 4503243750Srwatson 4504243750Srwatson /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 4505243750Srwatson strcat (newargz[0], actual_cwrapper_name); 4506243750Srwatson 4507243750Srwatson /* DO want the lt- prefix here if it exists, so use target_name */ 4508243750Srwatson lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 4509243750Srwatson XFREE (tmp_pathspec); 4510243750Srwatson tmp_pathspec = NULL; 4511243750SrwatsonEOF 4512243750Srwatson 4513243750Srwatson case $host_os in 4514243750Srwatson mingw*) 4515243750Srwatson cat <<"EOF" 4516243750Srwatson { 4517243750Srwatson char* p; 4518243750Srwatson while ((p = strchr (newargz[0], '\\')) != NULL) 4519243750Srwatson { 4520243750Srwatson *p = '/'; 4521243750Srwatson } 4522243750Srwatson while ((p = strchr (lt_argv_zero, '\\')) != NULL) 4523243750Srwatson { 4524243750Srwatson *p = '/'; 4525243750Srwatson } 4526243750Srwatson } 4527243750SrwatsonEOF 4528243750Srwatson ;; 4529243750Srwatson esac 4530243750Srwatson 4531243750Srwatson cat <<"EOF" 4532243750Srwatson XFREE (target_name); 4533243750Srwatson XFREE (actual_cwrapper_path); 4534243750Srwatson XFREE (actual_cwrapper_name); 4535243750Srwatson 4536243750Srwatson lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 4537243750Srwatson lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 4538243750Srwatson /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 4539243750Srwatson be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 4540243750Srwatson because on Windows, both *_VARNAMEs are PATH but uninstalled 4541243750Srwatson libraries must come first. */ 4542243750Srwatson lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 4543243750Srwatson lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4544243750Srwatson 4545243750Srwatson lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 4546243750Srwatson nonnull (lt_argv_zero)); 4547243750Srwatson for (i = 0; i < newargc; i++) 4548243750Srwatson { 4549243750Srwatson lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 4550243750Srwatson i, nonnull (newargz[i])); 4551243750Srwatson } 4552243750Srwatson 4553243750SrwatsonEOF 4554243750Srwatson 4555243750Srwatson case $host_os in 4556243750Srwatson mingw*) 4557243750Srwatson cat <<"EOF" 4558243750Srwatson /* execv doesn't actually work on mingw as expected on unix */ 4559243750Srwatson newargz = prepare_spawn (newargz); 4560243750Srwatson rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 4561243750Srwatson if (rval == -1) 4562243750Srwatson { 4563243750Srwatson /* failed to start process */ 4564243750Srwatson lt_debugprintf (__FILE__, __LINE__, 4565243750Srwatson "(main) failed to launch target \"%s\": %s\n", 4566243750Srwatson lt_argv_zero, nonnull (strerror (errno))); 4567243750Srwatson return 127; 4568243750Srwatson } 4569243750Srwatson return rval; 4570243750SrwatsonEOF 4571243750Srwatson ;; 4572243750Srwatson *) 4573243750Srwatson cat <<"EOF" 4574243750Srwatson execv (lt_argv_zero, newargz); 4575243750Srwatson return rval; /* =127, but avoids unused variable warning */ 4576243750SrwatsonEOF 4577243750Srwatson ;; 4578243750Srwatson esac 4579243750Srwatson 4580243750Srwatson cat <<"EOF" 4581243750Srwatson} 4582243750Srwatson 4583243750Srwatsonvoid * 4584243750Srwatsonxmalloc (size_t num) 4585243750Srwatson{ 4586243750Srwatson void *p = (void *) malloc (num); 4587243750Srwatson if (!p) 4588243750Srwatson lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4589243750Srwatson 4590243750Srwatson return p; 4591243750Srwatson} 4592243750Srwatson 4593243750Srwatsonchar * 4594243750Srwatsonxstrdup (const char *string) 4595243750Srwatson{ 4596243750Srwatson return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 4597243750Srwatson string) : NULL; 4598243750Srwatson} 4599243750Srwatson 4600243750Srwatsonconst char * 4601243750Srwatsonbase_name (const char *name) 4602243750Srwatson{ 4603243750Srwatson const char *base; 4604243750Srwatson 4605243750Srwatson#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4606243750Srwatson /* Skip over the disk name in MSDOS pathnames. */ 4607243750Srwatson if (isalpha ((unsigned char) name[0]) && name[1] == ':') 4608243750Srwatson name += 2; 4609243750Srwatson#endif 4610243750Srwatson 4611243750Srwatson for (base = name; *name; name++) 4612243750Srwatson if (IS_DIR_SEPARATOR (*name)) 4613243750Srwatson base = name + 1; 4614243750Srwatson return base; 4615243750Srwatson} 4616243750Srwatson 4617243750Srwatsonint 4618243750Srwatsoncheck_executable (const char *path) 4619243750Srwatson{ 4620243750Srwatson struct stat st; 4621243750Srwatson 4622243750Srwatson lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 4623243750Srwatson nonempty (path)); 4624243750Srwatson if ((!path) || (!*path)) 4625243750Srwatson return 0; 4626243750Srwatson 4627243750Srwatson if ((stat (path, &st) >= 0) 4628243750Srwatson && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 4629243750Srwatson return 1; 4630243750Srwatson else 4631243750Srwatson return 0; 4632243750Srwatson} 4633243750Srwatson 4634243750Srwatsonint 4635243750Srwatsonmake_executable (const char *path) 4636243750Srwatson{ 4637243750Srwatson int rval = 0; 4638243750Srwatson struct stat st; 4639243750Srwatson 4640243750Srwatson lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 4641243750Srwatson nonempty (path)); 4642243750Srwatson if ((!path) || (!*path)) 4643243750Srwatson return 0; 4644243750Srwatson 4645243750Srwatson if (stat (path, &st) >= 0) 4646243750Srwatson { 4647243750Srwatson rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 4648243750Srwatson } 4649243750Srwatson return rval; 4650243750Srwatson} 4651243750Srwatson 4652243750Srwatson/* Searches for the full path of the wrapper. Returns 4653243750Srwatson newly allocated full path name if found, NULL otherwise 4654243750Srwatson Does not chase symlinks, even on platforms that support them. 4655243750Srwatson*/ 4656243750Srwatsonchar * 4657243750Srwatsonfind_executable (const char *wrapper) 4658243750Srwatson{ 4659243750Srwatson int has_slash = 0; 4660243750Srwatson const char *p; 4661243750Srwatson const char *p_next; 4662243750Srwatson /* static buffer for getcwd */ 4663243750Srwatson char tmp[LT_PATHMAX + 1]; 4664243750Srwatson int tmp_len; 4665243750Srwatson char *concat_name; 4666243750Srwatson 4667243750Srwatson lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 4668243750Srwatson nonempty (wrapper)); 4669243750Srwatson 4670243750Srwatson if ((wrapper == NULL) || (*wrapper == '\0')) 4671243750Srwatson return NULL; 4672243750Srwatson 4673243750Srwatson /* Absolute path? */ 4674243750Srwatson#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4675243750Srwatson if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 4676243750Srwatson { 4677243750Srwatson concat_name = xstrdup (wrapper); 4678243750Srwatson if (check_executable (concat_name)) 4679243750Srwatson return concat_name; 4680243750Srwatson XFREE (concat_name); 4681243750Srwatson } 4682243750Srwatson else 4683243750Srwatson { 4684243750Srwatson#endif 4685243750Srwatson if (IS_DIR_SEPARATOR (wrapper[0])) 4686243750Srwatson { 4687243750Srwatson concat_name = xstrdup (wrapper); 4688243750Srwatson if (check_executable (concat_name)) 4689243750Srwatson return concat_name; 4690243750Srwatson XFREE (concat_name); 4691243750Srwatson } 4692243750Srwatson#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4693243750Srwatson } 4694243750Srwatson#endif 4695243750Srwatson 4696243750Srwatson for (p = wrapper; *p; p++) 4697243750Srwatson if (*p == '/') 4698243750Srwatson { 4699243750Srwatson has_slash = 1; 4700243750Srwatson break; 4701243750Srwatson } 4702243750Srwatson if (!has_slash) 4703243750Srwatson { 4704243750Srwatson /* no slashes; search PATH */ 4705243750Srwatson const char *path = getenv ("PATH"); 4706243750Srwatson if (path != NULL) 4707243750Srwatson { 4708243750Srwatson for (p = path; *p; p = p_next) 4709243750Srwatson { 4710243750Srwatson const char *q; 4711243750Srwatson size_t p_len; 4712243750Srwatson for (q = p; *q; q++) 4713243750Srwatson if (IS_PATH_SEPARATOR (*q)) 4714243750Srwatson break; 4715243750Srwatson p_len = q - p; 4716243750Srwatson p_next = (*q == '\0' ? q : q + 1); 4717243750Srwatson if (p_len == 0) 4718243750Srwatson { 4719243750Srwatson /* empty path: current directory */ 4720243750Srwatson if (getcwd (tmp, LT_PATHMAX) == NULL) 4721243750Srwatson lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4722243750Srwatson nonnull (strerror (errno))); 4723243750Srwatson tmp_len = strlen (tmp); 4724243750Srwatson concat_name = 4725243750Srwatson XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4726243750Srwatson memcpy (concat_name, tmp, tmp_len); 4727243750Srwatson concat_name[tmp_len] = '/'; 4728243750Srwatson strcpy (concat_name + tmp_len + 1, wrapper); 4729243750Srwatson } 4730243750Srwatson else 4731243750Srwatson { 4732243750Srwatson concat_name = 4733243750Srwatson XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 4734243750Srwatson memcpy (concat_name, p, p_len); 4735243750Srwatson concat_name[p_len] = '/'; 4736243750Srwatson strcpy (concat_name + p_len + 1, wrapper); 4737243750Srwatson } 4738243750Srwatson if (check_executable (concat_name)) 4739243750Srwatson return concat_name; 4740243750Srwatson XFREE (concat_name); 4741243750Srwatson } 4742243750Srwatson } 4743243750Srwatson /* not found in PATH; assume curdir */ 4744243750Srwatson } 4745243750Srwatson /* Relative path | not found in path: prepend cwd */ 4746243750Srwatson if (getcwd (tmp, LT_PATHMAX) == NULL) 4747243750Srwatson lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4748243750Srwatson nonnull (strerror (errno))); 4749243750Srwatson tmp_len = strlen (tmp); 4750243750Srwatson concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4751243750Srwatson memcpy (concat_name, tmp, tmp_len); 4752243750Srwatson concat_name[tmp_len] = '/'; 4753243750Srwatson strcpy (concat_name + tmp_len + 1, wrapper); 4754243750Srwatson 4755243750Srwatson if (check_executable (concat_name)) 4756243750Srwatson return concat_name; 4757243750Srwatson XFREE (concat_name); 4758243750Srwatson return NULL; 4759243750Srwatson} 4760243750Srwatson 4761243750Srwatsonchar * 4762243750Srwatsonchase_symlinks (const char *pathspec) 4763243750Srwatson{ 4764243750Srwatson#ifndef S_ISLNK 4765243750Srwatson return xstrdup (pathspec); 4766243750Srwatson#else 4767243750Srwatson char buf[LT_PATHMAX]; 4768243750Srwatson struct stat s; 4769243750Srwatson char *tmp_pathspec = xstrdup (pathspec); 4770243750Srwatson char *p; 4771243750Srwatson int has_symlinks = 0; 4772243750Srwatson while (strlen (tmp_pathspec) && !has_symlinks) 4773243750Srwatson { 4774243750Srwatson lt_debugprintf (__FILE__, __LINE__, 4775243750Srwatson "checking path component for symlinks: %s\n", 4776243750Srwatson tmp_pathspec); 4777243750Srwatson if (lstat (tmp_pathspec, &s) == 0) 4778243750Srwatson { 4779243750Srwatson if (S_ISLNK (s.st_mode) != 0) 4780243750Srwatson { 4781243750Srwatson has_symlinks = 1; 4782243750Srwatson break; 4783243750Srwatson } 4784243750Srwatson 4785243750Srwatson /* search backwards for last DIR_SEPARATOR */ 4786243750Srwatson p = tmp_pathspec + strlen (tmp_pathspec) - 1; 4787243750Srwatson while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4788243750Srwatson p--; 4789243750Srwatson if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4790243750Srwatson { 4791243750Srwatson /* no more DIR_SEPARATORS left */ 4792243750Srwatson break; 4793243750Srwatson } 4794243750Srwatson *p = '\0'; 4795243750Srwatson } 4796243750Srwatson else 4797243750Srwatson { 4798243750Srwatson lt_fatal (__FILE__, __LINE__, 4799243750Srwatson "error accessing file \"%s\": %s", 4800243750Srwatson tmp_pathspec, nonnull (strerror (errno))); 4801243750Srwatson } 4802243750Srwatson } 4803243750Srwatson XFREE (tmp_pathspec); 4804243750Srwatson 4805243750Srwatson if (!has_symlinks) 4806243750Srwatson { 4807243750Srwatson return xstrdup (pathspec); 4808243750Srwatson } 4809243750Srwatson 4810243750Srwatson tmp_pathspec = realpath (pathspec, buf); 4811243750Srwatson if (tmp_pathspec == 0) 4812243750Srwatson { 4813243750Srwatson lt_fatal (__FILE__, __LINE__, 4814243750Srwatson "could not follow symlinks for %s", pathspec); 4815243750Srwatson } 4816243750Srwatson return xstrdup (tmp_pathspec); 4817243750Srwatson#endif 4818243750Srwatson} 4819243750Srwatson 4820243750Srwatsonchar * 4821243750Srwatsonstrendzap (char *str, const char *pat) 4822243750Srwatson{ 4823243750Srwatson size_t len, patlen; 4824243750Srwatson 4825243750Srwatson assert (str != NULL); 4826243750Srwatson assert (pat != NULL); 4827243750Srwatson 4828243750Srwatson len = strlen (str); 4829243750Srwatson patlen = strlen (pat); 4830243750Srwatson 4831243750Srwatson if (patlen <= len) 4832243750Srwatson { 4833243750Srwatson str += len - patlen; 4834243750Srwatson if (strcmp (str, pat) == 0) 4835243750Srwatson *str = '\0'; 4836243750Srwatson } 4837243750Srwatson return str; 4838243750Srwatson} 4839243750Srwatson 4840243750Srwatsonvoid 4841243750Srwatsonlt_debugprintf (const char *file, int line, const char *fmt, ...) 4842243750Srwatson{ 4843243750Srwatson va_list args; 4844243750Srwatson if (lt_debug) 4845243750Srwatson { 4846243750Srwatson (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 4847243750Srwatson va_start (args, fmt); 4848243750Srwatson (void) vfprintf (stderr, fmt, args); 4849243750Srwatson va_end (args); 4850243750Srwatson } 4851243750Srwatson} 4852243750Srwatson 4853243750Srwatsonstatic void 4854243750Srwatsonlt_error_core (int exit_status, const char *file, 4855243750Srwatson int line, const char *mode, 4856243750Srwatson const char *message, va_list ap) 4857243750Srwatson{ 4858243750Srwatson fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 4859243750Srwatson vfprintf (stderr, message, ap); 4860243750Srwatson fprintf (stderr, ".\n"); 4861243750Srwatson 4862243750Srwatson if (exit_status >= 0) 4863243750Srwatson exit (exit_status); 4864243750Srwatson} 4865243750Srwatson 4866243750Srwatsonvoid 4867243750Srwatsonlt_fatal (const char *file, int line, const char *message, ...) 4868243750Srwatson{ 4869243750Srwatson va_list ap; 4870243750Srwatson va_start (ap, message); 4871243750Srwatson lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 4872243750Srwatson va_end (ap); 4873243750Srwatson} 4874243750Srwatson 4875243750Srwatsonstatic const char * 4876243750Srwatsonnonnull (const char *s) 4877243750Srwatson{ 4878243750Srwatson return s ? s : "(null)"; 4879243750Srwatson} 4880243750Srwatson 4881243750Srwatsonstatic const char * 4882243750Srwatsonnonempty (const char *s) 4883243750Srwatson{ 4884243750Srwatson return (s && !*s) ? "(empty)" : nonnull (s); 4885243750Srwatson} 4886243750Srwatson 4887243750Srwatsonvoid 4888243750Srwatsonlt_setenv (const char *name, const char *value) 4889243750Srwatson{ 4890243750Srwatson lt_debugprintf (__FILE__, __LINE__, 4891243750Srwatson "(lt_setenv) setting '%s' to '%s'\n", 4892243750Srwatson nonnull (name), nonnull (value)); 4893243750Srwatson { 4894243750Srwatson#ifdef HAVE_SETENV 4895243750Srwatson /* always make a copy, for consistency with !HAVE_SETENV */ 4896243750Srwatson char *str = xstrdup (value); 4897243750Srwatson setenv (name, str, 1); 4898243750Srwatson#else 4899243750Srwatson int len = strlen (name) + 1 + strlen (value) + 1; 4900243750Srwatson char *str = XMALLOC (char, len); 4901243750Srwatson sprintf (str, "%s=%s", name, value); 4902243750Srwatson if (putenv (str) != EXIT_SUCCESS) 4903243750Srwatson { 4904243750Srwatson XFREE (str); 4905243750Srwatson } 4906243750Srwatson#endif 4907243750Srwatson } 4908243750Srwatson} 4909243750Srwatson 4910243750Srwatsonchar * 4911243750Srwatsonlt_extend_str (const char *orig_value, const char *add, int to_end) 4912243750Srwatson{ 4913243750Srwatson char *new_value; 4914243750Srwatson if (orig_value && *orig_value) 4915243750Srwatson { 4916243750Srwatson int orig_value_len = strlen (orig_value); 4917243750Srwatson int add_len = strlen (add); 4918243750Srwatson new_value = XMALLOC (char, add_len + orig_value_len + 1); 4919243750Srwatson if (to_end) 4920243750Srwatson { 4921243750Srwatson strcpy (new_value, orig_value); 4922243750Srwatson strcpy (new_value + orig_value_len, add); 4923243750Srwatson } 4924243750Srwatson else 4925243750Srwatson { 4926243750Srwatson strcpy (new_value, add); 4927243750Srwatson strcpy (new_value + add_len, orig_value); 4928243750Srwatson } 4929243750Srwatson } 4930243750Srwatson else 4931243750Srwatson { 4932243750Srwatson new_value = xstrdup (add); 4933243750Srwatson } 4934243750Srwatson return new_value; 4935243750Srwatson} 4936243750Srwatson 4937243750Srwatsonvoid 4938243750Srwatsonlt_update_exe_path (const char *name, const char *value) 4939243750Srwatson{ 4940243750Srwatson lt_debugprintf (__FILE__, __LINE__, 4941243750Srwatson "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 4942243750Srwatson nonnull (name), nonnull (value)); 4943243750Srwatson 4944243750Srwatson if (name && *name && value && *value) 4945243750Srwatson { 4946243750Srwatson char *new_value = lt_extend_str (getenv (name), value, 0); 4947243750Srwatson /* some systems can't cope with a ':'-terminated path #' */ 4948243750Srwatson int len = strlen (new_value); 4949243750Srwatson while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 4950243750Srwatson { 4951243750Srwatson new_value[len-1] = '\0'; 4952243750Srwatson } 4953243750Srwatson lt_setenv (name, new_value); 4954243750Srwatson XFREE (new_value); 4955243750Srwatson } 4956243750Srwatson} 4957243750Srwatson 4958243750Srwatsonvoid 4959243750Srwatsonlt_update_lib_path (const char *name, const char *value) 4960243750Srwatson{ 4961243750Srwatson lt_debugprintf (__FILE__, __LINE__, 4962243750Srwatson "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 4963243750Srwatson nonnull (name), nonnull (value)); 4964243750Srwatson 4965243750Srwatson if (name && *name && value && *value) 4966243750Srwatson { 4967243750Srwatson char *new_value = lt_extend_str (getenv (name), value, 0); 4968243750Srwatson lt_setenv (name, new_value); 4969243750Srwatson XFREE (new_value); 4970243750Srwatson } 4971243750Srwatson} 4972243750Srwatson 4973243750SrwatsonEOF 4974243750Srwatson case $host_os in 4975243750Srwatson mingw*) 4976243750Srwatson cat <<"EOF" 4977243750Srwatson 4978243750Srwatson/* Prepares an argument vector before calling spawn(). 4979243750Srwatson Note that spawn() does not by itself call the command interpreter 4980243750Srwatson (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 4981243750Srwatson ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 4982243750Srwatson GetVersionEx(&v); 4983243750Srwatson v.dwPlatformId == VER_PLATFORM_WIN32_NT; 4984243750Srwatson }) ? "cmd.exe" : "command.com"). 4985243750Srwatson Instead it simply concatenates the arguments, separated by ' ', and calls 4986243750Srwatson CreateProcess(). We must quote the arguments since Win32 CreateProcess() 4987243750Srwatson interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 4988243750Srwatson special way: 4989243750Srwatson - Space and tab are interpreted as delimiters. They are not treated as 4990243750Srwatson delimiters if they are surrounded by double quotes: "...". 4991243750Srwatson - Unescaped double quotes are removed from the input. Their only effect is 4992243750Srwatson that within double quotes, space and tab are treated like normal 4993243750Srwatson characters. 4994243750Srwatson - Backslashes not followed by double quotes are not special. 4995243750Srwatson - But 2*n+1 backslashes followed by a double quote become 4996243750Srwatson n backslashes followed by a double quote (n >= 0): 4997243750Srwatson \" -> " 4998243750Srwatson \\\" -> \" 4999243750Srwatson \\\\\" -> \\" 5000243750Srwatson */ 5001243750Srwatson#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" 5002243750Srwatson#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" 5003243750Srwatsonchar ** 5004243750Srwatsonprepare_spawn (char **argv) 5005243750Srwatson{ 5006243750Srwatson size_t argc; 5007243750Srwatson char **new_argv; 5008243750Srwatson size_t i; 5009243750Srwatson 5010243750Srwatson /* Count number of arguments. */ 5011243750Srwatson for (argc = 0; argv[argc] != NULL; argc++) 5012243750Srwatson ; 5013243750Srwatson 5014243750Srwatson /* Allocate new argument vector. */ 5015243750Srwatson new_argv = XMALLOC (char *, argc + 1); 5016243750Srwatson 5017243750Srwatson /* Put quoted arguments into the new argument vector. */ 5018243750Srwatson for (i = 0; i < argc; i++) 5019243750Srwatson { 5020243750Srwatson const char *string = argv[i]; 5021243750Srwatson 5022243750Srwatson if (string[0] == '\0') 5023243750Srwatson new_argv[i] = xstrdup ("\"\""); 5024243750Srwatson else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 5025243750Srwatson { 5026243750Srwatson int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 5027243750Srwatson size_t length; 5028243750Srwatson unsigned int backslashes; 5029243750Srwatson const char *s; 5030243750Srwatson char *quoted_string; 5031243750Srwatson char *p; 5032243750Srwatson 5033243750Srwatson length = 0; 5034243750Srwatson backslashes = 0; 5035243750Srwatson if (quote_around) 5036243750Srwatson length++; 5037243750Srwatson for (s = string; *s != '\0'; s++) 5038243750Srwatson { 5039243750Srwatson char c = *s; 5040243750Srwatson if (c == '"') 5041243750Srwatson length += backslashes + 1; 5042243750Srwatson length++; 5043243750Srwatson if (c == '\\') 5044243750Srwatson backslashes++; 5045243750Srwatson else 5046243750Srwatson backslashes = 0; 5047243750Srwatson } 5048243750Srwatson if (quote_around) 5049243750Srwatson length += backslashes + 1; 5050243750Srwatson 5051243750Srwatson quoted_string = XMALLOC (char, length + 1); 5052243750Srwatson 5053243750Srwatson p = quoted_string; 5054243750Srwatson backslashes = 0; 5055243750Srwatson if (quote_around) 5056243750Srwatson *p++ = '"'; 5057243750Srwatson for (s = string; *s != '\0'; s++) 5058243750Srwatson { 5059243750Srwatson char c = *s; 5060243750Srwatson if (c == '"') 5061243750Srwatson { 5062243750Srwatson unsigned int j; 5063243750Srwatson for (j = backslashes + 1; j > 0; j--) 5064243750Srwatson *p++ = '\\'; 5065243750Srwatson } 5066243750Srwatson *p++ = c; 5067243750Srwatson if (c == '\\') 5068243750Srwatson backslashes++; 5069243750Srwatson else 5070243750Srwatson backslashes = 0; 5071243750Srwatson } 5072243750Srwatson if (quote_around) 5073243750Srwatson { 5074243750Srwatson unsigned int j; 5075243750Srwatson for (j = backslashes; j > 0; j--) 5076243750Srwatson *p++ = '\\'; 5077243750Srwatson *p++ = '"'; 5078243750Srwatson } 5079243750Srwatson *p = '\0'; 5080243750Srwatson 5081243750Srwatson new_argv[i] = quoted_string; 5082243750Srwatson } 5083243750Srwatson else 5084243750Srwatson new_argv[i] = (char *) string; 5085243750Srwatson } 5086243750Srwatson new_argv[argc] = NULL; 5087243750Srwatson 5088243750Srwatson return new_argv; 5089243750Srwatson} 5090243750SrwatsonEOF 5091243750Srwatson ;; 5092243750Srwatson esac 5093243750Srwatson 5094243750Srwatson cat <<"EOF" 5095243750Srwatsonvoid lt_dump_script (FILE* f) 5096243750Srwatson{ 5097243750SrwatsonEOF 5098243750Srwatson func_emit_wrapper yes | 5099243750Srwatson $SED -n -e ' 5100243750Srwatsons/^\(.\{79\}\)\(..*\)/\1\ 5101243750Srwatson\2/ 5102243750Srwatsonh 5103243750Srwatsons/\([\\"]\)/\\\1/g 5104243750Srwatsons/$/\\n/ 5105243750Srwatsons/\([^\n]*\).*/ fputs ("\1", f);/p 5106243750Srwatsong 5107243750SrwatsonD' 5108243750Srwatson cat <<"EOF" 5109243750Srwatson} 5110243750SrwatsonEOF 5111243750Srwatson} 5112243750Srwatson# end: func_emit_cwrapperexe_src 5113243750Srwatson 5114243750Srwatson# func_win32_import_lib_p ARG 5115243750Srwatson# True if ARG is an import lib, as indicated by $file_magic_cmd 5116243750Srwatsonfunc_win32_import_lib_p () 5117243750Srwatson{ 5118243750Srwatson $opt_debug 5119243750Srwatson case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 5120243750Srwatson *import*) : ;; 5121243750Srwatson *) false ;; 5122243750Srwatson esac 5123243750Srwatson} 5124243750Srwatson 5125243750Srwatson# func_mode_link arg... 5126243750Srwatsonfunc_mode_link () 5127243750Srwatson{ 5128243750Srwatson $opt_debug 5129156283Srwatson case $host in 5130243750Srwatson *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5131156283Srwatson # It is impossible to link a dll without this setting, and 5132156283Srwatson # we shouldn't force the makefile maintainer to figure out 5133156283Srwatson # which system we are compiling for in order to pass an extra 5134156283Srwatson # flag for every libtool invocation. 5135156283Srwatson # allow_undefined=no 5136156283Srwatson 5137156283Srwatson # FIXME: Unfortunately, there are problems with the above when trying 5138156283Srwatson # to make a dll which has undefined symbols, in which case not 5139156283Srwatson # even a static library is built. For now, we need to specify 5140156283Srwatson # -no-undefined on the libtool link line when we can be certain 5141156283Srwatson # that all symbols are satisfied, otherwise we get a static library. 5142156283Srwatson allow_undefined=yes 5143156283Srwatson ;; 5144156283Srwatson *) 5145156283Srwatson allow_undefined=yes 5146156283Srwatson ;; 5147156283Srwatson esac 5148243750Srwatson libtool_args=$nonopt 5149156283Srwatson base_compile="$nonopt $@" 5150243750Srwatson compile_command=$nonopt 5151243750Srwatson finalize_command=$nonopt 5152156283Srwatson 5153156283Srwatson compile_rpath= 5154156283Srwatson finalize_rpath= 5155156283Srwatson compile_shlibpath= 5156156283Srwatson finalize_shlibpath= 5157156283Srwatson convenience= 5158156283Srwatson old_convenience= 5159156283Srwatson deplibs= 5160156283Srwatson old_deplibs= 5161156283Srwatson compiler_flags= 5162156283Srwatson linker_flags= 5163156283Srwatson dllsearchpath= 5164156283Srwatson lib_search_path=`pwd` 5165156283Srwatson inst_prefix_dir= 5166243750Srwatson new_inherited_linker_flags= 5167156283Srwatson 5168156283Srwatson avoid_version=no 5169243750Srwatson bindir= 5170156283Srwatson dlfiles= 5171156283Srwatson dlprefiles= 5172156283Srwatson dlself=no 5173156283Srwatson export_dynamic=no 5174156283Srwatson export_symbols= 5175156283Srwatson export_symbols_regex= 5176156283Srwatson generated= 5177156283Srwatson libobjs= 5178156283Srwatson ltlibs= 5179156283Srwatson module=no 5180156283Srwatson no_install=no 5181156283Srwatson objs= 5182156283Srwatson non_pic_objects= 5183156283Srwatson precious_files_regex= 5184156283Srwatson prefer_static_libs=no 5185156283Srwatson preload=no 5186156283Srwatson prev= 5187156283Srwatson prevarg= 5188156283Srwatson release= 5189156283Srwatson rpath= 5190156283Srwatson xrpath= 5191156283Srwatson perm_rpath= 5192156283Srwatson temp_rpath= 5193156283Srwatson thread_safe=no 5194156283Srwatson vinfo= 5195156283Srwatson vinfo_number=no 5196243750Srwatson weak_libs= 5197191273Srwatson single_module="${wl}-single_module" 5198156283Srwatson func_infer_tag $base_compile 5199156283Srwatson 5200156283Srwatson # We need to know -static, to get the right output filenames. 5201156283Srwatson for arg 5202156283Srwatson do 5203156283Srwatson case $arg in 5204243750Srwatson -shared) 5205243750Srwatson test "$build_libtool_libs" != yes && \ 5206243750Srwatson func_fatal_configuration "can not build a shared library" 5207243750Srwatson build_old_libs=no 5208243750Srwatson break 5209243750Srwatson ;; 5210173143Srwatson -all-static | -static | -static-libtool-libs) 5211173143Srwatson case $arg in 5212173143Srwatson -all-static) 5213156283Srwatson if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 5214243750Srwatson func_warning "complete static linking is impossible in this configuration" 5215156283Srwatson fi 5216156283Srwatson if test -n "$link_static_flag"; then 5217156283Srwatson dlopen_self=$dlopen_self_static 5218156283Srwatson fi 5219159985Srwatson prefer_static_libs=yes 5220173143Srwatson ;; 5221173143Srwatson -static) 5222156283Srwatson if test -z "$pic_flag" && test -n "$link_static_flag"; then 5223156283Srwatson dlopen_self=$dlopen_self_static 5224156283Srwatson fi 5225159985Srwatson prefer_static_libs=built 5226173143Srwatson ;; 5227173143Srwatson -static-libtool-libs) 5228173143Srwatson if test -z "$pic_flag" && test -n "$link_static_flag"; then 5229173143Srwatson dlopen_self=$dlopen_self_static 5230173143Srwatson fi 5231173143Srwatson prefer_static_libs=yes 5232173143Srwatson ;; 5233173143Srwatson esac 5234156283Srwatson build_libtool_libs=no 5235156283Srwatson build_old_libs=yes 5236156283Srwatson break 5237156283Srwatson ;; 5238156283Srwatson esac 5239156283Srwatson done 5240156283Srwatson 5241156283Srwatson # See if our shared archives depend on static archives. 5242156283Srwatson test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5243156283Srwatson 5244156283Srwatson # Go through the arguments, transforming them on the way. 5245156283Srwatson while test "$#" -gt 0; do 5246156283Srwatson arg="$1" 5247156283Srwatson shift 5248243750Srwatson func_quote_for_eval "$arg" 5249243750Srwatson qarg=$func_quote_for_eval_unquoted_result 5250243750Srwatson func_append libtool_args " $func_quote_for_eval_result" 5251156283Srwatson 5252156283Srwatson # If the previous option needs an argument, assign it. 5253156283Srwatson if test -n "$prev"; then 5254156283Srwatson case $prev in 5255156283Srwatson output) 5256243750Srwatson func_append compile_command " @OUTPUT@" 5257243750Srwatson func_append finalize_command " @OUTPUT@" 5258156283Srwatson ;; 5259156283Srwatson esac 5260156283Srwatson 5261156283Srwatson case $prev in 5262243750Srwatson bindir) 5263243750Srwatson bindir="$arg" 5264243750Srwatson prev= 5265243750Srwatson continue 5266243750Srwatson ;; 5267156283Srwatson dlfiles|dlprefiles) 5268156283Srwatson if test "$preload" = no; then 5269156283Srwatson # Add the symbol object into the linking commands. 5270243750Srwatson func_append compile_command " @SYMFILE@" 5271243750Srwatson func_append finalize_command " @SYMFILE@" 5272156283Srwatson preload=yes 5273156283Srwatson fi 5274156283Srwatson case $arg in 5275156283Srwatson *.la | *.lo) ;; # We handle these cases below. 5276156283Srwatson force) 5277156283Srwatson if test "$dlself" = no; then 5278156283Srwatson dlself=needless 5279156283Srwatson export_dynamic=yes 5280156283Srwatson fi 5281156283Srwatson prev= 5282156283Srwatson continue 5283156283Srwatson ;; 5284156283Srwatson self) 5285156283Srwatson if test "$prev" = dlprefiles; then 5286156283Srwatson dlself=yes 5287156283Srwatson elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 5288156283Srwatson dlself=yes 5289156283Srwatson else 5290156283Srwatson dlself=needless 5291156283Srwatson export_dynamic=yes 5292156283Srwatson fi 5293156283Srwatson prev= 5294156283Srwatson continue 5295156283Srwatson ;; 5296156283Srwatson *) 5297156283Srwatson if test "$prev" = dlfiles; then 5298243750Srwatson func_append dlfiles " $arg" 5299156283Srwatson else 5300243750Srwatson func_append dlprefiles " $arg" 5301156283Srwatson fi 5302156283Srwatson prev= 5303156283Srwatson continue 5304156283Srwatson ;; 5305156283Srwatson esac 5306156283Srwatson ;; 5307156283Srwatson expsyms) 5308156283Srwatson export_symbols="$arg" 5309243750Srwatson test -f "$arg" \ 5310243750Srwatson || func_fatal_error "symbol file \`$arg' does not exist" 5311156283Srwatson prev= 5312156283Srwatson continue 5313156283Srwatson ;; 5314156283Srwatson expsyms_regex) 5315156283Srwatson export_symbols_regex="$arg" 5316156283Srwatson prev= 5317156283Srwatson continue 5318156283Srwatson ;; 5319243750Srwatson framework) 5320243750Srwatson case $host in 5321243750Srwatson *-*-darwin*) 5322243750Srwatson case "$deplibs " in 5323243750Srwatson *" $qarg.ltframework "*) ;; 5324243750Srwatson *) func_append deplibs " $qarg.ltframework" # this is fixed later 5325243750Srwatson ;; 5326243750Srwatson esac 5327243750Srwatson ;; 5328243750Srwatson esac 5329156283Srwatson prev= 5330156283Srwatson continue 5331156283Srwatson ;; 5332243750Srwatson inst_prefix) 5333243750Srwatson inst_prefix_dir="$arg" 5334156283Srwatson prev= 5335156283Srwatson continue 5336156283Srwatson ;; 5337156283Srwatson objectlist) 5338156283Srwatson if test -f "$arg"; then 5339156283Srwatson save_arg=$arg 5340156283Srwatson moreargs= 5341243750Srwatson for fil in `cat "$save_arg"` 5342156283Srwatson do 5343243750Srwatson# func_append moreargs " $fil" 5344156283Srwatson arg=$fil 5345156283Srwatson # A libtool-controlled object. 5346156283Srwatson 5347156283Srwatson # Check to see that this really is a libtool object. 5348243750Srwatson if func_lalib_unsafe_p "$arg"; then 5349156283Srwatson pic_object= 5350156283Srwatson non_pic_object= 5351156283Srwatson 5352156283Srwatson # Read the .lo file 5353243750Srwatson func_source "$arg" 5354156283Srwatson 5355243750Srwatson if test -z "$pic_object" || 5356156283Srwatson test -z "$non_pic_object" || 5357243750Srwatson test "$pic_object" = none && 5358156283Srwatson test "$non_pic_object" = none; then 5359243750Srwatson func_fatal_error "cannot find name of object for \`$arg'" 5360156283Srwatson fi 5361156283Srwatson 5362156283Srwatson # Extract subdirectory from the argument. 5363243750Srwatson func_dirname "$arg" "/" "" 5364243750Srwatson xdir="$func_dirname_result" 5365156283Srwatson 5366156283Srwatson if test "$pic_object" != none; then 5367156283Srwatson # Prepend the subdirectory the object is found in. 5368156283Srwatson pic_object="$xdir$pic_object" 5369156283Srwatson 5370156283Srwatson if test "$prev" = dlfiles; then 5371156283Srwatson if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5372243750Srwatson func_append dlfiles " $pic_object" 5373156283Srwatson prev= 5374156283Srwatson continue 5375156283Srwatson else 5376156283Srwatson # If libtool objects are unsupported, then we need to preload. 5377156283Srwatson prev=dlprefiles 5378156283Srwatson fi 5379156283Srwatson fi 5380156283Srwatson 5381156283Srwatson # CHECK ME: I think I busted this. -Ossama 5382156283Srwatson if test "$prev" = dlprefiles; then 5383156283Srwatson # Preload the old-style object. 5384243750Srwatson func_append dlprefiles " $pic_object" 5385156283Srwatson prev= 5386156283Srwatson fi 5387156283Srwatson 5388156283Srwatson # A PIC object. 5389243750Srwatson func_append libobjs " $pic_object" 5390156283Srwatson arg="$pic_object" 5391156283Srwatson fi 5392156283Srwatson 5393156283Srwatson # Non-PIC object. 5394156283Srwatson if test "$non_pic_object" != none; then 5395156283Srwatson # Prepend the subdirectory the object is found in. 5396156283Srwatson non_pic_object="$xdir$non_pic_object" 5397156283Srwatson 5398156283Srwatson # A standard non-PIC object 5399243750Srwatson func_append non_pic_objects " $non_pic_object" 5400156283Srwatson if test -z "$pic_object" || test "$pic_object" = none ; then 5401156283Srwatson arg="$non_pic_object" 5402156283Srwatson fi 5403159985Srwatson else 5404159985Srwatson # If the PIC object exists, use it instead. 5405159985Srwatson # $xdir was prepended to $pic_object above. 5406159985Srwatson non_pic_object="$pic_object" 5407243750Srwatson func_append non_pic_objects " $non_pic_object" 5408156283Srwatson fi 5409156283Srwatson else 5410156283Srwatson # Only an error if not doing a dry-run. 5411243750Srwatson if $opt_dry_run; then 5412156283Srwatson # Extract subdirectory from the argument. 5413243750Srwatson func_dirname "$arg" "/" "" 5414243750Srwatson xdir="$func_dirname_result" 5415156283Srwatson 5416243750Srwatson func_lo2o "$arg" 5417243750Srwatson pic_object=$xdir$objdir/$func_lo2o_result 5418243750Srwatson non_pic_object=$xdir$func_lo2o_result 5419243750Srwatson func_append libobjs " $pic_object" 5420243750Srwatson func_append non_pic_objects " $non_pic_object" 5421243750Srwatson else 5422243750Srwatson func_fatal_error "\`$arg' is not a valid libtool object" 5423156283Srwatson fi 5424156283Srwatson fi 5425156283Srwatson done 5426156283Srwatson else 5427243750Srwatson func_fatal_error "link input file \`$arg' does not exist" 5428156283Srwatson fi 5429156283Srwatson arg=$save_arg 5430156283Srwatson prev= 5431156283Srwatson continue 5432156283Srwatson ;; 5433243750Srwatson precious_regex) 5434243750Srwatson precious_files_regex="$arg" 5435243750Srwatson prev= 5436243750Srwatson continue 5437243750Srwatson ;; 5438243750Srwatson release) 5439243750Srwatson release="-$arg" 5440243750Srwatson prev= 5441243750Srwatson continue 5442243750Srwatson ;; 5443156283Srwatson rpath | xrpath) 5444156283Srwatson # We need an absolute path. 5445156283Srwatson case $arg in 5446156283Srwatson [\\/]* | [A-Za-z]:[\\/]*) ;; 5447156283Srwatson *) 5448243750Srwatson func_fatal_error "only absolute run-paths are allowed" 5449156283Srwatson ;; 5450156283Srwatson esac 5451156283Srwatson if test "$prev" = rpath; then 5452156283Srwatson case "$rpath " in 5453156283Srwatson *" $arg "*) ;; 5454243750Srwatson *) func_append rpath " $arg" ;; 5455156283Srwatson esac 5456156283Srwatson else 5457156283Srwatson case "$xrpath " in 5458156283Srwatson *" $arg "*) ;; 5459243750Srwatson *) func_append xrpath " $arg" ;; 5460156283Srwatson esac 5461156283Srwatson fi 5462156283Srwatson prev= 5463156283Srwatson continue 5464156283Srwatson ;; 5465243750Srwatson shrext) 5466243750Srwatson shrext_cmds="$arg" 5467156283Srwatson prev= 5468156283Srwatson continue 5469156283Srwatson ;; 5470243750Srwatson weak) 5471243750Srwatson func_append weak_libs " $arg" 5472156283Srwatson prev= 5473156283Srwatson continue 5474156283Srwatson ;; 5475156283Srwatson xcclinker) 5476243750Srwatson func_append linker_flags " $qarg" 5477243750Srwatson func_append compiler_flags " $qarg" 5478156283Srwatson prev= 5479243750Srwatson func_append compile_command " $qarg" 5480243750Srwatson func_append finalize_command " $qarg" 5481156283Srwatson continue 5482156283Srwatson ;; 5483243750Srwatson xcompiler) 5484243750Srwatson func_append compiler_flags " $qarg" 5485156283Srwatson prev= 5486243750Srwatson func_append compile_command " $qarg" 5487243750Srwatson func_append finalize_command " $qarg" 5488156283Srwatson continue 5489156283Srwatson ;; 5490243750Srwatson xlinker) 5491243750Srwatson func_append linker_flags " $qarg" 5492243750Srwatson func_append compiler_flags " $wl$qarg" 5493156283Srwatson prev= 5494243750Srwatson func_append compile_command " $wl$qarg" 5495243750Srwatson func_append finalize_command " $wl$qarg" 5496156283Srwatson continue 5497156283Srwatson ;; 5498156283Srwatson *) 5499156283Srwatson eval "$prev=\"\$arg\"" 5500156283Srwatson prev= 5501156283Srwatson continue 5502156283Srwatson ;; 5503156283Srwatson esac 5504156283Srwatson fi # test -n "$prev" 5505156283Srwatson 5506156283Srwatson prevarg="$arg" 5507156283Srwatson 5508156283Srwatson case $arg in 5509156283Srwatson -all-static) 5510156283Srwatson if test -n "$link_static_flag"; then 5511243750Srwatson # See comment for -static flag below, for more details. 5512243750Srwatson func_append compile_command " $link_static_flag" 5513243750Srwatson func_append finalize_command " $link_static_flag" 5514156283Srwatson fi 5515156283Srwatson continue 5516156283Srwatson ;; 5517156283Srwatson 5518156283Srwatson -allow-undefined) 5519156283Srwatson # FIXME: remove this flag sometime in the future. 5520243750Srwatson func_fatal_error "\`-allow-undefined' must not be used because it is the default" 5521156283Srwatson ;; 5522156283Srwatson 5523156283Srwatson -avoid-version) 5524156283Srwatson avoid_version=yes 5525156283Srwatson continue 5526156283Srwatson ;; 5527156283Srwatson 5528243750Srwatson -bindir) 5529243750Srwatson prev=bindir 5530243750Srwatson continue 5531243750Srwatson ;; 5532243750Srwatson 5533156283Srwatson -dlopen) 5534156283Srwatson prev=dlfiles 5535156283Srwatson continue 5536156283Srwatson ;; 5537156283Srwatson 5538156283Srwatson -dlpreopen) 5539156283Srwatson prev=dlprefiles 5540156283Srwatson continue 5541156283Srwatson ;; 5542156283Srwatson 5543156283Srwatson -export-dynamic) 5544156283Srwatson export_dynamic=yes 5545156283Srwatson continue 5546156283Srwatson ;; 5547156283Srwatson 5548156283Srwatson -export-symbols | -export-symbols-regex) 5549156283Srwatson if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 5550243750Srwatson func_fatal_error "more than one -exported-symbols argument is not allowed" 5551156283Srwatson fi 5552156283Srwatson if test "X$arg" = "X-export-symbols"; then 5553156283Srwatson prev=expsyms 5554156283Srwatson else 5555156283Srwatson prev=expsyms_regex 5556156283Srwatson fi 5557156283Srwatson continue 5558156283Srwatson ;; 5559156283Srwatson 5560243750Srwatson -framework) 5561243750Srwatson prev=framework 5562159985Srwatson continue 5563159985Srwatson ;; 5564156283Srwatson 5565156283Srwatson -inst-prefix-dir) 5566156283Srwatson prev=inst_prefix 5567156283Srwatson continue 5568156283Srwatson ;; 5569156283Srwatson 5570156283Srwatson # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 5571156283Srwatson # so, if we see these flags be careful not to treat them like -L 5572156283Srwatson -L[A-Z][A-Z]*:*) 5573156283Srwatson case $with_gcc/$host in 5574156283Srwatson no/*-*-irix* | /*-*-irix*) 5575243750Srwatson func_append compile_command " $arg" 5576243750Srwatson func_append finalize_command " $arg" 5577156283Srwatson ;; 5578156283Srwatson esac 5579156283Srwatson continue 5580156283Srwatson ;; 5581156283Srwatson 5582156283Srwatson -L*) 5583243750Srwatson func_stripname "-L" '' "$arg" 5584243750Srwatson if test -z "$func_stripname_result"; then 5585243750Srwatson if test "$#" -gt 0; then 5586243750Srwatson func_fatal_error "require no space between \`-L' and \`$1'" 5587243750Srwatson else 5588243750Srwatson func_fatal_error "need path for \`-L' option" 5589243750Srwatson fi 5590243750Srwatson fi 5591243750Srwatson func_resolve_sysroot "$func_stripname_result" 5592243750Srwatson dir=$func_resolve_sysroot_result 5593156283Srwatson # We need an absolute path. 5594156283Srwatson case $dir in 5595156283Srwatson [\\/]* | [A-Za-z]:[\\/]*) ;; 5596156283Srwatson *) 5597156283Srwatson absdir=`cd "$dir" && pwd` 5598243750Srwatson test -z "$absdir" && \ 5599243750Srwatson func_fatal_error "cannot determine absolute directory name of \`$dir'" 5600156283Srwatson dir="$absdir" 5601156283Srwatson ;; 5602156283Srwatson esac 5603156283Srwatson case "$deplibs " in 5604243750Srwatson *" -L$dir "* | *" $arg "*) 5605243750Srwatson # Will only happen for absolute or sysroot arguments 5606243750Srwatson ;; 5607156283Srwatson *) 5608243750Srwatson # Preserve sysroot, but never include relative directories 5609243750Srwatson case $dir in 5610243750Srwatson [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 5611243750Srwatson *) func_append deplibs " -L$dir" ;; 5612243750Srwatson esac 5613243750Srwatson func_append lib_search_path " $dir" 5614156283Srwatson ;; 5615156283Srwatson esac 5616156283Srwatson case $host in 5617243750Srwatson *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5618243750Srwatson testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 5619156283Srwatson case :$dllsearchpath: in 5620156283Srwatson *":$dir:"*) ;; 5621243750Srwatson ::) dllsearchpath=$dir;; 5622243750Srwatson *) func_append dllsearchpath ":$dir";; 5623156283Srwatson esac 5624159985Srwatson case :$dllsearchpath: in 5625159985Srwatson *":$testbindir:"*) ;; 5626243750Srwatson ::) dllsearchpath=$testbindir;; 5627243750Srwatson *) func_append dllsearchpath ":$testbindir";; 5628159985Srwatson esac 5629156283Srwatson ;; 5630156283Srwatson esac 5631243750Srwatson deplibs="$deplibs $arg" 5632156283Srwatson continue 5633156283Srwatson ;; 5634156283Srwatson 5635156283Srwatson -l*) 5636156283Srwatson if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 5637156283Srwatson case $host in 5638243750Srwatson *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 5639156283Srwatson # These systems don't actually have a C or math library (as such) 5640156283Srwatson continue 5641156283Srwatson ;; 5642159985Srwatson *-*-os2*) 5643156283Srwatson # These systems don't actually have a C library (as such) 5644156283Srwatson test "X$arg" = "X-lc" && continue 5645156283Srwatson ;; 5646156283Srwatson *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5647156283Srwatson # Do not include libc due to us having libc/libc_r. 5648156283Srwatson test "X$arg" = "X-lc" && continue 5649156283Srwatson ;; 5650156283Srwatson *-*-rhapsody* | *-*-darwin1.[012]) 5651156283Srwatson # Rhapsody C and math libraries are in the System framework 5652243750Srwatson func_append deplibs " System.ltframework" 5653156283Srwatson continue 5654159985Srwatson ;; 5655159985Srwatson *-*-sco3.2v5* | *-*-sco5v6*) 5656159985Srwatson # Causes problems with __ctype 5657159985Srwatson test "X$arg" = "X-lc" && continue 5658159985Srwatson ;; 5659159985Srwatson *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 5660159985Srwatson # Compiler inserts libc in the correct place for threads to work 5661159985Srwatson test "X$arg" = "X-lc" && continue 5662159985Srwatson ;; 5663156283Srwatson esac 5664156283Srwatson elif test "X$arg" = "X-lc_r"; then 5665156283Srwatson case $host in 5666156283Srwatson *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5667156283Srwatson # Do not include libc_r directly, use -pthread flag. 5668156283Srwatson continue 5669156283Srwatson ;; 5670156283Srwatson esac 5671156283Srwatson fi 5672243750Srwatson func_append deplibs " $arg" 5673156283Srwatson continue 5674156283Srwatson ;; 5675156283Srwatson 5676243750Srwatson -module) 5677243750Srwatson module=yes 5678243750Srwatson continue 5679243750Srwatson ;; 5680243750Srwatson 5681156283Srwatson # Tru64 UNIX uses -model [arg] to determine the layout of C++ 5682156283Srwatson # classes, name mangling, and exception handling. 5683243750Srwatson # Darwin uses the -arch flag to determine output architecture. 5684243750Srwatson -model|-arch|-isysroot|--sysroot) 5685243750Srwatson func_append compiler_flags " $arg" 5686243750Srwatson func_append compile_command " $arg" 5687243750Srwatson func_append finalize_command " $arg" 5688156283Srwatson prev=xcompiler 5689156283Srwatson continue 5690156283Srwatson ;; 5691156283Srwatson 5692243750Srwatson -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 5693243750Srwatson |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 5694243750Srwatson func_append compiler_flags " $arg" 5695243750Srwatson func_append compile_command " $arg" 5696243750Srwatson func_append finalize_command " $arg" 5697243750Srwatson case "$new_inherited_linker_flags " in 5698243750Srwatson *" $arg "*) ;; 5699243750Srwatson * ) func_append new_inherited_linker_flags " $arg" ;; 5700243750Srwatson esac 5701156283Srwatson continue 5702156283Srwatson ;; 5703156283Srwatson 5704191273Srwatson -multi_module) 5705191273Srwatson single_module="${wl}-multi_module" 5706191273Srwatson continue 5707191273Srwatson ;; 5708191273Srwatson 5709156283Srwatson -no-fast-install) 5710156283Srwatson fast_install=no 5711156283Srwatson continue 5712156283Srwatson ;; 5713156283Srwatson 5714156283Srwatson -no-install) 5715156283Srwatson case $host in 5716243750Srwatson *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 5717156283Srwatson # The PATH hackery in wrapper scripts is required on Windows 5718173143Srwatson # and Darwin in order for the loader to find any dlls it needs. 5719243750Srwatson func_warning "\`-no-install' is ignored for $host" 5720243750Srwatson func_warning "assuming \`-no-fast-install' instead" 5721156283Srwatson fast_install=no 5722156283Srwatson ;; 5723156283Srwatson *) no_install=yes ;; 5724156283Srwatson esac 5725156283Srwatson continue 5726156283Srwatson ;; 5727156283Srwatson 5728156283Srwatson -no-undefined) 5729156283Srwatson allow_undefined=no 5730156283Srwatson continue 5731156283Srwatson ;; 5732156283Srwatson 5733156283Srwatson -objectlist) 5734156283Srwatson prev=objectlist 5735156283Srwatson continue 5736156283Srwatson ;; 5737156283Srwatson 5738156283Srwatson -o) prev=output ;; 5739156283Srwatson 5740156283Srwatson -precious-files-regex) 5741156283Srwatson prev=precious_regex 5742156283Srwatson continue 5743156283Srwatson ;; 5744156283Srwatson 5745156283Srwatson -release) 5746156283Srwatson prev=release 5747156283Srwatson continue 5748156283Srwatson ;; 5749156283Srwatson 5750156283Srwatson -rpath) 5751156283Srwatson prev=rpath 5752156283Srwatson continue 5753156283Srwatson ;; 5754156283Srwatson 5755156283Srwatson -R) 5756156283Srwatson prev=xrpath 5757156283Srwatson continue 5758156283Srwatson ;; 5759156283Srwatson 5760156283Srwatson -R*) 5761243750Srwatson func_stripname '-R' '' "$arg" 5762243750Srwatson dir=$func_stripname_result 5763156283Srwatson # We need an absolute path. 5764156283Srwatson case $dir in 5765156283Srwatson [\\/]* | [A-Za-z]:[\\/]*) ;; 5766243750Srwatson =*) 5767243750Srwatson func_stripname '=' '' "$dir" 5768243750Srwatson dir=$lt_sysroot$func_stripname_result 5769243750Srwatson ;; 5770156283Srwatson *) 5771243750Srwatson func_fatal_error "only absolute run-paths are allowed" 5772156283Srwatson ;; 5773156283Srwatson esac 5774156283Srwatson case "$xrpath " in 5775156283Srwatson *" $dir "*) ;; 5776243750Srwatson *) func_append xrpath " $dir" ;; 5777156283Srwatson esac 5778156283Srwatson continue 5779156283Srwatson ;; 5780156283Srwatson 5781243750Srwatson -shared) 5782243750Srwatson # The effects of -shared are defined in a previous loop. 5783243750Srwatson continue 5784243750Srwatson ;; 5785243750Srwatson 5786243750Srwatson -shrext) 5787243750Srwatson prev=shrext 5788243750Srwatson continue 5789243750Srwatson ;; 5790243750Srwatson 5791173143Srwatson -static | -static-libtool-libs) 5792156283Srwatson # The effects of -static are defined in a previous loop. 5793156283Srwatson # We used to do the same as -all-static on platforms that 5794156283Srwatson # didn't have a PIC flag, but the assumption that the effects 5795156283Srwatson # would be equivalent was wrong. It would break on at least 5796156283Srwatson # Digital Unix and AIX. 5797156283Srwatson continue 5798156283Srwatson ;; 5799156283Srwatson 5800156283Srwatson -thread-safe) 5801156283Srwatson thread_safe=yes 5802156283Srwatson continue 5803156283Srwatson ;; 5804156283Srwatson 5805156283Srwatson -version-info) 5806156283Srwatson prev=vinfo 5807156283Srwatson continue 5808156283Srwatson ;; 5809243750Srwatson 5810156283Srwatson -version-number) 5811156283Srwatson prev=vinfo 5812156283Srwatson vinfo_number=yes 5813156283Srwatson continue 5814156283Srwatson ;; 5815156283Srwatson 5816243750Srwatson -weak) 5817243750Srwatson prev=weak 5818243750Srwatson continue 5819243750Srwatson ;; 5820243750Srwatson 5821156283Srwatson -Wc,*) 5822243750Srwatson func_stripname '-Wc,' '' "$arg" 5823243750Srwatson args=$func_stripname_result 5824156283Srwatson arg= 5825156283Srwatson save_ifs="$IFS"; IFS=',' 5826156283Srwatson for flag in $args; do 5827156283Srwatson IFS="$save_ifs" 5828243750Srwatson func_quote_for_eval "$flag" 5829243750Srwatson func_append arg " $func_quote_for_eval_result" 5830243750Srwatson func_append compiler_flags " $func_quote_for_eval_result" 5831156283Srwatson done 5832156283Srwatson IFS="$save_ifs" 5833243750Srwatson func_stripname ' ' '' "$arg" 5834243750Srwatson arg=$func_stripname_result 5835156283Srwatson ;; 5836156283Srwatson 5837156283Srwatson -Wl,*) 5838243750Srwatson func_stripname '-Wl,' '' "$arg" 5839243750Srwatson args=$func_stripname_result 5840156283Srwatson arg= 5841156283Srwatson save_ifs="$IFS"; IFS=',' 5842156283Srwatson for flag in $args; do 5843156283Srwatson IFS="$save_ifs" 5844243750Srwatson func_quote_for_eval "$flag" 5845243750Srwatson func_append arg " $wl$func_quote_for_eval_result" 5846243750Srwatson func_append compiler_flags " $wl$func_quote_for_eval_result" 5847243750Srwatson func_append linker_flags " $func_quote_for_eval_result" 5848156283Srwatson done 5849156283Srwatson IFS="$save_ifs" 5850243750Srwatson func_stripname ' ' '' "$arg" 5851243750Srwatson arg=$func_stripname_result 5852156283Srwatson ;; 5853156283Srwatson 5854156283Srwatson -Xcompiler) 5855156283Srwatson prev=xcompiler 5856156283Srwatson continue 5857156283Srwatson ;; 5858156283Srwatson 5859156283Srwatson -Xlinker) 5860156283Srwatson prev=xlinker 5861156283Srwatson continue 5862156283Srwatson ;; 5863156283Srwatson 5864156283Srwatson -XCClinker) 5865156283Srwatson prev=xcclinker 5866156283Srwatson continue 5867156283Srwatson ;; 5868156283Srwatson 5869243750Srwatson # -msg_* for osf cc 5870243750Srwatson -msg_*) 5871243750Srwatson func_quote_for_eval "$arg" 5872243750Srwatson arg="$func_quote_for_eval_result" 5873243750Srwatson ;; 5874243750Srwatson 5875243750Srwatson # Flags to be passed through unchanged, with rationale: 5876243750Srwatson # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 5877243750Srwatson # -r[0-9][0-9]* specify processor for the SGI compiler 5878243750Srwatson # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 5879243750Srwatson # +DA*, +DD* enable 64-bit mode for the HP compiler 5880243750Srwatson # -q* compiler args for the IBM compiler 5881243750Srwatson # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 5882243750Srwatson # -F/path path to uninstalled frameworks, gcc on darwin 5883243750Srwatson # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 5884243750Srwatson # @file GCC response files 5885243750Srwatson # -tp=* Portland pgcc target processor selection 5886243750Srwatson # --sysroot=* for sysroot support 5887243750Srwatson # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 5888243750Srwatson -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 5889243750Srwatson -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 5890243750Srwatson -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 5891243750Srwatson func_quote_for_eval "$arg" 5892243750Srwatson arg="$func_quote_for_eval_result" 5893243750Srwatson func_append compile_command " $arg" 5894243750Srwatson func_append finalize_command " $arg" 5895243750Srwatson func_append compiler_flags " $arg" 5896243750Srwatson continue 5897243750Srwatson ;; 5898243750Srwatson 5899156283Srwatson # Some other compiler flag. 5900156283Srwatson -* | +*) 5901243750Srwatson func_quote_for_eval "$arg" 5902243750Srwatson arg="$func_quote_for_eval_result" 5903156283Srwatson ;; 5904156283Srwatson 5905156283Srwatson *.$objext) 5906156283Srwatson # A standard object. 5907243750Srwatson func_append objs " $arg" 5908156283Srwatson ;; 5909156283Srwatson 5910156283Srwatson *.lo) 5911156283Srwatson # A libtool-controlled object. 5912156283Srwatson 5913156283Srwatson # Check to see that this really is a libtool object. 5914243750Srwatson if func_lalib_unsafe_p "$arg"; then 5915156283Srwatson pic_object= 5916156283Srwatson non_pic_object= 5917156283Srwatson 5918156283Srwatson # Read the .lo file 5919243750Srwatson func_source "$arg" 5920156283Srwatson 5921243750Srwatson if test -z "$pic_object" || 5922156283Srwatson test -z "$non_pic_object" || 5923243750Srwatson test "$pic_object" = none && 5924156283Srwatson test "$non_pic_object" = none; then 5925243750Srwatson func_fatal_error "cannot find name of object for \`$arg'" 5926156283Srwatson fi 5927156283Srwatson 5928156283Srwatson # Extract subdirectory from the argument. 5929243750Srwatson func_dirname "$arg" "/" "" 5930243750Srwatson xdir="$func_dirname_result" 5931156283Srwatson 5932156283Srwatson if test "$pic_object" != none; then 5933156283Srwatson # Prepend the subdirectory the object is found in. 5934156283Srwatson pic_object="$xdir$pic_object" 5935156283Srwatson 5936156283Srwatson if test "$prev" = dlfiles; then 5937156283Srwatson if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5938243750Srwatson func_append dlfiles " $pic_object" 5939156283Srwatson prev= 5940156283Srwatson continue 5941156283Srwatson else 5942156283Srwatson # If libtool objects are unsupported, then we need to preload. 5943156283Srwatson prev=dlprefiles 5944156283Srwatson fi 5945156283Srwatson fi 5946156283Srwatson 5947156283Srwatson # CHECK ME: I think I busted this. -Ossama 5948156283Srwatson if test "$prev" = dlprefiles; then 5949156283Srwatson # Preload the old-style object. 5950243750Srwatson func_append dlprefiles " $pic_object" 5951156283Srwatson prev= 5952156283Srwatson fi 5953156283Srwatson 5954156283Srwatson # A PIC object. 5955243750Srwatson func_append libobjs " $pic_object" 5956156283Srwatson arg="$pic_object" 5957156283Srwatson fi 5958156283Srwatson 5959156283Srwatson # Non-PIC object. 5960156283Srwatson if test "$non_pic_object" != none; then 5961156283Srwatson # Prepend the subdirectory the object is found in. 5962156283Srwatson non_pic_object="$xdir$non_pic_object" 5963156283Srwatson 5964156283Srwatson # A standard non-PIC object 5965243750Srwatson func_append non_pic_objects " $non_pic_object" 5966156283Srwatson if test -z "$pic_object" || test "$pic_object" = none ; then 5967156283Srwatson arg="$non_pic_object" 5968156283Srwatson fi 5969159985Srwatson else 5970159985Srwatson # If the PIC object exists, use it instead. 5971159985Srwatson # $xdir was prepended to $pic_object above. 5972159985Srwatson non_pic_object="$pic_object" 5973243750Srwatson func_append non_pic_objects " $non_pic_object" 5974156283Srwatson fi 5975156283Srwatson else 5976156283Srwatson # Only an error if not doing a dry-run. 5977243750Srwatson if $opt_dry_run; then 5978156283Srwatson # Extract subdirectory from the argument. 5979243750Srwatson func_dirname "$arg" "/" "" 5980243750Srwatson xdir="$func_dirname_result" 5981156283Srwatson 5982243750Srwatson func_lo2o "$arg" 5983243750Srwatson pic_object=$xdir$objdir/$func_lo2o_result 5984243750Srwatson non_pic_object=$xdir$func_lo2o_result 5985243750Srwatson func_append libobjs " $pic_object" 5986243750Srwatson func_append non_pic_objects " $non_pic_object" 5987243750Srwatson else 5988243750Srwatson func_fatal_error "\`$arg' is not a valid libtool object" 5989156283Srwatson fi 5990156283Srwatson fi 5991156283Srwatson ;; 5992156283Srwatson 5993156283Srwatson *.$libext) 5994156283Srwatson # An archive. 5995243750Srwatson func_append deplibs " $arg" 5996243750Srwatson func_append old_deplibs " $arg" 5997156283Srwatson continue 5998156283Srwatson ;; 5999156283Srwatson 6000156283Srwatson *.la) 6001156283Srwatson # A libtool-controlled library. 6002156283Srwatson 6003243750Srwatson func_resolve_sysroot "$arg" 6004156283Srwatson if test "$prev" = dlfiles; then 6005156283Srwatson # This library was specified with -dlopen. 6006243750Srwatson func_append dlfiles " $func_resolve_sysroot_result" 6007156283Srwatson prev= 6008156283Srwatson elif test "$prev" = dlprefiles; then 6009156283Srwatson # The library was specified with -dlpreopen. 6010243750Srwatson func_append dlprefiles " $func_resolve_sysroot_result" 6011156283Srwatson prev= 6012156283Srwatson else 6013243750Srwatson func_append deplibs " $func_resolve_sysroot_result" 6014156283Srwatson fi 6015156283Srwatson continue 6016156283Srwatson ;; 6017156283Srwatson 6018156283Srwatson # Some other compiler argument. 6019156283Srwatson *) 6020156283Srwatson # Unknown arguments in both finalize_command and compile_command need 6021156283Srwatson # to be aesthetically quoted because they are evaled later. 6022243750Srwatson func_quote_for_eval "$arg" 6023243750Srwatson arg="$func_quote_for_eval_result" 6024156283Srwatson ;; 6025156283Srwatson esac # arg 6026156283Srwatson 6027156283Srwatson # Now actually substitute the argument into the commands. 6028156283Srwatson if test -n "$arg"; then 6029243750Srwatson func_append compile_command " $arg" 6030243750Srwatson func_append finalize_command " $arg" 6031156283Srwatson fi 6032156283Srwatson done # argument parsing loop 6033156283Srwatson 6034243750Srwatson test -n "$prev" && \ 6035243750Srwatson func_fatal_help "the \`$prevarg' option requires an argument" 6036156283Srwatson 6037156283Srwatson if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 6038156283Srwatson eval arg=\"$export_dynamic_flag_spec\" 6039243750Srwatson func_append compile_command " $arg" 6040243750Srwatson func_append finalize_command " $arg" 6041156283Srwatson fi 6042156283Srwatson 6043156283Srwatson oldlibs= 6044156283Srwatson # calculate the name of the file, without its directory 6045243750Srwatson func_basename "$output" 6046243750Srwatson outputname="$func_basename_result" 6047156283Srwatson libobjs_save="$libobjs" 6048156283Srwatson 6049156283Srwatson if test -n "$shlibpath_var"; then 6050156283Srwatson # get the directories listed in $shlibpath_var 6051243750Srwatson eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 6052156283Srwatson else 6053156283Srwatson shlib_search_path= 6054156283Srwatson fi 6055156283Srwatson eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 6056156283Srwatson eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 6057156283Srwatson 6058243750Srwatson func_dirname "$output" "/" "" 6059243750Srwatson output_objdir="$func_dirname_result$objdir" 6060243750Srwatson func_to_tool_file "$output_objdir/" 6061243750Srwatson tool_output_objdir=$func_to_tool_file_result 6062156283Srwatson # Create the object directory. 6063243750Srwatson func_mkdir_p "$output_objdir" 6064156283Srwatson 6065156283Srwatson # Determine the type of output 6066156283Srwatson case $output in 6067156283Srwatson "") 6068243750Srwatson func_fatal_help "you must specify an output file" 6069156283Srwatson ;; 6070156283Srwatson *.$libext) linkmode=oldlib ;; 6071156283Srwatson *.lo | *.$objext) linkmode=obj ;; 6072156283Srwatson *.la) linkmode=lib ;; 6073156283Srwatson *) linkmode=prog ;; # Anything else should be a program. 6074156283Srwatson esac 6075156283Srwatson 6076156283Srwatson specialdeplibs= 6077156283Srwatson 6078156283Srwatson libs= 6079156283Srwatson # Find all interdependent deplibs by searching for libraries 6080156283Srwatson # that are linked more than once (e.g. -la -lb -la) 6081156283Srwatson for deplib in $deplibs; do 6082243750Srwatson if $opt_preserve_dup_deps ; then 6083156283Srwatson case "$libs " in 6084243750Srwatson *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6085156283Srwatson esac 6086156283Srwatson fi 6087243750Srwatson func_append libs " $deplib" 6088156283Srwatson done 6089156283Srwatson 6090156283Srwatson if test "$linkmode" = lib; then 6091156283Srwatson libs="$predeps $libs $compiler_lib_search_path $postdeps" 6092156283Srwatson 6093156283Srwatson # Compute libraries that are listed more than once in $predeps 6094156283Srwatson # $postdeps and mark them as special (i.e., whose duplicates are 6095156283Srwatson # not to be eliminated). 6096156283Srwatson pre_post_deps= 6097243750Srwatson if $opt_duplicate_compiler_generated_deps; then 6098156283Srwatson for pre_post_dep in $predeps $postdeps; do 6099156283Srwatson case "$pre_post_deps " in 6100243750Srwatson *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 6101156283Srwatson esac 6102243750Srwatson func_append pre_post_deps " $pre_post_dep" 6103156283Srwatson done 6104156283Srwatson fi 6105156283Srwatson pre_post_deps= 6106156283Srwatson fi 6107156283Srwatson 6108156283Srwatson deplibs= 6109156283Srwatson newdependency_libs= 6110156283Srwatson newlib_search_path= 6111156283Srwatson need_relink=no # whether we're linking any uninstalled libtool libraries 6112156283Srwatson notinst_deplibs= # not-installed libtool libraries 6113243750Srwatson notinst_path= # paths that contain not-installed libtool libraries 6114243750Srwatson 6115156283Srwatson case $linkmode in 6116156283Srwatson lib) 6117243750Srwatson passes="conv dlpreopen link" 6118156283Srwatson for file in $dlfiles $dlprefiles; do 6119156283Srwatson case $file in 6120156283Srwatson *.la) ;; 6121156283Srwatson *) 6122243750Srwatson func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 6123156283Srwatson ;; 6124156283Srwatson esac 6125156283Srwatson done 6126156283Srwatson ;; 6127156283Srwatson prog) 6128156283Srwatson compile_deplibs= 6129156283Srwatson finalize_deplibs= 6130156283Srwatson alldeplibs=no 6131156283Srwatson newdlfiles= 6132156283Srwatson newdlprefiles= 6133156283Srwatson passes="conv scan dlopen dlpreopen link" 6134156283Srwatson ;; 6135156283Srwatson *) passes="conv" 6136156283Srwatson ;; 6137156283Srwatson esac 6138243750Srwatson 6139156283Srwatson for pass in $passes; do 6140243750Srwatson # The preopen pass in lib mode reverses $deplibs; put it back here 6141243750Srwatson # so that -L comes before libs that need it for instance... 6142243750Srwatson if test "$linkmode,$pass" = "lib,link"; then 6143243750Srwatson ## FIXME: Find the place where the list is rebuilt in the wrong 6144243750Srwatson ## order, and fix it there properly 6145243750Srwatson tmp_deplibs= 6146243750Srwatson for deplib in $deplibs; do 6147243750Srwatson tmp_deplibs="$deplib $tmp_deplibs" 6148243750Srwatson done 6149243750Srwatson deplibs="$tmp_deplibs" 6150243750Srwatson fi 6151243750Srwatson 6152156283Srwatson if test "$linkmode,$pass" = "lib,link" || 6153156283Srwatson test "$linkmode,$pass" = "prog,scan"; then 6154156283Srwatson libs="$deplibs" 6155156283Srwatson deplibs= 6156156283Srwatson fi 6157156283Srwatson if test "$linkmode" = prog; then 6158156283Srwatson case $pass in 6159156283Srwatson dlopen) libs="$dlfiles" ;; 6160156283Srwatson dlpreopen) libs="$dlprefiles" ;; 6161156283Srwatson link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 6162156283Srwatson esac 6163156283Srwatson fi 6164243750Srwatson if test "$linkmode,$pass" = "lib,dlpreopen"; then 6165243750Srwatson # Collect and forward deplibs of preopened libtool libs 6166243750Srwatson for lib in $dlprefiles; do 6167243750Srwatson # Ignore non-libtool-libs 6168243750Srwatson dependency_libs= 6169243750Srwatson func_resolve_sysroot "$lib" 6170243750Srwatson case $lib in 6171243750Srwatson *.la) func_source "$func_resolve_sysroot_result" ;; 6172243750Srwatson esac 6173243750Srwatson 6174243750Srwatson # Collect preopened libtool deplibs, except any this library 6175243750Srwatson # has declared as weak libs 6176243750Srwatson for deplib in $dependency_libs; do 6177243750Srwatson func_basename "$deplib" 6178243750Srwatson deplib_base=$func_basename_result 6179243750Srwatson case " $weak_libs " in 6180243750Srwatson *" $deplib_base "*) ;; 6181243750Srwatson *) func_append deplibs " $deplib" ;; 6182243750Srwatson esac 6183243750Srwatson done 6184243750Srwatson done 6185243750Srwatson libs="$dlprefiles" 6186243750Srwatson fi 6187156283Srwatson if test "$pass" = dlopen; then 6188156283Srwatson # Collect dlpreopened libraries 6189156283Srwatson save_deplibs="$deplibs" 6190156283Srwatson deplibs= 6191156283Srwatson fi 6192243750Srwatson 6193156283Srwatson for deplib in $libs; do 6194156283Srwatson lib= 6195156283Srwatson found=no 6196156283Srwatson case $deplib in 6197243750Srwatson -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 6198243750Srwatson |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 6199156283Srwatson if test "$linkmode,$pass" = "prog,link"; then 6200156283Srwatson compile_deplibs="$deplib $compile_deplibs" 6201156283Srwatson finalize_deplibs="$deplib $finalize_deplibs" 6202156283Srwatson else 6203243750Srwatson func_append compiler_flags " $deplib" 6204156283Srwatson fi 6205159985Srwatson 6206159985Srwatson case $linkmode in 6207159985Srwatson lib) 6208159985Srwatson deplibs="$deplib $deplibs" 6209159985Srwatson test "$pass" = conv && continue 6210159985Srwatson newdependency_libs="$deplib $newdependency_libs" 6211159985Srwatson ;; 6212159985Srwatson prog) 6213159985Srwatson if test "$pass" = conv; then 6214159985Srwatson deplibs="$deplib $deplibs" 6215159985Srwatson continue 6216159985Srwatson fi 6217159985Srwatson if test "$pass" = scan; then 6218159985Srwatson deplibs="$deplib $deplibs" 6219159985Srwatson else 6220159985Srwatson compile_deplibs="$deplib $compile_deplibs" 6221159985Srwatson finalize_deplibs="$deplib $finalize_deplibs" 6222159985Srwatson fi 6223159985Srwatson ;; 6224159985Srwatson *) 6225159985Srwatson ;; 6226159985Srwatson esac # linkmode 6227159985Srwatson 6228156283Srwatson continue 6229156283Srwatson ;; 6230156283Srwatson -l*) 6231156283Srwatson if test "$linkmode" != lib && test "$linkmode" != prog; then 6232243750Srwatson func_warning "\`-l' is ignored for archives/objects" 6233156283Srwatson continue 6234156283Srwatson fi 6235243750Srwatson func_stripname '-l' '' "$deplib" 6236243750Srwatson name=$func_stripname_result 6237191273Srwatson if test "$linkmode" = lib; then 6238191273Srwatson searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 6239191273Srwatson else 6240191273Srwatson searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 6241191273Srwatson fi 6242191273Srwatson for searchdir in $searchdirs; do 6243156283Srwatson for search_ext in .la $std_shrext .so .a; do 6244156283Srwatson # Search the libtool library 6245156283Srwatson lib="$searchdir/lib${name}${search_ext}" 6246156283Srwatson if test -f "$lib"; then 6247156283Srwatson if test "$search_ext" = ".la"; then 6248156283Srwatson found=yes 6249156283Srwatson else 6250156283Srwatson found=no 6251156283Srwatson fi 6252156283Srwatson break 2 6253156283Srwatson fi 6254156283Srwatson done 6255156283Srwatson done 6256156283Srwatson if test "$found" != yes; then 6257156283Srwatson # deplib doesn't seem to be a libtool library 6258156283Srwatson if test "$linkmode,$pass" = "prog,link"; then 6259156283Srwatson compile_deplibs="$deplib $compile_deplibs" 6260156283Srwatson finalize_deplibs="$deplib $finalize_deplibs" 6261156283Srwatson else 6262156283Srwatson deplibs="$deplib $deplibs" 6263156283Srwatson test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6264156283Srwatson fi 6265156283Srwatson continue 6266156283Srwatson else # deplib is a libtool library 6267156283Srwatson # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 6268156283Srwatson # We need to do some special things here, and not later. 6269156283Srwatson if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6270156283Srwatson case " $predeps $postdeps " in 6271156283Srwatson *" $deplib "*) 6272243750Srwatson if func_lalib_p "$lib"; then 6273156283Srwatson library_names= 6274156283Srwatson old_library= 6275243750Srwatson func_source "$lib" 6276156283Srwatson for l in $old_library $library_names; do 6277156283Srwatson ll="$l" 6278156283Srwatson done 6279156283Srwatson if test "X$ll" = "X$old_library" ; then # only static version available 6280156283Srwatson found=no 6281243750Srwatson func_dirname "$lib" "" "." 6282243750Srwatson ladir="$func_dirname_result" 6283156283Srwatson lib=$ladir/$old_library 6284156283Srwatson if test "$linkmode,$pass" = "prog,link"; then 6285156283Srwatson compile_deplibs="$deplib $compile_deplibs" 6286156283Srwatson finalize_deplibs="$deplib $finalize_deplibs" 6287156283Srwatson else 6288156283Srwatson deplibs="$deplib $deplibs" 6289156283Srwatson test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6290156283Srwatson fi 6291156283Srwatson continue 6292156283Srwatson fi 6293156283Srwatson fi 6294243750Srwatson ;; 6295156283Srwatson *) ;; 6296156283Srwatson esac 6297156283Srwatson fi 6298156283Srwatson fi 6299156283Srwatson ;; # -l 6300243750Srwatson *.ltframework) 6301243750Srwatson if test "$linkmode,$pass" = "prog,link"; then 6302243750Srwatson compile_deplibs="$deplib $compile_deplibs" 6303243750Srwatson finalize_deplibs="$deplib $finalize_deplibs" 6304243750Srwatson else 6305243750Srwatson deplibs="$deplib $deplibs" 6306243750Srwatson if test "$linkmode" = lib ; then 6307243750Srwatson case "$new_inherited_linker_flags " in 6308243750Srwatson *" $deplib "*) ;; 6309243750Srwatson * ) func_append new_inherited_linker_flags " $deplib" ;; 6310243750Srwatson esac 6311243750Srwatson fi 6312243750Srwatson fi 6313243750Srwatson continue 6314243750Srwatson ;; 6315156283Srwatson -L*) 6316156283Srwatson case $linkmode in 6317156283Srwatson lib) 6318156283Srwatson deplibs="$deplib $deplibs" 6319156283Srwatson test "$pass" = conv && continue 6320156283Srwatson newdependency_libs="$deplib $newdependency_libs" 6321243750Srwatson func_stripname '-L' '' "$deplib" 6322243750Srwatson func_resolve_sysroot "$func_stripname_result" 6323243750Srwatson func_append newlib_search_path " $func_resolve_sysroot_result" 6324156283Srwatson ;; 6325156283Srwatson prog) 6326156283Srwatson if test "$pass" = conv; then 6327156283Srwatson deplibs="$deplib $deplibs" 6328156283Srwatson continue 6329156283Srwatson fi 6330156283Srwatson if test "$pass" = scan; then 6331156283Srwatson deplibs="$deplib $deplibs" 6332156283Srwatson else 6333156283Srwatson compile_deplibs="$deplib $compile_deplibs" 6334156283Srwatson finalize_deplibs="$deplib $finalize_deplibs" 6335156283Srwatson fi 6336243750Srwatson func_stripname '-L' '' "$deplib" 6337243750Srwatson func_resolve_sysroot "$func_stripname_result" 6338243750Srwatson func_append newlib_search_path " $func_resolve_sysroot_result" 6339156283Srwatson ;; 6340156283Srwatson *) 6341243750Srwatson func_warning "\`-L' is ignored for archives/objects" 6342156283Srwatson ;; 6343156283Srwatson esac # linkmode 6344156283Srwatson continue 6345156283Srwatson ;; # -L 6346156283Srwatson -R*) 6347156283Srwatson if test "$pass" = link; then 6348243750Srwatson func_stripname '-R' '' "$deplib" 6349243750Srwatson func_resolve_sysroot "$func_stripname_result" 6350243750Srwatson dir=$func_resolve_sysroot_result 6351156283Srwatson # Make sure the xrpath contains only unique directories. 6352156283Srwatson case "$xrpath " in 6353156283Srwatson *" $dir "*) ;; 6354243750Srwatson *) func_append xrpath " $dir" ;; 6355156283Srwatson esac 6356156283Srwatson fi 6357156283Srwatson deplibs="$deplib $deplibs" 6358156283Srwatson continue 6359156283Srwatson ;; 6360243750Srwatson *.la) 6361243750Srwatson func_resolve_sysroot "$deplib" 6362243750Srwatson lib=$func_resolve_sysroot_result 6363243750Srwatson ;; 6364156283Srwatson *.$libext) 6365156283Srwatson if test "$pass" = conv; then 6366156283Srwatson deplibs="$deplib $deplibs" 6367156283Srwatson continue 6368156283Srwatson fi 6369156283Srwatson case $linkmode in 6370156283Srwatson lib) 6371243750Srwatson # Linking convenience modules into shared libraries is allowed, 6372243750Srwatson # but linking other static libraries is non-portable. 6373243750Srwatson case " $dlpreconveniencelibs " in 6374243750Srwatson *" $deplib "*) ;; 6375243750Srwatson *) 6376243750Srwatson valid_a_lib=no 6377243750Srwatson case $deplibs_check_method in 6378243750Srwatson match_pattern*) 6379243750Srwatson set dummy $deplibs_check_method; shift 6380243750Srwatson match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 6381243750Srwatson if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 6382156283Srwatson | $EGREP "$match_pattern_regex" > /dev/null; then 6383243750Srwatson valid_a_lib=yes 6384243750Srwatson fi 6385243750Srwatson ;; 6386243750Srwatson pass_all) 6387156283Srwatson valid_a_lib=yes 6388156283Srwatson ;; 6389243750Srwatson esac 6390243750Srwatson if test "$valid_a_lib" != yes; then 6391243750Srwatson echo 6392243750Srwatson $ECHO "*** Warning: Trying to link with static lib archive $deplib." 6393243750Srwatson echo "*** I have the capability to make that library automatically link in when" 6394243750Srwatson echo "*** you link to this library. But I can only do this if you have a" 6395243750Srwatson echo "*** shared version of the library, which you do not appear to have" 6396243750Srwatson echo "*** because the file extensions .$libext of this argument makes me believe" 6397243750Srwatson echo "*** that it is just a static archive that I should not use here." 6398243750Srwatson else 6399243750Srwatson echo 6400243750Srwatson $ECHO "*** Warning: Linking the shared library $output against the" 6401243750Srwatson $ECHO "*** static library $deplib is not portable!" 6402243750Srwatson deplibs="$deplib $deplibs" 6403243750Srwatson fi 6404243750Srwatson ;; 6405243750Srwatson esac 6406156283Srwatson continue 6407156283Srwatson ;; 6408156283Srwatson prog) 6409156283Srwatson if test "$pass" != link; then 6410156283Srwatson deplibs="$deplib $deplibs" 6411156283Srwatson else 6412156283Srwatson compile_deplibs="$deplib $compile_deplibs" 6413156283Srwatson finalize_deplibs="$deplib $finalize_deplibs" 6414156283Srwatson fi 6415156283Srwatson continue 6416156283Srwatson ;; 6417156283Srwatson esac # linkmode 6418156283Srwatson ;; # *.$libext 6419156283Srwatson *.lo | *.$objext) 6420156283Srwatson if test "$pass" = conv; then 6421156283Srwatson deplibs="$deplib $deplibs" 6422156283Srwatson elif test "$linkmode" = prog; then 6423156283Srwatson if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 6424156283Srwatson # If there is no dlopen support or we're linking statically, 6425156283Srwatson # we need to preload. 6426243750Srwatson func_append newdlprefiles " $deplib" 6427156283Srwatson compile_deplibs="$deplib $compile_deplibs" 6428156283Srwatson finalize_deplibs="$deplib $finalize_deplibs" 6429156283Srwatson else 6430243750Srwatson func_append newdlfiles " $deplib" 6431156283Srwatson fi 6432156283Srwatson fi 6433156283Srwatson continue 6434156283Srwatson ;; 6435156283Srwatson %DEPLIBS%) 6436156283Srwatson alldeplibs=yes 6437156283Srwatson continue 6438156283Srwatson ;; 6439156283Srwatson esac # case $deplib 6440243750Srwatson 6441156283Srwatson if test "$found" = yes || test -f "$lib"; then : 6442156283Srwatson else 6443243750Srwatson func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 6444156283Srwatson fi 6445156283Srwatson 6446156283Srwatson # Check to see that this really is a libtool archive. 6447243750Srwatson func_lalib_unsafe_p "$lib" \ 6448243750Srwatson || func_fatal_error "\`$lib' is not a valid libtool archive" 6449156283Srwatson 6450243750Srwatson func_dirname "$lib" "" "." 6451243750Srwatson ladir="$func_dirname_result" 6452156283Srwatson 6453156283Srwatson dlname= 6454156283Srwatson dlopen= 6455156283Srwatson dlpreopen= 6456156283Srwatson libdir= 6457156283Srwatson library_names= 6458156283Srwatson old_library= 6459243750Srwatson inherited_linker_flags= 6460156283Srwatson # If the library was installed with an old release of libtool, 6461156283Srwatson # it will not redefine variables installed, or shouldnotlink 6462156283Srwatson installed=yes 6463156283Srwatson shouldnotlink=no 6464156283Srwatson avoidtemprpath= 6465156283Srwatson 6466156283Srwatson 6467156283Srwatson # Read the .la file 6468243750Srwatson func_source "$lib" 6469156283Srwatson 6470243750Srwatson # Convert "-framework foo" to "foo.ltframework" 6471243750Srwatson if test -n "$inherited_linker_flags"; then 6472243750Srwatson tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 6473243750Srwatson for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 6474243750Srwatson case " $new_inherited_linker_flags " in 6475243750Srwatson *" $tmp_inherited_linker_flag "*) ;; 6476243750Srwatson *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 6477243750Srwatson esac 6478243750Srwatson done 6479243750Srwatson fi 6480243750Srwatson dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 6481156283Srwatson if test "$linkmode,$pass" = "lib,link" || 6482156283Srwatson test "$linkmode,$pass" = "prog,scan" || 6483156283Srwatson { test "$linkmode" != prog && test "$linkmode" != lib; }; then 6484243750Srwatson test -n "$dlopen" && func_append dlfiles " $dlopen" 6485243750Srwatson test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 6486156283Srwatson fi 6487156283Srwatson 6488156283Srwatson if test "$pass" = conv; then 6489156283Srwatson # Only check for convenience libraries 6490156283Srwatson deplibs="$lib $deplibs" 6491156283Srwatson if test -z "$libdir"; then 6492156283Srwatson if test -z "$old_library"; then 6493243750Srwatson func_fatal_error "cannot find name of link library for \`$lib'" 6494156283Srwatson fi 6495156283Srwatson # It is a libtool convenience library, so add in its objects. 6496243750Srwatson func_append convenience " $ladir/$objdir/$old_library" 6497243750Srwatson func_append old_convenience " $ladir/$objdir/$old_library" 6498156283Srwatson elif test "$linkmode" != prog && test "$linkmode" != lib; then 6499243750Srwatson func_fatal_error "\`$lib' is not a convenience library" 6500156283Srwatson fi 6501243750Srwatson tmp_libs= 6502243750Srwatson for deplib in $dependency_libs; do 6503243750Srwatson deplibs="$deplib $deplibs" 6504243750Srwatson if $opt_preserve_dup_deps ; then 6505243750Srwatson case "$tmp_libs " in 6506243750Srwatson *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6507243750Srwatson esac 6508243750Srwatson fi 6509243750Srwatson func_append tmp_libs " $deplib" 6510243750Srwatson done 6511156283Srwatson continue 6512156283Srwatson fi # $pass = conv 6513156283Srwatson 6514156283Srwatson 6515156283Srwatson # Get the name of the library we link against. 6516156283Srwatson linklib= 6517243750Srwatson if test -n "$old_library" && 6518243750Srwatson { test "$prefer_static_libs" = yes || 6519243750Srwatson test "$prefer_static_libs,$installed" = "built,no"; }; then 6520243750Srwatson linklib=$old_library 6521243750Srwatson else 6522243750Srwatson for l in $old_library $library_names; do 6523243750Srwatson linklib="$l" 6524243750Srwatson done 6525243750Srwatson fi 6526156283Srwatson if test -z "$linklib"; then 6527243750Srwatson func_fatal_error "cannot find name of link library for \`$lib'" 6528156283Srwatson fi 6529156283Srwatson 6530156283Srwatson # This library was specified with -dlopen. 6531156283Srwatson if test "$pass" = dlopen; then 6532156283Srwatson if test -z "$libdir"; then 6533243750Srwatson func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 6534156283Srwatson fi 6535156283Srwatson if test -z "$dlname" || 6536156283Srwatson test "$dlopen_support" != yes || 6537156283Srwatson test "$build_libtool_libs" = no; then 6538156283Srwatson # If there is no dlname, no dlopen support or we're linking 6539156283Srwatson # statically, we need to preload. We also need to preload any 6540156283Srwatson # dependent libraries so libltdl's deplib preloader doesn't 6541156283Srwatson # bomb out in the load deplibs phase. 6542243750Srwatson func_append dlprefiles " $lib $dependency_libs" 6543156283Srwatson else 6544243750Srwatson func_append newdlfiles " $lib" 6545156283Srwatson fi 6546156283Srwatson continue 6547156283Srwatson fi # $pass = dlopen 6548156283Srwatson 6549156283Srwatson # We need an absolute path. 6550156283Srwatson case $ladir in 6551156283Srwatson [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 6552156283Srwatson *) 6553156283Srwatson abs_ladir=`cd "$ladir" && pwd` 6554156283Srwatson if test -z "$abs_ladir"; then 6555243750Srwatson func_warning "cannot determine absolute directory name of \`$ladir'" 6556243750Srwatson func_warning "passing it literally to the linker, although it might fail" 6557156283Srwatson abs_ladir="$ladir" 6558156283Srwatson fi 6559156283Srwatson ;; 6560156283Srwatson esac 6561243750Srwatson func_basename "$lib" 6562243750Srwatson laname="$func_basename_result" 6563156283Srwatson 6564156283Srwatson # Find the relevant object directory and library name. 6565156283Srwatson if test "X$installed" = Xyes; then 6566243750Srwatson if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6567243750Srwatson func_warning "library \`$lib' was moved." 6568156283Srwatson dir="$ladir" 6569156283Srwatson absdir="$abs_ladir" 6570156283Srwatson libdir="$abs_ladir" 6571156283Srwatson else 6572243750Srwatson dir="$lt_sysroot$libdir" 6573243750Srwatson absdir="$lt_sysroot$libdir" 6574156283Srwatson fi 6575156283Srwatson test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 6576156283Srwatson else 6577156283Srwatson if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6578156283Srwatson dir="$ladir" 6579156283Srwatson absdir="$abs_ladir" 6580156283Srwatson # Remove this search path later 6581243750Srwatson func_append notinst_path " $abs_ladir" 6582156283Srwatson else 6583156283Srwatson dir="$ladir/$objdir" 6584156283Srwatson absdir="$abs_ladir/$objdir" 6585156283Srwatson # Remove this search path later 6586243750Srwatson func_append notinst_path " $abs_ladir" 6587156283Srwatson fi 6588156283Srwatson fi # $installed = yes 6589243750Srwatson func_stripname 'lib' '.la' "$laname" 6590243750Srwatson name=$func_stripname_result 6591156283Srwatson 6592156283Srwatson # This library was specified with -dlpreopen. 6593156283Srwatson if test "$pass" = dlpreopen; then 6594243750Srwatson if test -z "$libdir" && test "$linkmode" = prog; then 6595243750Srwatson func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 6596156283Srwatson fi 6597243750Srwatson case "$host" in 6598243750Srwatson # special handling for platforms with PE-DLLs. 6599243750Srwatson *cygwin* | *mingw* | *cegcc* ) 6600243750Srwatson # Linker will automatically link against shared library if both 6601243750Srwatson # static and shared are present. Therefore, ensure we extract 6602243750Srwatson # symbols from the import library if a shared library is present 6603243750Srwatson # (otherwise, the dlopen module name will be incorrect). We do 6604243750Srwatson # this by putting the import library name into $newdlprefiles. 6605243750Srwatson # We recover the dlopen module name by 'saving' the la file 6606243750Srwatson # name in a special purpose variable, and (later) extracting the 6607243750Srwatson # dlname from the la file. 6608243750Srwatson if test -n "$dlname"; then 6609243750Srwatson func_tr_sh "$dir/$linklib" 6610243750Srwatson eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 6611243750Srwatson func_append newdlprefiles " $dir/$linklib" 6612243750Srwatson else 6613243750Srwatson func_append newdlprefiles " $dir/$old_library" 6614243750Srwatson # Keep a list of preopened convenience libraries to check 6615243750Srwatson # that they are being used correctly in the link pass. 6616243750Srwatson test -z "$libdir" && \ 6617243750Srwatson func_append dlpreconveniencelibs " $dir/$old_library" 6618243750Srwatson fi 6619243750Srwatson ;; 6620243750Srwatson * ) 6621243750Srwatson # Prefer using a static library (so that no silly _DYNAMIC symbols 6622243750Srwatson # are required to link). 6623243750Srwatson if test -n "$old_library"; then 6624243750Srwatson func_append newdlprefiles " $dir/$old_library" 6625243750Srwatson # Keep a list of preopened convenience libraries to check 6626243750Srwatson # that they are being used correctly in the link pass. 6627243750Srwatson test -z "$libdir" && \ 6628243750Srwatson func_append dlpreconveniencelibs " $dir/$old_library" 6629243750Srwatson # Otherwise, use the dlname, so that lt_dlopen finds it. 6630243750Srwatson elif test -n "$dlname"; then 6631243750Srwatson func_append newdlprefiles " $dir/$dlname" 6632243750Srwatson else 6633243750Srwatson func_append newdlprefiles " $dir/$linklib" 6634243750Srwatson fi 6635243750Srwatson ;; 6636243750Srwatson esac 6637156283Srwatson fi # $pass = dlpreopen 6638156283Srwatson 6639156283Srwatson if test -z "$libdir"; then 6640156283Srwatson # Link the convenience library 6641156283Srwatson if test "$linkmode" = lib; then 6642156283Srwatson deplibs="$dir/$old_library $deplibs" 6643156283Srwatson elif test "$linkmode,$pass" = "prog,link"; then 6644156283Srwatson compile_deplibs="$dir/$old_library $compile_deplibs" 6645156283Srwatson finalize_deplibs="$dir/$old_library $finalize_deplibs" 6646156283Srwatson else 6647156283Srwatson deplibs="$lib $deplibs" # used for prog,scan pass 6648156283Srwatson fi 6649156283Srwatson continue 6650156283Srwatson fi 6651156283Srwatson 6652156283Srwatson 6653156283Srwatson if test "$linkmode" = prog && test "$pass" != link; then 6654243750Srwatson func_append newlib_search_path " $ladir" 6655156283Srwatson deplibs="$lib $deplibs" 6656156283Srwatson 6657156283Srwatson linkalldeplibs=no 6658156283Srwatson if test "$link_all_deplibs" != no || test -z "$library_names" || 6659156283Srwatson test "$build_libtool_libs" = no; then 6660156283Srwatson linkalldeplibs=yes 6661156283Srwatson fi 6662156283Srwatson 6663156283Srwatson tmp_libs= 6664156283Srwatson for deplib in $dependency_libs; do 6665156283Srwatson case $deplib in 6666243750Srwatson -L*) func_stripname '-L' '' "$deplib" 6667243750Srwatson func_resolve_sysroot "$func_stripname_result" 6668243750Srwatson func_append newlib_search_path " $func_resolve_sysroot_result" 6669243750Srwatson ;; 6670156283Srwatson esac 6671156283Srwatson # Need to link against all dependency_libs? 6672156283Srwatson if test "$linkalldeplibs" = yes; then 6673156283Srwatson deplibs="$deplib $deplibs" 6674156283Srwatson else 6675156283Srwatson # Need to hardcode shared library paths 6676156283Srwatson # or/and link against static libraries 6677156283Srwatson newdependency_libs="$deplib $newdependency_libs" 6678156283Srwatson fi 6679243750Srwatson if $opt_preserve_dup_deps ; then 6680156283Srwatson case "$tmp_libs " in 6681243750Srwatson *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6682156283Srwatson esac 6683156283Srwatson fi 6684243750Srwatson func_append tmp_libs " $deplib" 6685156283Srwatson done # for deplib 6686156283Srwatson continue 6687156283Srwatson fi # $linkmode = prog... 6688156283Srwatson 6689156283Srwatson if test "$linkmode,$pass" = "prog,link"; then 6690156283Srwatson if test -n "$library_names" && 6691173143Srwatson { { test "$prefer_static_libs" = no || 6692243750Srwatson test "$prefer_static_libs,$installed" = "built,yes"; } || 6693173143Srwatson test -z "$old_library"; }; then 6694156283Srwatson # We need to hardcode the library path 6695156283Srwatson if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 6696156283Srwatson # Make sure the rpath contains only unique directories. 6697243750Srwatson case "$temp_rpath:" in 6698243750Srwatson *"$absdir:"*) ;; 6699243750Srwatson *) func_append temp_rpath "$absdir:" ;; 6700156283Srwatson esac 6701156283Srwatson fi 6702156283Srwatson 6703156283Srwatson # Hardcode the library path. 6704156283Srwatson # Skip directories that are in the system default run-time 6705156283Srwatson # search path. 6706156283Srwatson case " $sys_lib_dlsearch_path " in 6707156283Srwatson *" $absdir "*) ;; 6708156283Srwatson *) 6709156283Srwatson case "$compile_rpath " in 6710156283Srwatson *" $absdir "*) ;; 6711243750Srwatson *) func_append compile_rpath " $absdir" ;; 6712156283Srwatson esac 6713156283Srwatson ;; 6714156283Srwatson esac 6715156283Srwatson case " $sys_lib_dlsearch_path " in 6716156283Srwatson *" $libdir "*) ;; 6717156283Srwatson *) 6718156283Srwatson case "$finalize_rpath " in 6719156283Srwatson *" $libdir "*) ;; 6720243750Srwatson *) func_append finalize_rpath " $libdir" ;; 6721156283Srwatson esac 6722156283Srwatson ;; 6723156283Srwatson esac 6724156283Srwatson fi # $linkmode,$pass = prog,link... 6725156283Srwatson 6726156283Srwatson if test "$alldeplibs" = yes && 6727156283Srwatson { test "$deplibs_check_method" = pass_all || 6728156283Srwatson { test "$build_libtool_libs" = yes && 6729156283Srwatson test -n "$library_names"; }; }; then 6730156283Srwatson # We only need to search for static libraries 6731156283Srwatson continue 6732156283Srwatson fi 6733156283Srwatson fi 6734156283Srwatson 6735156283Srwatson link_static=no # Whether the deplib will be linked statically 6736159985Srwatson use_static_libs=$prefer_static_libs 6737243750Srwatson if test "$use_static_libs" = built && test "$installed" = yes; then 6738159985Srwatson use_static_libs=no 6739159985Srwatson fi 6740156283Srwatson if test -n "$library_names" && 6741159985Srwatson { test "$use_static_libs" = no || test -z "$old_library"; }; then 6742243750Srwatson case $host in 6743243750Srwatson *cygwin* | *mingw* | *cegcc*) 6744243750Srwatson # No point in relinking DLLs because paths are not encoded 6745243750Srwatson func_append notinst_deplibs " $lib" 6746243750Srwatson need_relink=no 6747243750Srwatson ;; 6748243750Srwatson *) 6749243750Srwatson if test "$installed" = no; then 6750243750Srwatson func_append notinst_deplibs " $lib" 6751243750Srwatson need_relink=yes 6752243750Srwatson fi 6753243750Srwatson ;; 6754243750Srwatson esac 6755156283Srwatson # This is a shared library 6756156283Srwatson 6757243750Srwatson # Warn about portability, can't link against -module's on some 6758243750Srwatson # systems (darwin). Don't bleat about dlopened modules though! 6759243750Srwatson dlopenmodule="" 6760243750Srwatson for dlpremoduletest in $dlprefiles; do 6761243750Srwatson if test "X$dlpremoduletest" = "X$lib"; then 6762243750Srwatson dlopenmodule="$dlpremoduletest" 6763243750Srwatson break 6764243750Srwatson fi 6765243750Srwatson done 6766243750Srwatson if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 6767243750Srwatson echo 6768156283Srwatson if test "$linkmode" = prog; then 6769243750Srwatson $ECHO "*** Warning: Linking the executable $output against the loadable module" 6770156283Srwatson else 6771243750Srwatson $ECHO "*** Warning: Linking the shared library $output against the loadable module" 6772156283Srwatson fi 6773243750Srwatson $ECHO "*** $linklib is not portable!" 6774156283Srwatson fi 6775156283Srwatson if test "$linkmode" = lib && 6776156283Srwatson test "$hardcode_into_libs" = yes; then 6777156283Srwatson # Hardcode the library path. 6778156283Srwatson # Skip directories that are in the system default run-time 6779156283Srwatson # search path. 6780156283Srwatson case " $sys_lib_dlsearch_path " in 6781156283Srwatson *" $absdir "*) ;; 6782156283Srwatson *) 6783156283Srwatson case "$compile_rpath " in 6784156283Srwatson *" $absdir "*) ;; 6785243750Srwatson *) func_append compile_rpath " $absdir" ;; 6786156283Srwatson esac 6787156283Srwatson ;; 6788156283Srwatson esac 6789156283Srwatson case " $sys_lib_dlsearch_path " in 6790156283Srwatson *" $libdir "*) ;; 6791156283Srwatson *) 6792156283Srwatson case "$finalize_rpath " in 6793156283Srwatson *" $libdir "*) ;; 6794243750Srwatson *) func_append finalize_rpath " $libdir" ;; 6795156283Srwatson esac 6796156283Srwatson ;; 6797156283Srwatson esac 6798156283Srwatson fi 6799156283Srwatson 6800156283Srwatson if test -n "$old_archive_from_expsyms_cmds"; then 6801156283Srwatson # figure out the soname 6802156283Srwatson set dummy $library_names 6803243750Srwatson shift 6804243750Srwatson realname="$1" 6805243750Srwatson shift 6806243750Srwatson libname=`eval "\\$ECHO \"$libname_spec\""` 6807156283Srwatson # use dlname if we got it. it's perfectly good, no? 6808156283Srwatson if test -n "$dlname"; then 6809156283Srwatson soname="$dlname" 6810156283Srwatson elif test -n "$soname_spec"; then 6811156283Srwatson # bleh windows 6812156283Srwatson case $host in 6813243750Srwatson *cygwin* | mingw* | *cegcc*) 6814243750Srwatson func_arith $current - $age 6815243750Srwatson major=$func_arith_result 6816156283Srwatson versuffix="-$major" 6817156283Srwatson ;; 6818156283Srwatson esac 6819156283Srwatson eval soname=\"$soname_spec\" 6820156283Srwatson else 6821156283Srwatson soname="$realname" 6822156283Srwatson fi 6823156283Srwatson 6824156283Srwatson # Make a new name for the extract_expsyms_cmds to use 6825156283Srwatson soroot="$soname" 6826243750Srwatson func_basename "$soroot" 6827243750Srwatson soname="$func_basename_result" 6828243750Srwatson func_stripname 'lib' '.dll' "$soname" 6829243750Srwatson newlib=libimp-$func_stripname_result.a 6830156283Srwatson 6831156283Srwatson # If the library has no export list, then create one now 6832156283Srwatson if test -f "$output_objdir/$soname-def"; then : 6833156283Srwatson else 6834243750Srwatson func_verbose "extracting exported symbol list from \`$soname'" 6835243750Srwatson func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 6836156283Srwatson fi 6837156283Srwatson 6838156283Srwatson # Create $newlib 6839156283Srwatson if test -f "$output_objdir/$newlib"; then :; else 6840243750Srwatson func_verbose "generating import library for \`$soname'" 6841243750Srwatson func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 6842156283Srwatson fi 6843156283Srwatson # make sure the library variables are pointing to the new library 6844156283Srwatson dir=$output_objdir 6845156283Srwatson linklib=$newlib 6846156283Srwatson fi # test -n "$old_archive_from_expsyms_cmds" 6847156283Srwatson 6848243750Srwatson if test "$linkmode" = prog || test "$opt_mode" != relink; then 6849156283Srwatson add_shlibpath= 6850156283Srwatson add_dir= 6851156283Srwatson add= 6852156283Srwatson lib_linked=yes 6853156283Srwatson case $hardcode_action in 6854156283Srwatson immediate | unsupported) 6855156283Srwatson if test "$hardcode_direct" = no; then 6856156283Srwatson add="$dir/$linklib" 6857156283Srwatson case $host in 6858159985Srwatson *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6859159985Srwatson *-*-sysv4*uw2*) add_dir="-L$dir" ;; 6860159985Srwatson *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6861159985Srwatson *-*-unixware7*) add_dir="-L$dir" ;; 6862156283Srwatson *-*-darwin* ) 6863243750Srwatson # if the lib is a (non-dlopened) module then we can not 6864243750Srwatson # link against it, someone is ignoring the earlier warnings 6865159985Srwatson if /usr/bin/file -L $add 2> /dev/null | 6866243750Srwatson $GREP ": [^:]* bundle" >/dev/null ; then 6867243750Srwatson if test "X$dlopenmodule" != "X$lib"; then 6868243750Srwatson $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6869243750Srwatson if test -z "$old_library" ; then 6870243750Srwatson echo 6871243750Srwatson echo "*** And there doesn't seem to be a static archive available" 6872243750Srwatson echo "*** The link will probably fail, sorry" 6873243750Srwatson else 6874243750Srwatson add="$dir/$old_library" 6875243750Srwatson fi 6876243750Srwatson elif test -n "$old_library"; then 6877243750Srwatson add="$dir/$old_library" 6878156283Srwatson fi 6879156283Srwatson fi 6880156283Srwatson esac 6881156283Srwatson elif test "$hardcode_minus_L" = no; then 6882156283Srwatson case $host in 6883156283Srwatson *-*-sunos*) add_shlibpath="$dir" ;; 6884156283Srwatson esac 6885156283Srwatson add_dir="-L$dir" 6886156283Srwatson add="-l$name" 6887156283Srwatson elif test "$hardcode_shlibpath_var" = no; then 6888156283Srwatson add_shlibpath="$dir" 6889156283Srwatson add="-l$name" 6890156283Srwatson else 6891156283Srwatson lib_linked=no 6892156283Srwatson fi 6893156283Srwatson ;; 6894156283Srwatson relink) 6895243750Srwatson if test "$hardcode_direct" = yes && 6896243750Srwatson test "$hardcode_direct_absolute" = no; then 6897156283Srwatson add="$dir/$linklib" 6898156283Srwatson elif test "$hardcode_minus_L" = yes; then 6899243750Srwatson add_dir="-L$absdir" 6900156283Srwatson # Try looking first in the location we're being installed to. 6901156283Srwatson if test -n "$inst_prefix_dir"; then 6902156283Srwatson case $libdir in 6903156283Srwatson [\\/]*) 6904243750Srwatson func_append add_dir " -L$inst_prefix_dir$libdir" 6905156283Srwatson ;; 6906156283Srwatson esac 6907156283Srwatson fi 6908156283Srwatson add="-l$name" 6909156283Srwatson elif test "$hardcode_shlibpath_var" = yes; then 6910156283Srwatson add_shlibpath="$dir" 6911156283Srwatson add="-l$name" 6912156283Srwatson else 6913156283Srwatson lib_linked=no 6914156283Srwatson fi 6915156283Srwatson ;; 6916156283Srwatson *) lib_linked=no ;; 6917156283Srwatson esac 6918156283Srwatson 6919156283Srwatson if test "$lib_linked" != yes; then 6920243750Srwatson func_fatal_configuration "unsupported hardcode properties" 6921156283Srwatson fi 6922156283Srwatson 6923156283Srwatson if test -n "$add_shlibpath"; then 6924156283Srwatson case :$compile_shlibpath: in 6925156283Srwatson *":$add_shlibpath:"*) ;; 6926243750Srwatson *) func_append compile_shlibpath "$add_shlibpath:" ;; 6927156283Srwatson esac 6928156283Srwatson fi 6929156283Srwatson if test "$linkmode" = prog; then 6930156283Srwatson test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 6931156283Srwatson test -n "$add" && compile_deplibs="$add $compile_deplibs" 6932156283Srwatson else 6933156283Srwatson test -n "$add_dir" && deplibs="$add_dir $deplibs" 6934156283Srwatson test -n "$add" && deplibs="$add $deplibs" 6935243750Srwatson if test "$hardcode_direct" != yes && 6936243750Srwatson test "$hardcode_minus_L" != yes && 6937156283Srwatson test "$hardcode_shlibpath_var" = yes; then 6938156283Srwatson case :$finalize_shlibpath: in 6939156283Srwatson *":$libdir:"*) ;; 6940243750Srwatson *) func_append finalize_shlibpath "$libdir:" ;; 6941156283Srwatson esac 6942156283Srwatson fi 6943156283Srwatson fi 6944156283Srwatson fi 6945156283Srwatson 6946243750Srwatson if test "$linkmode" = prog || test "$opt_mode" = relink; then 6947156283Srwatson add_shlibpath= 6948156283Srwatson add_dir= 6949156283Srwatson add= 6950156283Srwatson # Finalize command for both is simple: just hardcode it. 6951243750Srwatson if test "$hardcode_direct" = yes && 6952243750Srwatson test "$hardcode_direct_absolute" = no; then 6953156283Srwatson add="$libdir/$linklib" 6954156283Srwatson elif test "$hardcode_minus_L" = yes; then 6955156283Srwatson add_dir="-L$libdir" 6956156283Srwatson add="-l$name" 6957156283Srwatson elif test "$hardcode_shlibpath_var" = yes; then 6958156283Srwatson case :$finalize_shlibpath: in 6959156283Srwatson *":$libdir:"*) ;; 6960243750Srwatson *) func_append finalize_shlibpath "$libdir:" ;; 6961156283Srwatson esac 6962156283Srwatson add="-l$name" 6963156283Srwatson elif test "$hardcode_automatic" = yes; then 6964156283Srwatson if test -n "$inst_prefix_dir" && 6965156283Srwatson test -f "$inst_prefix_dir$libdir/$linklib" ; then 6966243750Srwatson add="$inst_prefix_dir$libdir/$linklib" 6967156283Srwatson else 6968243750Srwatson add="$libdir/$linklib" 6969156283Srwatson fi 6970156283Srwatson else 6971156283Srwatson # We cannot seem to hardcode it, guess we'll fake it. 6972156283Srwatson add_dir="-L$libdir" 6973156283Srwatson # Try looking first in the location we're being installed to. 6974156283Srwatson if test -n "$inst_prefix_dir"; then 6975156283Srwatson case $libdir in 6976156283Srwatson [\\/]*) 6977243750Srwatson func_append add_dir " -L$inst_prefix_dir$libdir" 6978156283Srwatson ;; 6979156283Srwatson esac 6980156283Srwatson fi 6981156283Srwatson add="-l$name" 6982156283Srwatson fi 6983156283Srwatson 6984156283Srwatson if test "$linkmode" = prog; then 6985156283Srwatson test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 6986156283Srwatson test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 6987156283Srwatson else 6988156283Srwatson test -n "$add_dir" && deplibs="$add_dir $deplibs" 6989156283Srwatson test -n "$add" && deplibs="$add $deplibs" 6990156283Srwatson fi 6991156283Srwatson fi 6992156283Srwatson elif test "$linkmode" = prog; then 6993156283Srwatson # Here we assume that one of hardcode_direct or hardcode_minus_L 6994156283Srwatson # is not unsupported. This is valid on all known static and 6995156283Srwatson # shared platforms. 6996156283Srwatson if test "$hardcode_direct" != unsupported; then 6997156283Srwatson test -n "$old_library" && linklib="$old_library" 6998156283Srwatson compile_deplibs="$dir/$linklib $compile_deplibs" 6999156283Srwatson finalize_deplibs="$dir/$linklib $finalize_deplibs" 7000156283Srwatson else 7001156283Srwatson compile_deplibs="-l$name -L$dir $compile_deplibs" 7002156283Srwatson finalize_deplibs="-l$name -L$dir $finalize_deplibs" 7003156283Srwatson fi 7004156283Srwatson elif test "$build_libtool_libs" = yes; then 7005156283Srwatson # Not a shared library 7006156283Srwatson if test "$deplibs_check_method" != pass_all; then 7007156283Srwatson # We're trying link a shared library against a static one 7008156283Srwatson # but the system doesn't support it. 7009156283Srwatson 7010156283Srwatson # Just print a warning and add the library to dependency_libs so 7011156283Srwatson # that the program can be linked against the static library. 7012243750Srwatson echo 7013243750Srwatson $ECHO "*** Warning: This system can not link to static lib archive $lib." 7014243750Srwatson echo "*** I have the capability to make that library automatically link in when" 7015243750Srwatson echo "*** you link to this library. But I can only do this if you have a" 7016243750Srwatson echo "*** shared version of the library, which you do not appear to have." 7017156283Srwatson if test "$module" = yes; then 7018243750Srwatson echo "*** But as you try to build a module library, libtool will still create " 7019243750Srwatson echo "*** a static module, that should work as long as the dlopening application" 7020243750Srwatson echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 7021156283Srwatson if test -z "$global_symbol_pipe"; then 7022243750Srwatson echo 7023243750Srwatson echo "*** However, this would only work if libtool was able to extract symbol" 7024243750Srwatson echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 7025243750Srwatson echo "*** not find such a program. So, this module is probably useless." 7026243750Srwatson echo "*** \`nm' from GNU binutils and a full rebuild may help." 7027156283Srwatson fi 7028156283Srwatson if test "$build_old_libs" = no; then 7029156283Srwatson build_libtool_libs=module 7030156283Srwatson build_old_libs=yes 7031156283Srwatson else 7032156283Srwatson build_libtool_libs=no 7033156283Srwatson fi 7034156283Srwatson fi 7035156283Srwatson else 7036156283Srwatson deplibs="$dir/$old_library $deplibs" 7037156283Srwatson link_static=yes 7038156283Srwatson fi 7039156283Srwatson fi # link shared/static library? 7040156283Srwatson 7041156283Srwatson if test "$linkmode" = lib; then 7042156283Srwatson if test -n "$dependency_libs" && 7043156283Srwatson { test "$hardcode_into_libs" != yes || 7044156283Srwatson test "$build_old_libs" = yes || 7045156283Srwatson test "$link_static" = yes; }; then 7046156283Srwatson # Extract -R from dependency_libs 7047156283Srwatson temp_deplibs= 7048156283Srwatson for libdir in $dependency_libs; do 7049156283Srwatson case $libdir in 7050243750Srwatson -R*) func_stripname '-R' '' "$libdir" 7051243750Srwatson temp_xrpath=$func_stripname_result 7052156283Srwatson case " $xrpath " in 7053156283Srwatson *" $temp_xrpath "*) ;; 7054243750Srwatson *) func_append xrpath " $temp_xrpath";; 7055156283Srwatson esac;; 7056243750Srwatson *) func_append temp_deplibs " $libdir";; 7057156283Srwatson esac 7058156283Srwatson done 7059156283Srwatson dependency_libs="$temp_deplibs" 7060156283Srwatson fi 7061156283Srwatson 7062243750Srwatson func_append newlib_search_path " $absdir" 7063156283Srwatson # Link against this library 7064156283Srwatson test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 7065156283Srwatson # ... and its dependency_libs 7066156283Srwatson tmp_libs= 7067156283Srwatson for deplib in $dependency_libs; do 7068156283Srwatson newdependency_libs="$deplib $newdependency_libs" 7069243750Srwatson case $deplib in 7070243750Srwatson -L*) func_stripname '-L' '' "$deplib" 7071243750Srwatson func_resolve_sysroot "$func_stripname_result";; 7072243750Srwatson *) func_resolve_sysroot "$deplib" ;; 7073243750Srwatson esac 7074243750Srwatson if $opt_preserve_dup_deps ; then 7075156283Srwatson case "$tmp_libs " in 7076243750Srwatson *" $func_resolve_sysroot_result "*) 7077243750Srwatson func_append specialdeplibs " $func_resolve_sysroot_result" ;; 7078156283Srwatson esac 7079156283Srwatson fi 7080243750Srwatson func_append tmp_libs " $func_resolve_sysroot_result" 7081156283Srwatson done 7082156283Srwatson 7083156283Srwatson if test "$link_all_deplibs" != no; then 7084156283Srwatson # Add the search paths of all dependency libraries 7085156283Srwatson for deplib in $dependency_libs; do 7086243750Srwatson path= 7087156283Srwatson case $deplib in 7088156283Srwatson -L*) path="$deplib" ;; 7089156283Srwatson *.la) 7090243750Srwatson func_resolve_sysroot "$deplib" 7091243750Srwatson deplib=$func_resolve_sysroot_result 7092243750Srwatson func_dirname "$deplib" "" "." 7093243750Srwatson dir=$func_dirname_result 7094156283Srwatson # We need an absolute path. 7095156283Srwatson case $dir in 7096156283Srwatson [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 7097156283Srwatson *) 7098156283Srwatson absdir=`cd "$dir" && pwd` 7099156283Srwatson if test -z "$absdir"; then 7100243750Srwatson func_warning "cannot determine absolute directory name of \`$dir'" 7101156283Srwatson absdir="$dir" 7102156283Srwatson fi 7103156283Srwatson ;; 7104156283Srwatson esac 7105243750Srwatson if $GREP "^installed=no" $deplib > /dev/null; then 7106156283Srwatson case $host in 7107156283Srwatson *-*-darwin*) 7108243750Srwatson depdepl= 7109156283Srwatson eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 7110156283Srwatson if test -n "$deplibrary_names" ; then 7111156283Srwatson for tmp in $deplibrary_names ; do 7112156283Srwatson depdepl=$tmp 7113156283Srwatson done 7114243750Srwatson if test -f "$absdir/$objdir/$depdepl" ; then 7115243750Srwatson depdepl="$absdir/$objdir/$depdepl" 7116243750Srwatson darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7117243750Srwatson if test -z "$darwin_install_name"; then 7118243750Srwatson darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7119243750Srwatson fi 7120243750Srwatson func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 7121243750Srwatson func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 7122243750Srwatson path= 7123156283Srwatson fi 7124156283Srwatson fi 7125156283Srwatson ;; 7126156283Srwatson *) 7127243750Srwatson path="-L$absdir/$objdir" 7128156283Srwatson ;; 7129156283Srwatson esac 7130243750Srwatson else 7131243750Srwatson eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 7132243750Srwatson test -z "$libdir" && \ 7133243750Srwatson func_fatal_error "\`$deplib' is not a valid libtool archive" 7134243750Srwatson test "$absdir" != "$libdir" && \ 7135243750Srwatson func_warning "\`$deplib' seems to be moved" 7136243750Srwatson 7137243750Srwatson path="-L$absdir" 7138243750Srwatson fi 7139156283Srwatson ;; 7140156283Srwatson esac 7141156283Srwatson case " $deplibs " in 7142156283Srwatson *" $path "*) ;; 7143156283Srwatson *) deplibs="$path $deplibs" ;; 7144156283Srwatson esac 7145156283Srwatson done 7146156283Srwatson fi # link_all_deplibs != no 7147156283Srwatson fi # linkmode = lib 7148156283Srwatson done # for deplib in $libs 7149243750Srwatson if test "$pass" = link; then 7150243750Srwatson if test "$linkmode" = "prog"; then 7151243750Srwatson compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 7152243750Srwatson finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 7153243750Srwatson else 7154243750Srwatson compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7155243750Srwatson fi 7156243750Srwatson fi 7157156283Srwatson dependency_libs="$newdependency_libs" 7158156283Srwatson if test "$pass" = dlpreopen; then 7159156283Srwatson # Link the dlpreopened libraries before other libraries 7160156283Srwatson for deplib in $save_deplibs; do 7161156283Srwatson deplibs="$deplib $deplibs" 7162156283Srwatson done 7163156283Srwatson fi 7164156283Srwatson if test "$pass" != dlopen; then 7165156283Srwatson if test "$pass" != conv; then 7166156283Srwatson # Make sure lib_search_path contains only unique directories. 7167156283Srwatson lib_search_path= 7168156283Srwatson for dir in $newlib_search_path; do 7169156283Srwatson case "$lib_search_path " in 7170156283Srwatson *" $dir "*) ;; 7171243750Srwatson *) func_append lib_search_path " $dir" ;; 7172156283Srwatson esac 7173156283Srwatson done 7174156283Srwatson newlib_search_path= 7175156283Srwatson fi 7176156283Srwatson 7177156283Srwatson if test "$linkmode,$pass" != "prog,link"; then 7178156283Srwatson vars="deplibs" 7179156283Srwatson else 7180156283Srwatson vars="compile_deplibs finalize_deplibs" 7181156283Srwatson fi 7182156283Srwatson for var in $vars dependency_libs; do 7183156283Srwatson # Add libraries to $var in reverse order 7184156283Srwatson eval tmp_libs=\"\$$var\" 7185156283Srwatson new_libs= 7186156283Srwatson for deplib in $tmp_libs; do 7187156283Srwatson # FIXME: Pedantically, this is the right thing to do, so 7188156283Srwatson # that some nasty dependency loop isn't accidentally 7189156283Srwatson # broken: 7190156283Srwatson #new_libs="$deplib $new_libs" 7191156283Srwatson # Pragmatically, this seems to cause very few problems in 7192156283Srwatson # practice: 7193156283Srwatson case $deplib in 7194156283Srwatson -L*) new_libs="$deplib $new_libs" ;; 7195156283Srwatson -R*) ;; 7196156283Srwatson *) 7197156283Srwatson # And here is the reason: when a library appears more 7198156283Srwatson # than once as an explicit dependence of a library, or 7199156283Srwatson # is implicitly linked in more than once by the 7200156283Srwatson # compiler, it is considered special, and multiple 7201156283Srwatson # occurrences thereof are not removed. Compare this 7202156283Srwatson # with having the same library being listed as a 7203156283Srwatson # dependency of multiple other libraries: in this case, 7204156283Srwatson # we know (pedantically, we assume) the library does not 7205156283Srwatson # need to be listed more than once, so we keep only the 7206156283Srwatson # last copy. This is not always right, but it is rare 7207156283Srwatson # enough that we require users that really mean to play 7208156283Srwatson # such unportable linking tricks to link the library 7209156283Srwatson # using -Wl,-lname, so that libtool does not consider it 7210156283Srwatson # for duplicate removal. 7211156283Srwatson case " $specialdeplibs " in 7212156283Srwatson *" $deplib "*) new_libs="$deplib $new_libs" ;; 7213156283Srwatson *) 7214156283Srwatson case " $new_libs " in 7215156283Srwatson *" $deplib "*) ;; 7216156283Srwatson *) new_libs="$deplib $new_libs" ;; 7217156283Srwatson esac 7218156283Srwatson ;; 7219156283Srwatson esac 7220156283Srwatson ;; 7221156283Srwatson esac 7222156283Srwatson done 7223156283Srwatson tmp_libs= 7224156283Srwatson for deplib in $new_libs; do 7225156283Srwatson case $deplib in 7226156283Srwatson -L*) 7227156283Srwatson case " $tmp_libs " in 7228156283Srwatson *" $deplib "*) ;; 7229243750Srwatson *) func_append tmp_libs " $deplib" ;; 7230156283Srwatson esac 7231156283Srwatson ;; 7232243750Srwatson *) func_append tmp_libs " $deplib" ;; 7233156283Srwatson esac 7234156283Srwatson done 7235156283Srwatson eval $var=\"$tmp_libs\" 7236156283Srwatson done # for var 7237156283Srwatson fi 7238156283Srwatson # Last step: remove runtime libs from dependency_libs 7239156283Srwatson # (they stay in deplibs) 7240156283Srwatson tmp_libs= 7241156283Srwatson for i in $dependency_libs ; do 7242156283Srwatson case " $predeps $postdeps $compiler_lib_search_path " in 7243156283Srwatson *" $i "*) 7244156283Srwatson i="" 7245156283Srwatson ;; 7246156283Srwatson esac 7247156283Srwatson if test -n "$i" ; then 7248243750Srwatson func_append tmp_libs " $i" 7249156283Srwatson fi 7250156283Srwatson done 7251156283Srwatson dependency_libs=$tmp_libs 7252156283Srwatson done # for pass 7253156283Srwatson if test "$linkmode" = prog; then 7254156283Srwatson dlfiles="$newdlfiles" 7255243750Srwatson fi 7256243750Srwatson if test "$linkmode" = prog || test "$linkmode" = lib; then 7257156283Srwatson dlprefiles="$newdlprefiles" 7258156283Srwatson fi 7259156283Srwatson 7260156283Srwatson case $linkmode in 7261156283Srwatson oldlib) 7262243750Srwatson if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7263243750Srwatson func_warning "\`-dlopen' is ignored for archives" 7264243750Srwatson fi 7265243750Srwatson 7266191273Srwatson case " $deplibs" in 7267191273Srwatson *\ -l* | *\ -L*) 7268243750Srwatson func_warning "\`-l' and \`-L' are ignored for archives" ;; 7269191273Srwatson esac 7270156283Srwatson 7271243750Srwatson test -n "$rpath" && \ 7272243750Srwatson func_warning "\`-rpath' is ignored for archives" 7273156283Srwatson 7274243750Srwatson test -n "$xrpath" && \ 7275243750Srwatson func_warning "\`-R' is ignored for archives" 7276156283Srwatson 7277243750Srwatson test -n "$vinfo" && \ 7278243750Srwatson func_warning "\`-version-info/-version-number' is ignored for archives" 7279156283Srwatson 7280243750Srwatson test -n "$release" && \ 7281243750Srwatson func_warning "\`-release' is ignored for archives" 7282156283Srwatson 7283243750Srwatson test -n "$export_symbols$export_symbols_regex" && \ 7284243750Srwatson func_warning "\`-export-symbols' is ignored for archives" 7285156283Srwatson 7286156283Srwatson # Now set the variables for building old libraries. 7287156283Srwatson build_libtool_libs=no 7288156283Srwatson oldlibs="$output" 7289243750Srwatson func_append objs "$old_deplibs" 7290156283Srwatson ;; 7291156283Srwatson 7292156283Srwatson lib) 7293156283Srwatson # Make sure we only generate libraries of the form `libNAME.la'. 7294156283Srwatson case $outputname in 7295156283Srwatson lib*) 7296243750Srwatson func_stripname 'lib' '.la' "$outputname" 7297243750Srwatson name=$func_stripname_result 7298156283Srwatson eval shared_ext=\"$shrext_cmds\" 7299156283Srwatson eval libname=\"$libname_spec\" 7300156283Srwatson ;; 7301156283Srwatson *) 7302243750Srwatson test "$module" = no && \ 7303243750Srwatson func_fatal_help "libtool library \`$output' must begin with \`lib'" 7304243750Srwatson 7305156283Srwatson if test "$need_lib_prefix" != no; then 7306156283Srwatson # Add the "lib" prefix for modules if required 7307243750Srwatson func_stripname '' '.la' "$outputname" 7308243750Srwatson name=$func_stripname_result 7309156283Srwatson eval shared_ext=\"$shrext_cmds\" 7310156283Srwatson eval libname=\"$libname_spec\" 7311156283Srwatson else 7312243750Srwatson func_stripname '' '.la' "$outputname" 7313243750Srwatson libname=$func_stripname_result 7314156283Srwatson fi 7315156283Srwatson ;; 7316156283Srwatson esac 7317156283Srwatson 7318156283Srwatson if test -n "$objs"; then 7319156283Srwatson if test "$deplibs_check_method" != pass_all; then 7320243750Srwatson func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 7321156283Srwatson else 7322243750Srwatson echo 7323243750Srwatson $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 7324243750Srwatson $ECHO "*** objects $objs is not portable!" 7325243750Srwatson func_append libobjs " $objs" 7326156283Srwatson fi 7327156283Srwatson fi 7328156283Srwatson 7329243750Srwatson test "$dlself" != no && \ 7330243750Srwatson func_warning "\`-dlopen self' is ignored for libtool libraries" 7331156283Srwatson 7332156283Srwatson set dummy $rpath 7333243750Srwatson shift 7334243750Srwatson test "$#" -gt 1 && \ 7335243750Srwatson func_warning "ignoring multiple \`-rpath's for a libtool library" 7336156283Srwatson 7337243750Srwatson install_libdir="$1" 7338243750Srwatson 7339156283Srwatson oldlibs= 7340156283Srwatson if test -z "$rpath"; then 7341156283Srwatson if test "$build_libtool_libs" = yes; then 7342156283Srwatson # Building a libtool convenience library. 7343156283Srwatson # Some compilers have problems with a `.al' extension so 7344156283Srwatson # convenience libraries should have the same extension an 7345156283Srwatson # archive normally would. 7346156283Srwatson oldlibs="$output_objdir/$libname.$libext $oldlibs" 7347156283Srwatson build_libtool_libs=convenience 7348156283Srwatson build_old_libs=yes 7349156283Srwatson fi 7350156283Srwatson 7351243750Srwatson test -n "$vinfo" && \ 7352243750Srwatson func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 7353156283Srwatson 7354243750Srwatson test -n "$release" && \ 7355243750Srwatson func_warning "\`-release' is ignored for convenience libraries" 7356156283Srwatson else 7357156283Srwatson 7358156283Srwatson # Parse the version information argument. 7359156283Srwatson save_ifs="$IFS"; IFS=':' 7360156283Srwatson set dummy $vinfo 0 0 0 7361243750Srwatson shift 7362156283Srwatson IFS="$save_ifs" 7363156283Srwatson 7364243750Srwatson test -n "$7" && \ 7365243750Srwatson func_fatal_help "too many parameters to \`-version-info'" 7366156283Srwatson 7367156283Srwatson # convert absolute version numbers to libtool ages 7368156283Srwatson # this retains compatibility with .la files and attempts 7369156283Srwatson # to make the code below a bit more comprehensible 7370156283Srwatson 7371156283Srwatson case $vinfo_number in 7372156283Srwatson yes) 7373243750Srwatson number_major="$1" 7374243750Srwatson number_minor="$2" 7375243750Srwatson number_revision="$3" 7376156283Srwatson # 7377156283Srwatson # There are really only two kinds -- those that 7378156283Srwatson # use the current revision as the major version 7379156283Srwatson # and those that subtract age and use age as 7380156283Srwatson # a minor version. But, then there is irix 7381156283Srwatson # which has an extra 1 added just for fun 7382156283Srwatson # 7383156283Srwatson case $version_type in 7384243750Srwatson # correct linux to gnu/linux during the next big refactor 7385173143Srwatson darwin|linux|osf|windows|none) 7386243750Srwatson func_arith $number_major + $number_minor 7387243750Srwatson current=$func_arith_result 7388156283Srwatson age="$number_minor" 7389156283Srwatson revision="$number_revision" 7390156283Srwatson ;; 7391243750Srwatson freebsd-aout|freebsd-elf|qnx|sunos) 7392156283Srwatson current="$number_major" 7393156283Srwatson revision="$number_minor" 7394156283Srwatson age="0" 7395156283Srwatson ;; 7396156283Srwatson irix|nonstopux) 7397243750Srwatson func_arith $number_major + $number_minor 7398243750Srwatson current=$func_arith_result 7399156283Srwatson age="$number_minor" 7400156283Srwatson revision="$number_minor" 7401173143Srwatson lt_irix_increment=no 7402156283Srwatson ;; 7403156283Srwatson esac 7404156283Srwatson ;; 7405156283Srwatson no) 7406243750Srwatson current="$1" 7407243750Srwatson revision="$2" 7408243750Srwatson age="$3" 7409156283Srwatson ;; 7410156283Srwatson esac 7411156283Srwatson 7412156283Srwatson # Check that each of the things are valid numbers. 7413156283Srwatson case $current in 7414156283Srwatson 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]) ;; 7415156283Srwatson *) 7416243750Srwatson func_error "CURRENT \`$current' must be a nonnegative integer" 7417243750Srwatson func_fatal_error "\`$vinfo' is not valid version information" 7418156283Srwatson ;; 7419156283Srwatson esac 7420156283Srwatson 7421156283Srwatson case $revision in 7422156283Srwatson 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]) ;; 7423156283Srwatson *) 7424243750Srwatson func_error "REVISION \`$revision' must be a nonnegative integer" 7425243750Srwatson func_fatal_error "\`$vinfo' is not valid version information" 7426156283Srwatson ;; 7427156283Srwatson esac 7428156283Srwatson 7429156283Srwatson case $age in 7430156283Srwatson 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]) ;; 7431156283Srwatson *) 7432243750Srwatson func_error "AGE \`$age' must be a nonnegative integer" 7433243750Srwatson func_fatal_error "\`$vinfo' is not valid version information" 7434156283Srwatson ;; 7435156283Srwatson esac 7436156283Srwatson 7437156283Srwatson if test "$age" -gt "$current"; then 7438243750Srwatson func_error "AGE \`$age' is greater than the current interface number \`$current'" 7439243750Srwatson func_fatal_error "\`$vinfo' is not valid version information" 7440156283Srwatson fi 7441156283Srwatson 7442156283Srwatson # Calculate the version variables. 7443156283Srwatson major= 7444156283Srwatson versuffix= 7445156283Srwatson verstring= 7446156283Srwatson case $version_type in 7447156283Srwatson none) ;; 7448156283Srwatson 7449156283Srwatson darwin) 7450156283Srwatson # Like Linux, but with the current version available in 7451156283Srwatson # verstring for coding it into the library header 7452243750Srwatson func_arith $current - $age 7453243750Srwatson major=.$func_arith_result 7454156283Srwatson versuffix="$major.$age.$revision" 7455156283Srwatson # Darwin ld doesn't like 0 for these options... 7456243750Srwatson func_arith $current + 1 7457243750Srwatson minor_current=$func_arith_result 7458173143Srwatson xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 7459173143Srwatson verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 7460156283Srwatson ;; 7461156283Srwatson 7462156283Srwatson freebsd-aout) 7463156283Srwatson major=".$current" 7464156283Srwatson versuffix=".$current.$revision"; 7465156283Srwatson ;; 7466156283Srwatson 7467156283Srwatson freebsd-elf) 7468156283Srwatson major=".$current" 7469243750Srwatson versuffix=".$current" 7470156283Srwatson ;; 7471156283Srwatson 7472156283Srwatson irix | nonstopux) 7473173143Srwatson if test "X$lt_irix_increment" = "Xno"; then 7474243750Srwatson func_arith $current - $age 7475173143Srwatson else 7476243750Srwatson func_arith $current - $age + 1 7477173143Srwatson fi 7478243750Srwatson major=$func_arith_result 7479243750Srwatson 7480156283Srwatson case $version_type in 7481156283Srwatson nonstopux) verstring_prefix=nonstopux ;; 7482156283Srwatson *) verstring_prefix=sgi ;; 7483156283Srwatson esac 7484156283Srwatson verstring="$verstring_prefix$major.$revision" 7485156283Srwatson 7486156283Srwatson # Add in all the interfaces that we are compatible with. 7487156283Srwatson loop=$revision 7488156283Srwatson while test "$loop" -ne 0; do 7489243750Srwatson func_arith $revision - $loop 7490243750Srwatson iface=$func_arith_result 7491243750Srwatson func_arith $loop - 1 7492243750Srwatson loop=$func_arith_result 7493156283Srwatson verstring="$verstring_prefix$major.$iface:$verstring" 7494156283Srwatson done 7495156283Srwatson 7496156283Srwatson # Before this point, $major must not contain `.'. 7497156283Srwatson major=.$major 7498156283Srwatson versuffix="$major.$revision" 7499156283Srwatson ;; 7500156283Srwatson 7501243750Srwatson linux) # correct to gnu/linux during the next big refactor 7502243750Srwatson func_arith $current - $age 7503243750Srwatson major=.$func_arith_result 7504156283Srwatson versuffix="$major.$age.$revision" 7505156283Srwatson ;; 7506156283Srwatson 7507156283Srwatson osf) 7508243750Srwatson func_arith $current - $age 7509243750Srwatson major=.$func_arith_result 7510156283Srwatson versuffix=".$current.$age.$revision" 7511156283Srwatson verstring="$current.$age.$revision" 7512156283Srwatson 7513156283Srwatson # Add in all the interfaces that we are compatible with. 7514156283Srwatson loop=$age 7515156283Srwatson while test "$loop" -ne 0; do 7516243750Srwatson func_arith $current - $loop 7517243750Srwatson iface=$func_arith_result 7518243750Srwatson func_arith $loop - 1 7519243750Srwatson loop=$func_arith_result 7520156283Srwatson verstring="$verstring:${iface}.0" 7521156283Srwatson done 7522156283Srwatson 7523156283Srwatson # Make executables depend on our current version. 7524243750Srwatson func_append verstring ":${current}.0" 7525156283Srwatson ;; 7526156283Srwatson 7527243750Srwatson qnx) 7528243750Srwatson major=".$current" 7529243750Srwatson versuffix=".$current" 7530243750Srwatson ;; 7531243750Srwatson 7532156283Srwatson sunos) 7533156283Srwatson major=".$current" 7534156283Srwatson versuffix=".$current.$revision" 7535156283Srwatson ;; 7536156283Srwatson 7537156283Srwatson windows) 7538156283Srwatson # Use '-' rather than '.', since we only want one 7539156283Srwatson # extension on DOS 8.3 filesystems. 7540243750Srwatson func_arith $current - $age 7541243750Srwatson major=$func_arith_result 7542156283Srwatson versuffix="-$major" 7543156283Srwatson ;; 7544156283Srwatson 7545156283Srwatson *) 7546243750Srwatson func_fatal_configuration "unknown library version type \`$version_type'" 7547156283Srwatson ;; 7548156283Srwatson esac 7549156283Srwatson 7550156283Srwatson # Clear the version info if we defaulted, and they specified a release. 7551156283Srwatson if test -z "$vinfo" && test -n "$release"; then 7552156283Srwatson major= 7553156283Srwatson case $version_type in 7554156283Srwatson darwin) 7555156283Srwatson # we can't check for "0.0" in archive_cmds due to quoting 7556156283Srwatson # problems, so we reset it completely 7557156283Srwatson verstring= 7558156283Srwatson ;; 7559156283Srwatson *) 7560156283Srwatson verstring="0.0" 7561156283Srwatson ;; 7562156283Srwatson esac 7563156283Srwatson if test "$need_version" = no; then 7564156283Srwatson versuffix= 7565156283Srwatson else 7566156283Srwatson versuffix=".0.0" 7567156283Srwatson fi 7568156283Srwatson fi 7569156283Srwatson 7570156283Srwatson # Remove version info from name if versioning should be avoided 7571156283Srwatson if test "$avoid_version" = yes && test "$need_version" = no; then 7572156283Srwatson major= 7573156283Srwatson versuffix= 7574156283Srwatson verstring="" 7575156283Srwatson fi 7576156283Srwatson 7577156283Srwatson # Check to see if the archive will have undefined symbols. 7578156283Srwatson if test "$allow_undefined" = yes; then 7579156283Srwatson if test "$allow_undefined_flag" = unsupported; then 7580243750Srwatson func_warning "undefined symbols not allowed in $host shared libraries" 7581156283Srwatson build_libtool_libs=no 7582156283Srwatson build_old_libs=yes 7583156283Srwatson fi 7584156283Srwatson else 7585156283Srwatson # Don't allow undefined symbols. 7586156283Srwatson allow_undefined_flag="$no_undefined_flag" 7587156283Srwatson fi 7588243750Srwatson 7589156283Srwatson fi 7590156283Srwatson 7591243750Srwatson func_generate_dlsyms "$libname" "$libname" "yes" 7592243750Srwatson func_append libobjs " $symfileobj" 7593243750Srwatson test "X$libobjs" = "X " && libobjs= 7594243750Srwatson 7595243750Srwatson if test "$opt_mode" != relink; then 7596156283Srwatson # Remove our outputs, but don't remove object files since they 7597156283Srwatson # may have been created when compiling PIC objects. 7598156283Srwatson removelist= 7599243750Srwatson tempremovelist=`$ECHO "$output_objdir/*"` 7600156283Srwatson for p in $tempremovelist; do 7601156283Srwatson case $p in 7602243750Srwatson *.$objext | *.gcno) 7603156283Srwatson ;; 7604156283Srwatson $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 7605156283Srwatson if test "X$precious_files_regex" != "X"; then 7606243750Srwatson if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 7607243750Srwatson then 7608156283Srwatson continue 7609156283Srwatson fi 7610156283Srwatson fi 7611243750Srwatson func_append removelist " $p" 7612156283Srwatson ;; 7613156283Srwatson *) ;; 7614156283Srwatson esac 7615156283Srwatson done 7616243750Srwatson test -n "$removelist" && \ 7617243750Srwatson func_show_eval "${RM}r \$removelist" 7618156283Srwatson fi 7619156283Srwatson 7620156283Srwatson # Now set the variables for building old libraries. 7621156283Srwatson if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 7622243750Srwatson func_append oldlibs " $output_objdir/$libname.$libext" 7623156283Srwatson 7624156283Srwatson # Transform .lo files to .o files. 7625243750Srwatson oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 7626156283Srwatson fi 7627156283Srwatson 7628156283Srwatson # Eliminate all temporary directories. 7629173143Srwatson #for path in $notinst_path; do 7630243750Srwatson # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 7631243750Srwatson # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 7632243750Srwatson # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 7633173143Srwatson #done 7634156283Srwatson 7635156283Srwatson if test -n "$xrpath"; then 7636156283Srwatson # If the user specified any rpath flags, then add them. 7637156283Srwatson temp_xrpath= 7638156283Srwatson for libdir in $xrpath; do 7639243750Srwatson func_replace_sysroot "$libdir" 7640243750Srwatson func_append temp_xrpath " -R$func_replace_sysroot_result" 7641156283Srwatson case "$finalize_rpath " in 7642156283Srwatson *" $libdir "*) ;; 7643243750Srwatson *) func_append finalize_rpath " $libdir" ;; 7644156283Srwatson esac 7645156283Srwatson done 7646156283Srwatson if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 7647156283Srwatson dependency_libs="$temp_xrpath $dependency_libs" 7648156283Srwatson fi 7649156283Srwatson fi 7650156283Srwatson 7651156283Srwatson # Make sure dlfiles contains only unique files that won't be dlpreopened 7652156283Srwatson old_dlfiles="$dlfiles" 7653156283Srwatson dlfiles= 7654156283Srwatson for lib in $old_dlfiles; do 7655156283Srwatson case " $dlprefiles $dlfiles " in 7656156283Srwatson *" $lib "*) ;; 7657243750Srwatson *) func_append dlfiles " $lib" ;; 7658156283Srwatson esac 7659156283Srwatson done 7660156283Srwatson 7661156283Srwatson # Make sure dlprefiles contains only unique files 7662156283Srwatson old_dlprefiles="$dlprefiles" 7663156283Srwatson dlprefiles= 7664156283Srwatson for lib in $old_dlprefiles; do 7665156283Srwatson case "$dlprefiles " in 7666156283Srwatson *" $lib "*) ;; 7667243750Srwatson *) func_append dlprefiles " $lib" ;; 7668156283Srwatson esac 7669156283Srwatson done 7670156283Srwatson 7671156283Srwatson if test "$build_libtool_libs" = yes; then 7672156283Srwatson if test -n "$rpath"; then 7673156283Srwatson case $host in 7674243750Srwatson *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 7675156283Srwatson # these systems don't actually have a c library (as such)! 7676156283Srwatson ;; 7677156283Srwatson *-*-rhapsody* | *-*-darwin1.[012]) 7678156283Srwatson # Rhapsody C library is in the System framework 7679243750Srwatson func_append deplibs " System.ltframework" 7680156283Srwatson ;; 7681156283Srwatson *-*-netbsd*) 7682156283Srwatson # Don't link with libc until the a.out ld.so is fixed. 7683156283Srwatson ;; 7684156283Srwatson *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 7685156283Srwatson # Do not include libc due to us having libc/libc_r. 7686156283Srwatson ;; 7687159985Srwatson *-*-sco3.2v5* | *-*-sco5v6*) 7688159985Srwatson # Causes problems with __ctype 7689159985Srwatson ;; 7690159985Srwatson *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7691159985Srwatson # Compiler inserts libc in the correct place for threads to work 7692159985Srwatson ;; 7693243750Srwatson *) 7694156283Srwatson # Add libc to deplibs on all other systems if necessary. 7695156283Srwatson if test "$build_libtool_need_lc" = "yes"; then 7696243750Srwatson func_append deplibs " -lc" 7697156283Srwatson fi 7698156283Srwatson ;; 7699156283Srwatson esac 7700156283Srwatson fi 7701156283Srwatson 7702156283Srwatson # Transform deplibs into only deplibs that can be linked in shared. 7703156283Srwatson name_save=$name 7704156283Srwatson libname_save=$libname 7705156283Srwatson release_save=$release 7706156283Srwatson versuffix_save=$versuffix 7707156283Srwatson major_save=$major 7708156283Srwatson # I'm not sure if I'm treating the release correctly. I think 7709156283Srwatson # release should show up in the -l (ie -lgmp5) so we don't want to 7710156283Srwatson # add it in twice. Is that correct? 7711156283Srwatson release="" 7712156283Srwatson versuffix="" 7713156283Srwatson major="" 7714156283Srwatson newdeplibs= 7715156283Srwatson droppeddeps=no 7716156283Srwatson case $deplibs_check_method in 7717156283Srwatson pass_all) 7718156283Srwatson # Don't check for shared/static. Everything works. 7719156283Srwatson # This might be a little naive. We might want to check 7720156283Srwatson # whether the library exists or not. But this is on 7721156283Srwatson # osf3 & osf4 and I'm not really sure... Just 7722156283Srwatson # implementing what was already the behavior. 7723156283Srwatson newdeplibs=$deplibs 7724156283Srwatson ;; 7725156283Srwatson test_compile) 7726156283Srwatson # This code stresses the "libraries are programs" paradigm to its 7727156283Srwatson # limits. Maybe even breaks it. We compile a program, linking it 7728156283Srwatson # against the deplibs as a proxy for the library. Then we can check 7729156283Srwatson # whether they linked in statically or dynamically with ldd. 7730243750Srwatson $opt_dry_run || $RM conftest.c 7731156283Srwatson cat > conftest.c <<EOF 7732156283Srwatson int main() { return 0; } 7733156283SrwatsonEOF 7734243750Srwatson $opt_dry_run || $RM conftest 7735173143Srwatson if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 7736156283Srwatson ldd_output=`ldd conftest` 7737156283Srwatson for i in $deplibs; do 7738243750Srwatson case $i in 7739243750Srwatson -l*) 7740243750Srwatson func_stripname -l '' "$i" 7741243750Srwatson name=$func_stripname_result 7742156283Srwatson if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7743156283Srwatson case " $predeps $postdeps " in 7744156283Srwatson *" $i "*) 7745243750Srwatson func_append newdeplibs " $i" 7746156283Srwatson i="" 7747156283Srwatson ;; 7748156283Srwatson esac 7749243750Srwatson fi 7750156283Srwatson if test -n "$i" ; then 7751243750Srwatson libname=`eval "\\$ECHO \"$libname_spec\""` 7752243750Srwatson deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7753243750Srwatson set dummy $deplib_matches; shift 7754243750Srwatson deplib_match=$1 7755156283Srwatson if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7756243750Srwatson func_append newdeplibs " $i" 7757156283Srwatson else 7758156283Srwatson droppeddeps=yes 7759243750Srwatson echo 7760243750Srwatson $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7761243750Srwatson echo "*** I have the capability to make that library automatically link in when" 7762243750Srwatson echo "*** you link to this library. But I can only do this if you have a" 7763243750Srwatson echo "*** shared version of the library, which I believe you do not have" 7764243750Srwatson echo "*** because a test_compile did reveal that the linker did not use it for" 7765243750Srwatson echo "*** its dynamic dependency list that programs get resolved with at runtime." 7766156283Srwatson fi 7767156283Srwatson fi 7768243750Srwatson ;; 7769243750Srwatson *) 7770243750Srwatson func_append newdeplibs " $i" 7771243750Srwatson ;; 7772243750Srwatson esac 7773156283Srwatson done 7774156283Srwatson else 7775156283Srwatson # Error occurred in the first compile. Let's try to salvage 7776156283Srwatson # the situation: Compile a separate program for each library. 7777156283Srwatson for i in $deplibs; do 7778243750Srwatson case $i in 7779243750Srwatson -l*) 7780243750Srwatson func_stripname -l '' "$i" 7781243750Srwatson name=$func_stripname_result 7782243750Srwatson $opt_dry_run || $RM conftest 7783173143Srwatson if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 7784156283Srwatson ldd_output=`ldd conftest` 7785156283Srwatson if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7786156283Srwatson case " $predeps $postdeps " in 7787156283Srwatson *" $i "*) 7788243750Srwatson func_append newdeplibs " $i" 7789156283Srwatson i="" 7790156283Srwatson ;; 7791156283Srwatson esac 7792156283Srwatson fi 7793156283Srwatson if test -n "$i" ; then 7794243750Srwatson libname=`eval "\\$ECHO \"$libname_spec\""` 7795243750Srwatson deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7796243750Srwatson set dummy $deplib_matches; shift 7797243750Srwatson deplib_match=$1 7798156283Srwatson if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7799243750Srwatson func_append newdeplibs " $i" 7800156283Srwatson else 7801156283Srwatson droppeddeps=yes 7802243750Srwatson echo 7803243750Srwatson $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7804243750Srwatson echo "*** I have the capability to make that library automatically link in when" 7805243750Srwatson echo "*** you link to this library. But I can only do this if you have a" 7806243750Srwatson echo "*** shared version of the library, which you do not appear to have" 7807243750Srwatson echo "*** because a test_compile did reveal that the linker did not use this one" 7808243750Srwatson echo "*** as a dynamic dependency that programs can get resolved with at runtime." 7809156283Srwatson fi 7810156283Srwatson fi 7811156283Srwatson else 7812156283Srwatson droppeddeps=yes 7813243750Srwatson echo 7814243750Srwatson $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 7815243750Srwatson echo "*** make it link in! You will probably need to install it or some" 7816243750Srwatson echo "*** library that it depends on before this library will be fully" 7817243750Srwatson echo "*** functional. Installing it before continuing would be even better." 7818156283Srwatson fi 7819243750Srwatson ;; 7820243750Srwatson *) 7821243750Srwatson func_append newdeplibs " $i" 7822243750Srwatson ;; 7823243750Srwatson esac 7824156283Srwatson done 7825156283Srwatson fi 7826156283Srwatson ;; 7827156283Srwatson file_magic*) 7828243750Srwatson set dummy $deplibs_check_method; shift 7829243750Srwatson file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7830156283Srwatson for a_deplib in $deplibs; do 7831243750Srwatson case $a_deplib in 7832243750Srwatson -l*) 7833243750Srwatson func_stripname -l '' "$a_deplib" 7834243750Srwatson name=$func_stripname_result 7835156283Srwatson if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7836156283Srwatson case " $predeps $postdeps " in 7837156283Srwatson *" $a_deplib "*) 7838243750Srwatson func_append newdeplibs " $a_deplib" 7839156283Srwatson a_deplib="" 7840156283Srwatson ;; 7841156283Srwatson esac 7842156283Srwatson fi 7843156283Srwatson if test -n "$a_deplib" ; then 7844243750Srwatson libname=`eval "\\$ECHO \"$libname_spec\""` 7845243750Srwatson if test -n "$file_magic_glob"; then 7846243750Srwatson libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 7847243750Srwatson else 7848243750Srwatson libnameglob=$libname 7849243750Srwatson fi 7850243750Srwatson test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 7851156283Srwatson for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7852243750Srwatson if test "$want_nocaseglob" = yes; then 7853243750Srwatson shopt -s nocaseglob 7854243750Srwatson potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7855243750Srwatson $nocaseglob 7856243750Srwatson else 7857243750Srwatson potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7858243750Srwatson fi 7859156283Srwatson for potent_lib in $potential_libs; do 7860156283Srwatson # Follow soft links. 7861243750Srwatson if ls -lLd "$potent_lib" 2>/dev/null | 7862243750Srwatson $GREP " -> " >/dev/null; then 7863156283Srwatson continue 7864156283Srwatson fi 7865156283Srwatson # The statement above tries to avoid entering an 7866156283Srwatson # endless loop below, in case of cyclic links. 7867156283Srwatson # We might still enter an endless loop, since a link 7868156283Srwatson # loop can be closed while we follow links, 7869156283Srwatson # but so what? 7870156283Srwatson potlib="$potent_lib" 7871156283Srwatson while test -h "$potlib" 2>/dev/null; do 7872156283Srwatson potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 7873156283Srwatson case $potliblink in 7874156283Srwatson [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 7875243750Srwatson *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 7876156283Srwatson esac 7877156283Srwatson done 7878243750Srwatson if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 7879243750Srwatson $SED -e 10q | 7880243750Srwatson $EGREP "$file_magic_regex" > /dev/null; then 7881243750Srwatson func_append newdeplibs " $a_deplib" 7882156283Srwatson a_deplib="" 7883156283Srwatson break 2 7884156283Srwatson fi 7885156283Srwatson done 7886156283Srwatson done 7887156283Srwatson fi 7888156283Srwatson if test -n "$a_deplib" ; then 7889156283Srwatson droppeddeps=yes 7890243750Srwatson echo 7891243750Srwatson $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7892243750Srwatson echo "*** I have the capability to make that library automatically link in when" 7893243750Srwatson echo "*** you link to this library. But I can only do this if you have a" 7894243750Srwatson echo "*** shared version of the library, which you do not appear to have" 7895243750Srwatson echo "*** because I did check the linker path looking for a file starting" 7896156283Srwatson if test -z "$potlib" ; then 7897243750Srwatson $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 7898156283Srwatson else 7899243750Srwatson $ECHO "*** with $libname and none of the candidates passed a file format test" 7900243750Srwatson $ECHO "*** using a file magic. Last file checked: $potlib" 7901156283Srwatson fi 7902156283Srwatson fi 7903243750Srwatson ;; 7904243750Srwatson *) 7905156283Srwatson # Add a -L argument. 7906243750Srwatson func_append newdeplibs " $a_deplib" 7907243750Srwatson ;; 7908243750Srwatson esac 7909156283Srwatson done # Gone through all deplibs. 7910156283Srwatson ;; 7911156283Srwatson match_pattern*) 7912243750Srwatson set dummy $deplibs_check_method; shift 7913243750Srwatson match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7914156283Srwatson for a_deplib in $deplibs; do 7915243750Srwatson case $a_deplib in 7916243750Srwatson -l*) 7917243750Srwatson func_stripname -l '' "$a_deplib" 7918243750Srwatson name=$func_stripname_result 7919156283Srwatson if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7920156283Srwatson case " $predeps $postdeps " in 7921156283Srwatson *" $a_deplib "*) 7922243750Srwatson func_append newdeplibs " $a_deplib" 7923156283Srwatson a_deplib="" 7924156283Srwatson ;; 7925156283Srwatson esac 7926156283Srwatson fi 7927156283Srwatson if test -n "$a_deplib" ; then 7928243750Srwatson libname=`eval "\\$ECHO \"$libname_spec\""` 7929156283Srwatson for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7930156283Srwatson potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 7931156283Srwatson for potent_lib in $potential_libs; do 7932156283Srwatson potlib="$potent_lib" # see symlink-check above in file_magic test 7933243750Srwatson if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 7934243750Srwatson $EGREP "$match_pattern_regex" > /dev/null; then 7935243750Srwatson func_append newdeplibs " $a_deplib" 7936156283Srwatson a_deplib="" 7937156283Srwatson break 2 7938156283Srwatson fi 7939156283Srwatson done 7940156283Srwatson done 7941156283Srwatson fi 7942156283Srwatson if test -n "$a_deplib" ; then 7943156283Srwatson droppeddeps=yes 7944243750Srwatson echo 7945243750Srwatson $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7946243750Srwatson echo "*** I have the capability to make that library automatically link in when" 7947243750Srwatson echo "*** you link to this library. But I can only do this if you have a" 7948243750Srwatson echo "*** shared version of the library, which you do not appear to have" 7949243750Srwatson echo "*** because I did check the linker path looking for a file starting" 7950156283Srwatson if test -z "$potlib" ; then 7951243750Srwatson $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 7952156283Srwatson else 7953243750Srwatson $ECHO "*** with $libname and none of the candidates passed a file format test" 7954243750Srwatson $ECHO "*** using a regex pattern. Last file checked: $potlib" 7955156283Srwatson fi 7956156283Srwatson fi 7957243750Srwatson ;; 7958243750Srwatson *) 7959156283Srwatson # Add a -L argument. 7960243750Srwatson func_append newdeplibs " $a_deplib" 7961243750Srwatson ;; 7962243750Srwatson esac 7963156283Srwatson done # Gone through all deplibs. 7964156283Srwatson ;; 7965156283Srwatson none | unknown | *) 7966156283Srwatson newdeplibs="" 7967243750Srwatson tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7968156283Srwatson if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7969156283Srwatson for i in $predeps $postdeps ; do 7970156283Srwatson # can't use Xsed below, because $i might contain '/' 7971243750Srwatson tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 7972156283Srwatson done 7973156283Srwatson fi 7974243750Srwatson case $tmp_deplibs in 7975243750Srwatson *[!\ \ ]*) 7976243750Srwatson echo 7977156283Srwatson if test "X$deplibs_check_method" = "Xnone"; then 7978243750Srwatson echo "*** Warning: inter-library dependencies are not supported in this platform." 7979156283Srwatson else 7980243750Srwatson echo "*** Warning: inter-library dependencies are not known to be supported." 7981156283Srwatson fi 7982243750Srwatson echo "*** All declared inter-library dependencies are being dropped." 7983156283Srwatson droppeddeps=yes 7984243750Srwatson ;; 7985243750Srwatson esac 7986156283Srwatson ;; 7987156283Srwatson esac 7988156283Srwatson versuffix=$versuffix_save 7989156283Srwatson major=$major_save 7990156283Srwatson release=$release_save 7991156283Srwatson libname=$libname_save 7992156283Srwatson name=$name_save 7993156283Srwatson 7994156283Srwatson case $host in 7995156283Srwatson *-*-rhapsody* | *-*-darwin1.[012]) 7996243750Srwatson # On Rhapsody replace the C library with the System framework 7997243750Srwatson newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 7998156283Srwatson ;; 7999156283Srwatson esac 8000156283Srwatson 8001156283Srwatson if test "$droppeddeps" = yes; then 8002156283Srwatson if test "$module" = yes; then 8003243750Srwatson echo 8004243750Srwatson echo "*** Warning: libtool could not satisfy all declared inter-library" 8005243750Srwatson $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 8006243750Srwatson echo "*** a static module, that should work as long as the dlopening" 8007243750Srwatson echo "*** application is linked with the -dlopen flag." 8008156283Srwatson if test -z "$global_symbol_pipe"; then 8009243750Srwatson echo 8010243750Srwatson echo "*** However, this would only work if libtool was able to extract symbol" 8011243750Srwatson echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 8012243750Srwatson echo "*** not find such a program. So, this module is probably useless." 8013243750Srwatson echo "*** \`nm' from GNU binutils and a full rebuild may help." 8014156283Srwatson fi 8015156283Srwatson if test "$build_old_libs" = no; then 8016156283Srwatson oldlibs="$output_objdir/$libname.$libext" 8017156283Srwatson build_libtool_libs=module 8018156283Srwatson build_old_libs=yes 8019156283Srwatson else 8020156283Srwatson build_libtool_libs=no 8021156283Srwatson fi 8022156283Srwatson else 8023243750Srwatson echo "*** The inter-library dependencies that have been dropped here will be" 8024243750Srwatson echo "*** automatically added whenever a program is linked with this library" 8025243750Srwatson echo "*** or is declared to -dlopen it." 8026156283Srwatson 8027156283Srwatson if test "$allow_undefined" = no; then 8028243750Srwatson echo 8029243750Srwatson echo "*** Since this library must not contain undefined symbols," 8030243750Srwatson echo "*** because either the platform does not support them or" 8031243750Srwatson echo "*** it was explicitly requested with -no-undefined," 8032243750Srwatson echo "*** libtool will only create a static version of it." 8033156283Srwatson if test "$build_old_libs" = no; then 8034156283Srwatson oldlibs="$output_objdir/$libname.$libext" 8035156283Srwatson build_libtool_libs=module 8036156283Srwatson build_old_libs=yes 8037156283Srwatson else 8038156283Srwatson build_libtool_libs=no 8039156283Srwatson fi 8040156283Srwatson fi 8041156283Srwatson fi 8042156283Srwatson fi 8043156283Srwatson # Done checking deplibs! 8044156283Srwatson deplibs=$newdeplibs 8045156283Srwatson fi 8046243750Srwatson # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8047243750Srwatson case $host in 8048243750Srwatson *-*-darwin*) 8049243750Srwatson newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8050243750Srwatson new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8051243750Srwatson deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8052243750Srwatson ;; 8053243750Srwatson esac 8054156283Srwatson 8055159985Srwatson # move library search paths that coincide with paths to not yet 8056159985Srwatson # installed libraries to the beginning of the library search list 8057159985Srwatson new_libs= 8058159985Srwatson for path in $notinst_path; do 8059159985Srwatson case " $new_libs " in 8060159985Srwatson *" -L$path/$objdir "*) ;; 8061159985Srwatson *) 8062159985Srwatson case " $deplibs " in 8063159985Srwatson *" -L$path/$objdir "*) 8064243750Srwatson func_append new_libs " -L$path/$objdir" ;; 8065159985Srwatson esac 8066159985Srwatson ;; 8067159985Srwatson esac 8068159985Srwatson done 8069159985Srwatson for deplib in $deplibs; do 8070159985Srwatson case $deplib in 8071159985Srwatson -L*) 8072159985Srwatson case " $new_libs " in 8073159985Srwatson *" $deplib "*) ;; 8074243750Srwatson *) func_append new_libs " $deplib" ;; 8075159985Srwatson esac 8076159985Srwatson ;; 8077243750Srwatson *) func_append new_libs " $deplib" ;; 8078159985Srwatson esac 8079159985Srwatson done 8080159985Srwatson deplibs="$new_libs" 8081159985Srwatson 8082156283Srwatson # All the library-specific variables (install_libdir is set above). 8083156283Srwatson library_names= 8084156283Srwatson old_library= 8085156283Srwatson dlname= 8086156283Srwatson 8087156283Srwatson # Test again, we may have decided not to build it any more 8088156283Srwatson if test "$build_libtool_libs" = yes; then 8089243750Srwatson # Remove ${wl} instances when linking with ld. 8090243750Srwatson # FIXME: should test the right _cmds variable. 8091243750Srwatson case $archive_cmds in 8092243750Srwatson *\$LD\ *) wl= ;; 8093243750Srwatson esac 8094156283Srwatson if test "$hardcode_into_libs" = yes; then 8095156283Srwatson # Hardcode the library paths 8096156283Srwatson hardcode_libdirs= 8097156283Srwatson dep_rpath= 8098156283Srwatson rpath="$finalize_rpath" 8099243750Srwatson test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 8100156283Srwatson for libdir in $rpath; do 8101156283Srwatson if test -n "$hardcode_libdir_flag_spec"; then 8102156283Srwatson if test -n "$hardcode_libdir_separator"; then 8103243750Srwatson func_replace_sysroot "$libdir" 8104243750Srwatson libdir=$func_replace_sysroot_result 8105156283Srwatson if test -z "$hardcode_libdirs"; then 8106156283Srwatson hardcode_libdirs="$libdir" 8107156283Srwatson else 8108156283Srwatson # Just accumulate the unique libdirs. 8109156283Srwatson case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8110156283Srwatson *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8111156283Srwatson ;; 8112156283Srwatson *) 8113243750Srwatson func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8114156283Srwatson ;; 8115156283Srwatson esac 8116156283Srwatson fi 8117156283Srwatson else 8118156283Srwatson eval flag=\"$hardcode_libdir_flag_spec\" 8119243750Srwatson func_append dep_rpath " $flag" 8120156283Srwatson fi 8121156283Srwatson elif test -n "$runpath_var"; then 8122156283Srwatson case "$perm_rpath " in 8123156283Srwatson *" $libdir "*) ;; 8124243750Srwatson *) func_append perm_rpath " $libdir" ;; 8125156283Srwatson esac 8126156283Srwatson fi 8127156283Srwatson done 8128156283Srwatson # Substitute the hardcoded libdirs into the rpath. 8129156283Srwatson if test -n "$hardcode_libdir_separator" && 8130156283Srwatson test -n "$hardcode_libdirs"; then 8131156283Srwatson libdir="$hardcode_libdirs" 8132243750Srwatson eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 8133156283Srwatson fi 8134156283Srwatson if test -n "$runpath_var" && test -n "$perm_rpath"; then 8135156283Srwatson # We should set the runpath_var. 8136156283Srwatson rpath= 8137156283Srwatson for dir in $perm_rpath; do 8138243750Srwatson func_append rpath "$dir:" 8139156283Srwatson done 8140156283Srwatson eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 8141156283Srwatson fi 8142156283Srwatson test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 8143156283Srwatson fi 8144156283Srwatson 8145156283Srwatson shlibpath="$finalize_shlibpath" 8146243750Srwatson test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 8147156283Srwatson if test -n "$shlibpath"; then 8148156283Srwatson eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 8149156283Srwatson fi 8150156283Srwatson 8151156283Srwatson # Get the real and link names of the library. 8152156283Srwatson eval shared_ext=\"$shrext_cmds\" 8153156283Srwatson eval library_names=\"$library_names_spec\" 8154156283Srwatson set dummy $library_names 8155243750Srwatson shift 8156243750Srwatson realname="$1" 8157243750Srwatson shift 8158156283Srwatson 8159156283Srwatson if test -n "$soname_spec"; then 8160156283Srwatson eval soname=\"$soname_spec\" 8161156283Srwatson else 8162156283Srwatson soname="$realname" 8163156283Srwatson fi 8164156283Srwatson if test -z "$dlname"; then 8165156283Srwatson dlname=$soname 8166156283Srwatson fi 8167156283Srwatson 8168156283Srwatson lib="$output_objdir/$realname" 8169159985Srwatson linknames= 8170156283Srwatson for link 8171156283Srwatson do 8172243750Srwatson func_append linknames " $link" 8173156283Srwatson done 8174156283Srwatson 8175156283Srwatson # Use standard objects if they are pic 8176243750Srwatson test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 8177243750Srwatson test "X$libobjs" = "X " && libobjs= 8178156283Srwatson 8179243750Srwatson delfiles= 8180243750Srwatson if test -n "$export_symbols" && test -n "$include_expsyms"; then 8181243750Srwatson $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 8182243750Srwatson export_symbols="$output_objdir/$libname.uexp" 8183243750Srwatson func_append delfiles " $export_symbols" 8184243750Srwatson fi 8185243750Srwatson 8186243750Srwatson orig_export_symbols= 8187243750Srwatson case $host_os in 8188243750Srwatson cygwin* | mingw* | cegcc*) 8189243750Srwatson if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 8190243750Srwatson # exporting using user supplied symfile 8191243750Srwatson if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 8192243750Srwatson # and it's NOT already a .def file. Must figure out 8193243750Srwatson # which of the given symbols are data symbols and tag 8194243750Srwatson # them as such. So, trigger use of export_symbols_cmds. 8195243750Srwatson # export_symbols gets reassigned inside the "prepare 8196243750Srwatson # the list of exported symbols" if statement, so the 8197243750Srwatson # include_expsyms logic still works. 8198243750Srwatson orig_export_symbols="$export_symbols" 8199243750Srwatson export_symbols= 8200243750Srwatson always_export_symbols=yes 8201243750Srwatson fi 8202243750Srwatson fi 8203243750Srwatson ;; 8204243750Srwatson esac 8205243750Srwatson 8206156283Srwatson # Prepare the list of exported symbols 8207156283Srwatson if test -z "$export_symbols"; then 8208156283Srwatson if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 8209243750Srwatson func_verbose "generating symbol list for \`$libname.la'" 8210156283Srwatson export_symbols="$output_objdir/$libname.exp" 8211243750Srwatson $opt_dry_run || $RM $export_symbols 8212156283Srwatson cmds=$export_symbols_cmds 8213156283Srwatson save_ifs="$IFS"; IFS='~' 8214243750Srwatson for cmd1 in $cmds; do 8215156283Srwatson IFS="$save_ifs" 8216243750Srwatson # Take the normal branch if the nm_file_list_spec branch 8217243750Srwatson # doesn't work or if tool conversion is not needed. 8218243750Srwatson case $nm_file_list_spec~$to_tool_file_cmd in 8219243750Srwatson *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 8220243750Srwatson try_normal_branch=yes 8221243750Srwatson eval cmd=\"$cmd1\" 8222243750Srwatson func_len " $cmd" 8223243750Srwatson len=$func_len_result 8224243750Srwatson ;; 8225243750Srwatson *) 8226243750Srwatson try_normal_branch=no 8227243750Srwatson ;; 8228243750Srwatson esac 8229243750Srwatson if test "$try_normal_branch" = yes \ 8230243750Srwatson && { test "$len" -lt "$max_cmd_len" \ 8231243750Srwatson || test "$max_cmd_len" -le -1; } 8232243750Srwatson then 8233243750Srwatson func_show_eval "$cmd" 'exit $?' 8234243750Srwatson skipped_export=false 8235243750Srwatson elif test -n "$nm_file_list_spec"; then 8236243750Srwatson func_basename "$output" 8237243750Srwatson output_la=$func_basename_result 8238243750Srwatson save_libobjs=$libobjs 8239243750Srwatson save_output=$output 8240243750Srwatson output=${output_objdir}/${output_la}.nm 8241243750Srwatson func_to_tool_file "$output" 8242243750Srwatson libobjs=$nm_file_list_spec$func_to_tool_file_result 8243243750Srwatson func_append delfiles " $output" 8244243750Srwatson func_verbose "creating $NM input file list: $output" 8245243750Srwatson for obj in $save_libobjs; do 8246243750Srwatson func_to_tool_file "$obj" 8247243750Srwatson $ECHO "$func_to_tool_file_result" 8248243750Srwatson done > "$output" 8249243750Srwatson eval cmd=\"$cmd1\" 8250243750Srwatson func_show_eval "$cmd" 'exit $?' 8251243750Srwatson output=$save_output 8252243750Srwatson libobjs=$save_libobjs 8253243750Srwatson skipped_export=false 8254156283Srwatson else 8255243750Srwatson # The command line is too long to execute in one step. 8256243750Srwatson func_verbose "using reloadable object file for export list..." 8257243750Srwatson skipped_export=: 8258156283Srwatson # Break out early, otherwise skipped_export may be 8259156283Srwatson # set to false by a later but shorter cmd. 8260156283Srwatson break 8261156283Srwatson fi 8262156283Srwatson done 8263156283Srwatson IFS="$save_ifs" 8264243750Srwatson if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 8265243750Srwatson func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8266243750Srwatson func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8267156283Srwatson fi 8268156283Srwatson fi 8269156283Srwatson fi 8270156283Srwatson 8271156283Srwatson if test -n "$export_symbols" && test -n "$include_expsyms"; then 8272243750Srwatson tmp_export_symbols="$export_symbols" 8273243750Srwatson test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8274243750Srwatson $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8275156283Srwatson fi 8276156283Srwatson 8277243750Srwatson if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 8278243750Srwatson # The given exports_symbols file has to be filtered, so filter it. 8279243750Srwatson func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8280243750Srwatson # FIXME: $output_objdir/$libname.filter potentially contains lots of 8281243750Srwatson # 's' commands which not all seds can handle. GNU sed should be fine 8282243750Srwatson # though. Also, the filter scales superlinearly with the number of 8283243750Srwatson # global variables. join(1) would be nice here, but unfortunately 8284243750Srwatson # isn't a blessed tool. 8285243750Srwatson $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8286243750Srwatson func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8287243750Srwatson export_symbols=$output_objdir/$libname.def 8288243750Srwatson $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8289243750Srwatson fi 8290243750Srwatson 8291156283Srwatson tmp_deplibs= 8292156283Srwatson for test_deplib in $deplibs; do 8293243750Srwatson case " $convenience " in 8294243750Srwatson *" $test_deplib "*) ;; 8295243750Srwatson *) 8296243750Srwatson func_append tmp_deplibs " $test_deplib" 8297243750Srwatson ;; 8298243750Srwatson esac 8299156283Srwatson done 8300156283Srwatson deplibs="$tmp_deplibs" 8301156283Srwatson 8302156283Srwatson if test -n "$convenience"; then 8303243750Srwatson if test -n "$whole_archive_flag_spec" && 8304243750Srwatson test "$compiler_needs_object" = yes && 8305243750Srwatson test -z "$libobjs"; then 8306243750Srwatson # extract the archives, so we have objects to list. 8307243750Srwatson # TODO: could optimize this to just extract one archive. 8308243750Srwatson whole_archive_flag_spec= 8309243750Srwatson fi 8310156283Srwatson if test -n "$whole_archive_flag_spec"; then 8311156283Srwatson save_libobjs=$libobjs 8312156283Srwatson eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8313243750Srwatson test "X$libobjs" = "X " && libobjs= 8314156283Srwatson else 8315156283Srwatson gentop="$output_objdir/${outputname}x" 8316243750Srwatson func_append generated " $gentop" 8317156283Srwatson 8318156283Srwatson func_extract_archives $gentop $convenience 8319243750Srwatson func_append libobjs " $func_extract_archives_result" 8320243750Srwatson test "X$libobjs" = "X " && libobjs= 8321156283Srwatson fi 8322156283Srwatson fi 8323243750Srwatson 8324156283Srwatson if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 8325156283Srwatson eval flag=\"$thread_safe_flag_spec\" 8326243750Srwatson func_append linker_flags " $flag" 8327156283Srwatson fi 8328156283Srwatson 8329156283Srwatson # Make a backup of the uninstalled library when relinking 8330243750Srwatson if test "$opt_mode" = relink; then 8331243750Srwatson $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 8332156283Srwatson fi 8333156283Srwatson 8334156283Srwatson # Do each of the archive commands. 8335156283Srwatson if test "$module" = yes && test -n "$module_cmds" ; then 8336156283Srwatson if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8337156283Srwatson eval test_cmds=\"$module_expsym_cmds\" 8338156283Srwatson cmds=$module_expsym_cmds 8339156283Srwatson else 8340156283Srwatson eval test_cmds=\"$module_cmds\" 8341156283Srwatson cmds=$module_cmds 8342156283Srwatson fi 8343156283Srwatson else 8344243750Srwatson if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8345243750Srwatson eval test_cmds=\"$archive_expsym_cmds\" 8346243750Srwatson cmds=$archive_expsym_cmds 8347243750Srwatson else 8348243750Srwatson eval test_cmds=\"$archive_cmds\" 8349243750Srwatson cmds=$archive_cmds 8350156283Srwatson fi 8351156283Srwatson fi 8352156283Srwatson 8353156283Srwatson if test "X$skipped_export" != "X:" && 8354243750Srwatson func_len " $test_cmds" && 8355243750Srwatson len=$func_len_result && 8356243750Srwatson test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8357156283Srwatson : 8358156283Srwatson else 8359243750Srwatson # The command line is too long to link in one step, link piecewise 8360243750Srwatson # or, if using GNU ld and skipped_export is not :, use a linker 8361243750Srwatson # script. 8362156283Srwatson 8363156283Srwatson # Save the value of $output and $libobjs because we want to 8364156283Srwatson # use them later. If we have whole_archive_flag_spec, we 8365156283Srwatson # want to use save_libobjs as it was before 8366156283Srwatson # whole_archive_flag_spec was expanded, because we can't 8367156283Srwatson # assume the linker understands whole_archive_flag_spec. 8368156283Srwatson # This may have to be revisited, in case too many 8369156283Srwatson # convenience libraries get linked in and end up exceeding 8370156283Srwatson # the spec. 8371156283Srwatson if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 8372156283Srwatson save_libobjs=$libobjs 8373156283Srwatson fi 8374156283Srwatson save_output=$output 8375243750Srwatson func_basename "$output" 8376243750Srwatson output_la=$func_basename_result 8377156283Srwatson 8378156283Srwatson # Clear the reloadable object creation command queue and 8379156283Srwatson # initialize k to one. 8380156283Srwatson test_cmds= 8381156283Srwatson concat_cmds= 8382156283Srwatson objlist= 8383156283Srwatson last_robj= 8384156283Srwatson k=1 8385243750Srwatson 8386243750Srwatson if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 8387243750Srwatson output=${output_objdir}/${output_la}.lnkscript 8388243750Srwatson func_verbose "creating GNU ld script: $output" 8389243750Srwatson echo 'INPUT (' > $output 8390243750Srwatson for obj in $save_libobjs 8391243750Srwatson do 8392243750Srwatson func_to_tool_file "$obj" 8393243750Srwatson $ECHO "$func_to_tool_file_result" >> $output 8394243750Srwatson done 8395243750Srwatson echo ')' >> $output 8396243750Srwatson func_append delfiles " $output" 8397243750Srwatson func_to_tool_file "$output" 8398243750Srwatson output=$func_to_tool_file_result 8399243750Srwatson elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 8400243750Srwatson output=${output_objdir}/${output_la}.lnk 8401243750Srwatson func_verbose "creating linker input file list: $output" 8402243750Srwatson : > $output 8403243750Srwatson set x $save_libobjs 8404243750Srwatson shift 8405243750Srwatson firstobj= 8406243750Srwatson if test "$compiler_needs_object" = yes; then 8407243750Srwatson firstobj="$1 " 8408243750Srwatson shift 8409243750Srwatson fi 8410243750Srwatson for obj 8411243750Srwatson do 8412243750Srwatson func_to_tool_file "$obj" 8413243750Srwatson $ECHO "$func_to_tool_file_result" >> $output 8414243750Srwatson done 8415243750Srwatson func_append delfiles " $output" 8416243750Srwatson func_to_tool_file "$output" 8417243750Srwatson output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 8418243750Srwatson else 8419243750Srwatson if test -n "$save_libobjs"; then 8420243750Srwatson func_verbose "creating reloadable object files..." 8421243750Srwatson output=$output_objdir/$output_la-${k}.$objext 8422243750Srwatson eval test_cmds=\"$reload_cmds\" 8423243750Srwatson func_len " $test_cmds" 8424243750Srwatson len0=$func_len_result 8425243750Srwatson len=$len0 8426243750Srwatson 8427243750Srwatson # Loop over the list of objects to be linked. 8428243750Srwatson for obj in $save_libobjs 8429243750Srwatson do 8430243750Srwatson func_len " $obj" 8431243750Srwatson func_arith $len + $func_len_result 8432243750Srwatson len=$func_arith_result 8433243750Srwatson if test "X$objlist" = X || 8434243750Srwatson test "$len" -lt "$max_cmd_len"; then 8435243750Srwatson func_append objlist " $obj" 8436243750Srwatson else 8437243750Srwatson # The command $test_cmds is almost too long, add a 8438243750Srwatson # command to the queue. 8439243750Srwatson if test "$k" -eq 1 ; then 8440243750Srwatson # The first file doesn't have a previous command to add. 8441243750Srwatson reload_objs=$objlist 8442243750Srwatson eval concat_cmds=\"$reload_cmds\" 8443243750Srwatson else 8444243750Srwatson # All subsequent reloadable object files will link in 8445243750Srwatson # the last one created. 8446243750Srwatson reload_objs="$objlist $last_robj" 8447243750Srwatson eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 8448243750Srwatson fi 8449243750Srwatson last_robj=$output_objdir/$output_la-${k}.$objext 8450243750Srwatson func_arith $k + 1 8451243750Srwatson k=$func_arith_result 8452243750Srwatson output=$output_objdir/$output_la-${k}.$objext 8453243750Srwatson objlist=" $obj" 8454243750Srwatson func_len " $last_robj" 8455243750Srwatson func_arith $len0 + $func_len_result 8456243750Srwatson len=$func_arith_result 8457243750Srwatson fi 8458243750Srwatson done 8459243750Srwatson # Handle the remaining objects by creating one last 8460243750Srwatson # reloadable object file. All subsequent reloadable object 8461243750Srwatson # files will link in the last one created. 8462243750Srwatson test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8463243750Srwatson reload_objs="$objlist $last_robj" 8464243750Srwatson eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 8465243750Srwatson if test -n "$last_robj"; then 8466243750Srwatson eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8467243750Srwatson fi 8468243750Srwatson func_append delfiles " $output" 8469243750Srwatson 8470156283Srwatson else 8471243750Srwatson output= 8472243750Srwatson fi 8473243750Srwatson 8474243750Srwatson if ${skipped_export-false}; then 8475243750Srwatson func_verbose "generating symbol list for \`$libname.la'" 8476243750Srwatson export_symbols="$output_objdir/$libname.exp" 8477243750Srwatson $opt_dry_run || $RM $export_symbols 8478243750Srwatson libobjs=$output 8479243750Srwatson # Append the command to create the export file. 8480243750Srwatson test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8481243750Srwatson eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 8482243750Srwatson if test -n "$last_robj"; then 8483243750Srwatson eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8484156283Srwatson fi 8485156283Srwatson fi 8486156283Srwatson 8487243750Srwatson test -n "$save_libobjs" && 8488243750Srwatson func_verbose "creating a temporary reloadable object file: $output" 8489156283Srwatson 8490243750Srwatson # Loop through the commands generated above and execute them. 8491243750Srwatson save_ifs="$IFS"; IFS='~' 8492243750Srwatson for cmd in $concat_cmds; do 8493243750Srwatson IFS="$save_ifs" 8494243750Srwatson $opt_silent || { 8495243750Srwatson func_quote_for_expand "$cmd" 8496243750Srwatson eval "func_echo $func_quote_for_expand_result" 8497243750Srwatson } 8498243750Srwatson $opt_dry_run || eval "$cmd" || { 8499243750Srwatson lt_exit=$? 8500156283Srwatson 8501243750Srwatson # Restore the uninstalled library and exit 8502243750Srwatson if test "$opt_mode" = relink; then 8503243750Srwatson ( cd "$output_objdir" && \ 8504243750Srwatson $RM "${realname}T" && \ 8505243750Srwatson $MV "${realname}U" "$realname" ) 8506243750Srwatson fi 8507156283Srwatson 8508243750Srwatson exit $lt_exit 8509243750Srwatson } 8510243750Srwatson done 8511156283Srwatson IFS="$save_ifs" 8512156283Srwatson 8513243750Srwatson if test -n "$export_symbols_regex" && ${skipped_export-false}; then 8514243750Srwatson func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8515243750Srwatson func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8516243750Srwatson fi 8517243750Srwatson fi 8518243750Srwatson 8519243750Srwatson if ${skipped_export-false}; then 8520243750Srwatson if test -n "$export_symbols" && test -n "$include_expsyms"; then 8521243750Srwatson tmp_export_symbols="$export_symbols" 8522243750Srwatson test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8523243750Srwatson $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8524243750Srwatson fi 8525243750Srwatson 8526243750Srwatson if test -n "$orig_export_symbols"; then 8527243750Srwatson # The given exports_symbols file has to be filtered, so filter it. 8528243750Srwatson func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8529243750Srwatson # FIXME: $output_objdir/$libname.filter potentially contains lots of 8530243750Srwatson # 's' commands which not all seds can handle. GNU sed should be fine 8531243750Srwatson # though. Also, the filter scales superlinearly with the number of 8532243750Srwatson # global variables. join(1) would be nice here, but unfortunately 8533243750Srwatson # isn't a blessed tool. 8534243750Srwatson $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8535243750Srwatson func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8536243750Srwatson export_symbols=$output_objdir/$libname.def 8537243750Srwatson $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8538243750Srwatson fi 8539243750Srwatson fi 8540243750Srwatson 8541156283Srwatson libobjs=$output 8542156283Srwatson # Restore the value of output. 8543156283Srwatson output=$save_output 8544156283Srwatson 8545156283Srwatson if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 8546156283Srwatson eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8547243750Srwatson test "X$libobjs" = "X " && libobjs= 8548156283Srwatson fi 8549156283Srwatson # Expand the library linking commands again to reset the 8550156283Srwatson # value of $libobjs for piecewise linking. 8551156283Srwatson 8552156283Srwatson # Do each of the archive commands. 8553156283Srwatson if test "$module" = yes && test -n "$module_cmds" ; then 8554156283Srwatson if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8555156283Srwatson cmds=$module_expsym_cmds 8556156283Srwatson else 8557156283Srwatson cmds=$module_cmds 8558156283Srwatson fi 8559156283Srwatson else 8560243750Srwatson if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8561243750Srwatson cmds=$archive_expsym_cmds 8562243750Srwatson else 8563243750Srwatson cmds=$archive_cmds 8564156283Srwatson fi 8565156283Srwatson fi 8566243750Srwatson fi 8567156283Srwatson 8568243750Srwatson if test -n "$delfiles"; then 8569243750Srwatson # Append the command to remove temporary files to $cmds. 8570243750Srwatson eval cmds=\"\$cmds~\$RM $delfiles\" 8571156283Srwatson fi 8572243750Srwatson 8573243750Srwatson # Add any objects from preloaded convenience libraries 8574243750Srwatson if test -n "$dlprefiles"; then 8575243750Srwatson gentop="$output_objdir/${outputname}x" 8576243750Srwatson func_append generated " $gentop" 8577243750Srwatson 8578243750Srwatson func_extract_archives $gentop $dlprefiles 8579243750Srwatson func_append libobjs " $func_extract_archives_result" 8580243750Srwatson test "X$libobjs" = "X " && libobjs= 8581243750Srwatson fi 8582243750Srwatson 8583156283Srwatson save_ifs="$IFS"; IFS='~' 8584156283Srwatson for cmd in $cmds; do 8585156283Srwatson IFS="$save_ifs" 8586156283Srwatson eval cmd=\"$cmd\" 8587243750Srwatson $opt_silent || { 8588243750Srwatson func_quote_for_expand "$cmd" 8589243750Srwatson eval "func_echo $func_quote_for_expand_result" 8590243750Srwatson } 8591243750Srwatson $opt_dry_run || eval "$cmd" || { 8592156283Srwatson lt_exit=$? 8593156283Srwatson 8594156283Srwatson # Restore the uninstalled library and exit 8595243750Srwatson if test "$opt_mode" = relink; then 8596243750Srwatson ( cd "$output_objdir" && \ 8597243750Srwatson $RM "${realname}T" && \ 8598243750Srwatson $MV "${realname}U" "$realname" ) 8599156283Srwatson fi 8600156283Srwatson 8601156283Srwatson exit $lt_exit 8602156283Srwatson } 8603156283Srwatson done 8604156283Srwatson IFS="$save_ifs" 8605156283Srwatson 8606156283Srwatson # Restore the uninstalled library and exit 8607243750Srwatson if test "$opt_mode" = relink; then 8608243750Srwatson $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8609156283Srwatson 8610156283Srwatson if test -n "$convenience"; then 8611156283Srwatson if test -z "$whole_archive_flag_spec"; then 8612243750Srwatson func_show_eval '${RM}r "$gentop"' 8613156283Srwatson fi 8614156283Srwatson fi 8615156283Srwatson 8616156283Srwatson exit $EXIT_SUCCESS 8617156283Srwatson fi 8618156283Srwatson 8619156283Srwatson # Create links to the real library. 8620156283Srwatson for linkname in $linknames; do 8621156283Srwatson if test "$realname" != "$linkname"; then 8622243750Srwatson func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8623156283Srwatson fi 8624156283Srwatson done 8625156283Srwatson 8626156283Srwatson # If -module or -export-dynamic was specified, set the dlname. 8627156283Srwatson if test "$module" = yes || test "$export_dynamic" = yes; then 8628156283Srwatson # On all known operating systems, these are identical. 8629156283Srwatson dlname="$soname" 8630156283Srwatson fi 8631156283Srwatson fi 8632156283Srwatson ;; 8633156283Srwatson 8634156283Srwatson obj) 8635243750Srwatson if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 8636243750Srwatson func_warning "\`-dlopen' is ignored for objects" 8637243750Srwatson fi 8638243750Srwatson 8639191273Srwatson case " $deplibs" in 8640191273Srwatson *\ -l* | *\ -L*) 8641243750Srwatson func_warning "\`-l' and \`-L' are ignored for objects" ;; 8642191273Srwatson esac 8643156283Srwatson 8644243750Srwatson test -n "$rpath" && \ 8645243750Srwatson func_warning "\`-rpath' is ignored for objects" 8646156283Srwatson 8647243750Srwatson test -n "$xrpath" && \ 8648243750Srwatson func_warning "\`-R' is ignored for objects" 8649156283Srwatson 8650243750Srwatson test -n "$vinfo" && \ 8651243750Srwatson func_warning "\`-version-info' is ignored for objects" 8652156283Srwatson 8653243750Srwatson test -n "$release" && \ 8654243750Srwatson func_warning "\`-release' is ignored for objects" 8655156283Srwatson 8656156283Srwatson case $output in 8657156283Srwatson *.lo) 8658243750Srwatson test -n "$objs$old_deplibs" && \ 8659243750Srwatson func_fatal_error "cannot build library object \`$output' from non-libtool objects" 8660243750Srwatson 8661243750Srwatson libobj=$output 8662243750Srwatson func_lo2o "$libobj" 8663243750Srwatson obj=$func_lo2o_result 8664156283Srwatson ;; 8665156283Srwatson *) 8666156283Srwatson libobj= 8667156283Srwatson obj="$output" 8668156283Srwatson ;; 8669156283Srwatson esac 8670156283Srwatson 8671156283Srwatson # Delete the old objects. 8672243750Srwatson $opt_dry_run || $RM $obj $libobj 8673156283Srwatson 8674156283Srwatson # Objects from convenience libraries. This assumes 8675156283Srwatson # single-version convenience libraries. Whenever we create 8676156283Srwatson # different ones for PIC/non-PIC, this we'll have to duplicate 8677156283Srwatson # the extraction. 8678156283Srwatson reload_conv_objs= 8679156283Srwatson gentop= 8680156283Srwatson # reload_cmds runs $LD directly, so let us get rid of 8681173143Srwatson # -Wl from whole_archive_flag_spec and hope we can get by with 8682173143Srwatson # turning comma into space.. 8683156283Srwatson wl= 8684156283Srwatson 8685156283Srwatson if test -n "$convenience"; then 8686156283Srwatson if test -n "$whole_archive_flag_spec"; then 8687173143Srwatson eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 8688243750Srwatson reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 8689156283Srwatson else 8690156283Srwatson gentop="$output_objdir/${obj}x" 8691243750Srwatson func_append generated " $gentop" 8692156283Srwatson 8693156283Srwatson func_extract_archives $gentop $convenience 8694156283Srwatson reload_conv_objs="$reload_objs $func_extract_archives_result" 8695156283Srwatson fi 8696156283Srwatson fi 8697156283Srwatson 8698243750Srwatson # If we're not building shared, we need to use non_pic_objs 8699243750Srwatson test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8700243750Srwatson 8701156283Srwatson # Create the old-style object. 8702243750Srwatson reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8703156283Srwatson 8704156283Srwatson output="$obj" 8705243750Srwatson func_execute_cmds "$reload_cmds" 'exit $?' 8706156283Srwatson 8707156283Srwatson # Exit if we aren't doing a library object file. 8708156283Srwatson if test -z "$libobj"; then 8709156283Srwatson if test -n "$gentop"; then 8710243750Srwatson func_show_eval '${RM}r "$gentop"' 8711156283Srwatson fi 8712156283Srwatson 8713156283Srwatson exit $EXIT_SUCCESS 8714156283Srwatson fi 8715156283Srwatson 8716156283Srwatson if test "$build_libtool_libs" != yes; then 8717156283Srwatson if test -n "$gentop"; then 8718243750Srwatson func_show_eval '${RM}r "$gentop"' 8719156283Srwatson fi 8720156283Srwatson 8721156283Srwatson # Create an invalid libtool object if no PIC, so that we don't 8722156283Srwatson # accidentally link it into a program. 8723156283Srwatson # $show "echo timestamp > $libobj" 8724243750Srwatson # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 8725156283Srwatson exit $EXIT_SUCCESS 8726156283Srwatson fi 8727156283Srwatson 8728156283Srwatson if test -n "$pic_flag" || test "$pic_mode" != default; then 8729156283Srwatson # Only do commands if we really have different PIC objects. 8730156283Srwatson reload_objs="$libobjs $reload_conv_objs" 8731156283Srwatson output="$libobj" 8732243750Srwatson func_execute_cmds "$reload_cmds" 'exit $?' 8733156283Srwatson fi 8734156283Srwatson 8735156283Srwatson if test -n "$gentop"; then 8736243750Srwatson func_show_eval '${RM}r "$gentop"' 8737156283Srwatson fi 8738156283Srwatson 8739156283Srwatson exit $EXIT_SUCCESS 8740156283Srwatson ;; 8741156283Srwatson 8742156283Srwatson prog) 8743156283Srwatson case $host in 8744243750Srwatson *cygwin*) func_stripname '' '.exe' "$output" 8745243750Srwatson output=$func_stripname_result.exe;; 8746156283Srwatson esac 8747243750Srwatson test -n "$vinfo" && \ 8748243750Srwatson func_warning "\`-version-info' is ignored for programs" 8749156283Srwatson 8750243750Srwatson test -n "$release" && \ 8751243750Srwatson func_warning "\`-release' is ignored for programs" 8752156283Srwatson 8753243750Srwatson test "$preload" = yes \ 8754243750Srwatson && test "$dlopen_support" = unknown \ 8755243750Srwatson && test "$dlopen_self" = unknown \ 8756243750Srwatson && test "$dlopen_self_static" = unknown && \ 8757243750Srwatson func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 8758156283Srwatson 8759156283Srwatson case $host in 8760156283Srwatson *-*-rhapsody* | *-*-darwin1.[012]) 8761156283Srwatson # On Rhapsody replace the C library is the System framework 8762243750Srwatson compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 8763243750Srwatson finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8764156283Srwatson ;; 8765156283Srwatson esac 8766156283Srwatson 8767156283Srwatson case $host in 8768243750Srwatson *-*-darwin*) 8769243750Srwatson # Don't allow lazy linking, it breaks C++ global constructors 8770243750Srwatson # But is supposedly fixed on 10.4 or later (yay!). 8771243750Srwatson if test "$tagname" = CXX ; then 8772243750Srwatson case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 8773243750Srwatson 10.[0123]) 8774243750Srwatson func_append compile_command " ${wl}-bind_at_load" 8775243750Srwatson func_append finalize_command " ${wl}-bind_at_load" 8776243750Srwatson ;; 8777243750Srwatson esac 8778243750Srwatson fi 8779243750Srwatson # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8780243750Srwatson compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8781243750Srwatson finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8782243750Srwatson ;; 8783156283Srwatson esac 8784156283Srwatson 8785159985Srwatson 8786159985Srwatson # move library search paths that coincide with paths to not yet 8787159985Srwatson # installed libraries to the beginning of the library search list 8788159985Srwatson new_libs= 8789159985Srwatson for path in $notinst_path; do 8790159985Srwatson case " $new_libs " in 8791159985Srwatson *" -L$path/$objdir "*) ;; 8792159985Srwatson *) 8793159985Srwatson case " $compile_deplibs " in 8794159985Srwatson *" -L$path/$objdir "*) 8795243750Srwatson func_append new_libs " -L$path/$objdir" ;; 8796159985Srwatson esac 8797159985Srwatson ;; 8798159985Srwatson esac 8799159985Srwatson done 8800159985Srwatson for deplib in $compile_deplibs; do 8801159985Srwatson case $deplib in 8802159985Srwatson -L*) 8803159985Srwatson case " $new_libs " in 8804159985Srwatson *" $deplib "*) ;; 8805243750Srwatson *) func_append new_libs " $deplib" ;; 8806159985Srwatson esac 8807159985Srwatson ;; 8808243750Srwatson *) func_append new_libs " $deplib" ;; 8809159985Srwatson esac 8810159985Srwatson done 8811159985Srwatson compile_deplibs="$new_libs" 8812159985Srwatson 8813159985Srwatson 8814243750Srwatson func_append compile_command " $compile_deplibs" 8815243750Srwatson func_append finalize_command " $finalize_deplibs" 8816156283Srwatson 8817156283Srwatson if test -n "$rpath$xrpath"; then 8818156283Srwatson # If the user specified any rpath flags, then add them. 8819156283Srwatson for libdir in $rpath $xrpath; do 8820156283Srwatson # This is the magic to use -rpath. 8821156283Srwatson case "$finalize_rpath " in 8822156283Srwatson *" $libdir "*) ;; 8823243750Srwatson *) func_append finalize_rpath " $libdir" ;; 8824156283Srwatson esac 8825156283Srwatson done 8826156283Srwatson fi 8827156283Srwatson 8828156283Srwatson # Now hardcode the library paths 8829156283Srwatson rpath= 8830156283Srwatson hardcode_libdirs= 8831156283Srwatson for libdir in $compile_rpath $finalize_rpath; do 8832156283Srwatson if test -n "$hardcode_libdir_flag_spec"; then 8833156283Srwatson if test -n "$hardcode_libdir_separator"; then 8834156283Srwatson if test -z "$hardcode_libdirs"; then 8835156283Srwatson hardcode_libdirs="$libdir" 8836156283Srwatson else 8837156283Srwatson # Just accumulate the unique libdirs. 8838156283Srwatson case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8839156283Srwatson *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8840156283Srwatson ;; 8841156283Srwatson *) 8842243750Srwatson func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8843156283Srwatson ;; 8844156283Srwatson esac 8845156283Srwatson fi 8846156283Srwatson else 8847156283Srwatson eval flag=\"$hardcode_libdir_flag_spec\" 8848243750Srwatson func_append rpath " $flag" 8849156283Srwatson fi 8850156283Srwatson elif test -n "$runpath_var"; then 8851156283Srwatson case "$perm_rpath " in 8852156283Srwatson *" $libdir "*) ;; 8853243750Srwatson *) func_append perm_rpath " $libdir" ;; 8854156283Srwatson esac 8855156283Srwatson fi 8856156283Srwatson case $host in 8857243750Srwatson *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 8858243750Srwatson testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 8859156283Srwatson case :$dllsearchpath: in 8860156283Srwatson *":$libdir:"*) ;; 8861243750Srwatson ::) dllsearchpath=$libdir;; 8862243750Srwatson *) func_append dllsearchpath ":$libdir";; 8863156283Srwatson esac 8864159985Srwatson case :$dllsearchpath: in 8865159985Srwatson *":$testbindir:"*) ;; 8866243750Srwatson ::) dllsearchpath=$testbindir;; 8867243750Srwatson *) func_append dllsearchpath ":$testbindir";; 8868159985Srwatson esac 8869156283Srwatson ;; 8870156283Srwatson esac 8871156283Srwatson done 8872156283Srwatson # Substitute the hardcoded libdirs into the rpath. 8873156283Srwatson if test -n "$hardcode_libdir_separator" && 8874156283Srwatson test -n "$hardcode_libdirs"; then 8875156283Srwatson libdir="$hardcode_libdirs" 8876156283Srwatson eval rpath=\" $hardcode_libdir_flag_spec\" 8877156283Srwatson fi 8878156283Srwatson compile_rpath="$rpath" 8879156283Srwatson 8880156283Srwatson rpath= 8881156283Srwatson hardcode_libdirs= 8882156283Srwatson for libdir in $finalize_rpath; do 8883156283Srwatson if test -n "$hardcode_libdir_flag_spec"; then 8884156283Srwatson if test -n "$hardcode_libdir_separator"; then 8885156283Srwatson if test -z "$hardcode_libdirs"; then 8886156283Srwatson hardcode_libdirs="$libdir" 8887156283Srwatson else 8888156283Srwatson # Just accumulate the unique libdirs. 8889156283Srwatson case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8890156283Srwatson *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8891156283Srwatson ;; 8892156283Srwatson *) 8893243750Srwatson func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8894156283Srwatson ;; 8895156283Srwatson esac 8896156283Srwatson fi 8897156283Srwatson else 8898156283Srwatson eval flag=\"$hardcode_libdir_flag_spec\" 8899243750Srwatson func_append rpath " $flag" 8900156283Srwatson fi 8901156283Srwatson elif test -n "$runpath_var"; then 8902156283Srwatson case "$finalize_perm_rpath " in 8903156283Srwatson *" $libdir "*) ;; 8904243750Srwatson *) func_append finalize_perm_rpath " $libdir" ;; 8905156283Srwatson esac 8906156283Srwatson fi 8907156283Srwatson done 8908156283Srwatson # Substitute the hardcoded libdirs into the rpath. 8909156283Srwatson if test -n "$hardcode_libdir_separator" && 8910156283Srwatson test -n "$hardcode_libdirs"; then 8911156283Srwatson libdir="$hardcode_libdirs" 8912156283Srwatson eval rpath=\" $hardcode_libdir_flag_spec\" 8913156283Srwatson fi 8914156283Srwatson finalize_rpath="$rpath" 8915156283Srwatson 8916156283Srwatson if test -n "$libobjs" && test "$build_old_libs" = yes; then 8917156283Srwatson # Transform all the library objects into standard objects. 8918243750Srwatson compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8919243750Srwatson finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8920156283Srwatson fi 8921156283Srwatson 8922243750Srwatson func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8923156283Srwatson 8924243750Srwatson # template prelinking step 8925243750Srwatson if test -n "$prelink_cmds"; then 8926243750Srwatson func_execute_cmds "$prelink_cmds" 'exit $?' 8927156283Srwatson fi 8928156283Srwatson 8929243750Srwatson wrappers_required=yes 8930243750Srwatson case $host in 8931243750Srwatson *cegcc* | *mingw32ce*) 8932243750Srwatson # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 8933243750Srwatson wrappers_required=no 8934243750Srwatson ;; 8935243750Srwatson *cygwin* | *mingw* ) 8936243750Srwatson if test "$build_libtool_libs" != yes; then 8937243750Srwatson wrappers_required=no 8938243750Srwatson fi 8939243750Srwatson ;; 8940243750Srwatson *) 8941243750Srwatson if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8942243750Srwatson wrappers_required=no 8943243750Srwatson fi 8944243750Srwatson ;; 8945243750Srwatson esac 8946243750Srwatson if test "$wrappers_required" = no; then 8947156283Srwatson # Replace the output file specification. 8948243750Srwatson compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8949156283Srwatson link_command="$compile_command$compile_rpath" 8950156283Srwatson 8951156283Srwatson # We have no uninstalled library dependencies, so finalize right now. 8952243750Srwatson exit_status=0 8953243750Srwatson func_show_eval "$link_command" 'exit_status=$?' 8954156283Srwatson 8955243750Srwatson if test -n "$postlink_cmds"; then 8956243750Srwatson func_to_tool_file "$output" 8957243750Srwatson postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8958243750Srwatson func_execute_cmds "$postlink_cmds" 'exit $?' 8959243750Srwatson fi 8960243750Srwatson 8961156283Srwatson # Delete the generated files. 8962243750Srwatson if test -f "$output_objdir/${outputname}S.${objext}"; then 8963243750Srwatson func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8964156283Srwatson fi 8965156283Srwatson 8966159985Srwatson exit $exit_status 8967156283Srwatson fi 8968156283Srwatson 8969156283Srwatson if test -n "$compile_shlibpath$finalize_shlibpath"; then 8970156283Srwatson compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 8971156283Srwatson fi 8972156283Srwatson if test -n "$finalize_shlibpath"; then 8973156283Srwatson finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 8974156283Srwatson fi 8975156283Srwatson 8976156283Srwatson compile_var= 8977156283Srwatson finalize_var= 8978156283Srwatson if test -n "$runpath_var"; then 8979156283Srwatson if test -n "$perm_rpath"; then 8980156283Srwatson # We should set the runpath_var. 8981156283Srwatson rpath= 8982156283Srwatson for dir in $perm_rpath; do 8983243750Srwatson func_append rpath "$dir:" 8984156283Srwatson done 8985156283Srwatson compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8986156283Srwatson fi 8987156283Srwatson if test -n "$finalize_perm_rpath"; then 8988156283Srwatson # We should set the runpath_var. 8989156283Srwatson rpath= 8990156283Srwatson for dir in $finalize_perm_rpath; do 8991243750Srwatson func_append rpath "$dir:" 8992156283Srwatson done 8993156283Srwatson finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8994156283Srwatson fi 8995156283Srwatson fi 8996156283Srwatson 8997156283Srwatson if test "$no_install" = yes; then 8998156283Srwatson # We don't need to create a wrapper script. 8999156283Srwatson link_command="$compile_var$compile_command$compile_rpath" 9000156283Srwatson # Replace the output file specification. 9001243750Srwatson link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 9002156283Srwatson # Delete the old output file. 9003243750Srwatson $opt_dry_run || $RM $output 9004156283Srwatson # Link the executable and exit 9005243750Srwatson func_show_eval "$link_command" 'exit $?' 9006243750Srwatson 9007243750Srwatson if test -n "$postlink_cmds"; then 9008243750Srwatson func_to_tool_file "$output" 9009243750Srwatson postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 9010243750Srwatson func_execute_cmds "$postlink_cmds" 'exit $?' 9011243750Srwatson fi 9012243750Srwatson 9013156283Srwatson exit $EXIT_SUCCESS 9014156283Srwatson fi 9015156283Srwatson 9016156283Srwatson if test "$hardcode_action" = relink; then 9017156283Srwatson # Fast installation is not supported 9018156283Srwatson link_command="$compile_var$compile_command$compile_rpath" 9019156283Srwatson relink_command="$finalize_var$finalize_command$finalize_rpath" 9020156283Srwatson 9021243750Srwatson func_warning "this platform does not like uninstalled shared libraries" 9022243750Srwatson func_warning "\`$output' will be relinked during installation" 9023156283Srwatson else 9024156283Srwatson if test "$fast_install" != no; then 9025156283Srwatson link_command="$finalize_var$compile_command$finalize_rpath" 9026156283Srwatson if test "$fast_install" = yes; then 9027243750Srwatson relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 9028156283Srwatson else 9029156283Srwatson # fast_install is set to needless 9030156283Srwatson relink_command= 9031156283Srwatson fi 9032156283Srwatson else 9033156283Srwatson link_command="$compile_var$compile_command$compile_rpath" 9034156283Srwatson relink_command="$finalize_var$finalize_command$finalize_rpath" 9035156283Srwatson fi 9036156283Srwatson fi 9037156283Srwatson 9038156283Srwatson # Replace the output file specification. 9039243750Srwatson link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 9040156283Srwatson 9041156283Srwatson # Delete the old output files. 9042243750Srwatson $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 9043156283Srwatson 9044243750Srwatson func_show_eval "$link_command" 'exit $?' 9045156283Srwatson 9046243750Srwatson if test -n "$postlink_cmds"; then 9047243750Srwatson func_to_tool_file "$output_objdir/$outputname" 9048243750Srwatson 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'` 9049243750Srwatson func_execute_cmds "$postlink_cmds" 'exit $?' 9050243750Srwatson fi 9051243750Srwatson 9052156283Srwatson # Now create the wrapper script. 9053243750Srwatson func_verbose "creating $output" 9054156283Srwatson 9055156283Srwatson # Quote the relink command for shipping. 9056156283Srwatson if test -n "$relink_command"; then 9057156283Srwatson # Preserve any variables that may affect compiler behavior 9058156283Srwatson for var in $variables_saved_for_relink; do 9059156283Srwatson if eval test -z \"\${$var+set}\"; then 9060243750Srwatson relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9061156283Srwatson elif eval var_value=\$$var; test -z "$var_value"; then 9062156283Srwatson relink_command="$var=; export $var; $relink_command" 9063156283Srwatson else 9064243750Srwatson func_quote_for_eval "$var_value" 9065243750Srwatson relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9066156283Srwatson fi 9067156283Srwatson done 9068156283Srwatson relink_command="(cd `pwd`; $relink_command)" 9069243750Srwatson relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9070156283Srwatson fi 9071156283Srwatson 9072243750Srwatson # Only actually do things if not in dry run mode. 9073243750Srwatson $opt_dry_run || { 9074156283Srwatson # win32 will think the script is a binary if it has 9075156283Srwatson # a .exe suffix, so we strip it off here. 9076156283Srwatson case $output in 9077243750Srwatson *.exe) func_stripname '' '.exe' "$output" 9078243750Srwatson output=$func_stripname_result ;; 9079156283Srwatson esac 9080156283Srwatson # test for cygwin because mv fails w/o .exe extensions 9081156283Srwatson case $host in 9082156283Srwatson *cygwin*) 9083156283Srwatson exeext=.exe 9084243750Srwatson func_stripname '' '.exe' "$outputname" 9085243750Srwatson outputname=$func_stripname_result ;; 9086156283Srwatson *) exeext= ;; 9087156283Srwatson esac 9088156283Srwatson case $host in 9089156283Srwatson *cygwin* | *mingw* ) 9090243750Srwatson func_dirname_and_basename "$output" "" "." 9091243750Srwatson output_name=$func_basename_result 9092243750Srwatson output_path=$func_dirname_result 9093243750Srwatson cwrappersource="$output_path/$objdir/lt-$output_name.c" 9094243750Srwatson cwrapper="$output_path/$output_name.exe" 9095243750Srwatson $RM $cwrappersource $cwrapper 9096243750Srwatson trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 9097156283Srwatson 9098243750Srwatson func_emit_cwrapperexe_src > $cwrappersource 9099156283Srwatson 9100243750Srwatson # The wrapper executable is built using the $host compiler, 9101243750Srwatson # because it contains $host paths and files. If cross- 9102243750Srwatson # compiling, it, like the target executable, must be 9103243750Srwatson # executed on the $host or under an emulation environment. 9104243750Srwatson $opt_dry_run || { 9105243750Srwatson $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 9106243750Srwatson $STRIP $cwrapper 9107243750Srwatson } 9108156283Srwatson 9109243750Srwatson # Now, create the wrapper script for func_source use: 9110243750Srwatson func_ltwrapper_scriptname $cwrapper 9111243750Srwatson $RM $func_ltwrapper_scriptname_result 9112243750Srwatson trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 9113243750Srwatson $opt_dry_run || { 9114243750Srwatson # note: this script will not be executed, so do not chmod. 9115243750Srwatson if test "x$build" = "x$host" ; then 9116243750Srwatson $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 9117243750Srwatson else 9118243750Srwatson func_emit_wrapper no > $func_ltwrapper_scriptname_result 9119243750Srwatson fi 9120243750Srwatson } 9121156283Srwatson ;; 9122243750Srwatson * ) 9123243750Srwatson $RM $output 9124243750Srwatson trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9125156283Srwatson 9126243750Srwatson func_emit_wrapper no > $output 9127243750Srwatson chmod +x $output 9128156283Srwatson ;; 9129156283Srwatson esac 9130243750Srwatson } 9131156283Srwatson exit $EXIT_SUCCESS 9132156283Srwatson ;; 9133156283Srwatson esac 9134156283Srwatson 9135156283Srwatson # See if we need to build an old-fashioned archive. 9136156283Srwatson for oldlib in $oldlibs; do 9137156283Srwatson 9138156283Srwatson if test "$build_libtool_libs" = convenience; then 9139243750Srwatson oldobjs="$libobjs_save $symfileobj" 9140156283Srwatson addlibs="$convenience" 9141156283Srwatson build_libtool_libs=no 9142156283Srwatson else 9143156283Srwatson if test "$build_libtool_libs" = module; then 9144156283Srwatson oldobjs="$libobjs_save" 9145156283Srwatson build_libtool_libs=no 9146156283Srwatson else 9147156283Srwatson oldobjs="$old_deplibs $non_pic_objects" 9148243750Srwatson if test "$preload" = yes && test -f "$symfileobj"; then 9149243750Srwatson func_append oldobjs " $symfileobj" 9150243750Srwatson fi 9151156283Srwatson fi 9152156283Srwatson addlibs="$old_convenience" 9153156283Srwatson fi 9154156283Srwatson 9155156283Srwatson if test -n "$addlibs"; then 9156156283Srwatson gentop="$output_objdir/${outputname}x" 9157243750Srwatson func_append generated " $gentop" 9158156283Srwatson 9159156283Srwatson func_extract_archives $gentop $addlibs 9160243750Srwatson func_append oldobjs " $func_extract_archives_result" 9161156283Srwatson fi 9162156283Srwatson 9163156283Srwatson # Do each command in the archive commands. 9164156283Srwatson if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 9165243750Srwatson cmds=$old_archive_from_new_cmds 9166156283Srwatson else 9167243750Srwatson 9168243750Srwatson # Add any objects from preloaded convenience libraries 9169243750Srwatson if test -n "$dlprefiles"; then 9170243750Srwatson gentop="$output_objdir/${outputname}x" 9171243750Srwatson func_append generated " $gentop" 9172243750Srwatson 9173243750Srwatson func_extract_archives $gentop $dlprefiles 9174243750Srwatson func_append oldobjs " $func_extract_archives_result" 9175243750Srwatson fi 9176243750Srwatson 9177156283Srwatson # POSIX demands no paths to be encoded in archives. We have 9178156283Srwatson # to avoid creating archives with duplicate basenames if we 9179156283Srwatson # might have to extract them afterwards, e.g., when creating a 9180156283Srwatson # static archive out of a convenience library, or when linking 9181156283Srwatson # the entirety of a libtool archive into another (currently 9182156283Srwatson # not supported by libtool). 9183156283Srwatson if (for obj in $oldobjs 9184156283Srwatson do 9185243750Srwatson func_basename "$obj" 9186243750Srwatson $ECHO "$func_basename_result" 9187156283Srwatson done | sort | sort -uc >/dev/null 2>&1); then 9188156283Srwatson : 9189156283Srwatson else 9190243750Srwatson echo "copying selected object files to avoid basename conflicts..." 9191243750Srwatson gentop="$output_objdir/${outputname}x" 9192243750Srwatson func_append generated " $gentop" 9193243750Srwatson func_mkdir_p "$gentop" 9194156283Srwatson save_oldobjs=$oldobjs 9195156283Srwatson oldobjs= 9196156283Srwatson counter=1 9197156283Srwatson for obj in $save_oldobjs 9198156283Srwatson do 9199243750Srwatson func_basename "$obj" 9200243750Srwatson objbase="$func_basename_result" 9201156283Srwatson case " $oldobjs " in 9202156283Srwatson " ") oldobjs=$obj ;; 9203156283Srwatson *[\ /]"$objbase "*) 9204156283Srwatson while :; do 9205156283Srwatson # Make sure we don't pick an alternate name that also 9206156283Srwatson # overlaps. 9207156283Srwatson newobj=lt$counter-$objbase 9208243750Srwatson func_arith $counter + 1 9209243750Srwatson counter=$func_arith_result 9210156283Srwatson case " $oldobjs " in 9211156283Srwatson *[\ /]"$newobj "*) ;; 9212156283Srwatson *) if test ! -f "$gentop/$newobj"; then break; fi ;; 9213156283Srwatson esac 9214156283Srwatson done 9215243750Srwatson func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 9216243750Srwatson func_append oldobjs " $gentop/$newobj" 9217156283Srwatson ;; 9218243750Srwatson *) func_append oldobjs " $obj" ;; 9219156283Srwatson esac 9220156283Srwatson done 9221156283Srwatson fi 9222243750Srwatson func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 9223243750Srwatson tool_oldlib=$func_to_tool_file_result 9224156283Srwatson eval cmds=\"$old_archive_cmds\" 9225156283Srwatson 9226243750Srwatson func_len " $cmds" 9227243750Srwatson len=$func_len_result 9228243750Srwatson if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9229156283Srwatson cmds=$old_archive_cmds 9230243750Srwatson elif test -n "$archiver_list_spec"; then 9231243750Srwatson func_verbose "using command file archive linking..." 9232243750Srwatson for obj in $oldobjs 9233243750Srwatson do 9234243750Srwatson func_to_tool_file "$obj" 9235243750Srwatson $ECHO "$func_to_tool_file_result" 9236243750Srwatson done > $output_objdir/$libname.libcmd 9237243750Srwatson func_to_tool_file "$output_objdir/$libname.libcmd" 9238243750Srwatson oldobjs=" $archiver_list_spec$func_to_tool_file_result" 9239243750Srwatson cmds=$old_archive_cmds 9240156283Srwatson else 9241156283Srwatson # the command line is too long to link in one step, link in parts 9242243750Srwatson func_verbose "using piecewise archive linking..." 9243156283Srwatson save_RANLIB=$RANLIB 9244156283Srwatson RANLIB=: 9245156283Srwatson objlist= 9246156283Srwatson concat_cmds= 9247156283Srwatson save_oldobjs=$oldobjs 9248243750Srwatson oldobjs= 9249156283Srwatson # Is there a better way of finding the last object in the list? 9250156283Srwatson for obj in $save_oldobjs 9251156283Srwatson do 9252156283Srwatson last_oldobj=$obj 9253156283Srwatson done 9254243750Srwatson eval test_cmds=\"$old_archive_cmds\" 9255243750Srwatson func_len " $test_cmds" 9256243750Srwatson len0=$func_len_result 9257243750Srwatson len=$len0 9258156283Srwatson for obj in $save_oldobjs 9259156283Srwatson do 9260243750Srwatson func_len " $obj" 9261243750Srwatson func_arith $len + $func_len_result 9262243750Srwatson len=$func_arith_result 9263243750Srwatson func_append objlist " $obj" 9264243750Srwatson if test "$len" -lt "$max_cmd_len"; then 9265156283Srwatson : 9266156283Srwatson else 9267156283Srwatson # the above command should be used before it gets too long 9268156283Srwatson oldobjs=$objlist 9269156283Srwatson if test "$obj" = "$last_oldobj" ; then 9270243750Srwatson RANLIB=$save_RANLIB 9271156283Srwatson fi 9272156283Srwatson test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9273156283Srwatson eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 9274156283Srwatson objlist= 9275243750Srwatson len=$len0 9276156283Srwatson fi 9277156283Srwatson done 9278156283Srwatson RANLIB=$save_RANLIB 9279156283Srwatson oldobjs=$objlist 9280156283Srwatson if test "X$oldobjs" = "X" ; then 9281156283Srwatson eval cmds=\"\$concat_cmds\" 9282156283Srwatson else 9283156283Srwatson eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 9284156283Srwatson fi 9285156283Srwatson fi 9286156283Srwatson fi 9287243750Srwatson func_execute_cmds "$cmds" 'exit $?' 9288156283Srwatson done 9289156283Srwatson 9290243750Srwatson test -n "$generated" && \ 9291243750Srwatson func_show_eval "${RM}r$generated" 9292156283Srwatson 9293156283Srwatson # Now create the libtool archive. 9294156283Srwatson case $output in 9295156283Srwatson *.la) 9296156283Srwatson old_library= 9297156283Srwatson test "$build_old_libs" = yes && old_library="$libname.$libext" 9298243750Srwatson func_verbose "creating $output" 9299156283Srwatson 9300156283Srwatson # Preserve any variables that may affect compiler behavior 9301156283Srwatson for var in $variables_saved_for_relink; do 9302156283Srwatson if eval test -z \"\${$var+set}\"; then 9303243750Srwatson relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9304156283Srwatson elif eval var_value=\$$var; test -z "$var_value"; then 9305156283Srwatson relink_command="$var=; export $var; $relink_command" 9306156283Srwatson else 9307243750Srwatson func_quote_for_eval "$var_value" 9308243750Srwatson relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9309156283Srwatson fi 9310156283Srwatson done 9311156283Srwatson # Quote the link command for shipping. 9312156283Srwatson relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 9313243750Srwatson relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9314156283Srwatson if test "$hardcode_automatic" = yes ; then 9315156283Srwatson relink_command= 9316156283Srwatson fi 9317156283Srwatson 9318156283Srwatson # Only create the output if not a dry run. 9319243750Srwatson $opt_dry_run || { 9320156283Srwatson for installed in no yes; do 9321156283Srwatson if test "$installed" = yes; then 9322156283Srwatson if test -z "$install_libdir"; then 9323156283Srwatson break 9324156283Srwatson fi 9325156283Srwatson output="$output_objdir/$outputname"i 9326156283Srwatson # Replace all uninstalled libtool libraries with the installed ones 9327156283Srwatson newdependency_libs= 9328156283Srwatson for deplib in $dependency_libs; do 9329156283Srwatson case $deplib in 9330156283Srwatson *.la) 9331243750Srwatson func_basename "$deplib" 9332243750Srwatson name="$func_basename_result" 9333243750Srwatson func_resolve_sysroot "$deplib" 9334243750Srwatson eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 9335243750Srwatson test -z "$libdir" && \ 9336243750Srwatson func_fatal_error "\`$deplib' is not a valid libtool archive" 9337243750Srwatson func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 9338156283Srwatson ;; 9339243750Srwatson -L*) 9340243750Srwatson func_stripname -L '' "$deplib" 9341243750Srwatson func_replace_sysroot "$func_stripname_result" 9342243750Srwatson func_append newdependency_libs " -L$func_replace_sysroot_result" 9343243750Srwatson ;; 9344243750Srwatson -R*) 9345243750Srwatson func_stripname -R '' "$deplib" 9346243750Srwatson func_replace_sysroot "$func_stripname_result" 9347243750Srwatson func_append newdependency_libs " -R$func_replace_sysroot_result" 9348243750Srwatson ;; 9349243750Srwatson *) func_append newdependency_libs " $deplib" ;; 9350156283Srwatson esac 9351156283Srwatson done 9352156283Srwatson dependency_libs="$newdependency_libs" 9353156283Srwatson newdlfiles= 9354243750Srwatson 9355156283Srwatson for lib in $dlfiles; do 9356243750Srwatson case $lib in 9357243750Srwatson *.la) 9358243750Srwatson func_basename "$lib" 9359243750Srwatson name="$func_basename_result" 9360243750Srwatson eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9361243750Srwatson test -z "$libdir" && \ 9362243750Srwatson func_fatal_error "\`$lib' is not a valid libtool archive" 9363243750Srwatson func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 9364243750Srwatson ;; 9365243750Srwatson *) func_append newdlfiles " $lib" ;; 9366243750Srwatson esac 9367156283Srwatson done 9368156283Srwatson dlfiles="$newdlfiles" 9369156283Srwatson newdlprefiles= 9370156283Srwatson for lib in $dlprefiles; do 9371243750Srwatson case $lib in 9372243750Srwatson *.la) 9373243750Srwatson # Only pass preopened files to the pseudo-archive (for 9374243750Srwatson # eventual linking with the app. that links it) if we 9375243750Srwatson # didn't already link the preopened objects directly into 9376243750Srwatson # the library: 9377243750Srwatson func_basename "$lib" 9378243750Srwatson name="$func_basename_result" 9379243750Srwatson eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9380243750Srwatson test -z "$libdir" && \ 9381243750Srwatson func_fatal_error "\`$lib' is not a valid libtool archive" 9382243750Srwatson func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 9383243750Srwatson ;; 9384243750Srwatson esac 9385156283Srwatson done 9386156283Srwatson dlprefiles="$newdlprefiles" 9387156283Srwatson else 9388156283Srwatson newdlfiles= 9389156283Srwatson for lib in $dlfiles; do 9390156283Srwatson case $lib in 9391156283Srwatson [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9392156283Srwatson *) abs=`pwd`"/$lib" ;; 9393156283Srwatson esac 9394243750Srwatson func_append newdlfiles " $abs" 9395156283Srwatson done 9396156283Srwatson dlfiles="$newdlfiles" 9397156283Srwatson newdlprefiles= 9398156283Srwatson for lib in $dlprefiles; do 9399156283Srwatson case $lib in 9400156283Srwatson [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9401156283Srwatson *) abs=`pwd`"/$lib" ;; 9402156283Srwatson esac 9403243750Srwatson func_append newdlprefiles " $abs" 9404156283Srwatson done 9405156283Srwatson dlprefiles="$newdlprefiles" 9406156283Srwatson fi 9407243750Srwatson $RM $output 9408156283Srwatson # place dlname in correct position for cygwin 9409243750Srwatson # In fact, it would be nice if we could use this code for all target 9410243750Srwatson # systems that can't hard-code library paths into their executables 9411243750Srwatson # and that have no shared library path variable independent of PATH, 9412243750Srwatson # but it turns out we can't easily determine that from inspecting 9413243750Srwatson # libtool variables, so we have to hard-code the OSs to which it 9414243750Srwatson # applies here; at the moment, that means platforms that use the PE 9415243750Srwatson # object format with DLL files. See the long comment at the top of 9416243750Srwatson # tests/bindir.at for full details. 9417156283Srwatson tdlname=$dlname 9418156283Srwatson case $host,$output,$installed,$module,$dlname in 9419243750Srwatson *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 9420243750Srwatson # If a -bindir argument was supplied, place the dll there. 9421243750Srwatson if test "x$bindir" != x ; 9422243750Srwatson then 9423243750Srwatson func_relative_path "$install_libdir" "$bindir" 9424243750Srwatson tdlname=$func_relative_path_result$dlname 9425243750Srwatson else 9426243750Srwatson # Otherwise fall back on heuristic. 9427243750Srwatson tdlname=../bin/$dlname 9428243750Srwatson fi 9429243750Srwatson ;; 9430156283Srwatson esac 9431243750Srwatson $ECHO > $output "\ 9432156283Srwatson# $outputname - a libtool library file 9433243750Srwatson# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 9434156283Srwatson# 9435156283Srwatson# Please DO NOT delete this file! 9436156283Srwatson# It is necessary for linking the library. 9437156283Srwatson 9438156283Srwatson# The name that we can dlopen(3). 9439156283Srwatsondlname='$tdlname' 9440156283Srwatson 9441156283Srwatson# Names of this library. 9442156283Srwatsonlibrary_names='$library_names' 9443156283Srwatson 9444156283Srwatson# The name of the static archive. 9445156283Srwatsonold_library='$old_library' 9446156283Srwatson 9447243750Srwatson# Linker flags that can not go in dependency_libs. 9448243750Srwatsoninherited_linker_flags='$new_inherited_linker_flags' 9449243750Srwatson 9450156283Srwatson# Libraries that this one depends upon. 9451156283Srwatsondependency_libs='$dependency_libs' 9452156283Srwatson 9453243750Srwatson# Names of additional weak libraries provided by this library 9454243750Srwatsonweak_library_names='$weak_libs' 9455243750Srwatson 9456156283Srwatson# Version information for $libname. 9457156283Srwatsoncurrent=$current 9458156283Srwatsonage=$age 9459156283Srwatsonrevision=$revision 9460156283Srwatson 9461156283Srwatson# Is this an already installed library? 9462156283Srwatsoninstalled=$installed 9463156283Srwatson 9464156283Srwatson# Should we warn about portability when linking against -modules? 9465156283Srwatsonshouldnotlink=$module 9466156283Srwatson 9467156283Srwatson# Files to dlopen/dlpreopen 9468156283Srwatsondlopen='$dlfiles' 9469156283Srwatsondlpreopen='$dlprefiles' 9470156283Srwatson 9471156283Srwatson# Directory that this library needs to be installed in: 9472156283Srwatsonlibdir='$install_libdir'" 9473156283Srwatson if test "$installed" = no && test "$need_relink" = yes; then 9474243750Srwatson $ECHO >> $output "\ 9475156283Srwatsonrelink_command=\"$relink_command\"" 9476156283Srwatson fi 9477156283Srwatson done 9478243750Srwatson } 9479156283Srwatson 9480156283Srwatson # Do a symbolic link so that the libtool archive can be found in 9481156283Srwatson # LD_LIBRARY_PATH before the program is installed. 9482243750Srwatson func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 9483156283Srwatson ;; 9484156283Srwatson esac 9485156283Srwatson exit $EXIT_SUCCESS 9486243750Srwatson} 9487156283Srwatson 9488243750Srwatson{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 9489243750Srwatson func_mode_link ${1+"$@"} 9490156283Srwatson 9491156283Srwatson 9492243750Srwatson# func_mode_uninstall arg... 9493243750Srwatsonfunc_mode_uninstall () 9494243750Srwatson{ 9495243750Srwatson $opt_debug 9496243750Srwatson RM="$nonopt" 9497156283Srwatson files= 9498156283Srwatson rmforce= 9499156283Srwatson exit_status=0 9500156283Srwatson 9501156283Srwatson # This variable tells wrapper scripts just to set variables rather 9502156283Srwatson # than running their programs. 9503156283Srwatson libtool_install_magic="$magic" 9504156283Srwatson 9505156283Srwatson for arg 9506156283Srwatson do 9507156283Srwatson case $arg in 9508243750Srwatson -f) func_append RM " $arg"; rmforce=yes ;; 9509243750Srwatson -*) func_append RM " $arg" ;; 9510243750Srwatson *) func_append files " $arg" ;; 9511156283Srwatson esac 9512156283Srwatson done 9513156283Srwatson 9514243750Srwatson test -z "$RM" && \ 9515243750Srwatson func_fatal_help "you must specify an RM program" 9516156283Srwatson 9517156283Srwatson rmdirs= 9518156283Srwatson 9519156283Srwatson for file in $files; do 9520243750Srwatson func_dirname "$file" "" "." 9521243750Srwatson dir="$func_dirname_result" 9522243750Srwatson if test "X$dir" = X.; then 9523243750Srwatson odir="$objdir" 9524156283Srwatson else 9525243750Srwatson odir="$dir/$objdir" 9526156283Srwatson fi 9527243750Srwatson func_basename "$file" 9528243750Srwatson name="$func_basename_result" 9529243750Srwatson test "$opt_mode" = uninstall && odir="$dir" 9530156283Srwatson 9531243750Srwatson # Remember odir for removal later, being careful to avoid duplicates 9532243750Srwatson if test "$opt_mode" = clean; then 9533156283Srwatson case " $rmdirs " in 9534243750Srwatson *" $odir "*) ;; 9535243750Srwatson *) func_append rmdirs " $odir" ;; 9536156283Srwatson esac 9537156283Srwatson fi 9538156283Srwatson 9539156283Srwatson # Don't error if the file doesn't exist and rm -f was used. 9540243750Srwatson if { test -L "$file"; } >/dev/null 2>&1 || 9541243750Srwatson { test -h "$file"; } >/dev/null 2>&1 || 9542243750Srwatson test -f "$file"; then 9543156283Srwatson : 9544156283Srwatson elif test -d "$file"; then 9545156283Srwatson exit_status=1 9546156283Srwatson continue 9547156283Srwatson elif test "$rmforce" = yes; then 9548156283Srwatson continue 9549156283Srwatson fi 9550156283Srwatson 9551156283Srwatson rmfiles="$file" 9552156283Srwatson 9553156283Srwatson case $name in 9554156283Srwatson *.la) 9555156283Srwatson # Possibly a libtool archive, so verify it. 9556243750Srwatson if func_lalib_p "$file"; then 9557243750Srwatson func_source $dir/$name 9558156283Srwatson 9559156283Srwatson # Delete the libtool libraries and symlinks. 9560156283Srwatson for n in $library_names; do 9561243750Srwatson func_append rmfiles " $odir/$n" 9562156283Srwatson done 9563243750Srwatson test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9564156283Srwatson 9565243750Srwatson case "$opt_mode" in 9566159985Srwatson clean) 9567243750Srwatson case " $library_names " in 9568159985Srwatson *" $dlname "*) ;; 9569243750Srwatson *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9570159985Srwatson esac 9571243750Srwatson test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9572159985Srwatson ;; 9573159985Srwatson uninstall) 9574156283Srwatson if test -n "$library_names"; then 9575156283Srwatson # Do each command in the postuninstall commands. 9576243750Srwatson func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9577156283Srwatson fi 9578156283Srwatson 9579156283Srwatson if test -n "$old_library"; then 9580156283Srwatson # Do each command in the old_postuninstall commands. 9581243750Srwatson func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9582156283Srwatson fi 9583156283Srwatson # FIXME: should reinstall the best remaining shared library. 9584159985Srwatson ;; 9585159985Srwatson esac 9586156283Srwatson fi 9587156283Srwatson ;; 9588156283Srwatson 9589156283Srwatson *.lo) 9590156283Srwatson # Possibly a libtool object, so verify it. 9591243750Srwatson if func_lalib_p "$file"; then 9592156283Srwatson 9593156283Srwatson # Read the .lo file 9594243750Srwatson func_source $dir/$name 9595156283Srwatson 9596156283Srwatson # Add PIC object to the list of files to remove. 9597243750Srwatson if test -n "$pic_object" && 9598243750Srwatson test "$pic_object" != none; then 9599243750Srwatson func_append rmfiles " $dir/$pic_object" 9600156283Srwatson fi 9601156283Srwatson 9602156283Srwatson # Add non-PIC object to the list of files to remove. 9603243750Srwatson if test -n "$non_pic_object" && 9604243750Srwatson test "$non_pic_object" != none; then 9605243750Srwatson func_append rmfiles " $dir/$non_pic_object" 9606156283Srwatson fi 9607156283Srwatson fi 9608156283Srwatson ;; 9609156283Srwatson 9610156283Srwatson *) 9611243750Srwatson if test "$opt_mode" = clean ; then 9612156283Srwatson noexename=$name 9613156283Srwatson case $file in 9614156283Srwatson *.exe) 9615243750Srwatson func_stripname '' '.exe' "$file" 9616243750Srwatson file=$func_stripname_result 9617243750Srwatson func_stripname '' '.exe' "$name" 9618243750Srwatson noexename=$func_stripname_result 9619156283Srwatson # $file with .exe has already been added to rmfiles, 9620156283Srwatson # add $file without .exe 9621243750Srwatson func_append rmfiles " $file" 9622156283Srwatson ;; 9623156283Srwatson esac 9624156283Srwatson # Do a test to see if this is a libtool program. 9625243750Srwatson if func_ltwrapper_p "$file"; then 9626243750Srwatson if func_ltwrapper_executable_p "$file"; then 9627243750Srwatson func_ltwrapper_scriptname "$file" 9628243750Srwatson relink_command= 9629243750Srwatson func_source $func_ltwrapper_scriptname_result 9630243750Srwatson func_append rmfiles " $func_ltwrapper_scriptname_result" 9631243750Srwatson else 9632243750Srwatson relink_command= 9633243750Srwatson func_source $dir/$noexename 9634243750Srwatson fi 9635156283Srwatson 9636156283Srwatson # note $name still contains .exe if it was in $file originally 9637156283Srwatson # as does the version of $file that was added into $rmfiles 9638243750Srwatson func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9639156283Srwatson if test "$fast_install" = yes && test -n "$relink_command"; then 9640243750Srwatson func_append rmfiles " $odir/lt-$name" 9641156283Srwatson fi 9642156283Srwatson if test "X$noexename" != "X$name" ; then 9643243750Srwatson func_append rmfiles " $odir/lt-${noexename}.c" 9644156283Srwatson fi 9645156283Srwatson fi 9646156283Srwatson fi 9647156283Srwatson ;; 9648156283Srwatson esac 9649243750Srwatson func_show_eval "$RM $rmfiles" 'exit_status=1' 9650156283Srwatson done 9651156283Srwatson 9652156283Srwatson # Try to remove the ${objdir}s in the directories where we deleted files 9653156283Srwatson for dir in $rmdirs; do 9654156283Srwatson if test -d "$dir"; then 9655243750Srwatson func_show_eval "rmdir $dir >/dev/null 2>&1" 9656156283Srwatson fi 9657156283Srwatson done 9658156283Srwatson 9659156283Srwatson exit $exit_status 9660243750Srwatson} 9661156283Srwatson 9662243750Srwatson{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 9663243750Srwatson func_mode_uninstall ${1+"$@"} 9664156283Srwatson 9665243750Srwatsontest -z "$opt_mode" && { 9666243750Srwatson help="$generic_help" 9667243750Srwatson func_fatal_help "you must specify a MODE" 9668243750Srwatson} 9669156283Srwatson 9670243750Srwatsontest -z "$exec_cmd" && \ 9671243750Srwatson func_fatal_help "invalid operation mode \`$opt_mode'" 9672243750Srwatson 9673156283Srwatsonif test -n "$exec_cmd"; then 9674243750Srwatson eval exec "$exec_cmd" 9675156283Srwatson exit $EXIT_FAILURE 9676156283Srwatsonfi 9677156283Srwatson 9678243750Srwatsonexit $exit_status 9679156283Srwatson 9680156283Srwatson 9681156283Srwatson# The TAGs below are defined such that we never get into a situation 9682156283Srwatson# in which we disable both kinds of libraries. Given conflicting 9683156283Srwatson# choices, we go for a static library, that is the most portable, 9684156283Srwatson# since we can't tell whether shared libraries were disabled because 9685156283Srwatson# the user asked for that or because the platform doesn't support 9686156283Srwatson# them. This is particularly important on AIX, because we don't 9687156283Srwatson# support having both static and shared libraries enabled at the same 9688156283Srwatson# time on that platform, so we default to a shared-only configuration. 9689156283Srwatson# If a disable-shared tag is given, we'll fallback to a static-only 9690156283Srwatson# configuration. But we'll never go from static-only to shared-only. 9691156283Srwatson 9692156283Srwatson# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 9693243750Srwatsonbuild_libtool_libs=no 9694243750Srwatsonbuild_old_libs=yes 9695156283Srwatson# ### END LIBTOOL TAG CONFIG: disable-shared 9696156283Srwatson 9697156283Srwatson# ### BEGIN LIBTOOL TAG CONFIG: disable-static 9698243750Srwatsonbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9699156283Srwatson# ### END LIBTOOL TAG CONFIG: disable-static 9700156283Srwatson 9701156283Srwatson# Local Variables: 9702156283Srwatson# mode:shell-script 9703156283Srwatson# sh-indentation:2 9704156283Srwatson# End: 9705243750Srwatson# vi:sw=2 9706243750Srwatson 9707