1233294Sstas 2233294Sstas# libtool (GNU libtool) 2.4 3233294Sstas# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 4233294Sstas 5233294Sstas# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 6233294Sstas# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 7233294Sstas# This is free software; see the source for copying conditions. There is NO 8233294Sstas# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9233294Sstas 10233294Sstas# GNU Libtool is free software; you can redistribute it and/or modify 1155682Smarkm# it under the terms of the GNU General Public License as published by 1255682Smarkm# the Free Software Foundation; either version 2 of the License, or 1355682Smarkm# (at your option) any later version. 1455682Smarkm# 15233294Sstas# As a special exception to the GNU General Public License, 16233294Sstas# if you distribute this file as part of a program or library that 17233294Sstas# is built using GNU Libtool, you may include this file under the 18233294Sstas# same distribution terms that you use for the rest of that program. 19233294Sstas# 20233294Sstas# GNU Libtool is distributed in the hope that it will be useful, but 2155682Smarkm# WITHOUT ANY WARRANTY; without even the implied warranty of 2255682Smarkm# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2355682Smarkm# General Public License for more details. 2455682Smarkm# 2555682Smarkm# You should have received a copy of the GNU General Public License 26233294Sstas# along with GNU Libtool; see the file COPYING. If not, a copy 27233294Sstas# can be downloaded from http://www.gnu.org/licenses/gpl.html, 28233294Sstas# or obtained by writing to the Free Software Foundation, Inc., 29233294Sstas# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30233294Sstas 31233294Sstas# Usage: $progname [OPTION]... [MODE-ARG]... 3255682Smarkm# 33233294Sstas# Provide generalized library-building support services. 34233294Sstas# 35233294Sstas# --config show all configuration variables 36233294Sstas# --debug enable verbose shell tracing 37233294Sstas# -n, --dry-run display commands without modifying any files 38233294Sstas# --features display basic configuration information and exit 39233294Sstas# --mode=MODE use operation mode MODE 40233294Sstas# --preserve-dup-deps don't remove duplicate dependency libraries 41233294Sstas# --quiet, --silent don't print informational messages 42233294Sstas# --no-quiet, --no-silent 43233294Sstas# print informational messages (default) 44233294Sstas# --tag=TAG use configuration variables from tag TAG 45233294Sstas# -v, --verbose print more informational messages than default 46233294Sstas# --no-verbose don't print the extra informational messages 47233294Sstas# --version print version information 48233294Sstas# -h, --help, --help-all print short, long, or detailed help message 49233294Sstas# 50233294Sstas# MODE must be one of the following: 51233294Sstas# 52233294Sstas# clean remove files from the build directory 53233294Sstas# compile compile a source file into a libtool object 54233294Sstas# execute automatically set library path, then run a program 55233294Sstas# finish complete the installation of libtool libraries 56233294Sstas# install install libraries or executables 57233294Sstas# link create a library or an executable 58233294Sstas# uninstall remove libraries from an installed directory 59233294Sstas# 60233294Sstas# MODE-ARGS vary depending on the MODE. When passed as first option, 61233294Sstas# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 62233294Sstas# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 63233294Sstas# 64233294Sstas# When reporting a bug, please describe a test case to reproduce it and 65233294Sstas# include the following information: 66233294Sstas# 67233294Sstas# host-triplet: $host 68233294Sstas# shell: $SHELL 69233294Sstas# compiler: $LTCC 70233294Sstas# compiler flags: $LTCFLAGS 71233294Sstas# linker: $LD (gnu? $with_gnu_ld) 72233294Sstas# $progname: (GNU libtool) 2.4 73233294Sstas# automake: $automake_version 74233294Sstas# autoconf: $autoconf_version 75233294Sstas# 76233294Sstas# Report bugs to <bug-libtool@gnu.org>. 77233294Sstas# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 78233294Sstas# General help using GNU software: <http://www.gnu.org/gethelp/>. 7955682Smarkm 80233294SstasPROGRAM=libtool 81233294SstasPACKAGE=libtool 82233294SstasVERSION=2.4 83233294SstasTIMESTAMP="" 84233294Sstaspackage_revision=1.3293 85178825Sdfr 86233294Sstas# Be Bourne compatible 87233294Sstasif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 88233294Sstas emulate sh 89233294Sstas NULLCMD=: 90233294Sstas # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 91233294Sstas # is contrary to our usage. Disable this feature. 92233294Sstas alias -g '${1+"$@"}'='"$@"' 93233294Sstas setopt NO_GLOB_SUBST 94233294Sstaselse 95233294Sstas case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 96233294Sstasfi 97233294SstasBIN_SH=xpg4; export BIN_SH # for Tru64 98233294SstasDUALCASE=1; export DUALCASE # for MKS sh 99233294Sstas 100233294Sstas# A function that is used when there is no print builtin or printf. 101233294Sstasfunc_fallback_echo () 102233294Sstas{ 103233294Sstas eval 'cat <<_LTECHO_EOF 104233294Sstas$1 105233294Sstas_LTECHO_EOF' 106233294Sstas} 107233294Sstas 108233294Sstas# NLS nuisances: We save the old values to restore during execute mode. 109233294Sstaslt_user_locale= 110233294Sstaslt_safe_locale= 111233294Sstasfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 112233294Sstasdo 113233294Sstas eval "if test \"\${$lt_var+set}\" = set; then 114233294Sstas save_$lt_var=\$$lt_var 115233294Sstas $lt_var=C 116233294Sstas export $lt_var 117233294Sstas lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 118233294Sstas lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 119233294Sstas fi" 120233294Sstasdone 121233294SstasLC_ALL=C 122233294SstasLANGUAGE=C 123233294Sstasexport LANGUAGE LC_ALL 124233294Sstas 125233294Sstas$lt_unset CDPATH 126233294Sstas 127233294Sstas 128178825Sdfr# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 129178825Sdfr# is ksh but when the shell is invoked as "sh" and the current value of 130178825Sdfr# the _XPG environment variable is not equal to 1 (one), the special 131178825Sdfr# positional parameter $0, within a function call, is the name of the 132178825Sdfr# function. 133178825Sdfrprogpath="$0" 134178825Sdfr 135178825Sdfr 136233294Sstas 137233294Sstas: ${CP="cp -f"} 138233294Sstastest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 139233294Sstas: ${EGREP="grep -E"} 140233294Sstas: ${FGREP="grep -F"} 141233294Sstas: ${GREP="grep"} 142233294Sstas: ${LN_S="ln -s"} 143233294Sstas: ${MAKE="make"} 144233294Sstas: ${MKDIR="mkdir"} 145233294Sstas: ${MV="mv -f"} 146233294Sstas: ${RM="rm -f"} 147233294Sstas: ${SED="sed"} 148233294Sstas: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 149233294Sstas: ${Xsed="$SED -e 1s/^X//"} 150233294Sstas 151178825Sdfr# Global variables: 152178825SdfrEXIT_SUCCESS=0 153178825SdfrEXIT_FAILURE=1 154233294SstasEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 155233294SstasEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 156178825Sdfr 157233294Sstasexit_status=$EXIT_SUCCESS 158178825Sdfr 159233294Sstas# Make sure IFS has a sensible default 160233294Sstaslt_nl=' 161233294Sstas' 162233294SstasIFS=" $lt_nl" 163178825Sdfr 164233294Sstasdirname="s,/[^/]*$,," 165233294Sstasbasename="s,^.*/,," 16655682Smarkm 167233294Sstas# func_dirname file append nondir_replacement 168233294Sstas# Compute the dirname of FILE. If nonempty, add APPEND to the result, 169233294Sstas# otherwise set result to NONDIR_REPLACEMENT. 170233294Sstasfunc_dirname () 171233294Sstas{ 172233294Sstas func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 173233294Sstas if test "X$func_dirname_result" = "X${1}"; then 174233294Sstas func_dirname_result="${3}" 175233294Sstas else 176233294Sstas func_dirname_result="$func_dirname_result${2}" 177233294Sstas fi 178233294Sstas} # func_dirname may be replaced by extended shell implementation 17972445Sassar 18055682Smarkm 181233294Sstas# func_basename file 182233294Sstasfunc_basename () 183233294Sstas{ 184233294Sstas func_basename_result=`$ECHO "${1}" | $SED "$basename"` 185233294Sstas} # func_basename may be replaced by extended shell implementation 186233294Sstas 187233294Sstas 188233294Sstas# func_dirname_and_basename file append nondir_replacement 189233294Sstas# perform func_basename and func_dirname in a single function 190233294Sstas# call: 191233294Sstas# dirname: Compute the dirname of FILE. If nonempty, 192233294Sstas# add APPEND to the result, otherwise set result 193233294Sstas# to NONDIR_REPLACEMENT. 194233294Sstas# value returned in "$func_dirname_result" 195233294Sstas# basename: Compute filename of FILE. 196233294Sstas# value retuned in "$func_basename_result" 197233294Sstas# Implementation must be kept synchronized with func_dirname 198233294Sstas# and func_basename. For efficiency, we do not delegate to 199233294Sstas# those functions but instead duplicate the functionality here. 200233294Sstasfunc_dirname_and_basename () 201233294Sstas{ 202233294Sstas # Extract subdirectory from the argument. 203233294Sstas func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 204233294Sstas if test "X$func_dirname_result" = "X${1}"; then 205233294Sstas func_dirname_result="${3}" 206233294Sstas else 207233294Sstas func_dirname_result="$func_dirname_result${2}" 208233294Sstas fi 209233294Sstas func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 210233294Sstas} # func_dirname_and_basename may be replaced by extended shell implementation 211233294Sstas 212233294Sstas 213233294Sstas# func_stripname prefix suffix name 214233294Sstas# strip PREFIX and SUFFIX off of NAME. 215233294Sstas# PREFIX and SUFFIX must not contain globbing or regex special 216233294Sstas# characters, hashes, percent signs, but SUFFIX may contain a leading 217233294Sstas# dot (in which case that matches only a dot). 218233294Sstas# func_strip_suffix prefix name 219233294Sstasfunc_stripname () 220233294Sstas{ 221233294Sstas case ${2} in 222233294Sstas .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 223233294Sstas *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 224233294Sstas esac 225233294Sstas} # func_stripname may be replaced by extended shell implementation 226233294Sstas 227233294Sstas 228233294Sstas# These SED scripts presuppose an absolute path with a trailing slash. 229233294Sstaspathcar='s,^/\([^/]*\).*$,\1,' 230233294Sstaspathcdr='s,^/[^/]*,,' 231233294Sstasremovedotparts=':dotsl 232233294Sstas s@/\./@/@g 233233294Sstas t dotsl 234233294Sstas s,/\.$,/,' 235233294Sstascollapseslashes='s@/\{1,\}@/@g' 236233294Sstasfinalslash='s,/*$,/,' 237233294Sstas 238233294Sstas# func_normal_abspath PATH 239233294Sstas# Remove doubled-up and trailing slashes, "." path components, 240233294Sstas# and cancel out any ".." path components in PATH after making 241233294Sstas# it an absolute path. 242233294Sstas# value returned in "$func_normal_abspath_result" 243233294Sstasfunc_normal_abspath () 244233294Sstas{ 245233294Sstas # Start from root dir and reassemble the path. 246233294Sstas func_normal_abspath_result= 247233294Sstas func_normal_abspath_tpath=$1 248233294Sstas func_normal_abspath_altnamespace= 249233294Sstas case $func_normal_abspath_tpath in 250233294Sstas "") 251233294Sstas # Empty path, that just means $cwd. 252233294Sstas func_stripname '' '/' "`pwd`" 253233294Sstas func_normal_abspath_result=$func_stripname_result 254233294Sstas return 255233294Sstas ;; 256233294Sstas # The next three entries are used to spot a run of precisely 257233294Sstas # two leading slashes without using negated character classes; 258233294Sstas # we take advantage of case's first-match behaviour. 259233294Sstas ///*) 260233294Sstas # Unusual form of absolute path, do nothing. 261233294Sstas ;; 262233294Sstas //*) 263233294Sstas # Not necessarily an ordinary path; POSIX reserves leading '//' 264233294Sstas # and for example Cygwin uses it to access remote file shares 265233294Sstas # over CIFS/SMB, so we conserve a leading double slash if found. 266233294Sstas func_normal_abspath_altnamespace=/ 267233294Sstas ;; 268233294Sstas /*) 269233294Sstas # Absolute path, do nothing. 270233294Sstas ;; 271233294Sstas *) 272233294Sstas # Relative path, prepend $cwd. 273233294Sstas func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 274233294Sstas ;; 275233294Sstas esac 276233294Sstas # Cancel out all the simple stuff to save iterations. We also want 277233294Sstas # the path to end with a slash for ease of parsing, so make sure 278233294Sstas # there is one (and only one) here. 279233294Sstas func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 280233294Sstas -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 281233294Sstas while :; do 282233294Sstas # Processed it all yet? 283233294Sstas if test "$func_normal_abspath_tpath" = / ; then 284233294Sstas # If we ascended to the root using ".." the result may be empty now. 285233294Sstas if test -z "$func_normal_abspath_result" ; then 286233294Sstas func_normal_abspath_result=/ 287233294Sstas fi 288233294Sstas break 289233294Sstas fi 290233294Sstas func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 291233294Sstas -e "$pathcar"` 292233294Sstas func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 293233294Sstas -e "$pathcdr"` 294233294Sstas # Figure out what to do with it 295233294Sstas case $func_normal_abspath_tcomponent in 296233294Sstas "") 297233294Sstas # Trailing empty path component, ignore it. 298233294Sstas ;; 299233294Sstas ..) 300233294Sstas # Parent dir; strip last assembled component from result. 301233294Sstas func_dirname "$func_normal_abspath_result" 302233294Sstas func_normal_abspath_result=$func_dirname_result 303233294Sstas ;; 304233294Sstas *) 305233294Sstas # Actual path component, append it. 306233294Sstas func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 307233294Sstas ;; 308233294Sstas esac 309233294Sstas done 310233294Sstas # Restore leading double-slash if one was found on entry. 311233294Sstas func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 312233294Sstas} 313233294Sstas 314233294Sstas# func_relative_path SRCDIR DSTDIR 315233294Sstas# generates a relative path from SRCDIR to DSTDIR, with a trailing 316233294Sstas# slash if non-empty, suitable for immediately appending a filename 317233294Sstas# without needing to append a separator. 318233294Sstas# value returned in "$func_relative_path_result" 319233294Sstasfunc_relative_path () 320233294Sstas{ 321233294Sstas func_relative_path_result= 322233294Sstas func_normal_abspath "$1" 323233294Sstas func_relative_path_tlibdir=$func_normal_abspath_result 324233294Sstas func_normal_abspath "$2" 325233294Sstas func_relative_path_tbindir=$func_normal_abspath_result 326233294Sstas 327233294Sstas # Ascend the tree starting from libdir 328233294Sstas while :; do 329233294Sstas # check if we have found a prefix of bindir 330233294Sstas case $func_relative_path_tbindir in 331233294Sstas $func_relative_path_tlibdir) 332233294Sstas # found an exact match 333233294Sstas func_relative_path_tcancelled= 334233294Sstas break 335233294Sstas ;; 336233294Sstas $func_relative_path_tlibdir*) 337233294Sstas # found a matching prefix 338233294Sstas func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 339233294Sstas func_relative_path_tcancelled=$func_stripname_result 340233294Sstas if test -z "$func_relative_path_result"; then 341233294Sstas func_relative_path_result=. 342233294Sstas fi 343233294Sstas break 344233294Sstas ;; 345233294Sstas *) 346233294Sstas func_dirname $func_relative_path_tlibdir 347233294Sstas func_relative_path_tlibdir=${func_dirname_result} 348233294Sstas if test "x$func_relative_path_tlibdir" = x ; then 349233294Sstas # Have to descend all the way to the root! 350233294Sstas func_relative_path_result=../$func_relative_path_result 351233294Sstas func_relative_path_tcancelled=$func_relative_path_tbindir 352233294Sstas break 353233294Sstas fi 354233294Sstas func_relative_path_result=../$func_relative_path_result 355233294Sstas ;; 356233294Sstas esac 357233294Sstas done 358233294Sstas 359233294Sstas # Now calculate path; take care to avoid doubling-up slashes. 360233294Sstas func_stripname '' '/' "$func_relative_path_result" 361233294Sstas func_relative_path_result=$func_stripname_result 362233294Sstas func_stripname '/' '/' "$func_relative_path_tcancelled" 363233294Sstas if test "x$func_stripname_result" != x ; then 364233294Sstas func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 365233294Sstas fi 366233294Sstas 367233294Sstas # Normalisation. If bindir is libdir, return empty string, 368233294Sstas # else relative path ending with a slash; either way, target 369233294Sstas # file name can be directly appended. 370233294Sstas if test ! -z "$func_relative_path_result"; then 371233294Sstas func_stripname './' '' "$func_relative_path_result/" 372233294Sstas func_relative_path_result=$func_stripname_result 373233294Sstas fi 374233294Sstas} 375233294Sstas 376233294Sstas# The name of this program: 377233294Sstasfunc_dirname_and_basename "$progpath" 378233294Sstasprogname=$func_basename_result 379233294Sstas 380233294Sstas# Make sure we have an absolute path for reexecution: 381233294Sstascase $progpath in 382233294Sstas [\\/]*|[A-Za-z]:\\*) ;; 383233294Sstas *[\\/]*) 384233294Sstas progdir=$func_dirname_result 385233294Sstas progdir=`cd "$progdir" && pwd` 386233294Sstas progpath="$progdir/$progname" 387233294Sstas ;; 388233294Sstas *) 389233294Sstas save_IFS="$IFS" 390233294Sstas IFS=: 391233294Sstas for progdir in $PATH; do 392233294Sstas IFS="$save_IFS" 393233294Sstas test -x "$progdir/$progname" && break 394233294Sstas done 395233294Sstas IFS="$save_IFS" 396233294Sstas test -n "$progdir" || progdir=`pwd` 397233294Sstas progpath="$progdir/$progname" 398233294Sstas ;; 399233294Sstasesac 400233294Sstas 40155682Smarkm# Sed substitution that helps us do robust quoting. It backslashifies 40255682Smarkm# metacharacters that are still active within double-quoted strings. 403127808SnectarXsed="${SED}"' -e 1s/^X//' 404233294Sstassed_quote_subst='s/\([`"$\\]\)/\\\1/g' 40555682Smarkm 406233294Sstas# Same as above, but do not quote variable references. 407233294Sstasdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 40855682Smarkm 409233294Sstas# Sed substitution that turns a string into a regex matching for the 410233294Sstas# string literally. 411233294Sstassed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 412102644Snectar 413233294Sstas# Sed substitution that converts a w32 file name or path 414233294Sstas# which contains forward slashes, into one that contains 415233294Sstas# (escaped) backslashes. A very naive implementation. 416233294Sstaslt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 41755682Smarkm 418233294Sstas# Re-`\' parameter expansions in output of double_quote_subst that were 419233294Sstas# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 420233294Sstas# in input to double_quote_subst, that '$' was protected from expansion. 421233294Sstas# Since each input `\' is now two `\'s, look for any number of runs of 422233294Sstas# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 423233294Sstasbs='\\' 424233294Sstasbs2='\\\\' 425233294Sstasbs4='\\\\\\\\' 426233294Sstasdollar='\$' 427233294Sstassed_double_backslash="\ 428233294Sstas s/$bs4/&\\ 429233294Sstas/g 430233294Sstas s/^$bs2$dollar/$bs&/ 431233294Sstas s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 432233294Sstas s/\n//g" 43355682Smarkm 434233294Sstas# Standard options: 435233294Sstasopt_dry_run=false 436233294Sstasopt_help=false 437233294Sstasopt_quiet=false 438233294Sstasopt_verbose=false 439233294Sstasopt_warning=: 440127808Snectar 441233294Sstas# func_echo arg... 442233294Sstas# Echo program name prefixed message, along with the current mode 443233294Sstas# name if it has been set yet. 444233294Sstasfunc_echo () 445233294Sstas{ 446233294Sstas $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 447233294Sstas} 448233294Sstas 449233294Sstas# func_verbose arg... 450233294Sstas# Echo program name prefixed message in verbose mode only. 451233294Sstasfunc_verbose () 452233294Sstas{ 453233294Sstas $opt_verbose && func_echo ${1+"$@"} 454233294Sstas 455233294Sstas # A bug in bash halts the script if the last line of a function 456233294Sstas # fails when set -e is in force, so we need another command to 457233294Sstas # work around that: 458233294Sstas : 459233294Sstas} 460233294Sstas 461233294Sstas# func_echo_all arg... 462233294Sstas# Invoke $ECHO with all args, space-separated. 463233294Sstasfunc_echo_all () 464233294Sstas{ 465233294Sstas $ECHO "$*" 466233294Sstas} 467233294Sstas 468233294Sstas# func_error arg... 469233294Sstas# Echo program name prefixed message to standard error. 470233294Sstasfunc_error () 471233294Sstas{ 472233294Sstas $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 473233294Sstas} 474233294Sstas 475233294Sstas# func_warning arg... 476233294Sstas# Echo program name prefixed warning message to standard error. 477233294Sstasfunc_warning () 478233294Sstas{ 479233294Sstas $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 480233294Sstas 481233294Sstas # bash bug again: 482233294Sstas : 483233294Sstas} 484233294Sstas 485233294Sstas# func_fatal_error arg... 486233294Sstas# Echo program name prefixed message to standard error, and exit. 487233294Sstasfunc_fatal_error () 488233294Sstas{ 489233294Sstas func_error ${1+"$@"} 490233294Sstas exit $EXIT_FAILURE 491233294Sstas} 492233294Sstas 493233294Sstas# func_fatal_help arg... 494233294Sstas# Echo program name prefixed message to standard error, followed by 495233294Sstas# a help hint, and exit. 496233294Sstasfunc_fatal_help () 497233294Sstas{ 498233294Sstas func_error ${1+"$@"} 499233294Sstas func_fatal_error "$help" 500233294Sstas} 501233294Sstashelp="Try \`$progname --help' for more information." ## default 502233294Sstas 503233294Sstas 504233294Sstas# func_grep expression filename 505233294Sstas# Check whether EXPRESSION matches any line of FILENAME, without output. 506233294Sstasfunc_grep () 507233294Sstas{ 508233294Sstas $GREP "$1" "$2" >/dev/null 2>&1 509233294Sstas} 510233294Sstas 511233294Sstas 512233294Sstas# func_mkdir_p directory-path 513233294Sstas# Make sure the entire path to DIRECTORY-PATH is available. 514233294Sstasfunc_mkdir_p () 515233294Sstas{ 516233294Sstas my_directory_path="$1" 517233294Sstas my_dir_list= 518233294Sstas 519233294Sstas if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 520233294Sstas 521233294Sstas # Protect directory names starting with `-' 522233294Sstas case $my_directory_path in 523233294Sstas -*) my_directory_path="./$my_directory_path" ;; 524233294Sstas esac 525233294Sstas 526233294Sstas # While some portion of DIR does not yet exist... 527233294Sstas while test ! -d "$my_directory_path"; do 528233294Sstas # ...make a list in topmost first order. Use a colon delimited 529233294Sstas # list incase some portion of path contains whitespace. 530233294Sstas my_dir_list="$my_directory_path:$my_dir_list" 531233294Sstas 532233294Sstas # If the last portion added has no slash in it, the list is done 533233294Sstas case $my_directory_path in */*) ;; *) break ;; esac 534233294Sstas 535233294Sstas # ...otherwise throw away the child directory and loop 536233294Sstas my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 537233294Sstas done 538233294Sstas my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 539233294Sstas 540233294Sstas save_mkdir_p_IFS="$IFS"; IFS=':' 541233294Sstas for my_dir in $my_dir_list; do 542233294Sstas IFS="$save_mkdir_p_IFS" 543233294Sstas # mkdir can fail with a `File exist' error if two processes 544233294Sstas # try to create one of the directories concurrently. Don't 545233294Sstas # stop in that case! 546233294Sstas $MKDIR "$my_dir" 2>/dev/null || : 547233294Sstas done 548233294Sstas IFS="$save_mkdir_p_IFS" 549233294Sstas 550233294Sstas # Bail out if we (or some other process) failed to create a directory. 551233294Sstas test -d "$my_directory_path" || \ 552233294Sstas func_fatal_error "Failed to create \`$1'" 553233294Sstas fi 554233294Sstas} 555233294Sstas 556233294Sstas 557178825Sdfr# func_mktempdir [string] 558178825Sdfr# Make a temporary directory that won't clash with other running 559178825Sdfr# libtool processes, and avoids race conditions if possible. If 560178825Sdfr# given, STRING is the basename for that directory. 561178825Sdfrfunc_mktempdir () 562178825Sdfr{ 563178825Sdfr my_template="${TMPDIR-/tmp}/${1-$progname}" 564178825Sdfr 565233294Sstas if test "$opt_dry_run" = ":"; then 566178825Sdfr # Return a directory name, but don't create it in dry-run mode 567178825Sdfr my_tmpdir="${my_template}-$$" 568178825Sdfr else 569178825Sdfr 570178825Sdfr # If mktemp works, use that first and foremost 571178825Sdfr my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 572178825Sdfr 573178825Sdfr if test ! -d "$my_tmpdir"; then 574233294Sstas # Failing that, at least try and use $RANDOM to avoid a race 575233294Sstas my_tmpdir="${my_template}-${RANDOM-0}$$" 576178825Sdfr 577233294Sstas save_mktempdir_umask=`umask` 578233294Sstas umask 0077 579233294Sstas $MKDIR "$my_tmpdir" 580233294Sstas umask $save_mktempdir_umask 581178825Sdfr fi 582178825Sdfr 583178825Sdfr # If we're not in dry-run mode, bomb out on failure 584233294Sstas test -d "$my_tmpdir" || \ 585233294Sstas func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 586178825Sdfr fi 587178825Sdfr 588233294Sstas $ECHO "$my_tmpdir" 589178825Sdfr} 590178825Sdfr 591178825Sdfr 592233294Sstas# func_quote_for_eval arg 593233294Sstas# Aesthetically quote ARG to be evaled later. 594233294Sstas# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 595233294Sstas# is double-quoted, suitable for a subsequent eval, whereas 596233294Sstas# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 597233294Sstas# which are still active within double quotes backslashified. 598233294Sstasfunc_quote_for_eval () 599178825Sdfr{ 600233294Sstas case $1 in 601233294Sstas *[\\\`\"\$]*) 602233294Sstas func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 603233294Sstas *) 604233294Sstas func_quote_for_eval_unquoted_result="$1" ;; 605233294Sstas esac 606233294Sstas 607233294Sstas case $func_quote_for_eval_unquoted_result in 608233294Sstas # Double-quote args containing shell metacharacters to delay 609233294Sstas # word splitting, command substitution and and variable 610233294Sstas # expansion for a subsequent eval. 611233294Sstas # Many Bourne shells cannot handle close brackets correctly 612233294Sstas # in scan sets, so we specify it separately. 613233294Sstas *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 614233294Sstas func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 615233294Sstas ;; 616233294Sstas *) 617233294Sstas func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 618233294Sstas esac 619233294Sstas} 620233294Sstas 621233294Sstas 622233294Sstas# func_quote_for_expand arg 623233294Sstas# Aesthetically quote ARG to be evaled later; same as above, 624233294Sstas# but do not quote variable references. 625233294Sstasfunc_quote_for_expand () 626233294Sstas{ 627233294Sstas case $1 in 628233294Sstas *[\\\`\"]*) 629233294Sstas my_arg=`$ECHO "$1" | $SED \ 630233294Sstas -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 631233294Sstas *) 632233294Sstas my_arg="$1" ;; 633233294Sstas esac 634233294Sstas 635233294Sstas case $my_arg in 636233294Sstas # Double-quote args containing shell metacharacters to delay 637233294Sstas # word splitting and command substitution for a subsequent eval. 638233294Sstas # Many Bourne shells cannot handle close brackets correctly 639233294Sstas # in scan sets, so we specify it separately. 640233294Sstas *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 641233294Sstas my_arg="\"$my_arg\"" 642233294Sstas ;; 643233294Sstas esac 644233294Sstas 645233294Sstas func_quote_for_expand_result="$my_arg" 646233294Sstas} 647233294Sstas 648233294Sstas 649233294Sstas# func_show_eval cmd [fail_exp] 650233294Sstas# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 651233294Sstas# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 652233294Sstas# is given, then evaluate it. 653233294Sstasfunc_show_eval () 654233294Sstas{ 655233294Sstas my_cmd="$1" 656233294Sstas my_fail_exp="${2-:}" 657233294Sstas 658233294Sstas ${opt_silent-false} || { 659233294Sstas func_quote_for_expand "$my_cmd" 660233294Sstas eval "func_echo $func_quote_for_expand_result" 661233294Sstas } 662233294Sstas 663233294Sstas if ${opt_dry_run-false}; then :; else 664233294Sstas eval "$my_cmd" 665233294Sstas my_status=$? 666233294Sstas if test "$my_status" -eq 0; then :; else 667233294Sstas eval "(exit $my_status); $my_fail_exp" 668233294Sstas fi 669127808Snectar fi 670233294Sstas} 671233294Sstas 672233294Sstas 673233294Sstas# func_show_eval_locale cmd [fail_exp] 674233294Sstas# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 675233294Sstas# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 676233294Sstas# is given, then evaluate it. Use the saved locale for evaluation. 677233294Sstasfunc_show_eval_locale () 678233294Sstas{ 679233294Sstas my_cmd="$1" 680233294Sstas my_fail_exp="${2-:}" 681233294Sstas 682233294Sstas ${opt_silent-false} || { 683233294Sstas func_quote_for_expand "$my_cmd" 684233294Sstas eval "func_echo $func_quote_for_expand_result" 685233294Sstas } 686233294Sstas 687233294Sstas if ${opt_dry_run-false}; then :; else 688233294Sstas eval "$lt_user_locale 689233294Sstas $my_cmd" 690233294Sstas my_status=$? 691233294Sstas eval "$lt_safe_locale" 692233294Sstas if test "$my_status" -eq 0; then :; else 693233294Sstas eval "(exit $my_status); $my_fail_exp" 694233294Sstas fi 695233294Sstas fi 696233294Sstas} 697233294Sstas 698233294Sstas# func_tr_sh 699233294Sstas# Turn $1 into a string suitable for a shell variable name. 700233294Sstas# Result is stored in $func_tr_sh_result. All characters 701233294Sstas# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 702233294Sstas# if $1 begins with a digit, a '_' is prepended as well. 703233294Sstasfunc_tr_sh () 704233294Sstas{ 705233294Sstas case $1 in 706233294Sstas [0-9]* | *[!a-zA-Z0-9_]*) 707233294Sstas func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 708127808Snectar ;; 709233294Sstas * ) 710233294Sstas func_tr_sh_result=$1 711127808Snectar ;; 712233294Sstas esac 713233294Sstas} 714233294Sstas 715233294Sstas 716233294Sstas# func_version 717233294Sstas# Echo version message to standard output and exit. 718233294Sstasfunc_version () 719233294Sstas{ 720233294Sstas $opt_debug 721233294Sstas 722233294Sstas $SED -n '/(C)/!b go 723233294Sstas :more 724233294Sstas /\./!{ 725233294Sstas N 726233294Sstas s/\n# / / 727233294Sstas b more 728233294Sstas } 729233294Sstas :go 730233294Sstas /^# '$PROGRAM' (GNU /,/# warranty; / { 731233294Sstas s/^# // 732233294Sstas s/^# *$// 733233294Sstas s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 734233294Sstas p 735233294Sstas }' < "$progpath" 736233294Sstas exit $? 737233294Sstas} 738233294Sstas 739233294Sstas# func_usage 740233294Sstas# Echo short help message to standard output and exit. 741233294Sstasfunc_usage () 742233294Sstas{ 743233294Sstas $opt_debug 744233294Sstas 745233294Sstas $SED -n '/^# Usage:/,/^# *.*--help/ { 746233294Sstas s/^# // 747233294Sstas s/^# *$// 748233294Sstas s/\$progname/'$progname'/ 749233294Sstas p 750233294Sstas }' < "$progpath" 751233294Sstas echo 752233294Sstas $ECHO "run \`$progname --help | more' for full usage" 753233294Sstas exit $? 754233294Sstas} 755233294Sstas 756233294Sstas# func_help [NOEXIT] 757233294Sstas# Echo long help message to standard output and exit, 758233294Sstas# unless 'noexit' is passed as argument. 759233294Sstasfunc_help () 760233294Sstas{ 761233294Sstas $opt_debug 762233294Sstas 763233294Sstas $SED -n '/^# Usage:/,/# Report bugs to/ { 764233294Sstas :print 765233294Sstas s/^# // 766233294Sstas s/^# *$// 767233294Sstas s*\$progname*'$progname'* 768233294Sstas s*\$host*'"$host"'* 769233294Sstas s*\$SHELL*'"$SHELL"'* 770233294Sstas s*\$LTCC*'"$LTCC"'* 771233294Sstas s*\$LTCFLAGS*'"$LTCFLAGS"'* 772233294Sstas s*\$LD*'"$LD"'* 773233294Sstas s/\$with_gnu_ld/'"$with_gnu_ld"'/ 774233294Sstas s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ 775233294Sstas s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ 776233294Sstas p 777233294Sstas d 778233294Sstas } 779233294Sstas /^# .* home page:/b print 780233294Sstas /^# General help using/b print 781233294Sstas ' < "$progpath" 782233294Sstas ret=$? 783233294Sstas if test -z "$1"; then 784233294Sstas exit $ret 785233294Sstas fi 786233294Sstas} 787233294Sstas 788233294Sstas# func_missing_arg argname 789233294Sstas# Echo program name prefixed message to standard error and set global 790233294Sstas# exit_cmd. 791233294Sstasfunc_missing_arg () 792233294Sstas{ 793233294Sstas $opt_debug 794233294Sstas 795233294Sstas func_error "missing argument for $1." 796233294Sstas exit_cmd=exit 797233294Sstas} 798233294Sstas 799233294Sstas 800233294Sstas# func_split_short_opt shortopt 801233294Sstas# Set func_split_short_opt_name and func_split_short_opt_arg shell 802233294Sstas# variables after splitting SHORTOPT after the 2nd character. 803233294Sstasfunc_split_short_opt () 804233294Sstas{ 805233294Sstas my_sed_short_opt='1s/^\(..\).*$/\1/;q' 806233294Sstas my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 807233294Sstas 808233294Sstas func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 809233294Sstas func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 810233294Sstas} # func_split_short_opt may be replaced by extended shell implementation 811233294Sstas 812233294Sstas 813233294Sstas# func_split_long_opt longopt 814233294Sstas# Set func_split_long_opt_name and func_split_long_opt_arg shell 815233294Sstas# variables after splitting LONGOPT at the `=' sign. 816233294Sstasfunc_split_long_opt () 817233294Sstas{ 818233294Sstas my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 819233294Sstas my_sed_long_arg='1s/^--[^=]*=//' 820233294Sstas 821233294Sstas func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 822233294Sstas func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 823233294Sstas} # func_split_long_opt may be replaced by extended shell implementation 824233294Sstas 825233294Sstasexit_cmd=: 826233294Sstas 827233294Sstas 828233294Sstas 829233294Sstas 830233294Sstas 831233294Sstasmagic="%%%MAGIC variable%%%" 832233294Sstasmagic_exe="%%%MAGIC EXE variable%%%" 833233294Sstas 834233294Sstas# Global variables. 835233294Sstasnonopt= 836233294Sstaspreserve_args= 837233294Sstaslo2o="s/\\.lo\$/.${objext}/" 838233294Sstaso2lo="s/\\.${objext}\$/.lo/" 839233294Sstasextracted_archives= 840233294Sstasextracted_serial=0 841233294Sstas 842233294Sstas# If this variable is set in any of the actions, the command in it 843233294Sstas# will be execed at the end. This prevents here-documents from being 844233294Sstas# left over by shells. 845233294Sstasexec_cmd= 846233294Sstas 847233294Sstas# func_append var value 848233294Sstas# Append VALUE to the end of shell variable VAR. 849233294Sstasfunc_append () 850233294Sstas{ 851233294Sstas eval "${1}=\$${1}\${2}" 852233294Sstas} # func_append may be replaced by extended shell implementation 853233294Sstas 854233294Sstas# func_append_quoted var value 855233294Sstas# Quote VALUE and append to the end of shell variable VAR, separated 856233294Sstas# by a space. 857233294Sstasfunc_append_quoted () 858233294Sstas{ 859233294Sstas func_quote_for_eval "${2}" 860233294Sstas eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 861233294Sstas} # func_append_quoted may be replaced by extended shell implementation 862233294Sstas 863233294Sstas 864233294Sstas# func_arith arithmetic-term... 865233294Sstasfunc_arith () 866233294Sstas{ 867233294Sstas func_arith_result=`expr "${@}"` 868233294Sstas} # func_arith may be replaced by extended shell implementation 869233294Sstas 870233294Sstas 871233294Sstas# func_len string 872233294Sstas# STRING may not start with a hyphen. 873233294Sstasfunc_len () 874233294Sstas{ 875233294Sstas func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 876233294Sstas} # func_len may be replaced by extended shell implementation 877233294Sstas 878233294Sstas 879233294Sstas# func_lo2o object 880233294Sstasfunc_lo2o () 881233294Sstas{ 882233294Sstas func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 883233294Sstas} # func_lo2o may be replaced by extended shell implementation 884233294Sstas 885233294Sstas 886233294Sstas# func_xform libobj-or-source 887233294Sstasfunc_xform () 888233294Sstas{ 889233294Sstas func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 890233294Sstas} # func_xform may be replaced by extended shell implementation 891233294Sstas 892233294Sstas 893233294Sstas# func_fatal_configuration arg... 894233294Sstas# Echo program name prefixed message to standard error, followed by 895233294Sstas# a configuration failure hint, and exit. 896233294Sstasfunc_fatal_configuration () 897233294Sstas{ 898233294Sstas func_error ${1+"$@"} 899233294Sstas func_error "See the $PACKAGE documentation for more information." 900233294Sstas func_fatal_error "Fatal configuration error." 901233294Sstas} 902233294Sstas 903233294Sstas 904233294Sstas# func_config 905233294Sstas# Display the configuration for all the tags in this script. 906233294Sstasfunc_config () 907233294Sstas{ 908233294Sstas re_begincf='^# ### BEGIN LIBTOOL' 909233294Sstas re_endcf='^# ### END LIBTOOL' 910233294Sstas 911233294Sstas # Default configuration. 912233294Sstas $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 913233294Sstas 914233294Sstas # Now print the configurations for the tags. 915233294Sstas for tagname in $taglist; do 916233294Sstas $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 917233294Sstas done 918233294Sstas 919233294Sstas exit $? 920233294Sstas} 921233294Sstas 922233294Sstas# func_features 923233294Sstas# Display the features supported by this script. 924233294Sstasfunc_features () 925233294Sstas{ 926233294Sstas echo "host: $host" 927233294Sstas if test "$build_libtool_libs" = yes; then 928233294Sstas echo "enable shared libraries" 929233294Sstas else 930233294Sstas echo "disable shared libraries" 931233294Sstas fi 932233294Sstas if test "$build_old_libs" = yes; then 933233294Sstas echo "enable static libraries" 934233294Sstas else 935233294Sstas echo "disable static libraries" 936233294Sstas fi 937233294Sstas 938233294Sstas exit $? 939233294Sstas} 940233294Sstas 941233294Sstas# func_enable_tag tagname 942233294Sstas# Verify that TAGNAME is valid, and either flag an error and exit, or 943233294Sstas# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 944233294Sstas# variable here. 945233294Sstasfunc_enable_tag () 946233294Sstas{ 947233294Sstas # Global variable: 948233294Sstas tagname="$1" 949233294Sstas 950233294Sstas re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 951233294Sstas re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 952233294Sstas sed_extractcf="/$re_begincf/,/$re_endcf/p" 953233294Sstas 954233294Sstas # Validate tagname. 955233294Sstas case $tagname in 956233294Sstas *[!-_A-Za-z0-9,/]*) 957233294Sstas func_fatal_error "invalid tag name: $tagname" 958127808Snectar ;; 959233294Sstas esac 960233294Sstas 961233294Sstas # Don't test for the "default" C tag, as we know it's 962233294Sstas # there but not specially marked. 963233294Sstas case $tagname in 964233294Sstas CC) ;; 965233294Sstas *) 966233294Sstas if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 967233294Sstas taglist="$taglist $tagname" 968233294Sstas 969233294Sstas # Evaluate the configuration. Be careful to quote the path 970233294Sstas # and the sed script, to avoid splitting on whitespace, but 971233294Sstas # also don't use non-portable quotes within backquotes within 972233294Sstas # quotes we have to do it in 2 steps: 973233294Sstas extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 974233294Sstas eval "$extractedcf" 975233294Sstas else 976233294Sstas func_error "ignoring unknown tag $tagname" 977233294Sstas fi 978233294Sstas ;; 979233294Sstas esac 980233294Sstas} 981233294Sstas 982233294Sstas# func_check_version_match 983233294Sstas# Ensure that we are using m4 macros, and libtool script from the same 984233294Sstas# release of libtool. 985233294Sstasfunc_check_version_match () 986233294Sstas{ 987233294Sstas if test "$package_revision" != "$macro_revision"; then 988233294Sstas if test "$VERSION" != "$macro_version"; then 989233294Sstas if test -z "$macro_version"; then 990233294Sstas cat >&2 <<_LT_EOF 991233294Sstas$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 992233294Sstas$progname: definition of this LT_INIT comes from an older release. 993233294Sstas$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 994233294Sstas$progname: and run autoconf again. 995233294Sstas_LT_EOF 996233294Sstas else 997233294Sstas cat >&2 <<_LT_EOF 998233294Sstas$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 999233294Sstas$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 1000233294Sstas$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 1001233294Sstas$progname: and run autoconf again. 1002233294Sstas_LT_EOF 1003233294Sstas fi 1004233294Sstas else 1005233294Sstas cat >&2 <<_LT_EOF 1006233294Sstas$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 1007233294Sstas$progname: but the definition of this LT_INIT comes from revision $macro_revision. 1008233294Sstas$progname: You should recreate aclocal.m4 with macros from revision $package_revision 1009233294Sstas$progname: of $PACKAGE $VERSION and run autoconf again. 1010233294Sstas_LT_EOF 1011233294Sstas fi 1012233294Sstas 1013233294Sstas exit $EXIT_MISMATCH 1014233294Sstas fi 1015233294Sstas} 1016233294Sstas 1017233294Sstas 1018233294Sstas# Shorthand for --mode=foo, only valid as the first argument 1019233294Sstascase $1 in 1020233294Sstasclean|clea|cle|cl) 1021233294Sstas shift; set dummy --mode clean ${1+"$@"}; shift 1022233294Sstas ;; 1023233294Sstascompile|compil|compi|comp|com|co|c) 1024233294Sstas shift; set dummy --mode compile ${1+"$@"}; shift 1025233294Sstas ;; 1026233294Sstasexecute|execut|execu|exec|exe|ex|e) 1027233294Sstas shift; set dummy --mode execute ${1+"$@"}; shift 1028233294Sstas ;; 1029233294Sstasfinish|finis|fini|fin|fi|f) 1030233294Sstas shift; set dummy --mode finish ${1+"$@"}; shift 1031233294Sstas ;; 1032233294Sstasinstall|instal|insta|inst|ins|in|i) 1033233294Sstas shift; set dummy --mode install ${1+"$@"}; shift 1034233294Sstas ;; 1035233294Sstaslink|lin|li|l) 1036233294Sstas shift; set dummy --mode link ${1+"$@"}; shift 1037233294Sstas ;; 1038233294Sstasuninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 1039233294Sstas shift; set dummy --mode uninstall ${1+"$@"}; shift 1040233294Sstas ;; 1041233294Sstasesac 1042233294Sstas 1043233294Sstas 1044233294Sstas 1045233294Sstas# Option defaults: 1046233294Sstasopt_debug=: 1047233294Sstasopt_dry_run=false 1048233294Sstasopt_config=false 1049233294Sstasopt_preserve_dup_deps=false 1050233294Sstasopt_features=false 1051233294Sstasopt_finish=false 1052233294Sstasopt_help=false 1053233294Sstasopt_help_all=false 1054233294Sstasopt_silent=: 1055233294Sstasopt_verbose=: 1056233294Sstasopt_silent=false 1057233294Sstasopt_verbose=false 1058233294Sstas 1059233294Sstas 1060233294Sstas# Parse options once, thoroughly. This comes as soon as possible in the 1061233294Sstas# script to make things like `--version' happen as quickly as we can. 1062233294Sstas{ 1063233294Sstas # this just eases exit handling 1064233294Sstas while test $# -gt 0; do 1065233294Sstas opt="$1" 1066233294Sstas shift 1067233294Sstas case $opt in 1068233294Sstas --debug|-x) opt_debug='set -x' 1069233294Sstas func_echo "enabling shell trace mode" 1070233294Sstas $opt_debug 1071233294Sstas ;; 1072233294Sstas --dry-run|--dryrun|-n) 1073233294Sstas opt_dry_run=: 1074233294Sstas ;; 1075233294Sstas --config) 1076233294Sstas opt_config=: 1077233294Sstasfunc_config 1078233294Sstas ;; 1079233294Sstas --dlopen|-dlopen) 1080233294Sstas optarg="$1" 1081233294Sstas opt_dlopen="${opt_dlopen+$opt_dlopen 1082233294Sstas}$optarg" 1083233294Sstas shift 1084233294Sstas ;; 1085233294Sstas --preserve-dup-deps) 1086233294Sstas opt_preserve_dup_deps=: 1087233294Sstas ;; 1088233294Sstas --features) 1089233294Sstas opt_features=: 1090233294Sstasfunc_features 1091233294Sstas ;; 1092233294Sstas --finish) 1093233294Sstas opt_finish=: 1094233294Sstasset dummy --mode finish ${1+"$@"}; shift 1095233294Sstas ;; 1096233294Sstas --help) 1097233294Sstas opt_help=: 1098233294Sstas ;; 1099233294Sstas --help-all) 1100233294Sstas opt_help_all=: 1101233294Sstasopt_help=': help-all' 1102233294Sstas ;; 1103233294Sstas --mode) 1104233294Sstas test $# = 0 && func_missing_arg $opt && break 1105233294Sstas optarg="$1" 1106233294Sstas opt_mode="$optarg" 1107233294Sstascase $optarg in 1108233294Sstas # Valid mode arguments: 1109233294Sstas clean|compile|execute|finish|install|link|relink|uninstall) ;; 1110233294Sstas 1111233294Sstas # Catch anything else as an error 1112233294Sstas *) func_error "invalid argument for $opt" 1113233294Sstas exit_cmd=exit 1114233294Sstas break 1115233294Sstas ;; 1116233294Sstasesac 1117233294Sstas shift 1118233294Sstas ;; 1119233294Sstas --no-silent|--no-quiet) 1120233294Sstas opt_silent=false 1121233294Sstasfunc_append preserve_args " $opt" 1122233294Sstas ;; 1123233294Sstas --no-verbose) 1124233294Sstas opt_verbose=false 1125233294Sstasfunc_append preserve_args " $opt" 1126233294Sstas ;; 1127233294Sstas --silent|--quiet) 1128233294Sstas opt_silent=: 1129233294Sstasfunc_append preserve_args " $opt" 1130233294Sstas opt_verbose=false 1131233294Sstas ;; 1132233294Sstas --verbose|-v) 1133233294Sstas opt_verbose=: 1134233294Sstasfunc_append preserve_args " $opt" 1135233294Sstasopt_silent=false 1136233294Sstas ;; 1137233294Sstas --tag) 1138233294Sstas test $# = 0 && func_missing_arg $opt && break 1139233294Sstas optarg="$1" 1140233294Sstas opt_tag="$optarg" 1141233294Sstasfunc_append preserve_args " $opt $optarg" 1142233294Sstasfunc_enable_tag "$optarg" 1143233294Sstas shift 1144233294Sstas ;; 1145233294Sstas 1146233294Sstas -\?|-h) func_usage ;; 1147233294Sstas --help) func_help ;; 1148233294Sstas --version) func_version ;; 1149233294Sstas 1150233294Sstas # Separate optargs to long options: 1151233294Sstas --*=*) 1152233294Sstas func_split_long_opt "$opt" 1153233294Sstas set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 1154233294Sstas shift 1155233294Sstas ;; 1156233294Sstas 1157233294Sstas # Separate non-argument short options: 1158233294Sstas -\?*|-h*|-n*|-v*) 1159233294Sstas func_split_short_opt "$opt" 1160233294Sstas set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 1161233294Sstas shift 1162233294Sstas ;; 1163233294Sstas 1164233294Sstas --) break ;; 1165233294Sstas -*) func_fatal_help "unrecognized option \`$opt'" ;; 1166233294Sstas *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1167127808Snectar esac 1168233294Sstas done 1169233294Sstas 1170233294Sstas # Validate options: 1171233294Sstas 1172233294Sstas # save first non-option argument 1173233294Sstas if test "$#" -gt 0; then 1174233294Sstas nonopt="$opt" 1175233294Sstas shift 1176233294Sstas fi 1177233294Sstas 1178233294Sstas # preserve --debug 1179233294Sstas test "$opt_debug" = : || func_append preserve_args " --debug" 1180233294Sstas 1181233294Sstas case $host in 1182233294Sstas *cygwin* | *mingw* | *pw32* | *cegcc*) 1183233294Sstas # don't eliminate duplications in $postdeps and $predeps 1184233294Sstas opt_duplicate_compiler_generated_deps=: 1185233294Sstas ;; 1186233294Sstas *) 1187233294Sstas opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 1188233294Sstas ;; 1189233294Sstas esac 1190233294Sstas 1191233294Sstas $opt_help || { 1192233294Sstas # Sanity checks first: 1193233294Sstas func_check_version_match 1194233294Sstas 1195233294Sstas if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 1196233294Sstas func_fatal_configuration "not configured to build any kind of library" 1197233294Sstas fi 1198233294Sstas 1199233294Sstas # Darwin sucks 1200233294Sstas eval std_shrext=\"$shrext_cmds\" 1201233294Sstas 1202233294Sstas # Only execute mode is allowed to have -dlopen flags. 1203233294Sstas if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 1204233294Sstas func_error "unrecognized option \`-dlopen'" 1205233294Sstas $ECHO "$help" 1>&2 1206233294Sstas exit $EXIT_FAILURE 1207233294Sstas fi 1208233294Sstas 1209233294Sstas # Change the help message to a mode-specific one. 1210233294Sstas generic_help="$help" 1211233294Sstas help="Try \`$progname --help --mode=$opt_mode' for more information." 1212233294Sstas } 1213233294Sstas 1214233294Sstas 1215233294Sstas # Bail if the options were screwed 1216233294Sstas $exit_cmd $EXIT_FAILURE 1217233294Sstas} 1218233294Sstas 1219233294Sstas 1220233294Sstas 1221233294Sstas 1222233294Sstas## ----------- ## 1223233294Sstas## Main. ## 1224233294Sstas## ----------- ## 1225233294Sstas 1226233294Sstas# func_lalib_p file 1227233294Sstas# True iff FILE is a libtool `.la' library or `.lo' object file. 1228233294Sstas# This function is only a basic sanity check; it will hardly flush out 1229233294Sstas# determined imposters. 1230233294Sstasfunc_lalib_p () 1231233294Sstas{ 1232233294Sstas test -f "$1" && 1233233294Sstas $SED -e 4q "$1" 2>/dev/null \ 1234233294Sstas | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 1235233294Sstas} 1236233294Sstas 1237233294Sstas# func_lalib_unsafe_p file 1238233294Sstas# True iff FILE is a libtool `.la' library or `.lo' object file. 1239233294Sstas# This function implements the same check as func_lalib_p without 1240233294Sstas# resorting to external programs. To this end, it redirects stdin and 1241233294Sstas# closes it afterwards, without saving the original file descriptor. 1242233294Sstas# As a safety measure, use it only where a negative result would be 1243233294Sstas# fatal anyway. Works if `file' does not exist. 1244233294Sstasfunc_lalib_unsafe_p () 1245233294Sstas{ 1246233294Sstas lalib_p=no 1247233294Sstas if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 1248233294Sstas for lalib_p_l in 1 2 3 4 1249233294Sstas do 1250233294Sstas read lalib_p_line 1251233294Sstas case "$lalib_p_line" in 1252233294Sstas \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 1253233294Sstas esac 1254233294Sstas done 1255233294Sstas exec 0<&5 5<&- 1256233294Sstas fi 1257233294Sstas test "$lalib_p" = yes 1258233294Sstas} 1259233294Sstas 1260233294Sstas# func_ltwrapper_script_p file 1261233294Sstas# True iff FILE is a libtool wrapper script 1262233294Sstas# This function is only a basic sanity check; it will hardly flush out 1263233294Sstas# determined imposters. 1264233294Sstasfunc_ltwrapper_script_p () 1265233294Sstas{ 1266233294Sstas func_lalib_p "$1" 1267233294Sstas} 1268233294Sstas 1269233294Sstas# func_ltwrapper_executable_p file 1270233294Sstas# True iff FILE is a libtool wrapper executable 1271233294Sstas# This function is only a basic sanity check; it will hardly flush out 1272233294Sstas# determined imposters. 1273233294Sstasfunc_ltwrapper_executable_p () 1274233294Sstas{ 1275233294Sstas func_ltwrapper_exec_suffix= 1276233294Sstas case $1 in 1277233294Sstas *.exe) ;; 1278233294Sstas *) func_ltwrapper_exec_suffix=.exe ;; 1279233294Sstas esac 1280233294Sstas $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 1281233294Sstas} 1282233294Sstas 1283233294Sstas# func_ltwrapper_scriptname file 1284233294Sstas# Assumes file is an ltwrapper_executable 1285233294Sstas# uses $file to determine the appropriate filename for a 1286233294Sstas# temporary ltwrapper_script. 1287233294Sstasfunc_ltwrapper_scriptname () 1288233294Sstas{ 1289233294Sstas func_dirname_and_basename "$1" "" "." 1290233294Sstas func_stripname '' '.exe' "$func_basename_result" 1291233294Sstas func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 1292233294Sstas} 1293233294Sstas 1294233294Sstas# func_ltwrapper_p file 1295233294Sstas# True iff FILE is a libtool wrapper script or wrapper executable 1296233294Sstas# This function is only a basic sanity check; it will hardly flush out 1297233294Sstas# determined imposters. 1298233294Sstasfunc_ltwrapper_p () 1299233294Sstas{ 1300233294Sstas func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 1301233294Sstas} 1302233294Sstas 1303233294Sstas 1304233294Sstas# func_execute_cmds commands fail_cmd 1305233294Sstas# Execute tilde-delimited COMMANDS. 1306233294Sstas# If FAIL_CMD is given, eval that upon failure. 1307233294Sstas# FAIL_CMD may read-access the current command in variable CMD! 1308233294Sstasfunc_execute_cmds () 1309233294Sstas{ 1310233294Sstas $opt_debug 1311233294Sstas save_ifs=$IFS; IFS='~' 1312233294Sstas for cmd in $1; do 1313233294Sstas IFS=$save_ifs 1314233294Sstas eval cmd=\"$cmd\" 1315233294Sstas func_show_eval "$cmd" "${2-:}" 1316233294Sstas done 1317233294Sstas IFS=$save_ifs 1318233294Sstas} 1319233294Sstas 1320233294Sstas 1321233294Sstas# func_source file 1322233294Sstas# Source FILE, adding directory component if necessary. 1323233294Sstas# Note that it is not necessary on cygwin/mingw to append a dot to 1324233294Sstas# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 1325233294Sstas# behavior happens only for exec(3), not for open(2)! Also, sourcing 1326233294Sstas# `FILE.' does not work on cygwin managed mounts. 1327233294Sstasfunc_source () 1328233294Sstas{ 1329233294Sstas $opt_debug 1330233294Sstas case $1 in 1331233294Sstas */* | *\\*) . "$1" ;; 1332233294Sstas *) . "./$1" ;; 1333233294Sstas esac 1334233294Sstas} 1335233294Sstas 1336233294Sstas 1337233294Sstas# func_resolve_sysroot PATH 1338233294Sstas# Replace a leading = in PATH with a sysroot. Store the result into 1339233294Sstas# func_resolve_sysroot_result 1340233294Sstasfunc_resolve_sysroot () 1341233294Sstas{ 1342233294Sstas func_resolve_sysroot_result=$1 1343233294Sstas case $func_resolve_sysroot_result in 1344233294Sstas =*) 1345233294Sstas func_stripname '=' '' "$func_resolve_sysroot_result" 1346233294Sstas func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 1347127808Snectar ;; 1348127808Snectar esac 1349127808Snectar} 1350127808Snectar 1351233294Sstas# func_replace_sysroot PATH 1352233294Sstas# If PATH begins with the sysroot, replace it with = and 1353233294Sstas# store the result into func_replace_sysroot_result. 1354233294Sstasfunc_replace_sysroot () 1355233294Sstas{ 1356233294Sstas case "$lt_sysroot:$1" in 1357233294Sstas ?*:"$lt_sysroot"*) 1358233294Sstas func_stripname "$lt_sysroot" '' "$1" 1359233294Sstas func_replace_sysroot_result="=$func_stripname_result" 1360233294Sstas ;; 1361233294Sstas *) 1362233294Sstas # Including no sysroot. 1363233294Sstas func_replace_sysroot_result=$1 1364233294Sstas ;; 1365233294Sstas esac 1366233294Sstas} 1367178825Sdfr 1368178825Sdfr# func_infer_tag arg 1369178825Sdfr# Infer tagged configuration to use if any are available and 1370178825Sdfr# if one wasn't chosen via the "--tag" command line option. 1371178825Sdfr# Only attempt this if the compiler in the base compile 1372178825Sdfr# command doesn't match the default compiler. 1373178825Sdfr# arg is usually of the form 'gcc ...' 1374178825Sdfrfunc_infer_tag () 1375178825Sdfr{ 1376233294Sstas $opt_debug 1377178825Sdfr if test -n "$available_tags" && test -z "$tagname"; then 1378178825Sdfr CC_quoted= 1379178825Sdfr for arg in $CC; do 1380233294Sstas func_append_quoted CC_quoted "$arg" 1381178825Sdfr done 1382233294Sstas CC_expanded=`func_echo_all $CC` 1383233294Sstas CC_quoted_expanded=`func_echo_all $CC_quoted` 1384178825Sdfr case $@ in 1385178825Sdfr # Blanks in the command may have been stripped by the calling shell, 1386178825Sdfr # but not from the CC environment variable when configure was run. 1387233294Sstas " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1388233294Sstas " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 1389178825Sdfr # Blanks at the start of $base_compile will cause this to fail 1390178825Sdfr # if we don't check for them as well. 1391178825Sdfr *) 1392178825Sdfr for z in $available_tags; do 1393233294Sstas if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 1394178825Sdfr # Evaluate the configuration. 1395178825Sdfr eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 1396178825Sdfr CC_quoted= 1397178825Sdfr for arg in $CC; do 1398233294Sstas # Double-quote args containing other shell metacharacters. 1399233294Sstas func_append_quoted CC_quoted "$arg" 1400233294Sstas done 1401233294Sstas CC_expanded=`func_echo_all $CC` 1402233294Sstas CC_quoted_expanded=`func_echo_all $CC_quoted` 1403178825Sdfr case "$@ " in 1404233294Sstas " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1405233294Sstas " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 1406178825Sdfr # The compiler in the base compile command matches 1407178825Sdfr # the one in the tagged configuration. 1408178825Sdfr # Assume this is the tagged configuration we want. 1409178825Sdfr tagname=$z 1410178825Sdfr break 1411178825Sdfr ;; 1412178825Sdfr esac 1413178825Sdfr fi 1414178825Sdfr done 1415178825Sdfr # If $tagname still isn't set, then no tagged configuration 1416178825Sdfr # was found and let the user know that the "--tag" command 1417178825Sdfr # line option must be used. 1418178825Sdfr if test -z "$tagname"; then 1419233294Sstas func_echo "unable to infer tagged configuration" 1420233294Sstas func_fatal_error "specify a tag with \`--tag'" 1421233294Sstas# else 1422233294Sstas# func_verbose "using $tagname tagged configuration" 1423178825Sdfr fi 1424178825Sdfr ;; 1425178825Sdfr esac 1426178825Sdfr fi 1427178825Sdfr} 1428178825Sdfr 1429178825Sdfr 1430233294Sstas 1431233294Sstas# func_write_libtool_object output_name pic_name nonpic_name 1432233294Sstas# Create a libtool object file (analogous to a ".la" file), 1433233294Sstas# but don't create it if we're doing a dry run. 1434233294Sstasfunc_write_libtool_object () 1435178825Sdfr{ 1436233294Sstas write_libobj=${1} 1437233294Sstas if test "$build_libtool_libs" = yes; then 1438233294Sstas write_lobj=\'${2}\' 1439233294Sstas else 1440233294Sstas write_lobj=none 1441233294Sstas fi 1442178825Sdfr 1443233294Sstas if test "$build_old_libs" = yes; then 1444233294Sstas write_oldobj=\'${3}\' 1445178825Sdfr else 1446233294Sstas write_oldobj=none 1447178825Sdfr fi 1448233294Sstas 1449233294Sstas $opt_dry_run || { 1450233294Sstas cat >${write_libobj}T <<EOF 1451233294Sstas# $write_libobj - a libtool object file 1452233294Sstas# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1453233294Sstas# 1454233294Sstas# Please DO NOT delete this file! 1455233294Sstas# It is necessary for linking the library. 1456233294Sstas 1457233294Sstas# Name of the PIC object. 1458233294Sstaspic_object=$write_lobj 1459233294Sstas 1460233294Sstas# Name of the non-PIC object 1461233294Sstasnon_pic_object=$write_oldobj 1462233294Sstas 1463233294SstasEOF 1464233294Sstas $MV "${write_libobj}T" "${write_libobj}" 1465233294Sstas } 1466178825Sdfr} 1467178825Sdfr 1468233294Sstas 1469233294Sstas################################################## 1470233294Sstas# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 1471233294Sstas################################################## 1472233294Sstas 1473233294Sstas# func_convert_core_file_wine_to_w32 ARG 1474233294Sstas# Helper function used by file name conversion functions when $build is *nix, 1475233294Sstas# and $host is mingw, cygwin, or some other w32 environment. Relies on a 1476233294Sstas# correctly configured wine environment available, with the winepath program 1477233294Sstas# in $build's $PATH. 1478233294Sstas# 1479233294Sstas# ARG is the $build file name to be converted to w32 format. 1480233294Sstas# Result is available in $func_convert_core_file_wine_to_w32_result, and will 1481233294Sstas# be empty on error (or when ARG is empty) 1482233294Sstasfunc_convert_core_file_wine_to_w32 () 1483178825Sdfr{ 1484233294Sstas $opt_debug 1485233294Sstas func_convert_core_file_wine_to_w32_result="$1" 1486233294Sstas if test -n "$1"; then 1487233294Sstas # Unfortunately, winepath does not exit with a non-zero error code, so we 1488233294Sstas # are forced to check the contents of stdout. On the other hand, if the 1489233294Sstas # command is not found, the shell will set an exit code of 127 and print 1490233294Sstas # *an error message* to stdout. So we must check for both error code of 1491233294Sstas # zero AND non-empty stdout, which explains the odd construction: 1492233294Sstas func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 1493233294Sstas if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 1494233294Sstas func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 1495233294Sstas $SED -e "$lt_sed_naive_backslashify"` 1496233294Sstas else 1497233294Sstas func_convert_core_file_wine_to_w32_result= 1498178825Sdfr fi 1499233294Sstas fi 1500233294Sstas} 1501233294Sstas# end: func_convert_core_file_wine_to_w32 1502178825Sdfr 1503178825Sdfr 1504233294Sstas# func_convert_core_path_wine_to_w32 ARG 1505233294Sstas# Helper function used by path conversion functions when $build is *nix, and 1506233294Sstas# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 1507233294Sstas# configured wine environment available, with the winepath program in $build's 1508233294Sstas# $PATH. Assumes ARG has no leading or trailing path separator characters. 1509233294Sstas# 1510233294Sstas# ARG is path to be converted from $build format to win32. 1511233294Sstas# Result is available in $func_convert_core_path_wine_to_w32_result. 1512233294Sstas# Unconvertible file (directory) names in ARG are skipped; if no directory names 1513233294Sstas# are convertible, then the result may be empty. 1514233294Sstasfunc_convert_core_path_wine_to_w32 () 1515233294Sstas{ 1516233294Sstas $opt_debug 1517233294Sstas # unfortunately, winepath doesn't convert paths, only file names 1518233294Sstas func_convert_core_path_wine_to_w32_result="" 1519233294Sstas if test -n "$1"; then 1520233294Sstas oldIFS=$IFS 1521233294Sstas IFS=: 1522233294Sstas for func_convert_core_path_wine_to_w32_f in $1; do 1523233294Sstas IFS=$oldIFS 1524233294Sstas func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 1525233294Sstas if test -n "$func_convert_core_file_wine_to_w32_result" ; then 1526233294Sstas if test -z "$func_convert_core_path_wine_to_w32_result"; then 1527233294Sstas func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 1528233294Sstas else 1529233294Sstas func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 1530233294Sstas fi 1531178825Sdfr fi 1532178825Sdfr done 1533233294Sstas IFS=$oldIFS 1534233294Sstas fi 1535178825Sdfr} 1536233294Sstas# end: func_convert_core_path_wine_to_w32 1537127808Snectar 1538178825Sdfr 1539233294Sstas# func_cygpath ARGS... 1540233294Sstas# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 1541233294Sstas# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 1542233294Sstas# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 1543233294Sstas# (2), returns the Cygwin file name or path in func_cygpath_result (input 1544233294Sstas# file name or path is assumed to be in w32 format, as previously converted 1545233294Sstas# from $build's *nix or MSYS format). In case (3), returns the w32 file name 1546233294Sstas# or path in func_cygpath_result (input file name or path is assumed to be in 1547233294Sstas# Cygwin format). Returns an empty string on error. 1548233294Sstas# 1549233294Sstas# ARGS are passed to cygpath, with the last one being the file name or path to 1550233294Sstas# be converted. 1551233294Sstas# 1552233294Sstas# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 1553233294Sstas# environment variable; do not put it in $PATH. 1554233294Sstasfunc_cygpath () 1555233294Sstas{ 1556233294Sstas $opt_debug 1557233294Sstas if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 1558233294Sstas func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 1559233294Sstas if test "$?" -ne 0; then 1560233294Sstas # on failure, ensure result is empty 1561233294Sstas func_cygpath_result= 1562233294Sstas fi 1563233294Sstas else 1564233294Sstas func_cygpath_result= 1565233294Sstas func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 1566233294Sstas fi 1567233294Sstas} 1568233294Sstas#end: func_cygpath 1569178825Sdfr 157055682Smarkm 1571233294Sstas# func_convert_core_msys_to_w32 ARG 1572233294Sstas# Convert file name or path ARG from MSYS format to w32 format. Return 1573233294Sstas# result in func_convert_core_msys_to_w32_result. 1574233294Sstasfunc_convert_core_msys_to_w32 () 1575233294Sstas{ 1576233294Sstas $opt_debug 1577233294Sstas # awkward: cmd appends spaces to result 1578233294Sstas func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 1579233294Sstas $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 1580233294Sstas} 1581233294Sstas#end: func_convert_core_msys_to_w32 1582233294Sstas 1583233294Sstas 1584233294Sstas# func_convert_file_check ARG1 ARG2 1585233294Sstas# Verify that ARG1 (a file name in $build format) was converted to $host 1586233294Sstas# format in ARG2. Otherwise, emit an error message, but continue (resetting 1587233294Sstas# func_to_host_file_result to ARG1). 1588233294Sstasfunc_convert_file_check () 1589233294Sstas{ 1590233294Sstas $opt_debug 1591233294Sstas if test -z "$2" && test -n "$1" ; then 1592233294Sstas func_error "Could not determine host file name corresponding to" 1593233294Sstas func_error " \`$1'" 1594233294Sstas func_error "Continuing, but uninstalled executables may not work." 1595233294Sstas # Fallback: 1596233294Sstas func_to_host_file_result="$1" 1597233294Sstas fi 1598233294Sstas} 1599233294Sstas# end func_convert_file_check 1600233294Sstas 1601233294Sstas 1602233294Sstas# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 1603233294Sstas# Verify that FROM_PATH (a path in $build format) was converted to $host 1604233294Sstas# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 1605233294Sstas# func_to_host_file_result to a simplistic fallback value (see below). 1606233294Sstasfunc_convert_path_check () 1607233294Sstas{ 1608233294Sstas $opt_debug 1609233294Sstas if test -z "$4" && test -n "$3"; then 1610233294Sstas func_error "Could not determine the host path corresponding to" 1611233294Sstas func_error " \`$3'" 1612233294Sstas func_error "Continuing, but uninstalled executables may not work." 1613233294Sstas # Fallback. This is a deliberately simplistic "conversion" and 1614233294Sstas # should not be "improved". See libtool.info. 1615233294Sstas if test "x$1" != "x$2"; then 1616233294Sstas lt_replace_pathsep_chars="s|$1|$2|g" 1617233294Sstas func_to_host_path_result=`echo "$3" | 1618233294Sstas $SED -e "$lt_replace_pathsep_chars"` 1619233294Sstas else 1620233294Sstas func_to_host_path_result="$3" 1621233294Sstas fi 1622233294Sstas fi 1623233294Sstas} 1624233294Sstas# end func_convert_path_check 1625233294Sstas 1626233294Sstas 1627233294Sstas# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 1628233294Sstas# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 1629233294Sstas# and appending REPL if ORIG matches BACKPAT. 1630233294Sstasfunc_convert_path_front_back_pathsep () 1631233294Sstas{ 1632233294Sstas $opt_debug 1633233294Sstas case $4 in 1634233294Sstas $1 ) func_to_host_path_result="$3$func_to_host_path_result" 1635233294Sstas ;; 163655682Smarkm esac 1637233294Sstas case $4 in 1638233294Sstas $2 ) func_append func_to_host_path_result "$3" 1639233294Sstas ;; 1640233294Sstas esac 1641233294Sstas} 1642233294Sstas# end func_convert_path_front_back_pathsep 164355682Smarkm 1644127808Snectar 1645233294Sstas################################################## 1646233294Sstas# $build to $host FILE NAME CONVERSION FUNCTIONS # 1647233294Sstas################################################## 1648233294Sstas# invoked via `$to_host_file_cmd ARG' 1649233294Sstas# 1650233294Sstas# In each case, ARG is the path to be converted from $build to $host format. 1651233294Sstas# Result will be available in $func_to_host_file_result. 1652127808Snectar 1653233294Sstas 1654233294Sstas# func_to_host_file ARG 1655233294Sstas# Converts the file name ARG from $build format to $host format. Return result 1656233294Sstas# in func_to_host_file_result. 1657233294Sstasfunc_to_host_file () 1658233294Sstas{ 1659233294Sstas $opt_debug 1660233294Sstas $to_host_file_cmd "$1" 1661233294Sstas} 1662233294Sstas# end func_to_host_file 1663233294Sstas 1664233294Sstas 1665233294Sstas# func_to_tool_file ARG LAZY 1666233294Sstas# converts the file name ARG from $build format to toolchain format. Return 1667233294Sstas# result in func_to_tool_file_result. If the conversion in use is listed 1668233294Sstas# in (the comma separated) LAZY, no conversion takes place. 1669233294Sstasfunc_to_tool_file () 1670233294Sstas{ 1671233294Sstas $opt_debug 1672233294Sstas case ,$2, in 1673233294Sstas *,"$to_tool_file_cmd",*) 1674233294Sstas func_to_tool_file_result=$1 1675127808Snectar ;; 167655682Smarkm *) 1677233294Sstas $to_tool_file_cmd "$1" 1678233294Sstas func_to_tool_file_result=$func_to_host_file_result 167955682Smarkm ;; 1680233294Sstas esac 1681233294Sstas} 1682233294Sstas# end func_to_tool_file 168355682Smarkm 1684233294Sstas 1685233294Sstas# func_convert_file_noop ARG 1686233294Sstas# Copy ARG to func_to_host_file_result. 1687233294Sstasfunc_convert_file_noop () 1688233294Sstas{ 1689233294Sstas func_to_host_file_result="$1" 1690233294Sstas} 1691233294Sstas# end func_convert_file_noop 1692233294Sstas 1693233294Sstas 1694233294Sstas# func_convert_file_msys_to_w32 ARG 1695233294Sstas# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 1696233294Sstas# conversion to w32 is not available inside the cwrapper. Returns result in 1697233294Sstas# func_to_host_file_result. 1698233294Sstasfunc_convert_file_msys_to_w32 () 1699233294Sstas{ 1700233294Sstas $opt_debug 1701233294Sstas func_to_host_file_result="$1" 1702233294Sstas if test -n "$1"; then 1703233294Sstas func_convert_core_msys_to_w32 "$1" 1704233294Sstas func_to_host_file_result="$func_convert_core_msys_to_w32_result" 170555682Smarkm fi 1706233294Sstas func_convert_file_check "$1" "$func_to_host_file_result" 1707233294Sstas} 1708233294Sstas# end func_convert_file_msys_to_w32 170955682Smarkm 171055682Smarkm 1711233294Sstas# func_convert_file_cygwin_to_w32 ARG 1712233294Sstas# Convert file name ARG from Cygwin to w32 format. Returns result in 1713233294Sstas# func_to_host_file_result. 1714233294Sstasfunc_convert_file_cygwin_to_w32 () 1715233294Sstas{ 1716233294Sstas $opt_debug 1717233294Sstas func_to_host_file_result="$1" 1718233294Sstas if test -n "$1"; then 1719233294Sstas # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 1720233294Sstas # LT_CYGPATH in this case. 1721233294Sstas func_to_host_file_result=`cygpath -m "$1"` 1722233294Sstas fi 1723233294Sstas func_convert_file_check "$1" "$func_to_host_file_result" 1724233294Sstas} 1725233294Sstas# end func_convert_file_cygwin_to_w32 172655682Smarkm 172755682Smarkm 1728233294Sstas# func_convert_file_nix_to_w32 ARG 1729233294Sstas# Convert file name ARG from *nix to w32 format. Requires a wine environment 1730233294Sstas# and a working winepath. Returns result in func_to_host_file_result. 1731233294Sstasfunc_convert_file_nix_to_w32 () 1732233294Sstas{ 1733233294Sstas $opt_debug 1734233294Sstas func_to_host_file_result="$1" 1735233294Sstas if test -n "$1"; then 1736233294Sstas func_convert_core_file_wine_to_w32 "$1" 1737233294Sstas func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 1738233294Sstas fi 1739233294Sstas func_convert_file_check "$1" "$func_to_host_file_result" 1740233294Sstas} 1741233294Sstas# end func_convert_file_nix_to_w32 174255682Smarkm 174355682Smarkm 1744233294Sstas# func_convert_file_msys_to_cygwin ARG 1745233294Sstas# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1746233294Sstas# Returns result in func_to_host_file_result. 1747233294Sstasfunc_convert_file_msys_to_cygwin () 1748233294Sstas{ 1749233294Sstas $opt_debug 1750233294Sstas func_to_host_file_result="$1" 1751233294Sstas if test -n "$1"; then 1752233294Sstas func_convert_core_msys_to_w32 "$1" 1753233294Sstas func_cygpath -u "$func_convert_core_msys_to_w32_result" 1754233294Sstas func_to_host_file_result="$func_cygpath_result" 1755233294Sstas fi 1756233294Sstas func_convert_file_check "$1" "$func_to_host_file_result" 1757233294Sstas} 1758233294Sstas# end func_convert_file_msys_to_cygwin 175955682Smarkm 176055682Smarkm 1761233294Sstas# func_convert_file_nix_to_cygwin ARG 1762233294Sstas# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 1763233294Sstas# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 1764233294Sstas# in func_to_host_file_result. 1765233294Sstasfunc_convert_file_nix_to_cygwin () 1766233294Sstas{ 1767233294Sstas $opt_debug 1768233294Sstas func_to_host_file_result="$1" 1769233294Sstas if test -n "$1"; then 1770233294Sstas # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 1771233294Sstas func_convert_core_file_wine_to_w32 "$1" 1772233294Sstas func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 1773233294Sstas func_to_host_file_result="$func_cygpath_result" 1774233294Sstas fi 1775233294Sstas func_convert_file_check "$1" "$func_to_host_file_result" 1776233294Sstas} 1777233294Sstas# end func_convert_file_nix_to_cygwin 177855682Smarkm 1779127808Snectar 1780233294Sstas############################################# 1781233294Sstas# $build to $host PATH CONVERSION FUNCTIONS # 1782233294Sstas############################################# 1783233294Sstas# invoked via `$to_host_path_cmd ARG' 1784233294Sstas# 1785233294Sstas# In each case, ARG is the path to be converted from $build to $host format. 1786233294Sstas# The result will be available in $func_to_host_path_result. 1787233294Sstas# 1788233294Sstas# Path separators are also converted from $build format to $host format. If 1789233294Sstas# ARG begins or ends with a path separator character, it is preserved (but 1790233294Sstas# converted to $host format) on output. 1791233294Sstas# 1792233294Sstas# All path conversion functions are named using the following convention: 1793233294Sstas# file name conversion function : func_convert_file_X_to_Y () 1794233294Sstas# path conversion function : func_convert_path_X_to_Y () 1795233294Sstas# where, for any given $build/$host combination the 'X_to_Y' value is the 1796233294Sstas# same. If conversion functions are added for new $build/$host combinations, 1797233294Sstas# the two new functions must follow this pattern, or func_init_to_host_path_cmd 1798233294Sstas# will break. 179955682Smarkm 1800127808Snectar 1801233294Sstas# func_init_to_host_path_cmd 1802233294Sstas# Ensures that function "pointer" variable $to_host_path_cmd is set to the 1803233294Sstas# appropriate value, based on the value of $to_host_file_cmd. 1804233294Sstasto_host_path_cmd= 1805233294Sstasfunc_init_to_host_path_cmd () 1806233294Sstas{ 1807233294Sstas $opt_debug 1808233294Sstas if test -z "$to_host_path_cmd"; then 1809233294Sstas func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 1810233294Sstas to_host_path_cmd="func_convert_path_${func_stripname_result}" 1811233294Sstas fi 1812233294Sstas} 181355682Smarkm 181455682Smarkm 1815233294Sstas# func_to_host_path ARG 1816233294Sstas# Converts the path ARG from $build format to $host format. Return result 1817233294Sstas# in func_to_host_path_result. 1818233294Sstasfunc_to_host_path () 1819233294Sstas{ 1820233294Sstas $opt_debug 1821233294Sstas func_init_to_host_path_cmd 1822233294Sstas $to_host_path_cmd "$1" 1823233294Sstas} 1824233294Sstas# end func_to_host_path 182555682Smarkm 182655682Smarkm 1827233294Sstas# func_convert_path_noop ARG 1828233294Sstas# Copy ARG to func_to_host_path_result. 1829233294Sstasfunc_convert_path_noop () 1830233294Sstas{ 1831233294Sstas func_to_host_path_result="$1" 1832233294Sstas} 1833233294Sstas# end func_convert_path_noop 1834178825Sdfr 1835102644Snectar 1836233294Sstas# func_convert_path_msys_to_w32 ARG 1837233294Sstas# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 1838233294Sstas# conversion to w32 is not available inside the cwrapper. Returns result in 1839233294Sstas# func_to_host_path_result. 1840233294Sstasfunc_convert_path_msys_to_w32 () 1841233294Sstas{ 1842233294Sstas $opt_debug 1843233294Sstas func_to_host_path_result="$1" 1844233294Sstas if test -n "$1"; then 1845233294Sstas # Remove leading and trailing path separator characters from ARG. MSYS 1846233294Sstas # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 1847233294Sstas # and winepath ignores them completely. 1848233294Sstas func_stripname : : "$1" 1849233294Sstas func_to_host_path_tmp1=$func_stripname_result 1850233294Sstas func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1851233294Sstas func_to_host_path_result="$func_convert_core_msys_to_w32_result" 1852233294Sstas func_convert_path_check : ";" \ 1853233294Sstas "$func_to_host_path_tmp1" "$func_to_host_path_result" 1854233294Sstas func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1855233294Sstas fi 1856233294Sstas} 1857233294Sstas# end func_convert_path_msys_to_w32 185855682Smarkm 185955682Smarkm 1860233294Sstas# func_convert_path_cygwin_to_w32 ARG 1861233294Sstas# Convert path ARG from Cygwin to w32 format. Returns result in 1862233294Sstas# func_to_host_file_result. 1863233294Sstasfunc_convert_path_cygwin_to_w32 () 1864233294Sstas{ 1865233294Sstas $opt_debug 1866233294Sstas func_to_host_path_result="$1" 1867233294Sstas if test -n "$1"; then 1868233294Sstas # See func_convert_path_msys_to_w32: 1869233294Sstas func_stripname : : "$1" 1870233294Sstas func_to_host_path_tmp1=$func_stripname_result 1871233294Sstas func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 1872233294Sstas func_convert_path_check : ";" \ 1873233294Sstas "$func_to_host_path_tmp1" "$func_to_host_path_result" 1874233294Sstas func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 187555682Smarkm fi 1876233294Sstas} 1877233294Sstas# end func_convert_path_cygwin_to_w32 187855682Smarkm 1879233294Sstas 1880233294Sstas# func_convert_path_nix_to_w32 ARG 1881233294Sstas# Convert path ARG from *nix to w32 format. Requires a wine environment and 1882233294Sstas# a working winepath. Returns result in func_to_host_file_result. 1883233294Sstasfunc_convert_path_nix_to_w32 () 1884233294Sstas{ 1885233294Sstas $opt_debug 1886233294Sstas func_to_host_path_result="$1" 1887233294Sstas if test -n "$1"; then 1888233294Sstas # See func_convert_path_msys_to_w32: 1889233294Sstas func_stripname : : "$1" 1890233294Sstas func_to_host_path_tmp1=$func_stripname_result 1891233294Sstas func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1892233294Sstas func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 1893233294Sstas func_convert_path_check : ";" \ 1894233294Sstas "$func_to_host_path_tmp1" "$func_to_host_path_result" 1895233294Sstas func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 189655682Smarkm fi 1897233294Sstas} 1898233294Sstas# end func_convert_path_nix_to_w32 189955682Smarkm 190055682Smarkm 1901233294Sstas# func_convert_path_msys_to_cygwin ARG 1902233294Sstas# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1903233294Sstas# Returns result in func_to_host_file_result. 1904233294Sstasfunc_convert_path_msys_to_cygwin () 1905233294Sstas{ 1906233294Sstas $opt_debug 1907233294Sstas func_to_host_path_result="$1" 1908233294Sstas if test -n "$1"; then 1909233294Sstas # See func_convert_path_msys_to_w32: 1910233294Sstas func_stripname : : "$1" 1911233294Sstas func_to_host_path_tmp1=$func_stripname_result 1912233294Sstas func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1913233294Sstas func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 1914233294Sstas func_to_host_path_result="$func_cygpath_result" 1915233294Sstas func_convert_path_check : : \ 1916233294Sstas "$func_to_host_path_tmp1" "$func_to_host_path_result" 1917233294Sstas func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1918233294Sstas fi 1919233294Sstas} 1920233294Sstas# end func_convert_path_msys_to_cygwin 1921233294Sstas 1922233294Sstas 1923233294Sstas# func_convert_path_nix_to_cygwin ARG 1924233294Sstas# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 1925233294Sstas# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 1926233294Sstas# func_to_host_file_result. 1927233294Sstasfunc_convert_path_nix_to_cygwin () 1928233294Sstas{ 1929233294Sstas $opt_debug 1930233294Sstas func_to_host_path_result="$1" 1931233294Sstas if test -n "$1"; then 1932233294Sstas # Remove leading and trailing path separator characters from 1933233294Sstas # ARG. msys behavior is inconsistent here, cygpath turns them 1934233294Sstas # into '.;' and ';.', and winepath ignores them completely. 1935233294Sstas func_stripname : : "$1" 1936233294Sstas func_to_host_path_tmp1=$func_stripname_result 1937233294Sstas func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1938233294Sstas func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 1939233294Sstas func_to_host_path_result="$func_cygpath_result" 1940233294Sstas func_convert_path_check : : \ 1941233294Sstas "$func_to_host_path_tmp1" "$func_to_host_path_result" 1942233294Sstas func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1943233294Sstas fi 1944233294Sstas} 1945233294Sstas# end func_convert_path_nix_to_cygwin 1946233294Sstas 1947233294Sstas 1948233294Sstas# func_mode_compile arg... 1949233294Sstasfunc_mode_compile () 1950233294Sstas{ 1951233294Sstas $opt_debug 195255682Smarkm # Get the compilation command and the source file. 195355682Smarkm base_compile= 1954127808Snectar srcfile="$nonopt" # always keep a non-empty value in "srcfile" 1955127808Snectar suppress_opt=yes 195655682Smarkm suppress_output= 1957127808Snectar arg_mode=normal 1958127808Snectar libobj= 1959127808Snectar later= 1960233294Sstas pie_flag= 196155682Smarkm 196255682Smarkm for arg 196355682Smarkm do 1964178825Sdfr case $arg_mode in 1965127808Snectar arg ) 1966127808Snectar # do not "continue". Instead, add this to base_compile 1967127808Snectar lastarg="$arg" 1968127808Snectar arg_mode=normal 1969127808Snectar ;; 197072445Sassar 1971127808Snectar target ) 1972127808Snectar libobj="$arg" 1973127808Snectar arg_mode=normal 197472445Sassar continue 197572445Sassar ;; 197672445Sassar 1977127808Snectar normal ) 1978127808Snectar # Accept any command-line options. 1979127808Snectar case $arg in 1980127808Snectar -o) 1981233294Sstas test -n "$libobj" && \ 1982233294Sstas func_fatal_error "you cannot specify \`-o' more than once" 1983127808Snectar arg_mode=target 1984127808Snectar continue 1985127808Snectar ;; 198655682Smarkm 1987233294Sstas -pie | -fpie | -fPIE) 1988233294Sstas func_append pie_flag " $arg" 1989127808Snectar continue 1990127808Snectar ;; 199172445Sassar 1992233294Sstas -shared | -static | -prefer-pic | -prefer-non-pic) 1993233294Sstas func_append later " $arg" 1994233294Sstas continue 1995233294Sstas ;; 1996233294Sstas 1997127808Snectar -no-suppress) 1998127808Snectar suppress_opt=no 1999127808Snectar continue 2000127808Snectar ;; 200172445Sassar 2002127808Snectar -Xcompiler) 2003127808Snectar arg_mode=arg # the next one goes into the "base_compile" arg list 2004127808Snectar continue # The current "srcfile" will either be retained or 2005127808Snectar ;; # replaced later. I would guess that would be a bug. 200672445Sassar 2007127808Snectar -Wc,*) 2008233294Sstas func_stripname '-Wc,' '' "$arg" 2009233294Sstas args=$func_stripname_result 2010127808Snectar lastarg= 2011127808Snectar save_ifs="$IFS"; IFS=',' 2012233294Sstas for arg in $args; do 2013127808Snectar IFS="$save_ifs" 2014233294Sstas func_append_quoted lastarg "$arg" 2015127808Snectar done 201672445Sassar IFS="$save_ifs" 2017233294Sstas func_stripname ' ' '' "$lastarg" 2018233294Sstas lastarg=$func_stripname_result 201972445Sassar 2020127808Snectar # Add the arguments to base_compile. 2021233294Sstas func_append base_compile " $lastarg" 2022127808Snectar continue 2023127808Snectar ;; 202455682Smarkm 2025233294Sstas *) 2026127808Snectar # Accept the current argument as the source file. 2027127808Snectar # The previous "srcfile" becomes the current argument. 2028127808Snectar # 2029127808Snectar lastarg="$srcfile" 2030127808Snectar srcfile="$arg" 2031127808Snectar ;; 2032127808Snectar esac # case $arg 203372445Sassar ;; 2034127808Snectar esac # case $arg_mode 203555682Smarkm 203655682Smarkm # Aesthetically quote the previous argument. 2037233294Sstas func_append_quoted base_compile "$lastarg" 2038127808Snectar done # for arg 203955682Smarkm 2040127808Snectar case $arg_mode in 2041127808Snectar arg) 2042233294Sstas func_fatal_error "you must specify an argument for -Xcompile" 204355682Smarkm ;; 2044127808Snectar target) 2045233294Sstas func_fatal_error "you must specify a target with \`-o'" 204655682Smarkm ;; 2047127808Snectar *) 2048127808Snectar # Get the name of the library object. 2049233294Sstas test -z "$libobj" && { 2050233294Sstas func_basename "$srcfile" 2051233294Sstas libobj="$func_basename_result" 2052233294Sstas } 2053127808Snectar ;; 205455682Smarkm esac 205555682Smarkm 205655682Smarkm # Recognize several different file suffixes. 205755682Smarkm # If the user specifies -o file.o, it is replaced with file.lo 205890926Snectar case $libobj in 2059233294Sstas *.[cCFSifmso] | \ 2060233294Sstas *.ada | *.adb | *.ads | *.asm | \ 2061233294Sstas *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 2062233294Sstas *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) 2063233294Sstas func_xform "$libobj" 2064233294Sstas libobj=$func_xform_result 2065233294Sstas ;; 206655682Smarkm esac 206755682Smarkm 206890926Snectar case $libobj in 2069233294Sstas *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 207055682Smarkm *) 2071233294Sstas func_fatal_error "cannot determine name of library object from \`$libobj'" 207255682Smarkm ;; 207355682Smarkm esac 207455682Smarkm 2075178825Sdfr func_infer_tag $base_compile 2076127808Snectar 2077127808Snectar for arg in $later; do 2078127808Snectar case $arg in 2079233294Sstas -shared) 2080233294Sstas test "$build_libtool_libs" != yes && \ 2081233294Sstas func_fatal_configuration "can not build a shared library" 2082233294Sstas build_old_libs=no 2083233294Sstas continue 2084233294Sstas ;; 2085233294Sstas 2086127808Snectar -static) 2087233294Sstas build_libtool_libs=no 2088127808Snectar build_old_libs=yes 2089127808Snectar continue 2090127808Snectar ;; 2091127808Snectar 2092127808Snectar -prefer-pic) 2093127808Snectar pic_mode=yes 2094127808Snectar continue 2095127808Snectar ;; 2096127808Snectar 2097127808Snectar -prefer-non-pic) 2098127808Snectar pic_mode=no 2099127808Snectar continue 2100127808Snectar ;; 2101127808Snectar esac 2102127808Snectar done 2103127808Snectar 2104233294Sstas func_quote_for_eval "$libobj" 2105233294Sstas test "X$libobj" != "X$func_quote_for_eval_result" \ 2106233294Sstas && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 2107233294Sstas && func_warning "libobj name \`$libobj' may not contain shell special characters." 2108233294Sstas func_dirname_and_basename "$obj" "/" "" 2109233294Sstas objname="$func_basename_result" 2110233294Sstas xdir="$func_dirname_result" 2111127808Snectar lobj=${xdir}$objdir/$objname 2112127808Snectar 2113233294Sstas test -z "$base_compile" && \ 2114233294Sstas func_fatal_help "you must specify a compilation command" 211555682Smarkm 211655682Smarkm # Delete any leftover library objects. 211755682Smarkm if test "$build_old_libs" = yes; then 2118127808Snectar removelist="$obj $lobj $libobj ${libobj}T" 211955682Smarkm else 2120127808Snectar removelist="$lobj $libobj ${libobj}T" 212155682Smarkm fi 212255682Smarkm 212372445Sassar # On Cygwin there's no "real" PIC flag so we must build both object types 212490926Snectar case $host_os in 2125233294Sstas cygwin* | mingw* | pw32* | os2* | cegcc*) 212672445Sassar pic_mode=default 212772445Sassar ;; 212872445Sassar esac 2129127808Snectar if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 213072445Sassar # non-PIC code in shared libraries is not supported 213172445Sassar pic_mode=default 213272445Sassar fi 213372445Sassar 213455682Smarkm # Calculate the filename of the output object if compiler does 213555682Smarkm # not support -o with -c 213655682Smarkm if test "$compiler_c_o" = no; then 2137233294Sstas output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 213855682Smarkm lockfile="$output_obj.lock" 213955682Smarkm else 2140127808Snectar output_obj= 214155682Smarkm need_locks=no 214255682Smarkm lockfile= 214355682Smarkm fi 214455682Smarkm 214555682Smarkm # Lock this critical section if it is needed 214655682Smarkm # We use this script file to make the link, it avoids creating a new file 214755682Smarkm if test "$need_locks" = yes; then 2148233294Sstas until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 2149233294Sstas func_echo "Waiting for $lockfile to be removed" 215072445Sassar sleep 2 215155682Smarkm done 215255682Smarkm elif test "$need_locks" = warn; then 215355682Smarkm if test -f "$lockfile"; then 2154233294Sstas $ECHO "\ 215555682Smarkm*** ERROR, $lockfile exists and contains: 215655682Smarkm`cat $lockfile 2>/dev/null` 215755682Smarkm 215855682SmarkmThis indicates that another process is trying to use the same 215955682Smarkmtemporary object file, and libtool could not work around it because 216055682Smarkmyour compiler does not support \`-c' and \`-o' together. If you 216155682Smarkmrepeat this compilation, it may succeed, by chance, but you had better 216255682Smarkmavoid parallel builds (make -j) in this platform, or get a better 216355682Smarkmcompiler." 216455682Smarkm 2165233294Sstas $opt_dry_run || $RM $removelist 2166178825Sdfr exit $EXIT_FAILURE 216755682Smarkm fi 2168233294Sstas func_append removelist " $output_obj" 2169233294Sstas $ECHO "$srcfile" > "$lockfile" 217055682Smarkm fi 217155682Smarkm 2172233294Sstas $opt_dry_run || $RM $removelist 2173233294Sstas func_append removelist " $lockfile" 2174233294Sstas trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 217555682Smarkm 2176233294Sstas func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 2177233294Sstas srcfile=$func_to_tool_file_result 2178233294Sstas func_quote_for_eval "$srcfile" 2179233294Sstas qsrcfile=$func_quote_for_eval_result 2180127808Snectar 218155682Smarkm # Only build a PIC object if we are building libtool libraries. 218255682Smarkm if test "$build_libtool_libs" = yes; then 218355682Smarkm # Without this assignment, base_compile gets emptied. 218455682Smarkm fbsd_hideous_sh_bug=$base_compile 218555682Smarkm 218672445Sassar if test "$pic_mode" != no; then 2187178825Sdfr command="$base_compile $qsrcfile $pic_flag" 218872445Sassar else 218972445Sassar # Don't build PIC code 2190178825Sdfr command="$base_compile $qsrcfile" 219172445Sassar fi 219272445Sassar 2193233294Sstas func_mkdir_p "$xdir$objdir" 2194127808Snectar 2195127808Snectar if test -z "$output_obj"; then 2196127808Snectar # Place PIC objects in $objdir 2197233294Sstas func_append command " -o $lobj" 219855682Smarkm fi 219955682Smarkm 2200233294Sstas func_show_eval_locale "$command" \ 2201233294Sstas 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2202127808Snectar 220355682Smarkm if test "$need_locks" = warn && 2204127808Snectar test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2205233294Sstas $ECHO "\ 220655682Smarkm*** ERROR, $lockfile contains: 220755682Smarkm`cat $lockfile 2>/dev/null` 220855682Smarkm 220955682Smarkmbut it should contain: 221055682Smarkm$srcfile 221155682Smarkm 221255682SmarkmThis indicates that another process is trying to use the same 221355682Smarkmtemporary object file, and libtool could not work around it because 221455682Smarkmyour compiler does not support \`-c' and \`-o' together. If you 221555682Smarkmrepeat this compilation, it may succeed, by chance, but you had better 221655682Smarkmavoid parallel builds (make -j) in this platform, or get a better 221755682Smarkmcompiler." 221855682Smarkm 2219233294Sstas $opt_dry_run || $RM $removelist 2220178825Sdfr exit $EXIT_FAILURE 222155682Smarkm fi 222255682Smarkm 222355682Smarkm # Just move the object if needed, then go on to compile the next one 2224127808Snectar if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 2225233294Sstas func_show_eval '$MV "$output_obj" "$lobj"' \ 2226233294Sstas 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 222755682Smarkm fi 222855682Smarkm 2229127808Snectar # Allow error messages only from the first compilation. 2230127808Snectar if test "$suppress_opt" = yes; then 2231233294Sstas suppress_output=' >/dev/null 2>&1' 223255682Smarkm fi 223355682Smarkm fi 223455682Smarkm 223555682Smarkm # Only build a position-dependent object if we build old libraries. 223655682Smarkm if test "$build_old_libs" = yes; then 223772445Sassar if test "$pic_mode" != yes; then 223872445Sassar # Don't build PIC code 2239233294Sstas command="$base_compile $qsrcfile$pie_flag" 224072445Sassar else 2241178825Sdfr command="$base_compile $qsrcfile $pic_flag" 224255682Smarkm fi 224355682Smarkm if test "$compiler_c_o" = yes; then 2244233294Sstas func_append command " -o $obj" 224555682Smarkm fi 224655682Smarkm 224755682Smarkm # Suppress compiler output if we already did a PIC compilation. 2248233294Sstas func_append command "$suppress_output" 2249233294Sstas func_show_eval_locale "$command" \ 2250233294Sstas '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 225155682Smarkm 225255682Smarkm if test "$need_locks" = warn && 2253127808Snectar test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2254233294Sstas $ECHO "\ 225555682Smarkm*** ERROR, $lockfile contains: 225655682Smarkm`cat $lockfile 2>/dev/null` 225755682Smarkm 225855682Smarkmbut it should contain: 225955682Smarkm$srcfile 226055682Smarkm 226155682SmarkmThis indicates that another process is trying to use the same 226255682Smarkmtemporary object file, and libtool could not work around it because 226355682Smarkmyour compiler does not support \`-c' and \`-o' together. If you 226455682Smarkmrepeat this compilation, it may succeed, by chance, but you had better 226555682Smarkmavoid parallel builds (make -j) in this platform, or get a better 226655682Smarkmcompiler." 226755682Smarkm 2268233294Sstas $opt_dry_run || $RM $removelist 2269178825Sdfr exit $EXIT_FAILURE 227055682Smarkm fi 227155682Smarkm 227255682Smarkm # Just move the object if needed 2273127808Snectar if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 2274233294Sstas func_show_eval '$MV "$output_obj" "$obj"' \ 2275233294Sstas 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2276233294Sstas fi 2277233294Sstas fi 2278233294Sstas 2279233294Sstas $opt_dry_run || { 2280233294Sstas func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2281233294Sstas 2282233294Sstas # Unlock the critical section if it was locked 2283233294Sstas if test "$need_locks" != no; then 2284233294Sstas removelist=$lockfile 2285233294Sstas $RM "$lockfile" 2286233294Sstas fi 2287233294Sstas } 2288233294Sstas 2289233294Sstas exit $EXIT_SUCCESS 2290233294Sstas} 2291233294Sstas 2292233294Sstas$opt_help || { 2293233294Sstas test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 2294233294Sstas} 2295233294Sstas 2296233294Sstasfunc_mode_help () 2297233294Sstas{ 2298233294Sstas # We need to display help for each of the modes. 2299233294Sstas case $opt_mode in 2300233294Sstas "") 2301233294Sstas # Generic help is extracted from the usage comments 2302233294Sstas # at the start of this file. 2303233294Sstas func_help 2304233294Sstas ;; 2305233294Sstas 2306233294Sstas clean) 2307233294Sstas $ECHO \ 2308233294Sstas"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2309233294Sstas 2310233294SstasRemove files from the build directory. 2311233294Sstas 2312233294SstasRM is the name of the program to use to delete files associated with each FILE 2313233294Sstas(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2314233294Sstasto RM. 2315233294Sstas 2316233294SstasIf FILE is a libtool library, object or program, all the files associated 2317233294Sstaswith it are deleted. Otherwise, only FILE itself is deleted using RM." 2318233294Sstas ;; 2319233294Sstas 2320233294Sstas compile) 2321233294Sstas $ECHO \ 2322233294Sstas"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2323233294Sstas 2324233294SstasCompile a source file into a libtool library object. 2325233294Sstas 2326233294SstasThis mode accepts the following additional options: 2327233294Sstas 2328233294Sstas -o OUTPUT-FILE set the output file name to OUTPUT-FILE 2329233294Sstas -no-suppress do not suppress compiler output for multiple passes 2330233294Sstas -prefer-pic try to build PIC objects only 2331233294Sstas -prefer-non-pic try to build non-PIC objects only 2332233294Sstas -shared do not build a \`.o' file suitable for static linking 2333233294Sstas -static only build a \`.o' file suitable for static linking 2334233294Sstas -Wc,FLAG pass FLAG directly to the compiler 2335233294Sstas 2336233294SstasCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 2337233294Sstasfrom the given SOURCEFILE. 2338233294Sstas 2339233294SstasThe output file name is determined by removing the directory component from 2340233294SstasSOURCEFILE, then substituting the C source code suffix \`.c' with the 2341233294Sstaslibrary object suffix, \`.lo'." 2342233294Sstas ;; 2343233294Sstas 2344233294Sstas execute) 2345233294Sstas $ECHO \ 2346233294Sstas"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2347233294Sstas 2348233294SstasAutomatically set library path, then run a program. 2349233294Sstas 2350233294SstasThis mode accepts the following additional options: 2351233294Sstas 2352233294Sstas -dlopen FILE add the directory containing FILE to the library path 2353233294Sstas 2354233294SstasThis mode sets the library path environment variable according to \`-dlopen' 2355233294Sstasflags. 2356233294Sstas 2357233294SstasIf any of the ARGS are libtool executable wrappers, then they are translated 2358233294Sstasinto their corresponding uninstalled binary, and any of their required library 2359233294Sstasdirectories are added to the library path. 2360233294Sstas 2361233294SstasThen, COMMAND is executed, with ARGS as arguments." 2362233294Sstas ;; 2363233294Sstas 2364233294Sstas finish) 2365233294Sstas $ECHO \ 2366233294Sstas"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2367233294Sstas 2368233294SstasComplete the installation of libtool libraries. 2369233294Sstas 2370233294SstasEach LIBDIR is a directory that contains libtool libraries. 2371233294Sstas 2372233294SstasThe commands that this mode executes may require superuser privileges. Use 2373233294Sstasthe \`--dry-run' option if you just want to see what would be executed." 2374233294Sstas ;; 2375233294Sstas 2376233294Sstas install) 2377233294Sstas $ECHO \ 2378233294Sstas"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2379233294Sstas 2380233294SstasInstall executables or libraries. 2381233294Sstas 2382233294SstasINSTALL-COMMAND is the installation command. The first component should be 2383233294Sstaseither the \`install' or \`cp' program. 2384233294Sstas 2385233294SstasThe following components of INSTALL-COMMAND are treated specially: 2386233294Sstas 2387233294Sstas -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2388233294Sstas 2389233294SstasThe rest of the components are interpreted as arguments to that command (only 2390233294SstasBSD-compatible install options are recognized)." 2391233294Sstas ;; 2392233294Sstas 2393233294Sstas link) 2394233294Sstas $ECHO \ 2395233294Sstas"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2396233294Sstas 2397233294SstasLink object files or libraries together to form another library, or to 2398233294Sstascreate an executable program. 2399233294Sstas 2400233294SstasLINK-COMMAND is a command using the C compiler that you would use to create 2401233294Sstasa program from several object files. 2402233294Sstas 2403233294SstasThe following components of LINK-COMMAND are treated specially: 2404233294Sstas 2405233294Sstas -all-static do not do any dynamic linking at all 2406233294Sstas -avoid-version do not add a version suffix if possible 2407233294Sstas -bindir BINDIR specify path to binaries directory (for systems where 2408233294Sstas libraries must be found in the PATH setting at runtime) 2409233294Sstas -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 2410233294Sstas -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 2411233294Sstas -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 2412233294Sstas -export-symbols SYMFILE 2413233294Sstas try to export only the symbols listed in SYMFILE 2414233294Sstas -export-symbols-regex REGEX 2415233294Sstas try to export only the symbols matching REGEX 2416233294Sstas -LLIBDIR search LIBDIR for required installed libraries 2417233294Sstas -lNAME OUTPUT-FILE requires the installed library libNAME 2418233294Sstas -module build a library that can dlopened 2419233294Sstas -no-fast-install disable the fast-install mode 2420233294Sstas -no-install link a not-installable executable 2421233294Sstas -no-undefined declare that a library does not refer to external symbols 2422233294Sstas -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 2423233294Sstas -objectlist FILE Use a list of object files found in FILE to specify objects 2424233294Sstas -precious-files-regex REGEX 2425233294Sstas don't remove output files matching REGEX 2426233294Sstas -release RELEASE specify package release information 2427233294Sstas -rpath LIBDIR the created library will eventually be installed in LIBDIR 2428233294Sstas -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 2429233294Sstas -shared only do dynamic linking of libtool libraries 2430233294Sstas -shrext SUFFIX override the standard shared library file extension 2431233294Sstas -static do not do any dynamic linking of uninstalled libtool libraries 2432233294Sstas -static-libtool-libs 2433233294Sstas do not do any dynamic linking of libtool libraries 2434233294Sstas -version-info CURRENT[:REVISION[:AGE]] 2435233294Sstas specify library version info [each variable defaults to 0] 2436233294Sstas -weak LIBNAME declare that the target provides the LIBNAME interface 2437233294Sstas -Wc,FLAG 2438233294Sstas -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 2439233294Sstas -Wl,FLAG 2440233294Sstas -Xlinker FLAG pass linker-specific FLAG directly to the linker 2441233294Sstas -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2442233294Sstas 2443233294SstasAll other options (arguments beginning with \`-') are ignored. 2444233294Sstas 2445233294SstasEvery other argument is treated as a filename. Files ending in \`.la' are 2446233294Sstastreated as uninstalled libtool libraries, other files are standard or library 2447233294Sstasobject files. 2448233294Sstas 2449233294SstasIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 2450233294Sstasonly library objects (\`.lo' files) may be specified, and \`-rpath' is 2451233294Sstasrequired, except when creating a convenience library. 2452233294Sstas 2453233294SstasIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 2454233294Sstasusing \`ar' and \`ranlib', or on Windows using \`lib'. 2455233294Sstas 2456233294SstasIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 2457233294Sstasis created, otherwise an executable program is created." 2458233294Sstas ;; 2459233294Sstas 2460233294Sstas uninstall) 2461233294Sstas $ECHO \ 2462233294Sstas"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2463233294Sstas 2464233294SstasRemove libraries from an installation directory. 2465233294Sstas 2466233294SstasRM is the name of the program to use to delete files associated with each FILE 2467233294Sstas(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2468233294Sstasto RM. 2469233294Sstas 2470233294SstasIf FILE is a libtool library, all the files associated with it are deleted. 2471233294SstasOtherwise, only FILE itself is deleted using RM." 2472233294Sstas ;; 2473233294Sstas 2474233294Sstas *) 2475233294Sstas func_fatal_help "invalid operation mode \`$opt_mode'" 2476233294Sstas ;; 2477233294Sstas esac 2478233294Sstas 2479233294Sstas echo 2480233294Sstas $ECHO "Try \`$progname --help' for more information about other modes." 2481233294Sstas} 2482233294Sstas 2483233294Sstas# Now that we've collected a possible --mode arg, show help if necessary 2484233294Sstasif $opt_help; then 2485233294Sstas if test "$opt_help" = :; then 2486233294Sstas func_mode_help 2487233294Sstas else 2488233294Sstas { 2489233294Sstas func_help noexit 2490233294Sstas for opt_mode in compile link execute install finish uninstall clean; do 2491233294Sstas func_mode_help 2492233294Sstas done 2493233294Sstas } | sed -n '1p; 2,$s/^Usage:/ or: /p' 2494233294Sstas { 2495233294Sstas func_help noexit 2496233294Sstas for opt_mode in compile link execute install finish uninstall clean; do 2497233294Sstas echo 2498233294Sstas func_mode_help 2499233294Sstas done 2500233294Sstas } | 2501233294Sstas sed '1d 2502233294Sstas /^When reporting/,/^Report/{ 2503233294Sstas H 2504233294Sstas d 2505233294Sstas } 2506233294Sstas $x 2507233294Sstas /information about other modes/d 2508233294Sstas /more detailed .*MODE/d 2509233294Sstas s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 2510233294Sstas fi 2511233294Sstas exit $? 2512233294Sstasfi 2513233294Sstas 2514233294Sstas 2515233294Sstas# func_mode_execute arg... 2516233294Sstasfunc_mode_execute () 2517233294Sstas{ 2518233294Sstas $opt_debug 2519233294Sstas # The first argument is the command name. 2520233294Sstas cmd="$nonopt" 2521233294Sstas test -z "$cmd" && \ 2522233294Sstas func_fatal_help "you must specify a COMMAND" 2523233294Sstas 2524233294Sstas # Handle -dlopen flags immediately. 2525233294Sstas for file in $opt_dlopen; do 2526233294Sstas test -f "$file" \ 2527233294Sstas || func_fatal_help "\`$file' is not a file" 2528233294Sstas 2529233294Sstas dir= 2530233294Sstas case $file in 2531233294Sstas *.la) 2532233294Sstas func_resolve_sysroot "$file" 2533233294Sstas file=$func_resolve_sysroot_result 2534233294Sstas 2535233294Sstas # Check to see that this really is a libtool archive. 2536233294Sstas func_lalib_unsafe_p "$file" \ 2537233294Sstas || func_fatal_help "\`$lib' is not a valid libtool archive" 2538233294Sstas 2539233294Sstas # Read the libtool library. 2540233294Sstas dlname= 2541233294Sstas library_names= 2542233294Sstas func_source "$file" 2543233294Sstas 2544233294Sstas # Skip this library if it cannot be dlopened. 2545233294Sstas if test -z "$dlname"; then 2546233294Sstas # Warn if it was a shared library. 2547233294Sstas test -n "$library_names" && \ 2548233294Sstas func_warning "\`$file' was not linked with \`-export-dynamic'" 2549233294Sstas continue 2550233294Sstas fi 2551233294Sstas 2552233294Sstas func_dirname "$file" "" "." 2553233294Sstas dir="$func_dirname_result" 2554233294Sstas 2555233294Sstas if test -f "$dir/$objdir/$dlname"; then 2556233294Sstas func_append dir "/$objdir" 255755682Smarkm else 2558233294Sstas if test ! -f "$dir/$dlname"; then 2559233294Sstas func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 2560233294Sstas fi 256155682Smarkm fi 2562233294Sstas ;; 2563233294Sstas 2564233294Sstas *.lo) 2565233294Sstas # Just add the directory containing the .lo file. 2566233294Sstas func_dirname "$file" "" "." 2567233294Sstas dir="$func_dirname_result" 2568233294Sstas ;; 2569233294Sstas 2570233294Sstas *) 2571233294Sstas func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 2572233294Sstas continue 2573233294Sstas ;; 2574233294Sstas esac 2575233294Sstas 2576233294Sstas # Get the absolute pathname. 2577233294Sstas absdir=`cd "$dir" && pwd` 2578233294Sstas test -n "$absdir" && dir="$absdir" 2579233294Sstas 2580233294Sstas # Now add the directory to shlibpath_var. 2581233294Sstas if eval "test -z \"\$$shlibpath_var\""; then 2582233294Sstas eval "$shlibpath_var=\"\$dir\"" 2583233294Sstas else 2584233294Sstas eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 258555682Smarkm fi 2586233294Sstas done 258772445Sassar 2588233294Sstas # This variable tells wrapper scripts just to set shlibpath_var 2589233294Sstas # rather than running their programs. 2590233294Sstas libtool_execute_magic="$magic" 2591127808Snectar 2592233294Sstas # Check if any of the arguments is a wrapper script. 2593233294Sstas args= 2594233294Sstas for file 2595233294Sstas do 2596233294Sstas case $file in 2597233294Sstas -* | *.la | *.lo ) ;; 2598233294Sstas *) 2599233294Sstas # Do a test to see if this is really a libtool program. 2600233294Sstas if func_ltwrapper_script_p "$file"; then 2601233294Sstas func_source "$file" 2602233294Sstas # Transform arg to wrapped name. 2603233294Sstas file="$progdir/$program" 2604233294Sstas elif func_ltwrapper_executable_p "$file"; then 2605233294Sstas func_ltwrapper_scriptname "$file" 2606233294Sstas func_source "$func_ltwrapper_scriptname_result" 2607233294Sstas # Transform arg to wrapped name. 2608233294Sstas file="$progdir/$program" 2609233294Sstas fi 2610233294Sstas ;; 2611233294Sstas esac 2612233294Sstas # Quote arguments (to preserve shell metacharacters). 2613233294Sstas func_append_quoted args "$file" 2614233294Sstas done 2615233294Sstas 2616233294Sstas if test "X$opt_dry_run" = Xfalse; then 2617233294Sstas if test -n "$shlibpath_var"; then 2618233294Sstas # Export the shlibpath_var. 2619233294Sstas eval "export $shlibpath_var" 2620233294Sstas fi 2621233294Sstas 2622233294Sstas # Restore saved environment variables 2623233294Sstas for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 2624233294Sstas do 2625233294Sstas eval "if test \"\${save_$lt_var+set}\" = set; then 2626233294Sstas $lt_var=\$save_$lt_var; export $lt_var 2627233294Sstas else 2628233294Sstas $lt_unset $lt_var 2629233294Sstas fi" 2630233294Sstas done 2631233294Sstas 2632233294Sstas # Now prepare to actually exec the command. 2633233294Sstas exec_cmd="\$cmd$args" 2634127808Snectar else 2635233294Sstas # Display what would be done. 2636233294Sstas if test -n "$shlibpath_var"; then 2637233294Sstas eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 2638233294Sstas echo "export $shlibpath_var" 2639233294Sstas fi 2640233294Sstas $ECHO "$cmd$args" 2641233294Sstas exit $EXIT_SUCCESS 2642233294Sstas fi 2643233294Sstas} 2644127808Snectar 2645233294Sstastest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2646233294Sstas 2647233294Sstas 2648233294Sstas# func_mode_finish arg... 2649233294Sstasfunc_mode_finish () 2650233294Sstas{ 2651233294Sstas $opt_debug 2652233294Sstas libs= 2653233294Sstas libdirs= 2654233294Sstas admincmds= 2655233294Sstas 2656233294Sstas for opt in "$nonopt" ${1+"$@"} 2657233294Sstas do 2658233294Sstas if test -d "$opt"; then 2659233294Sstas func_append libdirs " $opt" 2660233294Sstas 2661233294Sstas elif test -f "$opt"; then 2662233294Sstas if func_lalib_unsafe_p "$opt"; then 2663233294Sstas func_append libs " $opt" 2664233294Sstas else 2665233294Sstas func_warning "\`$opt' is not a valid libtool archive" 2666233294Sstas fi 2667233294Sstas 2668233294Sstas else 2669233294Sstas func_fatal_error "invalid argument \`$opt'" 2670233294Sstas fi 2671233294Sstas done 2672233294Sstas 2673233294Sstas if test -n "$libs"; then 2674233294Sstas if test -n "$lt_sysroot"; then 2675233294Sstas sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 2676233294Sstas sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 2677233294Sstas else 2678233294Sstas sysroot_cmd= 2679233294Sstas fi 2680233294Sstas 2681233294Sstas # Remove sysroot references 2682233294Sstas if $opt_dry_run; then 2683233294Sstas for lib in $libs; do 2684233294Sstas echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 2685233294Sstas done 2686233294Sstas else 2687233294Sstas tmpdir=`func_mktempdir` 2688233294Sstas for lib in $libs; do 2689233294Sstas sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 2690233294Sstas > $tmpdir/tmp-la 2691233294Sstas mv -f $tmpdir/tmp-la $lib 2692233294Sstas done 2693233294Sstas ${RM}r "$tmpdir" 2694233294Sstas fi 269555682Smarkm fi 269655682Smarkm 2697233294Sstas if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2698233294Sstas for libdir in $libdirs; do 2699233294Sstas if test -n "$finish_cmds"; then 2700233294Sstas # Do each command in the finish commands. 2701233294Sstas func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 2702233294Sstas'"$cmd"'"' 2703233294Sstas fi 2704233294Sstas if test -n "$finish_eval"; then 2705233294Sstas # Do the single finish_eval. 2706233294Sstas eval cmds=\"$finish_eval\" 2707233294Sstas $opt_dry_run || eval "$cmds" || func_append admincmds " 2708233294Sstas $cmds" 2709233294Sstas fi 2710233294Sstas done 2711233294Sstas fi 2712127808Snectar 2713233294Sstas # Exit here if they wanted silent mode. 2714233294Sstas $opt_silent && exit $EXIT_SUCCESS 2715233294Sstas 2716233294Sstas if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2717233294Sstas echo "----------------------------------------------------------------------" 2718233294Sstas echo "Libraries have been installed in:" 2719233294Sstas for libdir in $libdirs; do 2720233294Sstas $ECHO " $libdir" 2721233294Sstas done 2722233294Sstas echo 2723233294Sstas echo "If you ever happen to want to link against installed libraries" 2724233294Sstas echo "in a given directory, LIBDIR, you must either use libtool, and" 2725233294Sstas echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 2726233294Sstas echo "flag during linking and do at least one of the following:" 2727233294Sstas if test -n "$shlibpath_var"; then 2728233294Sstas echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 2729233294Sstas echo " during execution" 2730233294Sstas fi 2731233294Sstas if test -n "$runpath_var"; then 2732233294Sstas echo " - add LIBDIR to the \`$runpath_var' environment variable" 2733233294Sstas echo " during linking" 2734233294Sstas fi 2735233294Sstas if test -n "$hardcode_libdir_flag_spec"; then 2736233294Sstas libdir=LIBDIR 2737233294Sstas eval flag=\"$hardcode_libdir_flag_spec\" 2738233294Sstas 2739233294Sstas $ECHO " - use the \`$flag' linker flag" 2740233294Sstas fi 2741233294Sstas if test -n "$admincmds"; then 2742233294Sstas $ECHO " - have your system administrator run these commands:$admincmds" 2743233294Sstas fi 2744233294Sstas if test -f /etc/ld.so.conf; then 2745233294Sstas echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 2746233294Sstas fi 2747233294Sstas echo 2748233294Sstas 2749233294Sstas echo "See any operating system documentation about shared libraries for" 2750233294Sstas case $host in 2751233294Sstas solaris2.[6789]|solaris2.1[0-9]) 2752233294Sstas echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 2753233294Sstas echo "pages." 2754233294Sstas ;; 2755233294Sstas *) 2756233294Sstas echo "more information, such as the ld(1) and ld.so(8) manual pages." 2757233294Sstas ;; 2758233294Sstas esac 2759233294Sstas echo "----------------------------------------------------------------------" 276055682Smarkm fi 2761233294Sstas exit $EXIT_SUCCESS 2762233294Sstas} 276355682Smarkm 2764233294Sstastest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2765233294Sstas 2766233294Sstas 2767233294Sstas# func_mode_install arg... 2768233294Sstasfunc_mode_install () 2769233294Sstas{ 2770233294Sstas $opt_debug 2771233294Sstas # There may be an optional sh(1) argument at the beginning of 2772233294Sstas # install_prog (especially on Windows NT). 2773233294Sstas if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 2774233294Sstas # Allow the use of GNU shtool's install command. 2775233294Sstas case $nonopt in *shtool*) :;; *) false;; esac; then 2776233294Sstas # Aesthetically quote it. 2777233294Sstas func_quote_for_eval "$nonopt" 2778233294Sstas install_prog="$func_quote_for_eval_result " 2779233294Sstas arg=$1 2780233294Sstas shift 2781233294Sstas else 2782233294Sstas install_prog= 2783233294Sstas arg=$nonopt 2784233294Sstas fi 2785233294Sstas 2786233294Sstas # The real first argument should be the name of the installation program. 2787233294Sstas # Aesthetically quote it. 2788233294Sstas func_quote_for_eval "$arg" 2789233294Sstas func_append install_prog "$func_quote_for_eval_result" 2790233294Sstas install_shared_prog=$install_prog 2791233294Sstas case " $install_prog " in 2792233294Sstas *[\\\ /]cp\ *) install_cp=: ;; 2793233294Sstas *) install_cp=false ;; 2794233294Sstas esac 2795233294Sstas 2796233294Sstas # We need to accept at least all the BSD install flags. 2797233294Sstas dest= 2798233294Sstas files= 2799233294Sstas opts= 2800233294Sstas prev= 2801233294Sstas install_type= 2802233294Sstas isdir=no 2803233294Sstas stripme= 2804233294Sstas no_mode=: 2805233294Sstas for arg 2806233294Sstas do 2807233294Sstas arg2= 2808233294Sstas if test -n "$dest"; then 2809233294Sstas func_append files " $dest" 2810233294Sstas dest=$arg 2811233294Sstas continue 2812233294Sstas fi 2813233294Sstas 2814233294Sstas case $arg in 2815233294Sstas -d) isdir=yes ;; 2816233294Sstas -f) 2817233294Sstas if $install_cp; then :; else 2818233294Sstas prev=$arg 2819233294Sstas fi 2820233294Sstas ;; 2821233294Sstas -g | -m | -o) 2822233294Sstas prev=$arg 2823233294Sstas ;; 2824233294Sstas -s) 2825233294Sstas stripme=" -s" 2826233294Sstas continue 2827233294Sstas ;; 2828233294Sstas -*) 2829233294Sstas ;; 2830233294Sstas *) 2831233294Sstas # If the previous option needed an argument, then skip it. 2832233294Sstas if test -n "$prev"; then 2833233294Sstas if test "x$prev" = x-m && test -n "$install_override_mode"; then 2834233294Sstas arg2=$install_override_mode 2835233294Sstas no_mode=false 2836233294Sstas fi 2837233294Sstas prev= 2838233294Sstas else 2839233294Sstas dest=$arg 2840233294Sstas continue 2841233294Sstas fi 2842233294Sstas ;; 2843233294Sstas esac 2844233294Sstas 2845233294Sstas # Aesthetically quote the argument. 2846233294Sstas func_quote_for_eval "$arg" 2847233294Sstas func_append install_prog " $func_quote_for_eval_result" 2848233294Sstas if test -n "$arg2"; then 2849233294Sstas func_quote_for_eval "$arg2" 2850233294Sstas fi 2851233294Sstas func_append install_shared_prog " $func_quote_for_eval_result" 2852233294Sstas done 2853233294Sstas 2854233294Sstas test -z "$install_prog" && \ 2855233294Sstas func_fatal_help "you must specify an install program" 2856233294Sstas 2857233294Sstas test -n "$prev" && \ 2858233294Sstas func_fatal_help "the \`$prev' option requires an argument" 2859233294Sstas 2860233294Sstas if test -n "$install_override_mode" && $no_mode; then 2861233294Sstas if $install_cp; then :; else 2862233294Sstas func_quote_for_eval "$install_override_mode" 2863233294Sstas func_append install_shared_prog " -m $func_quote_for_eval_result" 2864233294Sstas fi 2865233294Sstas fi 2866233294Sstas 2867233294Sstas if test -z "$files"; then 2868233294Sstas if test -z "$dest"; then 2869233294Sstas func_fatal_help "no file or destination specified" 2870233294Sstas else 2871233294Sstas func_fatal_help "you must specify a destination" 2872233294Sstas fi 2873233294Sstas fi 2874233294Sstas 2875233294Sstas # Strip any trailing slash from the destination. 2876233294Sstas func_stripname '' '/' "$dest" 2877233294Sstas dest=$func_stripname_result 2878233294Sstas 2879233294Sstas # Check to see that the destination is a directory. 2880233294Sstas test -d "$dest" && isdir=yes 2881233294Sstas if test "$isdir" = yes; then 2882233294Sstas destdir="$dest" 2883233294Sstas destname= 2884233294Sstas else 2885233294Sstas func_dirname_and_basename "$dest" "" "." 2886233294Sstas destdir="$func_dirname_result" 2887233294Sstas destname="$func_basename_result" 2888233294Sstas 2889233294Sstas # Not a directory, so check to see that there is only one file specified. 2890233294Sstas set dummy $files; shift 2891233294Sstas test "$#" -gt 1 && \ 2892233294Sstas func_fatal_help "\`$dest' is not a directory" 2893233294Sstas fi 2894233294Sstas case $destdir in 2895233294Sstas [\\/]* | [A-Za-z]:[\\/]*) ;; 2896233294Sstas *) 2897233294Sstas for file in $files; do 2898233294Sstas case $file in 2899233294Sstas *.lo) ;; 2900233294Sstas *) 2901233294Sstas func_fatal_help "\`$destdir' must be an absolute directory name" 2902233294Sstas ;; 2903233294Sstas esac 2904233294Sstas done 2905233294Sstas ;; 2906233294Sstas esac 2907233294Sstas 2908233294Sstas # This variable tells wrapper scripts just to set variables rather 2909233294Sstas # than running their programs. 2910233294Sstas libtool_install_magic="$magic" 2911233294Sstas 2912233294Sstas staticlibs= 2913233294Sstas future_libdirs= 2914233294Sstas current_libdirs= 2915233294Sstas for file in $files; do 2916233294Sstas 2917233294Sstas # Do each installation. 2918233294Sstas case $file in 2919233294Sstas *.$libext) 2920233294Sstas # Do the static libraries later. 2921233294Sstas func_append staticlibs " $file" 2922233294Sstas ;; 2923233294Sstas 2924233294Sstas *.la) 2925233294Sstas func_resolve_sysroot "$file" 2926233294Sstas file=$func_resolve_sysroot_result 2927233294Sstas 2928233294Sstas # Check to see that this really is a libtool archive. 2929233294Sstas func_lalib_unsafe_p "$file" \ 2930233294Sstas || func_fatal_help "\`$file' is not a valid libtool archive" 2931233294Sstas 2932233294Sstas library_names= 2933233294Sstas old_library= 2934233294Sstas relink_command= 2935233294Sstas func_source "$file" 2936233294Sstas 2937233294Sstas # Add the libdir to current_libdirs if it is the destination. 2938233294Sstas if test "X$destdir" = "X$libdir"; then 2939233294Sstas case "$current_libdirs " in 2940233294Sstas *" $libdir "*) ;; 2941233294Sstas *) func_append current_libdirs " $libdir" ;; 2942233294Sstas esac 2943233294Sstas else 2944233294Sstas # Note the libdir as a future libdir. 2945233294Sstas case "$future_libdirs " in 2946233294Sstas *" $libdir "*) ;; 2947233294Sstas *) func_append future_libdirs " $libdir" ;; 2948233294Sstas esac 2949233294Sstas fi 2950233294Sstas 2951233294Sstas func_dirname "$file" "/" "" 2952233294Sstas dir="$func_dirname_result" 2953233294Sstas func_append dir "$objdir" 2954233294Sstas 2955233294Sstas if test -n "$relink_command"; then 2956233294Sstas # Determine the prefix the user has applied to our future dir. 2957233294Sstas inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2958233294Sstas 2959233294Sstas # Don't allow the user to place us outside of our expected 2960233294Sstas # location b/c this prevents finding dependent libraries that 2961233294Sstas # are installed to the same prefix. 2962233294Sstas # At present, this check doesn't affect windows .dll's that 2963233294Sstas # are installed into $libdir/../bin (currently, that works fine) 2964233294Sstas # but it's something to keep an eye on. 2965233294Sstas test "$inst_prefix_dir" = "$destdir" && \ 2966233294Sstas func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 2967233294Sstas 2968233294Sstas if test -n "$inst_prefix_dir"; then 2969233294Sstas # Stick the inst_prefix_dir data into the link command. 2970233294Sstas relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2971233294Sstas else 2972233294Sstas relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2973233294Sstas fi 2974233294Sstas 2975233294Sstas func_warning "relinking \`$file'" 2976233294Sstas func_show_eval "$relink_command" \ 2977233294Sstas 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 2978233294Sstas fi 2979233294Sstas 2980233294Sstas # See the names of the shared library. 2981233294Sstas set dummy $library_names; shift 2982233294Sstas if test -n "$1"; then 2983233294Sstas realname="$1" 2984233294Sstas shift 2985233294Sstas 2986233294Sstas srcname="$realname" 2987233294Sstas test -n "$relink_command" && srcname="$realname"T 2988233294Sstas 2989233294Sstas # Install the shared library and build the symlinks. 2990233294Sstas func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 2991233294Sstas 'exit $?' 2992233294Sstas tstripme="$stripme" 2993233294Sstas case $host_os in 2994233294Sstas cygwin* | mingw* | pw32* | cegcc*) 2995233294Sstas case $realname in 2996233294Sstas *.dll.a) 2997233294Sstas tstripme="" 2998233294Sstas ;; 2999233294Sstas esac 3000233294Sstas ;; 3001233294Sstas esac 3002233294Sstas if test -n "$tstripme" && test -n "$striplib"; then 3003233294Sstas func_show_eval "$striplib $destdir/$realname" 'exit $?' 3004233294Sstas fi 3005233294Sstas 3006233294Sstas if test "$#" -gt 0; then 3007233294Sstas # Delete the old symlinks, and create new ones. 3008233294Sstas # Try `ln -sf' first, because the `ln' binary might depend on 3009233294Sstas # the symlink we replace! Solaris /bin/ln does not understand -f, 3010233294Sstas # so we also need to try rm && ln -s. 3011233294Sstas for linkname 3012233294Sstas do 3013233294Sstas test "$linkname" != "$realname" \ 3014233294Sstas && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3015233294Sstas done 3016233294Sstas fi 3017233294Sstas 3018233294Sstas # Do each command in the postinstall commands. 3019233294Sstas lib="$destdir/$realname" 3020233294Sstas func_execute_cmds "$postinstall_cmds" 'exit $?' 3021233294Sstas fi 3022233294Sstas 3023233294Sstas # Install the pseudo-library for information purposes. 3024233294Sstas func_basename "$file" 3025233294Sstas name="$func_basename_result" 3026233294Sstas instname="$dir/$name"i 3027233294Sstas func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3028233294Sstas 3029233294Sstas # Maybe install the static library, too. 3030233294Sstas test -n "$old_library" && func_append staticlibs " $dir/$old_library" 3031233294Sstas ;; 3032233294Sstas 3033233294Sstas *.lo) 3034233294Sstas # Install (i.e. copy) a libtool object. 3035233294Sstas 3036233294Sstas # Figure out destination file name, if it wasn't already specified. 3037233294Sstas if test -n "$destname"; then 3038233294Sstas destfile="$destdir/$destname" 3039233294Sstas else 3040233294Sstas func_basename "$file" 3041233294Sstas destfile="$func_basename_result" 3042233294Sstas destfile="$destdir/$destfile" 3043233294Sstas fi 3044233294Sstas 3045233294Sstas # Deduce the name of the destination old-style object file. 3046233294Sstas case $destfile in 3047233294Sstas *.lo) 3048233294Sstas func_lo2o "$destfile" 3049233294Sstas staticdest=$func_lo2o_result 3050233294Sstas ;; 3051233294Sstas *.$objext) 3052233294Sstas staticdest="$destfile" 3053233294Sstas destfile= 3054233294Sstas ;; 3055233294Sstas *) 3056233294Sstas func_fatal_help "cannot copy a libtool object to \`$destfile'" 3057233294Sstas ;; 3058233294Sstas esac 3059233294Sstas 3060233294Sstas # Install the libtool object if requested. 3061233294Sstas test -n "$destfile" && \ 3062233294Sstas func_show_eval "$install_prog $file $destfile" 'exit $?' 3063233294Sstas 3064233294Sstas # Install the old object if enabled. 3065233294Sstas if test "$build_old_libs" = yes; then 3066233294Sstas # Deduce the name of the old-style object file. 3067233294Sstas func_lo2o "$file" 3068233294Sstas staticobj=$func_lo2o_result 3069233294Sstas func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3070233294Sstas fi 3071233294Sstas exit $EXIT_SUCCESS 3072233294Sstas ;; 3073233294Sstas 3074233294Sstas *) 3075233294Sstas # Figure out destination file name, if it wasn't already specified. 3076233294Sstas if test -n "$destname"; then 3077233294Sstas destfile="$destdir/$destname" 3078233294Sstas else 3079233294Sstas func_basename "$file" 3080233294Sstas destfile="$func_basename_result" 3081233294Sstas destfile="$destdir/$destfile" 3082233294Sstas fi 3083233294Sstas 3084233294Sstas # If the file is missing, and there is a .exe on the end, strip it 3085233294Sstas # because it is most likely a libtool script we actually want to 3086233294Sstas # install 3087233294Sstas stripped_ext="" 3088233294Sstas case $file in 3089233294Sstas *.exe) 3090233294Sstas if test ! -f "$file"; then 3091233294Sstas func_stripname '' '.exe' "$file" 3092233294Sstas file=$func_stripname_result 3093233294Sstas stripped_ext=".exe" 3094233294Sstas fi 3095233294Sstas ;; 3096233294Sstas esac 3097233294Sstas 3098233294Sstas # Do a test to see if this is really a libtool program. 3099233294Sstas case $host in 3100233294Sstas *cygwin* | *mingw*) 3101233294Sstas if func_ltwrapper_executable_p "$file"; then 3102233294Sstas func_ltwrapper_scriptname "$file" 3103233294Sstas wrapper=$func_ltwrapper_scriptname_result 3104233294Sstas else 3105233294Sstas func_stripname '' '.exe' "$file" 3106233294Sstas wrapper=$func_stripname_result 3107233294Sstas fi 3108233294Sstas ;; 3109233294Sstas *) 3110233294Sstas wrapper=$file 3111233294Sstas ;; 3112233294Sstas esac 3113233294Sstas if func_ltwrapper_script_p "$wrapper"; then 3114233294Sstas notinst_deplibs= 3115233294Sstas relink_command= 3116233294Sstas 3117233294Sstas func_source "$wrapper" 3118233294Sstas 3119233294Sstas # Check the variables that should have been set. 3120233294Sstas test -z "$generated_by_libtool_version" && \ 3121233294Sstas func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3122233294Sstas 3123233294Sstas finalize=yes 3124233294Sstas for lib in $notinst_deplibs; do 3125233294Sstas # Check to see that each library is installed. 3126233294Sstas libdir= 3127233294Sstas if test -f "$lib"; then 3128233294Sstas func_source "$lib" 3129233294Sstas fi 3130233294Sstas libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 3131233294Sstas if test -n "$libdir" && test ! -f "$libfile"; then 3132233294Sstas func_warning "\`$lib' has not been installed in \`$libdir'" 3133233294Sstas finalize=no 3134233294Sstas fi 3135233294Sstas done 3136233294Sstas 3137233294Sstas relink_command= 3138233294Sstas func_source "$wrapper" 3139233294Sstas 3140233294Sstas outputname= 3141233294Sstas if test "$fast_install" = no && test -n "$relink_command"; then 3142233294Sstas $opt_dry_run || { 3143233294Sstas if test "$finalize" = yes; then 3144233294Sstas tmpdir=`func_mktempdir` 3145233294Sstas func_basename "$file$stripped_ext" 3146233294Sstas file="$func_basename_result" 3147233294Sstas outputname="$tmpdir/$file" 3148233294Sstas # Replace the output file specification. 3149233294Sstas relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 3150233294Sstas 3151233294Sstas $opt_silent || { 3152233294Sstas func_quote_for_expand "$relink_command" 3153233294Sstas eval "func_echo $func_quote_for_expand_result" 3154233294Sstas } 3155233294Sstas if eval "$relink_command"; then : 3156233294Sstas else 3157233294Sstas func_error "error: relink \`$file' with the above command before installing it" 3158233294Sstas $opt_dry_run || ${RM}r "$tmpdir" 3159233294Sstas continue 3160233294Sstas fi 3161233294Sstas file="$outputname" 3162233294Sstas else 3163233294Sstas func_warning "cannot relink \`$file'" 3164233294Sstas fi 3165233294Sstas } 3166233294Sstas else 3167233294Sstas # Install the binary that we compiled earlier. 3168233294Sstas file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 3169233294Sstas fi 3170233294Sstas fi 3171233294Sstas 3172233294Sstas # remove .exe since cygwin /usr/bin/install will append another 3173233294Sstas # one anyway 3174233294Sstas case $install_prog,$host in 3175233294Sstas */usr/bin/install*,*cygwin*) 3176233294Sstas case $file:$destfile in 3177233294Sstas *.exe:*.exe) 3178233294Sstas # this is ok 3179233294Sstas ;; 3180233294Sstas *.exe:*) 3181233294Sstas destfile=$destfile.exe 3182233294Sstas ;; 3183233294Sstas *:*.exe) 3184233294Sstas func_stripname '' '.exe' "$destfile" 3185233294Sstas destfile=$func_stripname_result 3186233294Sstas ;; 3187233294Sstas esac 3188233294Sstas ;; 3189233294Sstas esac 3190233294Sstas func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 3191233294Sstas $opt_dry_run || if test -n "$outputname"; then 3192233294Sstas ${RM}r "$tmpdir" 3193233294Sstas fi 3194233294Sstas ;; 3195233294Sstas esac 3196233294Sstas done 3197233294Sstas 3198233294Sstas for file in $staticlibs; do 3199233294Sstas func_basename "$file" 3200233294Sstas name="$func_basename_result" 3201233294Sstas 3202233294Sstas # Set up the ranlib parameters. 3203233294Sstas oldlib="$destdir/$name" 3204233294Sstas 3205233294Sstas func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 3206233294Sstas 3207233294Sstas if test -n "$stripme" && test -n "$old_striplib"; then 3208233294Sstas func_show_eval "$old_striplib $oldlib" 'exit $?' 3209233294Sstas fi 3210233294Sstas 3211233294Sstas # Do each command in the postinstall commands. 3212233294Sstas func_execute_cmds "$old_postinstall_cmds" 'exit $?' 3213233294Sstas done 3214233294Sstas 3215233294Sstas test -n "$future_libdirs" && \ 3216233294Sstas func_warning "remember to run \`$progname --finish$future_libdirs'" 3217233294Sstas 3218233294Sstas if test -n "$current_libdirs"; then 3219233294Sstas # Maybe just do a dry run. 3220233294Sstas $opt_dry_run && current_libdirs=" -n$current_libdirs" 3221233294Sstas exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 3222233294Sstas else 3223233294Sstas exit $EXIT_SUCCESS 3224233294Sstas fi 3225233294Sstas} 3226233294Sstas 3227233294Sstastest "$opt_mode" = install && func_mode_install ${1+"$@"} 3228233294Sstas 3229233294Sstas 3230233294Sstas# func_generate_dlsyms outputname originator pic_p 3231233294Sstas# Extract symbols from dlprefiles and create ${outputname}S.o with 3232233294Sstas# a dlpreopen symbol table. 3233233294Sstasfunc_generate_dlsyms () 3234233294Sstas{ 3235233294Sstas $opt_debug 3236233294Sstas my_outputname="$1" 3237233294Sstas my_originator="$2" 3238233294Sstas my_pic_p="${3-no}" 3239233294Sstas my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 3240233294Sstas my_dlsyms= 3241233294Sstas 3242233294Sstas if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 3243233294Sstas if test -n "$NM" && test -n "$global_symbol_pipe"; then 3244233294Sstas my_dlsyms="${my_outputname}S.c" 3245233294Sstas else 3246233294Sstas func_error "not configured to extract global symbols from dlpreopened files" 3247233294Sstas fi 3248233294Sstas fi 3249233294Sstas 3250233294Sstas if test -n "$my_dlsyms"; then 3251233294Sstas case $my_dlsyms in 3252233294Sstas "") ;; 3253233294Sstas *.c) 3254233294Sstas # Discover the nlist of each of the dlfiles. 3255233294Sstas nlist="$output_objdir/${my_outputname}.nm" 3256233294Sstas 3257233294Sstas func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3258233294Sstas 3259233294Sstas # Parse the name list into a source file. 3260233294Sstas func_verbose "creating $output_objdir/$my_dlsyms" 3261233294Sstas 3262233294Sstas $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 3263233294Sstas/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 3264233294Sstas/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3265233294Sstas 3266233294Sstas#ifdef __cplusplus 3267233294Sstasextern \"C\" { 3268233294Sstas#endif 3269233294Sstas 3270233294Sstas#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 3271233294Sstas#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 3272233294Sstas#endif 3273233294Sstas 3274233294Sstas/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 3275233294Sstas#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 3276233294Sstas/* DATA imports from DLLs on WIN32 con't be const, because runtime 3277233294Sstas relocations are performed -- see ld's documentation on pseudo-relocs. */ 3278233294Sstas# define LT_DLSYM_CONST 3279233294Sstas#elif defined(__osf__) 3280233294Sstas/* This system does not cope well with relocations in const data. */ 3281233294Sstas# define LT_DLSYM_CONST 3282233294Sstas#else 3283233294Sstas# define LT_DLSYM_CONST const 3284233294Sstas#endif 3285233294Sstas 3286233294Sstas/* External symbol declarations for the compiler. */\ 3287233294Sstas" 3288233294Sstas 3289233294Sstas if test "$dlself" = yes; then 3290233294Sstas func_verbose "generating symbol list for \`$output'" 3291233294Sstas 3292233294Sstas $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3293233294Sstas 3294233294Sstas # Add our own program objects to the symbol list. 3295233294Sstas progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 3296233294Sstas for progfile in $progfiles; do 3297233294Sstas func_to_tool_file "$progfile" func_convert_file_msys_to_w32 3298233294Sstas func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 3299233294Sstas $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3300233294Sstas done 3301233294Sstas 3302233294Sstas if test -n "$exclude_expsyms"; then 3303233294Sstas $opt_dry_run || { 3304233294Sstas eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 3305233294Sstas eval '$MV "$nlist"T "$nlist"' 3306233294Sstas } 3307233294Sstas fi 3308233294Sstas 3309233294Sstas if test -n "$export_symbols_regex"; then 3310233294Sstas $opt_dry_run || { 3311233294Sstas eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 3312233294Sstas eval '$MV "$nlist"T "$nlist"' 3313233294Sstas } 3314233294Sstas fi 3315233294Sstas 3316233294Sstas # Prepare the list of exported symbols 3317233294Sstas if test -z "$export_symbols"; then 3318233294Sstas export_symbols="$output_objdir/$outputname.exp" 3319233294Sstas $opt_dry_run || { 3320233294Sstas $RM $export_symbols 3321233294Sstas eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 3322233294Sstas case $host in 3323233294Sstas *cygwin* | *mingw* | *cegcc* ) 3324233294Sstas eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3325233294Sstas eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 3326233294Sstas ;; 3327233294Sstas esac 3328233294Sstas } 3329233294Sstas else 3330233294Sstas $opt_dry_run || { 3331233294Sstas eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 3332233294Sstas eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 3333233294Sstas eval '$MV "$nlist"T "$nlist"' 3334233294Sstas case $host in 3335233294Sstas *cygwin* | *mingw* | *cegcc* ) 3336233294Sstas eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3337233294Sstas eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 3338233294Sstas ;; 3339233294Sstas esac 3340233294Sstas } 3341233294Sstas fi 3342233294Sstas fi 3343233294Sstas 3344233294Sstas for dlprefile in $dlprefiles; do 3345233294Sstas func_verbose "extracting global C symbols from \`$dlprefile'" 3346233294Sstas func_basename "$dlprefile" 3347233294Sstas name="$func_basename_result" 3348233294Sstas case $host in 3349233294Sstas *cygwin* | *mingw* | *cegcc* ) 3350233294Sstas # if an import library, we need to obtain dlname 3351233294Sstas if func_win32_import_lib_p "$dlprefile"; then 3352233294Sstas func_tr_sh "$dlprefile" 3353233294Sstas eval "curr_lafile=\$libfile_$func_tr_sh_result" 3354233294Sstas dlprefile_dlbasename="" 3355233294Sstas if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 3356233294Sstas # Use subshell, to avoid clobbering current variable values 3357233294Sstas dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 3358233294Sstas if test -n "$dlprefile_dlname" ; then 3359233294Sstas func_basename "$dlprefile_dlname" 3360233294Sstas dlprefile_dlbasename="$func_basename_result" 3361233294Sstas else 3362233294Sstas # no lafile. user explicitly requested -dlpreopen <import library>. 3363233294Sstas $sharedlib_from_linklib_cmd "$dlprefile" 3364233294Sstas dlprefile_dlbasename=$sharedlib_from_linklib_result 3365233294Sstas fi 3366233294Sstas fi 3367233294Sstas $opt_dry_run || { 3368233294Sstas if test -n "$dlprefile_dlbasename" ; then 3369233294Sstas eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 3370233294Sstas else 3371233294Sstas func_warning "Could not compute DLL name from $name" 3372233294Sstas eval '$ECHO ": $name " >> "$nlist"' 3373233294Sstas fi 3374233294Sstas func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3375233294Sstas eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 3376233294Sstas $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 3377233294Sstas } 3378233294Sstas else # not an import lib 3379233294Sstas $opt_dry_run || { 3380233294Sstas eval '$ECHO ": $name " >> "$nlist"' 3381233294Sstas func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3382233294Sstas eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3383233294Sstas } 3384233294Sstas fi 3385233294Sstas ;; 3386233294Sstas *) 3387233294Sstas $opt_dry_run || { 3388233294Sstas eval '$ECHO ": $name " >> "$nlist"' 3389233294Sstas func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3390233294Sstas eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3391233294Sstas } 3392233294Sstas ;; 3393233294Sstas esac 3394233294Sstas done 3395233294Sstas 3396233294Sstas $opt_dry_run || { 3397233294Sstas # Make sure we have at least an empty file. 3398233294Sstas test -f "$nlist" || : > "$nlist" 3399233294Sstas 3400233294Sstas if test -n "$exclude_expsyms"; then 3401233294Sstas $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 3402233294Sstas $MV "$nlist"T "$nlist" 3403233294Sstas fi 3404233294Sstas 3405233294Sstas # Try sorting and uniquifying the output. 3406233294Sstas if $GREP -v "^: " < "$nlist" | 3407233294Sstas if sort -k 3 </dev/null >/dev/null 2>&1; then 3408233294Sstas sort -k 3 3409233294Sstas else 3410233294Sstas sort +2 3411233294Sstas fi | 3412233294Sstas uniq > "$nlist"S; then 3413233294Sstas : 3414233294Sstas else 3415233294Sstas $GREP -v "^: " < "$nlist" > "$nlist"S 3416233294Sstas fi 3417233294Sstas 3418233294Sstas if test -f "$nlist"S; then 3419233294Sstas eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 3420233294Sstas else 3421233294Sstas echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 3422233294Sstas fi 3423233294Sstas 3424233294Sstas echo >> "$output_objdir/$my_dlsyms" "\ 3425233294Sstas 3426233294Sstas/* The mapping between symbol names and symbols. */ 3427233294Sstastypedef struct { 3428233294Sstas const char *name; 3429233294Sstas void *address; 3430233294Sstas} lt_dlsymlist; 3431233294Sstasextern LT_DLSYM_CONST lt_dlsymlist 3432233294Sstaslt_${my_prefix}_LTX_preloaded_symbols[]; 3433233294SstasLT_DLSYM_CONST lt_dlsymlist 3434233294Sstaslt_${my_prefix}_LTX_preloaded_symbols[] = 3435233294Sstas{\ 3436233294Sstas { \"$my_originator\", (void *) 0 }," 3437233294Sstas 3438233294Sstas case $need_lib_prefix in 3439233294Sstas no) 3440233294Sstas eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3441233294Sstas ;; 3442233294Sstas *) 3443233294Sstas eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3444233294Sstas ;; 3445233294Sstas esac 3446233294Sstas echo >> "$output_objdir/$my_dlsyms" "\ 3447233294Sstas {0, (void *) 0} 3448233294Sstas}; 3449233294Sstas 3450233294Sstas/* This works around a problem in FreeBSD linker */ 3451233294Sstas#ifdef FREEBSD_WORKAROUND 3452233294Sstasstatic const void *lt_preloaded_setup() { 3453233294Sstas return lt_${my_prefix}_LTX_preloaded_symbols; 3454233294Sstas} 3455233294Sstas#endif 3456233294Sstas 3457233294Sstas#ifdef __cplusplus 3458233294Sstas} 3459233294Sstas#endif\ 3460233294Sstas" 3461233294Sstas } # !$opt_dry_run 3462233294Sstas 3463233294Sstas pic_flag_for_symtable= 3464233294Sstas case "$compile_command " in 3465233294Sstas *" -static "*) ;; 3466233294Sstas *) 3467233294Sstas case $host in 3468233294Sstas # compiling the symbol table file with pic_flag works around 3469233294Sstas # a FreeBSD bug that causes programs to crash when -lm is 3470233294Sstas # linked before any other PIC object. But we must not use 3471233294Sstas # pic_flag when linking with -static. The problem exists in 3472233294Sstas # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 3473233294Sstas *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 3474233294Sstas pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 3475233294Sstas *-*-hpux*) 3476233294Sstas pic_flag_for_symtable=" $pic_flag" ;; 3477233294Sstas *) 3478233294Sstas if test "X$my_pic_p" != Xno; then 3479233294Sstas pic_flag_for_symtable=" $pic_flag" 3480233294Sstas fi 3481233294Sstas ;; 3482233294Sstas esac 3483233294Sstas ;; 3484233294Sstas esac 3485233294Sstas symtab_cflags= 3486233294Sstas for arg in $LTCFLAGS; do 3487233294Sstas case $arg in 3488233294Sstas -pie | -fpie | -fPIE) ;; 3489233294Sstas *) func_append symtab_cflags " $arg" ;; 3490233294Sstas esac 3491233294Sstas done 3492233294Sstas 3493233294Sstas # Now compile the dynamic symbol file. 3494233294Sstas func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3495233294Sstas 3496233294Sstas # Clean up the generated files. 3497233294Sstas func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3498233294Sstas 3499233294Sstas # Transform the symbol file into the correct name. 3500233294Sstas symfileobj="$output_objdir/${my_outputname}S.$objext" 3501233294Sstas case $host in 3502233294Sstas *cygwin* | *mingw* | *cegcc* ) 3503233294Sstas if test -f "$output_objdir/$my_outputname.def"; then 3504233294Sstas compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3505233294Sstas finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3506233294Sstas else 3507233294Sstas compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3508233294Sstas finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3509233294Sstas fi 3510233294Sstas ;; 3511233294Sstas *) 3512233294Sstas compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3513233294Sstas finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3514233294Sstas ;; 3515233294Sstas esac 3516233294Sstas ;; 3517233294Sstas *) 3518233294Sstas func_fatal_error "unknown suffix for \`$my_dlsyms'" 3519233294Sstas ;; 3520233294Sstas esac 3521233294Sstas else 3522233294Sstas # We keep going just in case the user didn't refer to 3523233294Sstas # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 3524233294Sstas # really was required. 3525233294Sstas 3526233294Sstas # Nullify the symbol file. 3527233294Sstas compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 3528233294Sstas finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 3529233294Sstas fi 3530233294Sstas} 3531233294Sstas 3532233294Sstas# func_win32_libid arg 3533233294Sstas# return the library type of file 'arg' 3534233294Sstas# 3535233294Sstas# Need a lot of goo to handle *both* DLLs and import libs 3536233294Sstas# Has to be a shell function in order to 'eat' the argument 3537233294Sstas# that is supplied when $file_magic_command is called. 3538233294Sstas# Despite the name, also deal with 64 bit binaries. 3539233294Sstasfunc_win32_libid () 3540233294Sstas{ 3541233294Sstas $opt_debug 3542233294Sstas win32_libid_type="unknown" 3543233294Sstas win32_fileres=`file -L $1 2>/dev/null` 3544233294Sstas case $win32_fileres in 3545233294Sstas *ar\ archive\ import\ library*) # definitely import 3546233294Sstas win32_libid_type="x86 archive import" 354755682Smarkm ;; 3548233294Sstas *ar\ archive*) # could be an import, or static 3549233294Sstas # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 3550233294Sstas if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 3551233294Sstas $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 3552233294Sstas func_to_tool_file "$1" func_convert_file_msys_to_w32 3553233294Sstas win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 3554233294Sstas $SED -n -e ' 3555233294Sstas 1,100{ 3556233294Sstas / I /{ 3557233294Sstas s,.*,import, 3558233294Sstas p 3559233294Sstas q 3560233294Sstas } 3561233294Sstas }'` 3562233294Sstas case $win32_nmres in 3563233294Sstas import*) win32_libid_type="x86 archive import";; 3564233294Sstas *) win32_libid_type="x86 archive static";; 3565233294Sstas esac 3566233294Sstas fi 3567233294Sstas ;; 3568233294Sstas *DLL*) 3569233294Sstas win32_libid_type="x86 DLL" 3570233294Sstas ;; 3571233294Sstas *executable*) # but shell scripts are "executable" too... 3572233294Sstas case $win32_fileres in 3573233294Sstas *MS\ Windows\ PE\ Intel*) 3574233294Sstas win32_libid_type="x86 DLL" 3575233294Sstas ;; 3576233294Sstas esac 3577233294Sstas ;; 3578233294Sstas esac 3579233294Sstas $ECHO "$win32_libid_type" 3580233294Sstas} 358155682Smarkm 3582233294Sstas# func_cygming_dll_for_implib ARG 3583233294Sstas# 3584233294Sstas# Platform-specific function to extract the 3585233294Sstas# name of the DLL associated with the specified 3586233294Sstas# import library ARG. 3587233294Sstas# Invoked by eval'ing the libtool variable 3588233294Sstas# $sharedlib_from_linklib_cmd 3589233294Sstas# Result is available in the variable 3590233294Sstas# $sharedlib_from_linklib_result 3591233294Sstasfunc_cygming_dll_for_implib () 3592233294Sstas{ 3593233294Sstas $opt_debug 3594233294Sstas sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 3595233294Sstas} 3596233294Sstas 3597233294Sstas# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 3598233294Sstas# 3599233294Sstas# The is the core of a fallback implementation of a 3600233294Sstas# platform-specific function to extract the name of the 3601233294Sstas# DLL associated with the specified import library LIBNAME. 3602233294Sstas# 3603233294Sstas# SECTION_NAME is either .idata$6 or .idata$7, depending 3604233294Sstas# on the platform and compiler that created the implib. 3605233294Sstas# 3606233294Sstas# Echos the name of the DLL associated with the 3607233294Sstas# specified import library. 3608233294Sstasfunc_cygming_dll_for_implib_fallback_core () 3609233294Sstas{ 3610233294Sstas $opt_debug 3611233294Sstas match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 3612233294Sstas $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 3613233294Sstas $SED '/^Contents of section '"$match_literal"':/{ 3614233294Sstas # Place marker at beginning of archive member dllname section 3615233294Sstas s/.*/====MARK====/ 3616233294Sstas p 3617233294Sstas d 3618233294Sstas } 3619233294Sstas # These lines can sometimes be longer than 43 characters, but 3620233294Sstas # are always uninteresting 3621233294Sstas /:[ ]*file format pe[i]\{,1\}-/d 3622233294Sstas /^In archive [^:]*:/d 3623233294Sstas # Ensure marker is printed 3624233294Sstas /^====MARK====/p 3625233294Sstas # Remove all lines with less than 43 characters 3626233294Sstas /^.\{43\}/!d 3627233294Sstas # From remaining lines, remove first 43 characters 3628233294Sstas s/^.\{43\}//' | 3629233294Sstas $SED -n ' 3630233294Sstas # Join marker and all lines until next marker into a single line 3631233294Sstas /^====MARK====/ b para 3632233294Sstas H 3633233294Sstas $ b para 3634233294Sstas b 3635233294Sstas :para 3636233294Sstas x 3637233294Sstas s/\n//g 3638233294Sstas # Remove the marker 3639233294Sstas s/^====MARK====// 3640233294Sstas # Remove trailing dots and whitespace 3641233294Sstas s/[\. \t]*$// 3642233294Sstas # Print 3643233294Sstas /./p' | 3644233294Sstas # we now have a list, one entry per line, of the stringified 3645233294Sstas # contents of the appropriate section of all members of the 3646233294Sstas # archive which possess that section. Heuristic: eliminate 3647233294Sstas # all those which have a first or second character that is 3648233294Sstas # a '.' (that is, objdump's representation of an unprintable 3649233294Sstas # character.) This should work for all archives with less than 3650233294Sstas # 0x302f exports -- but will fail for DLLs whose name actually 3651233294Sstas # begins with a literal '.' or a single character followed by 3652233294Sstas # a '.'. 3653233294Sstas # 3654233294Sstas # Of those that remain, print the first one. 3655233294Sstas $SED -e '/^\./d;/^.\./d;q' 3656233294Sstas} 3657233294Sstas 3658233294Sstas# func_cygming_gnu_implib_p ARG 3659233294Sstas# This predicate returns with zero status (TRUE) if 3660233294Sstas# ARG is a GNU/binutils-style import library. Returns 3661233294Sstas# with nonzero status (FALSE) otherwise. 3662233294Sstasfunc_cygming_gnu_implib_p () 3663233294Sstas{ 3664233294Sstas $opt_debug 3665233294Sstas func_to_tool_file "$1" func_convert_file_msys_to_w32 3666233294Sstas 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)$'` 3667233294Sstas test -n "$func_cygming_gnu_implib_tmp" 3668233294Sstas} 3669233294Sstas 3670233294Sstas# func_cygming_ms_implib_p ARG 3671233294Sstas# This predicate returns with zero status (TRUE) if 3672233294Sstas# ARG is an MS-style import library. Returns 3673233294Sstas# with nonzero status (FALSE) otherwise. 3674233294Sstasfunc_cygming_ms_implib_p () 3675233294Sstas{ 3676233294Sstas $opt_debug 3677233294Sstas func_to_tool_file "$1" func_convert_file_msys_to_w32 3678233294Sstas func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 3679233294Sstas test -n "$func_cygming_ms_implib_tmp" 3680233294Sstas} 3681233294Sstas 3682233294Sstas# func_cygming_dll_for_implib_fallback ARG 3683233294Sstas# Platform-specific function to extract the 3684233294Sstas# name of the DLL associated with the specified 3685233294Sstas# import library ARG. 3686233294Sstas# 3687233294Sstas# This fallback implementation is for use when $DLLTOOL 3688233294Sstas# does not support the --identify-strict option. 3689233294Sstas# Invoked by eval'ing the libtool variable 3690233294Sstas# $sharedlib_from_linklib_cmd 3691233294Sstas# Result is available in the variable 3692233294Sstas# $sharedlib_from_linklib_result 3693233294Sstasfunc_cygming_dll_for_implib_fallback () 3694233294Sstas{ 3695233294Sstas $opt_debug 3696233294Sstas if func_cygming_gnu_implib_p "$1" ; then 3697233294Sstas # binutils import library 3698233294Sstas sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 3699233294Sstas elif func_cygming_ms_implib_p "$1" ; then 3700233294Sstas # ms-generated import library 3701233294Sstas sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 3702233294Sstas else 3703233294Sstas # unknown 3704233294Sstas sharedlib_from_linklib_result="" 3705233294Sstas fi 3706233294Sstas} 3707233294Sstas 3708233294Sstas 3709233294Sstas# func_extract_an_archive dir oldlib 3710233294Sstasfunc_extract_an_archive () 3711233294Sstas{ 3712233294Sstas $opt_debug 3713233294Sstas f_ex_an_ar_dir="$1"; shift 3714233294Sstas f_ex_an_ar_oldlib="$1" 3715233294Sstas if test "$lock_old_archive_extraction" = yes; then 3716233294Sstas lockfile=$f_ex_an_ar_oldlib.lock 3717233294Sstas until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3718233294Sstas func_echo "Waiting for $lockfile to be removed" 3719233294Sstas sleep 2 3720233294Sstas done 3721233294Sstas fi 3722233294Sstas func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 3723233294Sstas 'stat=$?; rm -f "$lockfile"; exit $stat' 3724233294Sstas if test "$lock_old_archive_extraction" = yes; then 3725233294Sstas $opt_dry_run || rm -f "$lockfile" 3726233294Sstas fi 3727233294Sstas if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 3728233294Sstas : 3729233294Sstas else 3730233294Sstas func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 3731233294Sstas fi 3732233294Sstas} 3733233294Sstas 3734233294Sstas 3735233294Sstas# func_extract_archives gentop oldlib ... 3736233294Sstasfunc_extract_archives () 3737233294Sstas{ 3738233294Sstas $opt_debug 3739233294Sstas my_gentop="$1"; shift 3740233294Sstas my_oldlibs=${1+"$@"} 3741233294Sstas my_oldobjs="" 3742233294Sstas my_xlib="" 3743233294Sstas my_xabs="" 3744233294Sstas my_xdir="" 3745233294Sstas 3746233294Sstas for my_xlib in $my_oldlibs; do 3747233294Sstas # Extract the objects. 3748233294Sstas case $my_xlib in 3749233294Sstas [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 3750233294Sstas *) my_xabs=`pwd`"/$my_xlib" ;; 3751233294Sstas esac 3752233294Sstas func_basename "$my_xlib" 3753233294Sstas my_xlib="$func_basename_result" 3754233294Sstas my_xlib_u=$my_xlib 3755233294Sstas while :; do 3756233294Sstas case " $extracted_archives " in 3757233294Sstas *" $my_xlib_u "*) 3758233294Sstas func_arith $extracted_serial + 1 3759233294Sstas extracted_serial=$func_arith_result 3760233294Sstas my_xlib_u=lt$extracted_serial-$my_xlib ;; 3761233294Sstas *) break ;; 3762233294Sstas esac 3763233294Sstas done 3764233294Sstas extracted_archives="$extracted_archives $my_xlib_u" 3765233294Sstas my_xdir="$my_gentop/$my_xlib_u" 3766233294Sstas 3767233294Sstas func_mkdir_p "$my_xdir" 3768233294Sstas 3769233294Sstas case $host in 3770233294Sstas *-darwin*) 3771233294Sstas func_verbose "Extracting $my_xabs" 3772233294Sstas # Do not bother doing anything if just a dry run 3773233294Sstas $opt_dry_run || { 3774233294Sstas darwin_orig_dir=`pwd` 3775233294Sstas cd $my_xdir || exit $? 3776233294Sstas darwin_archive=$my_xabs 3777233294Sstas darwin_curdir=`pwd` 3778233294Sstas darwin_base_archive=`basename "$darwin_archive"` 3779233294Sstas darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 3780233294Sstas if test -n "$darwin_arches"; then 3781233294Sstas darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 3782233294Sstas darwin_arch= 3783233294Sstas func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 3784233294Sstas for darwin_arch in $darwin_arches ; do 3785233294Sstas func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3786233294Sstas $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 3787233294Sstas cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3788233294Sstas func_extract_an_archive "`pwd`" "${darwin_base_archive}" 3789233294Sstas cd "$darwin_curdir" 3790233294Sstas $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 3791233294Sstas done # $darwin_arches 3792233294Sstas ## Okay now we've a bunch of thin objects, gotta fatten them up :) 3793233294Sstas darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 3794233294Sstas darwin_file= 3795233294Sstas darwin_files= 3796233294Sstas for darwin_file in $darwin_filelist; do 3797233294Sstas darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 3798233294Sstas $LIPO -create -output "$darwin_file" $darwin_files 3799233294Sstas done # $darwin_filelist 3800233294Sstas $RM -rf unfat-$$ 3801233294Sstas cd "$darwin_orig_dir" 3802233294Sstas else 3803233294Sstas cd $darwin_orig_dir 3804233294Sstas func_extract_an_archive "$my_xdir" "$my_xabs" 3805233294Sstas fi # $darwin_arches 3806233294Sstas } # !$opt_dry_run 3807233294Sstas ;; 3808233294Sstas *) 3809233294Sstas func_extract_an_archive "$my_xdir" "$my_xabs" 3810233294Sstas ;; 3811233294Sstas esac 3812233294Sstas my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 3813233294Sstas done 3814233294Sstas 3815233294Sstas func_extract_archives_result="$my_oldobjs" 3816233294Sstas} 3817233294Sstas 3818233294Sstas 3819233294Sstas# func_emit_wrapper [arg=no] 3820233294Sstas# 3821233294Sstas# Emit a libtool wrapper script on stdout. 3822233294Sstas# Don't directly open a file because we may want to 3823233294Sstas# incorporate the script contents within a cygwin/mingw 3824233294Sstas# wrapper executable. Must ONLY be called from within 3825233294Sstas# func_mode_link because it depends on a number of variables 3826233294Sstas# set therein. 3827233294Sstas# 3828233294Sstas# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 3829233294Sstas# variable will take. If 'yes', then the emitted script 3830233294Sstas# will assume that the directory in which it is stored is 3831233294Sstas# the $objdir directory. This is a cygwin/mingw-specific 3832233294Sstas# behavior. 3833233294Sstasfunc_emit_wrapper () 3834233294Sstas{ 3835233294Sstas func_emit_wrapper_arg1=${1-no} 3836233294Sstas 3837233294Sstas $ECHO "\ 3838233294Sstas#! $SHELL 3839233294Sstas 3840233294Sstas# $output - temporary wrapper script for $objdir/$outputname 3841233294Sstas# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3842233294Sstas# 3843233294Sstas# The $output program cannot be directly executed until all the libtool 3844233294Sstas# libraries that it depends on are installed. 3845233294Sstas# 3846233294Sstas# This wrapper script should never be moved out of the build directory. 3847233294Sstas# If it is, it will not operate correctly. 3848233294Sstas 3849233294Sstas# Sed substitution that helps us do robust quoting. It backslashifies 3850233294Sstas# metacharacters that are still active within double-quoted strings. 3851233294Sstassed_quote_subst='$sed_quote_subst' 3852233294Sstas 3853233294Sstas# Be Bourne compatible 3854233294Sstasif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 3855233294Sstas emulate sh 3856233294Sstas NULLCMD=: 3857233294Sstas # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 3858233294Sstas # is contrary to our usage. Disable this feature. 3859233294Sstas alias -g '\${1+\"\$@\"}'='\"\$@\"' 3860233294Sstas setopt NO_GLOB_SUBST 3861233294Sstaselse 3862233294Sstas case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 3863233294Sstasfi 3864233294SstasBIN_SH=xpg4; export BIN_SH # for Tru64 3865233294SstasDUALCASE=1; export DUALCASE # for MKS sh 3866233294Sstas 3867233294Sstas# The HP-UX ksh and POSIX shell print the target directory to stdout 3868233294Sstas# if CDPATH is set. 3869233294Sstas(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3870233294Sstas 3871233294Sstasrelink_command=\"$relink_command\" 3872233294Sstas 3873233294Sstas# This environment variable determines our operation mode. 3874233294Sstasif test \"\$libtool_install_magic\" = \"$magic\"; then 3875233294Sstas # install mode needs the following variables: 3876233294Sstas generated_by_libtool_version='$macro_version' 3877233294Sstas notinst_deplibs='$notinst_deplibs' 3878233294Sstaselse 3879233294Sstas # When we are sourced in execute mode, \$file and \$ECHO are already set. 3880233294Sstas if test \"\$libtool_execute_magic\" != \"$magic\"; then 3881233294Sstas file=\"\$0\"" 3882233294Sstas 3883233294Sstas qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 3884233294Sstas $ECHO "\ 3885233294Sstas 3886233294Sstas# A function that is used when there is no print builtin or printf. 3887233294Sstasfunc_fallback_echo () 3888233294Sstas{ 3889233294Sstas eval 'cat <<_LTECHO_EOF 3890233294Sstas\$1 3891233294Sstas_LTECHO_EOF' 3892233294Sstas} 3893233294Sstas ECHO=\"$qECHO\" 3894233294Sstas fi 3895233294Sstas 3896233294Sstas# Very basic option parsing. These options are (a) specific to 3897233294Sstas# the libtool wrapper, (b) are identical between the wrapper 3898233294Sstas# /script/ and the wrapper /executable/ which is used only on 3899233294Sstas# windows platforms, and (c) all begin with the string "--lt-" 3900233294Sstas# (application programs are unlikely to have options which match 3901233294Sstas# this pattern). 3902233294Sstas# 3903233294Sstas# There are only two supported options: --lt-debug and 3904233294Sstas# --lt-dump-script. There is, deliberately, no --lt-help. 3905233294Sstas# 3906233294Sstas# The first argument to this parsing function should be the 3907233294Sstas# script's $0 value, followed by "$@". 3908233294Sstaslt_option_debug= 3909233294Sstasfunc_parse_lt_options () 3910233294Sstas{ 3911233294Sstas lt_script_arg0=\$0 3912233294Sstas shift 3913233294Sstas for lt_opt 3914233294Sstas do 3915233294Sstas case \"\$lt_opt\" in 3916233294Sstas --lt-debug) lt_option_debug=1 ;; 3917233294Sstas --lt-dump-script) 3918233294Sstas lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 3919233294Sstas test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 3920233294Sstas lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 3921233294Sstas cat \"\$lt_dump_D/\$lt_dump_F\" 3922233294Sstas exit 0 3923233294Sstas ;; 3924233294Sstas --lt-*) 3925233294Sstas \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 3926233294Sstas exit 1 3927233294Sstas ;; 3928233294Sstas esac 3929233294Sstas done 3930233294Sstas 3931233294Sstas # Print the debug banner immediately: 3932233294Sstas if test -n \"\$lt_option_debug\"; then 3933233294Sstas echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 3934233294Sstas fi 3935233294Sstas} 3936233294Sstas 3937233294Sstas# Used when --lt-debug. Prints its arguments to stdout 3938233294Sstas# (redirection is the responsibility of the caller) 3939233294Sstasfunc_lt_dump_args () 3940233294Sstas{ 3941233294Sstas lt_dump_args_N=1; 3942233294Sstas for lt_arg 3943233294Sstas do 3944233294Sstas \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 3945233294Sstas lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 3946233294Sstas done 3947233294Sstas} 3948233294Sstas 3949233294Sstas# Core function for launching the target application 3950233294Sstasfunc_exec_program_core () 3951233294Sstas{ 3952233294Sstas" 3953233294Sstas case $host in 3954233294Sstas # Backslashes separate directories on plain windows 3955233294Sstas *-*-mingw | *-*-os2* | *-cegcc*) 3956233294Sstas $ECHO "\ 3957233294Sstas if test -n \"\$lt_option_debug\"; then 3958233294Sstas \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 3959233294Sstas func_lt_dump_args \${1+\"\$@\"} 1>&2 3960233294Sstas fi 3961233294Sstas exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 3962233294Sstas" 3963233294Sstas ;; 3964233294Sstas 3965233294Sstas *) 3966233294Sstas $ECHO "\ 3967233294Sstas if test -n \"\$lt_option_debug\"; then 3968233294Sstas \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 3969233294Sstas func_lt_dump_args \${1+\"\$@\"} 1>&2 3970233294Sstas fi 3971233294Sstas exec \"\$progdir/\$program\" \${1+\"\$@\"} 3972233294Sstas" 3973233294Sstas ;; 3974233294Sstas esac 3975233294Sstas $ECHO "\ 3976233294Sstas \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 3977233294Sstas exit 1 3978233294Sstas} 3979233294Sstas 3980233294Sstas# A function to encapsulate launching the target application 3981233294Sstas# Strips options in the --lt-* namespace from \$@ and 3982233294Sstas# launches target application with the remaining arguments. 3983233294Sstasfunc_exec_program () 3984233294Sstas{ 3985233294Sstas for lt_wr_arg 3986233294Sstas do 3987233294Sstas case \$lt_wr_arg in 3988233294Sstas --lt-*) ;; 3989233294Sstas *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 3990233294Sstas esac 3991233294Sstas shift 3992233294Sstas done 3993233294Sstas func_exec_program_core \${1+\"\$@\"} 3994233294Sstas} 3995233294Sstas 3996233294Sstas # Parse options 3997233294Sstas func_parse_lt_options \"\$0\" \${1+\"\$@\"} 3998233294Sstas 3999233294Sstas # Find the directory that this script lives in. 4000233294Sstas thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 4001233294Sstas test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4002233294Sstas 4003233294Sstas # Follow symbolic links until we get to the real thisdir. 4004233294Sstas file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 4005233294Sstas while test -n \"\$file\"; do 4006233294Sstas destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4007233294Sstas 4008233294Sstas # If there was a directory component, then change thisdir. 4009233294Sstas if test \"x\$destdir\" != \"x\$file\"; then 4010233294Sstas case \"\$destdir\" in 4011233294Sstas [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 4012233294Sstas *) thisdir=\"\$thisdir/\$destdir\" ;; 4013233294Sstas esac 4014233294Sstas fi 4015233294Sstas 4016233294Sstas file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 4017233294Sstas file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 4018233294Sstas done 4019233294Sstas 4020233294Sstas # Usually 'no', except on cygwin/mingw when embedded into 4021233294Sstas # the cwrapper. 4022233294Sstas WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 4023233294Sstas if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 4024233294Sstas # special case for '.' 4025233294Sstas if test \"\$thisdir\" = \".\"; then 4026233294Sstas thisdir=\`pwd\` 4027233294Sstas fi 4028233294Sstas # remove .libs from thisdir 4029233294Sstas case \"\$thisdir\" in 4030233294Sstas *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 4031233294Sstas $objdir ) thisdir=. ;; 4032233294Sstas esac 4033233294Sstas fi 4034233294Sstas 4035233294Sstas # Try to get the absolute directory name. 4036233294Sstas absdir=\`cd \"\$thisdir\" && pwd\` 4037233294Sstas test -n \"\$absdir\" && thisdir=\"\$absdir\" 4038233294Sstas" 4039233294Sstas 4040233294Sstas if test "$fast_install" = yes; then 4041233294Sstas $ECHO "\ 4042233294Sstas program=lt-'$outputname'$exeext 4043233294Sstas progdir=\"\$thisdir/$objdir\" 4044233294Sstas 4045233294Sstas if test ! -f \"\$progdir/\$program\" || 4046233294Sstas { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 4047233294Sstas test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4048233294Sstas 4049233294Sstas file=\"\$\$-\$program\" 4050233294Sstas 4051233294Sstas if test ! -d \"\$progdir\"; then 4052233294Sstas $MKDIR \"\$progdir\" 4053233294Sstas else 4054233294Sstas $RM \"\$progdir/\$file\" 4055233294Sstas fi" 4056233294Sstas 4057233294Sstas $ECHO "\ 4058233294Sstas 4059233294Sstas # relink executable if necessary 4060233294Sstas if test -n \"\$relink_command\"; then 4061233294Sstas if relink_command_output=\`eval \$relink_command 2>&1\`; then : 4062233294Sstas else 4063233294Sstas $ECHO \"\$relink_command_output\" >&2 4064233294Sstas $RM \"\$progdir/\$file\" 4065233294Sstas exit 1 4066233294Sstas fi 4067233294Sstas fi 4068233294Sstas 4069233294Sstas $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 4070233294Sstas { $RM \"\$progdir/\$program\"; 4071233294Sstas $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 4072233294Sstas $RM \"\$progdir/\$file\" 4073233294Sstas fi" 4074233294Sstas else 4075233294Sstas $ECHO "\ 4076233294Sstas program='$outputname' 4077233294Sstas progdir=\"\$thisdir/$objdir\" 4078233294Sstas" 4079233294Sstas fi 4080233294Sstas 4081233294Sstas $ECHO "\ 4082233294Sstas 4083233294Sstas if test -f \"\$progdir/\$program\"; then" 4084233294Sstas 4085233294Sstas # fixup the dll searchpath if we need to. 4086233294Sstas # 4087233294Sstas # Fix the DLL searchpath if we need to. Do this before prepending 4088233294Sstas # to shlibpath, because on Windows, both are PATH and uninstalled 4089233294Sstas # libraries must come first. 4090233294Sstas if test -n "$dllsearchpath"; then 4091233294Sstas $ECHO "\ 4092233294Sstas # Add the dll search path components to the executable PATH 4093233294Sstas PATH=$dllsearchpath:\$PATH 4094233294Sstas" 4095233294Sstas fi 4096233294Sstas 4097233294Sstas # Export our shlibpath_var if we have one. 4098233294Sstas if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4099233294Sstas $ECHO "\ 4100233294Sstas # Add our own library path to $shlibpath_var 4101233294Sstas $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4102233294Sstas 4103233294Sstas # Some systems cannot cope with colon-terminated $shlibpath_var 4104233294Sstas # The second colon is a workaround for a bug in BeOS R4 sed 4105233294Sstas $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4106233294Sstas 4107233294Sstas export $shlibpath_var 4108233294Sstas" 4109233294Sstas fi 4110233294Sstas 4111233294Sstas $ECHO "\ 4112233294Sstas if test \"\$libtool_execute_magic\" != \"$magic\"; then 4113233294Sstas # Run the actual program with our arguments. 4114233294Sstas func_exec_program \${1+\"\$@\"} 4115233294Sstas fi 4116233294Sstas else 4117233294Sstas # The program doesn't exist. 4118233294Sstas \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 4119233294Sstas \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 4120233294Sstas \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 4121233294Sstas exit 1 4122233294Sstas fi 4123233294Sstasfi\ 4124233294Sstas" 4125233294Sstas} 4126233294Sstas 4127233294Sstas 4128233294Sstas# func_emit_cwrapperexe_src 4129233294Sstas# emit the source code for a wrapper executable on stdout 4130233294Sstas# Must ONLY be called from within func_mode_link because 4131233294Sstas# it depends on a number of variable set therein. 4132233294Sstasfunc_emit_cwrapperexe_src () 4133233294Sstas{ 4134233294Sstas cat <<EOF 4135233294Sstas 4136233294Sstas/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4137233294Sstas Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4138233294Sstas 4139233294Sstas The $output program cannot be directly executed until all the libtool 4140233294Sstas libraries that it depends on are installed. 4141233294Sstas 4142233294Sstas This wrapper executable should never be moved out of the build directory. 4143233294Sstas If it is, it will not operate correctly. 4144233294Sstas*/ 4145233294SstasEOF 4146233294Sstas cat <<"EOF" 4147233294Sstas#ifdef _MSC_VER 4148233294Sstas# define _CRT_SECURE_NO_DEPRECATE 1 4149233294Sstas#endif 4150233294Sstas#include <stdio.h> 4151233294Sstas#include <stdlib.h> 4152233294Sstas#ifdef _MSC_VER 4153233294Sstas# include <direct.h> 4154233294Sstas# include <process.h> 4155233294Sstas# include <io.h> 4156233294Sstas#else 4157233294Sstas# include <unistd.h> 4158233294Sstas# include <stdint.h> 4159233294Sstas# ifdef __CYGWIN__ 4160233294Sstas# include <io.h> 4161233294Sstas# endif 4162233294Sstas#endif 4163233294Sstas#include <malloc.h> 4164233294Sstas#include <stdarg.h> 4165233294Sstas#include <assert.h> 4166233294Sstas#include <string.h> 4167233294Sstas#include <ctype.h> 4168233294Sstas#include <errno.h> 4169233294Sstas#include <fcntl.h> 4170233294Sstas#include <sys/stat.h> 4171233294Sstas 4172233294Sstas/* declarations of non-ANSI functions */ 4173233294Sstas#if defined(__MINGW32__) 4174233294Sstas# ifdef __STRICT_ANSI__ 4175233294Sstasint _putenv (const char *); 4176233294Sstas# endif 4177233294Sstas#elif defined(__CYGWIN__) 4178233294Sstas# ifdef __STRICT_ANSI__ 4179233294Sstaschar *realpath (const char *, char *); 4180233294Sstasint putenv (char *); 4181233294Sstasint setenv (const char *, const char *, int); 4182233294Sstas# endif 4183233294Sstas/* #elif defined (other platforms) ... */ 4184233294Sstas#endif 4185233294Sstas 4186233294Sstas/* portability defines, excluding path handling macros */ 4187233294Sstas#if defined(_MSC_VER) 4188233294Sstas# define setmode _setmode 4189233294Sstas# define stat _stat 4190233294Sstas# define chmod _chmod 4191233294Sstas# define getcwd _getcwd 4192233294Sstas# define putenv _putenv 4193233294Sstas# define S_IXUSR _S_IEXEC 4194233294Sstas# ifndef _INTPTR_T_DEFINED 4195233294Sstas# define _INTPTR_T_DEFINED 4196233294Sstas# define intptr_t int 4197233294Sstas# endif 4198233294Sstas#elif defined(__MINGW32__) 4199233294Sstas# define setmode _setmode 4200233294Sstas# define stat _stat 4201233294Sstas# define chmod _chmod 4202233294Sstas# define getcwd _getcwd 4203233294Sstas# define putenv _putenv 4204233294Sstas#elif defined(__CYGWIN__) 4205233294Sstas# define HAVE_SETENV 4206233294Sstas# define FOPEN_WB "wb" 4207233294Sstas/* #elif defined (other platforms) ... */ 4208233294Sstas#endif 4209233294Sstas 4210233294Sstas#if defined(PATH_MAX) 4211233294Sstas# define LT_PATHMAX PATH_MAX 4212233294Sstas#elif defined(MAXPATHLEN) 4213233294Sstas# define LT_PATHMAX MAXPATHLEN 4214233294Sstas#else 4215233294Sstas# define LT_PATHMAX 1024 4216233294Sstas#endif 4217233294Sstas 4218233294Sstas#ifndef S_IXOTH 4219233294Sstas# define S_IXOTH 0 4220233294Sstas#endif 4221233294Sstas#ifndef S_IXGRP 4222233294Sstas# define S_IXGRP 0 4223233294Sstas#endif 4224233294Sstas 4225233294Sstas/* path handling portability macros */ 4226233294Sstas#ifndef DIR_SEPARATOR 4227233294Sstas# define DIR_SEPARATOR '/' 4228233294Sstas# define PATH_SEPARATOR ':' 4229233294Sstas#endif 4230233294Sstas 4231233294Sstas#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4232233294Sstas defined (__OS2__) 4233233294Sstas# define HAVE_DOS_BASED_FILE_SYSTEM 4234233294Sstas# define FOPEN_WB "wb" 4235233294Sstas# ifndef DIR_SEPARATOR_2 4236233294Sstas# define DIR_SEPARATOR_2 '\\' 4237233294Sstas# endif 4238233294Sstas# ifndef PATH_SEPARATOR_2 4239233294Sstas# define PATH_SEPARATOR_2 ';' 4240233294Sstas# endif 4241233294Sstas#endif 4242233294Sstas 4243233294Sstas#ifndef DIR_SEPARATOR_2 4244233294Sstas# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 4245233294Sstas#else /* DIR_SEPARATOR_2 */ 4246233294Sstas# define IS_DIR_SEPARATOR(ch) \ 4247233294Sstas (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 4248233294Sstas#endif /* DIR_SEPARATOR_2 */ 4249233294Sstas 4250233294Sstas#ifndef PATH_SEPARATOR_2 4251233294Sstas# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 4252233294Sstas#else /* PATH_SEPARATOR_2 */ 4253233294Sstas# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 4254233294Sstas#endif /* PATH_SEPARATOR_2 */ 4255233294Sstas 4256233294Sstas#ifndef FOPEN_WB 4257233294Sstas# define FOPEN_WB "w" 4258233294Sstas#endif 4259233294Sstas#ifndef _O_BINARY 4260233294Sstas# define _O_BINARY 0 4261233294Sstas#endif 4262233294Sstas 4263233294Sstas#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 4264233294Sstas#define XFREE(stale) do { \ 4265233294Sstas if (stale) { free ((void *) stale); stale = 0; } \ 4266233294Sstas} while (0) 4267233294Sstas 4268233294Sstas#if defined(LT_DEBUGWRAPPER) 4269233294Sstasstatic int lt_debug = 1; 4270233294Sstas#else 4271233294Sstasstatic int lt_debug = 0; 4272233294Sstas#endif 4273233294Sstas 4274233294Sstasconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4275233294Sstas 4276233294Sstasvoid *xmalloc (size_t num); 4277233294Sstaschar *xstrdup (const char *string); 4278233294Sstasconst char *base_name (const char *name); 4279233294Sstaschar *find_executable (const char *wrapper); 4280233294Sstaschar *chase_symlinks (const char *pathspec); 4281233294Sstasint make_executable (const char *path); 4282233294Sstasint check_executable (const char *path); 4283233294Sstaschar *strendzap (char *str, const char *pat); 4284233294Sstasvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 4285233294Sstasvoid lt_fatal (const char *file, int line, const char *message, ...); 4286233294Sstasstatic const char *nonnull (const char *s); 4287233294Sstasstatic const char *nonempty (const char *s); 4288233294Sstasvoid lt_setenv (const char *name, const char *value); 4289233294Sstaschar *lt_extend_str (const char *orig_value, const char *add, int to_end); 4290233294Sstasvoid lt_update_exe_path (const char *name, const char *value); 4291233294Sstasvoid lt_update_lib_path (const char *name, const char *value); 4292233294Sstaschar **prepare_spawn (char **argv); 4293233294Sstasvoid lt_dump_script (FILE *f); 4294233294SstasEOF 4295233294Sstas 4296233294Sstas cat <<EOF 4297233294Sstasvolatile const char * MAGIC_EXE = "$magic_exe"; 4298233294Sstasconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 4299233294SstasEOF 4300233294Sstas 4301233294Sstas if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4302233294Sstas func_to_host_path "$temp_rpath" 4303233294Sstas cat <<EOF 4304233294Sstasconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 4305233294SstasEOF 4306233294Sstas else 4307233294Sstas cat <<"EOF" 4308233294Sstasconst char * LIB_PATH_VALUE = ""; 4309233294SstasEOF 4310233294Sstas fi 4311233294Sstas 4312233294Sstas if test -n "$dllsearchpath"; then 4313233294Sstas func_to_host_path "$dllsearchpath:" 4314233294Sstas cat <<EOF 4315233294Sstasconst char * EXE_PATH_VARNAME = "PATH"; 4316233294Sstasconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 4317233294SstasEOF 4318233294Sstas else 4319233294Sstas cat <<"EOF" 4320233294Sstasconst char * EXE_PATH_VARNAME = ""; 4321233294Sstasconst char * EXE_PATH_VALUE = ""; 4322233294SstasEOF 4323233294Sstas fi 4324233294Sstas 4325233294Sstas if test "$fast_install" = yes; then 4326233294Sstas cat <<EOF 4327233294Sstasconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 4328233294SstasEOF 4329233294Sstas else 4330233294Sstas cat <<EOF 4331233294Sstasconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 4332233294SstasEOF 4333233294Sstas fi 4334233294Sstas 4335233294Sstas 4336233294Sstas cat <<"EOF" 4337233294Sstas 4338233294Sstas#define LTWRAPPER_OPTION_PREFIX "--lt-" 4339233294Sstas 4340233294Sstasstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 4341233294Sstasstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 4342233294Sstasstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4343233294Sstas 4344233294Sstasint 4345233294Sstasmain (int argc, char *argv[]) 4346233294Sstas{ 4347233294Sstas char **newargz; 4348233294Sstas int newargc; 4349233294Sstas char *tmp_pathspec; 4350233294Sstas char *actual_cwrapper_path; 4351233294Sstas char *actual_cwrapper_name; 4352233294Sstas char *target_name; 4353233294Sstas char *lt_argv_zero; 4354233294Sstas intptr_t rval = 127; 4355233294Sstas 4356233294Sstas int i; 4357233294Sstas 4358233294Sstas program_name = (char *) xstrdup (base_name (argv[0])); 4359233294Sstas newargz = XMALLOC (char *, argc + 1); 4360233294Sstas 4361233294Sstas /* very simple arg parsing; don't want to rely on getopt 4362233294Sstas * also, copy all non cwrapper options to newargz, except 4363233294Sstas * argz[0], which is handled differently 4364233294Sstas */ 4365233294Sstas newargc=0; 4366233294Sstas for (i = 1; i < argc; i++) 4367233294Sstas { 4368233294Sstas if (strcmp (argv[i], dumpscript_opt) == 0) 4369233294Sstas { 4370233294SstasEOF 4371233294Sstas case "$host" in 4372233294Sstas *mingw* | *cygwin* ) 4373233294Sstas # make stdout use "unix" line endings 4374233294Sstas echo " setmode(1,_O_BINARY);" 4375233294Sstas ;; 4376233294Sstas esac 4377233294Sstas 4378233294Sstas cat <<"EOF" 4379233294Sstas lt_dump_script (stdout); 4380233294Sstas return 0; 4381233294Sstas } 4382233294Sstas if (strcmp (argv[i], debug_opt) == 0) 4383233294Sstas { 4384233294Sstas lt_debug = 1; 4385233294Sstas continue; 4386233294Sstas } 4387233294Sstas if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 4388233294Sstas { 4389233294Sstas /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4390233294Sstas namespace, but it is not one of the ones we know about and 4391233294Sstas have already dealt with, above (inluding dump-script), then 4392233294Sstas report an error. Otherwise, targets might begin to believe 4393233294Sstas they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4394233294Sstas namespace. The first time any user complains about this, we'll 4395233294Sstas need to make LTWRAPPER_OPTION_PREFIX a configure-time option 4396233294Sstas or a configure.ac-settable value. 4397233294Sstas */ 4398233294Sstas lt_fatal (__FILE__, __LINE__, 4399233294Sstas "unrecognized %s option: '%s'", 4400233294Sstas ltwrapper_option_prefix, argv[i]); 4401233294Sstas } 4402233294Sstas /* otherwise ... */ 4403233294Sstas newargz[++newargc] = xstrdup (argv[i]); 4404233294Sstas } 4405233294Sstas newargz[++newargc] = NULL; 4406233294Sstas 4407233294SstasEOF 4408233294Sstas cat <<EOF 4409233294Sstas /* The GNU banner must be the first non-error debug message */ 4410233294Sstas lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 4411233294SstasEOF 4412233294Sstas cat <<"EOF" 4413233294Sstas lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 4414233294Sstas lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4415233294Sstas 4416233294Sstas tmp_pathspec = find_executable (argv[0]); 4417233294Sstas if (tmp_pathspec == NULL) 4418233294Sstas lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 4419233294Sstas lt_debugprintf (__FILE__, __LINE__, 4420233294Sstas "(main) found exe (before symlink chase) at: %s\n", 4421233294Sstas tmp_pathspec); 4422233294Sstas 4423233294Sstas actual_cwrapper_path = chase_symlinks (tmp_pathspec); 4424233294Sstas lt_debugprintf (__FILE__, __LINE__, 4425233294Sstas "(main) found exe (after symlink chase) at: %s\n", 4426233294Sstas actual_cwrapper_path); 4427233294Sstas XFREE (tmp_pathspec); 4428233294Sstas 4429233294Sstas actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 4430233294Sstas strendzap (actual_cwrapper_path, actual_cwrapper_name); 4431233294Sstas 4432233294Sstas /* wrapper name transforms */ 4433233294Sstas strendzap (actual_cwrapper_name, ".exe"); 4434233294Sstas tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 4435233294Sstas XFREE (actual_cwrapper_name); 4436233294Sstas actual_cwrapper_name = tmp_pathspec; 4437233294Sstas tmp_pathspec = 0; 4438233294Sstas 4439233294Sstas /* target_name transforms -- use actual target program name; might have lt- prefix */ 4440233294Sstas target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 4441233294Sstas strendzap (target_name, ".exe"); 4442233294Sstas tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 4443233294Sstas XFREE (target_name); 4444233294Sstas target_name = tmp_pathspec; 4445233294Sstas tmp_pathspec = 0; 4446233294Sstas 4447233294Sstas lt_debugprintf (__FILE__, __LINE__, 4448233294Sstas "(main) libtool target name: %s\n", 4449233294Sstas target_name); 4450233294SstasEOF 4451233294Sstas 4452233294Sstas cat <<EOF 4453233294Sstas newargz[0] = 4454233294Sstas XMALLOC (char, (strlen (actual_cwrapper_path) + 4455233294Sstas strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 4456233294Sstas strcpy (newargz[0], actual_cwrapper_path); 4457233294Sstas strcat (newargz[0], "$objdir"); 4458233294Sstas strcat (newargz[0], "/"); 4459233294SstasEOF 4460233294Sstas 4461233294Sstas cat <<"EOF" 4462233294Sstas /* stop here, and copy so we don't have to do this twice */ 4463233294Sstas tmp_pathspec = xstrdup (newargz[0]); 4464233294Sstas 4465233294Sstas /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 4466233294Sstas strcat (newargz[0], actual_cwrapper_name); 4467233294Sstas 4468233294Sstas /* DO want the lt- prefix here if it exists, so use target_name */ 4469233294Sstas lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 4470233294Sstas XFREE (tmp_pathspec); 4471233294Sstas tmp_pathspec = NULL; 4472233294SstasEOF 4473233294Sstas 4474233294Sstas case $host_os in 4475233294Sstas mingw*) 4476233294Sstas cat <<"EOF" 4477233294Sstas { 4478233294Sstas char* p; 4479233294Sstas while ((p = strchr (newargz[0], '\\')) != NULL) 4480233294Sstas { 4481233294Sstas *p = '/'; 4482233294Sstas } 4483233294Sstas while ((p = strchr (lt_argv_zero, '\\')) != NULL) 4484233294Sstas { 4485233294Sstas *p = '/'; 4486233294Sstas } 4487233294Sstas } 4488233294SstasEOF 4489233294Sstas ;; 4490233294Sstas esac 4491233294Sstas 4492233294Sstas cat <<"EOF" 4493233294Sstas XFREE (target_name); 4494233294Sstas XFREE (actual_cwrapper_path); 4495233294Sstas XFREE (actual_cwrapper_name); 4496233294Sstas 4497233294Sstas lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 4498233294Sstas lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 4499233294Sstas /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 4500233294Sstas be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 4501233294Sstas because on Windows, both *_VARNAMEs are PATH but uninstalled 4502233294Sstas libraries must come first. */ 4503233294Sstas lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 4504233294Sstas lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4505233294Sstas 4506233294Sstas lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 4507233294Sstas nonnull (lt_argv_zero)); 4508233294Sstas for (i = 0; i < newargc; i++) 4509233294Sstas { 4510233294Sstas lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 4511233294Sstas i, nonnull (newargz[i])); 4512233294Sstas } 4513233294Sstas 4514233294SstasEOF 4515233294Sstas 4516233294Sstas case $host_os in 4517233294Sstas mingw*) 4518233294Sstas cat <<"EOF" 4519233294Sstas /* execv doesn't actually work on mingw as expected on unix */ 4520233294Sstas newargz = prepare_spawn (newargz); 4521233294Sstas rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 4522233294Sstas if (rval == -1) 4523233294Sstas { 4524233294Sstas /* failed to start process */ 4525233294Sstas lt_debugprintf (__FILE__, __LINE__, 4526233294Sstas "(main) failed to launch target \"%s\": %s\n", 4527233294Sstas lt_argv_zero, nonnull (strerror (errno))); 4528233294Sstas return 127; 4529233294Sstas } 4530233294Sstas return rval; 4531233294SstasEOF 4532233294Sstas ;; 4533233294Sstas *) 4534233294Sstas cat <<"EOF" 4535233294Sstas execv (lt_argv_zero, newargz); 4536233294Sstas return rval; /* =127, but avoids unused variable warning */ 4537233294SstasEOF 4538233294Sstas ;; 4539233294Sstas esac 4540233294Sstas 4541233294Sstas cat <<"EOF" 4542233294Sstas} 4543233294Sstas 4544233294Sstasvoid * 4545233294Sstasxmalloc (size_t num) 4546233294Sstas{ 4547233294Sstas void *p = (void *) malloc (num); 4548233294Sstas if (!p) 4549233294Sstas lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4550233294Sstas 4551233294Sstas return p; 4552233294Sstas} 4553233294Sstas 4554233294Sstaschar * 4555233294Sstasxstrdup (const char *string) 4556233294Sstas{ 4557233294Sstas return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 4558233294Sstas string) : NULL; 4559233294Sstas} 4560233294Sstas 4561233294Sstasconst char * 4562233294Sstasbase_name (const char *name) 4563233294Sstas{ 4564233294Sstas const char *base; 4565233294Sstas 4566233294Sstas#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4567233294Sstas /* Skip over the disk name in MSDOS pathnames. */ 4568233294Sstas if (isalpha ((unsigned char) name[0]) && name[1] == ':') 4569233294Sstas name += 2; 4570233294Sstas#endif 4571233294Sstas 4572233294Sstas for (base = name; *name; name++) 4573233294Sstas if (IS_DIR_SEPARATOR (*name)) 4574233294Sstas base = name + 1; 4575233294Sstas return base; 4576233294Sstas} 4577233294Sstas 4578233294Sstasint 4579233294Sstascheck_executable (const char *path) 4580233294Sstas{ 4581233294Sstas struct stat st; 4582233294Sstas 4583233294Sstas lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 4584233294Sstas nonempty (path)); 4585233294Sstas if ((!path) || (!*path)) 4586233294Sstas return 0; 4587233294Sstas 4588233294Sstas if ((stat (path, &st) >= 0) 4589233294Sstas && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 4590233294Sstas return 1; 4591233294Sstas else 4592233294Sstas return 0; 4593233294Sstas} 4594233294Sstas 4595233294Sstasint 4596233294Sstasmake_executable (const char *path) 4597233294Sstas{ 4598233294Sstas int rval = 0; 4599233294Sstas struct stat st; 4600233294Sstas 4601233294Sstas lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 4602233294Sstas nonempty (path)); 4603233294Sstas if ((!path) || (!*path)) 4604233294Sstas return 0; 4605233294Sstas 4606233294Sstas if (stat (path, &st) >= 0) 4607233294Sstas { 4608233294Sstas rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 4609233294Sstas } 4610233294Sstas return rval; 4611233294Sstas} 4612233294Sstas 4613233294Sstas/* Searches for the full path of the wrapper. Returns 4614233294Sstas newly allocated full path name if found, NULL otherwise 4615233294Sstas Does not chase symlinks, even on platforms that support them. 4616233294Sstas*/ 4617233294Sstaschar * 4618233294Sstasfind_executable (const char *wrapper) 4619233294Sstas{ 4620233294Sstas int has_slash = 0; 4621233294Sstas const char *p; 4622233294Sstas const char *p_next; 4623233294Sstas /* static buffer for getcwd */ 4624233294Sstas char tmp[LT_PATHMAX + 1]; 4625233294Sstas int tmp_len; 4626233294Sstas char *concat_name; 4627233294Sstas 4628233294Sstas lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 4629233294Sstas nonempty (wrapper)); 4630233294Sstas 4631233294Sstas if ((wrapper == NULL) || (*wrapper == '\0')) 4632233294Sstas return NULL; 4633233294Sstas 4634233294Sstas /* Absolute path? */ 4635233294Sstas#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4636233294Sstas if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 4637233294Sstas { 4638233294Sstas concat_name = xstrdup (wrapper); 4639233294Sstas if (check_executable (concat_name)) 4640233294Sstas return concat_name; 4641233294Sstas XFREE (concat_name); 4642233294Sstas } 4643233294Sstas else 4644233294Sstas { 4645233294Sstas#endif 4646233294Sstas if (IS_DIR_SEPARATOR (wrapper[0])) 4647233294Sstas { 4648233294Sstas concat_name = xstrdup (wrapper); 4649233294Sstas if (check_executable (concat_name)) 4650233294Sstas return concat_name; 4651233294Sstas XFREE (concat_name); 4652233294Sstas } 4653233294Sstas#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4654233294Sstas } 4655233294Sstas#endif 4656233294Sstas 4657233294Sstas for (p = wrapper; *p; p++) 4658233294Sstas if (*p == '/') 4659233294Sstas { 4660233294Sstas has_slash = 1; 4661233294Sstas break; 4662233294Sstas } 4663233294Sstas if (!has_slash) 4664233294Sstas { 4665233294Sstas /* no slashes; search PATH */ 4666233294Sstas const char *path = getenv ("PATH"); 4667233294Sstas if (path != NULL) 4668233294Sstas { 4669233294Sstas for (p = path; *p; p = p_next) 4670233294Sstas { 4671233294Sstas const char *q; 4672233294Sstas size_t p_len; 4673233294Sstas for (q = p; *q; q++) 4674233294Sstas if (IS_PATH_SEPARATOR (*q)) 4675233294Sstas break; 4676233294Sstas p_len = q - p; 4677233294Sstas p_next = (*q == '\0' ? q : q + 1); 4678233294Sstas if (p_len == 0) 4679233294Sstas { 4680233294Sstas /* empty path: current directory */ 4681233294Sstas if (getcwd (tmp, LT_PATHMAX) == NULL) 4682233294Sstas lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4683233294Sstas nonnull (strerror (errno))); 4684233294Sstas tmp_len = strlen (tmp); 4685233294Sstas concat_name = 4686233294Sstas XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4687233294Sstas memcpy (concat_name, tmp, tmp_len); 4688233294Sstas concat_name[tmp_len] = '/'; 4689233294Sstas strcpy (concat_name + tmp_len + 1, wrapper); 4690233294Sstas } 4691233294Sstas else 4692233294Sstas { 4693233294Sstas concat_name = 4694233294Sstas XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 4695233294Sstas memcpy (concat_name, p, p_len); 4696233294Sstas concat_name[p_len] = '/'; 4697233294Sstas strcpy (concat_name + p_len + 1, wrapper); 4698233294Sstas } 4699233294Sstas if (check_executable (concat_name)) 4700233294Sstas return concat_name; 4701233294Sstas XFREE (concat_name); 4702233294Sstas } 4703233294Sstas } 4704233294Sstas /* not found in PATH; assume curdir */ 4705233294Sstas } 4706233294Sstas /* Relative path | not found in path: prepend cwd */ 4707233294Sstas if (getcwd (tmp, LT_PATHMAX) == NULL) 4708233294Sstas lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4709233294Sstas nonnull (strerror (errno))); 4710233294Sstas tmp_len = strlen (tmp); 4711233294Sstas concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4712233294Sstas memcpy (concat_name, tmp, tmp_len); 4713233294Sstas concat_name[tmp_len] = '/'; 4714233294Sstas strcpy (concat_name + tmp_len + 1, wrapper); 4715233294Sstas 4716233294Sstas if (check_executable (concat_name)) 4717233294Sstas return concat_name; 4718233294Sstas XFREE (concat_name); 4719233294Sstas return NULL; 4720233294Sstas} 4721233294Sstas 4722233294Sstaschar * 4723233294Sstaschase_symlinks (const char *pathspec) 4724233294Sstas{ 4725233294Sstas#ifndef S_ISLNK 4726233294Sstas return xstrdup (pathspec); 4727233294Sstas#else 4728233294Sstas char buf[LT_PATHMAX]; 4729233294Sstas struct stat s; 4730233294Sstas char *tmp_pathspec = xstrdup (pathspec); 4731233294Sstas char *p; 4732233294Sstas int has_symlinks = 0; 4733233294Sstas while (strlen (tmp_pathspec) && !has_symlinks) 4734233294Sstas { 4735233294Sstas lt_debugprintf (__FILE__, __LINE__, 4736233294Sstas "checking path component for symlinks: %s\n", 4737233294Sstas tmp_pathspec); 4738233294Sstas if (lstat (tmp_pathspec, &s) == 0) 4739233294Sstas { 4740233294Sstas if (S_ISLNK (s.st_mode) != 0) 4741233294Sstas { 4742233294Sstas has_symlinks = 1; 4743233294Sstas break; 4744233294Sstas } 4745233294Sstas 4746233294Sstas /* search backwards for last DIR_SEPARATOR */ 4747233294Sstas p = tmp_pathspec + strlen (tmp_pathspec) - 1; 4748233294Sstas while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4749233294Sstas p--; 4750233294Sstas if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4751233294Sstas { 4752233294Sstas /* no more DIR_SEPARATORS left */ 4753233294Sstas break; 4754233294Sstas } 4755233294Sstas *p = '\0'; 4756233294Sstas } 4757233294Sstas else 4758233294Sstas { 4759233294Sstas lt_fatal (__FILE__, __LINE__, 4760233294Sstas "error accessing file \"%s\": %s", 4761233294Sstas tmp_pathspec, nonnull (strerror (errno))); 4762233294Sstas } 4763233294Sstas } 4764233294Sstas XFREE (tmp_pathspec); 4765233294Sstas 4766233294Sstas if (!has_symlinks) 4767233294Sstas { 4768233294Sstas return xstrdup (pathspec); 4769233294Sstas } 4770233294Sstas 4771233294Sstas tmp_pathspec = realpath (pathspec, buf); 4772233294Sstas if (tmp_pathspec == 0) 4773233294Sstas { 4774233294Sstas lt_fatal (__FILE__, __LINE__, 4775233294Sstas "could not follow symlinks for %s", pathspec); 4776233294Sstas } 4777233294Sstas return xstrdup (tmp_pathspec); 4778233294Sstas#endif 4779233294Sstas} 4780233294Sstas 4781233294Sstaschar * 4782233294Sstasstrendzap (char *str, const char *pat) 4783233294Sstas{ 4784233294Sstas size_t len, patlen; 4785233294Sstas 4786233294Sstas assert (str != NULL); 4787233294Sstas assert (pat != NULL); 4788233294Sstas 4789233294Sstas len = strlen (str); 4790233294Sstas patlen = strlen (pat); 4791233294Sstas 4792233294Sstas if (patlen <= len) 4793233294Sstas { 4794233294Sstas str += len - patlen; 4795233294Sstas if (strcmp (str, pat) == 0) 4796233294Sstas *str = '\0'; 4797233294Sstas } 4798233294Sstas return str; 4799233294Sstas} 4800233294Sstas 4801233294Sstasvoid 4802233294Sstaslt_debugprintf (const char *file, int line, const char *fmt, ...) 4803233294Sstas{ 4804233294Sstas va_list args; 4805233294Sstas if (lt_debug) 4806233294Sstas { 4807233294Sstas (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 4808233294Sstas va_start (args, fmt); 4809233294Sstas (void) vfprintf (stderr, fmt, args); 4810233294Sstas va_end (args); 4811233294Sstas } 4812233294Sstas} 4813233294Sstas 4814233294Sstasstatic void 4815233294Sstaslt_error_core (int exit_status, const char *file, 4816233294Sstas int line, const char *mode, 4817233294Sstas const char *message, va_list ap) 4818233294Sstas{ 4819233294Sstas fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 4820233294Sstas vfprintf (stderr, message, ap); 4821233294Sstas fprintf (stderr, ".\n"); 4822233294Sstas 4823233294Sstas if (exit_status >= 0) 4824233294Sstas exit (exit_status); 4825233294Sstas} 4826233294Sstas 4827233294Sstasvoid 4828233294Sstaslt_fatal (const char *file, int line, const char *message, ...) 4829233294Sstas{ 4830233294Sstas va_list ap; 4831233294Sstas va_start (ap, message); 4832233294Sstas lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 4833233294Sstas va_end (ap); 4834233294Sstas} 4835233294Sstas 4836233294Sstasstatic const char * 4837233294Sstasnonnull (const char *s) 4838233294Sstas{ 4839233294Sstas return s ? s : "(null)"; 4840233294Sstas} 4841233294Sstas 4842233294Sstasstatic const char * 4843233294Sstasnonempty (const char *s) 4844233294Sstas{ 4845233294Sstas return (s && !*s) ? "(empty)" : nonnull (s); 4846233294Sstas} 4847233294Sstas 4848233294Sstasvoid 4849233294Sstaslt_setenv (const char *name, const char *value) 4850233294Sstas{ 4851233294Sstas lt_debugprintf (__FILE__, __LINE__, 4852233294Sstas "(lt_setenv) setting '%s' to '%s'\n", 4853233294Sstas nonnull (name), nonnull (value)); 4854233294Sstas { 4855233294Sstas#ifdef HAVE_SETENV 4856233294Sstas /* always make a copy, for consistency with !HAVE_SETENV */ 4857233294Sstas char *str = xstrdup (value); 4858233294Sstas setenv (name, str, 1); 4859233294Sstas#else 4860233294Sstas int len = strlen (name) + 1 + strlen (value) + 1; 4861233294Sstas char *str = XMALLOC (char, len); 4862233294Sstas sprintf (str, "%s=%s", name, value); 4863233294Sstas if (putenv (str) != EXIT_SUCCESS) 4864233294Sstas { 4865233294Sstas XFREE (str); 4866233294Sstas } 4867233294Sstas#endif 4868233294Sstas } 4869233294Sstas} 4870233294Sstas 4871233294Sstaschar * 4872233294Sstaslt_extend_str (const char *orig_value, const char *add, int to_end) 4873233294Sstas{ 4874233294Sstas char *new_value; 4875233294Sstas if (orig_value && *orig_value) 4876233294Sstas { 4877233294Sstas int orig_value_len = strlen (orig_value); 4878233294Sstas int add_len = strlen (add); 4879233294Sstas new_value = XMALLOC (char, add_len + orig_value_len + 1); 4880233294Sstas if (to_end) 4881233294Sstas { 4882233294Sstas strcpy (new_value, orig_value); 4883233294Sstas strcpy (new_value + orig_value_len, add); 4884233294Sstas } 4885233294Sstas else 4886233294Sstas { 4887233294Sstas strcpy (new_value, add); 4888233294Sstas strcpy (new_value + add_len, orig_value); 4889233294Sstas } 4890233294Sstas } 4891233294Sstas else 4892233294Sstas { 4893233294Sstas new_value = xstrdup (add); 4894233294Sstas } 4895233294Sstas return new_value; 4896233294Sstas} 4897233294Sstas 4898233294Sstasvoid 4899233294Sstaslt_update_exe_path (const char *name, const char *value) 4900233294Sstas{ 4901233294Sstas lt_debugprintf (__FILE__, __LINE__, 4902233294Sstas "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 4903233294Sstas nonnull (name), nonnull (value)); 4904233294Sstas 4905233294Sstas if (name && *name && value && *value) 4906233294Sstas { 4907233294Sstas char *new_value = lt_extend_str (getenv (name), value, 0); 4908233294Sstas /* some systems can't cope with a ':'-terminated path #' */ 4909233294Sstas int len = strlen (new_value); 4910233294Sstas while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 4911233294Sstas { 4912233294Sstas new_value[len-1] = '\0'; 4913233294Sstas } 4914233294Sstas lt_setenv (name, new_value); 4915233294Sstas XFREE (new_value); 4916233294Sstas } 4917233294Sstas} 4918233294Sstas 4919233294Sstasvoid 4920233294Sstaslt_update_lib_path (const char *name, const char *value) 4921233294Sstas{ 4922233294Sstas lt_debugprintf (__FILE__, __LINE__, 4923233294Sstas "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 4924233294Sstas nonnull (name), nonnull (value)); 4925233294Sstas 4926233294Sstas if (name && *name && value && *value) 4927233294Sstas { 4928233294Sstas char *new_value = lt_extend_str (getenv (name), value, 0); 4929233294Sstas lt_setenv (name, new_value); 4930233294Sstas XFREE (new_value); 4931233294Sstas } 4932233294Sstas} 4933233294Sstas 4934233294SstasEOF 4935233294Sstas case $host_os in 4936233294Sstas mingw*) 4937233294Sstas cat <<"EOF" 4938233294Sstas 4939233294Sstas/* Prepares an argument vector before calling spawn(). 4940233294Sstas Note that spawn() does not by itself call the command interpreter 4941233294Sstas (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 4942233294Sstas ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 4943233294Sstas GetVersionEx(&v); 4944233294Sstas v.dwPlatformId == VER_PLATFORM_WIN32_NT; 4945233294Sstas }) ? "cmd.exe" : "command.com"). 4946233294Sstas Instead it simply concatenates the arguments, separated by ' ', and calls 4947233294Sstas CreateProcess(). We must quote the arguments since Win32 CreateProcess() 4948233294Sstas interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 4949233294Sstas special way: 4950233294Sstas - Space and tab are interpreted as delimiters. They are not treated as 4951233294Sstas delimiters if they are surrounded by double quotes: "...". 4952233294Sstas - Unescaped double quotes are removed from the input. Their only effect is 4953233294Sstas that within double quotes, space and tab are treated like normal 4954233294Sstas characters. 4955233294Sstas - Backslashes not followed by double quotes are not special. 4956233294Sstas - But 2*n+1 backslashes followed by a double quote become 4957233294Sstas n backslashes followed by a double quote (n >= 0): 4958233294Sstas \" -> " 4959233294Sstas \\\" -> \" 4960233294Sstas \\\\\" -> \\" 4961233294Sstas */ 4962233294Sstas#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" 4963233294Sstas#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" 4964233294Sstaschar ** 4965233294Sstasprepare_spawn (char **argv) 4966233294Sstas{ 4967233294Sstas size_t argc; 4968233294Sstas char **new_argv; 4969233294Sstas size_t i; 4970233294Sstas 4971233294Sstas /* Count number of arguments. */ 4972233294Sstas for (argc = 0; argv[argc] != NULL; argc++) 4973233294Sstas ; 4974233294Sstas 4975233294Sstas /* Allocate new argument vector. */ 4976233294Sstas new_argv = XMALLOC (char *, argc + 1); 4977233294Sstas 4978233294Sstas /* Put quoted arguments into the new argument vector. */ 4979233294Sstas for (i = 0; i < argc; i++) 4980233294Sstas { 4981233294Sstas const char *string = argv[i]; 4982233294Sstas 4983233294Sstas if (string[0] == '\0') 4984233294Sstas new_argv[i] = xstrdup ("\"\""); 4985233294Sstas else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 4986233294Sstas { 4987233294Sstas int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 4988233294Sstas size_t length; 4989233294Sstas unsigned int backslashes; 4990233294Sstas const char *s; 4991233294Sstas char *quoted_string; 4992233294Sstas char *p; 4993233294Sstas 4994233294Sstas length = 0; 4995233294Sstas backslashes = 0; 4996233294Sstas if (quote_around) 4997233294Sstas length++; 4998233294Sstas for (s = string; *s != '\0'; s++) 4999233294Sstas { 5000233294Sstas char c = *s; 5001233294Sstas if (c == '"') 5002233294Sstas length += backslashes + 1; 5003233294Sstas length++; 5004233294Sstas if (c == '\\') 5005233294Sstas backslashes++; 5006233294Sstas else 5007233294Sstas backslashes = 0; 5008233294Sstas } 5009233294Sstas if (quote_around) 5010233294Sstas length += backslashes + 1; 5011233294Sstas 5012233294Sstas quoted_string = XMALLOC (char, length + 1); 5013233294Sstas 5014233294Sstas p = quoted_string; 5015233294Sstas backslashes = 0; 5016233294Sstas if (quote_around) 5017233294Sstas *p++ = '"'; 5018233294Sstas for (s = string; *s != '\0'; s++) 5019233294Sstas { 5020233294Sstas char c = *s; 5021233294Sstas if (c == '"') 5022233294Sstas { 5023233294Sstas unsigned int j; 5024233294Sstas for (j = backslashes + 1; j > 0; j--) 5025233294Sstas *p++ = '\\'; 5026233294Sstas } 5027233294Sstas *p++ = c; 5028233294Sstas if (c == '\\') 5029233294Sstas backslashes++; 5030233294Sstas else 5031233294Sstas backslashes = 0; 5032233294Sstas } 5033233294Sstas if (quote_around) 5034233294Sstas { 5035233294Sstas unsigned int j; 5036233294Sstas for (j = backslashes; j > 0; j--) 5037233294Sstas *p++ = '\\'; 5038233294Sstas *p++ = '"'; 5039233294Sstas } 5040233294Sstas *p = '\0'; 5041233294Sstas 5042233294Sstas new_argv[i] = quoted_string; 5043233294Sstas } 5044233294Sstas else 5045233294Sstas new_argv[i] = (char *) string; 5046233294Sstas } 5047233294Sstas new_argv[argc] = NULL; 5048233294Sstas 5049233294Sstas return new_argv; 5050233294Sstas} 5051233294SstasEOF 5052233294Sstas ;; 5053233294Sstas esac 5054233294Sstas 5055233294Sstas cat <<"EOF" 5056233294Sstasvoid lt_dump_script (FILE* f) 5057233294Sstas{ 5058233294SstasEOF 5059233294Sstas func_emit_wrapper yes | 5060233294Sstas $SED -e 's/\([\\"]\)/\\\1/g' \ 5061233294Sstas -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' 5062233294Sstas 5063233294Sstas cat <<"EOF" 5064233294Sstas} 5065233294SstasEOF 5066233294Sstas} 5067233294Sstas# end: func_emit_cwrapperexe_src 5068233294Sstas 5069233294Sstas# func_win32_import_lib_p ARG 5070233294Sstas# True if ARG is an import lib, as indicated by $file_magic_cmd 5071233294Sstasfunc_win32_import_lib_p () 5072233294Sstas{ 5073233294Sstas $opt_debug 5074233294Sstas case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 5075233294Sstas *import*) : ;; 5076233294Sstas *) false ;; 5077233294Sstas esac 5078233294Sstas} 5079233294Sstas 5080233294Sstas# func_mode_link arg... 5081233294Sstasfunc_mode_link () 5082233294Sstas{ 5083233294Sstas $opt_debug 508490926Snectar case $host in 5085233294Sstas *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 508672445Sassar # It is impossible to link a dll without this setting, and 508772445Sassar # we shouldn't force the makefile maintainer to figure out 508872445Sassar # which system we are compiling for in order to pass an extra 5089127808Snectar # flag for every libtool invocation. 509072445Sassar # allow_undefined=no 509155682Smarkm 509272445Sassar # FIXME: Unfortunately, there are problems with the above when trying 509372445Sassar # to make a dll which has undefined symbols, in which case not 509472445Sassar # even a static library is built. For now, we need to specify 509572445Sassar # -no-undefined on the libtool link line when we can be certain 509672445Sassar # that all symbols are satisfied, otherwise we get a static library. 509772445Sassar allow_undefined=yes 509872445Sassar ;; 509972445Sassar *) 510072445Sassar allow_undefined=yes 510172445Sassar ;; 510272445Sassar esac 5103233294Sstas libtool_args=$nonopt 5104127808Snectar base_compile="$nonopt $@" 5105233294Sstas compile_command=$nonopt 5106233294Sstas finalize_command=$nonopt 510772445Sassar 510872445Sassar compile_rpath= 510972445Sassar finalize_rpath= 511055682Smarkm compile_shlibpath= 511155682Smarkm finalize_shlibpath= 511255682Smarkm convenience= 511355682Smarkm old_convenience= 511455682Smarkm deplibs= 511572445Sassar old_deplibs= 511672445Sassar compiler_flags= 511772445Sassar linker_flags= 511872445Sassar dllsearchpath= 511972445Sassar lib_search_path=`pwd` 5120127808Snectar inst_prefix_dir= 5121233294Sstas new_inherited_linker_flags= 512272445Sassar 512372445Sassar avoid_version=no 5124233294Sstas bindir= 512555682Smarkm dlfiles= 512655682Smarkm dlprefiles= 512772445Sassar dlself=no 512855682Smarkm export_dynamic=no 512955682Smarkm export_symbols= 513072445Sassar export_symbols_regex= 513155682Smarkm generated= 513255682Smarkm libobjs= 513355682Smarkm ltlibs= 513455682Smarkm module=no 513572445Sassar no_install=no 513655682Smarkm objs= 5137127808Snectar non_pic_objects= 5138127808Snectar precious_files_regex= 513972445Sassar prefer_static_libs=no 514072445Sassar preload=no 514155682Smarkm prev= 514255682Smarkm prevarg= 514355682Smarkm release= 514455682Smarkm rpath= 514572445Sassar xrpath= 514655682Smarkm perm_rpath= 514755682Smarkm temp_rpath= 514872445Sassar thread_safe=no 514955682Smarkm vinfo= 5150127808Snectar vinfo_number=no 5151233294Sstas weak_libs= 5152233294Sstas single_module="${wl}-single_module" 5153178825Sdfr func_infer_tag $base_compile 5154127808Snectar 515555682Smarkm # We need to know -static, to get the right output filenames. 515655682Smarkm for arg 515755682Smarkm do 515890926Snectar case $arg in 5159233294Sstas -shared) 5160233294Sstas test "$build_libtool_libs" != yes && \ 5161233294Sstas func_fatal_configuration "can not build a shared library" 5162233294Sstas build_old_libs=no 5163233294Sstas break 5164233294Sstas ;; 5165233294Sstas -all-static | -static | -static-libtool-libs) 5166233294Sstas case $arg in 5167233294Sstas -all-static) 516872445Sassar if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 5169233294Sstas func_warning "complete static linking is impossible in this configuration" 517072445Sassar fi 517172445Sassar if test -n "$link_static_flag"; then 517272445Sassar dlopen_self=$dlopen_self_static 517372445Sassar fi 5174178825Sdfr prefer_static_libs=yes 5175233294Sstas ;; 5176233294Sstas -static) 517772445Sassar if test -z "$pic_flag" && test -n "$link_static_flag"; then 517872445Sassar dlopen_self=$dlopen_self_static 517972445Sassar fi 5180178825Sdfr prefer_static_libs=built 5181233294Sstas ;; 5182233294Sstas -static-libtool-libs) 5183233294Sstas if test -z "$pic_flag" && test -n "$link_static_flag"; then 5184233294Sstas dlopen_self=$dlopen_self_static 5185233294Sstas fi 5186233294Sstas prefer_static_libs=yes 5187233294Sstas ;; 5188233294Sstas esac 518972445Sassar build_libtool_libs=no 519055682Smarkm build_old_libs=yes 519172445Sassar break 519272445Sassar ;; 519355682Smarkm esac 519455682Smarkm done 519555682Smarkm 519655682Smarkm # See if our shared archives depend on static archives. 519755682Smarkm test -n "$old_archive_from_new_cmds" && build_old_libs=yes 519855682Smarkm 519955682Smarkm # Go through the arguments, transforming them on the way. 5200127808Snectar while test "$#" -gt 0; do 520155682Smarkm arg="$1" 520255682Smarkm shift 5203233294Sstas func_quote_for_eval "$arg" 5204233294Sstas qarg=$func_quote_for_eval_unquoted_result 5205233294Sstas func_append libtool_args " $func_quote_for_eval_result" 520655682Smarkm 520755682Smarkm # If the previous option needs an argument, assign it. 520855682Smarkm if test -n "$prev"; then 520990926Snectar case $prev in 521072445Sassar output) 5211233294Sstas func_append compile_command " @OUTPUT@" 5212233294Sstas func_append finalize_command " @OUTPUT@" 521372445Sassar ;; 521472445Sassar esac 521555682Smarkm 521690926Snectar case $prev in 5217233294Sstas bindir) 5218233294Sstas bindir="$arg" 5219233294Sstas prev= 5220233294Sstas continue 5221233294Sstas ;; 522272445Sassar dlfiles|dlprefiles) 522372445Sassar if test "$preload" = no; then 522472445Sassar # Add the symbol object into the linking commands. 5225233294Sstas func_append compile_command " @SYMFILE@" 5226233294Sstas func_append finalize_command " @SYMFILE@" 522772445Sassar preload=yes 522872445Sassar fi 522990926Snectar case $arg in 523072445Sassar *.la | *.lo) ;; # We handle these cases below. 523172445Sassar force) 523272445Sassar if test "$dlself" = no; then 523372445Sassar dlself=needless 523472445Sassar export_dynamic=yes 523572445Sassar fi 523672445Sassar prev= 523772445Sassar continue 523872445Sassar ;; 523972445Sassar self) 524072445Sassar if test "$prev" = dlprefiles; then 524172445Sassar dlself=yes 524272445Sassar elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 524372445Sassar dlself=yes 524472445Sassar else 524572445Sassar dlself=needless 524672445Sassar export_dynamic=yes 524772445Sassar fi 524872445Sassar prev= 524972445Sassar continue 525072445Sassar ;; 525172445Sassar *) 525272445Sassar if test "$prev" = dlfiles; then 5253233294Sstas func_append dlfiles " $arg" 525472445Sassar else 5255233294Sstas func_append dlprefiles " $arg" 525672445Sassar fi 525772445Sassar prev= 525872445Sassar continue 525972445Sassar ;; 526072445Sassar esac 526172445Sassar ;; 526272445Sassar expsyms) 526355682Smarkm export_symbols="$arg" 5264233294Sstas test -f "$arg" \ 5265233294Sstas || func_fatal_error "symbol file \`$arg' does not exist" 526655682Smarkm prev= 526772445Sassar continue 526855682Smarkm ;; 526972445Sassar expsyms_regex) 527072445Sassar export_symbols_regex="$arg" 527172445Sassar prev= 527272445Sassar continue 527372445Sassar ;; 5274233294Sstas framework) 5275233294Sstas case $host in 5276233294Sstas *-*-darwin*) 5277233294Sstas case "$deplibs " in 5278233294Sstas *" $qarg.ltframework "*) ;; 5279233294Sstas *) func_append deplibs " $qarg.ltframework" # this is fixed later 5280233294Sstas ;; 5281233294Sstas esac 5282233294Sstas ;; 5283233294Sstas esac 5284127808Snectar prev= 5285127808Snectar continue 5286127808Snectar ;; 5287233294Sstas inst_prefix) 5288233294Sstas inst_prefix_dir="$arg" 5289127808Snectar prev= 5290127808Snectar continue 5291127808Snectar ;; 5292127808Snectar objectlist) 5293127808Snectar if test -f "$arg"; then 5294127808Snectar save_arg=$arg 5295127808Snectar moreargs= 5296233294Sstas for fil in `cat "$save_arg"` 5297127808Snectar do 5298233294Sstas# func_append moreargs " $fil" 5299127808Snectar arg=$fil 5300127808Snectar # A libtool-controlled object. 5301127808Snectar 5302127808Snectar # Check to see that this really is a libtool object. 5303233294Sstas if func_lalib_unsafe_p "$arg"; then 5304127808Snectar pic_object= 5305127808Snectar non_pic_object= 5306127808Snectar 5307127808Snectar # Read the .lo file 5308233294Sstas func_source "$arg" 5309127808Snectar 5310233294Sstas if test -z "$pic_object" || 5311127808Snectar test -z "$non_pic_object" || 5312233294Sstas test "$pic_object" = none && 5313127808Snectar test "$non_pic_object" = none; then 5314233294Sstas func_fatal_error "cannot find name of object for \`$arg'" 5315127808Snectar fi 5316127808Snectar 5317127808Snectar # Extract subdirectory from the argument. 5318233294Sstas func_dirname "$arg" "/" "" 5319233294Sstas xdir="$func_dirname_result" 5320127808Snectar 5321127808Snectar if test "$pic_object" != none; then 5322127808Snectar # Prepend the subdirectory the object is found in. 5323127808Snectar pic_object="$xdir$pic_object" 5324127808Snectar 5325127808Snectar if test "$prev" = dlfiles; then 5326127808Snectar if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5327233294Sstas func_append dlfiles " $pic_object" 5328127808Snectar prev= 5329127808Snectar continue 5330127808Snectar else 5331127808Snectar # If libtool objects are unsupported, then we need to preload. 5332127808Snectar prev=dlprefiles 5333127808Snectar fi 5334127808Snectar fi 5335127808Snectar 5336127808Snectar # CHECK ME: I think I busted this. -Ossama 5337127808Snectar if test "$prev" = dlprefiles; then 5338127808Snectar # Preload the old-style object. 5339233294Sstas func_append dlprefiles " $pic_object" 5340127808Snectar prev= 5341127808Snectar fi 5342127808Snectar 5343127808Snectar # A PIC object. 5344233294Sstas func_append libobjs " $pic_object" 5345127808Snectar arg="$pic_object" 5346127808Snectar fi 5347127808Snectar 5348127808Snectar # Non-PIC object. 5349127808Snectar if test "$non_pic_object" != none; then 5350127808Snectar # Prepend the subdirectory the object is found in. 5351127808Snectar non_pic_object="$xdir$non_pic_object" 5352127808Snectar 5353127808Snectar # A standard non-PIC object 5354233294Sstas func_append non_pic_objects " $non_pic_object" 5355127808Snectar if test -z "$pic_object" || test "$pic_object" = none ; then 5356127808Snectar arg="$non_pic_object" 5357127808Snectar fi 5358178825Sdfr else 5359178825Sdfr # If the PIC object exists, use it instead. 5360178825Sdfr # $xdir was prepended to $pic_object above. 5361178825Sdfr non_pic_object="$pic_object" 5362233294Sstas func_append non_pic_objects " $non_pic_object" 5363127808Snectar fi 5364127808Snectar else 5365127808Snectar # Only an error if not doing a dry-run. 5366233294Sstas if $opt_dry_run; then 5367127808Snectar # Extract subdirectory from the argument. 5368233294Sstas func_dirname "$arg" "/" "" 5369233294Sstas xdir="$func_dirname_result" 5370127808Snectar 5371233294Sstas func_lo2o "$arg" 5372233294Sstas pic_object=$xdir$objdir/$func_lo2o_result 5373233294Sstas non_pic_object=$xdir$func_lo2o_result 5374233294Sstas func_append libobjs " $pic_object" 5375233294Sstas func_append non_pic_objects " $non_pic_object" 5376233294Sstas else 5377233294Sstas func_fatal_error "\`$arg' is not a valid libtool object" 5378127808Snectar fi 5379127808Snectar fi 5380127808Snectar done 5381127808Snectar else 5382233294Sstas func_fatal_error "link input file \`$arg' does not exist" 5383127808Snectar fi 5384127808Snectar arg=$save_arg 5385127808Snectar prev= 5386127808Snectar continue 5387127808Snectar ;; 5388233294Sstas precious_regex) 5389233294Sstas precious_files_regex="$arg" 5390233294Sstas prev= 5391233294Sstas continue 5392233294Sstas ;; 5393233294Sstas release) 5394233294Sstas release="-$arg" 5395233294Sstas prev= 5396233294Sstas continue 5397233294Sstas ;; 539872445Sassar rpath | xrpath) 539972445Sassar # We need an absolute path. 540090926Snectar case $arg in 540172445Sassar [\\/]* | [A-Za-z]:[\\/]*) ;; 540272445Sassar *) 5403233294Sstas func_fatal_error "only absolute run-paths are allowed" 540472445Sassar ;; 540572445Sassar esac 540672445Sassar if test "$prev" = rpath; then 540772445Sassar case "$rpath " in 540872445Sassar *" $arg "*) ;; 5409233294Sstas *) func_append rpath " $arg" ;; 541072445Sassar esac 541172445Sassar else 541272445Sassar case "$xrpath " in 541372445Sassar *" $arg "*) ;; 5414233294Sstas *) func_append xrpath " $arg" ;; 541572445Sassar esac 541672445Sassar fi 541755682Smarkm prev= 541855682Smarkm continue 541955682Smarkm ;; 5420233294Sstas shrext) 5421233294Sstas shrext_cmds="$arg" 542272445Sassar prev= 542372445Sassar continue 542472445Sassar ;; 5425233294Sstas weak) 5426233294Sstas func_append weak_libs " $arg" 542772445Sassar prev= 542872445Sassar continue 542972445Sassar ;; 5430127808Snectar xcclinker) 5431233294Sstas func_append linker_flags " $qarg" 5432233294Sstas func_append compiler_flags " $qarg" 5433127808Snectar prev= 5434233294Sstas func_append compile_command " $qarg" 5435233294Sstas func_append finalize_command " $qarg" 5436127808Snectar continue 5437127808Snectar ;; 5438233294Sstas xcompiler) 5439233294Sstas func_append compiler_flags " $qarg" 5440178825Sdfr prev= 5441233294Sstas func_append compile_command " $qarg" 5442233294Sstas func_append finalize_command " $qarg" 5443178825Sdfr continue 5444178825Sdfr ;; 5445233294Sstas xlinker) 5446233294Sstas func_append linker_flags " $qarg" 5447233294Sstas func_append compiler_flags " $wl$qarg" 5448178825Sdfr prev= 5449233294Sstas func_append compile_command " $wl$qarg" 5450233294Sstas func_append finalize_command " $wl$qarg" 5451178825Sdfr continue 5452178825Sdfr ;; 545372445Sassar *) 545472445Sassar eval "$prev=\"\$arg\"" 545572445Sassar prev= 545672445Sassar continue 545772445Sassar ;; 545872445Sassar esac 5459127808Snectar fi # test -n "$prev" 546055682Smarkm 546155682Smarkm prevarg="$arg" 546255682Smarkm 546390926Snectar case $arg in 546455682Smarkm -all-static) 546555682Smarkm if test -n "$link_static_flag"; then 5466233294Sstas # See comment for -static flag below, for more details. 5467233294Sstas func_append compile_command " $link_static_flag" 5468233294Sstas func_append finalize_command " $link_static_flag" 546972445Sassar fi 547072445Sassar continue 547155682Smarkm ;; 547255682Smarkm 547355682Smarkm -allow-undefined) 547455682Smarkm # FIXME: remove this flag sometime in the future. 5475233294Sstas func_fatal_error "\`-allow-undefined' must not be used because it is the default" 547655682Smarkm ;; 547755682Smarkm 547872445Sassar -avoid-version) 547972445Sassar avoid_version=yes 548072445Sassar continue 548172445Sassar ;; 548272445Sassar 5483233294Sstas -bindir) 5484233294Sstas prev=bindir 5485233294Sstas continue 5486233294Sstas ;; 5487233294Sstas 548855682Smarkm -dlopen) 548972445Sassar prev=dlfiles 549072445Sassar continue 549172445Sassar ;; 549255682Smarkm 549355682Smarkm -dlpreopen) 549472445Sassar prev=dlprefiles 549572445Sassar continue 549672445Sassar ;; 549755682Smarkm 549855682Smarkm -export-dynamic) 549972445Sassar export_dynamic=yes 550072445Sassar continue 550172445Sassar ;; 550272445Sassar 550372445Sassar -export-symbols | -export-symbols-regex) 550472445Sassar if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 5505233294Sstas func_fatal_error "more than one -exported-symbols argument is not allowed" 550672445Sassar fi 550772445Sassar if test "X$arg" = "X-export-symbols"; then 550872445Sassar prev=expsyms 550972445Sassar else 551072445Sassar prev=expsyms_regex 551172445Sassar fi 551272445Sassar continue 551372445Sassar ;; 551472445Sassar 5515233294Sstas -framework) 5516233294Sstas prev=framework 5517178825Sdfr continue 5518178825Sdfr ;; 5519178825Sdfr 5520127808Snectar -inst-prefix-dir) 5521127808Snectar prev=inst_prefix 5522127808Snectar continue 5523127808Snectar ;; 5524127808Snectar 552590926Snectar # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 552690926Snectar # so, if we see these flags be careful not to treat them like -L 552790926Snectar -L[A-Z][A-Z]*:*) 552890926Snectar case $with_gcc/$host in 5529127808Snectar no/*-*-irix* | /*-*-irix*) 5530233294Sstas func_append compile_command " $arg" 5531233294Sstas func_append finalize_command " $arg" 553290926Snectar ;; 553390926Snectar esac 553490926Snectar continue 553590926Snectar ;; 553690926Snectar 553772445Sassar -L*) 5538233294Sstas func_stripname "-L" '' "$arg" 5539233294Sstas if test -z "$func_stripname_result"; then 5540233294Sstas if test "$#" -gt 0; then 5541233294Sstas func_fatal_error "require no space between \`-L' and \`$1'" 5542233294Sstas else 5543233294Sstas func_fatal_error "need path for \`-L' option" 5544233294Sstas fi 5545233294Sstas fi 5546233294Sstas func_resolve_sysroot "$func_stripname_result" 5547233294Sstas dir=$func_resolve_sysroot_result 554872445Sassar # We need an absolute path. 554990926Snectar case $dir in 555072445Sassar [\\/]* | [A-Za-z]:[\\/]*) ;; 555172445Sassar *) 555272445Sassar absdir=`cd "$dir" && pwd` 5553233294Sstas test -z "$absdir" && \ 5554233294Sstas func_fatal_error "cannot determine absolute directory name of \`$dir'" 555572445Sassar dir="$absdir" 555672445Sassar ;; 555772445Sassar esac 555872445Sassar case "$deplibs " in 5559233294Sstas *" -L$dir "* | *" $arg "*) 5560233294Sstas # Will only happen for absolute or sysroot arguments 5561233294Sstas ;; 556272445Sassar *) 5563233294Sstas # Preserve sysroot, but never include relative directories 5564233294Sstas case $dir in 5565233294Sstas [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 5566233294Sstas *) func_append deplibs " -L$dir" ;; 5567233294Sstas esac 5568233294Sstas func_append lib_search_path " $dir" 556972445Sassar ;; 557072445Sassar esac 557190926Snectar case $host in 5572233294Sstas *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5573233294Sstas testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 557490926Snectar case :$dllsearchpath: in 557572445Sassar *":$dir:"*) ;; 5576233294Sstas ::) dllsearchpath=$dir;; 5577233294Sstas *) func_append dllsearchpath ":$dir";; 557872445Sassar esac 5579178825Sdfr case :$dllsearchpath: in 5580178825Sdfr *":$testbindir:"*) ;; 5581233294Sstas ::) dllsearchpath=$testbindir;; 5582233294Sstas *) func_append dllsearchpath ":$testbindir";; 5583178825Sdfr esac 558472445Sassar ;; 558572445Sassar esac 558672445Sassar continue 558772445Sassar ;; 558855682Smarkm 558972445Sassar -l*) 559090926Snectar if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 559190926Snectar case $host in 5592233294Sstas *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 559390926Snectar # These systems don't actually have a C or math library (as such) 559472445Sassar continue 559572445Sassar ;; 5596178825Sdfr *-*-os2*) 559790926Snectar # These systems don't actually have a C library (as such) 559890926Snectar test "X$arg" = "X-lc" && continue 559972445Sassar ;; 5600178825Sdfr *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5601102644Snectar # Do not include libc due to us having libc/libc_r. 5602102644Snectar test "X$arg" = "X-lc" && continue 5603102644Snectar ;; 5604127808Snectar *-*-rhapsody* | *-*-darwin1.[012]) 5605127808Snectar # Rhapsody C and math libraries are in the System framework 5606233294Sstas func_append deplibs " System.ltframework" 5607102644Snectar continue 5608178825Sdfr ;; 5609178825Sdfr *-*-sco3.2v5* | *-*-sco5v6*) 5610178825Sdfr # Causes problems with __ctype 5611178825Sdfr test "X$arg" = "X-lc" && continue 5612178825Sdfr ;; 5613178825Sdfr *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 5614178825Sdfr # Compiler inserts libc in the correct place for threads to work 5615178825Sdfr test "X$arg" = "X-lc" && continue 5616178825Sdfr ;; 5617102644Snectar esac 5618127808Snectar elif test "X$arg" = "X-lc_r"; then 5619127808Snectar case $host in 5620178825Sdfr *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5621127808Snectar # Do not include libc_r directly, use -pthread flag. 5622127808Snectar continue 5623127808Snectar ;; 5624127808Snectar esac 562572445Sassar fi 5626233294Sstas func_append deplibs " $arg" 562772445Sassar continue 562872445Sassar ;; 562955682Smarkm 5630233294Sstas -module) 5631233294Sstas module=yes 5632233294Sstas continue 5633233294Sstas ;; 5634233294Sstas 5635178825Sdfr # Tru64 UNIX uses -model [arg] to determine the layout of C++ 5636178825Sdfr # classes, name mangling, and exception handling. 5637233294Sstas # Darwin uses the -arch flag to determine output architecture. 5638233294Sstas -model|-arch|-isysroot|--sysroot) 5639233294Sstas func_append compiler_flags " $arg" 5640233294Sstas func_append compile_command " $arg" 5641233294Sstas func_append finalize_command " $arg" 5642178825Sdfr prev=xcompiler 5643178825Sdfr continue 5644178825Sdfr ;; 5645178825Sdfr 5646233294Sstas -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 5647233294Sstas func_append compiler_flags " $arg" 5648233294Sstas func_append compile_command " $arg" 5649233294Sstas func_append finalize_command " $arg" 5650233294Sstas case "$new_inherited_linker_flags " in 5651233294Sstas *" $arg "*) ;; 5652233294Sstas * ) func_append new_inherited_linker_flags " $arg" ;; 5653233294Sstas esac 5654127808Snectar continue 5655127808Snectar ;; 5656127808Snectar 5657233294Sstas -multi_module) 5658233294Sstas single_module="${wl}-multi_module" 565955682Smarkm continue 566072445Sassar ;; 566155682Smarkm 566272445Sassar -no-fast-install) 566372445Sassar fast_install=no 566472445Sassar continue 566572445Sassar ;; 566655682Smarkm 566772445Sassar -no-install) 566890926Snectar case $host in 5669233294Sstas *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 567072445Sassar # The PATH hackery in wrapper scripts is required on Windows 5671233294Sstas # and Darwin in order for the loader to find any dlls it needs. 5672233294Sstas func_warning "\`-no-install' is ignored for $host" 5673233294Sstas func_warning "assuming \`-no-fast-install' instead" 567472445Sassar fast_install=no 567572445Sassar ;; 567690926Snectar *) no_install=yes ;; 567772445Sassar esac 567872445Sassar continue 567972445Sassar ;; 568055682Smarkm 568155682Smarkm -no-undefined) 568255682Smarkm allow_undefined=no 568355682Smarkm continue 568455682Smarkm ;; 568555682Smarkm 5686127808Snectar -objectlist) 5687127808Snectar prev=objectlist 5688127808Snectar continue 5689127808Snectar ;; 5690127808Snectar 569155682Smarkm -o) prev=output ;; 569255682Smarkm 5693127808Snectar -precious-files-regex) 5694127808Snectar prev=precious_regex 5695127808Snectar continue 5696127808Snectar ;; 5697127808Snectar 569855682Smarkm -release) 569955682Smarkm prev=release 570055682Smarkm continue 570155682Smarkm ;; 570255682Smarkm 570355682Smarkm -rpath) 570472445Sassar prev=rpath 570572445Sassar continue 570672445Sassar ;; 570755682Smarkm 570872445Sassar -R) 570972445Sassar prev=xrpath 571072445Sassar continue 571172445Sassar ;; 571272445Sassar 571372445Sassar -R*) 5714233294Sstas func_stripname '-R' '' "$arg" 5715233294Sstas dir=$func_stripname_result 571672445Sassar # We need an absolute path. 571790926Snectar case $dir in 571872445Sassar [\\/]* | [A-Za-z]:[\\/]*) ;; 5719233294Sstas =*) 5720233294Sstas func_stripname '=' '' "$dir" 5721233294Sstas dir=$lt_sysroot$func_stripname_result 5722233294Sstas ;; 572372445Sassar *) 5724233294Sstas func_fatal_error "only absolute run-paths are allowed" 572572445Sassar ;; 572672445Sassar esac 572772445Sassar case "$xrpath " in 572872445Sassar *" $dir "*) ;; 5729233294Sstas *) func_append xrpath " $dir" ;; 573072445Sassar esac 573172445Sassar continue 573272445Sassar ;; 573372445Sassar 5734233294Sstas -shared) 5735233294Sstas # The effects of -shared are defined in a previous loop. 5736233294Sstas continue 5737233294Sstas ;; 5738233294Sstas 5739233294Sstas -shrext) 5740233294Sstas prev=shrext 5741233294Sstas continue 5742233294Sstas ;; 5743233294Sstas 5744233294Sstas -static | -static-libtool-libs) 574590926Snectar # The effects of -static are defined in a previous loop. 574690926Snectar # We used to do the same as -all-static on platforms that 574790926Snectar # didn't have a PIC flag, but the assumption that the effects 574890926Snectar # would be equivalent was wrong. It would break on at least 574990926Snectar # Digital Unix and AIX. 575055682Smarkm continue 575155682Smarkm ;; 575255682Smarkm 575372445Sassar -thread-safe) 575472445Sassar thread_safe=yes 575572445Sassar continue 575672445Sassar ;; 575772445Sassar 575855682Smarkm -version-info) 575972445Sassar prev=vinfo 576072445Sassar continue 576172445Sassar ;; 5762233294Sstas 5763127808Snectar -version-number) 5764127808Snectar prev=vinfo 5765127808Snectar vinfo_number=yes 5766127808Snectar continue 5767127808Snectar ;; 576855682Smarkm 5769233294Sstas -weak) 5770233294Sstas prev=weak 5771233294Sstas continue 5772233294Sstas ;; 5773233294Sstas 577472445Sassar -Wc,*) 5775233294Sstas func_stripname '-Wc,' '' "$arg" 5776233294Sstas args=$func_stripname_result 577772445Sassar arg= 5778102644Snectar save_ifs="$IFS"; IFS=',' 577972445Sassar for flag in $args; do 578072445Sassar IFS="$save_ifs" 5781233294Sstas func_quote_for_eval "$flag" 5782233294Sstas func_append arg " $func_quote_for_eval_result" 5783233294Sstas func_append compiler_flags " $func_quote_for_eval_result" 578472445Sassar done 578572445Sassar IFS="$save_ifs" 5786233294Sstas func_stripname ' ' '' "$arg" 5787233294Sstas arg=$func_stripname_result 578872445Sassar ;; 578972445Sassar 579072445Sassar -Wl,*) 5791233294Sstas func_stripname '-Wl,' '' "$arg" 5792233294Sstas args=$func_stripname_result 579372445Sassar arg= 5794102644Snectar save_ifs="$IFS"; IFS=',' 579572445Sassar for flag in $args; do 579672445Sassar IFS="$save_ifs" 5797233294Sstas func_quote_for_eval "$flag" 5798233294Sstas func_append arg " $wl$func_quote_for_eval_result" 5799233294Sstas func_append compiler_flags " $wl$func_quote_for_eval_result" 5800233294Sstas func_append linker_flags " $func_quote_for_eval_result" 580172445Sassar done 580272445Sassar IFS="$save_ifs" 5803233294Sstas func_stripname ' ' '' "$arg" 5804233294Sstas arg=$func_stripname_result 580572445Sassar ;; 580672445Sassar 580772445Sassar -Xcompiler) 580872445Sassar prev=xcompiler 580972445Sassar continue 581072445Sassar ;; 581172445Sassar 581272445Sassar -Xlinker) 581372445Sassar prev=xlinker 581472445Sassar continue 581572445Sassar ;; 581672445Sassar 5817127808Snectar -XCClinker) 5818127808Snectar prev=xcclinker 5819127808Snectar continue 5820127808Snectar ;; 5821127808Snectar 5822233294Sstas # -msg_* for osf cc 5823233294Sstas -msg_*) 5824233294Sstas func_quote_for_eval "$arg" 5825233294Sstas arg="$func_quote_for_eval_result" 5826233294Sstas ;; 5827233294Sstas 5828233294Sstas # Flags to be passed through unchanged, with rationale: 5829233294Sstas # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 5830233294Sstas # -r[0-9][0-9]* specify processor for the SGI compiler 5831233294Sstas # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 5832233294Sstas # +DA*, +DD* enable 64-bit mode for the HP compiler 5833233294Sstas # -q* compiler args for the IBM compiler 5834233294Sstas # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 5835233294Sstas # -F/path path to uninstalled frameworks, gcc on darwin 5836233294Sstas # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 5837233294Sstas # @file GCC response files 5838233294Sstas # -tp=* Portland pgcc target processor selection 5839233294Sstas # --sysroot=* for sysroot support 5840233294Sstas # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 5841233294Sstas -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 5842233294Sstas -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 5843233294Sstas -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 5844233294Sstas func_quote_for_eval "$arg" 5845233294Sstas arg="$func_quote_for_eval_result" 5846233294Sstas func_append compile_command " $arg" 5847233294Sstas func_append finalize_command " $arg" 5848233294Sstas func_append compiler_flags " $arg" 5849233294Sstas continue 5850233294Sstas ;; 5851233294Sstas 585255682Smarkm # Some other compiler flag. 585355682Smarkm -* | +*) 5854233294Sstas func_quote_for_eval "$arg" 5855233294Sstas arg="$func_quote_for_eval_result" 585672445Sassar ;; 585755682Smarkm 5858127808Snectar *.$objext) 5859127808Snectar # A standard object. 5860233294Sstas func_append objs " $arg" 5861127808Snectar ;; 5862127808Snectar 5863127808Snectar *.lo) 5864127808Snectar # A libtool-controlled object. 5865127808Snectar 5866127808Snectar # Check to see that this really is a libtool object. 5867233294Sstas if func_lalib_unsafe_p "$arg"; then 5868127808Snectar pic_object= 5869127808Snectar non_pic_object= 5870127808Snectar 5871127808Snectar # Read the .lo file 5872233294Sstas func_source "$arg" 5873127808Snectar 5874233294Sstas if test -z "$pic_object" || 5875127808Snectar test -z "$non_pic_object" || 5876233294Sstas test "$pic_object" = none && 5877127808Snectar test "$non_pic_object" = none; then 5878233294Sstas func_fatal_error "cannot find name of object for \`$arg'" 587955682Smarkm fi 588055682Smarkm 5881127808Snectar # Extract subdirectory from the argument. 5882233294Sstas func_dirname "$arg" "/" "" 5883233294Sstas xdir="$func_dirname_result" 5884127808Snectar 5885127808Snectar if test "$pic_object" != none; then 5886127808Snectar # Prepend the subdirectory the object is found in. 5887127808Snectar pic_object="$xdir$pic_object" 5888127808Snectar 5889127808Snectar if test "$prev" = dlfiles; then 5890127808Snectar if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5891233294Sstas func_append dlfiles " $pic_object" 5892127808Snectar prev= 5893127808Snectar continue 5894127808Snectar else 5895127808Snectar # If libtool objects are unsupported, then we need to preload. 5896127808Snectar prev=dlprefiles 5897127808Snectar fi 5898127808Snectar fi 5899127808Snectar 5900127808Snectar # CHECK ME: I think I busted this. -Ossama 5901127808Snectar if test "$prev" = dlprefiles; then 5902127808Snectar # Preload the old-style object. 5903233294Sstas func_append dlprefiles " $pic_object" 5904127808Snectar prev= 5905127808Snectar fi 5906127808Snectar 5907127808Snectar # A PIC object. 5908233294Sstas func_append libobjs " $pic_object" 5909127808Snectar arg="$pic_object" 5910127808Snectar fi 5911127808Snectar 5912127808Snectar # Non-PIC object. 5913127808Snectar if test "$non_pic_object" != none; then 5914127808Snectar # Prepend the subdirectory the object is found in. 5915127808Snectar non_pic_object="$xdir$non_pic_object" 5916127808Snectar 5917127808Snectar # A standard non-PIC object 5918233294Sstas func_append non_pic_objects " $non_pic_object" 5919127808Snectar if test -z "$pic_object" || test "$pic_object" = none ; then 5920127808Snectar arg="$non_pic_object" 5921127808Snectar fi 5922178825Sdfr else 5923178825Sdfr # If the PIC object exists, use it instead. 5924178825Sdfr # $xdir was prepended to $pic_object above. 5925178825Sdfr non_pic_object="$pic_object" 5926233294Sstas func_append non_pic_objects " $non_pic_object" 5927127808Snectar fi 592872445Sassar else 5929127808Snectar # Only an error if not doing a dry-run. 5930233294Sstas if $opt_dry_run; then 5931127808Snectar # Extract subdirectory from the argument. 5932233294Sstas func_dirname "$arg" "/" "" 5933233294Sstas xdir="$func_dirname_result" 5934127808Snectar 5935233294Sstas func_lo2o "$arg" 5936233294Sstas pic_object=$xdir$objdir/$func_lo2o_result 5937233294Sstas non_pic_object=$xdir$func_lo2o_result 5938233294Sstas func_append libobjs " $pic_object" 5939233294Sstas func_append non_pic_objects " $non_pic_object" 5940233294Sstas else 5941233294Sstas func_fatal_error "\`$arg' is not a valid libtool object" 5942127808Snectar fi 594355682Smarkm fi 594472445Sassar ;; 594555682Smarkm 594672445Sassar *.$libext) 594772445Sassar # An archive. 5948233294Sstas func_append deplibs " $arg" 5949233294Sstas func_append old_deplibs " $arg" 595072445Sassar continue 595172445Sassar ;; 595272445Sassar 595355682Smarkm *.la) 595472445Sassar # A libtool-controlled library. 595555682Smarkm 5956233294Sstas func_resolve_sysroot "$arg" 595772445Sassar if test "$prev" = dlfiles; then 595872445Sassar # This library was specified with -dlopen. 5959233294Sstas func_append dlfiles " $func_resolve_sysroot_result" 596072445Sassar prev= 596172445Sassar elif test "$prev" = dlprefiles; then 596272445Sassar # The library was specified with -dlpreopen. 5963233294Sstas func_append dlprefiles " $func_resolve_sysroot_result" 596472445Sassar prev= 596572445Sassar else 5966233294Sstas func_append deplibs " $func_resolve_sysroot_result" 596772445Sassar fi 596872445Sassar continue 596972445Sassar ;; 597055682Smarkm 597172445Sassar # Some other compiler argument. 597272445Sassar *) 597372445Sassar # Unknown arguments in both finalize_command and compile_command need 597472445Sassar # to be aesthetically quoted because they are evaled later. 5975233294Sstas func_quote_for_eval "$arg" 5976233294Sstas arg="$func_quote_for_eval_result" 597772445Sassar ;; 597890926Snectar esac # arg 597955682Smarkm 598072445Sassar # Now actually substitute the argument into the commands. 598172445Sassar if test -n "$arg"; then 5982233294Sstas func_append compile_command " $arg" 5983233294Sstas func_append finalize_command " $arg" 598472445Sassar fi 598590926Snectar done # argument parsing loop 598672445Sassar 5987233294Sstas test -n "$prev" && \ 5988233294Sstas func_fatal_help "the \`$prevarg' option requires an argument" 598972445Sassar 599072445Sassar if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 599172445Sassar eval arg=\"$export_dynamic_flag_spec\" 5992233294Sstas func_append compile_command " $arg" 5993233294Sstas func_append finalize_command " $arg" 599472445Sassar fi 599572445Sassar 5996127808Snectar oldlibs= 599772445Sassar # calculate the name of the file, without its directory 5998233294Sstas func_basename "$output" 5999233294Sstas outputname="$func_basename_result" 600072445Sassar libobjs_save="$libobjs" 600172445Sassar 600272445Sassar if test -n "$shlibpath_var"; then 600372445Sassar # get the directories listed in $shlibpath_var 6004233294Sstas eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 600572445Sassar else 600672445Sassar shlib_search_path= 600772445Sassar fi 600872445Sassar eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 600972445Sassar eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 601072445Sassar 6011233294Sstas func_dirname "$output" "/" "" 6012233294Sstas output_objdir="$func_dirname_result$objdir" 6013233294Sstas func_to_tool_file "$output_objdir/" 6014233294Sstas tool_output_objdir=$func_to_tool_file_result 601572445Sassar # Create the object directory. 6016233294Sstas func_mkdir_p "$output_objdir" 601772445Sassar 601872445Sassar # Determine the type of output 601990926Snectar case $output in 602072445Sassar "") 6021233294Sstas func_fatal_help "you must specify an output file" 602272445Sassar ;; 602372445Sassar *.$libext) linkmode=oldlib ;; 602472445Sassar *.lo | *.$objext) linkmode=obj ;; 602572445Sassar *.la) linkmode=lib ;; 602672445Sassar *) linkmode=prog ;; # Anything else should be a program. 602772445Sassar esac 602872445Sassar 602972445Sassar specialdeplibs= 6030127808Snectar 603172445Sassar libs= 603272445Sassar # Find all interdependent deplibs by searching for libraries 603372445Sassar # that are linked more than once (e.g. -la -lb -la) 603472445Sassar for deplib in $deplibs; do 6035233294Sstas if $opt_preserve_dup_deps ; then 6036127808Snectar case "$libs " in 6037233294Sstas *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6038127808Snectar esac 6039127808Snectar fi 6040233294Sstas func_append libs " $deplib" 604172445Sassar done 6042127808Snectar 6043127808Snectar if test "$linkmode" = lib; then 6044127808Snectar libs="$predeps $libs $compiler_lib_search_path $postdeps" 6045127808Snectar 6046127808Snectar # Compute libraries that are listed more than once in $predeps 6047127808Snectar # $postdeps and mark them as special (i.e., whose duplicates are 6048127808Snectar # not to be eliminated). 6049127808Snectar pre_post_deps= 6050233294Sstas if $opt_duplicate_compiler_generated_deps; then 6051127808Snectar for pre_post_dep in $predeps $postdeps; do 6052127808Snectar case "$pre_post_deps " in 6053233294Sstas *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 6054127808Snectar esac 6055233294Sstas func_append pre_post_deps " $pre_post_dep" 6056127808Snectar done 6057127808Snectar fi 6058127808Snectar pre_post_deps= 6059127808Snectar fi 6060127808Snectar 606172445Sassar deplibs= 606272445Sassar newdependency_libs= 606372445Sassar newlib_search_path= 606472445Sassar need_relink=no # whether we're linking any uninstalled libtool libraries 606590926Snectar notinst_deplibs= # not-installed libtool libraries 6066233294Sstas notinst_path= # paths that contain not-installed libtool libraries 6067233294Sstas 606872445Sassar case $linkmode in 606972445Sassar lib) 6070233294Sstas passes="conv dlpreopen link" 607172445Sassar for file in $dlfiles $dlprefiles; do 607290926Snectar case $file in 607372445Sassar *.la) ;; 607472445Sassar *) 6075233294Sstas func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 607672445Sassar ;; 607772445Sassar esac 607872445Sassar done 607972445Sassar ;; 608072445Sassar prog) 608172445Sassar compile_deplibs= 608272445Sassar finalize_deplibs= 608372445Sassar alldeplibs=no 608472445Sassar newdlfiles= 608572445Sassar newdlprefiles= 608672445Sassar passes="conv scan dlopen dlpreopen link" 608772445Sassar ;; 608890926Snectar *) passes="conv" 608972445Sassar ;; 609072445Sassar esac 6091233294Sstas 609272445Sassar for pass in $passes; do 6093233294Sstas # The preopen pass in lib mode reverses $deplibs; put it back here 6094233294Sstas # so that -L comes before libs that need it for instance... 6095233294Sstas if test "$linkmode,$pass" = "lib,link"; then 6096233294Sstas ## FIXME: Find the place where the list is rebuilt in the wrong 6097233294Sstas ## order, and fix it there properly 6098233294Sstas tmp_deplibs= 6099233294Sstas for deplib in $deplibs; do 6100233294Sstas tmp_deplibs="$deplib $tmp_deplibs" 6101233294Sstas done 6102233294Sstas deplibs="$tmp_deplibs" 6103233294Sstas fi 6104233294Sstas 6105127808Snectar if test "$linkmode,$pass" = "lib,link" || 6106127808Snectar test "$linkmode,$pass" = "prog,scan"; then 6107127808Snectar libs="$deplibs" 6108127808Snectar deplibs= 6109127808Snectar fi 6110127808Snectar if test "$linkmode" = prog; then 611172445Sassar case $pass in 6112127808Snectar dlopen) libs="$dlfiles" ;; 611372445Sassar dlpreopen) libs="$dlprefiles" ;; 611472445Sassar link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 611572445Sassar esac 611672445Sassar fi 6117233294Sstas if test "$linkmode,$pass" = "lib,dlpreopen"; then 6118233294Sstas # Collect and forward deplibs of preopened libtool libs 6119233294Sstas for lib in $dlprefiles; do 6120233294Sstas # Ignore non-libtool-libs 6121233294Sstas dependency_libs= 6122233294Sstas func_resolve_sysroot "$lib" 6123233294Sstas case $lib in 6124233294Sstas *.la) func_source "$func_resolve_sysroot_result" ;; 6125233294Sstas esac 6126233294Sstas 6127233294Sstas # Collect preopened libtool deplibs, except any this library 6128233294Sstas # has declared as weak libs 6129233294Sstas for deplib in $dependency_libs; do 6130233294Sstas func_basename "$deplib" 6131233294Sstas deplib_base=$func_basename_result 6132233294Sstas case " $weak_libs " in 6133233294Sstas *" $deplib_base "*) ;; 6134233294Sstas *) func_append deplibs " $deplib" ;; 6135233294Sstas esac 6136233294Sstas done 6137233294Sstas done 6138233294Sstas libs="$dlprefiles" 6139233294Sstas fi 6140127808Snectar if test "$pass" = dlopen; then 6141127808Snectar # Collect dlpreopened libraries 6142127808Snectar save_deplibs="$deplibs" 6143127808Snectar deplibs= 6144127808Snectar fi 6145233294Sstas 614672445Sassar for deplib in $libs; do 614772445Sassar lib= 614872445Sassar found=no 614990926Snectar case $deplib in 6150233294Sstas -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 6151127808Snectar if test "$linkmode,$pass" = "prog,link"; then 6152127808Snectar compile_deplibs="$deplib $compile_deplibs" 6153127808Snectar finalize_deplibs="$deplib $finalize_deplibs" 6154127808Snectar else 6155233294Sstas func_append compiler_flags " $deplib" 6156233294Sstas if test "$linkmode" = lib ; then 6157233294Sstas case "$new_inherited_linker_flags " in 6158233294Sstas *" $deplib "*) ;; 6159233294Sstas * ) func_append new_inherited_linker_flags " $deplib" ;; 6160233294Sstas esac 6161233294Sstas fi 6162127808Snectar fi 6163127808Snectar continue 6164127808Snectar ;; 616572445Sassar -l*) 6166127808Snectar if test "$linkmode" != lib && test "$linkmode" != prog; then 6167233294Sstas func_warning "\`-l' is ignored for archives/objects" 616872445Sassar continue 616972445Sassar fi 6170233294Sstas func_stripname '-l' '' "$deplib" 6171233294Sstas name=$func_stripname_result 6172233294Sstas if test "$linkmode" = lib; then 6173233294Sstas searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 6174233294Sstas else 6175233294Sstas searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 6176233294Sstas fi 6177233294Sstas for searchdir in $searchdirs; do 6178178825Sdfr for search_ext in .la $std_shrext .so .a; do 6179127808Snectar # Search the libtool library 6180127808Snectar lib="$searchdir/lib${name}${search_ext}" 6181127808Snectar if test -f "$lib"; then 6182127808Snectar if test "$search_ext" = ".la"; then 6183127808Snectar found=yes 6184127808Snectar else 6185127808Snectar found=no 6186127808Snectar fi 6187127808Snectar break 2 6188127808Snectar fi 6189127808Snectar done 619072445Sassar done 619172445Sassar if test "$found" != yes; then 619290926Snectar # deplib doesn't seem to be a libtool library 619372445Sassar if test "$linkmode,$pass" = "prog,link"; then 619472445Sassar compile_deplibs="$deplib $compile_deplibs" 619572445Sassar finalize_deplibs="$deplib $finalize_deplibs" 619672445Sassar else 619772445Sassar deplibs="$deplib $deplibs" 6198127808Snectar test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 619972445Sassar fi 620072445Sassar continue 6201127808Snectar else # deplib is a libtool library 6202127808Snectar # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 6203127808Snectar # We need to do some special things here, and not later. 6204127808Snectar if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6205127808Snectar case " $predeps $postdeps " in 6206127808Snectar *" $deplib "*) 6207233294Sstas if func_lalib_p "$lib"; then 6208127808Snectar library_names= 6209127808Snectar old_library= 6210233294Sstas func_source "$lib" 6211127808Snectar for l in $old_library $library_names; do 6212127808Snectar ll="$l" 6213127808Snectar done 6214127808Snectar if test "X$ll" = "X$old_library" ; then # only static version available 6215127808Snectar found=no 6216233294Sstas func_dirname "$lib" "" "." 6217233294Sstas ladir="$func_dirname_result" 6218127808Snectar lib=$ladir/$old_library 6219127808Snectar if test "$linkmode,$pass" = "prog,link"; then 6220127808Snectar compile_deplibs="$deplib $compile_deplibs" 6221127808Snectar finalize_deplibs="$deplib $finalize_deplibs" 6222127808Snectar else 6223127808Snectar deplibs="$deplib $deplibs" 6224127808Snectar test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6225127808Snectar fi 6226127808Snectar continue 6227127808Snectar fi 6228127808Snectar fi 6229233294Sstas ;; 6230127808Snectar *) ;; 6231127808Snectar esac 6232127808Snectar fi 623372445Sassar fi 623490926Snectar ;; # -l 6235233294Sstas *.ltframework) 6236233294Sstas if test "$linkmode,$pass" = "prog,link"; then 6237233294Sstas compile_deplibs="$deplib $compile_deplibs" 6238233294Sstas finalize_deplibs="$deplib $finalize_deplibs" 6239233294Sstas else 6240233294Sstas deplibs="$deplib $deplibs" 6241233294Sstas if test "$linkmode" = lib ; then 6242233294Sstas case "$new_inherited_linker_flags " in 6243233294Sstas *" $deplib "*) ;; 6244233294Sstas * ) func_append new_inherited_linker_flags " $deplib" ;; 6245233294Sstas esac 6246233294Sstas fi 6247233294Sstas fi 6248233294Sstas continue 6249233294Sstas ;; 625072445Sassar -L*) 625172445Sassar case $linkmode in 625272445Sassar lib) 625372445Sassar deplibs="$deplib $deplibs" 6254127808Snectar test "$pass" = conv && continue 625572445Sassar newdependency_libs="$deplib $newdependency_libs" 6256233294Sstas func_stripname '-L' '' "$deplib" 6257233294Sstas func_resolve_sysroot "$func_stripname_result" 6258233294Sstas func_append newlib_search_path " $func_resolve_sysroot_result" 625972445Sassar ;; 626072445Sassar prog) 6261127808Snectar if test "$pass" = conv; then 626272445Sassar deplibs="$deplib $deplibs" 626372445Sassar continue 626472445Sassar fi 6265127808Snectar if test "$pass" = scan; then 626672445Sassar deplibs="$deplib $deplibs" 626772445Sassar else 626872445Sassar compile_deplibs="$deplib $compile_deplibs" 626972445Sassar finalize_deplibs="$deplib $finalize_deplibs" 627072445Sassar fi 6271233294Sstas func_stripname '-L' '' "$deplib" 6272233294Sstas func_resolve_sysroot "$func_stripname_result" 6273233294Sstas func_append newlib_search_path " $func_resolve_sysroot_result" 627472445Sassar ;; 627572445Sassar *) 6276233294Sstas func_warning "\`-L' is ignored for archives/objects" 627772445Sassar ;; 627890926Snectar esac # linkmode 627972445Sassar continue 628090926Snectar ;; # -L 628172445Sassar -R*) 6282127808Snectar if test "$pass" = link; then 6283233294Sstas func_stripname '-R' '' "$deplib" 6284233294Sstas func_resolve_sysroot "$func_stripname_result" 6285233294Sstas dir=$func_resolve_sysroot_result 628672445Sassar # Make sure the xrpath contains only unique directories. 628772445Sassar case "$xrpath " in 628872445Sassar *" $dir "*) ;; 6289233294Sstas *) func_append xrpath " $dir" ;; 629072445Sassar esac 629172445Sassar fi 629272445Sassar deplibs="$deplib $deplibs" 629372445Sassar continue 629472445Sassar ;; 6295233294Sstas *.la) 6296233294Sstas func_resolve_sysroot "$deplib" 6297233294Sstas lib=$func_resolve_sysroot_result 6298233294Sstas ;; 629972445Sassar *.$libext) 6300127808Snectar if test "$pass" = conv; then 630172445Sassar deplibs="$deplib $deplibs" 630272445Sassar continue 630372445Sassar fi 630472445Sassar case $linkmode in 630572445Sassar lib) 6306233294Sstas # Linking convenience modules into shared libraries is allowed, 6307233294Sstas # but linking other static libraries is non-portable. 6308233294Sstas case " $dlpreconveniencelibs " in 6309233294Sstas *" $deplib "*) ;; 6310233294Sstas *) 6311233294Sstas valid_a_lib=no 6312233294Sstas case $deplibs_check_method in 6313233294Sstas match_pattern*) 6314233294Sstas set dummy $deplibs_check_method; shift 6315233294Sstas match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 6316233294Sstas if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 6317178825Sdfr | $EGREP "$match_pattern_regex" > /dev/null; then 6318233294Sstas valid_a_lib=yes 6319233294Sstas fi 6320233294Sstas ;; 6321233294Sstas pass_all) 6322178825Sdfr valid_a_lib=yes 6323178825Sdfr ;; 6324233294Sstas esac 6325233294Sstas if test "$valid_a_lib" != yes; then 6326233294Sstas echo 6327233294Sstas $ECHO "*** Warning: Trying to link with static lib archive $deplib." 6328233294Sstas echo "*** I have the capability to make that library automatically link in when" 6329233294Sstas echo "*** you link to this library. But I can only do this if you have a" 6330233294Sstas echo "*** shared version of the library, which you do not appear to have" 6331233294Sstas echo "*** because the file extensions .$libext of this argument makes me believe" 6332233294Sstas echo "*** that it is just a static archive that I should not use here." 6333233294Sstas else 6334233294Sstas echo 6335233294Sstas $ECHO "*** Warning: Linking the shared library $output against the" 6336233294Sstas $ECHO "*** static library $deplib is not portable!" 6337233294Sstas deplibs="$deplib $deplibs" 6338233294Sstas fi 6339233294Sstas ;; 6340233294Sstas esac 634172445Sassar continue 634272445Sassar ;; 634372445Sassar prog) 6344127808Snectar if test "$pass" != link; then 634572445Sassar deplibs="$deplib $deplibs" 634672445Sassar else 634772445Sassar compile_deplibs="$deplib $compile_deplibs" 634872445Sassar finalize_deplibs="$deplib $finalize_deplibs" 634972445Sassar fi 635072445Sassar continue 635172445Sassar ;; 635290926Snectar esac # linkmode 635390926Snectar ;; # *.$libext 635472445Sassar *.lo | *.$objext) 6355127808Snectar if test "$pass" = conv; then 6356127808Snectar deplibs="$deplib $deplibs" 6357127808Snectar elif test "$linkmode" = prog; then 6358127808Snectar if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 6359127808Snectar # If there is no dlopen support or we're linking statically, 6360127808Snectar # we need to preload. 6361233294Sstas func_append newdlprefiles " $deplib" 6362127808Snectar compile_deplibs="$deplib $compile_deplibs" 6363127808Snectar finalize_deplibs="$deplib $finalize_deplibs" 6364127808Snectar else 6365233294Sstas func_append newdlfiles " $deplib" 6366127808Snectar fi 636772445Sassar fi 636872445Sassar continue 636972445Sassar ;; 637072445Sassar %DEPLIBS%) 637172445Sassar alldeplibs=yes 637272445Sassar continue 637372445Sassar ;; 637490926Snectar esac # case $deplib 6375233294Sstas 6376127808Snectar if test "$found" = yes || test -f "$lib"; then : 637772445Sassar else 6378233294Sstas func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 637972445Sassar fi 638072445Sassar 638172445Sassar # Check to see that this really is a libtool archive. 6382233294Sstas func_lalib_unsafe_p "$lib" \ 6383233294Sstas || func_fatal_error "\`$lib' is not a valid libtool archive" 638472445Sassar 6385233294Sstas func_dirname "$lib" "" "." 6386233294Sstas ladir="$func_dirname_result" 638772445Sassar 638872445Sassar dlname= 638972445Sassar dlopen= 639072445Sassar dlpreopen= 639172445Sassar libdir= 639272445Sassar library_names= 639372445Sassar old_library= 6394233294Sstas inherited_linker_flags= 639555682Smarkm # If the library was installed with an old release of libtool, 6396127808Snectar # it will not redefine variables installed, or shouldnotlink 639755682Smarkm installed=yes 6398127808Snectar shouldnotlink=no 6399178825Sdfr avoidtemprpath= 640055682Smarkm 6401178825Sdfr 640272445Sassar # Read the .la file 6403233294Sstas func_source "$lib" 640455682Smarkm 6405233294Sstas # Convert "-framework foo" to "foo.ltframework" 6406233294Sstas if test -n "$inherited_linker_flags"; then 6407233294Sstas tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 6408233294Sstas for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 6409233294Sstas case " $new_inherited_linker_flags " in 6410233294Sstas *" $tmp_inherited_linker_flag "*) ;; 6411233294Sstas *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 6412233294Sstas esac 6413233294Sstas done 6414233294Sstas fi 6415233294Sstas dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 641672445Sassar if test "$linkmode,$pass" = "lib,link" || 641772445Sassar test "$linkmode,$pass" = "prog,scan" || 6418127808Snectar { test "$linkmode" != prog && test "$linkmode" != lib; }; then 6419233294Sstas test -n "$dlopen" && func_append dlfiles " $dlopen" 6420233294Sstas test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 642172445Sassar fi 642255682Smarkm 6423127808Snectar if test "$pass" = conv; then 642490926Snectar # Only check for convenience libraries 642572445Sassar deplibs="$lib $deplibs" 642672445Sassar if test -z "$libdir"; then 642772445Sassar if test -z "$old_library"; then 6428233294Sstas func_fatal_error "cannot find name of link library for \`$lib'" 642972445Sassar fi 643072445Sassar # It is a libtool convenience library, so add in its objects. 6431233294Sstas func_append convenience " $ladir/$objdir/$old_library" 6432233294Sstas func_append old_convenience " $ladir/$objdir/$old_library" 6433127808Snectar elif test "$linkmode" != prog && test "$linkmode" != lib; then 6434233294Sstas func_fatal_error "\`$lib' is not a convenience library" 643572445Sassar fi 6436233294Sstas tmp_libs= 6437233294Sstas for deplib in $dependency_libs; do 6438233294Sstas deplibs="$deplib $deplibs" 6439233294Sstas if $opt_preserve_dup_deps ; then 6440233294Sstas case "$tmp_libs " in 6441233294Sstas *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6442233294Sstas esac 6443233294Sstas fi 6444233294Sstas func_append tmp_libs " $deplib" 6445233294Sstas done 644672445Sassar continue 644790926Snectar fi # $pass = conv 644855682Smarkm 6449178825Sdfr 645072445Sassar # Get the name of the library we link against. 645172445Sassar linklib= 6452233294Sstas if test -n "$old_library" && 6453233294Sstas { test "$prefer_static_libs" = yes || 6454233294Sstas test "$prefer_static_libs,$installed" = "built,no"; }; then 6455233294Sstas linklib=$old_library 6456233294Sstas else 6457233294Sstas for l in $old_library $library_names; do 6458233294Sstas linklib="$l" 6459233294Sstas done 6460233294Sstas fi 646172445Sassar if test -z "$linklib"; then 6462233294Sstas func_fatal_error "cannot find name of link library for \`$lib'" 646372445Sassar fi 646455682Smarkm 646572445Sassar # This library was specified with -dlopen. 6466127808Snectar if test "$pass" = dlopen; then 646772445Sassar if test -z "$libdir"; then 6468233294Sstas func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 646972445Sassar fi 6470178825Sdfr if test -z "$dlname" || 6471178825Sdfr test "$dlopen_support" != yes || 6472178825Sdfr test "$build_libtool_libs" = no; then 647390926Snectar # If there is no dlname, no dlopen support or we're linking 6474127808Snectar # statically, we need to preload. We also need to preload any 6475127808Snectar # dependent libraries so libltdl's deplib preloader doesn't 6476127808Snectar # bomb out in the load deplibs phase. 6477233294Sstas func_append dlprefiles " $lib $dependency_libs" 647872445Sassar else 6479233294Sstas func_append newdlfiles " $lib" 648072445Sassar fi 648172445Sassar continue 648290926Snectar fi # $pass = dlopen 648372445Sassar 648472445Sassar # We need an absolute path. 648590926Snectar case $ladir in 648672445Sassar [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 648772445Sassar *) 648872445Sassar abs_ladir=`cd "$ladir" && pwd` 648972445Sassar if test -z "$abs_ladir"; then 6490233294Sstas func_warning "cannot determine absolute directory name of \`$ladir'" 6491233294Sstas func_warning "passing it literally to the linker, although it might fail" 649272445Sassar abs_ladir="$ladir" 649372445Sassar fi 649472445Sassar ;; 649572445Sassar esac 6496233294Sstas func_basename "$lib" 6497233294Sstas laname="$func_basename_result" 649872445Sassar 649972445Sassar # Find the relevant object directory and library name. 650055682Smarkm if test "X$installed" = Xyes; then 6501233294Sstas if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6502233294Sstas func_warning "library \`$lib' was moved." 650372445Sassar dir="$ladir" 650472445Sassar absdir="$abs_ladir" 650572445Sassar libdir="$abs_ladir" 650672445Sassar else 6507233294Sstas dir="$lt_sysroot$libdir" 6508233294Sstas absdir="$lt_sysroot$libdir" 650972445Sassar fi 6510178825Sdfr test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 651155682Smarkm else 6512178825Sdfr if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6513178825Sdfr dir="$ladir" 6514178825Sdfr absdir="$abs_ladir" 6515178825Sdfr # Remove this search path later 6516233294Sstas func_append notinst_path " $abs_ladir" 6517178825Sdfr else 6518178825Sdfr dir="$ladir/$objdir" 6519178825Sdfr absdir="$abs_ladir/$objdir" 6520178825Sdfr # Remove this search path later 6521233294Sstas func_append notinst_path " $abs_ladir" 6522178825Sdfr fi 652390926Snectar fi # $installed = yes 6524233294Sstas func_stripname 'lib' '.la' "$laname" 6525233294Sstas name=$func_stripname_result 652672445Sassar 652772445Sassar # This library was specified with -dlpreopen. 6528127808Snectar if test "$pass" = dlpreopen; then 6529233294Sstas if test -z "$libdir" && test "$linkmode" = prog; then 6530233294Sstas func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 653172445Sassar fi 6532233294Sstas case "$host" in 6533233294Sstas # special handling for platforms with PE-DLLs. 6534233294Sstas *cygwin* | *mingw* | *cegcc* ) 6535233294Sstas # Linker will automatically link against shared library if both 6536233294Sstas # static and shared are present. Therefore, ensure we extract 6537233294Sstas # symbols from the import library if a shared library is present 6538233294Sstas # (otherwise, the dlopen module name will be incorrect). We do 6539233294Sstas # this by putting the import library name into $newdlprefiles. 6540233294Sstas # We recover the dlopen module name by 'saving' the la file 6541233294Sstas # name in a special purpose variable, and (later) extracting the 6542233294Sstas # dlname from the la file. 6543233294Sstas if test -n "$dlname"; then 6544233294Sstas func_tr_sh "$dir/$linklib" 6545233294Sstas eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 6546233294Sstas func_append newdlprefiles " $dir/$linklib" 6547233294Sstas else 6548233294Sstas func_append newdlprefiles " $dir/$old_library" 6549233294Sstas # Keep a list of preopened convenience libraries to check 6550233294Sstas # that they are being used correctly in the link pass. 6551233294Sstas test -z "$libdir" && \ 6552233294Sstas func_append dlpreconveniencelibs " $dir/$old_library" 6553233294Sstas fi 6554233294Sstas ;; 6555233294Sstas * ) 6556233294Sstas # Prefer using a static library (so that no silly _DYNAMIC symbols 6557233294Sstas # are required to link). 6558233294Sstas if test -n "$old_library"; then 6559233294Sstas func_append newdlprefiles " $dir/$old_library" 6560233294Sstas # Keep a list of preopened convenience libraries to check 6561233294Sstas # that they are being used correctly in the link pass. 6562233294Sstas test -z "$libdir" && \ 6563233294Sstas func_append dlpreconveniencelibs " $dir/$old_library" 6564233294Sstas # Otherwise, use the dlname, so that lt_dlopen finds it. 6565233294Sstas elif test -n "$dlname"; then 6566233294Sstas func_append newdlprefiles " $dir/$dlname" 6567233294Sstas else 6568233294Sstas func_append newdlprefiles " $dir/$linklib" 6569233294Sstas fi 6570233294Sstas ;; 6571233294Sstas esac 657290926Snectar fi # $pass = dlpreopen 657355682Smarkm 657472445Sassar if test -z "$libdir"; then 657590926Snectar # Link the convenience library 6576127808Snectar if test "$linkmode" = lib; then 657772445Sassar deplibs="$dir/$old_library $deplibs" 657872445Sassar elif test "$linkmode,$pass" = "prog,link"; then 657972445Sassar compile_deplibs="$dir/$old_library $compile_deplibs" 658072445Sassar finalize_deplibs="$dir/$old_library $finalize_deplibs" 658172445Sassar else 6582127808Snectar deplibs="$lib $deplibs" # used for prog,scan pass 658372445Sassar fi 658455682Smarkm continue 658555682Smarkm fi 658655682Smarkm 6587178825Sdfr 6588127808Snectar if test "$linkmode" = prog && test "$pass" != link; then 6589233294Sstas func_append newlib_search_path " $ladir" 659072445Sassar deplibs="$lib $deplibs" 659155682Smarkm 659272445Sassar linkalldeplibs=no 659372445Sassar if test "$link_all_deplibs" != no || test -z "$library_names" || 659472445Sassar test "$build_libtool_libs" = no; then 659572445Sassar linkalldeplibs=yes 659672445Sassar fi 659755682Smarkm 659872445Sassar tmp_libs= 659972445Sassar for deplib in $dependency_libs; do 660090926Snectar case $deplib in 6601233294Sstas -L*) func_stripname '-L' '' "$deplib" 6602233294Sstas func_resolve_sysroot "$func_stripname_result" 6603233294Sstas func_append newlib_search_path " $func_resolve_sysroot_result" 6604233294Sstas ;; 660572445Sassar esac 660672445Sassar # Need to link against all dependency_libs? 6607127808Snectar if test "$linkalldeplibs" = yes; then 660872445Sassar deplibs="$deplib $deplibs" 660972445Sassar else 661072445Sassar # Need to hardcode shared library paths 661172445Sassar # or/and link against static libraries 661272445Sassar newdependency_libs="$deplib $newdependency_libs" 661372445Sassar fi 6614233294Sstas if $opt_preserve_dup_deps ; then 6615127808Snectar case "$tmp_libs " in 6616233294Sstas *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6617127808Snectar esac 6618127808Snectar fi 6619233294Sstas func_append tmp_libs " $deplib" 662090926Snectar done # for deplib 662172445Sassar continue 662290926Snectar fi # $linkmode = prog... 662355682Smarkm 6624127808Snectar if test "$linkmode,$pass" = "prog,link"; then 6625127808Snectar if test -n "$library_names" && 6626233294Sstas { { test "$prefer_static_libs" = no || 6627233294Sstas test "$prefer_static_libs,$installed" = "built,yes"; } || 6628233294Sstas test -z "$old_library"; }; then 6629127808Snectar # We need to hardcode the library path 6630178825Sdfr if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 6631127808Snectar # Make sure the rpath contains only unique directories. 6632233294Sstas case "$temp_rpath:" in 6633233294Sstas *"$absdir:"*) ;; 6634233294Sstas *) func_append temp_rpath "$absdir:" ;; 6635127808Snectar esac 6636127808Snectar fi 663755682Smarkm 663872445Sassar # Hardcode the library path. 663972445Sassar # Skip directories that are in the system default run-time 664072445Sassar # search path. 664172445Sassar case " $sys_lib_dlsearch_path " in 664272445Sassar *" $absdir "*) ;; 664372445Sassar *) 664472445Sassar case "$compile_rpath " in 664572445Sassar *" $absdir "*) ;; 6646233294Sstas *) func_append compile_rpath " $absdir" ;; 664772445Sassar esac 664872445Sassar ;; 664972445Sassar esac 665072445Sassar case " $sys_lib_dlsearch_path " in 665172445Sassar *" $libdir "*) ;; 665272445Sassar *) 665372445Sassar case "$finalize_rpath " in 665472445Sassar *" $libdir "*) ;; 6655233294Sstas *) func_append finalize_rpath " $libdir" ;; 665672445Sassar esac 665772445Sassar ;; 665872445Sassar esac 665990926Snectar fi # $linkmode,$pass = prog,link... 666055682Smarkm 666172445Sassar if test "$alldeplibs" = yes && 666272445Sassar { test "$deplibs_check_method" = pass_all || 666372445Sassar { test "$build_libtool_libs" = yes && 666472445Sassar test -n "$library_names"; }; }; then 666572445Sassar # We only need to search for static libraries 666672445Sassar continue 666772445Sassar fi 6668127808Snectar fi 666955682Smarkm 6670127808Snectar link_static=no # Whether the deplib will be linked statically 6671178825Sdfr use_static_libs=$prefer_static_libs 6672233294Sstas if test "$use_static_libs" = built && test "$installed" = yes; then 6673178825Sdfr use_static_libs=no 6674178825Sdfr fi 6675127808Snectar if test -n "$library_names" && 6676178825Sdfr { test "$use_static_libs" = no || test -z "$old_library"; }; then 6677233294Sstas case $host in 6678233294Sstas *cygwin* | *mingw* | *cegcc*) 6679233294Sstas # No point in relinking DLLs because paths are not encoded 6680233294Sstas func_append notinst_deplibs " $lib" 6681233294Sstas need_relink=no 6682233294Sstas ;; 6683233294Sstas *) 6684233294Sstas if test "$installed" = no; then 6685233294Sstas func_append notinst_deplibs " $lib" 6686233294Sstas need_relink=yes 6687233294Sstas fi 6688233294Sstas ;; 6689233294Sstas esac 6690127808Snectar # This is a shared library 6691178825Sdfr 6692233294Sstas # Warn about portability, can't link against -module's on some 6693233294Sstas # systems (darwin). Don't bleat about dlopened modules though! 6694233294Sstas dlopenmodule="" 6695233294Sstas for dlpremoduletest in $dlprefiles; do 6696233294Sstas if test "X$dlpremoduletest" = "X$lib"; then 6697233294Sstas dlopenmodule="$dlpremoduletest" 6698233294Sstas break 6699233294Sstas fi 6700233294Sstas done 6701233294Sstas if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 6702233294Sstas echo 6703127808Snectar if test "$linkmode" = prog; then 6704233294Sstas $ECHO "*** Warning: Linking the executable $output against the loadable module" 6705127808Snectar else 6706233294Sstas $ECHO "*** Warning: Linking the shared library $output against the loadable module" 6707127808Snectar fi 6708233294Sstas $ECHO "*** $linklib is not portable!" 6709178825Sdfr fi 6710127808Snectar if test "$linkmode" = lib && 6711127808Snectar test "$hardcode_into_libs" = yes; then 6712127808Snectar # Hardcode the library path. 6713127808Snectar # Skip directories that are in the system default run-time 6714127808Snectar # search path. 6715127808Snectar case " $sys_lib_dlsearch_path " in 6716127808Snectar *" $absdir "*) ;; 6717127808Snectar *) 6718127808Snectar case "$compile_rpath " in 6719127808Snectar *" $absdir "*) ;; 6720233294Sstas *) func_append compile_rpath " $absdir" ;; 6721127808Snectar esac 6722127808Snectar ;; 6723127808Snectar esac 6724127808Snectar case " $sys_lib_dlsearch_path " in 6725127808Snectar *" $libdir "*) ;; 6726127808Snectar *) 6727127808Snectar case "$finalize_rpath " in 6728127808Snectar *" $libdir "*) ;; 6729233294Sstas *) func_append finalize_rpath " $libdir" ;; 6730127808Snectar esac 6731127808Snectar ;; 6732127808Snectar esac 6733127808Snectar fi 673472445Sassar 673572445Sassar if test -n "$old_archive_from_expsyms_cmds"; then 673672445Sassar # figure out the soname 673772445Sassar set dummy $library_names 6738233294Sstas shift 6739233294Sstas realname="$1" 6740233294Sstas shift 6741233294Sstas libname=`eval "\\$ECHO \"$libname_spec\""` 674290926Snectar # use dlname if we got it. it's perfectly good, no? 674390926Snectar if test -n "$dlname"; then 674490926Snectar soname="$dlname" 674590926Snectar elif test -n "$soname_spec"; then 674690926Snectar # bleh windows 674790926Snectar case $host in 6748233294Sstas *cygwin* | mingw* | *cegcc*) 6749233294Sstas func_arith $current - $age 6750233294Sstas major=$func_arith_result 675190926Snectar versuffix="-$major" 675290926Snectar ;; 675390926Snectar esac 675472445Sassar eval soname=\"$soname_spec\" 675555682Smarkm else 675672445Sassar soname="$realname" 675772445Sassar fi 675855682Smarkm 675972445Sassar # Make a new name for the extract_expsyms_cmds to use 676090926Snectar soroot="$soname" 6761233294Sstas func_basename "$soroot" 6762233294Sstas soname="$func_basename_result" 6763233294Sstas func_stripname 'lib' '.dll' "$soname" 6764233294Sstas newlib=libimp-$func_stripname_result.a 676555682Smarkm 676672445Sassar # If the library has no export list, then create one now 676772445Sassar if test -f "$output_objdir/$soname-def"; then : 676855682Smarkm else 6769233294Sstas func_verbose "extracting exported symbol list from \`$soname'" 6770233294Sstas func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 677172445Sassar fi 677255682Smarkm 677372445Sassar # Create $newlib 677472445Sassar if test -f "$output_objdir/$newlib"; then :; else 6775233294Sstas func_verbose "generating import library for \`$soname'" 6776233294Sstas func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 677772445Sassar fi 677872445Sassar # make sure the library variables are pointing to the new library 677972445Sassar dir=$output_objdir 678072445Sassar linklib=$newlib 6781127808Snectar fi # test -n "$old_archive_from_expsyms_cmds" 678255682Smarkm 6783233294Sstas if test "$linkmode" = prog || test "$opt_mode" != relink; then 678472445Sassar add_shlibpath= 678572445Sassar add_dir= 678672445Sassar add= 678772445Sassar lib_linked=yes 678890926Snectar case $hardcode_action in 678972445Sassar immediate | unsupported) 679072445Sassar if test "$hardcode_direct" = no; then 679172445Sassar add="$dir/$linklib" 6792127808Snectar case $host in 6793178825Sdfr *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6794178825Sdfr *-*-sysv4*uw2*) add_dir="-L$dir" ;; 6795178825Sdfr *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6796178825Sdfr *-*-unixware7*) add_dir="-L$dir" ;; 6797127808Snectar *-*-darwin* ) 6798233294Sstas # if the lib is a (non-dlopened) module then we can not 6799233294Sstas # link against it, someone is ignoring the earlier warnings 6800178825Sdfr if /usr/bin/file -L $add 2> /dev/null | 6801233294Sstas $GREP ": [^:]* bundle" >/dev/null ; then 6802233294Sstas if test "X$dlopenmodule" != "X$lib"; then 6803233294Sstas $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6804233294Sstas if test -z "$old_library" ; then 6805233294Sstas echo 6806233294Sstas echo "*** And there doesn't seem to be a static archive available" 6807233294Sstas echo "*** The link will probably fail, sorry" 6808233294Sstas else 6809233294Sstas add="$dir/$old_library" 6810233294Sstas fi 6811233294Sstas elif test -n "$old_library"; then 6812233294Sstas add="$dir/$old_library" 6813178825Sdfr fi 6814127808Snectar fi 6815127808Snectar esac 681672445Sassar elif test "$hardcode_minus_L" = no; then 681790926Snectar case $host in 681872445Sassar *-*-sunos*) add_shlibpath="$dir" ;; 681972445Sassar esac 682072445Sassar add_dir="-L$dir" 682172445Sassar add="-l$name" 682272445Sassar elif test "$hardcode_shlibpath_var" = no; then 682372445Sassar add_shlibpath="$dir" 682472445Sassar add="-l$name" 682572445Sassar else 682672445Sassar lib_linked=no 682772445Sassar fi 682872445Sassar ;; 682972445Sassar relink) 6830233294Sstas if test "$hardcode_direct" = yes && 6831233294Sstas test "$hardcode_direct_absolute" = no; then 683272445Sassar add="$dir/$linklib" 683372445Sassar elif test "$hardcode_minus_L" = yes; then 683472445Sassar add_dir="-L$dir" 6835127808Snectar # Try looking first in the location we're being installed to. 6836127808Snectar if test -n "$inst_prefix_dir"; then 6837178825Sdfr case $libdir in 6838127808Snectar [\\/]*) 6839233294Sstas func_append add_dir " -L$inst_prefix_dir$libdir" 6840127808Snectar ;; 6841127808Snectar esac 6842127808Snectar fi 684372445Sassar add="-l$name" 684472445Sassar elif test "$hardcode_shlibpath_var" = yes; then 684572445Sassar add_shlibpath="$dir" 684672445Sassar add="-l$name" 684772445Sassar else 684872445Sassar lib_linked=no 684972445Sassar fi 685072445Sassar ;; 685172445Sassar *) lib_linked=no ;; 685272445Sassar esac 685372445Sassar 685472445Sassar if test "$lib_linked" != yes; then 6855233294Sstas func_fatal_configuration "unsupported hardcode properties" 685672445Sassar fi 685772445Sassar 685872445Sassar if test -n "$add_shlibpath"; then 685990926Snectar case :$compile_shlibpath: in 686072445Sassar *":$add_shlibpath:"*) ;; 6861233294Sstas *) func_append compile_shlibpath "$add_shlibpath:" ;; 686272445Sassar esac 686372445Sassar fi 6864127808Snectar if test "$linkmode" = prog; then 686572445Sassar test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 686672445Sassar test -n "$add" && compile_deplibs="$add $compile_deplibs" 686772445Sassar else 686872445Sassar test -n "$add_dir" && deplibs="$add_dir $deplibs" 686972445Sassar test -n "$add" && deplibs="$add $deplibs" 6870233294Sstas if test "$hardcode_direct" != yes && 6871233294Sstas test "$hardcode_minus_L" != yes && 687272445Sassar test "$hardcode_shlibpath_var" = yes; then 687390926Snectar case :$finalize_shlibpath: in 687472445Sassar *":$libdir:"*) ;; 6875233294Sstas *) func_append finalize_shlibpath "$libdir:" ;; 687672445Sassar esac 687772445Sassar fi 687872445Sassar fi 687955682Smarkm fi 688055682Smarkm 6881233294Sstas if test "$linkmode" = prog || test "$opt_mode" = relink; then 688272445Sassar add_shlibpath= 688372445Sassar add_dir= 688472445Sassar add= 688572445Sassar # Finalize command for both is simple: just hardcode it. 6886233294Sstas if test "$hardcode_direct" = yes && 6887233294Sstas test "$hardcode_direct_absolute" = no; then 688872445Sassar add="$libdir/$linklib" 688972445Sassar elif test "$hardcode_minus_L" = yes; then 689072445Sassar add_dir="-L$libdir" 689172445Sassar add="-l$name" 689272445Sassar elif test "$hardcode_shlibpath_var" = yes; then 689390926Snectar case :$finalize_shlibpath: in 689472445Sassar *":$libdir:"*) ;; 6895233294Sstas *) func_append finalize_shlibpath "$libdir:" ;; 689672445Sassar esac 689772445Sassar add="-l$name" 6898127808Snectar elif test "$hardcode_automatic" = yes; then 6899178825Sdfr if test -n "$inst_prefix_dir" && 6900178825Sdfr test -f "$inst_prefix_dir$libdir/$linklib" ; then 6901233294Sstas add="$inst_prefix_dir$libdir/$linklib" 6902127808Snectar else 6903233294Sstas add="$libdir/$linklib" 6904127808Snectar fi 690572445Sassar else 690672445Sassar # We cannot seem to hardcode it, guess we'll fake it. 690772445Sassar add_dir="-L$libdir" 6908127808Snectar # Try looking first in the location we're being installed to. 6909127808Snectar if test -n "$inst_prefix_dir"; then 6910178825Sdfr case $libdir in 6911127808Snectar [\\/]*) 6912233294Sstas func_append add_dir " -L$inst_prefix_dir$libdir" 6913127808Snectar ;; 6914127808Snectar esac 6915127808Snectar fi 691672445Sassar add="-l$name" 691772445Sassar fi 691855682Smarkm 6919127808Snectar if test "$linkmode" = prog; then 692072445Sassar test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 692172445Sassar test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 692272445Sassar else 692372445Sassar test -n "$add_dir" && deplibs="$add_dir $deplibs" 692490926Snectar test -n "$add" && deplibs="$add $deplibs" 692572445Sassar fi 692672445Sassar fi 6927127808Snectar elif test "$linkmode" = prog; then 692855682Smarkm # Here we assume that one of hardcode_direct or hardcode_minus_L 692955682Smarkm # is not unsupported. This is valid on all known static and 693055682Smarkm # shared platforms. 693155682Smarkm if test "$hardcode_direct" != unsupported; then 693255682Smarkm test -n "$old_library" && linklib="$old_library" 693372445Sassar compile_deplibs="$dir/$linklib $compile_deplibs" 693472445Sassar finalize_deplibs="$dir/$linklib $finalize_deplibs" 693555682Smarkm else 693672445Sassar compile_deplibs="-l$name -L$dir $compile_deplibs" 693772445Sassar finalize_deplibs="-l$name -L$dir $finalize_deplibs" 693855682Smarkm fi 693972445Sassar elif test "$build_libtool_libs" = yes; then 694072445Sassar # Not a shared library 694172445Sassar if test "$deplibs_check_method" != pass_all; then 694272445Sassar # We're trying link a shared library against a static one 694372445Sassar # but the system doesn't support it. 694490926Snectar 694572445Sassar # Just print a warning and add the library to dependency_libs so 694672445Sassar # that the program can be linked against the static library. 6947233294Sstas echo 6948233294Sstas $ECHO "*** Warning: This system can not link to static lib archive $lib." 6949233294Sstas echo "*** I have the capability to make that library automatically link in when" 6950233294Sstas echo "*** you link to this library. But I can only do this if you have a" 6951233294Sstas echo "*** shared version of the library, which you do not appear to have." 695290926Snectar if test "$module" = yes; then 6953233294Sstas echo "*** But as you try to build a module library, libtool will still create " 6954233294Sstas echo "*** a static module, that should work as long as the dlopening application" 6955233294Sstas echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 695690926Snectar if test -z "$global_symbol_pipe"; then 6957233294Sstas echo 6958233294Sstas echo "*** However, this would only work if libtool was able to extract symbol" 6959233294Sstas echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 6960233294Sstas echo "*** not find such a program. So, this module is probably useless." 6961233294Sstas echo "*** \`nm' from GNU binutils and a full rebuild may help." 696290926Snectar fi 696390926Snectar if test "$build_old_libs" = no; then 6964102644Snectar build_libtool_libs=module 6965102644Snectar build_old_libs=yes 696690926Snectar else 6967102644Snectar build_libtool_libs=no 696890926Snectar fi 696990926Snectar fi 697072445Sassar else 697172445Sassar deplibs="$dir/$old_library $deplibs" 697272445Sassar link_static=yes 697372445Sassar fi 697490926Snectar fi # link shared/static library? 697555682Smarkm 6976127808Snectar if test "$linkmode" = lib; then 697772445Sassar if test -n "$dependency_libs" && 6978178825Sdfr { test "$hardcode_into_libs" != yes || 6979178825Sdfr test "$build_old_libs" = yes || 6980127808Snectar test "$link_static" = yes; }; then 698172445Sassar # Extract -R from dependency_libs 698272445Sassar temp_deplibs= 698372445Sassar for libdir in $dependency_libs; do 698490926Snectar case $libdir in 6985233294Sstas -R*) func_stripname '-R' '' "$libdir" 6986233294Sstas temp_xrpath=$func_stripname_result 698772445Sassar case " $xrpath " in 698872445Sassar *" $temp_xrpath "*) ;; 6989233294Sstas *) func_append xrpath " $temp_xrpath";; 699072445Sassar esac;; 6991233294Sstas *) func_append temp_deplibs " $libdir";; 699272445Sassar esac 699372445Sassar done 699472445Sassar dependency_libs="$temp_deplibs" 699572445Sassar fi 699655682Smarkm 6997233294Sstas func_append newlib_search_path " $absdir" 699872445Sassar # Link against this library 699972445Sassar test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 700072445Sassar # ... and its dependency_libs 700172445Sassar tmp_libs= 700272445Sassar for deplib in $dependency_libs; do 700372445Sassar newdependency_libs="$deplib $newdependency_libs" 7004233294Sstas case $deplib in 7005233294Sstas -L*) func_stripname '-L' '' "$deplib" 7006233294Sstas func_resolve_sysroot "$func_stripname_result";; 7007233294Sstas *) func_resolve_sysroot "$deplib" ;; 7008233294Sstas esac 7009233294Sstas if $opt_preserve_dup_deps ; then 7010127808Snectar case "$tmp_libs " in 7011233294Sstas *" $func_resolve_sysroot_result "*) 7012233294Sstas func_append specialdeplibs " $func_resolve_sysroot_result" ;; 7013127808Snectar esac 7014127808Snectar fi 7015233294Sstas func_append tmp_libs " $func_resolve_sysroot_result" 701672445Sassar done 701755682Smarkm 7018127808Snectar if test "$link_all_deplibs" != no; then 701972445Sassar # Add the search paths of all dependency libraries 702072445Sassar for deplib in $dependency_libs; do 7021233294Sstas path= 702290926Snectar case $deplib in 702372445Sassar -L*) path="$deplib" ;; 702472445Sassar *.la) 7025233294Sstas func_resolve_sysroot "$deplib" 7026233294Sstas deplib=$func_resolve_sysroot_result 7027233294Sstas func_dirname "$deplib" "" "." 7028233294Sstas dir=$func_dirname_result 702972445Sassar # We need an absolute path. 703090926Snectar case $dir in 703172445Sassar [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 703272445Sassar *) 703372445Sassar absdir=`cd "$dir" && pwd` 703472445Sassar if test -z "$absdir"; then 7035233294Sstas func_warning "cannot determine absolute directory name of \`$dir'" 703672445Sassar absdir="$dir" 703772445Sassar fi 703872445Sassar ;; 703972445Sassar esac 7040233294Sstas if $GREP "^installed=no" $deplib > /dev/null; then 7041127808Snectar case $host in 7042127808Snectar *-*-darwin*) 7043233294Sstas depdepl= 7044127808Snectar eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 7045127808Snectar if test -n "$deplibrary_names" ; then 7046127808Snectar for tmp in $deplibrary_names ; do 7047127808Snectar depdepl=$tmp 7048127808Snectar done 7049233294Sstas if test -f "$absdir/$objdir/$depdepl" ; then 7050233294Sstas depdepl="$absdir/$objdir/$depdepl" 7051233294Sstas darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7052233294Sstas if test -z "$darwin_install_name"; then 7053233294Sstas darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7054233294Sstas fi 7055233294Sstas func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 7056233294Sstas func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 7057233294Sstas path= 7058178825Sdfr fi 7059127808Snectar fi 7060127808Snectar ;; 7061127808Snectar *) 7062233294Sstas path="-L$absdir/$objdir" 7063178825Sdfr ;; 7064178825Sdfr esac 7065233294Sstas else 7066233294Sstas eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 7067233294Sstas test -z "$libdir" && \ 7068233294Sstas func_fatal_error "\`$deplib' is not a valid libtool archive" 7069233294Sstas test "$absdir" != "$libdir" && \ 7070233294Sstas func_warning "\`$deplib' seems to be moved" 7071233294Sstas 7072233294Sstas path="-L$absdir" 7073233294Sstas fi 707472445Sassar ;; 707572445Sassar esac 707672445Sassar case " $deplibs " in 707772445Sassar *" $path "*) ;; 7078178825Sdfr *) deplibs="$path $deplibs" ;; 707972445Sassar esac 708072445Sassar done 708190926Snectar fi # link_all_deplibs != no 708290926Snectar fi # linkmode = lib 708390926Snectar done # for deplib in $libs 7084233294Sstas if test "$pass" = link; then 7085233294Sstas if test "$linkmode" = "prog"; then 7086233294Sstas compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 7087233294Sstas finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 7088233294Sstas else 7089233294Sstas compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7090233294Sstas fi 7091233294Sstas fi 7092127808Snectar dependency_libs="$newdependency_libs" 7093127808Snectar if test "$pass" = dlpreopen; then 709472445Sassar # Link the dlpreopened libraries before other libraries 709572445Sassar for deplib in $save_deplibs; do 709672445Sassar deplibs="$deplib $deplibs" 709772445Sassar done 709855682Smarkm fi 7099127808Snectar if test "$pass" != dlopen; then 7100127808Snectar if test "$pass" != conv; then 710172445Sassar # Make sure lib_search_path contains only unique directories. 710272445Sassar lib_search_path= 710372445Sassar for dir in $newlib_search_path; do 710472445Sassar case "$lib_search_path " in 710572445Sassar *" $dir "*) ;; 7106233294Sstas *) func_append lib_search_path " $dir" ;; 710772445Sassar esac 710872445Sassar done 710972445Sassar newlib_search_path= 711072445Sassar fi 711172445Sassar 711272445Sassar if test "$linkmode,$pass" != "prog,link"; then 711372445Sassar vars="deplibs" 711472445Sassar else 711572445Sassar vars="compile_deplibs finalize_deplibs" 711672445Sassar fi 711772445Sassar for var in $vars dependency_libs; do 711890926Snectar # Add libraries to $var in reverse order 711972445Sassar eval tmp_libs=\"\$$var\" 712072445Sassar new_libs= 712172445Sassar for deplib in $tmp_libs; do 7122127808Snectar # FIXME: Pedantically, this is the right thing to do, so 7123127808Snectar # that some nasty dependency loop isn't accidentally 7124127808Snectar # broken: 7125127808Snectar #new_libs="$deplib $new_libs" 7126127808Snectar # Pragmatically, this seems to cause very few problems in 7127127808Snectar # practice: 712890926Snectar case $deplib in 712972445Sassar -L*) new_libs="$deplib $new_libs" ;; 7130127808Snectar -R*) ;; 713172445Sassar *) 7132127808Snectar # And here is the reason: when a library appears more 7133127808Snectar # than once as an explicit dependence of a library, or 7134127808Snectar # is implicitly linked in more than once by the 7135127808Snectar # compiler, it is considered special, and multiple 7136127808Snectar # occurrences thereof are not removed. Compare this 7137127808Snectar # with having the same library being listed as a 7138127808Snectar # dependency of multiple other libraries: in this case, 7139127808Snectar # we know (pedantically, we assume) the library does not 7140127808Snectar # need to be listed more than once, so we keep only the 7141127808Snectar # last copy. This is not always right, but it is rare 7142127808Snectar # enough that we require users that really mean to play 7143127808Snectar # such unportable linking tricks to link the library 7144127808Snectar # using -Wl,-lname, so that libtool does not consider it 7145127808Snectar # for duplicate removal. 714672445Sassar case " $specialdeplibs " in 714772445Sassar *" $deplib "*) new_libs="$deplib $new_libs" ;; 714872445Sassar *) 714972445Sassar case " $new_libs " in 715072445Sassar *" $deplib "*) ;; 715172445Sassar *) new_libs="$deplib $new_libs" ;; 715272445Sassar esac 715372445Sassar ;; 715472445Sassar esac 715572445Sassar ;; 715672445Sassar esac 715772445Sassar done 715872445Sassar tmp_libs= 715972445Sassar for deplib in $new_libs; do 716090926Snectar case $deplib in 716172445Sassar -L*) 716272445Sassar case " $tmp_libs " in 716372445Sassar *" $deplib "*) ;; 7164233294Sstas *) func_append tmp_libs " $deplib" ;; 716572445Sassar esac 716672445Sassar ;; 7167233294Sstas *) func_append tmp_libs " $deplib" ;; 716872445Sassar esac 716972445Sassar done 717072445Sassar eval $var=\"$tmp_libs\" 717190926Snectar done # for var 717272445Sassar fi 7173178825Sdfr # Last step: remove runtime libs from dependency_libs 7174178825Sdfr # (they stay in deplibs) 7175127808Snectar tmp_libs= 7176127808Snectar for i in $dependency_libs ; do 7177127808Snectar case " $predeps $postdeps $compiler_lib_search_path " in 7178127808Snectar *" $i "*) 7179127808Snectar i="" 7180127808Snectar ;; 7181127808Snectar esac 7182127808Snectar if test -n "$i" ; then 7183233294Sstas func_append tmp_libs " $i" 7184127808Snectar fi 7185127808Snectar done 7186127808Snectar dependency_libs=$tmp_libs 718790926Snectar done # for pass 7188127808Snectar if test "$linkmode" = prog; then 718972445Sassar dlfiles="$newdlfiles" 7190233294Sstas fi 7191233294Sstas if test "$linkmode" = prog || test "$linkmode" = lib; then 719272445Sassar dlprefiles="$newdlprefiles" 719355682Smarkm fi 719455682Smarkm 719572445Sassar case $linkmode in 719672445Sassar oldlib) 719772445Sassar if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7198233294Sstas func_warning "\`-dlopen' is ignored for archives" 719955682Smarkm fi 720055682Smarkm 7201233294Sstas case " $deplibs" in 7202233294Sstas *\ -l* | *\ -L*) 7203233294Sstas func_warning "\`-l' and \`-L' are ignored for archives" ;; 7204233294Sstas esac 720555682Smarkm 7206233294Sstas test -n "$rpath" && \ 7207233294Sstas func_warning "\`-rpath' is ignored for archives" 720872445Sassar 7209233294Sstas test -n "$xrpath" && \ 7210233294Sstas func_warning "\`-R' is ignored for archives" 721155682Smarkm 7212233294Sstas test -n "$vinfo" && \ 7213233294Sstas func_warning "\`-version-info/-version-number' is ignored for archives" 721455682Smarkm 7215233294Sstas test -n "$release" && \ 7216233294Sstas func_warning "\`-release' is ignored for archives" 721755682Smarkm 7218233294Sstas test -n "$export_symbols$export_symbols_regex" && \ 7219233294Sstas func_warning "\`-export-symbols' is ignored for archives" 7220233294Sstas 722155682Smarkm # Now set the variables for building old libraries. 722255682Smarkm build_libtool_libs=no 722355682Smarkm oldlibs="$output" 7224233294Sstas func_append objs "$old_deplibs" 722555682Smarkm ;; 722655682Smarkm 722772445Sassar lib) 722855682Smarkm # Make sure we only generate libraries of the form `libNAME.la'. 722990926Snectar case $outputname in 723072445Sassar lib*) 7231233294Sstas func_stripname 'lib' '.la' "$outputname" 7232233294Sstas name=$func_stripname_result 7233178825Sdfr eval shared_ext=\"$shrext_cmds\" 723472445Sassar eval libname=\"$libname_spec\" 723572445Sassar ;; 723655682Smarkm *) 7237233294Sstas test "$module" = no && \ 7238233294Sstas func_fatal_help "libtool library \`$output' must begin with \`lib'" 7239233294Sstas 724072445Sassar if test "$need_lib_prefix" != no; then 724172445Sassar # Add the "lib" prefix for modules if required 7242233294Sstas func_stripname '' '.la' "$outputname" 7243233294Sstas name=$func_stripname_result 7244178825Sdfr eval shared_ext=\"$shrext_cmds\" 724572445Sassar eval libname=\"$libname_spec\" 724672445Sassar else 7247233294Sstas func_stripname '' '.la' "$outputname" 7248233294Sstas libname=$func_stripname_result 724972445Sassar fi 725055682Smarkm ;; 725155682Smarkm esac 725255682Smarkm 725355682Smarkm if test -n "$objs"; then 725472445Sassar if test "$deplibs_check_method" != pass_all; then 7255233294Sstas func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 725672445Sassar else 7257233294Sstas echo 7258233294Sstas $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 7259233294Sstas $ECHO "*** objects $objs is not portable!" 7260233294Sstas func_append libobjs " $objs" 726172445Sassar fi 726255682Smarkm fi 726355682Smarkm 7264233294Sstas test "$dlself" != no && \ 7265233294Sstas func_warning "\`-dlopen self' is ignored for libtool libraries" 726655682Smarkm 726755682Smarkm set dummy $rpath 7268233294Sstas shift 7269233294Sstas test "$#" -gt 1 && \ 7270233294Sstas func_warning "ignoring multiple \`-rpath's for a libtool library" 727155682Smarkm 7272233294Sstas install_libdir="$1" 7273233294Sstas 727455682Smarkm oldlibs= 727555682Smarkm if test -z "$rpath"; then 727672445Sassar if test "$build_libtool_libs" = yes; then 727772445Sassar # Building a libtool convenience library. 7278127808Snectar # Some compilers have problems with a `.al' extension so 7279127808Snectar # convenience libraries should have the same extension an 7280127808Snectar # archive normally would. 728172445Sassar oldlibs="$output_objdir/$libname.$libext $oldlibs" 728272445Sassar build_libtool_libs=convenience 728372445Sassar build_old_libs=yes 728472445Sassar fi 728555682Smarkm 7286233294Sstas test -n "$vinfo" && \ 7287233294Sstas func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 728855682Smarkm 7289233294Sstas test -n "$release" && \ 7290233294Sstas func_warning "\`-release' is ignored for convenience libraries" 729155682Smarkm else 729255682Smarkm 729355682Smarkm # Parse the version information argument. 7294102644Snectar save_ifs="$IFS"; IFS=':' 729555682Smarkm set dummy $vinfo 0 0 0 7296233294Sstas shift 729755682Smarkm IFS="$save_ifs" 729855682Smarkm 7299233294Sstas test -n "$7" && \ 7300233294Sstas func_fatal_help "too many parameters to \`-version-info'" 730155682Smarkm 7302127808Snectar # convert absolute version numbers to libtool ages 7303127808Snectar # this retains compatibility with .la files and attempts 7304127808Snectar # to make the code below a bit more comprehensible 7305178825Sdfr 7306127808Snectar case $vinfo_number in 7307127808Snectar yes) 7308233294Sstas number_major="$1" 7309233294Sstas number_minor="$2" 7310233294Sstas number_revision="$3" 7311127808Snectar # 7312127808Snectar # There are really only two kinds -- those that 7313127808Snectar # use the current revision as the major version 7314127808Snectar # and those that subtract age and use age as 7315127808Snectar # a minor version. But, then there is irix 7316127808Snectar # which has an extra 1 added just for fun 7317127808Snectar # 7318127808Snectar case $version_type in 7319233294Sstas darwin|linux|osf|windows|none) 7320233294Sstas func_arith $number_major + $number_minor 7321233294Sstas current=$func_arith_result 7322127808Snectar age="$number_minor" 7323127808Snectar revision="$number_revision" 7324127808Snectar ;; 7325233294Sstas freebsd-aout|freebsd-elf|qnx|sunos) 7326127808Snectar current="$number_major" 7327127808Snectar revision="$number_minor" 7328127808Snectar age="0" 7329127808Snectar ;; 7330127808Snectar irix|nonstopux) 7331233294Sstas func_arith $number_major + $number_minor 7332233294Sstas current=$func_arith_result 7333127808Snectar age="$number_minor" 7334127808Snectar revision="$number_minor" 7335233294Sstas lt_irix_increment=no 7336127808Snectar ;; 7337127808Snectar esac 7338127808Snectar ;; 7339127808Snectar no) 7340233294Sstas current="$1" 7341233294Sstas revision="$2" 7342233294Sstas age="$3" 7343127808Snectar ;; 7344127808Snectar esac 734555682Smarkm 734655682Smarkm # Check that each of the things are valid numbers. 734790926Snectar case $current in 7348178825Sdfr 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]) ;; 734955682Smarkm *) 7350233294Sstas func_error "CURRENT \`$current' must be a nonnegative integer" 7351233294Sstas func_fatal_error "\`$vinfo' is not valid version information" 735255682Smarkm ;; 735355682Smarkm esac 735455682Smarkm 735590926Snectar case $revision in 7356178825Sdfr 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]) ;; 735755682Smarkm *) 7358233294Sstas func_error "REVISION \`$revision' must be a nonnegative integer" 7359233294Sstas func_fatal_error "\`$vinfo' is not valid version information" 736055682Smarkm ;; 736155682Smarkm esac 736255682Smarkm 736390926Snectar case $age in 7364178825Sdfr 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]) ;; 736555682Smarkm *) 7366233294Sstas func_error "AGE \`$age' must be a nonnegative integer" 7367233294Sstas func_fatal_error "\`$vinfo' is not valid version information" 736855682Smarkm ;; 736955682Smarkm esac 737055682Smarkm 7371127808Snectar if test "$age" -gt "$current"; then 7372233294Sstas func_error "AGE \`$age' is greater than the current interface number \`$current'" 7373233294Sstas func_fatal_error "\`$vinfo' is not valid version information" 737455682Smarkm fi 737555682Smarkm 737655682Smarkm # Calculate the version variables. 737755682Smarkm major= 737855682Smarkm versuffix= 737955682Smarkm verstring= 738090926Snectar case $version_type in 738155682Smarkm none) ;; 738255682Smarkm 738390926Snectar darwin) 738490926Snectar # Like Linux, but with the current version available in 738590926Snectar # verstring for coding it into the library header 7386233294Sstas func_arith $current - $age 7387233294Sstas major=.$func_arith_result 738890926Snectar versuffix="$major.$age.$revision" 738990926Snectar # Darwin ld doesn't like 0 for these options... 7390233294Sstas func_arith $current + 1 7391233294Sstas minor_current=$func_arith_result 7392233294Sstas xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 7393233294Sstas verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 739490926Snectar ;; 739590926Snectar 739690926Snectar freebsd-aout) 739790926Snectar major=".$current" 739890926Snectar versuffix=".$current.$revision"; 739990926Snectar ;; 740090926Snectar 740190926Snectar freebsd-elf) 740290926Snectar major=".$current" 7403233294Sstas versuffix=".$current" 740490926Snectar ;; 740590926Snectar 7406127808Snectar irix | nonstopux) 7407233294Sstas if test "X$lt_irix_increment" = "Xno"; then 7408233294Sstas func_arith $current - $age 7409233294Sstas else 7410233294Sstas func_arith $current - $age + 1 7411233294Sstas fi 7412233294Sstas major=$func_arith_result 741372445Sassar 7414127808Snectar case $version_type in 7415127808Snectar nonstopux) verstring_prefix=nonstopux ;; 7416127808Snectar *) verstring_prefix=sgi ;; 7417127808Snectar esac 7418127808Snectar verstring="$verstring_prefix$major.$revision" 7419127808Snectar 742072445Sassar # Add in all the interfaces that we are compatible with. 742172445Sassar loop=$revision 7422127808Snectar while test "$loop" -ne 0; do 7423233294Sstas func_arith $revision - $loop 7424233294Sstas iface=$func_arith_result 7425233294Sstas func_arith $loop - 1 7426233294Sstas loop=$func_arith_result 7427127808Snectar verstring="$verstring_prefix$major.$iface:$verstring" 742872445Sassar done 742990926Snectar 743090926Snectar # Before this point, $major must not contain `.'. 743190926Snectar major=.$major 743290926Snectar versuffix="$major.$revision" 743372445Sassar ;; 743472445Sassar 743555682Smarkm linux) 7436233294Sstas func_arith $current - $age 7437233294Sstas major=.$func_arith_result 743855682Smarkm versuffix="$major.$age.$revision" 743955682Smarkm ;; 744055682Smarkm 744155682Smarkm osf) 7442233294Sstas func_arith $current - $age 7443233294Sstas major=.$func_arith_result 744455682Smarkm versuffix=".$current.$age.$revision" 744555682Smarkm verstring="$current.$age.$revision" 744655682Smarkm 744755682Smarkm # Add in all the interfaces that we are compatible with. 744855682Smarkm loop=$age 7449127808Snectar while test "$loop" -ne 0; do 7450233294Sstas func_arith $current - $loop 7451233294Sstas iface=$func_arith_result 7452233294Sstas func_arith $loop - 1 7453233294Sstas loop=$func_arith_result 745455682Smarkm verstring="$verstring:${iface}.0" 745555682Smarkm done 745655682Smarkm 745755682Smarkm # Make executables depend on our current version. 7458233294Sstas func_append verstring ":${current}.0" 745955682Smarkm ;; 746055682Smarkm 7461233294Sstas qnx) 7462233294Sstas major=".$current" 7463233294Sstas versuffix=".$current" 7464233294Sstas ;; 7465233294Sstas 746655682Smarkm sunos) 746755682Smarkm major=".$current" 746855682Smarkm versuffix=".$current.$revision" 746955682Smarkm ;; 747055682Smarkm 747155682Smarkm windows) 747290926Snectar # Use '-' rather than '.', since we only want one 747390926Snectar # extension on DOS 8.3 filesystems. 7474233294Sstas func_arith $current - $age 7475233294Sstas major=$func_arith_result 747690926Snectar versuffix="-$major" 747755682Smarkm ;; 747855682Smarkm 747955682Smarkm *) 7480233294Sstas func_fatal_configuration "unknown library version type \`$version_type'" 748155682Smarkm ;; 748255682Smarkm esac 748355682Smarkm 748455682Smarkm # Clear the version info if we defaulted, and they specified a release. 748555682Smarkm if test -z "$vinfo" && test -n "$release"; then 748655682Smarkm major= 7487102644Snectar case $version_type in 7488102644Snectar darwin) 7489102644Snectar # we can't check for "0.0" in archive_cmds due to quoting 7490102644Snectar # problems, so we reset it completely 7491127808Snectar verstring= 7492102644Snectar ;; 7493102644Snectar *) 7494102644Snectar verstring="0.0" 7495102644Snectar ;; 7496102644Snectar esac 749772445Sassar if test "$need_version" = no; then 749872445Sassar versuffix= 749972445Sassar else 750055682Smarkm versuffix=".0.0" 750172445Sassar fi 750255682Smarkm fi 750355682Smarkm 750472445Sassar # Remove version info from name if versioning should be avoided 750572445Sassar if test "$avoid_version" = yes && test "$need_version" = no; then 750672445Sassar major= 750772445Sassar versuffix= 750872445Sassar verstring="" 750972445Sassar fi 751072445Sassar 751155682Smarkm # Check to see if the archive will have undefined symbols. 751255682Smarkm if test "$allow_undefined" = yes; then 751355682Smarkm if test "$allow_undefined_flag" = unsupported; then 7514233294Sstas func_warning "undefined symbols not allowed in $host shared libraries" 751555682Smarkm build_libtool_libs=no 751655682Smarkm build_old_libs=yes 751755682Smarkm fi 751855682Smarkm else 751955682Smarkm # Don't allow undefined symbols. 752055682Smarkm allow_undefined_flag="$no_undefined_flag" 752155682Smarkm fi 7522233294Sstas 752355682Smarkm fi 752455682Smarkm 7525233294Sstas func_generate_dlsyms "$libname" "$libname" "yes" 7526233294Sstas func_append libobjs " $symfileobj" 7527233294Sstas test "X$libobjs" = "X " && libobjs= 7528233294Sstas 7529233294Sstas if test "$opt_mode" != relink; then 7530127808Snectar # Remove our outputs, but don't remove object files since they 7531127808Snectar # may have been created when compiling PIC objects. 7532127808Snectar removelist= 7533233294Sstas tempremovelist=`$ECHO "$output_objdir/*"` 7534127808Snectar for p in $tempremovelist; do 7535127808Snectar case $p in 7536233294Sstas *.$objext | *.gcno) 7537127808Snectar ;; 7538127808Snectar $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 7539178825Sdfr if test "X$precious_files_regex" != "X"; then 7540233294Sstas if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 7541233294Sstas then 7542178825Sdfr continue 7543178825Sdfr fi 7544127808Snectar fi 7545233294Sstas func_append removelist " $p" 7546127808Snectar ;; 7547127808Snectar *) ;; 7548127808Snectar esac 7549127808Snectar done 7550233294Sstas test -n "$removelist" && \ 7551233294Sstas func_show_eval "${RM}r \$removelist" 755255682Smarkm fi 755355682Smarkm 755455682Smarkm # Now set the variables for building old libraries. 755555682Smarkm if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 7556233294Sstas func_append oldlibs " $output_objdir/$libname.$libext" 755755682Smarkm 755855682Smarkm # Transform .lo files to .o files. 7559233294Sstas oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 756055682Smarkm fi 756155682Smarkm 756272445Sassar # Eliminate all temporary directories. 7563233294Sstas #for path in $notinst_path; do 7564233294Sstas # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 7565233294Sstas # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 7566233294Sstas # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 7567233294Sstas #done 756872445Sassar 756972445Sassar if test -n "$xrpath"; then 757072445Sassar # If the user specified any rpath flags, then add them. 757172445Sassar temp_xrpath= 757272445Sassar for libdir in $xrpath; do 7573233294Sstas func_replace_sysroot "$libdir" 7574233294Sstas func_append temp_xrpath " -R$func_replace_sysroot_result" 757572445Sassar case "$finalize_rpath " in 757672445Sassar *" $libdir "*) ;; 7577233294Sstas *) func_append finalize_rpath " $libdir" ;; 757872445Sassar esac 757972445Sassar done 7580127808Snectar if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 758172445Sassar dependency_libs="$temp_xrpath $dependency_libs" 758272445Sassar fi 758372445Sassar fi 758472445Sassar 758572445Sassar # Make sure dlfiles contains only unique files that won't be dlpreopened 758672445Sassar old_dlfiles="$dlfiles" 758772445Sassar dlfiles= 758872445Sassar for lib in $old_dlfiles; do 758972445Sassar case " $dlprefiles $dlfiles " in 759072445Sassar *" $lib "*) ;; 7591233294Sstas *) func_append dlfiles " $lib" ;; 759272445Sassar esac 759372445Sassar done 759472445Sassar 759572445Sassar # Make sure dlprefiles contains only unique files 759672445Sassar old_dlprefiles="$dlprefiles" 759772445Sassar dlprefiles= 759872445Sassar for lib in $old_dlprefiles; do 759972445Sassar case "$dlprefiles " in 760072445Sassar *" $lib "*) ;; 7601233294Sstas *) func_append dlprefiles " $lib" ;; 760272445Sassar esac 760372445Sassar done 760472445Sassar 760555682Smarkm if test "$build_libtool_libs" = yes; then 760672445Sassar if test -n "$rpath"; then 760790926Snectar case $host in 7608233294Sstas *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 760972445Sassar # these systems don't actually have a c library (as such)! 761072445Sassar ;; 761190926Snectar *-*-rhapsody* | *-*-darwin1.[012]) 761290926Snectar # Rhapsody C library is in the System framework 7613233294Sstas func_append deplibs " System.ltframework" 761490926Snectar ;; 761590926Snectar *-*-netbsd*) 761690926Snectar # Don't link with libc until the a.out ld.so is fixed. 761790926Snectar ;; 7618178825Sdfr *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 7619102644Snectar # Do not include libc due to us having libc/libc_r. 7620102644Snectar ;; 7621178825Sdfr *-*-sco3.2v5* | *-*-sco5v6*) 7622178825Sdfr # Causes problems with __ctype 7623178825Sdfr ;; 7624178825Sdfr *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7625178825Sdfr # Compiler inserts libc in the correct place for threads to work 7626178825Sdfr ;; 7627233294Sstas *) 762890926Snectar # Add libc to deplibs on all other systems if necessary. 7629127808Snectar if test "$build_libtool_need_lc" = "yes"; then 7630233294Sstas func_append deplibs " -lc" 763190926Snectar fi 763272445Sassar ;; 763372445Sassar esac 763472445Sassar fi 763572445Sassar 763672445Sassar # Transform deplibs into only deplibs that can be linked in shared. 763772445Sassar name_save=$name 763872445Sassar libname_save=$libname 763972445Sassar release_save=$release 764072445Sassar versuffix_save=$versuffix 764172445Sassar major_save=$major 764272445Sassar # I'm not sure if I'm treating the release correctly. I think 764372445Sassar # release should show up in the -l (ie -lgmp5) so we don't want to 764472445Sassar # add it in twice. Is that correct? 764572445Sassar release="" 764672445Sassar versuffix="" 764772445Sassar major="" 764872445Sassar newdeplibs= 764972445Sassar droppeddeps=no 765090926Snectar case $deplibs_check_method in 765172445Sassar pass_all) 765272445Sassar # Don't check for shared/static. Everything works. 765372445Sassar # This might be a little naive. We might want to check 765472445Sassar # whether the library exists or not. But this is on 765572445Sassar # osf3 & osf4 and I'm not really sure... Just 7656127808Snectar # implementing what was already the behavior. 765772445Sassar newdeplibs=$deplibs 765872445Sassar ;; 765972445Sassar test_compile) 766072445Sassar # This code stresses the "libraries are programs" paradigm to its 766172445Sassar # limits. Maybe even breaks it. We compile a program, linking it 766272445Sassar # against the deplibs as a proxy for the library. Then we can check 766372445Sassar # whether they linked in statically or dynamically with ldd. 7664233294Sstas $opt_dry_run || $RM conftest.c 766572445Sassar cat > conftest.c <<EOF 766672445Sassar int main() { return 0; } 766755682SmarkmEOF 7668233294Sstas $opt_dry_run || $RM conftest 7669233294Sstas if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 767072445Sassar ldd_output=`ldd conftest` 767172445Sassar for i in $deplibs; do 7672233294Sstas case $i in 7673233294Sstas -l*) 7674233294Sstas func_stripname -l '' "$i" 7675233294Sstas name=$func_stripname_result 7676127808Snectar if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7677127808Snectar case " $predeps $postdeps " in 7678127808Snectar *" $i "*) 7679233294Sstas func_append newdeplibs " $i" 7680127808Snectar i="" 7681127808Snectar ;; 7682127808Snectar esac 7683233294Sstas fi 7684127808Snectar if test -n "$i" ; then 7685233294Sstas libname=`eval "\\$ECHO \"$libname_spec\""` 7686233294Sstas deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7687233294Sstas set dummy $deplib_matches; shift 7688233294Sstas deplib_match=$1 7689127808Snectar if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7690233294Sstas func_append newdeplibs " $i" 7691127808Snectar else 7692127808Snectar droppeddeps=yes 7693233294Sstas echo 7694233294Sstas $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7695233294Sstas echo "*** I have the capability to make that library automatically link in when" 7696233294Sstas echo "*** you link to this library. But I can only do this if you have a" 7697233294Sstas echo "*** shared version of the library, which I believe you do not have" 7698233294Sstas echo "*** because a test_compile did reveal that the linker did not use it for" 7699233294Sstas echo "*** its dynamic dependency list that programs get resolved with at runtime." 7700127808Snectar fi 770172445Sassar fi 7702233294Sstas ;; 7703233294Sstas *) 7704233294Sstas func_append newdeplibs " $i" 7705233294Sstas ;; 7706233294Sstas esac 770772445Sassar done 770872445Sassar else 7709127808Snectar # Error occurred in the first compile. Let's try to salvage 7710127808Snectar # the situation: Compile a separate program for each library. 771172445Sassar for i in $deplibs; do 7712233294Sstas case $i in 7713233294Sstas -l*) 7714233294Sstas func_stripname -l '' "$i" 7715233294Sstas name=$func_stripname_result 7716233294Sstas $opt_dry_run || $RM conftest 7717233294Sstas if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 771872445Sassar ldd_output=`ldd conftest` 7719127808Snectar if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7720127808Snectar case " $predeps $postdeps " in 7721127808Snectar *" $i "*) 7722233294Sstas func_append newdeplibs " $i" 7723127808Snectar i="" 7724127808Snectar ;; 7725127808Snectar esac 772672445Sassar fi 7727127808Snectar if test -n "$i" ; then 7728233294Sstas libname=`eval "\\$ECHO \"$libname_spec\""` 7729233294Sstas deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7730233294Sstas set dummy $deplib_matches; shift 7731233294Sstas deplib_match=$1 7732127808Snectar if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7733233294Sstas func_append newdeplibs " $i" 7734127808Snectar else 7735127808Snectar droppeddeps=yes 7736233294Sstas echo 7737233294Sstas $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7738233294Sstas echo "*** I have the capability to make that library automatically link in when" 7739233294Sstas echo "*** you link to this library. But I can only do this if you have a" 7740233294Sstas echo "*** shared version of the library, which you do not appear to have" 7741233294Sstas echo "*** because a test_compile did reveal that the linker did not use this one" 7742233294Sstas echo "*** as a dynamic dependency that programs can get resolved with at runtime." 7743127808Snectar fi 7744127808Snectar fi 774572445Sassar else 774672445Sassar droppeddeps=yes 7747233294Sstas echo 7748233294Sstas $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 7749233294Sstas echo "*** make it link in! You will probably need to install it or some" 7750233294Sstas echo "*** library that it depends on before this library will be fully" 7751233294Sstas echo "*** functional. Installing it before continuing would be even better." 775272445Sassar fi 7753233294Sstas ;; 7754233294Sstas *) 7755233294Sstas func_append newdeplibs " $i" 7756233294Sstas ;; 7757233294Sstas esac 775872445Sassar done 775972445Sassar fi 776072445Sassar ;; 776172445Sassar file_magic*) 7762233294Sstas set dummy $deplibs_check_method; shift 7763233294Sstas file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 776472445Sassar for a_deplib in $deplibs; do 7765233294Sstas case $a_deplib in 7766233294Sstas -l*) 7767233294Sstas func_stripname -l '' "$a_deplib" 7768233294Sstas name=$func_stripname_result 7769127808Snectar if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7770127808Snectar case " $predeps $postdeps " in 7771127808Snectar *" $a_deplib "*) 7772233294Sstas func_append newdeplibs " $a_deplib" 7773127808Snectar a_deplib="" 7774127808Snectar ;; 7775127808Snectar esac 7776127808Snectar fi 7777127808Snectar if test -n "$a_deplib" ; then 7778233294Sstas libname=`eval "\\$ECHO \"$libname_spec\""` 7779233294Sstas if test -n "$file_magic_glob"; then 7780233294Sstas libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 7781233294Sstas else 7782233294Sstas libnameglob=$libname 7783233294Sstas fi 7784233294Sstas test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 7785127808Snectar for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7786233294Sstas if test "$want_nocaseglob" = yes; then 7787233294Sstas shopt -s nocaseglob 7788233294Sstas potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7789233294Sstas $nocaseglob 7790233294Sstas else 7791233294Sstas potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7792233294Sstas fi 7793127808Snectar for potent_lib in $potential_libs; do 779472445Sassar # Follow soft links. 7795233294Sstas if ls -lLd "$potent_lib" 2>/dev/null | 7796233294Sstas $GREP " -> " >/dev/null; then 779772445Sassar continue 779872445Sassar fi 779972445Sassar # The statement above tries to avoid entering an 780072445Sassar # endless loop below, in case of cyclic links. 780172445Sassar # We might still enter an endless loop, since a link 780272445Sassar # loop can be closed while we follow links, 780372445Sassar # but so what? 780472445Sassar potlib="$potent_lib" 780572445Sassar while test -h "$potlib" 2>/dev/null; do 7806127808Snectar potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 780790926Snectar case $potliblink in 780872445Sassar [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 7809233294Sstas *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 781072445Sassar esac 781172445Sassar done 7812233294Sstas if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 7813233294Sstas $SED -e 10q | 7814233294Sstas $EGREP "$file_magic_regex" > /dev/null; then 7815233294Sstas func_append newdeplibs " $a_deplib" 781672445Sassar a_deplib="" 781772445Sassar break 2 781872445Sassar fi 7819127808Snectar done 7820127808Snectar done 7821127808Snectar fi 782272445Sassar if test -n "$a_deplib" ; then 782372445Sassar droppeddeps=yes 7824233294Sstas echo 7825233294Sstas $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7826233294Sstas echo "*** I have the capability to make that library automatically link in when" 7827233294Sstas echo "*** you link to this library. But I can only do this if you have a" 7828233294Sstas echo "*** shared version of the library, which you do not appear to have" 7829233294Sstas echo "*** because I did check the linker path looking for a file starting" 7830127808Snectar if test -z "$potlib" ; then 7831233294Sstas $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 7832127808Snectar else 7833233294Sstas $ECHO "*** with $libname and none of the candidates passed a file format test" 7834233294Sstas $ECHO "*** using a file magic. Last file checked: $potlib" 7835127808Snectar fi 783672445Sassar fi 7837233294Sstas ;; 7838233294Sstas *) 783972445Sassar # Add a -L argument. 7840233294Sstas func_append newdeplibs " $a_deplib" 7841233294Sstas ;; 7842233294Sstas esac 784372445Sassar done # Gone through all deplibs. 784472445Sassar ;; 784590926Snectar match_pattern*) 7846233294Sstas set dummy $deplibs_check_method; shift 7847233294Sstas match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 784890926Snectar for a_deplib in $deplibs; do 7849233294Sstas case $a_deplib in 7850233294Sstas -l*) 7851233294Sstas func_stripname -l '' "$a_deplib" 7852233294Sstas name=$func_stripname_result 7853127808Snectar if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7854127808Snectar case " $predeps $postdeps " in 7855127808Snectar *" $a_deplib "*) 7856233294Sstas func_append newdeplibs " $a_deplib" 7857127808Snectar a_deplib="" 7858127808Snectar ;; 7859127808Snectar esac 7860127808Snectar fi 7861127808Snectar if test -n "$a_deplib" ; then 7862233294Sstas libname=`eval "\\$ECHO \"$libname_spec\""` 7863127808Snectar for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7864127808Snectar potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 7865127808Snectar for potent_lib in $potential_libs; do 7866127808Snectar potlib="$potent_lib" # see symlink-check above in file_magic test 7867233294Sstas if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 7868233294Sstas $EGREP "$match_pattern_regex" > /dev/null; then 7869233294Sstas func_append newdeplibs " $a_deplib" 7870127808Snectar a_deplib="" 7871127808Snectar break 2 7872127808Snectar fi 7873127808Snectar done 787490926Snectar done 7875127808Snectar fi 787690926Snectar if test -n "$a_deplib" ; then 787790926Snectar droppeddeps=yes 7878233294Sstas echo 7879233294Sstas $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7880233294Sstas echo "*** I have the capability to make that library automatically link in when" 7881233294Sstas echo "*** you link to this library. But I can only do this if you have a" 7882233294Sstas echo "*** shared version of the library, which you do not appear to have" 7883233294Sstas echo "*** because I did check the linker path looking for a file starting" 7884127808Snectar if test -z "$potlib" ; then 7885233294Sstas $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 7886127808Snectar else 7887233294Sstas $ECHO "*** with $libname and none of the candidates passed a file format test" 7888233294Sstas $ECHO "*** using a regex pattern. Last file checked: $potlib" 7889127808Snectar fi 789090926Snectar fi 7891233294Sstas ;; 7892233294Sstas *) 789390926Snectar # Add a -L argument. 7894233294Sstas func_append newdeplibs " $a_deplib" 7895233294Sstas ;; 7896233294Sstas esac 789790926Snectar done # Gone through all deplibs. 789890926Snectar ;; 789972445Sassar none | unknown | *) 790072445Sassar newdeplibs="" 7901233294Sstas tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7902127808Snectar if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7903127808Snectar for i in $predeps $postdeps ; do 7904127808Snectar # can't use Xsed below, because $i might contain '/' 7905233294Sstas tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 7906127808Snectar done 7907127808Snectar fi 7908233294Sstas case $tmp_deplibs in 7909233294Sstas *[!\ \ ]*) 7910233294Sstas echo 791172445Sassar if test "X$deplibs_check_method" = "Xnone"; then 7912233294Sstas echo "*** Warning: inter-library dependencies are not supported in this platform." 791372445Sassar else 7914233294Sstas echo "*** Warning: inter-library dependencies are not known to be supported." 791572445Sassar fi 7916233294Sstas echo "*** All declared inter-library dependencies are being dropped." 791772445Sassar droppeddeps=yes 7918233294Sstas ;; 7919233294Sstas esac 792072445Sassar ;; 792172445Sassar esac 792272445Sassar versuffix=$versuffix_save 792372445Sassar major=$major_save 792472445Sassar release=$release_save 792572445Sassar libname=$libname_save 792672445Sassar name=$name_save 792772445Sassar 792890926Snectar case $host in 792990926Snectar *-*-rhapsody* | *-*-darwin1.[012]) 7930233294Sstas # On Rhapsody replace the C library with the System framework 7931233294Sstas newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 793290926Snectar ;; 793390926Snectar esac 793490926Snectar 793572445Sassar if test "$droppeddeps" = yes; then 793672445Sassar if test "$module" = yes; then 7937233294Sstas echo 7938233294Sstas echo "*** Warning: libtool could not satisfy all declared inter-library" 7939233294Sstas $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 7940233294Sstas echo "*** a static module, that should work as long as the dlopening" 7941233294Sstas echo "*** application is linked with the -dlopen flag." 794272445Sassar if test -z "$global_symbol_pipe"; then 7943233294Sstas echo 7944233294Sstas echo "*** However, this would only work if libtool was able to extract symbol" 7945233294Sstas echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 7946233294Sstas echo "*** not find such a program. So, this module is probably useless." 7947233294Sstas echo "*** \`nm' from GNU binutils and a full rebuild may help." 794872445Sassar fi 794972445Sassar if test "$build_old_libs" = no; then 795072445Sassar oldlibs="$output_objdir/$libname.$libext" 795172445Sassar build_libtool_libs=module 795272445Sassar build_old_libs=yes 795372445Sassar else 795472445Sassar build_libtool_libs=no 795572445Sassar fi 795672445Sassar else 7957233294Sstas echo "*** The inter-library dependencies that have been dropped here will be" 7958233294Sstas echo "*** automatically added whenever a program is linked with this library" 7959233294Sstas echo "*** or is declared to -dlopen it." 796090926Snectar 7961127808Snectar if test "$allow_undefined" = no; then 7962233294Sstas echo 7963233294Sstas echo "*** Since this library must not contain undefined symbols," 7964233294Sstas echo "*** because either the platform does not support them or" 7965233294Sstas echo "*** it was explicitly requested with -no-undefined," 7966233294Sstas echo "*** libtool will only create a static version of it." 796790926Snectar if test "$build_old_libs" = no; then 796890926Snectar oldlibs="$output_objdir/$libname.$libext" 796990926Snectar build_libtool_libs=module 797090926Snectar build_old_libs=yes 797190926Snectar else 797290926Snectar build_libtool_libs=no 797390926Snectar fi 797490926Snectar fi 797572445Sassar fi 797672445Sassar fi 797772445Sassar # Done checking deplibs! 797872445Sassar deplibs=$newdeplibs 797972445Sassar fi 7980233294Sstas # Time to change all our "foo.ltframework" stuff back to "-framework foo" 7981233294Sstas case $host in 7982233294Sstas *-*-darwin*) 7983233294Sstas newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7984233294Sstas new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7985233294Sstas deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7986233294Sstas ;; 7987233294Sstas esac 798872445Sassar 7989178825Sdfr # move library search paths that coincide with paths to not yet 7990178825Sdfr # installed libraries to the beginning of the library search list 7991178825Sdfr new_libs= 7992178825Sdfr for path in $notinst_path; do 7993178825Sdfr case " $new_libs " in 7994178825Sdfr *" -L$path/$objdir "*) ;; 7995178825Sdfr *) 7996178825Sdfr case " $deplibs " in 7997178825Sdfr *" -L$path/$objdir "*) 7998233294Sstas func_append new_libs " -L$path/$objdir" ;; 7999178825Sdfr esac 8000178825Sdfr ;; 8001178825Sdfr esac 8002178825Sdfr done 8003178825Sdfr for deplib in $deplibs; do 8004178825Sdfr case $deplib in 8005178825Sdfr -L*) 8006178825Sdfr case " $new_libs " in 8007178825Sdfr *" $deplib "*) ;; 8008233294Sstas *) func_append new_libs " $deplib" ;; 8009178825Sdfr esac 8010178825Sdfr ;; 8011233294Sstas *) func_append new_libs " $deplib" ;; 8012178825Sdfr esac 8013178825Sdfr done 8014178825Sdfr deplibs="$new_libs" 8015178825Sdfr 801672445Sassar # All the library-specific variables (install_libdir is set above). 801772445Sassar library_names= 801872445Sassar old_library= 801972445Sassar dlname= 802072445Sassar 802172445Sassar # Test again, we may have decided not to build it any more 802272445Sassar if test "$build_libtool_libs" = yes; then 8023127808Snectar if test "$hardcode_into_libs" = yes; then 802472445Sassar # Hardcode the library paths 802572445Sassar hardcode_libdirs= 802672445Sassar dep_rpath= 802772445Sassar rpath="$finalize_rpath" 8028233294Sstas test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 802972445Sassar for libdir in $rpath; do 803072445Sassar if test -n "$hardcode_libdir_flag_spec"; then 803172445Sassar if test -n "$hardcode_libdir_separator"; then 8032233294Sstas func_replace_sysroot "$libdir" 8033233294Sstas libdir=$func_replace_sysroot_result 803472445Sassar if test -z "$hardcode_libdirs"; then 803572445Sassar hardcode_libdirs="$libdir" 803672445Sassar else 803772445Sassar # Just accumulate the unique libdirs. 803890926Snectar case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 803972445Sassar *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 804072445Sassar ;; 804172445Sassar *) 8042233294Sstas func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 804372445Sassar ;; 804472445Sassar esac 804572445Sassar fi 804672445Sassar else 804772445Sassar eval flag=\"$hardcode_libdir_flag_spec\" 8048233294Sstas func_append dep_rpath " $flag" 804972445Sassar fi 805072445Sassar elif test -n "$runpath_var"; then 805172445Sassar case "$perm_rpath " in 805272445Sassar *" $libdir "*) ;; 8053233294Sstas *) func_apped perm_rpath " $libdir" ;; 805472445Sassar esac 805572445Sassar fi 805672445Sassar done 805772445Sassar # Substitute the hardcoded libdirs into the rpath. 805872445Sassar if test -n "$hardcode_libdir_separator" && 805972445Sassar test -n "$hardcode_libdirs"; then 806072445Sassar libdir="$hardcode_libdirs" 8061127808Snectar if test -n "$hardcode_libdir_flag_spec_ld"; then 8062127808Snectar eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 8063127808Snectar else 8064127808Snectar eval dep_rpath=\"$hardcode_libdir_flag_spec\" 8065127808Snectar fi 806672445Sassar fi 806772445Sassar if test -n "$runpath_var" && test -n "$perm_rpath"; then 806872445Sassar # We should set the runpath_var. 806972445Sassar rpath= 807072445Sassar for dir in $perm_rpath; do 8071233294Sstas func_append rpath "$dir:" 807272445Sassar done 807372445Sassar eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 807472445Sassar fi 807572445Sassar test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 807672445Sassar fi 807772445Sassar 807872445Sassar shlibpath="$finalize_shlibpath" 8079233294Sstas test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 808072445Sassar if test -n "$shlibpath"; then 808172445Sassar eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 808272445Sassar fi 808372445Sassar 808455682Smarkm # Get the real and link names of the library. 8085178825Sdfr eval shared_ext=\"$shrext_cmds\" 808655682Smarkm eval library_names=\"$library_names_spec\" 808755682Smarkm set dummy $library_names 8088233294Sstas shift 8089233294Sstas realname="$1" 8090233294Sstas shift 809155682Smarkm 809255682Smarkm if test -n "$soname_spec"; then 809355682Smarkm eval soname=\"$soname_spec\" 809455682Smarkm else 809555682Smarkm soname="$realname" 809655682Smarkm fi 8097127808Snectar if test -z "$dlname"; then 8098127808Snectar dlname=$soname 8099127808Snectar fi 810055682Smarkm 810155682Smarkm lib="$output_objdir/$realname" 8102178825Sdfr linknames= 810355682Smarkm for link 810455682Smarkm do 8105233294Sstas func_append linknames " $link" 810655682Smarkm done 810755682Smarkm 810872445Sassar # Use standard objects if they are pic 8109233294Sstas test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 8110233294Sstas test "X$libobjs" = "X " && libobjs= 811172445Sassar 8112233294Sstas delfiles= 8113233294Sstas if test -n "$export_symbols" && test -n "$include_expsyms"; then 8114233294Sstas $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 8115233294Sstas export_symbols="$output_objdir/$libname.uexp" 8116233294Sstas func_append delfiles " $export_symbols" 8117233294Sstas fi 8118233294Sstas 8119233294Sstas orig_export_symbols= 8120233294Sstas case $host_os in 8121233294Sstas cygwin* | mingw* | cegcc*) 8122233294Sstas if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 8123233294Sstas # exporting using user supplied symfile 8124233294Sstas if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 8125233294Sstas # and it's NOT already a .def file. Must figure out 8126233294Sstas # which of the given symbols are data symbols and tag 8127233294Sstas # them as such. So, trigger use of export_symbols_cmds. 8128233294Sstas # export_symbols gets reassigned inside the "prepare 8129233294Sstas # the list of exported symbols" if statement, so the 8130233294Sstas # include_expsyms logic still works. 8131233294Sstas orig_export_symbols="$export_symbols" 8132233294Sstas export_symbols= 8133233294Sstas always_export_symbols=yes 8134233294Sstas fi 8135233294Sstas fi 8136233294Sstas ;; 8137233294Sstas esac 8138233294Sstas 813972445Sassar # Prepare the list of exported symbols 814072445Sassar if test -z "$export_symbols"; then 814172445Sassar if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 8142233294Sstas func_verbose "generating symbol list for \`$libname.la'" 814372445Sassar export_symbols="$output_objdir/$libname.exp" 8144233294Sstas $opt_dry_run || $RM $export_symbols 8145127808Snectar cmds=$export_symbols_cmds 8146102644Snectar save_ifs="$IFS"; IFS='~' 8147233294Sstas for cmd1 in $cmds; do 814872445Sassar IFS="$save_ifs" 8149233294Sstas # Take the normal branch if the nm_file_list_spec branch 8150233294Sstas # doesn't work or if tool conversion is not needed. 8151233294Sstas case $nm_file_list_spec~$to_tool_file_cmd in 8152233294Sstas *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 8153233294Sstas try_normal_branch=yes 8154233294Sstas eval cmd=\"$cmd1\" 8155233294Sstas func_len " $cmd" 8156233294Sstas len=$func_len_result 8157233294Sstas ;; 8158233294Sstas *) 8159233294Sstas try_normal_branch=no 8160233294Sstas ;; 8161233294Sstas esac 8162233294Sstas if test "$try_normal_branch" = yes \ 8163233294Sstas && { test "$len" -lt "$max_cmd_len" \ 8164233294Sstas || test "$max_cmd_len" -le -1; } 8165233294Sstas then 8166233294Sstas func_show_eval "$cmd" 'exit $?' 8167233294Sstas skipped_export=false 8168233294Sstas elif test -n "$nm_file_list_spec"; then 8169233294Sstas func_basename "$output" 8170233294Sstas output_la=$func_basename_result 8171233294Sstas save_libobjs=$libobjs 8172233294Sstas save_output=$output 8173233294Sstas output=${output_objdir}/${output_la}.nm 8174233294Sstas func_to_tool_file "$output" 8175233294Sstas libobjs=$nm_file_list_spec$func_to_tool_file_result 8176233294Sstas func_append delfiles " $output" 8177233294Sstas func_verbose "creating $NM input file list: $output" 8178233294Sstas for obj in $save_libobjs; do 8179233294Sstas func_to_tool_file "$obj" 8180233294Sstas $ECHO "$func_to_tool_file_result" 8181233294Sstas done > "$output" 8182233294Sstas eval cmd=\"$cmd1\" 8183233294Sstas func_show_eval "$cmd" 'exit $?' 8184233294Sstas output=$save_output 8185233294Sstas libobjs=$save_libobjs 8186233294Sstas skipped_export=false 8187127808Snectar else 8188233294Sstas # The command line is too long to execute in one step. 8189233294Sstas func_verbose "using reloadable object file for export list..." 8190233294Sstas skipped_export=: 8191178825Sdfr # Break out early, otherwise skipped_export may be 8192178825Sdfr # set to false by a later but shorter cmd. 8193178825Sdfr break 8194127808Snectar fi 819572445Sassar done 819672445Sassar IFS="$save_ifs" 8197233294Sstas if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 8198233294Sstas func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8199233294Sstas func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 820072445Sassar fi 820155682Smarkm fi 820272445Sassar fi 820355682Smarkm 820472445Sassar if test -n "$export_symbols" && test -n "$include_expsyms"; then 8205233294Sstas tmp_export_symbols="$export_symbols" 8206233294Sstas test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8207233294Sstas $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 820872445Sassar fi 820972445Sassar 8210233294Sstas if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 8211233294Sstas # The given exports_symbols file has to be filtered, so filter it. 8212233294Sstas func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8213233294Sstas # FIXME: $output_objdir/$libname.filter potentially contains lots of 8214233294Sstas # 's' commands which not all seds can handle. GNU sed should be fine 8215233294Sstas # though. Also, the filter scales superlinearly with the number of 8216233294Sstas # global variables. join(1) would be nice here, but unfortunately 8217233294Sstas # isn't a blessed tool. 8218233294Sstas $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8219233294Sstas func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8220233294Sstas export_symbols=$output_objdir/$libname.def 8221233294Sstas $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8222233294Sstas fi 8223233294Sstas 8224127808Snectar tmp_deplibs= 8225127808Snectar for test_deplib in $deplibs; do 8226233294Sstas case " $convenience " in 8227233294Sstas *" $test_deplib "*) ;; 8228233294Sstas *) 8229233294Sstas func_append tmp_deplibs " $test_deplib" 8230233294Sstas ;; 8231233294Sstas esac 8232127808Snectar done 8233178825Sdfr deplibs="$tmp_deplibs" 8234127808Snectar 823572445Sassar if test -n "$convenience"; then 8236233294Sstas if test -n "$whole_archive_flag_spec" && 8237233294Sstas test "$compiler_needs_object" = yes && 8238233294Sstas test -z "$libobjs"; then 8239233294Sstas # extract the archives, so we have objects to list. 8240233294Sstas # TODO: could optimize this to just extract one archive. 8241233294Sstas whole_archive_flag_spec= 8242233294Sstas fi 824372445Sassar if test -n "$whole_archive_flag_spec"; then 8244127808Snectar save_libobjs=$libobjs 824572445Sassar eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8246233294Sstas test "X$libobjs" = "X " && libobjs= 824772445Sassar else 824872445Sassar gentop="$output_objdir/${outputname}x" 8249233294Sstas func_append generated " $gentop" 825055682Smarkm 8251178825Sdfr func_extract_archives $gentop $convenience 8252233294Sstas func_append libobjs " $func_extract_archives_result" 8253233294Sstas test "X$libobjs" = "X " && libobjs= 825472445Sassar fi 825555682Smarkm fi 8256233294Sstas 825772445Sassar if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 825872445Sassar eval flag=\"$thread_safe_flag_spec\" 8259233294Sstas func_append linker_flags " $flag" 826072445Sassar fi 826172445Sassar 826272445Sassar # Make a backup of the uninstalled library when relinking 8263233294Sstas if test "$opt_mode" = relink; then 8264233294Sstas $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 826572445Sassar fi 826672445Sassar 826755682Smarkm # Do each of the archive commands. 8268127808Snectar if test "$module" = yes && test -n "$module_cmds" ; then 8269127808Snectar if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8270127808Snectar eval test_cmds=\"$module_expsym_cmds\" 8271127808Snectar cmds=$module_expsym_cmds 8272127808Snectar else 8273127808Snectar eval test_cmds=\"$module_cmds\" 8274127808Snectar cmds=$module_cmds 8275127808Snectar fi 8276127808Snectar else 8277233294Sstas if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8278233294Sstas eval test_cmds=\"$archive_expsym_cmds\" 8279233294Sstas cmds=$archive_expsym_cmds 8280233294Sstas else 8281233294Sstas eval test_cmds=\"$archive_cmds\" 8282233294Sstas cmds=$archive_cmds 8283127808Snectar fi 828455682Smarkm fi 8285127808Snectar 8286178825Sdfr if test "X$skipped_export" != "X:" && 8287233294Sstas func_len " $test_cmds" && 8288233294Sstas len=$func_len_result && 8289233294Sstas test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8290127808Snectar : 8291127808Snectar else 8292233294Sstas # The command line is too long to link in one step, link piecewise 8293233294Sstas # or, if using GNU ld and skipped_export is not :, use a linker 8294233294Sstas # script. 8295127808Snectar 8296127808Snectar # Save the value of $output and $libobjs because we want to 8297127808Snectar # use them later. If we have whole_archive_flag_spec, we 8298127808Snectar # want to use save_libobjs as it was before 8299127808Snectar # whole_archive_flag_spec was expanded, because we can't 8300127808Snectar # assume the linker understands whole_archive_flag_spec. 8301127808Snectar # This may have to be revisited, in case too many 8302127808Snectar # convenience libraries get linked in and end up exceeding 8303127808Snectar # the spec. 8304127808Snectar if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 8305127808Snectar save_libobjs=$libobjs 8306127808Snectar fi 8307127808Snectar save_output=$output 8308233294Sstas func_basename "$output" 8309233294Sstas output_la=$func_basename_result 8310127808Snectar 8311127808Snectar # Clear the reloadable object creation command queue and 8312127808Snectar # initialize k to one. 8313127808Snectar test_cmds= 8314127808Snectar concat_cmds= 8315127808Snectar objlist= 8316127808Snectar last_robj= 8317127808Snectar k=1 8318233294Sstas 8319233294Sstas if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 8320233294Sstas output=${output_objdir}/${output_la}.lnkscript 8321233294Sstas func_verbose "creating GNU ld script: $output" 8322233294Sstas echo 'INPUT (' > $output 8323233294Sstas for obj in $save_libobjs 8324233294Sstas do 8325233294Sstas func_to_tool_file "$obj" 8326233294Sstas $ECHO "$func_to_tool_file_result" >> $output 8327233294Sstas done 8328233294Sstas echo ')' >> $output 8329233294Sstas func_append delfiles " $output" 8330233294Sstas func_to_tool_file "$output" 8331233294Sstas output=$func_to_tool_file_result 8332233294Sstas elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 8333233294Sstas output=${output_objdir}/${output_la}.lnk 8334233294Sstas func_verbose "creating linker input file list: $output" 8335233294Sstas : > $output 8336233294Sstas set x $save_libobjs 8337233294Sstas shift 8338233294Sstas firstobj= 8339233294Sstas if test "$compiler_needs_object" = yes; then 8340233294Sstas firstobj="$1 " 8341233294Sstas shift 8342233294Sstas fi 8343233294Sstas for obj 8344233294Sstas do 8345233294Sstas func_to_tool_file "$obj" 8346233294Sstas $ECHO "$func_to_tool_file_result" >> $output 8347233294Sstas done 8348233294Sstas func_append delfiles " $output" 8349233294Sstas func_to_tool_file "$output" 8350233294Sstas output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 8351233294Sstas else 8352233294Sstas if test -n "$save_libobjs"; then 8353233294Sstas func_verbose "creating reloadable object files..." 8354233294Sstas output=$output_objdir/$output_la-${k}.$objext 8355233294Sstas eval test_cmds=\"$reload_cmds\" 8356233294Sstas func_len " $test_cmds" 8357233294Sstas len0=$func_len_result 8358233294Sstas len=$len0 8359233294Sstas 8360233294Sstas # Loop over the list of objects to be linked. 8361233294Sstas for obj in $save_libobjs 8362233294Sstas do 8363233294Sstas func_len " $obj" 8364233294Sstas func_arith $len + $func_len_result 8365233294Sstas len=$func_arith_result 8366233294Sstas if test "X$objlist" = X || 8367233294Sstas test "$len" -lt "$max_cmd_len"; then 8368233294Sstas func_append objlist " $obj" 8369233294Sstas else 8370233294Sstas # The command $test_cmds is almost too long, add a 8371233294Sstas # command to the queue. 8372233294Sstas if test "$k" -eq 1 ; then 8373233294Sstas # The first file doesn't have a previous command to add. 8374233294Sstas reload_objs=$objlist 8375233294Sstas eval concat_cmds=\"$reload_cmds\" 8376233294Sstas else 8377233294Sstas # All subsequent reloadable object files will link in 8378233294Sstas # the last one created. 8379233294Sstas reload_objs="$objlist $last_robj" 8380233294Sstas eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 8381233294Sstas fi 8382233294Sstas last_robj=$output_objdir/$output_la-${k}.$objext 8383233294Sstas func_arith $k + 1 8384233294Sstas k=$func_arith_result 8385233294Sstas output=$output_objdir/$output_la-${k}.$objext 8386233294Sstas objlist=" $obj" 8387233294Sstas func_len " $last_robj" 8388233294Sstas func_arith $len0 + $func_len_result 8389233294Sstas len=$func_arith_result 8390233294Sstas fi 8391233294Sstas done 8392233294Sstas # Handle the remaining objects by creating one last 8393233294Sstas # reloadable object file. All subsequent reloadable object 8394233294Sstas # files will link in the last one created. 8395233294Sstas test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8396233294Sstas reload_objs="$objlist $last_robj" 8397233294Sstas eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 8398233294Sstas if test -n "$last_robj"; then 8399233294Sstas eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8400233294Sstas fi 8401233294Sstas func_append delfiles " $output" 8402233294Sstas 8403127808Snectar else 8404233294Sstas output= 8405233294Sstas fi 8406233294Sstas 8407233294Sstas if ${skipped_export-false}; then 8408233294Sstas func_verbose "generating symbol list for \`$libname.la'" 8409233294Sstas export_symbols="$output_objdir/$libname.exp" 8410233294Sstas $opt_dry_run || $RM $export_symbols 8411233294Sstas libobjs=$output 8412233294Sstas # Append the command to create the export file. 8413233294Sstas test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8414233294Sstas eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 8415233294Sstas if test -n "$last_robj"; then 8416233294Sstas eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8417127808Snectar fi 8418127808Snectar fi 8419127808Snectar 8420233294Sstas test -n "$save_libobjs" && 8421233294Sstas func_verbose "creating a temporary reloadable object file: $output" 8422127808Snectar 8423233294Sstas # Loop through the commands generated above and execute them. 8424233294Sstas save_ifs="$IFS"; IFS='~' 8425233294Sstas for cmd in $concat_cmds; do 8426233294Sstas IFS="$save_ifs" 8427233294Sstas $opt_silent || { 8428233294Sstas func_quote_for_expand "$cmd" 8429233294Sstas eval "func_echo $func_quote_for_expand_result" 8430233294Sstas } 8431233294Sstas $opt_dry_run || eval "$cmd" || { 8432233294Sstas lt_exit=$? 8433127808Snectar 8434233294Sstas # Restore the uninstalled library and exit 8435233294Sstas if test "$opt_mode" = relink; then 8436233294Sstas ( cd "$output_objdir" && \ 8437233294Sstas $RM "${realname}T" && \ 8438233294Sstas $MV "${realname}U" "$realname" ) 8439233294Sstas fi 8440127808Snectar 8441233294Sstas exit $lt_exit 8442233294Sstas } 8443233294Sstas done 8444127808Snectar IFS="$save_ifs" 8445127808Snectar 8446233294Sstas if test -n "$export_symbols_regex" && ${skipped_export-false}; then 8447233294Sstas func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8448233294Sstas func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8449233294Sstas fi 8450233294Sstas fi 8451233294Sstas 8452233294Sstas if ${skipped_export-false}; then 8453233294Sstas if test -n "$export_symbols" && test -n "$include_expsyms"; then 8454233294Sstas tmp_export_symbols="$export_symbols" 8455233294Sstas test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8456233294Sstas $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8457233294Sstas fi 8458233294Sstas 8459233294Sstas if test -n "$orig_export_symbols"; then 8460233294Sstas # The given exports_symbols file has to be filtered, so filter it. 8461233294Sstas func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8462233294Sstas # FIXME: $output_objdir/$libname.filter potentially contains lots of 8463233294Sstas # 's' commands which not all seds can handle. GNU sed should be fine 8464233294Sstas # though. Also, the filter scales superlinearly with the number of 8465233294Sstas # global variables. join(1) would be nice here, but unfortunately 8466233294Sstas # isn't a blessed tool. 8467233294Sstas $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8468233294Sstas func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8469233294Sstas export_symbols=$output_objdir/$libname.def 8470233294Sstas $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8471233294Sstas fi 8472233294Sstas fi 8473233294Sstas 8474127808Snectar libobjs=$output 8475127808Snectar # Restore the value of output. 8476127808Snectar output=$save_output 8477127808Snectar 8478127808Snectar if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 8479127808Snectar eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8480233294Sstas test "X$libobjs" = "X " && libobjs= 8481127808Snectar fi 8482127808Snectar # Expand the library linking commands again to reset the 8483127808Snectar # value of $libobjs for piecewise linking. 8484127808Snectar 8485127808Snectar # Do each of the archive commands. 8486127808Snectar if test "$module" = yes && test -n "$module_cmds" ; then 8487127808Snectar if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8488127808Snectar cmds=$module_expsym_cmds 8489127808Snectar else 8490127808Snectar cmds=$module_cmds 8491127808Snectar fi 8492127808Snectar else 8493233294Sstas if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8494233294Sstas cmds=$archive_expsym_cmds 8495233294Sstas else 8496233294Sstas cmds=$archive_cmds 8497127808Snectar fi 8498127808Snectar fi 8499233294Sstas fi 8500127808Snectar 8501233294Sstas if test -n "$delfiles"; then 8502233294Sstas # Append the command to remove temporary files to $cmds. 8503233294Sstas eval cmds=\"\$cmds~\$RM $delfiles\" 8504127808Snectar fi 8505233294Sstas 8506233294Sstas # Add any objects from preloaded convenience libraries 8507233294Sstas if test -n "$dlprefiles"; then 8508233294Sstas gentop="$output_objdir/${outputname}x" 8509233294Sstas func_append generated " $gentop" 8510233294Sstas 8511233294Sstas func_extract_archives $gentop $dlprefiles 8512233294Sstas func_append libobjs " $func_extract_archives_result" 8513233294Sstas test "X$libobjs" = "X " && libobjs= 8514233294Sstas fi 8515233294Sstas 8516102644Snectar save_ifs="$IFS"; IFS='~' 851755682Smarkm for cmd in $cmds; do 851855682Smarkm IFS="$save_ifs" 8519127808Snectar eval cmd=\"$cmd\" 8520233294Sstas $opt_silent || { 8521233294Sstas func_quote_for_expand "$cmd" 8522233294Sstas eval "func_echo $func_quote_for_expand_result" 8523233294Sstas } 8524233294Sstas $opt_dry_run || eval "$cmd" || { 8525178825Sdfr lt_exit=$? 8526178825Sdfr 8527178825Sdfr # Restore the uninstalled library and exit 8528233294Sstas if test "$opt_mode" = relink; then 8529233294Sstas ( cd "$output_objdir" && \ 8530233294Sstas $RM "${realname}T" && \ 8531233294Sstas $MV "${realname}U" "$realname" ) 8532178825Sdfr fi 8533178825Sdfr 8534178825Sdfr exit $lt_exit 8535178825Sdfr } 853655682Smarkm done 853755682Smarkm IFS="$save_ifs" 853855682Smarkm 853972445Sassar # Restore the uninstalled library and exit 8540233294Sstas if test "$opt_mode" = relink; then 8541233294Sstas $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8542178825Sdfr 8543178825Sdfr if test -n "$convenience"; then 8544178825Sdfr if test -z "$whole_archive_flag_spec"; then 8545233294Sstas func_show_eval '${RM}r "$gentop"' 8546178825Sdfr fi 8547178825Sdfr fi 8548178825Sdfr 8549178825Sdfr exit $EXIT_SUCCESS 855072445Sassar fi 855172445Sassar 855255682Smarkm # Create links to the real library. 855355682Smarkm for linkname in $linknames; do 855455682Smarkm if test "$realname" != "$linkname"; then 8555233294Sstas func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 855655682Smarkm fi 855755682Smarkm done 855855682Smarkm 855955682Smarkm # If -module or -export-dynamic was specified, set the dlname. 856055682Smarkm if test "$module" = yes || test "$export_dynamic" = yes; then 856155682Smarkm # On all known operating systems, these are identical. 856255682Smarkm dlname="$soname" 856355682Smarkm fi 856455682Smarkm fi 856555682Smarkm ;; 856655682Smarkm 856772445Sassar obj) 856872445Sassar if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 8569233294Sstas func_warning "\`-dlopen' is ignored for objects" 857055682Smarkm fi 857155682Smarkm 8572233294Sstas case " $deplibs" in 8573233294Sstas *\ -l* | *\ -L*) 8574233294Sstas func_warning "\`-l' and \`-L' are ignored for objects" ;; 8575233294Sstas esac 857655682Smarkm 8577233294Sstas test -n "$rpath" && \ 8578233294Sstas func_warning "\`-rpath' is ignored for objects" 857972445Sassar 8580233294Sstas test -n "$xrpath" && \ 8581233294Sstas func_warning "\`-R' is ignored for objects" 858255682Smarkm 8583233294Sstas test -n "$vinfo" && \ 8584233294Sstas func_warning "\`-version-info' is ignored for objects" 858555682Smarkm 8586233294Sstas test -n "$release" && \ 8587233294Sstas func_warning "\`-release' is ignored for objects" 8588233294Sstas 858990926Snectar case $output in 859055682Smarkm *.lo) 8591233294Sstas test -n "$objs$old_deplibs" && \ 8592233294Sstas func_fatal_error "cannot build library object \`$output' from non-libtool objects" 8593233294Sstas 8594233294Sstas libobj=$output 8595233294Sstas func_lo2o "$libobj" 8596233294Sstas obj=$func_lo2o_result 859772445Sassar ;; 859855682Smarkm *) 859972445Sassar libobj= 860072445Sassar obj="$output" 860172445Sassar ;; 860255682Smarkm esac 860355682Smarkm 860455682Smarkm # Delete the old objects. 8605233294Sstas $opt_dry_run || $RM $obj $libobj 860655682Smarkm 860772445Sassar # Objects from convenience libraries. This assumes 860872445Sassar # single-version convenience libraries. Whenever we create 860972445Sassar # different ones for PIC/non-PIC, this we'll have to duplicate 861072445Sassar # the extraction. 861172445Sassar reload_conv_objs= 861272445Sassar gentop= 861372445Sassar # reload_cmds runs $LD directly, so let us get rid of 8614233294Sstas # -Wl from whole_archive_flag_spec and hope we can get by with 8615233294Sstas # turning comma into space.. 861672445Sassar wl= 861772445Sassar 861872445Sassar if test -n "$convenience"; then 861972445Sassar if test -n "$whole_archive_flag_spec"; then 8620233294Sstas eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 8621233294Sstas reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 862272445Sassar else 862372445Sassar gentop="$output_objdir/${obj}x" 8624233294Sstas func_append generated " $gentop" 862572445Sassar 8626178825Sdfr func_extract_archives $gentop $convenience 8627178825Sdfr reload_conv_objs="$reload_objs $func_extract_archives_result" 862872445Sassar fi 862972445Sassar fi 863072445Sassar 8631233294Sstas # If we're not building shared, we need to use non_pic_objs 8632233294Sstas test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8633233294Sstas 863455682Smarkm # Create the old-style object. 8635233294Sstas reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 863655682Smarkm 863755682Smarkm output="$obj" 8638233294Sstas func_execute_cmds "$reload_cmds" 'exit $?' 863955682Smarkm 864055682Smarkm # Exit if we aren't doing a library object file. 864172445Sassar if test -z "$libobj"; then 864272445Sassar if test -n "$gentop"; then 8643233294Sstas func_show_eval '${RM}r "$gentop"' 864472445Sassar fi 864555682Smarkm 8646178825Sdfr exit $EXIT_SUCCESS 864772445Sassar fi 864872445Sassar 864955682Smarkm if test "$build_libtool_libs" != yes; then 865072445Sassar if test -n "$gentop"; then 8651233294Sstas func_show_eval '${RM}r "$gentop"' 865272445Sassar fi 865372445Sassar 865472445Sassar # Create an invalid libtool object if no PIC, so that we don't 865572445Sassar # accidentally link it into a program. 8656127808Snectar # $show "echo timestamp > $libobj" 8657233294Sstas # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 8658178825Sdfr exit $EXIT_SUCCESS 865955682Smarkm fi 866055682Smarkm 866172445Sassar if test -n "$pic_flag" || test "$pic_mode" != default; then 866272445Sassar # Only do commands if we really have different PIC objects. 866372445Sassar reload_objs="$libobjs $reload_conv_objs" 866472445Sassar output="$libobj" 8665233294Sstas func_execute_cmds "$reload_cmds" 'exit $?' 866655682Smarkm fi 866755682Smarkm 866872445Sassar if test -n "$gentop"; then 8669233294Sstas func_show_eval '${RM}r "$gentop"' 867072445Sassar fi 867172445Sassar 8672178825Sdfr exit $EXIT_SUCCESS 867355682Smarkm ;; 867455682Smarkm 867572445Sassar prog) 867690926Snectar case $host in 8677233294Sstas *cygwin*) func_stripname '' '.exe' "$output" 8678233294Sstas output=$func_stripname_result.exe;; 867990926Snectar esac 8680233294Sstas test -n "$vinfo" && \ 8681233294Sstas func_warning "\`-version-info' is ignored for programs" 868255682Smarkm 8683233294Sstas test -n "$release" && \ 8684233294Sstas func_warning "\`-release' is ignored for programs" 868555682Smarkm 8686233294Sstas test "$preload" = yes \ 8687233294Sstas && test "$dlopen_support" = unknown \ 8688233294Sstas && test "$dlopen_self" = unknown \ 8689233294Sstas && test "$dlopen_self_static" = unknown && \ 8690233294Sstas func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 869155682Smarkm 869290926Snectar case $host in 869390926Snectar *-*-rhapsody* | *-*-darwin1.[012]) 869490926Snectar # On Rhapsody replace the C library is the System framework 8695233294Sstas compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 8696233294Sstas finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 869790926Snectar ;; 869890926Snectar esac 869990926Snectar 8700127808Snectar case $host in 8701233294Sstas *-*-darwin*) 8702233294Sstas # Don't allow lazy linking, it breaks C++ global constructors 8703233294Sstas # But is supposedly fixed on 10.4 or later (yay!). 8704233294Sstas if test "$tagname" = CXX ; then 8705233294Sstas case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 8706233294Sstas 10.[0123]) 8707233294Sstas func_append compile_command " ${wl}-bind_at_load" 8708233294Sstas func_append finalize_command " ${wl}-bind_at_load" 8709233294Sstas ;; 8710233294Sstas esac 8711233294Sstas fi 8712233294Sstas # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8713233294Sstas compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8714233294Sstas finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8715233294Sstas ;; 8716127808Snectar esac 8717127808Snectar 8718178825Sdfr 8719178825Sdfr # move library search paths that coincide with paths to not yet 8720178825Sdfr # installed libraries to the beginning of the library search list 8721178825Sdfr new_libs= 8722178825Sdfr for path in $notinst_path; do 8723178825Sdfr case " $new_libs " in 8724178825Sdfr *" -L$path/$objdir "*) ;; 8725178825Sdfr *) 8726178825Sdfr case " $compile_deplibs " in 8727178825Sdfr *" -L$path/$objdir "*) 8728233294Sstas func_append new_libs " -L$path/$objdir" ;; 8729178825Sdfr esac 8730178825Sdfr ;; 8731178825Sdfr esac 8732178825Sdfr done 8733178825Sdfr for deplib in $compile_deplibs; do 8734178825Sdfr case $deplib in 8735178825Sdfr -L*) 8736178825Sdfr case " $new_libs " in 8737178825Sdfr *" $deplib "*) ;; 8738233294Sstas *) func_append new_libs " $deplib" ;; 8739178825Sdfr esac 8740178825Sdfr ;; 8741233294Sstas *) func_append new_libs " $deplib" ;; 8742178825Sdfr esac 8743178825Sdfr done 8744178825Sdfr compile_deplibs="$new_libs" 8745178825Sdfr 8746178825Sdfr 8747233294Sstas func_append compile_command " $compile_deplibs" 8748233294Sstas func_append finalize_command " $finalize_deplibs" 874955682Smarkm 875072445Sassar if test -n "$rpath$xrpath"; then 875172445Sassar # If the user specified any rpath flags, then add them. 875272445Sassar for libdir in $rpath $xrpath; do 875372445Sassar # This is the magic to use -rpath. 875472445Sassar case "$finalize_rpath " in 875572445Sassar *" $libdir "*) ;; 8756233294Sstas *) func_append finalize_rpath " $libdir" ;; 875772445Sassar esac 875855682Smarkm done 875955682Smarkm fi 876055682Smarkm 876172445Sassar # Now hardcode the library paths 876272445Sassar rpath= 876372445Sassar hardcode_libdirs= 876472445Sassar for libdir in $compile_rpath $finalize_rpath; do 876572445Sassar if test -n "$hardcode_libdir_flag_spec"; then 876672445Sassar if test -n "$hardcode_libdir_separator"; then 876772445Sassar if test -z "$hardcode_libdirs"; then 876872445Sassar hardcode_libdirs="$libdir" 876972445Sassar else 877072445Sassar # Just accumulate the unique libdirs. 877190926Snectar case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 877272445Sassar *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 877372445Sassar ;; 877472445Sassar *) 8775233294Sstas func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 877672445Sassar ;; 877772445Sassar esac 877872445Sassar fi 877972445Sassar else 878072445Sassar eval flag=\"$hardcode_libdir_flag_spec\" 8781233294Sstas func_append rpath " $flag" 878272445Sassar fi 878372445Sassar elif test -n "$runpath_var"; then 878472445Sassar case "$perm_rpath " in 878572445Sassar *" $libdir "*) ;; 8786233294Sstas *) func_append perm_rpath " $libdir" ;; 878772445Sassar esac 878872445Sassar fi 878990926Snectar case $host in 8790233294Sstas *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 8791233294Sstas testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 879290926Snectar case :$dllsearchpath: in 879372445Sassar *":$libdir:"*) ;; 8794233294Sstas ::) dllsearchpath=$libdir;; 8795233294Sstas *) func_append dllsearchpath ":$libdir";; 879672445Sassar esac 8797178825Sdfr case :$dllsearchpath: in 8798178825Sdfr *":$testbindir:"*) ;; 8799233294Sstas ::) dllsearchpath=$testbindir;; 8800233294Sstas *) func_append dllsearchpath ":$testbindir";; 8801178825Sdfr esac 880272445Sassar ;; 880372445Sassar esac 880472445Sassar done 880572445Sassar # Substitute the hardcoded libdirs into the rpath. 880672445Sassar if test -n "$hardcode_libdir_separator" && 880772445Sassar test -n "$hardcode_libdirs"; then 880872445Sassar libdir="$hardcode_libdirs" 880972445Sassar eval rpath=\" $hardcode_libdir_flag_spec\" 881055682Smarkm fi 881172445Sassar compile_rpath="$rpath" 881255682Smarkm 881372445Sassar rpath= 881472445Sassar hardcode_libdirs= 881572445Sassar for libdir in $finalize_rpath; do 881672445Sassar if test -n "$hardcode_libdir_flag_spec"; then 881772445Sassar if test -n "$hardcode_libdir_separator"; then 881872445Sassar if test -z "$hardcode_libdirs"; then 881972445Sassar hardcode_libdirs="$libdir" 882072445Sassar else 882172445Sassar # Just accumulate the unique libdirs. 882290926Snectar case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 882372445Sassar *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 882472445Sassar ;; 882572445Sassar *) 8826233294Sstas func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 882772445Sassar ;; 882872445Sassar esac 882972445Sassar fi 883072445Sassar else 883172445Sassar eval flag=\"$hardcode_libdir_flag_spec\" 8832233294Sstas func_append rpath " $flag" 883372445Sassar fi 883472445Sassar elif test -n "$runpath_var"; then 883572445Sassar case "$finalize_perm_rpath " in 883672445Sassar *" $libdir "*) ;; 8837233294Sstas *) func_append finalize_perm_rpath " $libdir" ;; 883872445Sassar esac 883972445Sassar fi 884072445Sassar done 884172445Sassar # Substitute the hardcoded libdirs into the rpath. 884272445Sassar if test -n "$hardcode_libdir_separator" && 884372445Sassar test -n "$hardcode_libdirs"; then 884472445Sassar libdir="$hardcode_libdirs" 884572445Sassar eval rpath=\" $hardcode_libdir_flag_spec\" 884655682Smarkm fi 884772445Sassar finalize_rpath="$rpath" 884855682Smarkm 884955682Smarkm if test -n "$libobjs" && test "$build_old_libs" = yes; then 885072445Sassar # Transform all the library objects into standard objects. 8851233294Sstas compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8852233294Sstas finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 885355682Smarkm fi 885455682Smarkm 8855233294Sstas func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 885655682Smarkm 8857233294Sstas # template prelinking step 8858233294Sstas if test -n "$prelink_cmds"; then 8859233294Sstas func_execute_cmds "$prelink_cmds" 'exit $?' 886055682Smarkm fi 886155682Smarkm 8862233294Sstas wrappers_required=yes 8863233294Sstas case $host in 8864233294Sstas *cegcc* | *mingw32ce*) 8865233294Sstas # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 8866233294Sstas wrappers_required=no 8867233294Sstas ;; 8868233294Sstas *cygwin* | *mingw* ) 8869233294Sstas if test "$build_libtool_libs" != yes; then 8870233294Sstas wrappers_required=no 8871233294Sstas fi 8872233294Sstas ;; 8873233294Sstas *) 8874233294Sstas if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8875233294Sstas wrappers_required=no 8876233294Sstas fi 8877233294Sstas ;; 8878233294Sstas esac 8879233294Sstas if test "$wrappers_required" = no; then 888072445Sassar # Replace the output file specification. 8881233294Sstas compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 888272445Sassar link_command="$compile_command$compile_rpath" 888355682Smarkm 888472445Sassar # We have no uninstalled library dependencies, so finalize right now. 8885233294Sstas exit_status=0 8886233294Sstas func_show_eval "$link_command" 'exit_status=$?' 888755682Smarkm 8888233294Sstas if test -n "$postlink_cmds"; then 8889233294Sstas func_to_tool_file "$output" 8890233294Sstas postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8891233294Sstas func_execute_cmds "$postlink_cmds" 'exit $?' 8892233294Sstas fi 8893233294Sstas 889472445Sassar # Delete the generated files. 8895233294Sstas if test -f "$output_objdir/${outputname}S.${objext}"; then 8896233294Sstas func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 889772445Sassar fi 889855682Smarkm 8899178825Sdfr exit $exit_status 890055682Smarkm fi 890155682Smarkm 890272445Sassar if test -n "$compile_shlibpath$finalize_shlibpath"; then 890372445Sassar compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 890455682Smarkm fi 890555682Smarkm if test -n "$finalize_shlibpath"; then 890672445Sassar finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 890755682Smarkm fi 890855682Smarkm 890972445Sassar compile_var= 891072445Sassar finalize_var= 891172445Sassar if test -n "$runpath_var"; then 891272445Sassar if test -n "$perm_rpath"; then 891372445Sassar # We should set the runpath_var. 891472445Sassar rpath= 891572445Sassar for dir in $perm_rpath; do 8916233294Sstas func_append rpath "$dir:" 891772445Sassar done 891872445Sassar compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 891972445Sassar fi 892072445Sassar if test -n "$finalize_perm_rpath"; then 892172445Sassar # We should set the runpath_var. 892272445Sassar rpath= 892372445Sassar for dir in $finalize_perm_rpath; do 8924233294Sstas func_append rpath "$dir:" 892572445Sassar done 892672445Sassar finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 892772445Sassar fi 892855682Smarkm fi 892955682Smarkm 893072445Sassar if test "$no_install" = yes; then 893172445Sassar # We don't need to create a wrapper script. 893272445Sassar link_command="$compile_var$compile_command$compile_rpath" 893372445Sassar # Replace the output file specification. 8934233294Sstas link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 893572445Sassar # Delete the old output file. 8936233294Sstas $opt_dry_run || $RM $output 893772445Sassar # Link the executable and exit 8938233294Sstas func_show_eval "$link_command" 'exit $?' 8939233294Sstas 8940233294Sstas if test -n "$postlink_cmds"; then 8941233294Sstas func_to_tool_file "$output" 8942233294Sstas postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8943233294Sstas func_execute_cmds "$postlink_cmds" 'exit $?' 8944233294Sstas fi 8945233294Sstas 8946178825Sdfr exit $EXIT_SUCCESS 894755682Smarkm fi 894855682Smarkm 894990926Snectar if test "$hardcode_action" = relink; then 895072445Sassar # Fast installation is not supported 895172445Sassar link_command="$compile_var$compile_command$compile_rpath" 895272445Sassar relink_command="$finalize_var$finalize_command$finalize_rpath" 895355682Smarkm 8954233294Sstas func_warning "this platform does not like uninstalled shared libraries" 8955233294Sstas func_warning "\`$output' will be relinked during installation" 895672445Sassar else 895772445Sassar if test "$fast_install" != no; then 895872445Sassar link_command="$finalize_var$compile_command$finalize_rpath" 895972445Sassar if test "$fast_install" = yes; then 8960233294Sstas relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 896172445Sassar else 896272445Sassar # fast_install is set to needless 896372445Sassar relink_command= 896472445Sassar fi 896572445Sassar else 896672445Sassar link_command="$compile_var$compile_command$compile_rpath" 896772445Sassar relink_command="$finalize_var$finalize_command$finalize_rpath" 896872445Sassar fi 896972445Sassar fi 897072445Sassar 897172445Sassar # Replace the output file specification. 8972233294Sstas link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 897372445Sassar 897472445Sassar # Delete the old output files. 8975233294Sstas $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 897672445Sassar 8977233294Sstas func_show_eval "$link_command" 'exit $?' 897872445Sassar 8979233294Sstas if test -n "$postlink_cmds"; then 8980233294Sstas func_to_tool_file "$output_objdir/$outputname" 8981233294Sstas 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'` 8982233294Sstas func_execute_cmds "$postlink_cmds" 'exit $?' 8983233294Sstas fi 8984233294Sstas 898555682Smarkm # Now create the wrapper script. 8986233294Sstas func_verbose "creating $output" 898755682Smarkm 898872445Sassar # Quote the relink command for shipping. 898972445Sassar if test -n "$relink_command"; then 899072445Sassar # Preserve any variables that may affect compiler behavior 899172445Sassar for var in $variables_saved_for_relink; do 899290926Snectar if eval test -z \"\${$var+set}\"; then 8993233294Sstas relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 899490926Snectar elif eval var_value=\$$var; test -z "$var_value"; then 899590926Snectar relink_command="$var=; export $var; $relink_command" 899690926Snectar else 8997233294Sstas func_quote_for_eval "$var_value" 8998233294Sstas relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 899990926Snectar fi 900072445Sassar done 9001127808Snectar relink_command="(cd `pwd`; $relink_command)" 9002233294Sstas relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 900372445Sassar fi 900455682Smarkm 9005233294Sstas # Only actually do things if not in dry run mode. 9006233294Sstas $opt_dry_run || { 900772445Sassar # win32 will think the script is a binary if it has 900872445Sassar # a .exe suffix, so we strip it off here. 900972445Sassar case $output in 9010233294Sstas *.exe) func_stripname '' '.exe' "$output" 9011233294Sstas output=$func_stripname_result ;; 901272445Sassar esac 901390926Snectar # test for cygwin because mv fails w/o .exe extensions 901490926Snectar case $host in 9015127808Snectar *cygwin*) 9016127808Snectar exeext=.exe 9017233294Sstas func_stripname '' '.exe' "$outputname" 9018233294Sstas outputname=$func_stripname_result ;; 901990926Snectar *) exeext= ;; 902090926Snectar esac 9021127808Snectar case $host in 9022127808Snectar *cygwin* | *mingw* ) 9023233294Sstas func_dirname_and_basename "$output" "" "." 9024233294Sstas output_name=$func_basename_result 9025233294Sstas output_path=$func_dirname_result 9026233294Sstas cwrappersource="$output_path/$objdir/lt-$output_name.c" 9027233294Sstas cwrapper="$output_path/$output_name.exe" 9028233294Sstas $RM $cwrappersource $cwrapper 9029233294Sstas trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 9030127808Snectar 9031233294Sstas func_emit_cwrapperexe_src > $cwrappersource 9032127808Snectar 9033233294Sstas # The wrapper executable is built using the $host compiler, 9034233294Sstas # because it contains $host paths and files. If cross- 9035233294Sstas # compiling, it, like the target executable, must be 9036233294Sstas # executed on the $host or under an emulation environment. 9037233294Sstas $opt_dry_run || { 9038233294Sstas $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 9039233294Sstas $STRIP $cwrapper 9040233294Sstas } 9041127808Snectar 9042233294Sstas # Now, create the wrapper script for func_source use: 9043233294Sstas func_ltwrapper_scriptname $cwrapper 9044233294Sstas $RM $func_ltwrapper_scriptname_result 9045233294Sstas trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 9046233294Sstas $opt_dry_run || { 9047233294Sstas # note: this script will not be executed, so do not chmod. 9048233294Sstas if test "x$build" = "x$host" ; then 9049233294Sstas $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 9050233294Sstas else 9051233294Sstas func_emit_wrapper no > $func_ltwrapper_scriptname_result 9052233294Sstas fi 9053233294Sstas } 905472445Sassar ;; 9055233294Sstas * ) 9056233294Sstas $RM $output 9057233294Sstas trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 905872445Sassar 9059233294Sstas func_emit_wrapper no > $output 9060233294Sstas chmod +x $output 906172445Sassar ;; 906272445Sassar esac 9063233294Sstas } 9064178825Sdfr exit $EXIT_SUCCESS 906555682Smarkm ;; 906655682Smarkm esac 906755682Smarkm 906855682Smarkm # See if we need to build an old-fashioned archive. 906955682Smarkm for oldlib in $oldlibs; do 907055682Smarkm 907155682Smarkm if test "$build_libtool_libs" = convenience; then 9072233294Sstas oldobjs="$libobjs_save $symfileobj" 907355682Smarkm addlibs="$convenience" 907455682Smarkm build_libtool_libs=no 907555682Smarkm else 907672445Sassar if test "$build_libtool_libs" = module; then 907772445Sassar oldobjs="$libobjs_save" 907872445Sassar build_libtool_libs=no 907972445Sassar else 9080127808Snectar oldobjs="$old_deplibs $non_pic_objects" 9081233294Sstas if test "$preload" = yes && test -f "$symfileobj"; then 9082233294Sstas func_append oldobjs " $symfileobj" 9083233294Sstas fi 908472445Sassar fi 908555682Smarkm addlibs="$old_convenience" 908655682Smarkm fi 908755682Smarkm 908872445Sassar if test -n "$addlibs"; then 908972445Sassar gentop="$output_objdir/${outputname}x" 9090233294Sstas func_append generated " $gentop" 909155682Smarkm 9092178825Sdfr func_extract_archives $gentop $addlibs 9093233294Sstas func_append oldobjs " $func_extract_archives_result" 909472445Sassar fi 909572445Sassar 909655682Smarkm # Do each command in the archive commands. 909755682Smarkm if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 9098233294Sstas cmds=$old_archive_from_new_cmds 909955682Smarkm else 9100233294Sstas 9101233294Sstas # Add any objects from preloaded convenience libraries 9102233294Sstas if test -n "$dlprefiles"; then 9103233294Sstas gentop="$output_objdir/${outputname}x" 9104233294Sstas func_append generated " $gentop" 9105233294Sstas 9106233294Sstas func_extract_archives $gentop $dlprefiles 9107233294Sstas func_append oldobjs " $func_extract_archives_result" 9108233294Sstas fi 9109233294Sstas 9110178825Sdfr # POSIX demands no paths to be encoded in archives. We have 9111178825Sdfr # to avoid creating archives with duplicate basenames if we 9112178825Sdfr # might have to extract them afterwards, e.g., when creating a 9113178825Sdfr # static archive out of a convenience library, or when linking 9114178825Sdfr # the entirety of a libtool archive into another (currently 9115178825Sdfr # not supported by libtool). 9116178825Sdfr if (for obj in $oldobjs 9117178825Sdfr do 9118233294Sstas func_basename "$obj" 9119233294Sstas $ECHO "$func_basename_result" 9120178825Sdfr done | sort | sort -uc >/dev/null 2>&1); then 9121178825Sdfr : 9122178825Sdfr else 9123233294Sstas echo "copying selected object files to avoid basename conflicts..." 9124233294Sstas gentop="$output_objdir/${outputname}x" 9125233294Sstas func_append generated " $gentop" 9126233294Sstas func_mkdir_p "$gentop" 9127178825Sdfr save_oldobjs=$oldobjs 9128178825Sdfr oldobjs= 9129178825Sdfr counter=1 9130178825Sdfr for obj in $save_oldobjs 9131178825Sdfr do 9132233294Sstas func_basename "$obj" 9133233294Sstas objbase="$func_basename_result" 9134178825Sdfr case " $oldobjs " in 9135178825Sdfr " ") oldobjs=$obj ;; 9136178825Sdfr *[\ /]"$objbase "*) 9137178825Sdfr while :; do 9138178825Sdfr # Make sure we don't pick an alternate name that also 9139178825Sdfr # overlaps. 9140178825Sdfr newobj=lt$counter-$objbase 9141233294Sstas func_arith $counter + 1 9142233294Sstas counter=$func_arith_result 9143178825Sdfr case " $oldobjs " in 9144178825Sdfr *[\ /]"$newobj "*) ;; 9145178825Sdfr *) if test ! -f "$gentop/$newobj"; then break; fi ;; 9146178825Sdfr esac 9147178825Sdfr done 9148233294Sstas func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 9149233294Sstas func_append oldobjs " $gentop/$newobj" 9150178825Sdfr ;; 9151233294Sstas *) func_append oldobjs " $obj" ;; 9152178825Sdfr esac 9153178825Sdfr done 9154178825Sdfr fi 9155127808Snectar eval cmds=\"$old_archive_cmds\" 9156127808Snectar 9157233294Sstas func_len " $cmds" 9158233294Sstas len=$func_len_result 9159233294Sstas if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9160127808Snectar cmds=$old_archive_cmds 9161233294Sstas elif test -n "$archiver_list_spec"; then 9162233294Sstas func_verbose "using command file archive linking..." 9163233294Sstas for obj in $oldobjs 9164233294Sstas do 9165233294Sstas func_to_tool_file "$obj" 9166233294Sstas $ECHO "$func_to_tool_file_result" 9167233294Sstas done > $output_objdir/$libname.libcmd 9168233294Sstas func_to_tool_file "$output_objdir/$libname.libcmd" 9169233294Sstas oldobjs=" $archiver_list_spec$func_to_tool_file_result" 9170233294Sstas cmds=$old_archive_cmds 9171127808Snectar else 9172127808Snectar # the command line is too long to link in one step, link in parts 9173233294Sstas func_verbose "using piecewise archive linking..." 9174127808Snectar save_RANLIB=$RANLIB 9175127808Snectar RANLIB=: 9176127808Snectar objlist= 9177127808Snectar concat_cmds= 9178127808Snectar save_oldobjs=$oldobjs 9179233294Sstas oldobjs= 9180127808Snectar # Is there a better way of finding the last object in the list? 9181127808Snectar for obj in $save_oldobjs 9182127808Snectar do 9183127808Snectar last_oldobj=$obj 9184178825Sdfr done 9185233294Sstas eval test_cmds=\"$old_archive_cmds\" 9186233294Sstas func_len " $test_cmds" 9187233294Sstas len0=$func_len_result 9188233294Sstas len=$len0 9189127808Snectar for obj in $save_oldobjs 9190127808Snectar do 9191233294Sstas func_len " $obj" 9192233294Sstas func_arith $len + $func_len_result 9193233294Sstas len=$func_arith_result 9194233294Sstas func_append objlist " $obj" 9195233294Sstas if test "$len" -lt "$max_cmd_len"; then 9196127808Snectar : 919772445Sassar else 9198127808Snectar # the above command should be used before it gets too long 9199127808Snectar oldobjs=$objlist 9200127808Snectar if test "$obj" = "$last_oldobj" ; then 9201233294Sstas RANLIB=$save_RANLIB 9202178825Sdfr fi 9203127808Snectar test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9204127808Snectar eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 9205127808Snectar objlist= 9206233294Sstas len=$len0 920772445Sassar fi 9208127808Snectar done 9209127808Snectar RANLIB=$save_RANLIB 9210127808Snectar oldobjs=$objlist 9211127808Snectar if test "X$oldobjs" = "X" ; then 9212127808Snectar eval cmds=\"\$concat_cmds\" 9213127808Snectar else 9214127808Snectar eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 921572445Sassar fi 9216127808Snectar fi 921755682Smarkm fi 9218233294Sstas func_execute_cmds "$cmds" 'exit $?' 921955682Smarkm done 922055682Smarkm 9221233294Sstas test -n "$generated" && \ 9222233294Sstas func_show_eval "${RM}r$generated" 922355682Smarkm 922455682Smarkm # Now create the libtool archive. 922590926Snectar case $output in 922655682Smarkm *.la) 922755682Smarkm old_library= 922855682Smarkm test "$build_old_libs" = yes && old_library="$libname.$libext" 9229233294Sstas func_verbose "creating $output" 923055682Smarkm 923172445Sassar # Preserve any variables that may affect compiler behavior 923272445Sassar for var in $variables_saved_for_relink; do 923390926Snectar if eval test -z \"\${$var+set}\"; then 9234233294Sstas relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 923590926Snectar elif eval var_value=\$$var; test -z "$var_value"; then 923690926Snectar relink_command="$var=; export $var; $relink_command" 923790926Snectar else 9238233294Sstas func_quote_for_eval "$var_value" 9239233294Sstas relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 924090926Snectar fi 924172445Sassar done 924272445Sassar # Quote the link command for shipping. 9243178825Sdfr relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 9244233294Sstas relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9245127808Snectar if test "$hardcode_automatic" = yes ; then 9246178825Sdfr relink_command= 9247178825Sdfr fi 9248178825Sdfr 924955682Smarkm # Only create the output if not a dry run. 9250233294Sstas $opt_dry_run || { 925172445Sassar for installed in no yes; do 925272445Sassar if test "$installed" = yes; then 925372445Sassar if test -z "$install_libdir"; then 925472445Sassar break 925572445Sassar fi 925672445Sassar output="$output_objdir/$outputname"i 925772445Sassar # Replace all uninstalled libtool libraries with the installed ones 925872445Sassar newdependency_libs= 925972445Sassar for deplib in $dependency_libs; do 926090926Snectar case $deplib in 926172445Sassar *.la) 9262233294Sstas func_basename "$deplib" 9263233294Sstas name="$func_basename_result" 9264127808Snectar eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 9265233294Sstas test -z "$libdir" && \ 9266233294Sstas func_fatal_error "\`$deplib' is not a valid libtool archive" 9267233294Sstas func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 926872445Sassar ;; 9269233294Sstas -L*) 9270233294Sstas func_stripname -L '' "$deplib" 9271233294Sstas func_replace_sysroot "$func_stripname_result" 9272233294Sstas func_append newdependency_libs " -L$func_replace_sysroot_result" 9273233294Sstas ;; 9274233294Sstas -R*) 9275233294Sstas func_stripname -R '' "$deplib" 9276233294Sstas func_replace_sysroot "$func_stripname_result" 9277233294Sstas func_append newdependency_libs " -R$func_replace_sysroot_result" 9278233294Sstas ;; 9279233294Sstas *) func_append newdependency_libs " $deplib" ;; 928072445Sassar esac 928172445Sassar done 928272445Sassar dependency_libs="$newdependency_libs" 928372445Sassar newdlfiles= 9284233294Sstas 928572445Sassar for lib in $dlfiles; do 9286233294Sstas case $lib in 9287233294Sstas *.la) 9288233294Sstas func_basename "$lib" 9289233294Sstas name="$func_basename_result" 9290233294Sstas eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9291233294Sstas test -z "$libdir" && \ 9292233294Sstas func_fatal_error "\`$lib' is not a valid libtool archive" 9293233294Sstas func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 9294233294Sstas ;; 9295233294Sstas *) func_append newdlfiles " $lib" ;; 9296233294Sstas esac 929772445Sassar done 929872445Sassar dlfiles="$newdlfiles" 929972445Sassar newdlprefiles= 930072445Sassar for lib in $dlprefiles; do 9301233294Sstas case $lib in 9302233294Sstas *.la) 9303233294Sstas # Only pass preopened files to the pseudo-archive (for 9304233294Sstas # eventual linking with the app. that links it) if we 9305233294Sstas # didn't already link the preopened objects directly into 9306233294Sstas # the library: 9307233294Sstas func_basename "$lib" 9308233294Sstas name="$func_basename_result" 9309233294Sstas eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9310233294Sstas test -z "$libdir" && \ 9311233294Sstas func_fatal_error "\`$lib' is not a valid libtool archive" 9312233294Sstas func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 9313233294Sstas ;; 9314233294Sstas esac 931572445Sassar done 931672445Sassar dlprefiles="$newdlprefiles" 9317127808Snectar else 9318127808Snectar newdlfiles= 9319127808Snectar for lib in $dlfiles; do 9320178825Sdfr case $lib in 9321127808Snectar [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9322127808Snectar *) abs=`pwd`"/$lib" ;; 9323127808Snectar esac 9324233294Sstas func_append newdlfiles " $abs" 9325127808Snectar done 9326127808Snectar dlfiles="$newdlfiles" 9327127808Snectar newdlprefiles= 9328127808Snectar for lib in $dlprefiles; do 9329178825Sdfr case $lib in 9330127808Snectar [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9331127808Snectar *) abs=`pwd`"/$lib" ;; 9332127808Snectar esac 9333233294Sstas func_append newdlprefiles " $abs" 9334127808Snectar done 9335127808Snectar dlprefiles="$newdlprefiles" 933672445Sassar fi 9337233294Sstas $RM $output 933890926Snectar # place dlname in correct position for cygwin 9339233294Sstas # In fact, it would be nice if we could use this code for all target 9340233294Sstas # systems that can't hard-code library paths into their executables 9341233294Sstas # and that have no shared library path variable independent of PATH, 9342233294Sstas # but it turns out we can't easily determine that from inspecting 9343233294Sstas # libtool variables, so we have to hard-code the OSs to which it 9344233294Sstas # applies here; at the moment, that means platforms that use the PE 9345233294Sstas # object format with DLL files. See the long comment at the top of 9346233294Sstas # tests/bindir.at for full details. 934790926Snectar tdlname=$dlname 934890926Snectar case $host,$output,$installed,$module,$dlname in 9349233294Sstas *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 9350233294Sstas # If a -bindir argument was supplied, place the dll there. 9351233294Sstas if test "x$bindir" != x ; 9352233294Sstas then 9353233294Sstas func_relative_path "$install_libdir" "$bindir" 9354233294Sstas tdlname=$func_relative_path_result$dlname 9355233294Sstas else 9356233294Sstas # Otherwise fall back on heuristic. 9357233294Sstas tdlname=../bin/$dlname 9358233294Sstas fi 9359233294Sstas ;; 936090926Snectar esac 9361233294Sstas $ECHO > $output "\ 936272445Sassar# $outputname - a libtool library file 9363233294Sstas# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 936472445Sassar# 936572445Sassar# Please DO NOT delete this file! 936672445Sassar# It is necessary for linking the library. 936755682Smarkm 936855682Smarkm# The name that we can dlopen(3). 936990926Snectardlname='$tdlname' 937055682Smarkm 937155682Smarkm# Names of this library. 937255682Smarkmlibrary_names='$library_names' 937355682Smarkm 937455682Smarkm# The name of the static archive. 937555682Smarkmold_library='$old_library' 937655682Smarkm 9377233294Sstas# Linker flags that can not go in dependency_libs. 9378233294Sstasinherited_linker_flags='$new_inherited_linker_flags' 9379233294Sstas 938055682Smarkm# Libraries that this one depends upon. 938155682Smarkmdependency_libs='$dependency_libs' 938255682Smarkm 9383233294Sstas# Names of additional weak libraries provided by this library 9384233294Sstasweak_library_names='$weak_libs' 9385233294Sstas 938655682Smarkm# Version information for $libname. 938755682Smarkmcurrent=$current 938855682Smarkmage=$age 938955682Smarkmrevision=$revision 939055682Smarkm 939155682Smarkm# Is this an already installed library? 939272445Sassarinstalled=$installed 939355682Smarkm 9394127808Snectar# Should we warn about portability when linking against -modules? 9395127808Snectarshouldnotlink=$module 9396127808Snectar 939772445Sassar# Files to dlopen/dlpreopen 939872445Sassardlopen='$dlfiles' 939972445Sassardlpreopen='$dlprefiles' 940072445Sassar 940155682Smarkm# Directory that this library needs to be installed in: 940272445Sassarlibdir='$install_libdir'" 9403127808Snectar if test "$installed" = no && test "$need_relink" = yes; then 9404233294Sstas $ECHO >> $output "\ 940572445Sassarrelink_command=\"$relink_command\"" 940672445Sassar fi 940772445Sassar done 9408233294Sstas } 940955682Smarkm 941055682Smarkm # Do a symbolic link so that the libtool archive can be found in 941155682Smarkm # LD_LIBRARY_PATH before the program is installed. 9412233294Sstas func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 941355682Smarkm ;; 941455682Smarkm esac 9415178825Sdfr exit $EXIT_SUCCESS 9416233294Sstas} 941755682Smarkm 9418233294Sstas{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 9419233294Sstas func_mode_link ${1+"$@"} 942055682Smarkm 942155682Smarkm 9422233294Sstas# func_mode_uninstall arg... 9423233294Sstasfunc_mode_uninstall () 9424233294Sstas{ 9425233294Sstas $opt_debug 9426233294Sstas RM="$nonopt" 942755682Smarkm files= 942890926Snectar rmforce= 942990926Snectar exit_status=0 943055682Smarkm 943172445Sassar # This variable tells wrapper scripts just to set variables rather 943272445Sassar # than running their programs. 943372445Sassar libtool_install_magic="$magic" 943472445Sassar 943555682Smarkm for arg 943655682Smarkm do 943790926Snectar case $arg in 9438233294Sstas -f) func_append RM " $arg"; rmforce=yes ;; 9439233294Sstas -*) func_append RM " $arg" ;; 9440233294Sstas *) func_append files " $arg" ;; 944155682Smarkm esac 944255682Smarkm done 944355682Smarkm 9444233294Sstas test -z "$RM" && \ 9445233294Sstas func_fatal_help "you must specify an RM program" 944655682Smarkm 944790926Snectar rmdirs= 944890926Snectar 944955682Smarkm for file in $files; do 9450233294Sstas func_dirname "$file" "" "." 9451233294Sstas dir="$func_dirname_result" 9452233294Sstas if test "X$dir" = X.; then 9453233294Sstas odir="$objdir" 945472445Sassar else 9455233294Sstas odir="$dir/$objdir" 945672445Sassar fi 9457233294Sstas func_basename "$file" 9458233294Sstas name="$func_basename_result" 9459233294Sstas test "$opt_mode" = uninstall && odir="$dir" 946055682Smarkm 9461233294Sstas # Remember odir for removal later, being careful to avoid duplicates 9462233294Sstas if test "$opt_mode" = clean; then 946390926Snectar case " $rmdirs " in 9464233294Sstas *" $odir "*) ;; 9465233294Sstas *) func_append rmdirs " $odir" ;; 946690926Snectar esac 946790926Snectar fi 946890926Snectar 946990926Snectar # Don't error if the file doesn't exist and rm -f was used. 9470233294Sstas if { test -L "$file"; } >/dev/null 2>&1 || 9471233294Sstas { test -h "$file"; } >/dev/null 2>&1 || 9472233294Sstas test -f "$file"; then 9473102644Snectar : 947490926Snectar elif test -d "$file"; then 9475102644Snectar exit_status=1 947690926Snectar continue 947790926Snectar elif test "$rmforce" = yes; then 9478102644Snectar continue 947990926Snectar fi 948090926Snectar 948155682Smarkm rmfiles="$file" 948255682Smarkm 948390926Snectar case $name in 948455682Smarkm *.la) 948572445Sassar # Possibly a libtool archive, so verify it. 9486233294Sstas if func_lalib_p "$file"; then 9487233294Sstas func_source $dir/$name 948855682Smarkm 948972445Sassar # Delete the libtool libraries and symlinks. 949072445Sassar for n in $library_names; do 9491233294Sstas func_append rmfiles " $odir/$n" 949272445Sassar done 9493233294Sstas test -n "$old_library" && func_append rmfiles " $odir/$old_library" 949455682Smarkm 9495233294Sstas case "$opt_mode" in 9496178825Sdfr clean) 9497233294Sstas case " $library_names " in 9498178825Sdfr *" $dlname "*) ;; 9499233294Sstas *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9500178825Sdfr esac 9501233294Sstas test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9502178825Sdfr ;; 9503178825Sdfr uninstall) 950472445Sassar if test -n "$library_names"; then 950572445Sassar # Do each command in the postuninstall commands. 9506233294Sstas func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 950772445Sassar fi 950855682Smarkm 950972445Sassar if test -n "$old_library"; then 951072445Sassar # Do each command in the old_postuninstall commands. 9511233294Sstas func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 951272445Sassar fi 951372445Sassar # FIXME: should reinstall the best remaining shared library. 9514178825Sdfr ;; 9515178825Sdfr esac 951672445Sassar fi 951772445Sassar ;; 951855682Smarkm 951955682Smarkm *.lo) 9520127808Snectar # Possibly a libtool object, so verify it. 9521233294Sstas if func_lalib_p "$file"; then 9522127808Snectar 9523127808Snectar # Read the .lo file 9524233294Sstas func_source $dir/$name 9525127808Snectar 9526127808Snectar # Add PIC object to the list of files to remove. 9527233294Sstas if test -n "$pic_object" && 9528233294Sstas test "$pic_object" != none; then 9529233294Sstas func_append rmfiles " $dir/$pic_object" 9530127808Snectar fi 9531127808Snectar 9532127808Snectar # Add non-PIC object to the list of files to remove. 9533233294Sstas if test -n "$non_pic_object" && 9534233294Sstas test "$non_pic_object" != none; then 9535233294Sstas func_append rmfiles " $dir/$non_pic_object" 9536127808Snectar fi 953772445Sassar fi 953872445Sassar ;; 953955682Smarkm 954055682Smarkm *) 9541233294Sstas if test "$opt_mode" = clean ; then 9542127808Snectar noexename=$name 9543127808Snectar case $file in 9544178825Sdfr *.exe) 9545233294Sstas func_stripname '' '.exe' "$file" 9546233294Sstas file=$func_stripname_result 9547233294Sstas func_stripname '' '.exe' "$name" 9548233294Sstas noexename=$func_stripname_result 9549127808Snectar # $file with .exe has already been added to rmfiles, 9550127808Snectar # add $file without .exe 9551233294Sstas func_append rmfiles " $file" 9552127808Snectar ;; 9553127808Snectar esac 9554127808Snectar # Do a test to see if this is a libtool program. 9555233294Sstas if func_ltwrapper_p "$file"; then 9556233294Sstas if func_ltwrapper_executable_p "$file"; then 9557233294Sstas func_ltwrapper_scriptname "$file" 9558233294Sstas relink_command= 9559233294Sstas func_source $func_ltwrapper_scriptname_result 9560233294Sstas func_append rmfiles " $func_ltwrapper_scriptname_result" 9561233294Sstas else 9562233294Sstas relink_command= 9563233294Sstas func_source $dir/$noexename 9564233294Sstas fi 956572445Sassar 9566127808Snectar # note $name still contains .exe if it was in $file originally 9567127808Snectar # as does the version of $file that was added into $rmfiles 9568233294Sstas func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9569127808Snectar if test "$fast_install" = yes && test -n "$relink_command"; then 9570233294Sstas func_append rmfiles " $odir/lt-$name" 9571127808Snectar fi 9572127808Snectar if test "X$noexename" != "X$name" ; then 9573233294Sstas func_append rmfiles " $odir/lt-${noexename}.c" 9574127808Snectar fi 957572445Sassar fi 957672445Sassar fi 957755682Smarkm ;; 957855682Smarkm esac 9579233294Sstas func_show_eval "$RM $rmfiles" 'exit_status=1' 958055682Smarkm done 958190926Snectar 958290926Snectar # Try to remove the ${objdir}s in the directories where we deleted files 958390926Snectar for dir in $rmdirs; do 958490926Snectar if test -d "$dir"; then 9585233294Sstas func_show_eval "rmdir $dir >/dev/null 2>&1" 958690926Snectar fi 958790926Snectar done 958890926Snectar 958990926Snectar exit $exit_status 9590233294Sstas} 959155682Smarkm 9592233294Sstas{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 9593233294Sstas func_mode_uninstall ${1+"$@"} 959455682Smarkm 9595233294Sstastest -z "$opt_mode" && { 9596233294Sstas help="$generic_help" 9597233294Sstas func_fatal_help "you must specify a MODE" 9598233294Sstas} 959955682Smarkm 9600233294Sstastest -z "$exec_cmd" && \ 9601233294Sstas func_fatal_help "invalid operation mode \`$opt_mode'" 9602233294Sstas 9603102644Snectarif test -n "$exec_cmd"; then 9604233294Sstas eval exec "$exec_cmd" 9605178825Sdfr exit $EXIT_FAILURE 9606102644Snectarfi 9607102644Snectar 9608233294Sstasexit $exit_status 960955682Smarkm 961055682Smarkm 9611127808Snectar# The TAGs below are defined such that we never get into a situation 9612127808Snectar# in which we disable both kinds of libraries. Given conflicting 9613127808Snectar# choices, we go for a static library, that is the most portable, 9614127808Snectar# since we can't tell whether shared libraries were disabled because 9615127808Snectar# the user asked for that or because the platform doesn't support 9616127808Snectar# them. This is particularly important on AIX, because we don't 9617127808Snectar# support having both static and shared libraries enabled at the same 9618127808Snectar# time on that platform, so we default to a shared-only configuration. 9619127808Snectar# If a disable-shared tag is given, we'll fallback to a static-only 9620127808Snectar# configuration. But we'll never go from static-only to shared-only. 9621127808Snectar 9622127808Snectar# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 9623233294Sstasbuild_libtool_libs=no 9624233294Sstasbuild_old_libs=yes 9625127808Snectar# ### END LIBTOOL TAG CONFIG: disable-shared 9626127808Snectar 9627127808Snectar# ### BEGIN LIBTOOL TAG CONFIG: disable-static 9628233294Sstasbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9629127808Snectar# ### END LIBTOOL TAG CONFIG: disable-static 9630127808Snectar 963155682Smarkm# Local Variables: 963255682Smarkm# mode:shell-script 963355682Smarkm# sh-indentation:2 963455682Smarkm# End: 9635233294Sstas# vi:sw=2 9636233294Sstas 9637