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