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