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