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