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