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