1228692Sdes 2236109Sdes# libtool (GNU libtool) 2.4.2 3228692Sdes# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 4228692Sdes 5174832Sdes# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 6236109Sdes# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 7228692Sdes# This is free software; see the source for copying conditions. There is NO 8228692Sdes# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9228692Sdes 10228692Sdes# GNU Libtool is free software; you can redistribute it and/or modify 11117610Sdes# it under the terms of the GNU General Public License as published by 12117610Sdes# the Free Software Foundation; either version 2 of the License, or 13117610Sdes# (at your option) any later version. 14117610Sdes# 15228692Sdes# As a special exception to the GNU General Public License, 16228692Sdes# if you distribute this file as part of a program or library that 17228692Sdes# is built using GNU Libtool, you may include this file under the 18228692Sdes# same distribution terms that you use for the rest of that program. 19228692Sdes# 20228692Sdes# GNU Libtool is distributed in the hope that it will be useful, but 21117610Sdes# WITHOUT ANY WARRANTY; without even the implied warranty of 22117610Sdes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23117610Sdes# General Public License for more details. 24117610Sdes# 25117610Sdes# You should have received a copy of the GNU General Public License 26228692Sdes# along with GNU Libtool; see the file COPYING. If not, a copy 27228692Sdes# can be downloaded from http://www.gnu.org/licenses/gpl.html, 28228692Sdes# or obtained by writing to the Free Software Foundation, Inc., 29228692Sdes# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30228692Sdes 31228692Sdes# Usage: $progname [OPTION]... [MODE-ARG]... 32117610Sdes# 33228692Sdes# Provide generalized library-building support services. 34228692Sdes# 35228692Sdes# --config show all configuration variables 36228692Sdes# --debug enable verbose shell tracing 37228692Sdes# -n, --dry-run display commands without modifying any files 38228692Sdes# --features display basic configuration information and exit 39228692Sdes# --mode=MODE use operation mode MODE 40228692Sdes# --preserve-dup-deps don't remove duplicate dependency libraries 41228692Sdes# --quiet, --silent don't print informational messages 42228692Sdes# --no-quiet, --no-silent 43228692Sdes# print informational messages (default) 44236109Sdes# --no-warn don't display warning messages 45228692Sdes# --tag=TAG use configuration variables from tag TAG 46228692Sdes# -v, --verbose print more informational messages than default 47228692Sdes# --no-verbose don't print the extra informational messages 48228692Sdes# --version print version information 49228692Sdes# -h, --help, --help-all print short, long, or detailed help message 50228692Sdes# 51228692Sdes# MODE must be one of the following: 52228692Sdes# 53228692Sdes# clean remove files from the build directory 54228692Sdes# compile compile a source file into a libtool object 55228692Sdes# execute automatically set library path, then run a program 56228692Sdes# finish complete the installation of libtool libraries 57228692Sdes# install install libraries or executables 58228692Sdes# link create a library or an executable 59228692Sdes# uninstall remove libraries from an installed directory 60228692Sdes# 61228692Sdes# MODE-ARGS vary depending on the MODE. When passed as first option, 62228692Sdes# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 63228692Sdes# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 64228692Sdes# 65228692Sdes# When reporting a bug, please describe a test case to reproduce it and 66228692Sdes# include the following information: 67228692Sdes# 68228692Sdes# host-triplet: $host 69228692Sdes# shell: $SHELL 70228692Sdes# compiler: $LTCC 71228692Sdes# compiler flags: $LTCFLAGS 72228692Sdes# linker: $LD (gnu? $with_gnu_ld) 73236109Sdes# $progname: (GNU libtool) 2.4.2 74228692Sdes# automake: $automake_version 75228692Sdes# autoconf: $autoconf_version 76228692Sdes# 77228692Sdes# Report bugs to <bug-libtool@gnu.org>. 78228692Sdes# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 79228692Sdes# General help using GNU software: <http://www.gnu.org/gethelp/>. 80117610Sdes 81228692SdesPROGRAM=libtool 82141098SdesPACKAGE=libtool 83236109SdesVERSION=2.4.2 84228692SdesTIMESTAMP="" 85236109Sdespackage_revision=1.3337 86141098Sdes 87228692Sdes# Be Bourne compatible 88174832Sdesif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 89174832Sdes emulate sh 90174832Sdes NULLCMD=: 91174832Sdes # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 92174832Sdes # is contrary to our usage. Disable this feature. 93174832Sdes alias -g '${1+"$@"}'='"$@"' 94141098Sdes setopt NO_GLOB_SUBST 95174832Sdeselse 96174832Sdes case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 97141098Sdesfi 98174832SdesBIN_SH=xpg4; export BIN_SH # for Tru64 99174832SdesDUALCASE=1; export DUALCASE # for MKS sh 100141098Sdes 101228692Sdes# A function that is used when there is no print builtin or printf. 102228692Sdesfunc_fallback_echo () 103228692Sdes{ 104228692Sdes eval 'cat <<_LTECHO_EOF 105228692Sdes$1 106228692Sdes_LTECHO_EOF' 107228692Sdes} 108117610Sdes 109228692Sdes# NLS nuisances: We save the old values to restore during execute mode. 110228692Sdeslt_user_locale= 111228692Sdeslt_safe_locale= 112228692Sdesfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 113174832Sdesdo 114174832Sdes eval "if test \"\${$lt_var+set}\" = set; then 115228692Sdes save_$lt_var=\$$lt_var 116228692Sdes $lt_var=C 117174832Sdes export $lt_var 118228692Sdes lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 119228692Sdes lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 120174832Sdes fi" 121174832Sdesdone 122228692SdesLC_ALL=C 123228692SdesLANGUAGE=C 124228692Sdesexport LANGUAGE LC_ALL 125117610Sdes 126228692Sdes$lt_unset CDPATH 127228692Sdes 128228692Sdes 129228692Sdes# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 130228692Sdes# is ksh but when the shell is invoked as "sh" and the current value of 131228692Sdes# the _XPG environment variable is not equal to 1 (one), the special 132228692Sdes# positional parameter $0, within a function call, is the name of the 133228692Sdes# function. 134228692Sdesprogpath="$0" 135228692Sdes 136228692Sdes 137228692Sdes 138228692Sdes: ${CP="cp -f"} 139228692Sdestest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 140228692Sdes: ${MAKE="make"} 141228692Sdes: ${MKDIR="mkdir"} 142228692Sdes: ${MV="mv -f"} 143228692Sdes: ${RM="rm -f"} 144228692Sdes: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 145228692Sdes: ${Xsed="$SED -e 1s/^X//"} 146228692Sdes 147228692Sdes# Global variables: 148228692SdesEXIT_SUCCESS=0 149228692SdesEXIT_FAILURE=1 150228692SdesEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 151228692SdesEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 152228692Sdes 153228692Sdesexit_status=$EXIT_SUCCESS 154228692Sdes 155125647Sdes# Make sure IFS has a sensible default 156174832Sdeslt_nl=' 157174832Sdes' 158174832SdesIFS=" $lt_nl" 159117610Sdes 160228692Sdesdirname="s,/[^/]*$,," 161228692Sdesbasename="s,^.*/,," 162117610Sdes 163228692Sdes# func_dirname file append nondir_replacement 164228692Sdes# Compute the dirname of FILE. If nonempty, add APPEND to the result, 165228692Sdes# otherwise set result to NONDIR_REPLACEMENT. 166228692Sdesfunc_dirname () 167228692Sdes{ 168228692Sdes func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 169228692Sdes if test "X$func_dirname_result" = "X${1}"; then 170228692Sdes func_dirname_result="${3}" 171228692Sdes else 172228692Sdes func_dirname_result="$func_dirname_result${2}" 173228692Sdes fi 174228692Sdes} # func_dirname may be replaced by extended shell implementation 175117610Sdes 176141098Sdes 177228692Sdes# func_basename file 178228692Sdesfunc_basename () 179228692Sdes{ 180228692Sdes func_basename_result=`$ECHO "${1}" | $SED "$basename"` 181228692Sdes} # func_basename may be replaced by extended shell implementation 182228692Sdes 183228692Sdes 184228692Sdes# func_dirname_and_basename file append nondir_replacement 185228692Sdes# perform func_basename and func_dirname in a single function 186228692Sdes# call: 187228692Sdes# dirname: Compute the dirname of FILE. If nonempty, 188228692Sdes# add APPEND to the result, otherwise set result 189228692Sdes# to NONDIR_REPLACEMENT. 190228692Sdes# value returned in "$func_dirname_result" 191228692Sdes# basename: Compute filename of FILE. 192228692Sdes# value retuned in "$func_basename_result" 193228692Sdes# Implementation must be kept synchronized with func_dirname 194228692Sdes# and func_basename. For efficiency, we do not delegate to 195228692Sdes# those functions but instead duplicate the functionality here. 196228692Sdesfunc_dirname_and_basename () 197228692Sdes{ 198228692Sdes # Extract subdirectory from the argument. 199228692Sdes func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 200228692Sdes if test "X$func_dirname_result" = "X${1}"; then 201228692Sdes func_dirname_result="${3}" 202228692Sdes else 203228692Sdes func_dirname_result="$func_dirname_result${2}" 204228692Sdes fi 205228692Sdes func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 206228692Sdes} # func_dirname_and_basename may be replaced by extended shell implementation 207228692Sdes 208228692Sdes 209228692Sdes# func_stripname prefix suffix name 210228692Sdes# strip PREFIX and SUFFIX off of NAME. 211228692Sdes# PREFIX and SUFFIX must not contain globbing or regex special 212228692Sdes# characters, hashes, percent signs, but SUFFIX may contain a leading 213228692Sdes# dot (in which case that matches only a dot). 214228692Sdes# func_strip_suffix prefix name 215228692Sdesfunc_stripname () 216228692Sdes{ 217228692Sdes case ${2} in 218228692Sdes .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 219228692Sdes *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 220228692Sdes esac 221228692Sdes} # func_stripname may be replaced by extended shell implementation 222228692Sdes 223228692Sdes 224228692Sdes# These SED scripts presuppose an absolute path with a trailing slash. 225228692Sdespathcar='s,^/\([^/]*\).*$,\1,' 226228692Sdespathcdr='s,^/[^/]*,,' 227228692Sdesremovedotparts=':dotsl 228228692Sdes s@/\./@/@g 229228692Sdes t dotsl 230228692Sdes s,/\.$,/,' 231228692Sdescollapseslashes='s@/\{1,\}@/@g' 232228692Sdesfinalslash='s,/*$,/,' 233228692Sdes 234228692Sdes# func_normal_abspath PATH 235228692Sdes# Remove doubled-up and trailing slashes, "." path components, 236228692Sdes# and cancel out any ".." path components in PATH after making 237228692Sdes# it an absolute path. 238228692Sdes# value returned in "$func_normal_abspath_result" 239228692Sdesfunc_normal_abspath () 240228692Sdes{ 241228692Sdes # Start from root dir and reassemble the path. 242228692Sdes func_normal_abspath_result= 243228692Sdes func_normal_abspath_tpath=$1 244228692Sdes func_normal_abspath_altnamespace= 245228692Sdes case $func_normal_abspath_tpath in 246228692Sdes "") 247228692Sdes # Empty path, that just means $cwd. 248228692Sdes func_stripname '' '/' "`pwd`" 249228692Sdes func_normal_abspath_result=$func_stripname_result 250228692Sdes return 251228692Sdes ;; 252228692Sdes # The next three entries are used to spot a run of precisely 253228692Sdes # two leading slashes without using negated character classes; 254228692Sdes # we take advantage of case's first-match behaviour. 255228692Sdes ///*) 256228692Sdes # Unusual form of absolute path, do nothing. 257228692Sdes ;; 258228692Sdes //*) 259228692Sdes # Not necessarily an ordinary path; POSIX reserves leading '//' 260228692Sdes # and for example Cygwin uses it to access remote file shares 261228692Sdes # over CIFS/SMB, so we conserve a leading double slash if found. 262228692Sdes func_normal_abspath_altnamespace=/ 263228692Sdes ;; 264228692Sdes /*) 265228692Sdes # Absolute path, do nothing. 266228692Sdes ;; 267228692Sdes *) 268228692Sdes # Relative path, prepend $cwd. 269228692Sdes func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 270228692Sdes ;; 271228692Sdes esac 272228692Sdes # Cancel out all the simple stuff to save iterations. We also want 273228692Sdes # the path to end with a slash for ease of parsing, so make sure 274228692Sdes # there is one (and only one) here. 275228692Sdes func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 276228692Sdes -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 277228692Sdes while :; do 278228692Sdes # Processed it all yet? 279228692Sdes if test "$func_normal_abspath_tpath" = / ; then 280228692Sdes # If we ascended to the root using ".." the result may be empty now. 281228692Sdes if test -z "$func_normal_abspath_result" ; then 282228692Sdes func_normal_abspath_result=/ 283228692Sdes fi 284228692Sdes break 285228692Sdes fi 286228692Sdes func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 287228692Sdes -e "$pathcar"` 288228692Sdes func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 289228692Sdes -e "$pathcdr"` 290228692Sdes # Figure out what to do with it 291228692Sdes case $func_normal_abspath_tcomponent in 292228692Sdes "") 293228692Sdes # Trailing empty path component, ignore it. 294228692Sdes ;; 295228692Sdes ..) 296228692Sdes # Parent dir; strip last assembled component from result. 297228692Sdes func_dirname "$func_normal_abspath_result" 298228692Sdes func_normal_abspath_result=$func_dirname_result 299228692Sdes ;; 300228692Sdes *) 301228692Sdes # Actual path component, append it. 302228692Sdes func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 303228692Sdes ;; 304228692Sdes esac 305228692Sdes done 306228692Sdes # Restore leading double-slash if one was found on entry. 307228692Sdes func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 308228692Sdes} 309228692Sdes 310228692Sdes# func_relative_path SRCDIR DSTDIR 311228692Sdes# generates a relative path from SRCDIR to DSTDIR, with a trailing 312228692Sdes# slash if non-empty, suitable for immediately appending a filename 313228692Sdes# without needing to append a separator. 314228692Sdes# value returned in "$func_relative_path_result" 315228692Sdesfunc_relative_path () 316228692Sdes{ 317228692Sdes func_relative_path_result= 318228692Sdes func_normal_abspath "$1" 319228692Sdes func_relative_path_tlibdir=$func_normal_abspath_result 320228692Sdes func_normal_abspath "$2" 321228692Sdes func_relative_path_tbindir=$func_normal_abspath_result 322228692Sdes 323228692Sdes # Ascend the tree starting from libdir 324228692Sdes while :; do 325228692Sdes # check if we have found a prefix of bindir 326228692Sdes case $func_relative_path_tbindir in 327228692Sdes $func_relative_path_tlibdir) 328228692Sdes # found an exact match 329228692Sdes func_relative_path_tcancelled= 330228692Sdes break 331228692Sdes ;; 332228692Sdes $func_relative_path_tlibdir*) 333228692Sdes # found a matching prefix 334228692Sdes func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 335228692Sdes func_relative_path_tcancelled=$func_stripname_result 336228692Sdes if test -z "$func_relative_path_result"; then 337228692Sdes func_relative_path_result=. 338228692Sdes fi 339228692Sdes break 340228692Sdes ;; 341228692Sdes *) 342228692Sdes func_dirname $func_relative_path_tlibdir 343228692Sdes func_relative_path_tlibdir=${func_dirname_result} 344228692Sdes if test "x$func_relative_path_tlibdir" = x ; then 345228692Sdes # Have to descend all the way to the root! 346228692Sdes func_relative_path_result=../$func_relative_path_result 347228692Sdes func_relative_path_tcancelled=$func_relative_path_tbindir 348228692Sdes break 349228692Sdes fi 350228692Sdes func_relative_path_result=../$func_relative_path_result 351228692Sdes ;; 352228692Sdes esac 353228692Sdes done 354228692Sdes 355228692Sdes # Now calculate path; take care to avoid doubling-up slashes. 356228692Sdes func_stripname '' '/' "$func_relative_path_result" 357228692Sdes func_relative_path_result=$func_stripname_result 358228692Sdes func_stripname '/' '/' "$func_relative_path_tcancelled" 359228692Sdes if test "x$func_stripname_result" != x ; then 360228692Sdes func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 361228692Sdes fi 362228692Sdes 363228692Sdes # Normalisation. If bindir is libdir, return empty string, 364228692Sdes # else relative path ending with a slash; either way, target 365228692Sdes # file name can be directly appended. 366228692Sdes if test ! -z "$func_relative_path_result"; then 367228692Sdes func_stripname './' '' "$func_relative_path_result/" 368228692Sdes func_relative_path_result=$func_stripname_result 369228692Sdes fi 370228692Sdes} 371228692Sdes 372228692Sdes# The name of this program: 373228692Sdesfunc_dirname_and_basename "$progpath" 374228692Sdesprogname=$func_basename_result 375228692Sdes 376228692Sdes# Make sure we have an absolute path for reexecution: 377228692Sdescase $progpath in 378228692Sdes [\\/]*|[A-Za-z]:\\*) ;; 379228692Sdes *[\\/]*) 380228692Sdes progdir=$func_dirname_result 381228692Sdes progdir=`cd "$progdir" && pwd` 382228692Sdes progpath="$progdir/$progname" 383228692Sdes ;; 384228692Sdes *) 385228692Sdes save_IFS="$IFS" 386236109Sdes IFS=${PATH_SEPARATOR-:} 387228692Sdes for progdir in $PATH; do 388228692Sdes IFS="$save_IFS" 389228692Sdes test -x "$progdir/$progname" && break 390228692Sdes done 391228692Sdes IFS="$save_IFS" 392228692Sdes test -n "$progdir" || progdir=`pwd` 393228692Sdes progpath="$progdir/$progname" 394228692Sdes ;; 395228692Sdesesac 396228692Sdes 397228692Sdes# Sed substitution that helps us do robust quoting. It backslashifies 398228692Sdes# metacharacters that are still active within double-quoted strings. 399228692SdesXsed="${SED}"' -e 1s/^X//' 400228692Sdessed_quote_subst='s/\([`"$\\]\)/\\\1/g' 401228692Sdes 402228692Sdes# Same as above, but do not quote variable references. 403228692Sdesdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 404228692Sdes 405228692Sdes# Sed substitution that turns a string into a regex matching for the 406228692Sdes# string literally. 407228692Sdessed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 408228692Sdes 409228692Sdes# Sed substitution that converts a w32 file name or path 410228692Sdes# which contains forward slashes, into one that contains 411228692Sdes# (escaped) backslashes. A very naive implementation. 412228692Sdeslt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 413228692Sdes 414228692Sdes# Re-`\' parameter expansions in output of double_quote_subst that were 415228692Sdes# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 416228692Sdes# in input to double_quote_subst, that '$' was protected from expansion. 417228692Sdes# Since each input `\' is now two `\'s, look for any number of runs of 418228692Sdes# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 419228692Sdesbs='\\' 420228692Sdesbs2='\\\\' 421228692Sdesbs4='\\\\\\\\' 422228692Sdesdollar='\$' 423228692Sdessed_double_backslash="\ 424228692Sdes s/$bs4/&\\ 425228692Sdes/g 426228692Sdes s/^$bs2$dollar/$bs&/ 427228692Sdes s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 428228692Sdes s/\n//g" 429228692Sdes 430228692Sdes# Standard options: 431228692Sdesopt_dry_run=false 432228692Sdesopt_help=false 433228692Sdesopt_quiet=false 434228692Sdesopt_verbose=false 435228692Sdesopt_warning=: 436228692Sdes 437228692Sdes# func_echo arg... 438228692Sdes# Echo program name prefixed message, along with the current mode 439228692Sdes# name if it has been set yet. 440228692Sdesfunc_echo () 441228692Sdes{ 442228692Sdes $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 443228692Sdes} 444228692Sdes 445228692Sdes# func_verbose arg... 446228692Sdes# Echo program name prefixed message in verbose mode only. 447228692Sdesfunc_verbose () 448228692Sdes{ 449228692Sdes $opt_verbose && func_echo ${1+"$@"} 450228692Sdes 451228692Sdes # A bug in bash halts the script if the last line of a function 452228692Sdes # fails when set -e is in force, so we need another command to 453228692Sdes # work around that: 454228692Sdes : 455228692Sdes} 456228692Sdes 457228692Sdes# func_echo_all arg... 458228692Sdes# Invoke $ECHO with all args, space-separated. 459228692Sdesfunc_echo_all () 460228692Sdes{ 461228692Sdes $ECHO "$*" 462228692Sdes} 463228692Sdes 464228692Sdes# func_error arg... 465228692Sdes# Echo program name prefixed message to standard error. 466228692Sdesfunc_error () 467228692Sdes{ 468228692Sdes $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 469228692Sdes} 470228692Sdes 471228692Sdes# func_warning arg... 472228692Sdes# Echo program name prefixed warning message to standard error. 473228692Sdesfunc_warning () 474228692Sdes{ 475228692Sdes $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 476228692Sdes 477228692Sdes # bash bug again: 478228692Sdes : 479228692Sdes} 480228692Sdes 481228692Sdes# func_fatal_error arg... 482228692Sdes# Echo program name prefixed message to standard error, and exit. 483228692Sdesfunc_fatal_error () 484228692Sdes{ 485228692Sdes func_error ${1+"$@"} 486228692Sdes exit $EXIT_FAILURE 487228692Sdes} 488228692Sdes 489228692Sdes# func_fatal_help arg... 490228692Sdes# Echo program name prefixed message to standard error, followed by 491228692Sdes# a help hint, and exit. 492228692Sdesfunc_fatal_help () 493228692Sdes{ 494228692Sdes func_error ${1+"$@"} 495228692Sdes func_fatal_error "$help" 496228692Sdes} 497228692Sdeshelp="Try \`$progname --help' for more information." ## default 498228692Sdes 499228692Sdes 500228692Sdes# func_grep expression filename 501228692Sdes# Check whether EXPRESSION matches any line of FILENAME, without output. 502228692Sdesfunc_grep () 503228692Sdes{ 504228692Sdes $GREP "$1" "$2" >/dev/null 2>&1 505228692Sdes} 506228692Sdes 507228692Sdes 508228692Sdes# func_mkdir_p directory-path 509228692Sdes# Make sure the entire path to DIRECTORY-PATH is available. 510228692Sdesfunc_mkdir_p () 511228692Sdes{ 512228692Sdes my_directory_path="$1" 513228692Sdes my_dir_list= 514228692Sdes 515228692Sdes if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 516228692Sdes 517228692Sdes # Protect directory names starting with `-' 518228692Sdes case $my_directory_path in 519228692Sdes -*) my_directory_path="./$my_directory_path" ;; 520228692Sdes esac 521228692Sdes 522228692Sdes # While some portion of DIR does not yet exist... 523228692Sdes while test ! -d "$my_directory_path"; do 524228692Sdes # ...make a list in topmost first order. Use a colon delimited 525228692Sdes # list incase some portion of path contains whitespace. 526228692Sdes my_dir_list="$my_directory_path:$my_dir_list" 527228692Sdes 528228692Sdes # If the last portion added has no slash in it, the list is done 529228692Sdes case $my_directory_path in */*) ;; *) break ;; esac 530228692Sdes 531228692Sdes # ...otherwise throw away the child directory and loop 532228692Sdes my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 533228692Sdes done 534228692Sdes my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 535228692Sdes 536228692Sdes save_mkdir_p_IFS="$IFS"; IFS=':' 537228692Sdes for my_dir in $my_dir_list; do 538228692Sdes IFS="$save_mkdir_p_IFS" 539228692Sdes # mkdir can fail with a `File exist' error if two processes 540228692Sdes # try to create one of the directories concurrently. Don't 541228692Sdes # stop in that case! 542228692Sdes $MKDIR "$my_dir" 2>/dev/null || : 543228692Sdes done 544228692Sdes IFS="$save_mkdir_p_IFS" 545228692Sdes 546228692Sdes # Bail out if we (or some other process) failed to create a directory. 547228692Sdes test -d "$my_directory_path" || \ 548228692Sdes func_fatal_error "Failed to create \`$1'" 549228692Sdes fi 550228692Sdes} 551228692Sdes 552228692Sdes 553174832Sdes# func_mktempdir [string] 554174832Sdes# Make a temporary directory that won't clash with other running 555174832Sdes# libtool processes, and avoids race conditions if possible. If 556174832Sdes# given, STRING is the basename for that directory. 557174832Sdesfunc_mktempdir () 558174832Sdes{ 559174832Sdes my_template="${TMPDIR-/tmp}/${1-$progname}" 560174832Sdes 561228692Sdes if test "$opt_dry_run" = ":"; then 562174832Sdes # Return a directory name, but don't create it in dry-run mode 563174832Sdes my_tmpdir="${my_template}-$$" 564174832Sdes else 565174832Sdes 566174832Sdes # If mktemp works, use that first and foremost 567174832Sdes my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 568174832Sdes 569174832Sdes if test ! -d "$my_tmpdir"; then 570228692Sdes # Failing that, at least try and use $RANDOM to avoid a race 571228692Sdes my_tmpdir="${my_template}-${RANDOM-0}$$" 572174832Sdes 573228692Sdes save_mktempdir_umask=`umask` 574228692Sdes umask 0077 575228692Sdes $MKDIR "$my_tmpdir" 576228692Sdes umask $save_mktempdir_umask 577174832Sdes fi 578174832Sdes 579174832Sdes # If we're not in dry-run mode, bomb out on failure 580228692Sdes test -d "$my_tmpdir" || \ 581228692Sdes func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 582174832Sdes fi 583174832Sdes 584228692Sdes $ECHO "$my_tmpdir" 585174832Sdes} 586174832Sdes 587174832Sdes 588228692Sdes# func_quote_for_eval arg 589228692Sdes# Aesthetically quote ARG to be evaled later. 590228692Sdes# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 591228692Sdes# is double-quoted, suitable for a subsequent eval, whereas 592228692Sdes# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 593228692Sdes# which are still active within double quotes backslashified. 594228692Sdesfunc_quote_for_eval () 595147455Sdes{ 596228692Sdes case $1 in 597228692Sdes *[\\\`\"\$]*) 598228692Sdes func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 599228692Sdes *) 600228692Sdes func_quote_for_eval_unquoted_result="$1" ;; 601228692Sdes esac 602228692Sdes 603228692Sdes case $func_quote_for_eval_unquoted_result in 604228692Sdes # Double-quote args containing shell metacharacters to delay 605228692Sdes # word splitting, command substitution and and variable 606228692Sdes # expansion for a subsequent eval. 607228692Sdes # Many Bourne shells cannot handle close brackets correctly 608228692Sdes # in scan sets, so we specify it separately. 609228692Sdes *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 610228692Sdes func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 611228692Sdes ;; 612228692Sdes *) 613228692Sdes func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 614228692Sdes esac 615228692Sdes} 616228692Sdes 617228692Sdes 618228692Sdes# func_quote_for_expand arg 619228692Sdes# Aesthetically quote ARG to be evaled later; same as above, 620228692Sdes# but do not quote variable references. 621228692Sdesfunc_quote_for_expand () 622228692Sdes{ 623228692Sdes case $1 in 624228692Sdes *[\\\`\"]*) 625228692Sdes my_arg=`$ECHO "$1" | $SED \ 626228692Sdes -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 627228692Sdes *) 628228692Sdes my_arg="$1" ;; 629228692Sdes esac 630228692Sdes 631228692Sdes case $my_arg in 632228692Sdes # Double-quote args containing shell metacharacters to delay 633228692Sdes # word splitting and command substitution for a subsequent eval. 634228692Sdes # Many Bourne shells cannot handle close brackets correctly 635228692Sdes # in scan sets, so we specify it separately. 636228692Sdes *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 637228692Sdes my_arg="\"$my_arg\"" 638228692Sdes ;; 639228692Sdes esac 640228692Sdes 641228692Sdes func_quote_for_expand_result="$my_arg" 642228692Sdes} 643228692Sdes 644228692Sdes 645228692Sdes# func_show_eval cmd [fail_exp] 646228692Sdes# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 647228692Sdes# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 648228692Sdes# is given, then evaluate it. 649228692Sdesfunc_show_eval () 650228692Sdes{ 651228692Sdes my_cmd="$1" 652228692Sdes my_fail_exp="${2-:}" 653228692Sdes 654228692Sdes ${opt_silent-false} || { 655228692Sdes func_quote_for_expand "$my_cmd" 656228692Sdes eval "func_echo $func_quote_for_expand_result" 657228692Sdes } 658228692Sdes 659228692Sdes if ${opt_dry_run-false}; then :; else 660228692Sdes eval "$my_cmd" 661228692Sdes my_status=$? 662228692Sdes if test "$my_status" -eq 0; then :; else 663228692Sdes eval "(exit $my_status); $my_fail_exp" 664228692Sdes fi 665141098Sdes fi 666228692Sdes} 667228692Sdes 668228692Sdes 669228692Sdes# func_show_eval_locale cmd [fail_exp] 670228692Sdes# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 671228692Sdes# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 672228692Sdes# is given, then evaluate it. Use the saved locale for evaluation. 673228692Sdesfunc_show_eval_locale () 674228692Sdes{ 675228692Sdes my_cmd="$1" 676228692Sdes my_fail_exp="${2-:}" 677228692Sdes 678228692Sdes ${opt_silent-false} || { 679228692Sdes func_quote_for_expand "$my_cmd" 680228692Sdes eval "func_echo $func_quote_for_expand_result" 681228692Sdes } 682228692Sdes 683228692Sdes if ${opt_dry_run-false}; then :; else 684228692Sdes eval "$lt_user_locale 685228692Sdes $my_cmd" 686228692Sdes my_status=$? 687228692Sdes eval "$lt_safe_locale" 688228692Sdes if test "$my_status" -eq 0; then :; else 689228692Sdes eval "(exit $my_status); $my_fail_exp" 690228692Sdes fi 691228692Sdes fi 692228692Sdes} 693228692Sdes 694228692Sdes# func_tr_sh 695228692Sdes# Turn $1 into a string suitable for a shell variable name. 696228692Sdes# Result is stored in $func_tr_sh_result. All characters 697228692Sdes# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 698228692Sdes# if $1 begins with a digit, a '_' is prepended as well. 699228692Sdesfunc_tr_sh () 700228692Sdes{ 701228692Sdes case $1 in 702228692Sdes [0-9]* | *[!a-zA-Z0-9_]*) 703228692Sdes func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 704141098Sdes ;; 705228692Sdes * ) 706228692Sdes func_tr_sh_result=$1 707141098Sdes ;; 708228692Sdes esac 709228692Sdes} 710228692Sdes 711228692Sdes 712228692Sdes# func_version 713228692Sdes# Echo version message to standard output and exit. 714228692Sdesfunc_version () 715228692Sdes{ 716228692Sdes $opt_debug 717228692Sdes 718228692Sdes $SED -n '/(C)/!b go 719228692Sdes :more 720228692Sdes /\./!{ 721228692Sdes N 722228692Sdes s/\n# / / 723228692Sdes b more 724228692Sdes } 725228692Sdes :go 726228692Sdes /^# '$PROGRAM' (GNU /,/# warranty; / { 727228692Sdes s/^# // 728228692Sdes s/^# *$// 729228692Sdes s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 730228692Sdes p 731228692Sdes }' < "$progpath" 732228692Sdes exit $? 733228692Sdes} 734228692Sdes 735228692Sdes# func_usage 736228692Sdes# Echo short help message to standard output and exit. 737228692Sdesfunc_usage () 738228692Sdes{ 739228692Sdes $opt_debug 740228692Sdes 741228692Sdes $SED -n '/^# Usage:/,/^# *.*--help/ { 742228692Sdes s/^# // 743228692Sdes s/^# *$// 744228692Sdes s/\$progname/'$progname'/ 745228692Sdes p 746228692Sdes }' < "$progpath" 747228692Sdes echo 748228692Sdes $ECHO "run \`$progname --help | more' for full usage" 749228692Sdes exit $? 750228692Sdes} 751228692Sdes 752228692Sdes# func_help [NOEXIT] 753228692Sdes# Echo long help message to standard output and exit, 754228692Sdes# unless 'noexit' is passed as argument. 755228692Sdesfunc_help () 756228692Sdes{ 757228692Sdes $opt_debug 758228692Sdes 759228692Sdes $SED -n '/^# Usage:/,/# Report bugs to/ { 760228692Sdes :print 761228692Sdes s/^# // 762228692Sdes s/^# *$// 763228692Sdes s*\$progname*'$progname'* 764228692Sdes s*\$host*'"$host"'* 765228692Sdes s*\$SHELL*'"$SHELL"'* 766228692Sdes s*\$LTCC*'"$LTCC"'* 767228692Sdes s*\$LTCFLAGS*'"$LTCFLAGS"'* 768228692Sdes s*\$LD*'"$LD"'* 769228692Sdes s/\$with_gnu_ld/'"$with_gnu_ld"'/ 770236109Sdes s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ 771236109Sdes s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ 772228692Sdes p 773228692Sdes d 774228692Sdes } 775228692Sdes /^# .* home page:/b print 776228692Sdes /^# General help using/b print 777228692Sdes ' < "$progpath" 778228692Sdes ret=$? 779228692Sdes if test -z "$1"; then 780228692Sdes exit $ret 781228692Sdes fi 782228692Sdes} 783228692Sdes 784228692Sdes# func_missing_arg argname 785228692Sdes# Echo program name prefixed message to standard error and set global 786228692Sdes# exit_cmd. 787228692Sdesfunc_missing_arg () 788228692Sdes{ 789228692Sdes $opt_debug 790228692Sdes 791228692Sdes func_error "missing argument for $1." 792228692Sdes exit_cmd=exit 793228692Sdes} 794228692Sdes 795228692Sdes 796228692Sdes# func_split_short_opt shortopt 797228692Sdes# Set func_split_short_opt_name and func_split_short_opt_arg shell 798228692Sdes# variables after splitting SHORTOPT after the 2nd character. 799228692Sdesfunc_split_short_opt () 800228692Sdes{ 801228692Sdes my_sed_short_opt='1s/^\(..\).*$/\1/;q' 802228692Sdes my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 803228692Sdes 804228692Sdes func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 805228692Sdes func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 806228692Sdes} # func_split_short_opt may be replaced by extended shell implementation 807228692Sdes 808228692Sdes 809228692Sdes# func_split_long_opt longopt 810228692Sdes# Set func_split_long_opt_name and func_split_long_opt_arg shell 811228692Sdes# variables after splitting LONGOPT at the `=' sign. 812228692Sdesfunc_split_long_opt () 813228692Sdes{ 814228692Sdes my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 815228692Sdes my_sed_long_arg='1s/^--[^=]*=//' 816228692Sdes 817228692Sdes func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 818228692Sdes func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 819228692Sdes} # func_split_long_opt may be replaced by extended shell implementation 820228692Sdes 821228692Sdesexit_cmd=: 822228692Sdes 823228692Sdes 824228692Sdes 825228692Sdes 826228692Sdes 827228692Sdesmagic="%%%MAGIC variable%%%" 828228692Sdesmagic_exe="%%%MAGIC EXE variable%%%" 829228692Sdes 830228692Sdes# Global variables. 831228692Sdesnonopt= 832228692Sdespreserve_args= 833228692Sdeslo2o="s/\\.lo\$/.${objext}/" 834228692Sdeso2lo="s/\\.${objext}\$/.lo/" 835228692Sdesextracted_archives= 836228692Sdesextracted_serial=0 837228692Sdes 838228692Sdes# If this variable is set in any of the actions, the command in it 839228692Sdes# will be execed at the end. This prevents here-documents from being 840228692Sdes# left over by shells. 841228692Sdesexec_cmd= 842228692Sdes 843228692Sdes# func_append var value 844228692Sdes# Append VALUE to the end of shell variable VAR. 845228692Sdesfunc_append () 846228692Sdes{ 847228692Sdes eval "${1}=\$${1}\${2}" 848228692Sdes} # func_append may be replaced by extended shell implementation 849228692Sdes 850228692Sdes# func_append_quoted var value 851228692Sdes# Quote VALUE and append to the end of shell variable VAR, separated 852228692Sdes# by a space. 853228692Sdesfunc_append_quoted () 854228692Sdes{ 855228692Sdes func_quote_for_eval "${2}" 856228692Sdes eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 857228692Sdes} # func_append_quoted may be replaced by extended shell implementation 858228692Sdes 859228692Sdes 860228692Sdes# func_arith arithmetic-term... 861228692Sdesfunc_arith () 862228692Sdes{ 863228692Sdes func_arith_result=`expr "${@}"` 864228692Sdes} # func_arith may be replaced by extended shell implementation 865228692Sdes 866228692Sdes 867228692Sdes# func_len string 868228692Sdes# STRING may not start with a hyphen. 869228692Sdesfunc_len () 870228692Sdes{ 871228692Sdes func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 872228692Sdes} # func_len may be replaced by extended shell implementation 873228692Sdes 874228692Sdes 875228692Sdes# func_lo2o object 876228692Sdesfunc_lo2o () 877228692Sdes{ 878228692Sdes func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 879228692Sdes} # func_lo2o may be replaced by extended shell implementation 880228692Sdes 881228692Sdes 882228692Sdes# func_xform libobj-or-source 883228692Sdesfunc_xform () 884228692Sdes{ 885228692Sdes func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 886228692Sdes} # func_xform may be replaced by extended shell implementation 887228692Sdes 888228692Sdes 889228692Sdes# func_fatal_configuration arg... 890228692Sdes# Echo program name prefixed message to standard error, followed by 891228692Sdes# a configuration failure hint, and exit. 892228692Sdesfunc_fatal_configuration () 893228692Sdes{ 894228692Sdes func_error ${1+"$@"} 895228692Sdes func_error "See the $PACKAGE documentation for more information." 896228692Sdes func_fatal_error "Fatal configuration error." 897228692Sdes} 898228692Sdes 899228692Sdes 900228692Sdes# func_config 901228692Sdes# Display the configuration for all the tags in this script. 902228692Sdesfunc_config () 903228692Sdes{ 904228692Sdes re_begincf='^# ### BEGIN LIBTOOL' 905228692Sdes re_endcf='^# ### END LIBTOOL' 906228692Sdes 907228692Sdes # Default configuration. 908228692Sdes $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 909228692Sdes 910228692Sdes # Now print the configurations for the tags. 911228692Sdes for tagname in $taglist; do 912228692Sdes $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 913228692Sdes done 914228692Sdes 915228692Sdes exit $? 916228692Sdes} 917228692Sdes 918228692Sdes# func_features 919228692Sdes# Display the features supported by this script. 920228692Sdesfunc_features () 921228692Sdes{ 922228692Sdes echo "host: $host" 923228692Sdes if test "$build_libtool_libs" = yes; then 924228692Sdes echo "enable shared libraries" 925228692Sdes else 926228692Sdes echo "disable shared libraries" 927228692Sdes fi 928228692Sdes if test "$build_old_libs" = yes; then 929228692Sdes echo "enable static libraries" 930228692Sdes else 931228692Sdes echo "disable static libraries" 932228692Sdes fi 933228692Sdes 934228692Sdes exit $? 935228692Sdes} 936228692Sdes 937228692Sdes# func_enable_tag tagname 938228692Sdes# Verify that TAGNAME is valid, and either flag an error and exit, or 939228692Sdes# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 940228692Sdes# variable here. 941228692Sdesfunc_enable_tag () 942228692Sdes{ 943228692Sdes # Global variable: 944228692Sdes tagname="$1" 945228692Sdes 946228692Sdes re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 947228692Sdes re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 948228692Sdes sed_extractcf="/$re_begincf/,/$re_endcf/p" 949228692Sdes 950228692Sdes # Validate tagname. 951228692Sdes case $tagname in 952228692Sdes *[!-_A-Za-z0-9,/]*) 953228692Sdes func_fatal_error "invalid tag name: $tagname" 954141098Sdes ;; 955228692Sdes esac 956228692Sdes 957228692Sdes # Don't test for the "default" C tag, as we know it's 958228692Sdes # there but not specially marked. 959228692Sdes case $tagname in 960228692Sdes CC) ;; 961228692Sdes *) 962228692Sdes if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 963228692Sdes taglist="$taglist $tagname" 964228692Sdes 965228692Sdes # Evaluate the configuration. Be careful to quote the path 966228692Sdes # and the sed script, to avoid splitting on whitespace, but 967228692Sdes # also don't use non-portable quotes within backquotes within 968228692Sdes # quotes we have to do it in 2 steps: 969228692Sdes extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 970228692Sdes eval "$extractedcf" 971228692Sdes else 972228692Sdes func_error "ignoring unknown tag $tagname" 973228692Sdes fi 974228692Sdes ;; 975228692Sdes esac 976228692Sdes} 977228692Sdes 978228692Sdes# func_check_version_match 979228692Sdes# Ensure that we are using m4 macros, and libtool script from the same 980228692Sdes# release of libtool. 981228692Sdesfunc_check_version_match () 982228692Sdes{ 983228692Sdes if test "$package_revision" != "$macro_revision"; then 984228692Sdes if test "$VERSION" != "$macro_version"; then 985228692Sdes if test -z "$macro_version"; then 986228692Sdes cat >&2 <<_LT_EOF 987228692Sdes$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 988228692Sdes$progname: definition of this LT_INIT comes from an older release. 989228692Sdes$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 990228692Sdes$progname: and run autoconf again. 991228692Sdes_LT_EOF 992228692Sdes else 993228692Sdes cat >&2 <<_LT_EOF 994228692Sdes$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 995228692Sdes$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 996228692Sdes$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 997228692Sdes$progname: and run autoconf again. 998228692Sdes_LT_EOF 999228692Sdes fi 1000228692Sdes else 1001228692Sdes cat >&2 <<_LT_EOF 1002228692Sdes$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 1003228692Sdes$progname: but the definition of this LT_INIT comes from revision $macro_revision. 1004228692Sdes$progname: You should recreate aclocal.m4 with macros from revision $package_revision 1005228692Sdes$progname: of $PACKAGE $VERSION and run autoconf again. 1006228692Sdes_LT_EOF 1007228692Sdes fi 1008228692Sdes 1009228692Sdes exit $EXIT_MISMATCH 1010228692Sdes fi 1011228692Sdes} 1012228692Sdes 1013228692Sdes 1014228692Sdes# Shorthand for --mode=foo, only valid as the first argument 1015228692Sdescase $1 in 1016228692Sdesclean|clea|cle|cl) 1017228692Sdes shift; set dummy --mode clean ${1+"$@"}; shift 1018228692Sdes ;; 1019228692Sdescompile|compil|compi|comp|com|co|c) 1020228692Sdes shift; set dummy --mode compile ${1+"$@"}; shift 1021228692Sdes ;; 1022228692Sdesexecute|execut|execu|exec|exe|ex|e) 1023228692Sdes shift; set dummy --mode execute ${1+"$@"}; shift 1024228692Sdes ;; 1025228692Sdesfinish|finis|fini|fin|fi|f) 1026228692Sdes shift; set dummy --mode finish ${1+"$@"}; shift 1027228692Sdes ;; 1028228692Sdesinstall|instal|insta|inst|ins|in|i) 1029228692Sdes shift; set dummy --mode install ${1+"$@"}; shift 1030228692Sdes ;; 1031228692Sdeslink|lin|li|l) 1032228692Sdes shift; set dummy --mode link ${1+"$@"}; shift 1033228692Sdes ;; 1034228692Sdesuninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 1035228692Sdes shift; set dummy --mode uninstall ${1+"$@"}; shift 1036228692Sdes ;; 1037228692Sdesesac 1038228692Sdes 1039228692Sdes 1040228692Sdes 1041228692Sdes# Option defaults: 1042228692Sdesopt_debug=: 1043228692Sdesopt_dry_run=false 1044228692Sdesopt_config=false 1045228692Sdesopt_preserve_dup_deps=false 1046228692Sdesopt_features=false 1047228692Sdesopt_finish=false 1048228692Sdesopt_help=false 1049228692Sdesopt_help_all=false 1050228692Sdesopt_silent=: 1051236109Sdesopt_warning=: 1052228692Sdesopt_verbose=: 1053228692Sdesopt_silent=false 1054228692Sdesopt_verbose=false 1055228692Sdes 1056228692Sdes 1057228692Sdes# Parse options once, thoroughly. This comes as soon as possible in the 1058228692Sdes# script to make things like `--version' happen as quickly as we can. 1059228692Sdes{ 1060228692Sdes # this just eases exit handling 1061228692Sdes while test $# -gt 0; do 1062228692Sdes opt="$1" 1063228692Sdes shift 1064228692Sdes case $opt in 1065228692Sdes --debug|-x) opt_debug='set -x' 1066228692Sdes func_echo "enabling shell trace mode" 1067228692Sdes $opt_debug 1068228692Sdes ;; 1069228692Sdes --dry-run|--dryrun|-n) 1070228692Sdes opt_dry_run=: 1071228692Sdes ;; 1072228692Sdes --config) 1073228692Sdes opt_config=: 1074228692Sdesfunc_config 1075228692Sdes ;; 1076228692Sdes --dlopen|-dlopen) 1077228692Sdes optarg="$1" 1078228692Sdes opt_dlopen="${opt_dlopen+$opt_dlopen 1079228692Sdes}$optarg" 1080228692Sdes shift 1081228692Sdes ;; 1082228692Sdes --preserve-dup-deps) 1083228692Sdes opt_preserve_dup_deps=: 1084228692Sdes ;; 1085228692Sdes --features) 1086228692Sdes opt_features=: 1087228692Sdesfunc_features 1088228692Sdes ;; 1089228692Sdes --finish) 1090228692Sdes opt_finish=: 1091228692Sdesset dummy --mode finish ${1+"$@"}; shift 1092228692Sdes ;; 1093228692Sdes --help) 1094228692Sdes opt_help=: 1095228692Sdes ;; 1096228692Sdes --help-all) 1097228692Sdes opt_help_all=: 1098228692Sdesopt_help=': help-all' 1099228692Sdes ;; 1100228692Sdes --mode) 1101228692Sdes test $# = 0 && func_missing_arg $opt && break 1102228692Sdes optarg="$1" 1103228692Sdes opt_mode="$optarg" 1104228692Sdescase $optarg in 1105228692Sdes # Valid mode arguments: 1106228692Sdes clean|compile|execute|finish|install|link|relink|uninstall) ;; 1107228692Sdes 1108228692Sdes # Catch anything else as an error 1109228692Sdes *) func_error "invalid argument for $opt" 1110228692Sdes exit_cmd=exit 1111228692Sdes break 1112228692Sdes ;; 1113228692Sdesesac 1114228692Sdes shift 1115228692Sdes ;; 1116228692Sdes --no-silent|--no-quiet) 1117228692Sdes opt_silent=false 1118228692Sdesfunc_append preserve_args " $opt" 1119228692Sdes ;; 1120236109Sdes --no-warning|--no-warn) 1121236109Sdes opt_warning=false 1122236109Sdesfunc_append preserve_args " $opt" 1123236109Sdes ;; 1124228692Sdes --no-verbose) 1125228692Sdes opt_verbose=false 1126228692Sdesfunc_append preserve_args " $opt" 1127228692Sdes ;; 1128228692Sdes --silent|--quiet) 1129228692Sdes opt_silent=: 1130228692Sdesfunc_append preserve_args " $opt" 1131228692Sdes opt_verbose=false 1132228692Sdes ;; 1133228692Sdes --verbose|-v) 1134228692Sdes opt_verbose=: 1135228692Sdesfunc_append preserve_args " $opt" 1136228692Sdesopt_silent=false 1137228692Sdes ;; 1138228692Sdes --tag) 1139228692Sdes test $# = 0 && func_missing_arg $opt && break 1140228692Sdes optarg="$1" 1141228692Sdes opt_tag="$optarg" 1142228692Sdesfunc_append preserve_args " $opt $optarg" 1143228692Sdesfunc_enable_tag "$optarg" 1144228692Sdes shift 1145228692Sdes ;; 1146228692Sdes 1147228692Sdes -\?|-h) func_usage ;; 1148228692Sdes --help) func_help ;; 1149228692Sdes --version) func_version ;; 1150228692Sdes 1151228692Sdes # Separate optargs to long options: 1152228692Sdes --*=*) 1153228692Sdes func_split_long_opt "$opt" 1154228692Sdes set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 1155228692Sdes shift 1156228692Sdes ;; 1157228692Sdes 1158228692Sdes # Separate non-argument short options: 1159228692Sdes -\?*|-h*|-n*|-v*) 1160228692Sdes func_split_short_opt "$opt" 1161228692Sdes set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 1162228692Sdes shift 1163228692Sdes ;; 1164228692Sdes 1165228692Sdes --) break ;; 1166228692Sdes -*) func_fatal_help "unrecognized option \`$opt'" ;; 1167228692Sdes *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1168141098Sdes esac 1169228692Sdes done 1170228692Sdes 1171228692Sdes # Validate options: 1172228692Sdes 1173228692Sdes # save first non-option argument 1174228692Sdes if test "$#" -gt 0; then 1175228692Sdes nonopt="$opt" 1176228692Sdes shift 1177228692Sdes fi 1178228692Sdes 1179228692Sdes # preserve --debug 1180228692Sdes test "$opt_debug" = : || func_append preserve_args " --debug" 1181228692Sdes 1182228692Sdes case $host in 1183228692Sdes *cygwin* | *mingw* | *pw32* | *cegcc*) 1184228692Sdes # don't eliminate duplications in $postdeps and $predeps 1185228692Sdes opt_duplicate_compiler_generated_deps=: 1186228692Sdes ;; 1187228692Sdes *) 1188228692Sdes opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 1189228692Sdes ;; 1190228692Sdes esac 1191228692Sdes 1192228692Sdes $opt_help || { 1193228692Sdes # Sanity checks first: 1194228692Sdes func_check_version_match 1195228692Sdes 1196228692Sdes if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 1197228692Sdes func_fatal_configuration "not configured to build any kind of library" 1198228692Sdes fi 1199228692Sdes 1200228692Sdes # Darwin sucks 1201228692Sdes eval std_shrext=\"$shrext_cmds\" 1202228692Sdes 1203228692Sdes # Only execute mode is allowed to have -dlopen flags. 1204228692Sdes if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 1205228692Sdes func_error "unrecognized option \`-dlopen'" 1206228692Sdes $ECHO "$help" 1>&2 1207228692Sdes exit $EXIT_FAILURE 1208228692Sdes fi 1209228692Sdes 1210228692Sdes # Change the help message to a mode-specific one. 1211228692Sdes generic_help="$help" 1212228692Sdes help="Try \`$progname --help --mode=$opt_mode' for more information." 1213228692Sdes } 1214228692Sdes 1215228692Sdes 1216228692Sdes # Bail if the options were screwed 1217228692Sdes $exit_cmd $EXIT_FAILURE 1218228692Sdes} 1219228692Sdes 1220228692Sdes 1221228692Sdes 1222228692Sdes 1223228692Sdes## ----------- ## 1224228692Sdes## Main. ## 1225228692Sdes## ----------- ## 1226228692Sdes 1227228692Sdes# func_lalib_p file 1228228692Sdes# True iff FILE is a libtool `.la' library or `.lo' object file. 1229228692Sdes# This function is only a basic sanity check; it will hardly flush out 1230228692Sdes# determined imposters. 1231228692Sdesfunc_lalib_p () 1232228692Sdes{ 1233228692Sdes test -f "$1" && 1234228692Sdes $SED -e 4q "$1" 2>/dev/null \ 1235228692Sdes | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 1236228692Sdes} 1237228692Sdes 1238228692Sdes# func_lalib_unsafe_p file 1239228692Sdes# True iff FILE is a libtool `.la' library or `.lo' object file. 1240228692Sdes# This function implements the same check as func_lalib_p without 1241228692Sdes# resorting to external programs. To this end, it redirects stdin and 1242228692Sdes# closes it afterwards, without saving the original file descriptor. 1243228692Sdes# As a safety measure, use it only where a negative result would be 1244228692Sdes# fatal anyway. Works if `file' does not exist. 1245228692Sdesfunc_lalib_unsafe_p () 1246228692Sdes{ 1247228692Sdes lalib_p=no 1248228692Sdes if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 1249228692Sdes for lalib_p_l in 1 2 3 4 1250228692Sdes do 1251228692Sdes read lalib_p_line 1252228692Sdes case "$lalib_p_line" in 1253228692Sdes \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 1254228692Sdes esac 1255228692Sdes done 1256228692Sdes exec 0<&5 5<&- 1257228692Sdes fi 1258228692Sdes test "$lalib_p" = yes 1259228692Sdes} 1260228692Sdes 1261228692Sdes# func_ltwrapper_script_p file 1262228692Sdes# True iff FILE is a libtool wrapper script 1263228692Sdes# This function is only a basic sanity check; it will hardly flush out 1264228692Sdes# determined imposters. 1265228692Sdesfunc_ltwrapper_script_p () 1266228692Sdes{ 1267228692Sdes func_lalib_p "$1" 1268228692Sdes} 1269228692Sdes 1270228692Sdes# func_ltwrapper_executable_p file 1271228692Sdes# True iff FILE is a libtool wrapper executable 1272228692Sdes# This function is only a basic sanity check; it will hardly flush out 1273228692Sdes# determined imposters. 1274228692Sdesfunc_ltwrapper_executable_p () 1275228692Sdes{ 1276228692Sdes func_ltwrapper_exec_suffix= 1277228692Sdes case $1 in 1278228692Sdes *.exe) ;; 1279228692Sdes *) func_ltwrapper_exec_suffix=.exe ;; 1280228692Sdes esac 1281228692Sdes $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 1282228692Sdes} 1283228692Sdes 1284228692Sdes# func_ltwrapper_scriptname file 1285228692Sdes# Assumes file is an ltwrapper_executable 1286228692Sdes# uses $file to determine the appropriate filename for a 1287228692Sdes# temporary ltwrapper_script. 1288228692Sdesfunc_ltwrapper_scriptname () 1289228692Sdes{ 1290228692Sdes func_dirname_and_basename "$1" "" "." 1291228692Sdes func_stripname '' '.exe' "$func_basename_result" 1292228692Sdes func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 1293228692Sdes} 1294228692Sdes 1295228692Sdes# func_ltwrapper_p file 1296228692Sdes# True iff FILE is a libtool wrapper script or wrapper executable 1297228692Sdes# This function is only a basic sanity check; it will hardly flush out 1298228692Sdes# determined imposters. 1299228692Sdesfunc_ltwrapper_p () 1300228692Sdes{ 1301228692Sdes func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 1302228692Sdes} 1303228692Sdes 1304228692Sdes 1305228692Sdes# func_execute_cmds commands fail_cmd 1306228692Sdes# Execute tilde-delimited COMMANDS. 1307228692Sdes# If FAIL_CMD is given, eval that upon failure. 1308228692Sdes# FAIL_CMD may read-access the current command in variable CMD! 1309228692Sdesfunc_execute_cmds () 1310228692Sdes{ 1311228692Sdes $opt_debug 1312228692Sdes save_ifs=$IFS; IFS='~' 1313228692Sdes for cmd in $1; do 1314228692Sdes IFS=$save_ifs 1315228692Sdes eval cmd=\"$cmd\" 1316228692Sdes func_show_eval "$cmd" "${2-:}" 1317228692Sdes done 1318228692Sdes IFS=$save_ifs 1319228692Sdes} 1320228692Sdes 1321228692Sdes 1322228692Sdes# func_source file 1323228692Sdes# Source FILE, adding directory component if necessary. 1324228692Sdes# Note that it is not necessary on cygwin/mingw to append a dot to 1325228692Sdes# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 1326228692Sdes# behavior happens only for exec(3), not for open(2)! Also, sourcing 1327228692Sdes# `FILE.' does not work on cygwin managed mounts. 1328228692Sdesfunc_source () 1329228692Sdes{ 1330228692Sdes $opt_debug 1331228692Sdes case $1 in 1332228692Sdes */* | *\\*) . "$1" ;; 1333228692Sdes *) . "./$1" ;; 1334228692Sdes esac 1335228692Sdes} 1336228692Sdes 1337228692Sdes 1338228692Sdes# func_resolve_sysroot PATH 1339228692Sdes# Replace a leading = in PATH with a sysroot. Store the result into 1340228692Sdes# func_resolve_sysroot_result 1341228692Sdesfunc_resolve_sysroot () 1342228692Sdes{ 1343228692Sdes func_resolve_sysroot_result=$1 1344228692Sdes case $func_resolve_sysroot_result in 1345228692Sdes =*) 1346228692Sdes func_stripname '=' '' "$func_resolve_sysroot_result" 1347228692Sdes func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 1348141098Sdes ;; 1349141098Sdes esac 1350141098Sdes} 1351141098Sdes 1352228692Sdes# func_replace_sysroot PATH 1353228692Sdes# If PATH begins with the sysroot, replace it with = and 1354228692Sdes# store the result into func_replace_sysroot_result. 1355228692Sdesfunc_replace_sysroot () 1356228692Sdes{ 1357228692Sdes case "$lt_sysroot:$1" in 1358228692Sdes ?*:"$lt_sysroot"*) 1359228692Sdes func_stripname "$lt_sysroot" '' "$1" 1360228692Sdes func_replace_sysroot_result="=$func_stripname_result" 1361228692Sdes ;; 1362228692Sdes *) 1363228692Sdes # Including no sysroot. 1364228692Sdes func_replace_sysroot_result=$1 1365228692Sdes ;; 1366228692Sdes esac 1367228692Sdes} 1368141098Sdes 1369141098Sdes# func_infer_tag arg 1370141098Sdes# Infer tagged configuration to use if any are available and 1371141098Sdes# if one wasn't chosen via the "--tag" command line option. 1372141098Sdes# Only attempt this if the compiler in the base compile 1373141098Sdes# command doesn't match the default compiler. 1374141098Sdes# arg is usually of the form 'gcc ...' 1375147455Sdesfunc_infer_tag () 1376147455Sdes{ 1377228692Sdes $opt_debug 1378228692Sdes 1379174832Sdes # FreeBSD-specific: where we install compilers with non-standard names 1380271947Sdes tag_compilers_CC="*cc cc* *gcc gcc* clang*" 1381271947Sdes tag_compilers_CXX="*c++ c++* *g++ g++* clang++*" 1382174832Sdes base_compiler=`set -- "$@"; echo $1` 1383174832Sdes 1384174832Sdes # If $tagname isn't set, then try to infer if the default "CC" tag applies 1385174832Sdes if test -z "$tagname"; then 1386174832Sdes for zp in $tag_compilers_CC; do 1387174832Sdes case $base_compiler in 1388174832Sdes $zp) tagname="CC"; break;; 1389174832Sdes esac 1390174832Sdes done 1391174832Sdes fi 1392174832Sdes 1393141098Sdes if test -n "$available_tags" && test -z "$tagname"; then 1394141098Sdes CC_quoted= 1395141098Sdes for arg in $CC; do 1396228692Sdes func_append_quoted CC_quoted "$arg" 1397141098Sdes done 1398228692Sdes CC_expanded=`func_echo_all $CC` 1399228692Sdes CC_quoted_expanded=`func_echo_all $CC_quoted` 1400141098Sdes case $@ in 1401141098Sdes # Blanks in the command may have been stripped by the calling shell, 1402141098Sdes # but not from the CC environment variable when configure was run. 1403228692Sdes " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1404228692Sdes " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 1405141098Sdes # Blanks at the start of $base_compile will cause this to fail 1406141098Sdes # if we don't check for them as well. 1407141098Sdes *) 1408141098Sdes for z in $available_tags; do 1409228692Sdes if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 1410141098Sdes # Evaluate the configuration. 1411141098Sdes eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 1412141098Sdes CC_quoted= 1413141098Sdes for arg in $CC; do 1414228692Sdes # Double-quote args containing other shell metacharacters. 1415228692Sdes func_append_quoted CC_quoted "$arg" 1416228692Sdes done 1417228692Sdes CC_expanded=`func_echo_all $CC` 1418228692Sdes CC_quoted_expanded=`func_echo_all $CC_quoted` 1419141098Sdes case "$@ " in 1420228692Sdes " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1421228692Sdes " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 1422141098Sdes # The compiler in the base compile command matches 1423141098Sdes # the one in the tagged configuration. 1424141098Sdes # Assume this is the tagged configuration we want. 1425141098Sdes tagname=$z 1426141098Sdes break 1427141098Sdes ;; 1428141098Sdes esac 1429174832Sdes 1430174832Sdes # FreeBSD-specific: try compilers based on inferred tag 1431174832Sdes if test -z "$tagname"; then 1432174832Sdes eval "tag_compilers=\$tag_compilers_${z}" 1433174832Sdes if test -n "$tag_compilers"; then 1434174832Sdes for zp in $tag_compilers; do 1435174832Sdes case $base_compiler in 1436174832Sdes $zp) tagname=$z; break;; 1437174832Sdes esac 1438174832Sdes done 1439174832Sdes if test -n "$tagname"; then 1440174832Sdes break 1441174832Sdes fi 1442174832Sdes fi 1443174832Sdes fi 1444174832Sdes fi 1445141098Sdes done 1446141098Sdes # If $tagname still isn't set, then no tagged configuration 1447141098Sdes # was found and let the user know that the "--tag" command 1448141098Sdes # line option must be used. 1449141098Sdes if test -z "$tagname"; then 1450228692Sdes func_echo "unable to infer tagged configuration" 1451228692Sdes func_fatal_error "specify a tag with \`--tag'" 1452228692Sdes# else 1453228692Sdes# func_verbose "using $tagname tagged configuration" 1454141098Sdes fi 1455141098Sdes ;; 1456141098Sdes esac 1457141098Sdes fi 1458141098Sdes} 1459141098Sdes 1460141098Sdes 1461228692Sdes 1462228692Sdes# func_write_libtool_object output_name pic_name nonpic_name 1463228692Sdes# Create a libtool object file (analogous to a ".la" file), 1464228692Sdes# but don't create it if we're doing a dry run. 1465228692Sdesfunc_write_libtool_object () 1466147455Sdes{ 1467228692Sdes write_libobj=${1} 1468228692Sdes if test "$build_libtool_libs" = yes; then 1469228692Sdes write_lobj=\'${2}\' 1470228692Sdes else 1471228692Sdes write_lobj=none 1472228692Sdes fi 1473147455Sdes 1474228692Sdes if test "$build_old_libs" = yes; then 1475228692Sdes write_oldobj=\'${3}\' 1476147455Sdes else 1477228692Sdes write_oldobj=none 1478147455Sdes fi 1479228692Sdes 1480228692Sdes $opt_dry_run || { 1481228692Sdes cat >${write_libobj}T <<EOF 1482228692Sdes# $write_libobj - a libtool object file 1483228692Sdes# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1484228692Sdes# 1485228692Sdes# Please DO NOT delete this file! 1486228692Sdes# It is necessary for linking the library. 1487228692Sdes 1488228692Sdes# Name of the PIC object. 1489228692Sdespic_object=$write_lobj 1490228692Sdes 1491228692Sdes# Name of the non-PIC object 1492228692Sdesnon_pic_object=$write_oldobj 1493228692Sdes 1494228692SdesEOF 1495228692Sdes $MV "${write_libobj}T" "${write_libobj}" 1496228692Sdes } 1497147455Sdes} 1498147455Sdes 1499228692Sdes 1500228692Sdes################################################## 1501228692Sdes# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 1502228692Sdes################################################## 1503228692Sdes 1504228692Sdes# func_convert_core_file_wine_to_w32 ARG 1505228692Sdes# Helper function used by file name conversion functions when $build is *nix, 1506228692Sdes# and $host is mingw, cygwin, or some other w32 environment. Relies on a 1507228692Sdes# correctly configured wine environment available, with the winepath program 1508228692Sdes# in $build's $PATH. 1509228692Sdes# 1510228692Sdes# ARG is the $build file name to be converted to w32 format. 1511228692Sdes# Result is available in $func_convert_core_file_wine_to_w32_result, and will 1512228692Sdes# be empty on error (or when ARG is empty) 1513228692Sdesfunc_convert_core_file_wine_to_w32 () 1514147455Sdes{ 1515228692Sdes $opt_debug 1516228692Sdes func_convert_core_file_wine_to_w32_result="$1" 1517228692Sdes if test -n "$1"; then 1518228692Sdes # Unfortunately, winepath does not exit with a non-zero error code, so we 1519228692Sdes # are forced to check the contents of stdout. On the other hand, if the 1520228692Sdes # command is not found, the shell will set an exit code of 127 and print 1521228692Sdes # *an error message* to stdout. So we must check for both error code of 1522228692Sdes # zero AND non-empty stdout, which explains the odd construction: 1523228692Sdes func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 1524228692Sdes if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 1525228692Sdes func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 1526228692Sdes $SED -e "$lt_sed_naive_backslashify"` 1527228692Sdes else 1528228692Sdes func_convert_core_file_wine_to_w32_result= 1529141098Sdes fi 1530228692Sdes fi 1531228692Sdes} 1532228692Sdes# end: func_convert_core_file_wine_to_w32 1533141098Sdes 1534141098Sdes 1535228692Sdes# func_convert_core_path_wine_to_w32 ARG 1536228692Sdes# Helper function used by path conversion functions when $build is *nix, and 1537228692Sdes# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 1538228692Sdes# configured wine environment available, with the winepath program in $build's 1539228692Sdes# $PATH. Assumes ARG has no leading or trailing path separator characters. 1540228692Sdes# 1541228692Sdes# ARG is path to be converted from $build format to win32. 1542228692Sdes# Result is available in $func_convert_core_path_wine_to_w32_result. 1543228692Sdes# Unconvertible file (directory) names in ARG are skipped; if no directory names 1544228692Sdes# are convertible, then the result may be empty. 1545228692Sdesfunc_convert_core_path_wine_to_w32 () 1546228692Sdes{ 1547228692Sdes $opt_debug 1548228692Sdes # unfortunately, winepath doesn't convert paths, only file names 1549228692Sdes func_convert_core_path_wine_to_w32_result="" 1550228692Sdes if test -n "$1"; then 1551228692Sdes oldIFS=$IFS 1552228692Sdes IFS=: 1553228692Sdes for func_convert_core_path_wine_to_w32_f in $1; do 1554228692Sdes IFS=$oldIFS 1555228692Sdes func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 1556228692Sdes if test -n "$func_convert_core_file_wine_to_w32_result" ; then 1557228692Sdes if test -z "$func_convert_core_path_wine_to_w32_result"; then 1558228692Sdes func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 1559228692Sdes else 1560228692Sdes func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 1561228692Sdes fi 1562141098Sdes fi 1563141098Sdes done 1564228692Sdes IFS=$oldIFS 1565228692Sdes fi 1566141098Sdes} 1567228692Sdes# end: func_convert_core_path_wine_to_w32 1568141098Sdes 1569141098Sdes 1570228692Sdes# func_cygpath ARGS... 1571228692Sdes# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 1572228692Sdes# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 1573228692Sdes# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 1574228692Sdes# (2), returns the Cygwin file name or path in func_cygpath_result (input 1575228692Sdes# file name or path is assumed to be in w32 format, as previously converted 1576228692Sdes# from $build's *nix or MSYS format). In case (3), returns the w32 file name 1577228692Sdes# or path in func_cygpath_result (input file name or path is assumed to be in 1578228692Sdes# Cygwin format). Returns an empty string on error. 1579228692Sdes# 1580228692Sdes# ARGS are passed to cygpath, with the last one being the file name or path to 1581228692Sdes# be converted. 1582228692Sdes# 1583228692Sdes# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 1584228692Sdes# environment variable; do not put it in $PATH. 1585228692Sdesfunc_cygpath () 1586228692Sdes{ 1587228692Sdes $opt_debug 1588228692Sdes if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 1589228692Sdes func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 1590228692Sdes if test "$?" -ne 0; then 1591228692Sdes # on failure, ensure result is empty 1592228692Sdes func_cygpath_result= 1593228692Sdes fi 1594228692Sdes else 1595228692Sdes func_cygpath_result= 1596228692Sdes func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 1597228692Sdes fi 1598228692Sdes} 1599228692Sdes#end: func_cygpath 1600174832Sdes 1601117610Sdes 1602228692Sdes# func_convert_core_msys_to_w32 ARG 1603228692Sdes# Convert file name or path ARG from MSYS format to w32 format. Return 1604228692Sdes# result in func_convert_core_msys_to_w32_result. 1605228692Sdesfunc_convert_core_msys_to_w32 () 1606228692Sdes{ 1607228692Sdes $opt_debug 1608228692Sdes # awkward: cmd appends spaces to result 1609228692Sdes func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 1610228692Sdes $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 1611228692Sdes} 1612228692Sdes#end: func_convert_core_msys_to_w32 1613228692Sdes 1614228692Sdes 1615228692Sdes# func_convert_file_check ARG1 ARG2 1616228692Sdes# Verify that ARG1 (a file name in $build format) was converted to $host 1617228692Sdes# format in ARG2. Otherwise, emit an error message, but continue (resetting 1618228692Sdes# func_to_host_file_result to ARG1). 1619228692Sdesfunc_convert_file_check () 1620228692Sdes{ 1621228692Sdes $opt_debug 1622228692Sdes if test -z "$2" && test -n "$1" ; then 1623228692Sdes func_error "Could not determine host file name corresponding to" 1624228692Sdes func_error " \`$1'" 1625228692Sdes func_error "Continuing, but uninstalled executables may not work." 1626228692Sdes # Fallback: 1627228692Sdes func_to_host_file_result="$1" 1628228692Sdes fi 1629228692Sdes} 1630228692Sdes# end func_convert_file_check 1631228692Sdes 1632228692Sdes 1633228692Sdes# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 1634228692Sdes# Verify that FROM_PATH (a path in $build format) was converted to $host 1635228692Sdes# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 1636228692Sdes# func_to_host_file_result to a simplistic fallback value (see below). 1637228692Sdesfunc_convert_path_check () 1638228692Sdes{ 1639228692Sdes $opt_debug 1640228692Sdes if test -z "$4" && test -n "$3"; then 1641228692Sdes func_error "Could not determine the host path corresponding to" 1642228692Sdes func_error " \`$3'" 1643228692Sdes func_error "Continuing, but uninstalled executables may not work." 1644228692Sdes # Fallback. This is a deliberately simplistic "conversion" and 1645228692Sdes # should not be "improved". See libtool.info. 1646228692Sdes if test "x$1" != "x$2"; then 1647228692Sdes lt_replace_pathsep_chars="s|$1|$2|g" 1648228692Sdes func_to_host_path_result=`echo "$3" | 1649228692Sdes $SED -e "$lt_replace_pathsep_chars"` 1650228692Sdes else 1651228692Sdes func_to_host_path_result="$3" 1652228692Sdes fi 1653228692Sdes fi 1654228692Sdes} 1655228692Sdes# end func_convert_path_check 1656228692Sdes 1657228692Sdes 1658228692Sdes# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 1659228692Sdes# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 1660228692Sdes# and appending REPL if ORIG matches BACKPAT. 1661228692Sdesfunc_convert_path_front_back_pathsep () 1662228692Sdes{ 1663228692Sdes $opt_debug 1664228692Sdes case $4 in 1665228692Sdes $1 ) func_to_host_path_result="$3$func_to_host_path_result" 1666228692Sdes ;; 1667117610Sdes esac 1668228692Sdes case $4 in 1669228692Sdes $2 ) func_append func_to_host_path_result "$3" 1670228692Sdes ;; 1671228692Sdes esac 1672228692Sdes} 1673228692Sdes# end func_convert_path_front_back_pathsep 1674117610Sdes 1675141098Sdes 1676228692Sdes################################################## 1677228692Sdes# $build to $host FILE NAME CONVERSION FUNCTIONS # 1678228692Sdes################################################## 1679228692Sdes# invoked via `$to_host_file_cmd ARG' 1680228692Sdes# 1681228692Sdes# In each case, ARG is the path to be converted from $build to $host format. 1682228692Sdes# Result will be available in $func_to_host_file_result. 1683141098Sdes 1684228692Sdes 1685228692Sdes# func_to_host_file ARG 1686228692Sdes# Converts the file name ARG from $build format to $host format. Return result 1687228692Sdes# in func_to_host_file_result. 1688228692Sdesfunc_to_host_file () 1689228692Sdes{ 1690228692Sdes $opt_debug 1691228692Sdes $to_host_file_cmd "$1" 1692228692Sdes} 1693228692Sdes# end func_to_host_file 1694228692Sdes 1695228692Sdes 1696228692Sdes# func_to_tool_file ARG LAZY 1697228692Sdes# converts the file name ARG from $build format to toolchain format. Return 1698228692Sdes# result in func_to_tool_file_result. If the conversion in use is listed 1699228692Sdes# in (the comma separated) LAZY, no conversion takes place. 1700228692Sdesfunc_to_tool_file () 1701228692Sdes{ 1702228692Sdes $opt_debug 1703228692Sdes case ,$2, in 1704228692Sdes *,"$to_tool_file_cmd",*) 1705228692Sdes func_to_tool_file_result=$1 1706141098Sdes ;; 1707117610Sdes *) 1708228692Sdes $to_tool_file_cmd "$1" 1709228692Sdes func_to_tool_file_result=$func_to_host_file_result 1710117610Sdes ;; 1711228692Sdes esac 1712228692Sdes} 1713228692Sdes# end func_to_tool_file 1714117610Sdes 1715228692Sdes 1716228692Sdes# func_convert_file_noop ARG 1717228692Sdes# Copy ARG to func_to_host_file_result. 1718228692Sdesfunc_convert_file_noop () 1719228692Sdes{ 1720228692Sdes func_to_host_file_result="$1" 1721228692Sdes} 1722228692Sdes# end func_convert_file_noop 1723228692Sdes 1724228692Sdes 1725228692Sdes# func_convert_file_msys_to_w32 ARG 1726228692Sdes# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 1727228692Sdes# conversion to w32 is not available inside the cwrapper. Returns result in 1728228692Sdes# func_to_host_file_result. 1729228692Sdesfunc_convert_file_msys_to_w32 () 1730228692Sdes{ 1731228692Sdes $opt_debug 1732228692Sdes func_to_host_file_result="$1" 1733228692Sdes if test -n "$1"; then 1734228692Sdes func_convert_core_msys_to_w32 "$1" 1735228692Sdes func_to_host_file_result="$func_convert_core_msys_to_w32_result" 1736117610Sdes fi 1737228692Sdes func_convert_file_check "$1" "$func_to_host_file_result" 1738228692Sdes} 1739228692Sdes# end func_convert_file_msys_to_w32 1740117610Sdes 1741117610Sdes 1742228692Sdes# func_convert_file_cygwin_to_w32 ARG 1743228692Sdes# Convert file name ARG from Cygwin to w32 format. Returns result in 1744228692Sdes# func_to_host_file_result. 1745228692Sdesfunc_convert_file_cygwin_to_w32 () 1746228692Sdes{ 1747228692Sdes $opt_debug 1748228692Sdes func_to_host_file_result="$1" 1749228692Sdes if test -n "$1"; then 1750228692Sdes # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 1751228692Sdes # LT_CYGPATH in this case. 1752228692Sdes func_to_host_file_result=`cygpath -m "$1"` 1753228692Sdes fi 1754228692Sdes func_convert_file_check "$1" "$func_to_host_file_result" 1755228692Sdes} 1756228692Sdes# end func_convert_file_cygwin_to_w32 1757174832Sdes 1758117610Sdes 1759228692Sdes# func_convert_file_nix_to_w32 ARG 1760228692Sdes# Convert file name ARG from *nix to w32 format. Requires a wine environment 1761228692Sdes# and a working winepath. Returns result in func_to_host_file_result. 1762228692Sdesfunc_convert_file_nix_to_w32 () 1763228692Sdes{ 1764228692Sdes $opt_debug 1765228692Sdes func_to_host_file_result="$1" 1766228692Sdes if test -n "$1"; then 1767228692Sdes func_convert_core_file_wine_to_w32 "$1" 1768228692Sdes func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 1769228692Sdes fi 1770228692Sdes func_convert_file_check "$1" "$func_to_host_file_result" 1771228692Sdes} 1772228692Sdes# end func_convert_file_nix_to_w32 1773117610Sdes 1774117610Sdes 1775228692Sdes# func_convert_file_msys_to_cygwin ARG 1776228692Sdes# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1777228692Sdes# Returns result in func_to_host_file_result. 1778228692Sdesfunc_convert_file_msys_to_cygwin () 1779228692Sdes{ 1780228692Sdes $opt_debug 1781228692Sdes func_to_host_file_result="$1" 1782228692Sdes if test -n "$1"; then 1783228692Sdes func_convert_core_msys_to_w32 "$1" 1784228692Sdes func_cygpath -u "$func_convert_core_msys_to_w32_result" 1785228692Sdes func_to_host_file_result="$func_cygpath_result" 1786228692Sdes fi 1787228692Sdes func_convert_file_check "$1" "$func_to_host_file_result" 1788228692Sdes} 1789228692Sdes# end func_convert_file_msys_to_cygwin 1790117610Sdes 1791117610Sdes 1792228692Sdes# func_convert_file_nix_to_cygwin ARG 1793228692Sdes# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 1794228692Sdes# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 1795228692Sdes# in func_to_host_file_result. 1796228692Sdesfunc_convert_file_nix_to_cygwin () 1797228692Sdes{ 1798228692Sdes $opt_debug 1799228692Sdes func_to_host_file_result="$1" 1800228692Sdes if test -n "$1"; then 1801228692Sdes # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 1802228692Sdes func_convert_core_file_wine_to_w32 "$1" 1803228692Sdes func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 1804228692Sdes func_to_host_file_result="$func_cygpath_result" 1805228692Sdes fi 1806228692Sdes func_convert_file_check "$1" "$func_to_host_file_result" 1807228692Sdes} 1808228692Sdes# end func_convert_file_nix_to_cygwin 1809117610Sdes 1810117610Sdes 1811228692Sdes############################################# 1812228692Sdes# $build to $host PATH CONVERSION FUNCTIONS # 1813228692Sdes############################################# 1814228692Sdes# invoked via `$to_host_path_cmd ARG' 1815228692Sdes# 1816228692Sdes# In each case, ARG is the path to be converted from $build to $host format. 1817228692Sdes# The result will be available in $func_to_host_path_result. 1818228692Sdes# 1819228692Sdes# Path separators are also converted from $build format to $host format. If 1820228692Sdes# ARG begins or ends with a path separator character, it is preserved (but 1821228692Sdes# converted to $host format) on output. 1822228692Sdes# 1823228692Sdes# All path conversion functions are named using the following convention: 1824228692Sdes# file name conversion function : func_convert_file_X_to_Y () 1825228692Sdes# path conversion function : func_convert_path_X_to_Y () 1826228692Sdes# where, for any given $build/$host combination the 'X_to_Y' value is the 1827228692Sdes# same. If conversion functions are added for new $build/$host combinations, 1828228692Sdes# the two new functions must follow this pattern, or func_init_to_host_path_cmd 1829228692Sdes# will break. 1830125647Sdes 1831117610Sdes 1832228692Sdes# func_init_to_host_path_cmd 1833228692Sdes# Ensures that function "pointer" variable $to_host_path_cmd is set to the 1834228692Sdes# appropriate value, based on the value of $to_host_file_cmd. 1835228692Sdesto_host_path_cmd= 1836228692Sdesfunc_init_to_host_path_cmd () 1837228692Sdes{ 1838228692Sdes $opt_debug 1839228692Sdes if test -z "$to_host_path_cmd"; then 1840228692Sdes func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 1841228692Sdes to_host_path_cmd="func_convert_path_${func_stripname_result}" 1842228692Sdes fi 1843228692Sdes} 1844141098Sdes 1845117610Sdes 1846228692Sdes# func_to_host_path ARG 1847228692Sdes# Converts the path ARG from $build format to $host format. Return result 1848228692Sdes# in func_to_host_path_result. 1849228692Sdesfunc_to_host_path () 1850228692Sdes{ 1851228692Sdes $opt_debug 1852228692Sdes func_init_to_host_path_cmd 1853228692Sdes $to_host_path_cmd "$1" 1854228692Sdes} 1855228692Sdes# end func_to_host_path 1856117610Sdes 1857117610Sdes 1858228692Sdes# func_convert_path_noop ARG 1859228692Sdes# Copy ARG to func_to_host_path_result. 1860228692Sdesfunc_convert_path_noop () 1861228692Sdes{ 1862228692Sdes func_to_host_path_result="$1" 1863228692Sdes} 1864228692Sdes# end func_convert_path_noop 1865117610Sdes 1866174832Sdes 1867228692Sdes# func_convert_path_msys_to_w32 ARG 1868228692Sdes# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 1869228692Sdes# conversion to w32 is not available inside the cwrapper. Returns result in 1870228692Sdes# func_to_host_path_result. 1871228692Sdesfunc_convert_path_msys_to_w32 () 1872228692Sdes{ 1873228692Sdes $opt_debug 1874228692Sdes func_to_host_path_result="$1" 1875228692Sdes if test -n "$1"; then 1876228692Sdes # Remove leading and trailing path separator characters from ARG. MSYS 1877228692Sdes # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 1878228692Sdes # and winepath ignores them completely. 1879228692Sdes func_stripname : : "$1" 1880228692Sdes func_to_host_path_tmp1=$func_stripname_result 1881228692Sdes func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1882228692Sdes func_to_host_path_result="$func_convert_core_msys_to_w32_result" 1883228692Sdes func_convert_path_check : ";" \ 1884228692Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 1885228692Sdes func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1886228692Sdes fi 1887228692Sdes} 1888228692Sdes# end func_convert_path_msys_to_w32 1889125647Sdes 1890117610Sdes 1891228692Sdes# func_convert_path_cygwin_to_w32 ARG 1892228692Sdes# Convert path ARG from Cygwin to w32 format. Returns result in 1893228692Sdes# func_to_host_file_result. 1894228692Sdesfunc_convert_path_cygwin_to_w32 () 1895228692Sdes{ 1896228692Sdes $opt_debug 1897228692Sdes func_to_host_path_result="$1" 1898228692Sdes if test -n "$1"; then 1899228692Sdes # See func_convert_path_msys_to_w32: 1900228692Sdes func_stripname : : "$1" 1901228692Sdes func_to_host_path_tmp1=$func_stripname_result 1902228692Sdes func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 1903228692Sdes func_convert_path_check : ";" \ 1904228692Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 1905228692Sdes func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1906228692Sdes fi 1907228692Sdes} 1908228692Sdes# end func_convert_path_cygwin_to_w32 1909117610Sdes 1910228692Sdes 1911228692Sdes# func_convert_path_nix_to_w32 ARG 1912228692Sdes# Convert path ARG from *nix to w32 format. Requires a wine environment and 1913228692Sdes# a working winepath. Returns result in func_to_host_file_result. 1914228692Sdesfunc_convert_path_nix_to_w32 () 1915228692Sdes{ 1916228692Sdes $opt_debug 1917228692Sdes func_to_host_path_result="$1" 1918228692Sdes if test -n "$1"; then 1919228692Sdes # See func_convert_path_msys_to_w32: 1920228692Sdes func_stripname : : "$1" 1921228692Sdes func_to_host_path_tmp1=$func_stripname_result 1922228692Sdes func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1923228692Sdes func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 1924228692Sdes func_convert_path_check : ";" \ 1925228692Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 1926228692Sdes func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1927117610Sdes fi 1928228692Sdes} 1929228692Sdes# end func_convert_path_nix_to_w32 1930117610Sdes 1931228692Sdes 1932228692Sdes# func_convert_path_msys_to_cygwin ARG 1933228692Sdes# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1934228692Sdes# Returns result in func_to_host_file_result. 1935228692Sdesfunc_convert_path_msys_to_cygwin () 1936228692Sdes{ 1937228692Sdes $opt_debug 1938228692Sdes func_to_host_path_result="$1" 1939228692Sdes if test -n "$1"; then 1940228692Sdes # See func_convert_path_msys_to_w32: 1941228692Sdes func_stripname : : "$1" 1942228692Sdes func_to_host_path_tmp1=$func_stripname_result 1943228692Sdes func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1944228692Sdes func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 1945228692Sdes func_to_host_path_result="$func_cygpath_result" 1946228692Sdes func_convert_path_check : : \ 1947228692Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 1948228692Sdes func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1949117610Sdes fi 1950228692Sdes} 1951228692Sdes# end func_convert_path_msys_to_cygwin 1952117610Sdes 1953117610Sdes 1954228692Sdes# func_convert_path_nix_to_cygwin ARG 1955228692Sdes# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 1956228692Sdes# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 1957228692Sdes# func_to_host_file_result. 1958228692Sdesfunc_convert_path_nix_to_cygwin () 1959228692Sdes{ 1960228692Sdes $opt_debug 1961228692Sdes func_to_host_path_result="$1" 1962228692Sdes if test -n "$1"; then 1963228692Sdes # Remove leading and trailing path separator characters from 1964228692Sdes # ARG. msys behavior is inconsistent here, cygpath turns them 1965228692Sdes # into '.;' and ';.', and winepath ignores them completely. 1966228692Sdes func_stripname : : "$1" 1967228692Sdes func_to_host_path_tmp1=$func_stripname_result 1968228692Sdes func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1969228692Sdes func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 1970228692Sdes func_to_host_path_result="$func_cygpath_result" 1971228692Sdes func_convert_path_check : : \ 1972228692Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 1973228692Sdes func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1974228692Sdes fi 1975228692Sdes} 1976228692Sdes# end func_convert_path_nix_to_cygwin 1977228692Sdes 1978228692Sdes 1979228692Sdes# func_mode_compile arg... 1980228692Sdesfunc_mode_compile () 1981228692Sdes{ 1982228692Sdes $opt_debug 1983117610Sdes # Get the compilation command and the source file. 1984117610Sdes base_compile= 1985141098Sdes srcfile="$nonopt" # always keep a non-empty value in "srcfile" 1986141098Sdes suppress_opt=yes 1987117610Sdes suppress_output= 1988141098Sdes arg_mode=normal 1989141098Sdes libobj= 1990141098Sdes later= 1991228692Sdes pie_flag= 1992117610Sdes 1993117610Sdes for arg 1994117610Sdes do 1995174832Sdes case $arg_mode in 1996141098Sdes arg ) 1997141098Sdes # do not "continue". Instead, add this to base_compile 1998141098Sdes lastarg="$arg" 1999141098Sdes arg_mode=normal 2000141098Sdes ;; 2001125647Sdes 2002141098Sdes target ) 2003141098Sdes libobj="$arg" 2004141098Sdes arg_mode=normal 2005125647Sdes continue 2006125647Sdes ;; 2007125647Sdes 2008141098Sdes normal ) 2009141098Sdes # Accept any command-line options. 2010141098Sdes case $arg in 2011141098Sdes -o) 2012228692Sdes test -n "$libobj" && \ 2013228692Sdes func_fatal_error "you cannot specify \`-o' more than once" 2014141098Sdes arg_mode=target 2015141098Sdes continue 2016141098Sdes ;; 2017117610Sdes 2018228692Sdes -pie | -fpie | -fPIE) 2019228692Sdes func_append pie_flag " $arg" 2020141098Sdes continue 2021141098Sdes ;; 2022125647Sdes 2023228692Sdes -shared | -static | -prefer-pic | -prefer-non-pic) 2024228692Sdes func_append later " $arg" 2025228692Sdes continue 2026228692Sdes ;; 2027228692Sdes 2028141098Sdes -no-suppress) 2029141098Sdes suppress_opt=no 2030141098Sdes continue 2031141098Sdes ;; 2032125647Sdes 2033141098Sdes -Xcompiler) 2034141098Sdes arg_mode=arg # the next one goes into the "base_compile" arg list 2035141098Sdes continue # The current "srcfile" will either be retained or 2036141098Sdes ;; # replaced later. I would guess that would be a bug. 2037125647Sdes 2038141098Sdes -Wc,*) 2039228692Sdes func_stripname '-Wc,' '' "$arg" 2040228692Sdes args=$func_stripname_result 2041141098Sdes lastarg= 2042141098Sdes save_ifs="$IFS"; IFS=',' 2043228692Sdes for arg in $args; do 2044141098Sdes IFS="$save_ifs" 2045228692Sdes func_append_quoted lastarg "$arg" 2046141098Sdes done 2047125647Sdes IFS="$save_ifs" 2048228692Sdes func_stripname ' ' '' "$lastarg" 2049228692Sdes lastarg=$func_stripname_result 2050125647Sdes 2051141098Sdes # Add the arguments to base_compile. 2052228692Sdes func_append base_compile " $lastarg" 2053141098Sdes continue 2054141098Sdes ;; 2055117610Sdes 2056228692Sdes *) 2057141098Sdes # Accept the current argument as the source file. 2058141098Sdes # The previous "srcfile" becomes the current argument. 2059141098Sdes # 2060141098Sdes lastarg="$srcfile" 2061141098Sdes srcfile="$arg" 2062141098Sdes ;; 2063141098Sdes esac # case $arg 2064117610Sdes ;; 2065141098Sdes esac # case $arg_mode 2066117610Sdes 2067117610Sdes # Aesthetically quote the previous argument. 2068228692Sdes func_append_quoted base_compile "$lastarg" 2069141098Sdes done # for arg 2070117610Sdes 2071141098Sdes case $arg_mode in 2072141098Sdes arg) 2073228692Sdes func_fatal_error "you must specify an argument for -Xcompile" 2074117610Sdes ;; 2075141098Sdes target) 2076228692Sdes func_fatal_error "you must specify a target with \`-o'" 2077117610Sdes ;; 2078117610Sdes *) 2079141098Sdes # Get the name of the library object. 2080228692Sdes test -z "$libobj" && { 2081228692Sdes func_basename "$srcfile" 2082228692Sdes libobj="$func_basename_result" 2083228692Sdes } 2084117610Sdes ;; 2085117610Sdes esac 2086117610Sdes 2087117610Sdes # Recognize several different file suffixes. 2088117610Sdes # If the user specifies -o file.o, it is replaced with file.lo 2089125647Sdes case $libobj in 2090228692Sdes *.[cCFSifmso] | \ 2091228692Sdes *.ada | *.adb | *.ads | *.asm | \ 2092228692Sdes *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 2093236109Sdes *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 2094228692Sdes func_xform "$libobj" 2095228692Sdes libobj=$func_xform_result 2096228692Sdes ;; 2097117610Sdes esac 2098117610Sdes 2099125647Sdes case $libobj in 2100228692Sdes *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2101117610Sdes *) 2102228692Sdes func_fatal_error "cannot determine name of library object from \`$libobj'" 2103117610Sdes ;; 2104117610Sdes esac 2105117610Sdes 2106141098Sdes func_infer_tag $base_compile 2107141098Sdes 2108141098Sdes for arg in $later; do 2109141098Sdes case $arg in 2110228692Sdes -shared) 2111228692Sdes test "$build_libtool_libs" != yes && \ 2112228692Sdes func_fatal_configuration "can not build a shared library" 2113228692Sdes build_old_libs=no 2114228692Sdes continue 2115228692Sdes ;; 2116228692Sdes 2117141098Sdes -static) 2118228692Sdes build_libtool_libs=no 2119141098Sdes build_old_libs=yes 2120141098Sdes continue 2121141098Sdes ;; 2122141098Sdes 2123141098Sdes -prefer-pic) 2124141098Sdes pic_mode=yes 2125141098Sdes continue 2126141098Sdes ;; 2127141098Sdes 2128141098Sdes -prefer-non-pic) 2129141098Sdes pic_mode=no 2130141098Sdes continue 2131141098Sdes ;; 2132141098Sdes esac 2133141098Sdes done 2134141098Sdes 2135228692Sdes func_quote_for_eval "$libobj" 2136228692Sdes test "X$libobj" != "X$func_quote_for_eval_result" \ 2137228692Sdes && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 2138228692Sdes && func_warning "libobj name \`$libobj' may not contain shell special characters." 2139228692Sdes func_dirname_and_basename "$obj" "/" "" 2140228692Sdes objname="$func_basename_result" 2141228692Sdes xdir="$func_dirname_result" 2142141098Sdes lobj=${xdir}$objdir/$objname 2143141098Sdes 2144228692Sdes test -z "$base_compile" && \ 2145228692Sdes func_fatal_help "you must specify a compilation command" 2146117610Sdes 2147117610Sdes # Delete any leftover library objects. 2148117610Sdes if test "$build_old_libs" = yes; then 2149141098Sdes removelist="$obj $lobj $libobj ${libobj}T" 2150117610Sdes else 2151141098Sdes removelist="$lobj $libobj ${libobj}T" 2152117610Sdes fi 2153117610Sdes 2154125647Sdes # On Cygwin there's no "real" PIC flag so we must build both object types 2155125647Sdes case $host_os in 2156228692Sdes cygwin* | mingw* | pw32* | os2* | cegcc*) 2157125647Sdes pic_mode=default 2158125647Sdes ;; 2159125647Sdes esac 2160125647Sdes if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2161125647Sdes # non-PIC code in shared libraries is not supported 2162125647Sdes pic_mode=default 2163125647Sdes fi 2164125647Sdes 2165117610Sdes # Calculate the filename of the output object if compiler does 2166117610Sdes # not support -o with -c 2167117610Sdes if test "$compiler_c_o" = no; then 2168228692Sdes output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2169117610Sdes lockfile="$output_obj.lock" 2170117610Sdes else 2171141098Sdes output_obj= 2172117610Sdes need_locks=no 2173117610Sdes lockfile= 2174117610Sdes fi 2175117610Sdes 2176117610Sdes # Lock this critical section if it is needed 2177117610Sdes # We use this script file to make the link, it avoids creating a new file 2178117610Sdes if test "$need_locks" = yes; then 2179228692Sdes until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 2180228692Sdes func_echo "Waiting for $lockfile to be removed" 2181117610Sdes sleep 2 2182117610Sdes done 2183117610Sdes elif test "$need_locks" = warn; then 2184117610Sdes if test -f "$lockfile"; then 2185228692Sdes $ECHO "\ 2186117610Sdes*** ERROR, $lockfile exists and contains: 2187117610Sdes`cat $lockfile 2>/dev/null` 2188117610Sdes 2189117610SdesThis indicates that another process is trying to use the same 2190117610Sdestemporary object file, and libtool could not work around it because 2191117610Sdesyour compiler does not support \`-c' and \`-o' together. If you 2192117610Sdesrepeat this compilation, it may succeed, by chance, but you had better 2193117610Sdesavoid parallel builds (make -j) in this platform, or get a better 2194117610Sdescompiler." 2195117610Sdes 2196228692Sdes $opt_dry_run || $RM $removelist 2197141098Sdes exit $EXIT_FAILURE 2198117610Sdes fi 2199228692Sdes func_append removelist " $output_obj" 2200228692Sdes $ECHO "$srcfile" > "$lockfile" 2201117610Sdes fi 2202117610Sdes 2203228692Sdes $opt_dry_run || $RM $removelist 2204228692Sdes func_append removelist " $lockfile" 2205228692Sdes trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 2206117610Sdes 2207228692Sdes func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 2208228692Sdes srcfile=$func_to_tool_file_result 2209228692Sdes func_quote_for_eval "$srcfile" 2210228692Sdes qsrcfile=$func_quote_for_eval_result 2211141098Sdes 2212117610Sdes # Only build a PIC object if we are building libtool libraries. 2213117610Sdes if test "$build_libtool_libs" = yes; then 2214117610Sdes # Without this assignment, base_compile gets emptied. 2215117610Sdes fbsd_hideous_sh_bug=$base_compile 2216117610Sdes 2217125647Sdes if test "$pic_mode" != no; then 2218174832Sdes command="$base_compile $qsrcfile $pic_flag" 2219125647Sdes else 2220125647Sdes # Don't build PIC code 2221174832Sdes command="$base_compile $qsrcfile" 2222125647Sdes fi 2223117610Sdes 2224228692Sdes func_mkdir_p "$xdir$objdir" 2225141098Sdes 2226141098Sdes if test -z "$output_obj"; then 2227141098Sdes # Place PIC objects in $objdir 2228228692Sdes func_append command " -o $lobj" 2229117610Sdes fi 2230117610Sdes 2231228692Sdes func_show_eval_locale "$command" \ 2232228692Sdes 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2233141098Sdes 2234117610Sdes if test "$need_locks" = warn && 2235141098Sdes test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2236228692Sdes $ECHO "\ 2237117610Sdes*** ERROR, $lockfile contains: 2238117610Sdes`cat $lockfile 2>/dev/null` 2239117610Sdes 2240117610Sdesbut it should contain: 2241117610Sdes$srcfile 2242117610Sdes 2243117610SdesThis indicates that another process is trying to use the same 2244117610Sdestemporary object file, and libtool could not work around it because 2245117610Sdesyour compiler does not support \`-c' and \`-o' together. If you 2246117610Sdesrepeat this compilation, it may succeed, by chance, but you had better 2247117610Sdesavoid parallel builds (make -j) in this platform, or get a better 2248117610Sdescompiler." 2249117610Sdes 2250228692Sdes $opt_dry_run || $RM $removelist 2251141098Sdes exit $EXIT_FAILURE 2252117610Sdes fi 2253117610Sdes 2254117610Sdes # Just move the object if needed, then go on to compile the next one 2255141098Sdes if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 2256228692Sdes func_show_eval '$MV "$output_obj" "$lobj"' \ 2257228692Sdes 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2258117610Sdes fi 2259117610Sdes 2260141098Sdes # Allow error messages only from the first compilation. 2261141098Sdes if test "$suppress_opt" = yes; then 2262228692Sdes suppress_output=' >/dev/null 2>&1' 2263117610Sdes fi 2264117610Sdes fi 2265117610Sdes 2266117610Sdes # Only build a position-dependent object if we build old libraries. 2267117610Sdes if test "$build_old_libs" = yes; then 2268125647Sdes if test "$pic_mode" != yes; then 2269125647Sdes # Don't build PIC code 2270228692Sdes command="$base_compile $qsrcfile$pie_flag" 2271125647Sdes else 2272174832Sdes command="$base_compile $qsrcfile $pic_flag" 2273125647Sdes fi 2274117610Sdes if test "$compiler_c_o" = yes; then 2275228692Sdes func_append command " -o $obj" 2276117610Sdes fi 2277117610Sdes 2278117610Sdes # Suppress compiler output if we already did a PIC compilation. 2279228692Sdes func_append command "$suppress_output" 2280228692Sdes func_show_eval_locale "$command" \ 2281228692Sdes '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2282117610Sdes 2283117610Sdes if test "$need_locks" = warn && 2284141098Sdes test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2285228692Sdes $ECHO "\ 2286117610Sdes*** ERROR, $lockfile contains: 2287117610Sdes`cat $lockfile 2>/dev/null` 2288117610Sdes 2289117610Sdesbut it should contain: 2290117610Sdes$srcfile 2291117610Sdes 2292117610SdesThis indicates that another process is trying to use the same 2293117610Sdestemporary object file, and libtool could not work around it because 2294117610Sdesyour compiler does not support \`-c' and \`-o' together. If you 2295117610Sdesrepeat this compilation, it may succeed, by chance, but you had better 2296117610Sdesavoid parallel builds (make -j) in this platform, or get a better 2297117610Sdescompiler." 2298117610Sdes 2299228692Sdes $opt_dry_run || $RM $removelist 2300141098Sdes exit $EXIT_FAILURE 2301117610Sdes fi 2302117610Sdes 2303117610Sdes # Just move the object if needed 2304141098Sdes if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 2305228692Sdes func_show_eval '$MV "$output_obj" "$obj"' \ 2306228692Sdes 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2307228692Sdes fi 2308228692Sdes fi 2309228692Sdes 2310228692Sdes $opt_dry_run || { 2311228692Sdes func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2312228692Sdes 2313228692Sdes # Unlock the critical section if it was locked 2314228692Sdes if test "$need_locks" != no; then 2315228692Sdes removelist=$lockfile 2316228692Sdes $RM "$lockfile" 2317228692Sdes fi 2318228692Sdes } 2319228692Sdes 2320228692Sdes exit $EXIT_SUCCESS 2321228692Sdes} 2322228692Sdes 2323228692Sdes$opt_help || { 2324228692Sdes test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 2325228692Sdes} 2326228692Sdes 2327228692Sdesfunc_mode_help () 2328228692Sdes{ 2329228692Sdes # We need to display help for each of the modes. 2330228692Sdes case $opt_mode in 2331228692Sdes "") 2332228692Sdes # Generic help is extracted from the usage comments 2333228692Sdes # at the start of this file. 2334228692Sdes func_help 2335228692Sdes ;; 2336228692Sdes 2337228692Sdes clean) 2338228692Sdes $ECHO \ 2339228692Sdes"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2340228692Sdes 2341228692SdesRemove files from the build directory. 2342228692Sdes 2343228692SdesRM is the name of the program to use to delete files associated with each FILE 2344228692Sdes(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2345228692Sdesto RM. 2346228692Sdes 2347228692SdesIf FILE is a libtool library, object or program, all the files associated 2348228692Sdeswith it are deleted. Otherwise, only FILE itself is deleted using RM." 2349228692Sdes ;; 2350228692Sdes 2351228692Sdes compile) 2352228692Sdes $ECHO \ 2353228692Sdes"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2354228692Sdes 2355228692SdesCompile a source file into a libtool library object. 2356228692Sdes 2357228692SdesThis mode accepts the following additional options: 2358228692Sdes 2359228692Sdes -o OUTPUT-FILE set the output file name to OUTPUT-FILE 2360228692Sdes -no-suppress do not suppress compiler output for multiple passes 2361228692Sdes -prefer-pic try to build PIC objects only 2362228692Sdes -prefer-non-pic try to build non-PIC objects only 2363228692Sdes -shared do not build a \`.o' file suitable for static linking 2364228692Sdes -static only build a \`.o' file suitable for static linking 2365228692Sdes -Wc,FLAG pass FLAG directly to the compiler 2366228692Sdes 2367228692SdesCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 2368228692Sdesfrom the given SOURCEFILE. 2369228692Sdes 2370228692SdesThe output file name is determined by removing the directory component from 2371228692SdesSOURCEFILE, then substituting the C source code suffix \`.c' with the 2372228692Sdeslibrary object suffix, \`.lo'." 2373228692Sdes ;; 2374228692Sdes 2375228692Sdes execute) 2376228692Sdes $ECHO \ 2377228692Sdes"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2378228692Sdes 2379228692SdesAutomatically set library path, then run a program. 2380228692Sdes 2381228692SdesThis mode accepts the following additional options: 2382228692Sdes 2383228692Sdes -dlopen FILE add the directory containing FILE to the library path 2384228692Sdes 2385228692SdesThis mode sets the library path environment variable according to \`-dlopen' 2386228692Sdesflags. 2387228692Sdes 2388228692SdesIf any of the ARGS are libtool executable wrappers, then they are translated 2389228692Sdesinto their corresponding uninstalled binary, and any of their required library 2390228692Sdesdirectories are added to the library path. 2391228692Sdes 2392228692SdesThen, COMMAND is executed, with ARGS as arguments." 2393228692Sdes ;; 2394228692Sdes 2395228692Sdes finish) 2396228692Sdes $ECHO \ 2397228692Sdes"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2398228692Sdes 2399228692SdesComplete the installation of libtool libraries. 2400228692Sdes 2401228692SdesEach LIBDIR is a directory that contains libtool libraries. 2402228692Sdes 2403228692SdesThe commands that this mode executes may require superuser privileges. Use 2404228692Sdesthe \`--dry-run' option if you just want to see what would be executed." 2405228692Sdes ;; 2406228692Sdes 2407228692Sdes install) 2408228692Sdes $ECHO \ 2409228692Sdes"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2410228692Sdes 2411228692SdesInstall executables or libraries. 2412228692Sdes 2413228692SdesINSTALL-COMMAND is the installation command. The first component should be 2414228692Sdeseither the \`install' or \`cp' program. 2415228692Sdes 2416228692SdesThe following components of INSTALL-COMMAND are treated specially: 2417228692Sdes 2418228692Sdes -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2419228692Sdes 2420228692SdesThe rest of the components are interpreted as arguments to that command (only 2421228692SdesBSD-compatible install options are recognized)." 2422228692Sdes ;; 2423228692Sdes 2424228692Sdes link) 2425228692Sdes $ECHO \ 2426228692Sdes"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2427228692Sdes 2428228692SdesLink object files or libraries together to form another library, or to 2429228692Sdescreate an executable program. 2430228692Sdes 2431228692SdesLINK-COMMAND is a command using the C compiler that you would use to create 2432228692Sdesa program from several object files. 2433228692Sdes 2434228692SdesThe following components of LINK-COMMAND are treated specially: 2435228692Sdes 2436228692Sdes -all-static do not do any dynamic linking at all 2437228692Sdes -avoid-version do not add a version suffix if possible 2438228692Sdes -bindir BINDIR specify path to binaries directory (for systems where 2439228692Sdes libraries must be found in the PATH setting at runtime) 2440228692Sdes -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 2441228692Sdes -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 2442228692Sdes -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 2443228692Sdes -export-symbols SYMFILE 2444228692Sdes try to export only the symbols listed in SYMFILE 2445228692Sdes -export-symbols-regex REGEX 2446228692Sdes try to export only the symbols matching REGEX 2447228692Sdes -LLIBDIR search LIBDIR for required installed libraries 2448228692Sdes -lNAME OUTPUT-FILE requires the installed library libNAME 2449228692Sdes -module build a library that can dlopened 2450228692Sdes -no-fast-install disable the fast-install mode 2451228692Sdes -no-install link a not-installable executable 2452228692Sdes -no-undefined declare that a library does not refer to external symbols 2453228692Sdes -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 2454228692Sdes -objectlist FILE Use a list of object files found in FILE to specify objects 2455228692Sdes -precious-files-regex REGEX 2456228692Sdes don't remove output files matching REGEX 2457228692Sdes -release RELEASE specify package release information 2458228692Sdes -rpath LIBDIR the created library will eventually be installed in LIBDIR 2459228692Sdes -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 2460228692Sdes -shared only do dynamic linking of libtool libraries 2461228692Sdes -shrext SUFFIX override the standard shared library file extension 2462228692Sdes -static do not do any dynamic linking of uninstalled libtool libraries 2463228692Sdes -static-libtool-libs 2464228692Sdes do not do any dynamic linking of libtool libraries 2465228692Sdes -version-info CURRENT[:REVISION[:AGE]] 2466228692Sdes specify library version info [each variable defaults to 0] 2467228692Sdes -weak LIBNAME declare that the target provides the LIBNAME interface 2468228692Sdes -Wc,FLAG 2469228692Sdes -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 2470228692Sdes -Wl,FLAG 2471228692Sdes -Xlinker FLAG pass linker-specific FLAG directly to the linker 2472228692Sdes -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2473228692Sdes 2474228692SdesAll other options (arguments beginning with \`-') are ignored. 2475228692Sdes 2476228692SdesEvery other argument is treated as a filename. Files ending in \`.la' are 2477228692Sdestreated as uninstalled libtool libraries, other files are standard or library 2478228692Sdesobject files. 2479228692Sdes 2480228692SdesIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 2481228692Sdesonly library objects (\`.lo' files) may be specified, and \`-rpath' is 2482228692Sdesrequired, except when creating a convenience library. 2483228692Sdes 2484228692SdesIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 2485228692Sdesusing \`ar' and \`ranlib', or on Windows using \`lib'. 2486228692Sdes 2487228692SdesIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 2488228692Sdesis created, otherwise an executable program is created." 2489228692Sdes ;; 2490228692Sdes 2491228692Sdes uninstall) 2492228692Sdes $ECHO \ 2493228692Sdes"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2494228692Sdes 2495228692SdesRemove libraries from an installation directory. 2496228692Sdes 2497228692SdesRM is the name of the program to use to delete files associated with each FILE 2498228692Sdes(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2499228692Sdesto RM. 2500228692Sdes 2501228692SdesIf FILE is a libtool library, all the files associated with it are deleted. 2502228692SdesOtherwise, only FILE itself is deleted using RM." 2503228692Sdes ;; 2504228692Sdes 2505228692Sdes *) 2506228692Sdes func_fatal_help "invalid operation mode \`$opt_mode'" 2507228692Sdes ;; 2508228692Sdes esac 2509228692Sdes 2510228692Sdes echo 2511228692Sdes $ECHO "Try \`$progname --help' for more information about other modes." 2512228692Sdes} 2513228692Sdes 2514228692Sdes# Now that we've collected a possible --mode arg, show help if necessary 2515228692Sdesif $opt_help; then 2516228692Sdes if test "$opt_help" = :; then 2517228692Sdes func_mode_help 2518228692Sdes else 2519228692Sdes { 2520228692Sdes func_help noexit 2521228692Sdes for opt_mode in compile link execute install finish uninstall clean; do 2522228692Sdes func_mode_help 2523228692Sdes done 2524228692Sdes } | sed -n '1p; 2,$s/^Usage:/ or: /p' 2525228692Sdes { 2526228692Sdes func_help noexit 2527228692Sdes for opt_mode in compile link execute install finish uninstall clean; do 2528228692Sdes echo 2529228692Sdes func_mode_help 2530228692Sdes done 2531228692Sdes } | 2532228692Sdes sed '1d 2533228692Sdes /^When reporting/,/^Report/{ 2534228692Sdes H 2535228692Sdes d 2536228692Sdes } 2537228692Sdes $x 2538228692Sdes /information about other modes/d 2539228692Sdes /more detailed .*MODE/d 2540228692Sdes s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 2541228692Sdes fi 2542228692Sdes exit $? 2543228692Sdesfi 2544228692Sdes 2545228692Sdes 2546228692Sdes# func_mode_execute arg... 2547228692Sdesfunc_mode_execute () 2548228692Sdes{ 2549228692Sdes $opt_debug 2550228692Sdes # The first argument is the command name. 2551228692Sdes cmd="$nonopt" 2552228692Sdes test -z "$cmd" && \ 2553228692Sdes func_fatal_help "you must specify a COMMAND" 2554228692Sdes 2555228692Sdes # Handle -dlopen flags immediately. 2556228692Sdes for file in $opt_dlopen; do 2557228692Sdes test -f "$file" \ 2558228692Sdes || func_fatal_help "\`$file' is not a file" 2559228692Sdes 2560228692Sdes dir= 2561228692Sdes case $file in 2562228692Sdes *.la) 2563228692Sdes func_resolve_sysroot "$file" 2564228692Sdes file=$func_resolve_sysroot_result 2565228692Sdes 2566228692Sdes # Check to see that this really is a libtool archive. 2567228692Sdes func_lalib_unsafe_p "$file" \ 2568228692Sdes || func_fatal_help "\`$lib' is not a valid libtool archive" 2569228692Sdes 2570228692Sdes # Read the libtool library. 2571228692Sdes dlname= 2572228692Sdes library_names= 2573228692Sdes func_source "$file" 2574228692Sdes 2575228692Sdes # Skip this library if it cannot be dlopened. 2576228692Sdes if test -z "$dlname"; then 2577228692Sdes # Warn if it was a shared library. 2578228692Sdes test -n "$library_names" && \ 2579228692Sdes func_warning "\`$file' was not linked with \`-export-dynamic'" 2580228692Sdes continue 2581228692Sdes fi 2582228692Sdes 2583228692Sdes func_dirname "$file" "" "." 2584228692Sdes dir="$func_dirname_result" 2585228692Sdes 2586228692Sdes if test -f "$dir/$objdir/$dlname"; then 2587228692Sdes func_append dir "/$objdir" 2588117610Sdes else 2589228692Sdes if test ! -f "$dir/$dlname"; then 2590228692Sdes func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 2591228692Sdes fi 2592117610Sdes fi 2593228692Sdes ;; 2594228692Sdes 2595228692Sdes *.lo) 2596228692Sdes # Just add the directory containing the .lo file. 2597228692Sdes func_dirname "$file" "" "." 2598228692Sdes dir="$func_dirname_result" 2599228692Sdes ;; 2600228692Sdes 2601228692Sdes *) 2602228692Sdes func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 2603228692Sdes continue 2604228692Sdes ;; 2605228692Sdes esac 2606228692Sdes 2607228692Sdes # Get the absolute pathname. 2608228692Sdes absdir=`cd "$dir" && pwd` 2609228692Sdes test -n "$absdir" && dir="$absdir" 2610228692Sdes 2611228692Sdes # Now add the directory to shlibpath_var. 2612228692Sdes if eval "test -z \"\$$shlibpath_var\""; then 2613228692Sdes eval "$shlibpath_var=\"\$dir\"" 2614228692Sdes else 2615228692Sdes eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2616117610Sdes fi 2617228692Sdes done 2618117610Sdes 2619228692Sdes # This variable tells wrapper scripts just to set shlibpath_var 2620228692Sdes # rather than running their programs. 2621228692Sdes libtool_execute_magic="$magic" 2622141098Sdes 2623228692Sdes # Check if any of the arguments is a wrapper script. 2624228692Sdes args= 2625228692Sdes for file 2626228692Sdes do 2627228692Sdes case $file in 2628228692Sdes -* | *.la | *.lo ) ;; 2629228692Sdes *) 2630228692Sdes # Do a test to see if this is really a libtool program. 2631228692Sdes if func_ltwrapper_script_p "$file"; then 2632228692Sdes func_source "$file" 2633228692Sdes # Transform arg to wrapped name. 2634228692Sdes file="$progdir/$program" 2635228692Sdes elif func_ltwrapper_executable_p "$file"; then 2636228692Sdes func_ltwrapper_scriptname "$file" 2637228692Sdes func_source "$func_ltwrapper_scriptname_result" 2638228692Sdes # Transform arg to wrapped name. 2639228692Sdes file="$progdir/$program" 2640228692Sdes fi 2641228692Sdes ;; 2642228692Sdes esac 2643228692Sdes # Quote arguments (to preserve shell metacharacters). 2644228692Sdes func_append_quoted args "$file" 2645228692Sdes done 2646228692Sdes 2647228692Sdes if test "X$opt_dry_run" = Xfalse; then 2648228692Sdes if test -n "$shlibpath_var"; then 2649228692Sdes # Export the shlibpath_var. 2650228692Sdes eval "export $shlibpath_var" 2651228692Sdes fi 2652228692Sdes 2653228692Sdes # Restore saved environment variables 2654228692Sdes for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 2655228692Sdes do 2656228692Sdes eval "if test \"\${save_$lt_var+set}\" = set; then 2657228692Sdes $lt_var=\$save_$lt_var; export $lt_var 2658228692Sdes else 2659228692Sdes $lt_unset $lt_var 2660228692Sdes fi" 2661228692Sdes done 2662228692Sdes 2663228692Sdes # Now prepare to actually exec the command. 2664228692Sdes exec_cmd="\$cmd$args" 2665141098Sdes else 2666228692Sdes # Display what would be done. 2667228692Sdes if test -n "$shlibpath_var"; then 2668228692Sdes eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 2669228692Sdes echo "export $shlibpath_var" 2670228692Sdes fi 2671228692Sdes $ECHO "$cmd$args" 2672228692Sdes exit $EXIT_SUCCESS 2673228692Sdes fi 2674228692Sdes} 2675141098Sdes 2676228692Sdestest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2677228692Sdes 2678228692Sdes 2679228692Sdes# func_mode_finish arg... 2680228692Sdesfunc_mode_finish () 2681228692Sdes{ 2682228692Sdes $opt_debug 2683228692Sdes libs= 2684228692Sdes libdirs= 2685228692Sdes admincmds= 2686228692Sdes 2687228692Sdes for opt in "$nonopt" ${1+"$@"} 2688228692Sdes do 2689228692Sdes if test -d "$opt"; then 2690228692Sdes func_append libdirs " $opt" 2691228692Sdes 2692228692Sdes elif test -f "$opt"; then 2693228692Sdes if func_lalib_unsafe_p "$opt"; then 2694228692Sdes func_append libs " $opt" 2695228692Sdes else 2696228692Sdes func_warning "\`$opt' is not a valid libtool archive" 2697228692Sdes fi 2698228692Sdes 2699228692Sdes else 2700228692Sdes func_fatal_error "invalid argument \`$opt'" 2701228692Sdes fi 2702228692Sdes done 2703228692Sdes 2704228692Sdes if test -n "$libs"; then 2705228692Sdes if test -n "$lt_sysroot"; then 2706228692Sdes sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 2707228692Sdes sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 2708228692Sdes else 2709228692Sdes sysroot_cmd= 2710228692Sdes fi 2711228692Sdes 2712228692Sdes # Remove sysroot references 2713228692Sdes if $opt_dry_run; then 2714228692Sdes for lib in $libs; do 2715228692Sdes echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 2716228692Sdes done 2717228692Sdes else 2718228692Sdes tmpdir=`func_mktempdir` 2719228692Sdes for lib in $libs; do 2720228692Sdes sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 2721228692Sdes > $tmpdir/tmp-la 2722228692Sdes mv -f $tmpdir/tmp-la $lib 2723228692Sdes done 2724228692Sdes ${RM}r "$tmpdir" 2725228692Sdes fi 2726117610Sdes fi 2727117610Sdes 2728228692Sdes if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2729228692Sdes for libdir in $libdirs; do 2730228692Sdes if test -n "$finish_cmds"; then 2731228692Sdes # Do each command in the finish commands. 2732228692Sdes func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 2733228692Sdes'"$cmd"'"' 2734228692Sdes fi 2735228692Sdes if test -n "$finish_eval"; then 2736228692Sdes # Do the single finish_eval. 2737228692Sdes eval cmds=\"$finish_eval\" 2738228692Sdes $opt_dry_run || eval "$cmds" || func_append admincmds " 2739228692Sdes $cmds" 2740228692Sdes fi 2741228692Sdes done 2742228692Sdes fi 2743141098Sdes 2744228692Sdes # Exit here if they wanted silent mode. 2745228692Sdes $opt_silent && exit $EXIT_SUCCESS 2746228692Sdes 2747228692Sdes if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2748228692Sdes echo "----------------------------------------------------------------------" 2749228692Sdes echo "Libraries have been installed in:" 2750228692Sdes for libdir in $libdirs; do 2751228692Sdes $ECHO " $libdir" 2752228692Sdes done 2753228692Sdes echo 2754228692Sdes echo "If you ever happen to want to link against installed libraries" 2755228692Sdes echo "in a given directory, LIBDIR, you must either use libtool, and" 2756228692Sdes echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 2757228692Sdes echo "flag during linking and do at least one of the following:" 2758228692Sdes if test -n "$shlibpath_var"; then 2759228692Sdes echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 2760228692Sdes echo " during execution" 2761228692Sdes fi 2762228692Sdes if test -n "$runpath_var"; then 2763228692Sdes echo " - add LIBDIR to the \`$runpath_var' environment variable" 2764228692Sdes echo " during linking" 2765228692Sdes fi 2766228692Sdes if test -n "$hardcode_libdir_flag_spec"; then 2767228692Sdes libdir=LIBDIR 2768228692Sdes eval flag=\"$hardcode_libdir_flag_spec\" 2769228692Sdes 2770228692Sdes $ECHO " - use the \`$flag' linker flag" 2771228692Sdes fi 2772228692Sdes if test -n "$admincmds"; then 2773228692Sdes $ECHO " - have your system administrator run these commands:$admincmds" 2774228692Sdes fi 2775228692Sdes if test -f /etc/ld.so.conf; then 2776228692Sdes echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 2777228692Sdes fi 2778228692Sdes echo 2779228692Sdes 2780228692Sdes echo "See any operating system documentation about shared libraries for" 2781228692Sdes case $host in 2782228692Sdes solaris2.[6789]|solaris2.1[0-9]) 2783228692Sdes echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 2784228692Sdes echo "pages." 2785228692Sdes ;; 2786228692Sdes *) 2787228692Sdes echo "more information, such as the ld(1) and ld.so(8) manual pages." 2788228692Sdes ;; 2789228692Sdes esac 2790228692Sdes echo "----------------------------------------------------------------------" 2791117610Sdes fi 2792228692Sdes exit $EXIT_SUCCESS 2793228692Sdes} 2794117610Sdes 2795228692Sdestest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2796228692Sdes 2797228692Sdes 2798228692Sdes# func_mode_install arg... 2799228692Sdesfunc_mode_install () 2800228692Sdes{ 2801228692Sdes $opt_debug 2802228692Sdes # There may be an optional sh(1) argument at the beginning of 2803228692Sdes # install_prog (especially on Windows NT). 2804228692Sdes if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 2805228692Sdes # Allow the use of GNU shtool's install command. 2806228692Sdes case $nonopt in *shtool*) :;; *) false;; esac; then 2807228692Sdes # Aesthetically quote it. 2808228692Sdes func_quote_for_eval "$nonopt" 2809228692Sdes install_prog="$func_quote_for_eval_result " 2810228692Sdes arg=$1 2811228692Sdes shift 2812228692Sdes else 2813228692Sdes install_prog= 2814228692Sdes arg=$nonopt 2815228692Sdes fi 2816228692Sdes 2817228692Sdes # The real first argument should be the name of the installation program. 2818228692Sdes # Aesthetically quote it. 2819228692Sdes func_quote_for_eval "$arg" 2820228692Sdes func_append install_prog "$func_quote_for_eval_result" 2821228692Sdes install_shared_prog=$install_prog 2822228692Sdes case " $install_prog " in 2823228692Sdes *[\\\ /]cp\ *) install_cp=: ;; 2824228692Sdes *) install_cp=false ;; 2825228692Sdes esac 2826228692Sdes 2827228692Sdes # We need to accept at least all the BSD install flags. 2828228692Sdes dest= 2829228692Sdes files= 2830228692Sdes opts= 2831228692Sdes prev= 2832228692Sdes install_type= 2833228692Sdes isdir=no 2834228692Sdes stripme= 2835228692Sdes no_mode=: 2836228692Sdes for arg 2837228692Sdes do 2838228692Sdes arg2= 2839228692Sdes if test -n "$dest"; then 2840228692Sdes func_append files " $dest" 2841228692Sdes dest=$arg 2842228692Sdes continue 2843228692Sdes fi 2844228692Sdes 2845228692Sdes case $arg in 2846228692Sdes -d) isdir=yes ;; 2847228692Sdes -f) 2848228692Sdes if $install_cp; then :; else 2849228692Sdes prev=$arg 2850228692Sdes fi 2851228692Sdes ;; 2852228692Sdes -g | -m | -o) 2853228692Sdes prev=$arg 2854228692Sdes ;; 2855228692Sdes -s) 2856228692Sdes stripme=" -s" 2857228692Sdes continue 2858228692Sdes ;; 2859228692Sdes -*) 2860228692Sdes ;; 2861228692Sdes *) 2862228692Sdes # If the previous option needed an argument, then skip it. 2863228692Sdes if test -n "$prev"; then 2864228692Sdes if test "x$prev" = x-m && test -n "$install_override_mode"; then 2865228692Sdes arg2=$install_override_mode 2866228692Sdes no_mode=false 2867228692Sdes fi 2868228692Sdes prev= 2869228692Sdes else 2870228692Sdes dest=$arg 2871228692Sdes continue 2872228692Sdes fi 2873228692Sdes ;; 2874228692Sdes esac 2875228692Sdes 2876228692Sdes # Aesthetically quote the argument. 2877228692Sdes func_quote_for_eval "$arg" 2878228692Sdes func_append install_prog " $func_quote_for_eval_result" 2879228692Sdes if test -n "$arg2"; then 2880228692Sdes func_quote_for_eval "$arg2" 2881228692Sdes fi 2882228692Sdes func_append install_shared_prog " $func_quote_for_eval_result" 2883228692Sdes done 2884228692Sdes 2885228692Sdes test -z "$install_prog" && \ 2886228692Sdes func_fatal_help "you must specify an install program" 2887228692Sdes 2888228692Sdes test -n "$prev" && \ 2889228692Sdes func_fatal_help "the \`$prev' option requires an argument" 2890228692Sdes 2891228692Sdes if test -n "$install_override_mode" && $no_mode; then 2892228692Sdes if $install_cp; then :; else 2893228692Sdes func_quote_for_eval "$install_override_mode" 2894228692Sdes func_append install_shared_prog " -m $func_quote_for_eval_result" 2895228692Sdes fi 2896228692Sdes fi 2897228692Sdes 2898228692Sdes if test -z "$files"; then 2899228692Sdes if test -z "$dest"; then 2900228692Sdes func_fatal_help "no file or destination specified" 2901228692Sdes else 2902228692Sdes func_fatal_help "you must specify a destination" 2903228692Sdes fi 2904228692Sdes fi 2905228692Sdes 2906228692Sdes # Strip any trailing slash from the destination. 2907228692Sdes func_stripname '' '/' "$dest" 2908228692Sdes dest=$func_stripname_result 2909228692Sdes 2910228692Sdes # Check to see that the destination is a directory. 2911228692Sdes test -d "$dest" && isdir=yes 2912228692Sdes if test "$isdir" = yes; then 2913228692Sdes destdir="$dest" 2914228692Sdes destname= 2915228692Sdes else 2916228692Sdes func_dirname_and_basename "$dest" "" "." 2917228692Sdes destdir="$func_dirname_result" 2918228692Sdes destname="$func_basename_result" 2919228692Sdes 2920228692Sdes # Not a directory, so check to see that there is only one file specified. 2921228692Sdes set dummy $files; shift 2922228692Sdes test "$#" -gt 1 && \ 2923228692Sdes func_fatal_help "\`$dest' is not a directory" 2924228692Sdes fi 2925228692Sdes case $destdir in 2926228692Sdes [\\/]* | [A-Za-z]:[\\/]*) ;; 2927228692Sdes *) 2928228692Sdes for file in $files; do 2929228692Sdes case $file in 2930228692Sdes *.lo) ;; 2931228692Sdes *) 2932228692Sdes func_fatal_help "\`$destdir' must be an absolute directory name" 2933228692Sdes ;; 2934228692Sdes esac 2935228692Sdes done 2936228692Sdes ;; 2937228692Sdes esac 2938228692Sdes 2939228692Sdes # This variable tells wrapper scripts just to set variables rather 2940228692Sdes # than running their programs. 2941228692Sdes libtool_install_magic="$magic" 2942228692Sdes 2943228692Sdes staticlibs= 2944228692Sdes future_libdirs= 2945228692Sdes current_libdirs= 2946228692Sdes for file in $files; do 2947228692Sdes 2948228692Sdes # Do each installation. 2949228692Sdes case $file in 2950228692Sdes *.$libext) 2951228692Sdes # Do the static libraries later. 2952228692Sdes func_append staticlibs " $file" 2953228692Sdes ;; 2954228692Sdes 2955228692Sdes *.la) 2956228692Sdes func_resolve_sysroot "$file" 2957228692Sdes file=$func_resolve_sysroot_result 2958228692Sdes 2959228692Sdes # Check to see that this really is a libtool archive. 2960228692Sdes func_lalib_unsafe_p "$file" \ 2961228692Sdes || func_fatal_help "\`$file' is not a valid libtool archive" 2962228692Sdes 2963228692Sdes library_names= 2964228692Sdes old_library= 2965228692Sdes relink_command= 2966228692Sdes func_source "$file" 2967228692Sdes 2968228692Sdes # Add the libdir to current_libdirs if it is the destination. 2969228692Sdes if test "X$destdir" = "X$libdir"; then 2970228692Sdes case "$current_libdirs " in 2971228692Sdes *" $libdir "*) ;; 2972228692Sdes *) func_append current_libdirs " $libdir" ;; 2973228692Sdes esac 2974228692Sdes else 2975228692Sdes # Note the libdir as a future libdir. 2976228692Sdes case "$future_libdirs " in 2977228692Sdes *" $libdir "*) ;; 2978228692Sdes *) func_append future_libdirs " $libdir" ;; 2979228692Sdes esac 2980228692Sdes fi 2981228692Sdes 2982228692Sdes func_dirname "$file" "/" "" 2983228692Sdes dir="$func_dirname_result" 2984228692Sdes func_append dir "$objdir" 2985228692Sdes 2986228692Sdes if test -n "$relink_command"; then 2987228692Sdes # Determine the prefix the user has applied to our future dir. 2988228692Sdes inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2989228692Sdes 2990228692Sdes # Don't allow the user to place us outside of our expected 2991228692Sdes # location b/c this prevents finding dependent libraries that 2992228692Sdes # are installed to the same prefix. 2993228692Sdes # At present, this check doesn't affect windows .dll's that 2994228692Sdes # are installed into $libdir/../bin (currently, that works fine) 2995228692Sdes # but it's something to keep an eye on. 2996228692Sdes test "$inst_prefix_dir" = "$destdir" && \ 2997228692Sdes func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 2998228692Sdes 2999228692Sdes if test -n "$inst_prefix_dir"; then 3000228692Sdes # Stick the inst_prefix_dir data into the link command. 3001228692Sdes relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 3002228692Sdes else 3003228692Sdes relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 3004228692Sdes fi 3005228692Sdes 3006228692Sdes func_warning "relinking \`$file'" 3007228692Sdes func_show_eval "$relink_command" \ 3008228692Sdes 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 3009228692Sdes fi 3010228692Sdes 3011228692Sdes # See the names of the shared library. 3012228692Sdes set dummy $library_names; shift 3013228692Sdes if test -n "$1"; then 3014228692Sdes realname="$1" 3015228692Sdes shift 3016228692Sdes 3017228692Sdes srcname="$realname" 3018228692Sdes test -n "$relink_command" && srcname="$realname"T 3019228692Sdes 3020228692Sdes # Install the shared library and build the symlinks. 3021228692Sdes func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 3022228692Sdes 'exit $?' 3023228692Sdes tstripme="$stripme" 3024228692Sdes case $host_os in 3025228692Sdes cygwin* | mingw* | pw32* | cegcc*) 3026228692Sdes case $realname in 3027228692Sdes *.dll.a) 3028228692Sdes tstripme="" 3029228692Sdes ;; 3030228692Sdes esac 3031228692Sdes ;; 3032228692Sdes esac 3033228692Sdes if test -n "$tstripme" && test -n "$striplib"; then 3034228692Sdes func_show_eval "$striplib $destdir/$realname" 'exit $?' 3035228692Sdes fi 3036228692Sdes 3037228692Sdes if test "$#" -gt 0; then 3038228692Sdes # Delete the old symlinks, and create new ones. 3039228692Sdes # Try `ln -sf' first, because the `ln' binary might depend on 3040228692Sdes # the symlink we replace! Solaris /bin/ln does not understand -f, 3041228692Sdes # so we also need to try rm && ln -s. 3042228692Sdes for linkname 3043228692Sdes do 3044228692Sdes test "$linkname" != "$realname" \ 3045228692Sdes && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3046228692Sdes done 3047228692Sdes fi 3048228692Sdes 3049228692Sdes # Do each command in the postinstall commands. 3050228692Sdes lib="$destdir/$realname" 3051228692Sdes func_execute_cmds "$postinstall_cmds" 'exit $?' 3052228692Sdes fi 3053228692Sdes 3054228692Sdes # Install the pseudo-library for information purposes. 3055228692Sdes func_basename "$file" 3056228692Sdes name="$func_basename_result" 3057228692Sdes instname="$dir/$name"i 3058228692Sdes func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3059228692Sdes 3060228692Sdes # Maybe install the static library, too. 3061228692Sdes test -n "$old_library" && func_append staticlibs " $dir/$old_library" 3062228692Sdes ;; 3063228692Sdes 3064228692Sdes *.lo) 3065228692Sdes # Install (i.e. copy) a libtool object. 3066228692Sdes 3067228692Sdes # Figure out destination file name, if it wasn't already specified. 3068228692Sdes if test -n "$destname"; then 3069228692Sdes destfile="$destdir/$destname" 3070228692Sdes else 3071228692Sdes func_basename "$file" 3072228692Sdes destfile="$func_basename_result" 3073228692Sdes destfile="$destdir/$destfile" 3074228692Sdes fi 3075228692Sdes 3076228692Sdes # Deduce the name of the destination old-style object file. 3077228692Sdes case $destfile in 3078228692Sdes *.lo) 3079228692Sdes func_lo2o "$destfile" 3080228692Sdes staticdest=$func_lo2o_result 3081228692Sdes ;; 3082228692Sdes *.$objext) 3083228692Sdes staticdest="$destfile" 3084228692Sdes destfile= 3085228692Sdes ;; 3086228692Sdes *) 3087228692Sdes func_fatal_help "cannot copy a libtool object to \`$destfile'" 3088228692Sdes ;; 3089228692Sdes esac 3090228692Sdes 3091228692Sdes # Install the libtool object if requested. 3092228692Sdes test -n "$destfile" && \ 3093228692Sdes func_show_eval "$install_prog $file $destfile" 'exit $?' 3094228692Sdes 3095228692Sdes # Install the old object if enabled. 3096228692Sdes if test "$build_old_libs" = yes; then 3097228692Sdes # Deduce the name of the old-style object file. 3098228692Sdes func_lo2o "$file" 3099228692Sdes staticobj=$func_lo2o_result 3100228692Sdes func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3101228692Sdes fi 3102228692Sdes exit $EXIT_SUCCESS 3103228692Sdes ;; 3104228692Sdes 3105228692Sdes *) 3106228692Sdes # Figure out destination file name, if it wasn't already specified. 3107228692Sdes if test -n "$destname"; then 3108228692Sdes destfile="$destdir/$destname" 3109228692Sdes else 3110228692Sdes func_basename "$file" 3111228692Sdes destfile="$func_basename_result" 3112228692Sdes destfile="$destdir/$destfile" 3113228692Sdes fi 3114228692Sdes 3115228692Sdes # If the file is missing, and there is a .exe on the end, strip it 3116228692Sdes # because it is most likely a libtool script we actually want to 3117228692Sdes # install 3118228692Sdes stripped_ext="" 3119228692Sdes case $file in 3120228692Sdes *.exe) 3121228692Sdes if test ! -f "$file"; then 3122228692Sdes func_stripname '' '.exe' "$file" 3123228692Sdes file=$func_stripname_result 3124228692Sdes stripped_ext=".exe" 3125228692Sdes fi 3126228692Sdes ;; 3127228692Sdes esac 3128228692Sdes 3129228692Sdes # Do a test to see if this is really a libtool program. 3130228692Sdes case $host in 3131228692Sdes *cygwin* | *mingw*) 3132228692Sdes if func_ltwrapper_executable_p "$file"; then 3133228692Sdes func_ltwrapper_scriptname "$file" 3134228692Sdes wrapper=$func_ltwrapper_scriptname_result 3135228692Sdes else 3136228692Sdes func_stripname '' '.exe' "$file" 3137228692Sdes wrapper=$func_stripname_result 3138228692Sdes fi 3139228692Sdes ;; 3140228692Sdes *) 3141228692Sdes wrapper=$file 3142228692Sdes ;; 3143228692Sdes esac 3144228692Sdes if func_ltwrapper_script_p "$wrapper"; then 3145228692Sdes notinst_deplibs= 3146228692Sdes relink_command= 3147228692Sdes 3148228692Sdes func_source "$wrapper" 3149228692Sdes 3150228692Sdes # Check the variables that should have been set. 3151228692Sdes test -z "$generated_by_libtool_version" && \ 3152228692Sdes func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3153228692Sdes 3154228692Sdes finalize=yes 3155228692Sdes for lib in $notinst_deplibs; do 3156228692Sdes # Check to see that each library is installed. 3157228692Sdes libdir= 3158228692Sdes if test -f "$lib"; then 3159228692Sdes func_source "$lib" 3160228692Sdes fi 3161228692Sdes libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 3162228692Sdes if test -n "$libdir" && test ! -f "$libfile"; then 3163228692Sdes func_warning "\`$lib' has not been installed in \`$libdir'" 3164228692Sdes finalize=no 3165228692Sdes fi 3166228692Sdes done 3167228692Sdes 3168228692Sdes relink_command= 3169228692Sdes func_source "$wrapper" 3170228692Sdes 3171228692Sdes outputname= 3172228692Sdes if test "$fast_install" = no && test -n "$relink_command"; then 3173228692Sdes $opt_dry_run || { 3174228692Sdes if test "$finalize" = yes; then 3175228692Sdes tmpdir=`func_mktempdir` 3176228692Sdes func_basename "$file$stripped_ext" 3177228692Sdes file="$func_basename_result" 3178228692Sdes outputname="$tmpdir/$file" 3179228692Sdes # Replace the output file specification. 3180228692Sdes relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 3181228692Sdes 3182228692Sdes $opt_silent || { 3183228692Sdes func_quote_for_expand "$relink_command" 3184228692Sdes eval "func_echo $func_quote_for_expand_result" 3185228692Sdes } 3186228692Sdes if eval "$relink_command"; then : 3187228692Sdes else 3188228692Sdes func_error "error: relink \`$file' with the above command before installing it" 3189228692Sdes $opt_dry_run || ${RM}r "$tmpdir" 3190228692Sdes continue 3191228692Sdes fi 3192228692Sdes file="$outputname" 3193228692Sdes else 3194228692Sdes func_warning "cannot relink \`$file'" 3195228692Sdes fi 3196228692Sdes } 3197228692Sdes else 3198228692Sdes # Install the binary that we compiled earlier. 3199228692Sdes file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 3200228692Sdes fi 3201228692Sdes fi 3202228692Sdes 3203228692Sdes # remove .exe since cygwin /usr/bin/install will append another 3204228692Sdes # one anyway 3205228692Sdes case $install_prog,$host in 3206228692Sdes */usr/bin/install*,*cygwin*) 3207228692Sdes case $file:$destfile in 3208228692Sdes *.exe:*.exe) 3209228692Sdes # this is ok 3210228692Sdes ;; 3211228692Sdes *.exe:*) 3212228692Sdes destfile=$destfile.exe 3213228692Sdes ;; 3214228692Sdes *:*.exe) 3215228692Sdes func_stripname '' '.exe' "$destfile" 3216228692Sdes destfile=$func_stripname_result 3217228692Sdes ;; 3218228692Sdes esac 3219228692Sdes ;; 3220228692Sdes esac 3221228692Sdes func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 3222228692Sdes $opt_dry_run || if test -n "$outputname"; then 3223228692Sdes ${RM}r "$tmpdir" 3224228692Sdes fi 3225228692Sdes ;; 3226228692Sdes esac 3227228692Sdes done 3228228692Sdes 3229228692Sdes for file in $staticlibs; do 3230228692Sdes func_basename "$file" 3231228692Sdes name="$func_basename_result" 3232228692Sdes 3233228692Sdes # Set up the ranlib parameters. 3234228692Sdes oldlib="$destdir/$name" 3235236109Sdes func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 3236236109Sdes tool_oldlib=$func_to_tool_file_result 3237228692Sdes 3238228692Sdes func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 3239228692Sdes 3240228692Sdes if test -n "$stripme" && test -n "$old_striplib"; then 3241236109Sdes func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 3242228692Sdes fi 3243228692Sdes 3244228692Sdes # Do each command in the postinstall commands. 3245228692Sdes func_execute_cmds "$old_postinstall_cmds" 'exit $?' 3246228692Sdes done 3247228692Sdes 3248228692Sdes test -n "$future_libdirs" && \ 3249228692Sdes func_warning "remember to run \`$progname --finish$future_libdirs'" 3250228692Sdes 3251228692Sdes if test -n "$current_libdirs"; then 3252228692Sdes # Maybe just do a dry run. 3253228692Sdes $opt_dry_run && current_libdirs=" -n$current_libdirs" 3254228692Sdes exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 3255228692Sdes else 3256228692Sdes exit $EXIT_SUCCESS 3257228692Sdes fi 3258228692Sdes} 3259228692Sdes 3260228692Sdestest "$opt_mode" = install && func_mode_install ${1+"$@"} 3261228692Sdes 3262228692Sdes 3263228692Sdes# func_generate_dlsyms outputname originator pic_p 3264228692Sdes# Extract symbols from dlprefiles and create ${outputname}S.o with 3265228692Sdes# a dlpreopen symbol table. 3266228692Sdesfunc_generate_dlsyms () 3267228692Sdes{ 3268228692Sdes $opt_debug 3269228692Sdes my_outputname="$1" 3270228692Sdes my_originator="$2" 3271228692Sdes my_pic_p="${3-no}" 3272228692Sdes my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 3273228692Sdes my_dlsyms= 3274228692Sdes 3275228692Sdes if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 3276228692Sdes if test -n "$NM" && test -n "$global_symbol_pipe"; then 3277228692Sdes my_dlsyms="${my_outputname}S.c" 3278228692Sdes else 3279228692Sdes func_error "not configured to extract global symbols from dlpreopened files" 3280228692Sdes fi 3281228692Sdes fi 3282228692Sdes 3283228692Sdes if test -n "$my_dlsyms"; then 3284228692Sdes case $my_dlsyms in 3285228692Sdes "") ;; 3286228692Sdes *.c) 3287228692Sdes # Discover the nlist of each of the dlfiles. 3288228692Sdes nlist="$output_objdir/${my_outputname}.nm" 3289228692Sdes 3290228692Sdes func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3291228692Sdes 3292228692Sdes # Parse the name list into a source file. 3293228692Sdes func_verbose "creating $output_objdir/$my_dlsyms" 3294228692Sdes 3295228692Sdes $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 3296228692Sdes/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 3297228692Sdes/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3298228692Sdes 3299228692Sdes#ifdef __cplusplus 3300228692Sdesextern \"C\" { 3301228692Sdes#endif 3302228692Sdes 3303228692Sdes#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 3304228692Sdes#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 3305228692Sdes#endif 3306228692Sdes 3307228692Sdes/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 3308228692Sdes#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 3309228692Sdes/* DATA imports from DLLs on WIN32 con't be const, because runtime 3310228692Sdes relocations are performed -- see ld's documentation on pseudo-relocs. */ 3311228692Sdes# define LT_DLSYM_CONST 3312228692Sdes#elif defined(__osf__) 3313228692Sdes/* This system does not cope well with relocations in const data. */ 3314228692Sdes# define LT_DLSYM_CONST 3315228692Sdes#else 3316228692Sdes# define LT_DLSYM_CONST const 3317228692Sdes#endif 3318228692Sdes 3319228692Sdes/* External symbol declarations for the compiler. */\ 3320228692Sdes" 3321228692Sdes 3322228692Sdes if test "$dlself" = yes; then 3323228692Sdes func_verbose "generating symbol list for \`$output'" 3324228692Sdes 3325228692Sdes $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3326228692Sdes 3327228692Sdes # Add our own program objects to the symbol list. 3328228692Sdes progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 3329228692Sdes for progfile in $progfiles; do 3330228692Sdes func_to_tool_file "$progfile" func_convert_file_msys_to_w32 3331228692Sdes func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 3332228692Sdes $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3333228692Sdes done 3334228692Sdes 3335228692Sdes if test -n "$exclude_expsyms"; then 3336228692Sdes $opt_dry_run || { 3337228692Sdes eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 3338228692Sdes eval '$MV "$nlist"T "$nlist"' 3339228692Sdes } 3340228692Sdes fi 3341228692Sdes 3342228692Sdes if test -n "$export_symbols_regex"; then 3343228692Sdes $opt_dry_run || { 3344228692Sdes eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 3345228692Sdes eval '$MV "$nlist"T "$nlist"' 3346228692Sdes } 3347228692Sdes fi 3348228692Sdes 3349228692Sdes # Prepare the list of exported symbols 3350228692Sdes if test -z "$export_symbols"; then 3351228692Sdes export_symbols="$output_objdir/$outputname.exp" 3352228692Sdes $opt_dry_run || { 3353228692Sdes $RM $export_symbols 3354228692Sdes eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 3355228692Sdes case $host in 3356228692Sdes *cygwin* | *mingw* | *cegcc* ) 3357228692Sdes eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3358228692Sdes eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 3359228692Sdes ;; 3360228692Sdes esac 3361228692Sdes } 3362228692Sdes else 3363228692Sdes $opt_dry_run || { 3364228692Sdes eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 3365228692Sdes eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 3366228692Sdes eval '$MV "$nlist"T "$nlist"' 3367228692Sdes case $host in 3368228692Sdes *cygwin* | *mingw* | *cegcc* ) 3369228692Sdes eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3370228692Sdes eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 3371228692Sdes ;; 3372228692Sdes esac 3373228692Sdes } 3374228692Sdes fi 3375228692Sdes fi 3376228692Sdes 3377228692Sdes for dlprefile in $dlprefiles; do 3378228692Sdes func_verbose "extracting global C symbols from \`$dlprefile'" 3379228692Sdes func_basename "$dlprefile" 3380228692Sdes name="$func_basename_result" 3381228692Sdes case $host in 3382228692Sdes *cygwin* | *mingw* | *cegcc* ) 3383228692Sdes # if an import library, we need to obtain dlname 3384228692Sdes if func_win32_import_lib_p "$dlprefile"; then 3385228692Sdes func_tr_sh "$dlprefile" 3386228692Sdes eval "curr_lafile=\$libfile_$func_tr_sh_result" 3387228692Sdes dlprefile_dlbasename="" 3388228692Sdes if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 3389228692Sdes # Use subshell, to avoid clobbering current variable values 3390228692Sdes dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 3391228692Sdes if test -n "$dlprefile_dlname" ; then 3392228692Sdes func_basename "$dlprefile_dlname" 3393228692Sdes dlprefile_dlbasename="$func_basename_result" 3394228692Sdes else 3395228692Sdes # no lafile. user explicitly requested -dlpreopen <import library>. 3396228692Sdes $sharedlib_from_linklib_cmd "$dlprefile" 3397228692Sdes dlprefile_dlbasename=$sharedlib_from_linklib_result 3398228692Sdes fi 3399228692Sdes fi 3400228692Sdes $opt_dry_run || { 3401228692Sdes if test -n "$dlprefile_dlbasename" ; then 3402228692Sdes eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 3403228692Sdes else 3404228692Sdes func_warning "Could not compute DLL name from $name" 3405228692Sdes eval '$ECHO ": $name " >> "$nlist"' 3406228692Sdes fi 3407228692Sdes func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3408228692Sdes eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 3409228692Sdes $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 3410228692Sdes } 3411228692Sdes else # not an import lib 3412228692Sdes $opt_dry_run || { 3413228692Sdes eval '$ECHO ": $name " >> "$nlist"' 3414228692Sdes func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3415228692Sdes eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3416228692Sdes } 3417228692Sdes fi 3418228692Sdes ;; 3419228692Sdes *) 3420228692Sdes $opt_dry_run || { 3421228692Sdes eval '$ECHO ": $name " >> "$nlist"' 3422228692Sdes func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3423228692Sdes eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3424228692Sdes } 3425228692Sdes ;; 3426228692Sdes esac 3427228692Sdes done 3428228692Sdes 3429228692Sdes $opt_dry_run || { 3430228692Sdes # Make sure we have at least an empty file. 3431228692Sdes test -f "$nlist" || : > "$nlist" 3432228692Sdes 3433228692Sdes if test -n "$exclude_expsyms"; then 3434228692Sdes $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 3435228692Sdes $MV "$nlist"T "$nlist" 3436228692Sdes fi 3437228692Sdes 3438228692Sdes # Try sorting and uniquifying the output. 3439228692Sdes if $GREP -v "^: " < "$nlist" | 3440228692Sdes if sort -k 3 </dev/null >/dev/null 2>&1; then 3441228692Sdes sort -k 3 3442228692Sdes else 3443228692Sdes sort +2 3444228692Sdes fi | 3445228692Sdes uniq > "$nlist"S; then 3446228692Sdes : 3447228692Sdes else 3448228692Sdes $GREP -v "^: " < "$nlist" > "$nlist"S 3449228692Sdes fi 3450228692Sdes 3451228692Sdes if test -f "$nlist"S; then 3452228692Sdes eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 3453228692Sdes else 3454228692Sdes echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 3455228692Sdes fi 3456228692Sdes 3457228692Sdes echo >> "$output_objdir/$my_dlsyms" "\ 3458228692Sdes 3459228692Sdes/* The mapping between symbol names and symbols. */ 3460228692Sdestypedef struct { 3461228692Sdes const char *name; 3462228692Sdes void *address; 3463228692Sdes} lt_dlsymlist; 3464228692Sdesextern LT_DLSYM_CONST lt_dlsymlist 3465228692Sdeslt_${my_prefix}_LTX_preloaded_symbols[]; 3466228692SdesLT_DLSYM_CONST lt_dlsymlist 3467228692Sdeslt_${my_prefix}_LTX_preloaded_symbols[] = 3468228692Sdes{\ 3469228692Sdes { \"$my_originator\", (void *) 0 }," 3470228692Sdes 3471228692Sdes case $need_lib_prefix in 3472228692Sdes no) 3473228692Sdes eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3474228692Sdes ;; 3475228692Sdes *) 3476228692Sdes eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3477228692Sdes ;; 3478228692Sdes esac 3479228692Sdes echo >> "$output_objdir/$my_dlsyms" "\ 3480228692Sdes {0, (void *) 0} 3481228692Sdes}; 3482228692Sdes 3483228692Sdes/* This works around a problem in FreeBSD linker */ 3484228692Sdes#ifdef FREEBSD_WORKAROUND 3485228692Sdesstatic const void *lt_preloaded_setup() { 3486228692Sdes return lt_${my_prefix}_LTX_preloaded_symbols; 3487228692Sdes} 3488228692Sdes#endif 3489228692Sdes 3490228692Sdes#ifdef __cplusplus 3491228692Sdes} 3492228692Sdes#endif\ 3493228692Sdes" 3494228692Sdes } # !$opt_dry_run 3495228692Sdes 3496228692Sdes pic_flag_for_symtable= 3497228692Sdes case "$compile_command " in 3498228692Sdes *" -static "*) ;; 3499228692Sdes *) 3500228692Sdes case $host in 3501228692Sdes # compiling the symbol table file with pic_flag works around 3502228692Sdes # a FreeBSD bug that causes programs to crash when -lm is 3503228692Sdes # linked before any other PIC object. But we must not use 3504228692Sdes # pic_flag when linking with -static. The problem exists in 3505228692Sdes # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 3506236109Sdes *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 3507228692Sdes pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 3508228692Sdes *-*-hpux*) 3509228692Sdes pic_flag_for_symtable=" $pic_flag" ;; 3510228692Sdes *) 3511228692Sdes if test "X$my_pic_p" != Xno; then 3512228692Sdes pic_flag_for_symtable=" $pic_flag" 3513228692Sdes fi 3514228692Sdes ;; 3515228692Sdes esac 3516228692Sdes ;; 3517228692Sdes esac 3518228692Sdes symtab_cflags= 3519228692Sdes for arg in $LTCFLAGS; do 3520228692Sdes case $arg in 3521228692Sdes -pie | -fpie | -fPIE) ;; 3522228692Sdes *) func_append symtab_cflags " $arg" ;; 3523228692Sdes esac 3524228692Sdes done 3525228692Sdes 3526228692Sdes # Now compile the dynamic symbol file. 3527228692Sdes func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3528228692Sdes 3529228692Sdes # Clean up the generated files. 3530228692Sdes func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3531228692Sdes 3532228692Sdes # Transform the symbol file into the correct name. 3533228692Sdes symfileobj="$output_objdir/${my_outputname}S.$objext" 3534228692Sdes case $host in 3535228692Sdes *cygwin* | *mingw* | *cegcc* ) 3536228692Sdes if test -f "$output_objdir/$my_outputname.def"; then 3537228692Sdes compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3538228692Sdes finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3539228692Sdes else 3540228692Sdes compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3541228692Sdes finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3542228692Sdes fi 3543228692Sdes ;; 3544228692Sdes *) 3545228692Sdes compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3546228692Sdes finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3547228692Sdes ;; 3548228692Sdes esac 3549228692Sdes ;; 3550228692Sdes *-*-freebsd*) 3551228692Sdes # FreeBSD doesn't need this... 3552228692Sdes ;; 3553228692Sdes *) 3554228692Sdes func_fatal_error "unknown suffix for \`$my_dlsyms'" 3555228692Sdes ;; 3556228692Sdes esac 3557228692Sdes else 3558228692Sdes # We keep going just in case the user didn't refer to 3559228692Sdes # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 3560228692Sdes # really was required. 3561228692Sdes 3562228692Sdes # Nullify the symbol file. 3563228692Sdes compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 3564228692Sdes finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 3565228692Sdes fi 3566228692Sdes} 3567228692Sdes 3568228692Sdes# func_win32_libid arg 3569228692Sdes# return the library type of file 'arg' 3570228692Sdes# 3571228692Sdes# Need a lot of goo to handle *both* DLLs and import libs 3572228692Sdes# Has to be a shell function in order to 'eat' the argument 3573228692Sdes# that is supplied when $file_magic_command is called. 3574228692Sdes# Despite the name, also deal with 64 bit binaries. 3575228692Sdesfunc_win32_libid () 3576228692Sdes{ 3577228692Sdes $opt_debug 3578228692Sdes win32_libid_type="unknown" 3579228692Sdes win32_fileres=`file -L $1 2>/dev/null` 3580228692Sdes case $win32_fileres in 3581228692Sdes *ar\ archive\ import\ library*) # definitely import 3582228692Sdes win32_libid_type="x86 archive import" 3583117610Sdes ;; 3584228692Sdes *ar\ archive*) # could be an import, or static 3585228692Sdes # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 3586228692Sdes if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 3587228692Sdes $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 3588228692Sdes func_to_tool_file "$1" func_convert_file_msys_to_w32 3589228692Sdes win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 3590228692Sdes $SED -n -e ' 3591228692Sdes 1,100{ 3592228692Sdes / I /{ 3593228692Sdes s,.*,import, 3594228692Sdes p 3595228692Sdes q 3596228692Sdes } 3597228692Sdes }'` 3598228692Sdes case $win32_nmres in 3599228692Sdes import*) win32_libid_type="x86 archive import";; 3600228692Sdes *) win32_libid_type="x86 archive static";; 3601228692Sdes esac 3602228692Sdes fi 3603228692Sdes ;; 3604228692Sdes *DLL*) 3605228692Sdes win32_libid_type="x86 DLL" 3606228692Sdes ;; 3607228692Sdes *executable*) # but shell scripts are "executable" too... 3608228692Sdes case $win32_fileres in 3609228692Sdes *MS\ Windows\ PE\ Intel*) 3610228692Sdes win32_libid_type="x86 DLL" 3611228692Sdes ;; 3612228692Sdes esac 3613228692Sdes ;; 3614228692Sdes esac 3615228692Sdes $ECHO "$win32_libid_type" 3616228692Sdes} 3617117610Sdes 3618228692Sdes# func_cygming_dll_for_implib ARG 3619228692Sdes# 3620228692Sdes# Platform-specific function to extract the 3621228692Sdes# name of the DLL associated with the specified 3622228692Sdes# import library ARG. 3623228692Sdes# Invoked by eval'ing the libtool variable 3624228692Sdes# $sharedlib_from_linklib_cmd 3625228692Sdes# Result is available in the variable 3626228692Sdes# $sharedlib_from_linklib_result 3627228692Sdesfunc_cygming_dll_for_implib () 3628228692Sdes{ 3629228692Sdes $opt_debug 3630228692Sdes sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 3631228692Sdes} 3632228692Sdes 3633228692Sdes# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 3634228692Sdes# 3635228692Sdes# The is the core of a fallback implementation of a 3636228692Sdes# platform-specific function to extract the name of the 3637228692Sdes# DLL associated with the specified import library LIBNAME. 3638228692Sdes# 3639228692Sdes# SECTION_NAME is either .idata$6 or .idata$7, depending 3640228692Sdes# on the platform and compiler that created the implib. 3641228692Sdes# 3642228692Sdes# Echos the name of the DLL associated with the 3643228692Sdes# specified import library. 3644228692Sdesfunc_cygming_dll_for_implib_fallback_core () 3645228692Sdes{ 3646228692Sdes $opt_debug 3647228692Sdes match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 3648228692Sdes $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 3649228692Sdes $SED '/^Contents of section '"$match_literal"':/{ 3650228692Sdes # Place marker at beginning of archive member dllname section 3651228692Sdes s/.*/====MARK====/ 3652228692Sdes p 3653228692Sdes d 3654228692Sdes } 3655228692Sdes # These lines can sometimes be longer than 43 characters, but 3656228692Sdes # are always uninteresting 3657228692Sdes /:[ ]*file format pe[i]\{,1\}-/d 3658228692Sdes /^In archive [^:]*:/d 3659228692Sdes # Ensure marker is printed 3660228692Sdes /^====MARK====/p 3661228692Sdes # Remove all lines with less than 43 characters 3662228692Sdes /^.\{43\}/!d 3663228692Sdes # From remaining lines, remove first 43 characters 3664228692Sdes s/^.\{43\}//' | 3665228692Sdes $SED -n ' 3666228692Sdes # Join marker and all lines until next marker into a single line 3667228692Sdes /^====MARK====/ b para 3668228692Sdes H 3669228692Sdes $ b para 3670228692Sdes b 3671228692Sdes :para 3672228692Sdes x 3673228692Sdes s/\n//g 3674228692Sdes # Remove the marker 3675228692Sdes s/^====MARK====// 3676228692Sdes # Remove trailing dots and whitespace 3677228692Sdes s/[\. \t]*$// 3678228692Sdes # Print 3679228692Sdes /./p' | 3680228692Sdes # we now have a list, one entry per line, of the stringified 3681228692Sdes # contents of the appropriate section of all members of the 3682228692Sdes # archive which possess that section. Heuristic: eliminate 3683228692Sdes # all those which have a first or second character that is 3684228692Sdes # a '.' (that is, objdump's representation of an unprintable 3685228692Sdes # character.) This should work for all archives with less than 3686228692Sdes # 0x302f exports -- but will fail for DLLs whose name actually 3687228692Sdes # begins with a literal '.' or a single character followed by 3688228692Sdes # a '.'. 3689228692Sdes # 3690228692Sdes # Of those that remain, print the first one. 3691228692Sdes $SED -e '/^\./d;/^.\./d;q' 3692228692Sdes} 3693228692Sdes 3694228692Sdes# func_cygming_gnu_implib_p ARG 3695228692Sdes# This predicate returns with zero status (TRUE) if 3696228692Sdes# ARG is a GNU/binutils-style import library. Returns 3697228692Sdes# with nonzero status (FALSE) otherwise. 3698228692Sdesfunc_cygming_gnu_implib_p () 3699228692Sdes{ 3700228692Sdes $opt_debug 3701228692Sdes func_to_tool_file "$1" func_convert_file_msys_to_w32 3702228692Sdes func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` 3703228692Sdes test -n "$func_cygming_gnu_implib_tmp" 3704228692Sdes} 3705228692Sdes 3706228692Sdes# func_cygming_ms_implib_p ARG 3707228692Sdes# This predicate returns with zero status (TRUE) if 3708228692Sdes# ARG is an MS-style import library. Returns 3709228692Sdes# with nonzero status (FALSE) otherwise. 3710228692Sdesfunc_cygming_ms_implib_p () 3711228692Sdes{ 3712228692Sdes $opt_debug 3713228692Sdes func_to_tool_file "$1" func_convert_file_msys_to_w32 3714228692Sdes func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 3715228692Sdes test -n "$func_cygming_ms_implib_tmp" 3716228692Sdes} 3717228692Sdes 3718228692Sdes# func_cygming_dll_for_implib_fallback ARG 3719228692Sdes# Platform-specific function to extract the 3720228692Sdes# name of the DLL associated with the specified 3721228692Sdes# import library ARG. 3722228692Sdes# 3723228692Sdes# This fallback implementation is for use when $DLLTOOL 3724228692Sdes# does not support the --identify-strict option. 3725228692Sdes# Invoked by eval'ing the libtool variable 3726228692Sdes# $sharedlib_from_linklib_cmd 3727228692Sdes# Result is available in the variable 3728228692Sdes# $sharedlib_from_linklib_result 3729228692Sdesfunc_cygming_dll_for_implib_fallback () 3730228692Sdes{ 3731228692Sdes $opt_debug 3732228692Sdes if func_cygming_gnu_implib_p "$1" ; then 3733228692Sdes # binutils import library 3734228692Sdes sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 3735228692Sdes elif func_cygming_ms_implib_p "$1" ; then 3736228692Sdes # ms-generated import library 3737228692Sdes sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 3738228692Sdes else 3739228692Sdes # unknown 3740228692Sdes sharedlib_from_linklib_result="" 3741228692Sdes fi 3742228692Sdes} 3743228692Sdes 3744228692Sdes 3745228692Sdes# func_extract_an_archive dir oldlib 3746228692Sdesfunc_extract_an_archive () 3747228692Sdes{ 3748228692Sdes $opt_debug 3749228692Sdes f_ex_an_ar_dir="$1"; shift 3750228692Sdes f_ex_an_ar_oldlib="$1" 3751228692Sdes if test "$lock_old_archive_extraction" = yes; then 3752228692Sdes lockfile=$f_ex_an_ar_oldlib.lock 3753228692Sdes until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3754228692Sdes func_echo "Waiting for $lockfile to be removed" 3755228692Sdes sleep 2 3756228692Sdes done 3757228692Sdes fi 3758228692Sdes func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 3759228692Sdes 'stat=$?; rm -f "$lockfile"; exit $stat' 3760228692Sdes if test "$lock_old_archive_extraction" = yes; then 3761228692Sdes $opt_dry_run || rm -f "$lockfile" 3762228692Sdes fi 3763228692Sdes if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 3764228692Sdes : 3765228692Sdes else 3766228692Sdes func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 3767228692Sdes fi 3768228692Sdes} 3769228692Sdes 3770228692Sdes 3771228692Sdes# func_extract_archives gentop oldlib ... 3772228692Sdesfunc_extract_archives () 3773228692Sdes{ 3774228692Sdes $opt_debug 3775228692Sdes my_gentop="$1"; shift 3776228692Sdes my_oldlibs=${1+"$@"} 3777228692Sdes my_oldobjs="" 3778228692Sdes my_xlib="" 3779228692Sdes my_xabs="" 3780228692Sdes my_xdir="" 3781228692Sdes 3782228692Sdes for my_xlib in $my_oldlibs; do 3783228692Sdes # Extract the objects. 3784228692Sdes case $my_xlib in 3785228692Sdes [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 3786228692Sdes *) my_xabs=`pwd`"/$my_xlib" ;; 3787228692Sdes esac 3788228692Sdes func_basename "$my_xlib" 3789228692Sdes my_xlib="$func_basename_result" 3790228692Sdes my_xlib_u=$my_xlib 3791228692Sdes while :; do 3792228692Sdes case " $extracted_archives " in 3793228692Sdes *" $my_xlib_u "*) 3794228692Sdes func_arith $extracted_serial + 1 3795228692Sdes extracted_serial=$func_arith_result 3796228692Sdes my_xlib_u=lt$extracted_serial-$my_xlib ;; 3797228692Sdes *) break ;; 3798228692Sdes esac 3799228692Sdes done 3800228692Sdes extracted_archives="$extracted_archives $my_xlib_u" 3801228692Sdes my_xdir="$my_gentop/$my_xlib_u" 3802228692Sdes 3803228692Sdes func_mkdir_p "$my_xdir" 3804228692Sdes 3805228692Sdes case $host in 3806228692Sdes *-darwin*) 3807228692Sdes func_verbose "Extracting $my_xabs" 3808228692Sdes # Do not bother doing anything if just a dry run 3809228692Sdes $opt_dry_run || { 3810228692Sdes darwin_orig_dir=`pwd` 3811228692Sdes cd $my_xdir || exit $? 3812228692Sdes darwin_archive=$my_xabs 3813228692Sdes darwin_curdir=`pwd` 3814228692Sdes darwin_base_archive=`basename "$darwin_archive"` 3815228692Sdes darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 3816228692Sdes if test -n "$darwin_arches"; then 3817228692Sdes darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 3818228692Sdes darwin_arch= 3819228692Sdes func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 3820228692Sdes for darwin_arch in $darwin_arches ; do 3821228692Sdes func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3822228692Sdes $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 3823228692Sdes cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3824228692Sdes func_extract_an_archive "`pwd`" "${darwin_base_archive}" 3825228692Sdes cd "$darwin_curdir" 3826228692Sdes $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 3827228692Sdes done # $darwin_arches 3828228692Sdes ## Okay now we've a bunch of thin objects, gotta fatten them up :) 3829228692Sdes darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 3830228692Sdes darwin_file= 3831228692Sdes darwin_files= 3832228692Sdes for darwin_file in $darwin_filelist; do 3833228692Sdes darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 3834228692Sdes $LIPO -create -output "$darwin_file" $darwin_files 3835228692Sdes done # $darwin_filelist 3836228692Sdes $RM -rf unfat-$$ 3837228692Sdes cd "$darwin_orig_dir" 3838228692Sdes else 3839228692Sdes cd $darwin_orig_dir 3840228692Sdes func_extract_an_archive "$my_xdir" "$my_xabs" 3841228692Sdes fi # $darwin_arches 3842228692Sdes } # !$opt_dry_run 3843228692Sdes ;; 3844228692Sdes *) 3845228692Sdes func_extract_an_archive "$my_xdir" "$my_xabs" 3846228692Sdes ;; 3847228692Sdes esac 3848228692Sdes my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 3849228692Sdes done 3850228692Sdes 3851228692Sdes func_extract_archives_result="$my_oldobjs" 3852228692Sdes} 3853228692Sdes 3854228692Sdes 3855228692Sdes# func_emit_wrapper [arg=no] 3856228692Sdes# 3857228692Sdes# Emit a libtool wrapper script on stdout. 3858228692Sdes# Don't directly open a file because we may want to 3859228692Sdes# incorporate the script contents within a cygwin/mingw 3860228692Sdes# wrapper executable. Must ONLY be called from within 3861228692Sdes# func_mode_link because it depends on a number of variables 3862228692Sdes# set therein. 3863228692Sdes# 3864228692Sdes# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 3865228692Sdes# variable will take. If 'yes', then the emitted script 3866228692Sdes# will assume that the directory in which it is stored is 3867228692Sdes# the $objdir directory. This is a cygwin/mingw-specific 3868228692Sdes# behavior. 3869228692Sdesfunc_emit_wrapper () 3870228692Sdes{ 3871228692Sdes func_emit_wrapper_arg1=${1-no} 3872228692Sdes 3873228692Sdes $ECHO "\ 3874228692Sdes#! $SHELL 3875228692Sdes 3876228692Sdes# $output - temporary wrapper script for $objdir/$outputname 3877228692Sdes# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3878228692Sdes# 3879228692Sdes# The $output program cannot be directly executed until all the libtool 3880228692Sdes# libraries that it depends on are installed. 3881228692Sdes# 3882228692Sdes# This wrapper script should never be moved out of the build directory. 3883228692Sdes# If it is, it will not operate correctly. 3884228692Sdes 3885228692Sdes# Sed substitution that helps us do robust quoting. It backslashifies 3886228692Sdes# metacharacters that are still active within double-quoted strings. 3887228692Sdessed_quote_subst='$sed_quote_subst' 3888228692Sdes 3889228692Sdes# Be Bourne compatible 3890228692Sdesif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 3891228692Sdes emulate sh 3892228692Sdes NULLCMD=: 3893228692Sdes # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 3894228692Sdes # is contrary to our usage. Disable this feature. 3895228692Sdes alias -g '\${1+\"\$@\"}'='\"\$@\"' 3896228692Sdes setopt NO_GLOB_SUBST 3897228692Sdeselse 3898228692Sdes case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 3899228692Sdesfi 3900228692SdesBIN_SH=xpg4; export BIN_SH # for Tru64 3901228692SdesDUALCASE=1; export DUALCASE # for MKS sh 3902228692Sdes 3903228692Sdes# The HP-UX ksh and POSIX shell print the target directory to stdout 3904228692Sdes# if CDPATH is set. 3905228692Sdes(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3906228692Sdes 3907228692Sdesrelink_command=\"$relink_command\" 3908228692Sdes 3909228692Sdes# This environment variable determines our operation mode. 3910228692Sdesif test \"\$libtool_install_magic\" = \"$magic\"; then 3911228692Sdes # install mode needs the following variables: 3912228692Sdes generated_by_libtool_version='$macro_version' 3913228692Sdes notinst_deplibs='$notinst_deplibs' 3914228692Sdeselse 3915228692Sdes # When we are sourced in execute mode, \$file and \$ECHO are already set. 3916228692Sdes if test \"\$libtool_execute_magic\" != \"$magic\"; then 3917228692Sdes file=\"\$0\"" 3918228692Sdes 3919228692Sdes qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 3920228692Sdes $ECHO "\ 3921228692Sdes 3922228692Sdes# A function that is used when there is no print builtin or printf. 3923228692Sdesfunc_fallback_echo () 3924228692Sdes{ 3925228692Sdes eval 'cat <<_LTECHO_EOF 3926228692Sdes\$1 3927228692Sdes_LTECHO_EOF' 3928228692Sdes} 3929228692Sdes ECHO=\"$qECHO\" 3930228692Sdes fi 3931228692Sdes 3932228692Sdes# Very basic option parsing. These options are (a) specific to 3933228692Sdes# the libtool wrapper, (b) are identical between the wrapper 3934228692Sdes# /script/ and the wrapper /executable/ which is used only on 3935228692Sdes# windows platforms, and (c) all begin with the string "--lt-" 3936228692Sdes# (application programs are unlikely to have options which match 3937228692Sdes# this pattern). 3938228692Sdes# 3939228692Sdes# There are only two supported options: --lt-debug and 3940228692Sdes# --lt-dump-script. There is, deliberately, no --lt-help. 3941228692Sdes# 3942228692Sdes# The first argument to this parsing function should be the 3943228692Sdes# script's $0 value, followed by "$@". 3944228692Sdeslt_option_debug= 3945228692Sdesfunc_parse_lt_options () 3946228692Sdes{ 3947228692Sdes lt_script_arg0=\$0 3948228692Sdes shift 3949228692Sdes for lt_opt 3950228692Sdes do 3951228692Sdes case \"\$lt_opt\" in 3952228692Sdes --lt-debug) lt_option_debug=1 ;; 3953228692Sdes --lt-dump-script) 3954228692Sdes lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 3955228692Sdes test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 3956228692Sdes lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 3957228692Sdes cat \"\$lt_dump_D/\$lt_dump_F\" 3958228692Sdes exit 0 3959228692Sdes ;; 3960228692Sdes --lt-*) 3961228692Sdes \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 3962228692Sdes exit 1 3963228692Sdes ;; 3964228692Sdes esac 3965228692Sdes done 3966228692Sdes 3967228692Sdes # Print the debug banner immediately: 3968228692Sdes if test -n \"\$lt_option_debug\"; then 3969228692Sdes echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 3970228692Sdes fi 3971228692Sdes} 3972228692Sdes 3973228692Sdes# Used when --lt-debug. Prints its arguments to stdout 3974228692Sdes# (redirection is the responsibility of the caller) 3975228692Sdesfunc_lt_dump_args () 3976228692Sdes{ 3977228692Sdes lt_dump_args_N=1; 3978228692Sdes for lt_arg 3979228692Sdes do 3980228692Sdes \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 3981228692Sdes lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 3982228692Sdes done 3983228692Sdes} 3984228692Sdes 3985228692Sdes# Core function for launching the target application 3986228692Sdesfunc_exec_program_core () 3987228692Sdes{ 3988228692Sdes" 3989228692Sdes case $host in 3990228692Sdes # Backslashes separate directories on plain windows 3991228692Sdes *-*-mingw | *-*-os2* | *-cegcc*) 3992228692Sdes $ECHO "\ 3993228692Sdes if test -n \"\$lt_option_debug\"; then 3994228692Sdes \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 3995228692Sdes func_lt_dump_args \${1+\"\$@\"} 1>&2 3996228692Sdes fi 3997228692Sdes exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 3998228692Sdes" 3999228692Sdes ;; 4000228692Sdes 4001228692Sdes *) 4002228692Sdes $ECHO "\ 4003228692Sdes if test -n \"\$lt_option_debug\"; then 4004228692Sdes \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 4005228692Sdes func_lt_dump_args \${1+\"\$@\"} 1>&2 4006228692Sdes fi 4007228692Sdes exec \"\$progdir/\$program\" \${1+\"\$@\"} 4008228692Sdes" 4009228692Sdes ;; 4010228692Sdes esac 4011228692Sdes $ECHO "\ 4012228692Sdes \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 4013228692Sdes exit 1 4014228692Sdes} 4015228692Sdes 4016228692Sdes# A function to encapsulate launching the target application 4017228692Sdes# Strips options in the --lt-* namespace from \$@ and 4018228692Sdes# launches target application with the remaining arguments. 4019228692Sdesfunc_exec_program () 4020228692Sdes{ 4021236109Sdes case \" \$* \" in 4022236109Sdes *\\ --lt-*) 4023236109Sdes for lt_wr_arg 4024236109Sdes do 4025236109Sdes case \$lt_wr_arg in 4026236109Sdes --lt-*) ;; 4027236109Sdes *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 4028236109Sdes esac 4029236109Sdes shift 4030236109Sdes done ;; 4031236109Sdes esac 4032228692Sdes func_exec_program_core \${1+\"\$@\"} 4033228692Sdes} 4034228692Sdes 4035228692Sdes # Parse options 4036228692Sdes func_parse_lt_options \"\$0\" \${1+\"\$@\"} 4037228692Sdes 4038228692Sdes # Find the directory that this script lives in. 4039228692Sdes thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 4040228692Sdes test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4041228692Sdes 4042228692Sdes # Follow symbolic links until we get to the real thisdir. 4043228692Sdes file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 4044228692Sdes while test -n \"\$file\"; do 4045228692Sdes destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4046228692Sdes 4047228692Sdes # If there was a directory component, then change thisdir. 4048228692Sdes if test \"x\$destdir\" != \"x\$file\"; then 4049228692Sdes case \"\$destdir\" in 4050228692Sdes [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 4051228692Sdes *) thisdir=\"\$thisdir/\$destdir\" ;; 4052228692Sdes esac 4053228692Sdes fi 4054228692Sdes 4055228692Sdes file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 4056228692Sdes file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 4057228692Sdes done 4058228692Sdes 4059228692Sdes # Usually 'no', except on cygwin/mingw when embedded into 4060228692Sdes # the cwrapper. 4061228692Sdes WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 4062228692Sdes if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 4063228692Sdes # special case for '.' 4064228692Sdes if test \"\$thisdir\" = \".\"; then 4065228692Sdes thisdir=\`pwd\` 4066228692Sdes fi 4067228692Sdes # remove .libs from thisdir 4068228692Sdes case \"\$thisdir\" in 4069228692Sdes *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 4070228692Sdes $objdir ) thisdir=. ;; 4071228692Sdes esac 4072228692Sdes fi 4073228692Sdes 4074228692Sdes # Try to get the absolute directory name. 4075228692Sdes absdir=\`cd \"\$thisdir\" && pwd\` 4076228692Sdes test -n \"\$absdir\" && thisdir=\"\$absdir\" 4077228692Sdes" 4078228692Sdes 4079228692Sdes if test "$fast_install" = yes; then 4080228692Sdes $ECHO "\ 4081228692Sdes program=lt-'$outputname'$exeext 4082228692Sdes progdir=\"\$thisdir/$objdir\" 4083228692Sdes 4084228692Sdes if test ! -f \"\$progdir/\$program\" || 4085228692Sdes { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 4086228692Sdes test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4087228692Sdes 4088228692Sdes file=\"\$\$-\$program\" 4089228692Sdes 4090228692Sdes if test ! -d \"\$progdir\"; then 4091228692Sdes $MKDIR \"\$progdir\" 4092228692Sdes else 4093228692Sdes $RM \"\$progdir/\$file\" 4094228692Sdes fi" 4095228692Sdes 4096228692Sdes $ECHO "\ 4097228692Sdes 4098228692Sdes # relink executable if necessary 4099228692Sdes if test -n \"\$relink_command\"; then 4100228692Sdes if relink_command_output=\`eval \$relink_command 2>&1\`; then : 4101228692Sdes else 4102228692Sdes $ECHO \"\$relink_command_output\" >&2 4103228692Sdes $RM \"\$progdir/\$file\" 4104228692Sdes exit 1 4105228692Sdes fi 4106228692Sdes fi 4107228692Sdes 4108228692Sdes $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 4109228692Sdes { $RM \"\$progdir/\$program\"; 4110228692Sdes $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 4111228692Sdes $RM \"\$progdir/\$file\" 4112228692Sdes fi" 4113228692Sdes else 4114228692Sdes $ECHO "\ 4115228692Sdes program='$outputname' 4116228692Sdes progdir=\"\$thisdir/$objdir\" 4117228692Sdes" 4118228692Sdes fi 4119228692Sdes 4120228692Sdes $ECHO "\ 4121228692Sdes 4122228692Sdes if test -f \"\$progdir/\$program\"; then" 4123228692Sdes 4124228692Sdes # fixup the dll searchpath if we need to. 4125228692Sdes # 4126228692Sdes # Fix the DLL searchpath if we need to. Do this before prepending 4127228692Sdes # to shlibpath, because on Windows, both are PATH and uninstalled 4128228692Sdes # libraries must come first. 4129228692Sdes if test -n "$dllsearchpath"; then 4130228692Sdes $ECHO "\ 4131228692Sdes # Add the dll search path components to the executable PATH 4132228692Sdes PATH=$dllsearchpath:\$PATH 4133228692Sdes" 4134228692Sdes fi 4135228692Sdes 4136228692Sdes # Export our shlibpath_var if we have one. 4137228692Sdes if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4138228692Sdes $ECHO "\ 4139228692Sdes # Add our own library path to $shlibpath_var 4140228692Sdes $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4141228692Sdes 4142228692Sdes # Some systems cannot cope with colon-terminated $shlibpath_var 4143228692Sdes # The second colon is a workaround for a bug in BeOS R4 sed 4144228692Sdes $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4145228692Sdes 4146228692Sdes export $shlibpath_var 4147228692Sdes" 4148228692Sdes fi 4149228692Sdes 4150228692Sdes $ECHO "\ 4151228692Sdes if test \"\$libtool_execute_magic\" != \"$magic\"; then 4152228692Sdes # Run the actual program with our arguments. 4153228692Sdes func_exec_program \${1+\"\$@\"} 4154228692Sdes fi 4155228692Sdes else 4156228692Sdes # The program doesn't exist. 4157228692Sdes \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 4158228692Sdes \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 4159228692Sdes \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 4160228692Sdes exit 1 4161228692Sdes fi 4162228692Sdesfi\ 4163228692Sdes" 4164228692Sdes} 4165228692Sdes 4166228692Sdes 4167228692Sdes# func_emit_cwrapperexe_src 4168228692Sdes# emit the source code for a wrapper executable on stdout 4169228692Sdes# Must ONLY be called from within func_mode_link because 4170228692Sdes# it depends on a number of variable set therein. 4171228692Sdesfunc_emit_cwrapperexe_src () 4172228692Sdes{ 4173228692Sdes cat <<EOF 4174228692Sdes 4175228692Sdes/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4176228692Sdes Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4177228692Sdes 4178228692Sdes The $output program cannot be directly executed until all the libtool 4179228692Sdes libraries that it depends on are installed. 4180228692Sdes 4181228692Sdes This wrapper executable should never be moved out of the build directory. 4182228692Sdes If it is, it will not operate correctly. 4183228692Sdes*/ 4184228692SdesEOF 4185228692Sdes cat <<"EOF" 4186228692Sdes#ifdef _MSC_VER 4187228692Sdes# define _CRT_SECURE_NO_DEPRECATE 1 4188228692Sdes#endif 4189228692Sdes#include <stdio.h> 4190228692Sdes#include <stdlib.h> 4191228692Sdes#ifdef _MSC_VER 4192228692Sdes# include <direct.h> 4193228692Sdes# include <process.h> 4194228692Sdes# include <io.h> 4195228692Sdes#else 4196228692Sdes# include <unistd.h> 4197228692Sdes# include <stdint.h> 4198228692Sdes# ifdef __CYGWIN__ 4199228692Sdes# include <io.h> 4200228692Sdes# endif 4201228692Sdes#endif 4202228692Sdes#include <malloc.h> 4203228692Sdes#include <stdarg.h> 4204228692Sdes#include <assert.h> 4205228692Sdes#include <string.h> 4206228692Sdes#include <ctype.h> 4207228692Sdes#include <errno.h> 4208228692Sdes#include <fcntl.h> 4209228692Sdes#include <sys/stat.h> 4210228692Sdes 4211228692Sdes/* declarations of non-ANSI functions */ 4212228692Sdes#if defined(__MINGW32__) 4213228692Sdes# ifdef __STRICT_ANSI__ 4214228692Sdesint _putenv (const char *); 4215228692Sdes# endif 4216228692Sdes#elif defined(__CYGWIN__) 4217228692Sdes# ifdef __STRICT_ANSI__ 4218228692Sdeschar *realpath (const char *, char *); 4219228692Sdesint putenv (char *); 4220228692Sdesint setenv (const char *, const char *, int); 4221228692Sdes# endif 4222228692Sdes/* #elif defined (other platforms) ... */ 4223228692Sdes#endif 4224228692Sdes 4225228692Sdes/* portability defines, excluding path handling macros */ 4226228692Sdes#if defined(_MSC_VER) 4227228692Sdes# define setmode _setmode 4228228692Sdes# define stat _stat 4229228692Sdes# define chmod _chmod 4230228692Sdes# define getcwd _getcwd 4231228692Sdes# define putenv _putenv 4232228692Sdes# define S_IXUSR _S_IEXEC 4233228692Sdes# ifndef _INTPTR_T_DEFINED 4234228692Sdes# define _INTPTR_T_DEFINED 4235228692Sdes# define intptr_t int 4236228692Sdes# endif 4237228692Sdes#elif defined(__MINGW32__) 4238228692Sdes# define setmode _setmode 4239228692Sdes# define stat _stat 4240228692Sdes# define chmod _chmod 4241228692Sdes# define getcwd _getcwd 4242228692Sdes# define putenv _putenv 4243228692Sdes#elif defined(__CYGWIN__) 4244228692Sdes# define HAVE_SETENV 4245228692Sdes# define FOPEN_WB "wb" 4246228692Sdes/* #elif defined (other platforms) ... */ 4247228692Sdes#endif 4248228692Sdes 4249228692Sdes#if defined(PATH_MAX) 4250228692Sdes# define LT_PATHMAX PATH_MAX 4251228692Sdes#elif defined(MAXPATHLEN) 4252228692Sdes# define LT_PATHMAX MAXPATHLEN 4253228692Sdes#else 4254228692Sdes# define LT_PATHMAX 1024 4255228692Sdes#endif 4256228692Sdes 4257228692Sdes#ifndef S_IXOTH 4258228692Sdes# define S_IXOTH 0 4259228692Sdes#endif 4260228692Sdes#ifndef S_IXGRP 4261228692Sdes# define S_IXGRP 0 4262228692Sdes#endif 4263228692Sdes 4264228692Sdes/* path handling portability macros */ 4265228692Sdes#ifndef DIR_SEPARATOR 4266228692Sdes# define DIR_SEPARATOR '/' 4267228692Sdes# define PATH_SEPARATOR ':' 4268228692Sdes#endif 4269228692Sdes 4270228692Sdes#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4271228692Sdes defined (__OS2__) 4272228692Sdes# define HAVE_DOS_BASED_FILE_SYSTEM 4273228692Sdes# define FOPEN_WB "wb" 4274228692Sdes# ifndef DIR_SEPARATOR_2 4275228692Sdes# define DIR_SEPARATOR_2 '\\' 4276228692Sdes# endif 4277228692Sdes# ifndef PATH_SEPARATOR_2 4278228692Sdes# define PATH_SEPARATOR_2 ';' 4279228692Sdes# endif 4280228692Sdes#endif 4281228692Sdes 4282228692Sdes#ifndef DIR_SEPARATOR_2 4283228692Sdes# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 4284228692Sdes#else /* DIR_SEPARATOR_2 */ 4285228692Sdes# define IS_DIR_SEPARATOR(ch) \ 4286228692Sdes (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 4287228692Sdes#endif /* DIR_SEPARATOR_2 */ 4288228692Sdes 4289228692Sdes#ifndef PATH_SEPARATOR_2 4290228692Sdes# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 4291228692Sdes#else /* PATH_SEPARATOR_2 */ 4292228692Sdes# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 4293228692Sdes#endif /* PATH_SEPARATOR_2 */ 4294228692Sdes 4295228692Sdes#ifndef FOPEN_WB 4296228692Sdes# define FOPEN_WB "w" 4297228692Sdes#endif 4298228692Sdes#ifndef _O_BINARY 4299228692Sdes# define _O_BINARY 0 4300228692Sdes#endif 4301228692Sdes 4302228692Sdes#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 4303228692Sdes#define XFREE(stale) do { \ 4304228692Sdes if (stale) { free ((void *) stale); stale = 0; } \ 4305228692Sdes} while (0) 4306228692Sdes 4307228692Sdes#if defined(LT_DEBUGWRAPPER) 4308228692Sdesstatic int lt_debug = 1; 4309228692Sdes#else 4310228692Sdesstatic int lt_debug = 0; 4311228692Sdes#endif 4312228692Sdes 4313228692Sdesconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4314228692Sdes 4315228692Sdesvoid *xmalloc (size_t num); 4316228692Sdeschar *xstrdup (const char *string); 4317228692Sdesconst char *base_name (const char *name); 4318228692Sdeschar *find_executable (const char *wrapper); 4319228692Sdeschar *chase_symlinks (const char *pathspec); 4320228692Sdesint make_executable (const char *path); 4321228692Sdesint check_executable (const char *path); 4322228692Sdeschar *strendzap (char *str, const char *pat); 4323228692Sdesvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 4324228692Sdesvoid lt_fatal (const char *file, int line, const char *message, ...); 4325228692Sdesstatic const char *nonnull (const char *s); 4326228692Sdesstatic const char *nonempty (const char *s); 4327228692Sdesvoid lt_setenv (const char *name, const char *value); 4328228692Sdeschar *lt_extend_str (const char *orig_value, const char *add, int to_end); 4329228692Sdesvoid lt_update_exe_path (const char *name, const char *value); 4330228692Sdesvoid lt_update_lib_path (const char *name, const char *value); 4331228692Sdeschar **prepare_spawn (char **argv); 4332228692Sdesvoid lt_dump_script (FILE *f); 4333228692SdesEOF 4334228692Sdes 4335228692Sdes cat <<EOF 4336228692Sdesvolatile const char * MAGIC_EXE = "$magic_exe"; 4337228692Sdesconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 4338228692SdesEOF 4339228692Sdes 4340228692Sdes if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4341228692Sdes func_to_host_path "$temp_rpath" 4342228692Sdes cat <<EOF 4343228692Sdesconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 4344228692SdesEOF 4345228692Sdes else 4346228692Sdes cat <<"EOF" 4347228692Sdesconst char * LIB_PATH_VALUE = ""; 4348228692SdesEOF 4349228692Sdes fi 4350228692Sdes 4351228692Sdes if test -n "$dllsearchpath"; then 4352228692Sdes func_to_host_path "$dllsearchpath:" 4353228692Sdes cat <<EOF 4354228692Sdesconst char * EXE_PATH_VARNAME = "PATH"; 4355228692Sdesconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 4356228692SdesEOF 4357228692Sdes else 4358228692Sdes cat <<"EOF" 4359228692Sdesconst char * EXE_PATH_VARNAME = ""; 4360228692Sdesconst char * EXE_PATH_VALUE = ""; 4361228692SdesEOF 4362228692Sdes fi 4363228692Sdes 4364228692Sdes if test "$fast_install" = yes; then 4365228692Sdes cat <<EOF 4366228692Sdesconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 4367228692SdesEOF 4368228692Sdes else 4369228692Sdes cat <<EOF 4370228692Sdesconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 4371228692SdesEOF 4372228692Sdes fi 4373228692Sdes 4374228692Sdes 4375228692Sdes cat <<"EOF" 4376228692Sdes 4377228692Sdes#define LTWRAPPER_OPTION_PREFIX "--lt-" 4378228692Sdes 4379228692Sdesstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 4380228692Sdesstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 4381228692Sdesstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4382228692Sdes 4383228692Sdesint 4384228692Sdesmain (int argc, char *argv[]) 4385228692Sdes{ 4386228692Sdes char **newargz; 4387228692Sdes int newargc; 4388228692Sdes char *tmp_pathspec; 4389228692Sdes char *actual_cwrapper_path; 4390228692Sdes char *actual_cwrapper_name; 4391228692Sdes char *target_name; 4392228692Sdes char *lt_argv_zero; 4393228692Sdes intptr_t rval = 127; 4394228692Sdes 4395228692Sdes int i; 4396228692Sdes 4397228692Sdes program_name = (char *) xstrdup (base_name (argv[0])); 4398228692Sdes newargz = XMALLOC (char *, argc + 1); 4399228692Sdes 4400228692Sdes /* very simple arg parsing; don't want to rely on getopt 4401228692Sdes * also, copy all non cwrapper options to newargz, except 4402228692Sdes * argz[0], which is handled differently 4403228692Sdes */ 4404228692Sdes newargc=0; 4405228692Sdes for (i = 1; i < argc; i++) 4406228692Sdes { 4407228692Sdes if (strcmp (argv[i], dumpscript_opt) == 0) 4408228692Sdes { 4409228692SdesEOF 4410228692Sdes case "$host" in 4411228692Sdes *mingw* | *cygwin* ) 4412228692Sdes # make stdout use "unix" line endings 4413228692Sdes echo " setmode(1,_O_BINARY);" 4414228692Sdes ;; 4415228692Sdes esac 4416228692Sdes 4417228692Sdes cat <<"EOF" 4418228692Sdes lt_dump_script (stdout); 4419228692Sdes return 0; 4420228692Sdes } 4421228692Sdes if (strcmp (argv[i], debug_opt) == 0) 4422228692Sdes { 4423228692Sdes lt_debug = 1; 4424228692Sdes continue; 4425228692Sdes } 4426228692Sdes if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 4427228692Sdes { 4428228692Sdes /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4429228692Sdes namespace, but it is not one of the ones we know about and 4430228692Sdes have already dealt with, above (inluding dump-script), then 4431228692Sdes report an error. Otherwise, targets might begin to believe 4432228692Sdes they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4433228692Sdes namespace. The first time any user complains about this, we'll 4434228692Sdes need to make LTWRAPPER_OPTION_PREFIX a configure-time option 4435228692Sdes or a configure.ac-settable value. 4436228692Sdes */ 4437228692Sdes lt_fatal (__FILE__, __LINE__, 4438228692Sdes "unrecognized %s option: '%s'", 4439228692Sdes ltwrapper_option_prefix, argv[i]); 4440228692Sdes } 4441228692Sdes /* otherwise ... */ 4442228692Sdes newargz[++newargc] = xstrdup (argv[i]); 4443228692Sdes } 4444228692Sdes newargz[++newargc] = NULL; 4445228692Sdes 4446228692SdesEOF 4447228692Sdes cat <<EOF 4448228692Sdes /* The GNU banner must be the first non-error debug message */ 4449228692Sdes lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 4450228692SdesEOF 4451228692Sdes cat <<"EOF" 4452228692Sdes lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 4453228692Sdes lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4454228692Sdes 4455228692Sdes tmp_pathspec = find_executable (argv[0]); 4456228692Sdes if (tmp_pathspec == NULL) 4457228692Sdes lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 4458228692Sdes lt_debugprintf (__FILE__, __LINE__, 4459228692Sdes "(main) found exe (before symlink chase) at: %s\n", 4460228692Sdes tmp_pathspec); 4461228692Sdes 4462228692Sdes actual_cwrapper_path = chase_symlinks (tmp_pathspec); 4463228692Sdes lt_debugprintf (__FILE__, __LINE__, 4464228692Sdes "(main) found exe (after symlink chase) at: %s\n", 4465228692Sdes actual_cwrapper_path); 4466228692Sdes XFREE (tmp_pathspec); 4467228692Sdes 4468228692Sdes actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 4469228692Sdes strendzap (actual_cwrapper_path, actual_cwrapper_name); 4470228692Sdes 4471228692Sdes /* wrapper name transforms */ 4472228692Sdes strendzap (actual_cwrapper_name, ".exe"); 4473228692Sdes tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 4474228692Sdes XFREE (actual_cwrapper_name); 4475228692Sdes actual_cwrapper_name = tmp_pathspec; 4476228692Sdes tmp_pathspec = 0; 4477228692Sdes 4478228692Sdes /* target_name transforms -- use actual target program name; might have lt- prefix */ 4479228692Sdes target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 4480228692Sdes strendzap (target_name, ".exe"); 4481228692Sdes tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 4482228692Sdes XFREE (target_name); 4483228692Sdes target_name = tmp_pathspec; 4484228692Sdes tmp_pathspec = 0; 4485228692Sdes 4486228692Sdes lt_debugprintf (__FILE__, __LINE__, 4487228692Sdes "(main) libtool target name: %s\n", 4488228692Sdes target_name); 4489228692SdesEOF 4490228692Sdes 4491228692Sdes cat <<EOF 4492228692Sdes newargz[0] = 4493228692Sdes XMALLOC (char, (strlen (actual_cwrapper_path) + 4494228692Sdes strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 4495228692Sdes strcpy (newargz[0], actual_cwrapper_path); 4496228692Sdes strcat (newargz[0], "$objdir"); 4497228692Sdes strcat (newargz[0], "/"); 4498228692SdesEOF 4499228692Sdes 4500228692Sdes cat <<"EOF" 4501228692Sdes /* stop here, and copy so we don't have to do this twice */ 4502228692Sdes tmp_pathspec = xstrdup (newargz[0]); 4503228692Sdes 4504228692Sdes /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 4505228692Sdes strcat (newargz[0], actual_cwrapper_name); 4506228692Sdes 4507228692Sdes /* DO want the lt- prefix here if it exists, so use target_name */ 4508228692Sdes lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 4509228692Sdes XFREE (tmp_pathspec); 4510228692Sdes tmp_pathspec = NULL; 4511228692SdesEOF 4512228692Sdes 4513228692Sdes case $host_os in 4514228692Sdes mingw*) 4515228692Sdes cat <<"EOF" 4516228692Sdes { 4517228692Sdes char* p; 4518228692Sdes while ((p = strchr (newargz[0], '\\')) != NULL) 4519228692Sdes { 4520228692Sdes *p = '/'; 4521228692Sdes } 4522228692Sdes while ((p = strchr (lt_argv_zero, '\\')) != NULL) 4523228692Sdes { 4524228692Sdes *p = '/'; 4525228692Sdes } 4526228692Sdes } 4527228692SdesEOF 4528228692Sdes ;; 4529228692Sdes esac 4530228692Sdes 4531228692Sdes cat <<"EOF" 4532228692Sdes XFREE (target_name); 4533228692Sdes XFREE (actual_cwrapper_path); 4534228692Sdes XFREE (actual_cwrapper_name); 4535228692Sdes 4536228692Sdes lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 4537228692Sdes lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 4538228692Sdes /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 4539228692Sdes be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 4540228692Sdes because on Windows, both *_VARNAMEs are PATH but uninstalled 4541228692Sdes libraries must come first. */ 4542228692Sdes lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 4543228692Sdes lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4544228692Sdes 4545228692Sdes lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 4546228692Sdes nonnull (lt_argv_zero)); 4547228692Sdes for (i = 0; i < newargc; i++) 4548228692Sdes { 4549228692Sdes lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 4550228692Sdes i, nonnull (newargz[i])); 4551228692Sdes } 4552228692Sdes 4553228692SdesEOF 4554228692Sdes 4555228692Sdes case $host_os in 4556228692Sdes mingw*) 4557228692Sdes cat <<"EOF" 4558228692Sdes /* execv doesn't actually work on mingw as expected on unix */ 4559228692Sdes newargz = prepare_spawn (newargz); 4560228692Sdes rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 4561228692Sdes if (rval == -1) 4562228692Sdes { 4563228692Sdes /* failed to start process */ 4564228692Sdes lt_debugprintf (__FILE__, __LINE__, 4565228692Sdes "(main) failed to launch target \"%s\": %s\n", 4566228692Sdes lt_argv_zero, nonnull (strerror (errno))); 4567228692Sdes return 127; 4568228692Sdes } 4569228692Sdes return rval; 4570228692SdesEOF 4571228692Sdes ;; 4572228692Sdes *) 4573228692Sdes cat <<"EOF" 4574228692Sdes execv (lt_argv_zero, newargz); 4575228692Sdes return rval; /* =127, but avoids unused variable warning */ 4576228692SdesEOF 4577228692Sdes ;; 4578228692Sdes esac 4579228692Sdes 4580228692Sdes cat <<"EOF" 4581228692Sdes} 4582228692Sdes 4583228692Sdesvoid * 4584228692Sdesxmalloc (size_t num) 4585228692Sdes{ 4586228692Sdes void *p = (void *) malloc (num); 4587228692Sdes if (!p) 4588228692Sdes lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4589228692Sdes 4590228692Sdes return p; 4591228692Sdes} 4592228692Sdes 4593228692Sdeschar * 4594228692Sdesxstrdup (const char *string) 4595228692Sdes{ 4596228692Sdes return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 4597228692Sdes string) : NULL; 4598228692Sdes} 4599228692Sdes 4600228692Sdesconst char * 4601228692Sdesbase_name (const char *name) 4602228692Sdes{ 4603228692Sdes const char *base; 4604228692Sdes 4605228692Sdes#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4606228692Sdes /* Skip over the disk name in MSDOS pathnames. */ 4607228692Sdes if (isalpha ((unsigned char) name[0]) && name[1] == ':') 4608228692Sdes name += 2; 4609228692Sdes#endif 4610228692Sdes 4611228692Sdes for (base = name; *name; name++) 4612228692Sdes if (IS_DIR_SEPARATOR (*name)) 4613228692Sdes base = name + 1; 4614228692Sdes return base; 4615228692Sdes} 4616228692Sdes 4617228692Sdesint 4618228692Sdescheck_executable (const char *path) 4619228692Sdes{ 4620228692Sdes struct stat st; 4621228692Sdes 4622228692Sdes lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 4623228692Sdes nonempty (path)); 4624228692Sdes if ((!path) || (!*path)) 4625228692Sdes return 0; 4626228692Sdes 4627228692Sdes if ((stat (path, &st) >= 0) 4628228692Sdes && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 4629228692Sdes return 1; 4630228692Sdes else 4631228692Sdes return 0; 4632228692Sdes} 4633228692Sdes 4634228692Sdesint 4635228692Sdesmake_executable (const char *path) 4636228692Sdes{ 4637228692Sdes int rval = 0; 4638228692Sdes struct stat st; 4639228692Sdes 4640228692Sdes lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 4641228692Sdes nonempty (path)); 4642228692Sdes if ((!path) || (!*path)) 4643228692Sdes return 0; 4644228692Sdes 4645228692Sdes if (stat (path, &st) >= 0) 4646228692Sdes { 4647228692Sdes rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 4648228692Sdes } 4649228692Sdes return rval; 4650228692Sdes} 4651228692Sdes 4652228692Sdes/* Searches for the full path of the wrapper. Returns 4653228692Sdes newly allocated full path name if found, NULL otherwise 4654228692Sdes Does not chase symlinks, even on platforms that support them. 4655228692Sdes*/ 4656228692Sdeschar * 4657228692Sdesfind_executable (const char *wrapper) 4658228692Sdes{ 4659228692Sdes int has_slash = 0; 4660228692Sdes const char *p; 4661228692Sdes const char *p_next; 4662228692Sdes /* static buffer for getcwd */ 4663228692Sdes char tmp[LT_PATHMAX + 1]; 4664228692Sdes int tmp_len; 4665228692Sdes char *concat_name; 4666228692Sdes 4667228692Sdes lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 4668228692Sdes nonempty (wrapper)); 4669228692Sdes 4670228692Sdes if ((wrapper == NULL) || (*wrapper == '\0')) 4671228692Sdes return NULL; 4672228692Sdes 4673228692Sdes /* Absolute path? */ 4674228692Sdes#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4675228692Sdes if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 4676228692Sdes { 4677228692Sdes concat_name = xstrdup (wrapper); 4678228692Sdes if (check_executable (concat_name)) 4679228692Sdes return concat_name; 4680228692Sdes XFREE (concat_name); 4681228692Sdes } 4682228692Sdes else 4683228692Sdes { 4684228692Sdes#endif 4685228692Sdes if (IS_DIR_SEPARATOR (wrapper[0])) 4686228692Sdes { 4687228692Sdes concat_name = xstrdup (wrapper); 4688228692Sdes if (check_executable (concat_name)) 4689228692Sdes return concat_name; 4690228692Sdes XFREE (concat_name); 4691228692Sdes } 4692228692Sdes#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4693228692Sdes } 4694228692Sdes#endif 4695228692Sdes 4696228692Sdes for (p = wrapper; *p; p++) 4697228692Sdes if (*p == '/') 4698228692Sdes { 4699228692Sdes has_slash = 1; 4700228692Sdes break; 4701228692Sdes } 4702228692Sdes if (!has_slash) 4703228692Sdes { 4704228692Sdes /* no slashes; search PATH */ 4705228692Sdes const char *path = getenv ("PATH"); 4706228692Sdes if (path != NULL) 4707228692Sdes { 4708228692Sdes for (p = path; *p; p = p_next) 4709228692Sdes { 4710228692Sdes const char *q; 4711228692Sdes size_t p_len; 4712228692Sdes for (q = p; *q; q++) 4713228692Sdes if (IS_PATH_SEPARATOR (*q)) 4714228692Sdes break; 4715228692Sdes p_len = q - p; 4716228692Sdes p_next = (*q == '\0' ? q : q + 1); 4717228692Sdes if (p_len == 0) 4718228692Sdes { 4719228692Sdes /* empty path: current directory */ 4720228692Sdes if (getcwd (tmp, LT_PATHMAX) == NULL) 4721228692Sdes lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4722228692Sdes nonnull (strerror (errno))); 4723228692Sdes tmp_len = strlen (tmp); 4724228692Sdes concat_name = 4725228692Sdes XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4726228692Sdes memcpy (concat_name, tmp, tmp_len); 4727228692Sdes concat_name[tmp_len] = '/'; 4728228692Sdes strcpy (concat_name + tmp_len + 1, wrapper); 4729228692Sdes } 4730228692Sdes else 4731228692Sdes { 4732228692Sdes concat_name = 4733228692Sdes XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 4734228692Sdes memcpy (concat_name, p, p_len); 4735228692Sdes concat_name[p_len] = '/'; 4736228692Sdes strcpy (concat_name + p_len + 1, wrapper); 4737228692Sdes } 4738228692Sdes if (check_executable (concat_name)) 4739228692Sdes return concat_name; 4740228692Sdes XFREE (concat_name); 4741228692Sdes } 4742228692Sdes } 4743228692Sdes /* not found in PATH; assume curdir */ 4744228692Sdes } 4745228692Sdes /* Relative path | not found in path: prepend cwd */ 4746228692Sdes if (getcwd (tmp, LT_PATHMAX) == NULL) 4747228692Sdes lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4748228692Sdes nonnull (strerror (errno))); 4749228692Sdes tmp_len = strlen (tmp); 4750228692Sdes concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4751228692Sdes memcpy (concat_name, tmp, tmp_len); 4752228692Sdes concat_name[tmp_len] = '/'; 4753228692Sdes strcpy (concat_name + tmp_len + 1, wrapper); 4754228692Sdes 4755228692Sdes if (check_executable (concat_name)) 4756228692Sdes return concat_name; 4757228692Sdes XFREE (concat_name); 4758228692Sdes return NULL; 4759228692Sdes} 4760228692Sdes 4761228692Sdeschar * 4762228692Sdeschase_symlinks (const char *pathspec) 4763228692Sdes{ 4764228692Sdes#ifndef S_ISLNK 4765228692Sdes return xstrdup (pathspec); 4766228692Sdes#else 4767228692Sdes char buf[LT_PATHMAX]; 4768228692Sdes struct stat s; 4769228692Sdes char *tmp_pathspec = xstrdup (pathspec); 4770228692Sdes char *p; 4771228692Sdes int has_symlinks = 0; 4772228692Sdes while (strlen (tmp_pathspec) && !has_symlinks) 4773228692Sdes { 4774228692Sdes lt_debugprintf (__FILE__, __LINE__, 4775228692Sdes "checking path component for symlinks: %s\n", 4776228692Sdes tmp_pathspec); 4777228692Sdes if (lstat (tmp_pathspec, &s) == 0) 4778228692Sdes { 4779228692Sdes if (S_ISLNK (s.st_mode) != 0) 4780228692Sdes { 4781228692Sdes has_symlinks = 1; 4782228692Sdes break; 4783228692Sdes } 4784228692Sdes 4785228692Sdes /* search backwards for last DIR_SEPARATOR */ 4786228692Sdes p = tmp_pathspec + strlen (tmp_pathspec) - 1; 4787228692Sdes while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4788228692Sdes p--; 4789228692Sdes if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4790228692Sdes { 4791228692Sdes /* no more DIR_SEPARATORS left */ 4792228692Sdes break; 4793228692Sdes } 4794228692Sdes *p = '\0'; 4795228692Sdes } 4796228692Sdes else 4797228692Sdes { 4798228692Sdes lt_fatal (__FILE__, __LINE__, 4799228692Sdes "error accessing file \"%s\": %s", 4800228692Sdes tmp_pathspec, nonnull (strerror (errno))); 4801228692Sdes } 4802228692Sdes } 4803228692Sdes XFREE (tmp_pathspec); 4804228692Sdes 4805228692Sdes if (!has_symlinks) 4806228692Sdes { 4807228692Sdes return xstrdup (pathspec); 4808228692Sdes } 4809228692Sdes 4810228692Sdes tmp_pathspec = realpath (pathspec, buf); 4811228692Sdes if (tmp_pathspec == 0) 4812228692Sdes { 4813228692Sdes lt_fatal (__FILE__, __LINE__, 4814228692Sdes "could not follow symlinks for %s", pathspec); 4815228692Sdes } 4816228692Sdes return xstrdup (tmp_pathspec); 4817228692Sdes#endif 4818228692Sdes} 4819228692Sdes 4820228692Sdeschar * 4821228692Sdesstrendzap (char *str, const char *pat) 4822228692Sdes{ 4823228692Sdes size_t len, patlen; 4824228692Sdes 4825228692Sdes assert (str != NULL); 4826228692Sdes assert (pat != NULL); 4827228692Sdes 4828228692Sdes len = strlen (str); 4829228692Sdes patlen = strlen (pat); 4830228692Sdes 4831228692Sdes if (patlen <= len) 4832228692Sdes { 4833228692Sdes str += len - patlen; 4834228692Sdes if (strcmp (str, pat) == 0) 4835228692Sdes *str = '\0'; 4836228692Sdes } 4837228692Sdes return str; 4838228692Sdes} 4839228692Sdes 4840228692Sdesvoid 4841228692Sdeslt_debugprintf (const char *file, int line, const char *fmt, ...) 4842228692Sdes{ 4843228692Sdes va_list args; 4844228692Sdes if (lt_debug) 4845228692Sdes { 4846228692Sdes (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 4847228692Sdes va_start (args, fmt); 4848228692Sdes (void) vfprintf (stderr, fmt, args); 4849228692Sdes va_end (args); 4850228692Sdes } 4851228692Sdes} 4852228692Sdes 4853228692Sdesstatic void 4854228692Sdeslt_error_core (int exit_status, const char *file, 4855228692Sdes int line, const char *mode, 4856228692Sdes const char *message, va_list ap) 4857228692Sdes{ 4858228692Sdes fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 4859228692Sdes vfprintf (stderr, message, ap); 4860228692Sdes fprintf (stderr, ".\n"); 4861228692Sdes 4862228692Sdes if (exit_status >= 0) 4863228692Sdes exit (exit_status); 4864228692Sdes} 4865228692Sdes 4866228692Sdesvoid 4867228692Sdeslt_fatal (const char *file, int line, const char *message, ...) 4868228692Sdes{ 4869228692Sdes va_list ap; 4870228692Sdes va_start (ap, message); 4871228692Sdes lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 4872228692Sdes va_end (ap); 4873228692Sdes} 4874228692Sdes 4875228692Sdesstatic const char * 4876228692Sdesnonnull (const char *s) 4877228692Sdes{ 4878228692Sdes return s ? s : "(null)"; 4879228692Sdes} 4880228692Sdes 4881228692Sdesstatic const char * 4882228692Sdesnonempty (const char *s) 4883228692Sdes{ 4884228692Sdes return (s && !*s) ? "(empty)" : nonnull (s); 4885228692Sdes} 4886228692Sdes 4887228692Sdesvoid 4888228692Sdeslt_setenv (const char *name, const char *value) 4889228692Sdes{ 4890228692Sdes lt_debugprintf (__FILE__, __LINE__, 4891228692Sdes "(lt_setenv) setting '%s' to '%s'\n", 4892228692Sdes nonnull (name), nonnull (value)); 4893228692Sdes { 4894228692Sdes#ifdef HAVE_SETENV 4895228692Sdes /* always make a copy, for consistency with !HAVE_SETENV */ 4896228692Sdes char *str = xstrdup (value); 4897228692Sdes setenv (name, str, 1); 4898228692Sdes#else 4899228692Sdes int len = strlen (name) + 1 + strlen (value) + 1; 4900228692Sdes char *str = XMALLOC (char, len); 4901228692Sdes sprintf (str, "%s=%s", name, value); 4902228692Sdes if (putenv (str) != EXIT_SUCCESS) 4903228692Sdes { 4904228692Sdes XFREE (str); 4905228692Sdes } 4906228692Sdes#endif 4907228692Sdes } 4908228692Sdes} 4909228692Sdes 4910228692Sdeschar * 4911228692Sdeslt_extend_str (const char *orig_value, const char *add, int to_end) 4912228692Sdes{ 4913228692Sdes char *new_value; 4914228692Sdes if (orig_value && *orig_value) 4915228692Sdes { 4916228692Sdes int orig_value_len = strlen (orig_value); 4917228692Sdes int add_len = strlen (add); 4918228692Sdes new_value = XMALLOC (char, add_len + orig_value_len + 1); 4919228692Sdes if (to_end) 4920228692Sdes { 4921228692Sdes strcpy (new_value, orig_value); 4922228692Sdes strcpy (new_value + orig_value_len, add); 4923228692Sdes } 4924228692Sdes else 4925228692Sdes { 4926228692Sdes strcpy (new_value, add); 4927228692Sdes strcpy (new_value + add_len, orig_value); 4928228692Sdes } 4929228692Sdes } 4930228692Sdes else 4931228692Sdes { 4932228692Sdes new_value = xstrdup (add); 4933228692Sdes } 4934228692Sdes return new_value; 4935228692Sdes} 4936228692Sdes 4937228692Sdesvoid 4938228692Sdeslt_update_exe_path (const char *name, const char *value) 4939228692Sdes{ 4940228692Sdes lt_debugprintf (__FILE__, __LINE__, 4941228692Sdes "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 4942228692Sdes nonnull (name), nonnull (value)); 4943228692Sdes 4944228692Sdes if (name && *name && value && *value) 4945228692Sdes { 4946228692Sdes char *new_value = lt_extend_str (getenv (name), value, 0); 4947228692Sdes /* some systems can't cope with a ':'-terminated path #' */ 4948228692Sdes int len = strlen (new_value); 4949228692Sdes while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 4950228692Sdes { 4951228692Sdes new_value[len-1] = '\0'; 4952228692Sdes } 4953228692Sdes lt_setenv (name, new_value); 4954228692Sdes XFREE (new_value); 4955228692Sdes } 4956228692Sdes} 4957228692Sdes 4958228692Sdesvoid 4959228692Sdeslt_update_lib_path (const char *name, const char *value) 4960228692Sdes{ 4961228692Sdes lt_debugprintf (__FILE__, __LINE__, 4962228692Sdes "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 4963228692Sdes nonnull (name), nonnull (value)); 4964228692Sdes 4965228692Sdes if (name && *name && value && *value) 4966228692Sdes { 4967228692Sdes char *new_value = lt_extend_str (getenv (name), value, 0); 4968228692Sdes lt_setenv (name, new_value); 4969228692Sdes XFREE (new_value); 4970228692Sdes } 4971228692Sdes} 4972228692Sdes 4973228692SdesEOF 4974228692Sdes case $host_os in 4975228692Sdes mingw*) 4976228692Sdes cat <<"EOF" 4977228692Sdes 4978228692Sdes/* Prepares an argument vector before calling spawn(). 4979228692Sdes Note that spawn() does not by itself call the command interpreter 4980228692Sdes (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 4981228692Sdes ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 4982228692Sdes GetVersionEx(&v); 4983228692Sdes v.dwPlatformId == VER_PLATFORM_WIN32_NT; 4984228692Sdes }) ? "cmd.exe" : "command.com"). 4985228692Sdes Instead it simply concatenates the arguments, separated by ' ', and calls 4986228692Sdes CreateProcess(). We must quote the arguments since Win32 CreateProcess() 4987228692Sdes interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 4988228692Sdes special way: 4989228692Sdes - Space and tab are interpreted as delimiters. They are not treated as 4990228692Sdes delimiters if they are surrounded by double quotes: "...". 4991228692Sdes - Unescaped double quotes are removed from the input. Their only effect is 4992228692Sdes that within double quotes, space and tab are treated like normal 4993228692Sdes characters. 4994228692Sdes - Backslashes not followed by double quotes are not special. 4995228692Sdes - But 2*n+1 backslashes followed by a double quote become 4996228692Sdes n backslashes followed by a double quote (n >= 0): 4997228692Sdes \" -> " 4998228692Sdes \\\" -> \" 4999228692Sdes \\\\\" -> \\" 5000228692Sdes */ 5001228692Sdes#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" 5002228692Sdes#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" 5003228692Sdeschar ** 5004228692Sdesprepare_spawn (char **argv) 5005228692Sdes{ 5006228692Sdes size_t argc; 5007228692Sdes char **new_argv; 5008228692Sdes size_t i; 5009228692Sdes 5010228692Sdes /* Count number of arguments. */ 5011228692Sdes for (argc = 0; argv[argc] != NULL; argc++) 5012228692Sdes ; 5013228692Sdes 5014228692Sdes /* Allocate new argument vector. */ 5015228692Sdes new_argv = XMALLOC (char *, argc + 1); 5016228692Sdes 5017228692Sdes /* Put quoted arguments into the new argument vector. */ 5018228692Sdes for (i = 0; i < argc; i++) 5019228692Sdes { 5020228692Sdes const char *string = argv[i]; 5021228692Sdes 5022228692Sdes if (string[0] == '\0') 5023228692Sdes new_argv[i] = xstrdup ("\"\""); 5024228692Sdes else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 5025228692Sdes { 5026228692Sdes int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 5027228692Sdes size_t length; 5028228692Sdes unsigned int backslashes; 5029228692Sdes const char *s; 5030228692Sdes char *quoted_string; 5031228692Sdes char *p; 5032228692Sdes 5033228692Sdes length = 0; 5034228692Sdes backslashes = 0; 5035228692Sdes if (quote_around) 5036228692Sdes length++; 5037228692Sdes for (s = string; *s != '\0'; s++) 5038228692Sdes { 5039228692Sdes char c = *s; 5040228692Sdes if (c == '"') 5041228692Sdes length += backslashes + 1; 5042228692Sdes length++; 5043228692Sdes if (c == '\\') 5044228692Sdes backslashes++; 5045228692Sdes else 5046228692Sdes backslashes = 0; 5047228692Sdes } 5048228692Sdes if (quote_around) 5049228692Sdes length += backslashes + 1; 5050228692Sdes 5051228692Sdes quoted_string = XMALLOC (char, length + 1); 5052228692Sdes 5053228692Sdes p = quoted_string; 5054228692Sdes backslashes = 0; 5055228692Sdes if (quote_around) 5056228692Sdes *p++ = '"'; 5057228692Sdes for (s = string; *s != '\0'; s++) 5058228692Sdes { 5059228692Sdes char c = *s; 5060228692Sdes if (c == '"') 5061228692Sdes { 5062228692Sdes unsigned int j; 5063228692Sdes for (j = backslashes + 1; j > 0; j--) 5064228692Sdes *p++ = '\\'; 5065228692Sdes } 5066228692Sdes *p++ = c; 5067228692Sdes if (c == '\\') 5068228692Sdes backslashes++; 5069228692Sdes else 5070228692Sdes backslashes = 0; 5071228692Sdes } 5072228692Sdes if (quote_around) 5073228692Sdes { 5074228692Sdes unsigned int j; 5075228692Sdes for (j = backslashes; j > 0; j--) 5076228692Sdes *p++ = '\\'; 5077228692Sdes *p++ = '"'; 5078228692Sdes } 5079228692Sdes *p = '\0'; 5080228692Sdes 5081228692Sdes new_argv[i] = quoted_string; 5082228692Sdes } 5083228692Sdes else 5084228692Sdes new_argv[i] = (char *) string; 5085228692Sdes } 5086228692Sdes new_argv[argc] = NULL; 5087228692Sdes 5088228692Sdes return new_argv; 5089228692Sdes} 5090228692SdesEOF 5091228692Sdes ;; 5092228692Sdes esac 5093228692Sdes 5094228692Sdes cat <<"EOF" 5095228692Sdesvoid lt_dump_script (FILE* f) 5096228692Sdes{ 5097228692SdesEOF 5098228692Sdes func_emit_wrapper yes | 5099236109Sdes $SED -n -e ' 5100236109Sdess/^\(.\{79\}\)\(..*\)/\1\ 5101236109Sdes\2/ 5102236109Sdesh 5103236109Sdess/\([\\"]\)/\\\1/g 5104236109Sdess/$/\\n/ 5105236109Sdess/\([^\n]*\).*/ fputs ("\1", f);/p 5106236109Sdesg 5107236109SdesD' 5108228692Sdes cat <<"EOF" 5109228692Sdes} 5110228692SdesEOF 5111228692Sdes} 5112228692Sdes# end: func_emit_cwrapperexe_src 5113228692Sdes 5114228692Sdes# func_win32_import_lib_p ARG 5115228692Sdes# True if ARG is an import lib, as indicated by $file_magic_cmd 5116228692Sdesfunc_win32_import_lib_p () 5117228692Sdes{ 5118228692Sdes $opt_debug 5119228692Sdes case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 5120228692Sdes *import*) : ;; 5121228692Sdes *) false ;; 5122228692Sdes esac 5123228692Sdes} 5124228692Sdes 5125228692Sdes# func_mode_link arg... 5126228692Sdesfunc_mode_link () 5127228692Sdes{ 5128228692Sdes $opt_debug 5129125647Sdes case $host in 5130228692Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5131117610Sdes # It is impossible to link a dll without this setting, and 5132117610Sdes # we shouldn't force the makefile maintainer to figure out 5133117610Sdes # which system we are compiling for in order to pass an extra 5134141098Sdes # flag for every libtool invocation. 5135117610Sdes # allow_undefined=no 5136117610Sdes 5137117610Sdes # FIXME: Unfortunately, there are problems with the above when trying 5138117610Sdes # to make a dll which has undefined symbols, in which case not 5139117610Sdes # even a static library is built. For now, we need to specify 5140117610Sdes # -no-undefined on the libtool link line when we can be certain 5141117610Sdes # that all symbols are satisfied, otherwise we get a static library. 5142117610Sdes allow_undefined=yes 5143117610Sdes ;; 5144117610Sdes *) 5145117610Sdes allow_undefined=yes 5146117610Sdes ;; 5147117610Sdes esac 5148228692Sdes libtool_args=$nonopt 5149141098Sdes base_compile="$nonopt $@" 5150228692Sdes compile_command=$nonopt 5151228692Sdes finalize_command=$nonopt 5152117610Sdes 5153117610Sdes compile_rpath= 5154117610Sdes finalize_rpath= 5155117610Sdes compile_shlibpath= 5156117610Sdes finalize_shlibpath= 5157117610Sdes convenience= 5158117610Sdes old_convenience= 5159117610Sdes deplibs= 5160125647Sdes old_deplibs= 5161125647Sdes compiler_flags= 5162125647Sdes linker_flags= 5163125647Sdes dllsearchpath= 5164125647Sdes lib_search_path=`pwd` 5165141098Sdes inst_prefix_dir= 5166228692Sdes new_inherited_linker_flags= 5167117610Sdes 5168117610Sdes avoid_version=no 5169228692Sdes bindir= 5170117610Sdes dlfiles= 5171117610Sdes dlprefiles= 5172117610Sdes dlself=no 5173117610Sdes export_dynamic=no 5174117610Sdes export_symbols= 5175117610Sdes export_symbols_regex= 5176117610Sdes generated= 5177117610Sdes libobjs= 5178117610Sdes ltlibs= 5179117610Sdes module=no 5180125647Sdes no_install=no 5181117610Sdes objs= 5182141098Sdes non_pic_objects= 5183141098Sdes precious_files_regex= 5184117610Sdes prefer_static_libs=no 5185117610Sdes preload=no 5186117610Sdes prev= 5187117610Sdes prevarg= 5188117610Sdes release= 5189117610Sdes rpath= 5190117610Sdes xrpath= 5191117610Sdes perm_rpath= 5192117610Sdes temp_rpath= 5193117610Sdes thread_safe=no 5194117610Sdes vinfo= 5195141098Sdes vinfo_number=no 5196228692Sdes weak_libs= 5197228692Sdes single_module="${wl}-single_module" 5198141098Sdes func_infer_tag $base_compile 5199141098Sdes 5200117610Sdes # We need to know -static, to get the right output filenames. 5201117610Sdes for arg 5202117610Sdes do 5203125647Sdes case $arg in 5204228692Sdes -shared) 5205228692Sdes test "$build_libtool_libs" != yes && \ 5206228692Sdes func_fatal_configuration "can not build a shared library" 5207228692Sdes build_old_libs=no 5208228692Sdes break 5209228692Sdes ;; 5210174832Sdes -all-static | -static | -static-libtool-libs) 5211174832Sdes case $arg in 5212174832Sdes -all-static) 5213117610Sdes if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 5214228692Sdes func_warning "complete static linking is impossible in this configuration" 5215117610Sdes fi 5216117610Sdes if test -n "$link_static_flag"; then 5217117610Sdes dlopen_self=$dlopen_self_static 5218117610Sdes fi 5219174832Sdes prefer_static_libs=yes 5220174832Sdes ;; 5221174832Sdes -static) 5222117610Sdes if test -z "$pic_flag" && test -n "$link_static_flag"; then 5223117610Sdes dlopen_self=$dlopen_self_static 5224117610Sdes fi 5225174832Sdes prefer_static_libs=built 5226174832Sdes ;; 5227174832Sdes -static-libtool-libs) 5228174832Sdes if test -z "$pic_flag" && test -n "$link_static_flag"; then 5229174832Sdes dlopen_self=$dlopen_self_static 5230174832Sdes fi 5231174832Sdes prefer_static_libs=yes 5232174832Sdes ;; 5233174832Sdes esac 5234117610Sdes build_libtool_libs=no 5235117610Sdes build_old_libs=yes 5236117610Sdes break 5237117610Sdes ;; 5238117610Sdes esac 5239117610Sdes done 5240117610Sdes 5241117610Sdes # See if our shared archives depend on static archives. 5242117610Sdes test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5243117610Sdes 5244117610Sdes # Go through the arguments, transforming them on the way. 5245141098Sdes while test "$#" -gt 0; do 5246117610Sdes arg="$1" 5247117610Sdes shift 5248228692Sdes func_quote_for_eval "$arg" 5249228692Sdes qarg=$func_quote_for_eval_unquoted_result 5250228692Sdes func_append libtool_args " $func_quote_for_eval_result" 5251117610Sdes 5252117610Sdes # If the previous option needs an argument, assign it. 5253117610Sdes if test -n "$prev"; then 5254125647Sdes case $prev in 5255117610Sdes output) 5256228692Sdes func_append compile_command " @OUTPUT@" 5257228692Sdes func_append finalize_command " @OUTPUT@" 5258117610Sdes ;; 5259117610Sdes esac 5260117610Sdes 5261125647Sdes case $prev in 5262228692Sdes bindir) 5263228692Sdes bindir="$arg" 5264228692Sdes prev= 5265228692Sdes continue 5266228692Sdes ;; 5267117610Sdes dlfiles|dlprefiles) 5268117610Sdes if test "$preload" = no; then 5269117610Sdes # Add the symbol object into the linking commands. 5270228692Sdes func_append compile_command " @SYMFILE@" 5271228692Sdes func_append finalize_command " @SYMFILE@" 5272117610Sdes preload=yes 5273117610Sdes fi 5274125647Sdes case $arg in 5275117610Sdes *.la | *.lo) ;; # We handle these cases below. 5276117610Sdes force) 5277117610Sdes if test "$dlself" = no; then 5278117610Sdes dlself=needless 5279117610Sdes export_dynamic=yes 5280117610Sdes fi 5281117610Sdes prev= 5282117610Sdes continue 5283117610Sdes ;; 5284117610Sdes self) 5285117610Sdes if test "$prev" = dlprefiles; then 5286117610Sdes dlself=yes 5287117610Sdes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 5288117610Sdes dlself=yes 5289117610Sdes else 5290117610Sdes dlself=needless 5291117610Sdes export_dynamic=yes 5292117610Sdes fi 5293117610Sdes prev= 5294117610Sdes continue 5295117610Sdes ;; 5296117610Sdes *) 5297117610Sdes if test "$prev" = dlfiles; then 5298228692Sdes func_append dlfiles " $arg" 5299117610Sdes else 5300228692Sdes func_append dlprefiles " $arg" 5301117610Sdes fi 5302117610Sdes prev= 5303125647Sdes continue 5304117610Sdes ;; 5305117610Sdes esac 5306117610Sdes ;; 5307117610Sdes expsyms) 5308117610Sdes export_symbols="$arg" 5309228692Sdes test -f "$arg" \ 5310228692Sdes || func_fatal_error "symbol file \`$arg' does not exist" 5311117610Sdes prev= 5312117610Sdes continue 5313117610Sdes ;; 5314117610Sdes expsyms_regex) 5315117610Sdes export_symbols_regex="$arg" 5316117610Sdes prev= 5317117610Sdes continue 5318117610Sdes ;; 5319228692Sdes framework) 5320228692Sdes case $host in 5321228692Sdes *-*-darwin*) 5322228692Sdes case "$deplibs " in 5323228692Sdes *" $qarg.ltframework "*) ;; 5324228692Sdes *) func_append deplibs " $qarg.ltframework" # this is fixed later 5325228692Sdes ;; 5326228692Sdes esac 5327228692Sdes ;; 5328228692Sdes esac 5329141098Sdes prev= 5330141098Sdes continue 5331141098Sdes ;; 5332228692Sdes inst_prefix) 5333228692Sdes inst_prefix_dir="$arg" 5334141098Sdes prev= 5335141098Sdes continue 5336141098Sdes ;; 5337141098Sdes objectlist) 5338141098Sdes if test -f "$arg"; then 5339141098Sdes save_arg=$arg 5340141098Sdes moreargs= 5341228692Sdes for fil in `cat "$save_arg"` 5342141098Sdes do 5343228692Sdes# func_append moreargs " $fil" 5344141098Sdes arg=$fil 5345141098Sdes # A libtool-controlled object. 5346141098Sdes 5347141098Sdes # Check to see that this really is a libtool object. 5348228692Sdes if func_lalib_unsafe_p "$arg"; then 5349141098Sdes pic_object= 5350141098Sdes non_pic_object= 5351141098Sdes 5352141098Sdes # Read the .lo file 5353228692Sdes func_source "$arg" 5354141098Sdes 5355228692Sdes if test -z "$pic_object" || 5356141098Sdes test -z "$non_pic_object" || 5357228692Sdes test "$pic_object" = none && 5358141098Sdes test "$non_pic_object" = none; then 5359228692Sdes func_fatal_error "cannot find name of object for \`$arg'" 5360141098Sdes fi 5361141098Sdes 5362141098Sdes # Extract subdirectory from the argument. 5363228692Sdes func_dirname "$arg" "/" "" 5364228692Sdes xdir="$func_dirname_result" 5365141098Sdes 5366141098Sdes if test "$pic_object" != none; then 5367141098Sdes # Prepend the subdirectory the object is found in. 5368141098Sdes pic_object="$xdir$pic_object" 5369141098Sdes 5370141098Sdes if test "$prev" = dlfiles; then 5371141098Sdes if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5372228692Sdes func_append dlfiles " $pic_object" 5373141098Sdes prev= 5374141098Sdes continue 5375141098Sdes else 5376141098Sdes # If libtool objects are unsupported, then we need to preload. 5377141098Sdes prev=dlprefiles 5378141098Sdes fi 5379141098Sdes fi 5380141098Sdes 5381141098Sdes # CHECK ME: I think I busted this. -Ossama 5382141098Sdes if test "$prev" = dlprefiles; then 5383141098Sdes # Preload the old-style object. 5384228692Sdes func_append dlprefiles " $pic_object" 5385141098Sdes prev= 5386141098Sdes fi 5387141098Sdes 5388141098Sdes # A PIC object. 5389228692Sdes func_append libobjs " $pic_object" 5390141098Sdes arg="$pic_object" 5391141098Sdes fi 5392141098Sdes 5393141098Sdes # Non-PIC object. 5394141098Sdes if test "$non_pic_object" != none; then 5395141098Sdes # Prepend the subdirectory the object is found in. 5396141098Sdes non_pic_object="$xdir$non_pic_object" 5397141098Sdes 5398141098Sdes # A standard non-PIC object 5399228692Sdes func_append non_pic_objects " $non_pic_object" 5400141098Sdes if test -z "$pic_object" || test "$pic_object" = none ; then 5401141098Sdes arg="$non_pic_object" 5402141098Sdes fi 5403174832Sdes else 5404174832Sdes # If the PIC object exists, use it instead. 5405174832Sdes # $xdir was prepended to $pic_object above. 5406174832Sdes non_pic_object="$pic_object" 5407228692Sdes func_append non_pic_objects " $non_pic_object" 5408141098Sdes fi 5409141098Sdes else 5410141098Sdes # Only an error if not doing a dry-run. 5411228692Sdes if $opt_dry_run; then 5412141098Sdes # Extract subdirectory from the argument. 5413228692Sdes func_dirname "$arg" "/" "" 5414228692Sdes xdir="$func_dirname_result" 5415141098Sdes 5416228692Sdes func_lo2o "$arg" 5417228692Sdes pic_object=$xdir$objdir/$func_lo2o_result 5418228692Sdes non_pic_object=$xdir$func_lo2o_result 5419228692Sdes func_append libobjs " $pic_object" 5420228692Sdes func_append non_pic_objects " $non_pic_object" 5421228692Sdes else 5422228692Sdes func_fatal_error "\`$arg' is not a valid libtool object" 5423141098Sdes fi 5424141098Sdes fi 5425141098Sdes done 5426141098Sdes else 5427228692Sdes func_fatal_error "link input file \`$arg' does not exist" 5428141098Sdes fi 5429141098Sdes arg=$save_arg 5430141098Sdes prev= 5431141098Sdes continue 5432141098Sdes ;; 5433228692Sdes precious_regex) 5434228692Sdes precious_files_regex="$arg" 5435228692Sdes prev= 5436228692Sdes continue 5437228692Sdes ;; 5438228692Sdes release) 5439228692Sdes release="-$arg" 5440228692Sdes prev= 5441228692Sdes continue 5442228692Sdes ;; 5443117610Sdes rpath | xrpath) 5444117610Sdes # We need an absolute path. 5445125647Sdes case $arg in 5446117610Sdes [\\/]* | [A-Za-z]:[\\/]*) ;; 5447117610Sdes *) 5448228692Sdes func_fatal_error "only absolute run-paths are allowed" 5449117610Sdes ;; 5450117610Sdes esac 5451117610Sdes if test "$prev" = rpath; then 5452117610Sdes case "$rpath " in 5453117610Sdes *" $arg "*) ;; 5454228692Sdes *) func_append rpath " $arg" ;; 5455117610Sdes esac 5456117610Sdes else 5457117610Sdes case "$xrpath " in 5458117610Sdes *" $arg "*) ;; 5459228692Sdes *) func_append xrpath " $arg" ;; 5460117610Sdes esac 5461117610Sdes fi 5462117610Sdes prev= 5463117610Sdes continue 5464117610Sdes ;; 5465228692Sdes shrext) 5466228692Sdes shrext_cmds="$arg" 5467125647Sdes prev= 5468125647Sdes continue 5469125647Sdes ;; 5470228692Sdes weak) 5471228692Sdes func_append weak_libs " $arg" 5472125647Sdes prev= 5473125647Sdes continue 5474125647Sdes ;; 5475141098Sdes xcclinker) 5476228692Sdes func_append linker_flags " $qarg" 5477228692Sdes func_append compiler_flags " $qarg" 5478141098Sdes prev= 5479228692Sdes func_append compile_command " $qarg" 5480228692Sdes func_append finalize_command " $qarg" 5481141098Sdes continue 5482141098Sdes ;; 5483228692Sdes xcompiler) 5484228692Sdes func_append compiler_flags " $qarg" 5485141098Sdes prev= 5486228692Sdes func_append compile_command " $qarg" 5487228692Sdes func_append finalize_command " $qarg" 5488141098Sdes continue 5489141098Sdes ;; 5490228692Sdes xlinker) 5491228692Sdes func_append linker_flags " $qarg" 5492228692Sdes func_append compiler_flags " $wl$qarg" 5493147455Sdes prev= 5494228692Sdes func_append compile_command " $wl$qarg" 5495228692Sdes func_append finalize_command " $wl$qarg" 5496147455Sdes continue 5497147455Sdes ;; 5498117610Sdes *) 5499117610Sdes eval "$prev=\"\$arg\"" 5500117610Sdes prev= 5501117610Sdes continue 5502117610Sdes ;; 5503117610Sdes esac 5504141098Sdes fi # test -n "$prev" 5505117610Sdes 5506117610Sdes prevarg="$arg" 5507117610Sdes 5508125647Sdes case $arg in 5509117610Sdes -all-static) 5510117610Sdes if test -n "$link_static_flag"; then 5511228692Sdes # See comment for -static flag below, for more details. 5512228692Sdes func_append compile_command " $link_static_flag" 5513228692Sdes func_append finalize_command " $link_static_flag" 5514117610Sdes fi 5515117610Sdes continue 5516117610Sdes ;; 5517117610Sdes 5518117610Sdes -allow-undefined) 5519117610Sdes # FIXME: remove this flag sometime in the future. 5520228692Sdes func_fatal_error "\`-allow-undefined' must not be used because it is the default" 5521117610Sdes ;; 5522117610Sdes 5523117610Sdes -avoid-version) 5524117610Sdes avoid_version=yes 5525117610Sdes continue 5526117610Sdes ;; 5527117610Sdes 5528228692Sdes -bindir) 5529228692Sdes prev=bindir 5530228692Sdes continue 5531228692Sdes ;; 5532228692Sdes 5533117610Sdes -dlopen) 5534117610Sdes prev=dlfiles 5535117610Sdes continue 5536117610Sdes ;; 5537117610Sdes 5538117610Sdes -dlpreopen) 5539117610Sdes prev=dlprefiles 5540117610Sdes continue 5541117610Sdes ;; 5542117610Sdes 5543117610Sdes -export-dynamic) 5544117610Sdes export_dynamic=yes 5545117610Sdes continue 5546117610Sdes ;; 5547117610Sdes 5548117610Sdes -export-symbols | -export-symbols-regex) 5549117610Sdes if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 5550228692Sdes func_fatal_error "more than one -exported-symbols argument is not allowed" 5551117610Sdes fi 5552117610Sdes if test "X$arg" = "X-export-symbols"; then 5553117610Sdes prev=expsyms 5554117610Sdes else 5555117610Sdes prev=expsyms_regex 5556117610Sdes fi 5557117610Sdes continue 5558117610Sdes ;; 5559117610Sdes 5560228692Sdes -framework) 5561228692Sdes prev=framework 5562174832Sdes continue 5563174832Sdes ;; 5564147455Sdes 5565141098Sdes -inst-prefix-dir) 5566141098Sdes prev=inst_prefix 5567141098Sdes continue 5568141098Sdes ;; 5569141098Sdes 5570125647Sdes # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 5571125647Sdes # so, if we see these flags be careful not to treat them like -L 5572125647Sdes -L[A-Z][A-Z]*:*) 5573125647Sdes case $with_gcc/$host in 5574141098Sdes no/*-*-irix* | /*-*-irix*) 5575228692Sdes func_append compile_command " $arg" 5576228692Sdes func_append finalize_command " $arg" 5577125647Sdes ;; 5578125647Sdes esac 5579125647Sdes continue 5580125647Sdes ;; 5581125647Sdes 5582117610Sdes -L*) 5583228692Sdes func_stripname "-L" '' "$arg" 5584228692Sdes if test -z "$func_stripname_result"; then 5585228692Sdes if test "$#" -gt 0; then 5586228692Sdes func_fatal_error "require no space between \`-L' and \`$1'" 5587228692Sdes else 5588228692Sdes func_fatal_error "need path for \`-L' option" 5589228692Sdes fi 5590228692Sdes fi 5591228692Sdes func_resolve_sysroot "$func_stripname_result" 5592228692Sdes dir=$func_resolve_sysroot_result 5593117610Sdes # We need an absolute path. 5594125647Sdes case $dir in 5595117610Sdes [\\/]* | [A-Za-z]:[\\/]*) ;; 5596117610Sdes *) 5597117610Sdes absdir=`cd "$dir" && pwd` 5598228692Sdes test -z "$absdir" && \ 5599228692Sdes func_fatal_error "cannot determine absolute directory name of \`$dir'" 5600117610Sdes dir="$absdir" 5601117610Sdes ;; 5602117610Sdes esac 5603125647Sdes case "$deplibs " in 5604228692Sdes *" -L$dir "* | *" $arg "*) 5605228692Sdes # Will only happen for absolute or sysroot arguments 5606228692Sdes ;; 5607125647Sdes *) 5608228692Sdes # Preserve sysroot, but never include relative directories 5609228692Sdes case $dir in 5610228692Sdes [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 5611228692Sdes *) func_append deplibs " -L$dir" ;; 5612228692Sdes esac 5613228692Sdes func_append lib_search_path " $dir" 5614125647Sdes ;; 5615117610Sdes esac 5616125647Sdes case $host in 5617228692Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5618228692Sdes testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 5619125647Sdes case :$dllsearchpath: in 5620125647Sdes *":$dir:"*) ;; 5621228692Sdes ::) dllsearchpath=$dir;; 5622228692Sdes *) func_append dllsearchpath ":$dir";; 5623117610Sdes esac 5624174832Sdes case :$dllsearchpath: in 5625174832Sdes *":$testbindir:"*) ;; 5626228692Sdes ::) dllsearchpath=$testbindir;; 5627228692Sdes *) func_append dllsearchpath ":$testbindir";; 5628174832Sdes esac 5629117610Sdes ;; 5630117610Sdes esac 5631228692Sdes deplibs="$deplibs $arg" 5632125647Sdes continue 5633117610Sdes ;; 5634117610Sdes 5635117610Sdes -l*) 5636125647Sdes if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 5637125647Sdes case $host in 5638228692Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 5639125647Sdes # These systems don't actually have a C or math library (as such) 5640117610Sdes continue 5641117610Sdes ;; 5642174832Sdes *-*-os2*) 5643125647Sdes # These systems don't actually have a C library (as such) 5644125647Sdes test "X$arg" = "X-lc" && continue 5645125647Sdes ;; 5646147455Sdes *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5647125647Sdes # Do not include libc due to us having libc/libc_r. 5648125647Sdes test "X$arg" = "X-lc" && continue 5649125647Sdes ;; 5650141098Sdes *-*-rhapsody* | *-*-darwin1.[012]) 5651141098Sdes # Rhapsody C and math libraries are in the System framework 5652228692Sdes func_append deplibs " System.ltframework" 5653117610Sdes continue 5654174832Sdes ;; 5655174832Sdes *-*-sco3.2v5* | *-*-sco5v6*) 5656174832Sdes # Causes problems with __ctype 5657174832Sdes test "X$arg" = "X-lc" && continue 5658174832Sdes ;; 5659174832Sdes *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 5660174832Sdes # Compiler inserts libc in the correct place for threads to work 5661174832Sdes test "X$arg" = "X-lc" && continue 5662174832Sdes ;; 5663117610Sdes esac 5664141098Sdes elif test "X$arg" = "X-lc_r"; then 5665141098Sdes case $host in 5666147455Sdes *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5667141098Sdes # Do not include libc_r directly, use -pthread flag. 5668141098Sdes continue 5669141098Sdes ;; 5670141098Sdes esac 5671117610Sdes fi 5672228692Sdes func_append deplibs " $arg" 5673125647Sdes continue 5674117610Sdes ;; 5675117610Sdes 5676228692Sdes -module) 5677228692Sdes module=yes 5678228692Sdes continue 5679228692Sdes ;; 5680228692Sdes 5681147455Sdes # Tru64 UNIX uses -model [arg] to determine the layout of C++ 5682147455Sdes # classes, name mangling, and exception handling. 5683228692Sdes # Darwin uses the -arch flag to determine output architecture. 5684228692Sdes -model|-arch|-isysroot|--sysroot) 5685228692Sdes func_append compiler_flags " $arg" 5686228692Sdes func_append compile_command " $arg" 5687228692Sdes func_append finalize_command " $arg" 5688147455Sdes prev=xcompiler 5689147455Sdes continue 5690147455Sdes ;; 5691147455Sdes 5692236109Sdes -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 5693236109Sdes |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 5694228692Sdes func_append compiler_flags " $arg" 5695228692Sdes func_append compile_command " $arg" 5696228692Sdes func_append finalize_command " $arg" 5697228692Sdes case "$new_inherited_linker_flags " in 5698228692Sdes *" $arg "*) ;; 5699228692Sdes * ) func_append new_inherited_linker_flags " $arg" ;; 5700228692Sdes esac 5701141098Sdes continue 5702141098Sdes ;; 5703141098Sdes 5704228692Sdes -multi_module) 5705228692Sdes single_module="${wl}-multi_module" 5706141098Sdes continue 5707141098Sdes ;; 5708141098Sdes 5709125647Sdes -no-fast-install) 5710125647Sdes fast_install=no 5711125647Sdes continue 5712125647Sdes ;; 5713125647Sdes 5714125647Sdes -no-install) 5715125647Sdes case $host in 5716228692Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 5717125647Sdes # The PATH hackery in wrapper scripts is required on Windows 5718174832Sdes # and Darwin in order for the loader to find any dlls it needs. 5719228692Sdes func_warning "\`-no-install' is ignored for $host" 5720228692Sdes func_warning "assuming \`-no-fast-install' instead" 5721125647Sdes fast_install=no 5722125647Sdes ;; 5723125647Sdes *) no_install=yes ;; 5724125647Sdes esac 5725125647Sdes continue 5726125647Sdes ;; 5727125647Sdes 5728117610Sdes -no-undefined) 5729117610Sdes allow_undefined=no 5730117610Sdes continue 5731117610Sdes ;; 5732117610Sdes 5733141098Sdes -objectlist) 5734141098Sdes prev=objectlist 5735141098Sdes continue 5736141098Sdes ;; 5737141098Sdes 5738117610Sdes -o) prev=output ;; 5739117610Sdes 5740141098Sdes -precious-files-regex) 5741141098Sdes prev=precious_regex 5742141098Sdes continue 5743141098Sdes ;; 5744141098Sdes 5745117610Sdes -release) 5746117610Sdes prev=release 5747117610Sdes continue 5748117610Sdes ;; 5749117610Sdes 5750117610Sdes -rpath) 5751117610Sdes prev=rpath 5752117610Sdes continue 5753117610Sdes ;; 5754117610Sdes 5755117610Sdes -R) 5756117610Sdes prev=xrpath 5757117610Sdes continue 5758117610Sdes ;; 5759117610Sdes 5760117610Sdes -R*) 5761228692Sdes func_stripname '-R' '' "$arg" 5762228692Sdes dir=$func_stripname_result 5763117610Sdes # We need an absolute path. 5764125647Sdes case $dir in 5765117610Sdes [\\/]* | [A-Za-z]:[\\/]*) ;; 5766228692Sdes =*) 5767228692Sdes func_stripname '=' '' "$dir" 5768228692Sdes dir=$lt_sysroot$func_stripname_result 5769228692Sdes ;; 5770117610Sdes *) 5771228692Sdes func_fatal_error "only absolute run-paths are allowed" 5772117610Sdes ;; 5773117610Sdes esac 5774117610Sdes case "$xrpath " in 5775117610Sdes *" $dir "*) ;; 5776228692Sdes *) func_append xrpath " $dir" ;; 5777117610Sdes esac 5778117610Sdes continue 5779117610Sdes ;; 5780117610Sdes 5781228692Sdes -shared) 5782228692Sdes # The effects of -shared are defined in a previous loop. 5783228692Sdes continue 5784228692Sdes ;; 5785228692Sdes 5786228692Sdes -shrext) 5787228692Sdes prev=shrext 5788228692Sdes continue 5789228692Sdes ;; 5790228692Sdes 5791174832Sdes -static | -static-libtool-libs) 5792125647Sdes # The effects of -static are defined in a previous loop. 5793125647Sdes # We used to do the same as -all-static on platforms that 5794125647Sdes # didn't have a PIC flag, but the assumption that the effects 5795125647Sdes # would be equivalent was wrong. It would break on at least 5796125647Sdes # Digital Unix and AIX. 5797117610Sdes continue 5798117610Sdes ;; 5799117610Sdes 5800117610Sdes -thread-safe) 5801117610Sdes thread_safe=yes 5802117610Sdes continue 5803117610Sdes ;; 5804117610Sdes 5805117610Sdes -version-info) 5806117610Sdes prev=vinfo 5807117610Sdes continue 5808117610Sdes ;; 5809228692Sdes 5810141098Sdes -version-number) 5811141098Sdes prev=vinfo 5812141098Sdes vinfo_number=yes 5813141098Sdes continue 5814141098Sdes ;; 5815117610Sdes 5816228692Sdes -weak) 5817228692Sdes prev=weak 5818228692Sdes continue 5819228692Sdes ;; 5820228692Sdes 5821125647Sdes -Wc,*) 5822228692Sdes func_stripname '-Wc,' '' "$arg" 5823228692Sdes args=$func_stripname_result 5824125647Sdes arg= 5825125647Sdes save_ifs="$IFS"; IFS=',' 5826125647Sdes for flag in $args; do 5827125647Sdes IFS="$save_ifs" 5828228692Sdes func_quote_for_eval "$flag" 5829228692Sdes func_append arg " $func_quote_for_eval_result" 5830228692Sdes func_append compiler_flags " $func_quote_for_eval_result" 5831125647Sdes done 5832125647Sdes IFS="$save_ifs" 5833228692Sdes func_stripname ' ' '' "$arg" 5834228692Sdes arg=$func_stripname_result 5835125647Sdes ;; 5836125647Sdes 5837125647Sdes -Wl,*) 5838228692Sdes func_stripname '-Wl,' '' "$arg" 5839228692Sdes args=$func_stripname_result 5840125647Sdes arg= 5841125647Sdes save_ifs="$IFS"; IFS=',' 5842125647Sdes for flag in $args; do 5843125647Sdes IFS="$save_ifs" 5844228692Sdes func_quote_for_eval "$flag" 5845228692Sdes func_append arg " $wl$func_quote_for_eval_result" 5846228692Sdes func_append compiler_flags " $wl$func_quote_for_eval_result" 5847228692Sdes func_append linker_flags " $func_quote_for_eval_result" 5848125647Sdes done 5849125647Sdes IFS="$save_ifs" 5850228692Sdes func_stripname ' ' '' "$arg" 5851228692Sdes arg=$func_stripname_result 5852125647Sdes ;; 5853125647Sdes 5854125647Sdes -Xcompiler) 5855125647Sdes prev=xcompiler 5856125647Sdes continue 5857125647Sdes ;; 5858125647Sdes 5859125647Sdes -Xlinker) 5860125647Sdes prev=xlinker 5861125647Sdes continue 5862125647Sdes ;; 5863125647Sdes 5864141098Sdes -XCClinker) 5865141098Sdes prev=xcclinker 5866141098Sdes continue 5867141098Sdes ;; 5868141098Sdes 5869228692Sdes # -msg_* for osf cc 5870228692Sdes -msg_*) 5871228692Sdes func_quote_for_eval "$arg" 5872228692Sdes arg="$func_quote_for_eval_result" 5873228692Sdes ;; 5874228692Sdes 5875228692Sdes # Flags to be passed through unchanged, with rationale: 5876228692Sdes # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 5877228692Sdes # -r[0-9][0-9]* specify processor for the SGI compiler 5878228692Sdes # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 5879228692Sdes # +DA*, +DD* enable 64-bit mode for the HP compiler 5880228692Sdes # -q* compiler args for the IBM compiler 5881228692Sdes # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 5882228692Sdes # -F/path path to uninstalled frameworks, gcc on darwin 5883228692Sdes # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 5884228692Sdes # @file GCC response files 5885228692Sdes # -tp=* Portland pgcc target processor selection 5886228692Sdes # --sysroot=* for sysroot support 5887228692Sdes # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 5888228692Sdes -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 5889228692Sdes -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 5890228692Sdes -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 5891228692Sdes func_quote_for_eval "$arg" 5892228692Sdes arg="$func_quote_for_eval_result" 5893228692Sdes func_append compile_command " $arg" 5894228692Sdes func_append finalize_command " $arg" 5895228692Sdes func_append compiler_flags " $arg" 5896228692Sdes continue 5897228692Sdes ;; 5898228692Sdes 5899117610Sdes # Some other compiler flag. 5900117610Sdes -* | +*) 5901228692Sdes func_quote_for_eval "$arg" 5902228692Sdes arg="$func_quote_for_eval_result" 5903117610Sdes ;; 5904117610Sdes 5905141098Sdes *.$objext) 5906141098Sdes # A standard object. 5907228692Sdes func_append objs " $arg" 5908141098Sdes ;; 5909141098Sdes 5910141098Sdes *.lo) 5911141098Sdes # A libtool-controlled object. 5912141098Sdes 5913141098Sdes # Check to see that this really is a libtool object. 5914228692Sdes if func_lalib_unsafe_p "$arg"; then 5915141098Sdes pic_object= 5916141098Sdes non_pic_object= 5917141098Sdes 5918141098Sdes # Read the .lo file 5919228692Sdes func_source "$arg" 5920141098Sdes 5921228692Sdes if test -z "$pic_object" || 5922141098Sdes test -z "$non_pic_object" || 5923228692Sdes test "$pic_object" = none && 5924141098Sdes test "$non_pic_object" = none; then 5925228692Sdes func_fatal_error "cannot find name of object for \`$arg'" 5926117610Sdes fi 5927117610Sdes 5928141098Sdes # Extract subdirectory from the argument. 5929228692Sdes func_dirname "$arg" "/" "" 5930228692Sdes xdir="$func_dirname_result" 5931141098Sdes 5932141098Sdes if test "$pic_object" != none; then 5933141098Sdes # Prepend the subdirectory the object is found in. 5934141098Sdes pic_object="$xdir$pic_object" 5935141098Sdes 5936141098Sdes if test "$prev" = dlfiles; then 5937141098Sdes if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5938228692Sdes func_append dlfiles " $pic_object" 5939141098Sdes prev= 5940141098Sdes continue 5941141098Sdes else 5942141098Sdes # If libtool objects are unsupported, then we need to preload. 5943141098Sdes prev=dlprefiles 5944141098Sdes fi 5945141098Sdes fi 5946141098Sdes 5947141098Sdes # CHECK ME: I think I busted this. -Ossama 5948141098Sdes if test "$prev" = dlprefiles; then 5949141098Sdes # Preload the old-style object. 5950228692Sdes func_append dlprefiles " $pic_object" 5951141098Sdes prev= 5952141098Sdes fi 5953141098Sdes 5954141098Sdes # A PIC object. 5955228692Sdes func_append libobjs " $pic_object" 5956141098Sdes arg="$pic_object" 5957141098Sdes fi 5958141098Sdes 5959141098Sdes # Non-PIC object. 5960141098Sdes if test "$non_pic_object" != none; then 5961141098Sdes # Prepend the subdirectory the object is found in. 5962141098Sdes non_pic_object="$xdir$non_pic_object" 5963141098Sdes 5964141098Sdes # A standard non-PIC object 5965228692Sdes func_append non_pic_objects " $non_pic_object" 5966141098Sdes if test -z "$pic_object" || test "$pic_object" = none ; then 5967141098Sdes arg="$non_pic_object" 5968141098Sdes fi 5969174832Sdes else 5970174832Sdes # If the PIC object exists, use it instead. 5971174832Sdes # $xdir was prepended to $pic_object above. 5972174832Sdes non_pic_object="$pic_object" 5973228692Sdes func_append non_pic_objects " $non_pic_object" 5974141098Sdes fi 5975125647Sdes else 5976141098Sdes # Only an error if not doing a dry-run. 5977228692Sdes if $opt_dry_run; then 5978141098Sdes # Extract subdirectory from the argument. 5979228692Sdes func_dirname "$arg" "/" "" 5980228692Sdes xdir="$func_dirname_result" 5981141098Sdes 5982228692Sdes func_lo2o "$arg" 5983228692Sdes pic_object=$xdir$objdir/$func_lo2o_result 5984228692Sdes non_pic_object=$xdir$func_lo2o_result 5985228692Sdes func_append libobjs " $pic_object" 5986228692Sdes func_append non_pic_objects " $non_pic_object" 5987228692Sdes else 5988228692Sdes func_fatal_error "\`$arg' is not a valid libtool object" 5989141098Sdes fi 5990117610Sdes fi 5991117610Sdes ;; 5992117610Sdes 5993125647Sdes *.$libext) 5994125647Sdes # An archive. 5995228692Sdes func_append deplibs " $arg" 5996228692Sdes func_append old_deplibs " $arg" 5997125647Sdes continue 5998125647Sdes ;; 5999125647Sdes 6000117610Sdes *.la) 6001117610Sdes # A libtool-controlled library. 6002117610Sdes 6003228692Sdes func_resolve_sysroot "$arg" 6004125647Sdes if test "$prev" = dlfiles; then 6005125647Sdes # This library was specified with -dlopen. 6006228692Sdes func_append dlfiles " $func_resolve_sysroot_result" 6007125647Sdes prev= 6008125647Sdes elif test "$prev" = dlprefiles; then 6009125647Sdes # The library was specified with -dlpreopen. 6010228692Sdes func_append dlprefiles " $func_resolve_sysroot_result" 6011125647Sdes prev= 6012125647Sdes else 6013228692Sdes func_append deplibs " $func_resolve_sysroot_result" 6014125647Sdes fi 6015125647Sdes continue 6016125647Sdes ;; 6017117610Sdes 6018125647Sdes # Some other compiler argument. 6019125647Sdes *) 6020125647Sdes # Unknown arguments in both finalize_command and compile_command need 6021125647Sdes # to be aesthetically quoted because they are evaled later. 6022228692Sdes func_quote_for_eval "$arg" 6023228692Sdes arg="$func_quote_for_eval_result" 6024125647Sdes ;; 6025125647Sdes esac # arg 6026125647Sdes 6027125647Sdes # Now actually substitute the argument into the commands. 6028125647Sdes if test -n "$arg"; then 6029228692Sdes func_append compile_command " $arg" 6030228692Sdes func_append finalize_command " $arg" 6031125647Sdes fi 6032125647Sdes done # argument parsing loop 6033125647Sdes 6034228692Sdes test -n "$prev" && \ 6035228692Sdes func_fatal_help "the \`$prevarg' option requires an argument" 6036125647Sdes 6037125647Sdes if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 6038125647Sdes eval arg=\"$export_dynamic_flag_spec\" 6039228692Sdes func_append compile_command " $arg" 6040228692Sdes func_append finalize_command " $arg" 6041125647Sdes fi 6042125647Sdes 6043141098Sdes oldlibs= 6044125647Sdes # calculate the name of the file, without its directory 6045228692Sdes func_basename "$output" 6046228692Sdes outputname="$func_basename_result" 6047125647Sdes libobjs_save="$libobjs" 6048125647Sdes 6049125647Sdes if test -n "$shlibpath_var"; then 6050125647Sdes # get the directories listed in $shlibpath_var 6051228692Sdes eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 6052125647Sdes else 6053125647Sdes shlib_search_path= 6054125647Sdes fi 6055125647Sdes eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 6056125647Sdes eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 6057125647Sdes 6058228692Sdes func_dirname "$output" "/" "" 6059228692Sdes output_objdir="$func_dirname_result$objdir" 6060228692Sdes func_to_tool_file "$output_objdir/" 6061228692Sdes tool_output_objdir=$func_to_tool_file_result 6062125647Sdes # Create the object directory. 6063228692Sdes func_mkdir_p "$output_objdir" 6064125647Sdes 6065125647Sdes # Determine the type of output 6066125647Sdes case $output in 6067125647Sdes "") 6068228692Sdes func_fatal_help "you must specify an output file" 6069125647Sdes ;; 6070125647Sdes *.$libext) linkmode=oldlib ;; 6071125647Sdes *.lo | *.$objext) linkmode=obj ;; 6072125647Sdes *.la) linkmode=lib ;; 6073125647Sdes *) linkmode=prog ;; # Anything else should be a program. 6074125647Sdes esac 6075125647Sdes 6076125647Sdes specialdeplibs= 6077141098Sdes 6078125647Sdes libs= 6079125647Sdes # Find all interdependent deplibs by searching for libraries 6080125647Sdes # that are linked more than once (e.g. -la -lb -la) 6081125647Sdes for deplib in $deplibs; do 6082228692Sdes if $opt_preserve_dup_deps ; then 6083125647Sdes case "$libs " in 6084228692Sdes *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6085125647Sdes esac 6086125647Sdes fi 6087228692Sdes func_append libs " $deplib" 6088125647Sdes done 6089141098Sdes 6090141098Sdes if test "$linkmode" = lib; then 6091141098Sdes libs="$predeps $libs $compiler_lib_search_path $postdeps" 6092141098Sdes 6093141098Sdes # Compute libraries that are listed more than once in $predeps 6094141098Sdes # $postdeps and mark them as special (i.e., whose duplicates are 6095141098Sdes # not to be eliminated). 6096141098Sdes pre_post_deps= 6097228692Sdes if $opt_duplicate_compiler_generated_deps; then 6098141098Sdes for pre_post_dep in $predeps $postdeps; do 6099141098Sdes case "$pre_post_deps " in 6100228692Sdes *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 6101141098Sdes esac 6102228692Sdes func_append pre_post_deps " $pre_post_dep" 6103141098Sdes done 6104141098Sdes fi 6105141098Sdes pre_post_deps= 6106141098Sdes fi 6107141098Sdes 6108125647Sdes deplibs= 6109125647Sdes newdependency_libs= 6110125647Sdes newlib_search_path= 6111125647Sdes need_relink=no # whether we're linking any uninstalled libtool libraries 6112125647Sdes notinst_deplibs= # not-installed libtool libraries 6113228692Sdes notinst_path= # paths that contain not-installed libtool libraries 6114228692Sdes 6115125647Sdes case $linkmode in 6116125647Sdes lib) 6117228692Sdes passes="conv dlpreopen link" 6118125647Sdes for file in $dlfiles $dlprefiles; do 6119125647Sdes case $file in 6120125647Sdes *.la) ;; 6121125647Sdes *) 6122228692Sdes func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 6123125647Sdes ;; 6124125647Sdes esac 6125125647Sdes done 6126125647Sdes ;; 6127125647Sdes prog) 6128125647Sdes compile_deplibs= 6129125647Sdes finalize_deplibs= 6130125647Sdes alldeplibs=no 6131125647Sdes newdlfiles= 6132125647Sdes newdlprefiles= 6133125647Sdes passes="conv scan dlopen dlpreopen link" 6134125647Sdes ;; 6135125647Sdes *) passes="conv" 6136125647Sdes ;; 6137125647Sdes esac 6138228692Sdes 6139125647Sdes for pass in $passes; do 6140228692Sdes # The preopen pass in lib mode reverses $deplibs; put it back here 6141228692Sdes # so that -L comes before libs that need it for instance... 6142228692Sdes if test "$linkmode,$pass" = "lib,link"; then 6143228692Sdes ## FIXME: Find the place where the list is rebuilt in the wrong 6144228692Sdes ## order, and fix it there properly 6145228692Sdes tmp_deplibs= 6146228692Sdes for deplib in $deplibs; do 6147228692Sdes tmp_deplibs="$deplib $tmp_deplibs" 6148228692Sdes done 6149228692Sdes deplibs="$tmp_deplibs" 6150228692Sdes fi 6151228692Sdes 6152141098Sdes if test "$linkmode,$pass" = "lib,link" || 6153141098Sdes test "$linkmode,$pass" = "prog,scan"; then 6154141098Sdes libs="$deplibs" 6155141098Sdes deplibs= 6156141098Sdes fi 6157141098Sdes if test "$linkmode" = prog; then 6158125647Sdes case $pass in 6159141098Sdes dlopen) libs="$dlfiles" ;; 6160125647Sdes dlpreopen) libs="$dlprefiles" ;; 6161125647Sdes link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 6162125647Sdes esac 6163125647Sdes fi 6164228692Sdes if test "$linkmode,$pass" = "lib,dlpreopen"; then 6165228692Sdes # Collect and forward deplibs of preopened libtool libs 6166228692Sdes for lib in $dlprefiles; do 6167228692Sdes # Ignore non-libtool-libs 6168228692Sdes dependency_libs= 6169228692Sdes func_resolve_sysroot "$lib" 6170228692Sdes case $lib in 6171228692Sdes *.la) func_source "$func_resolve_sysroot_result" ;; 6172228692Sdes esac 6173228692Sdes 6174228692Sdes # Collect preopened libtool deplibs, except any this library 6175228692Sdes # has declared as weak libs 6176228692Sdes for deplib in $dependency_libs; do 6177228692Sdes func_basename "$deplib" 6178228692Sdes deplib_base=$func_basename_result 6179228692Sdes case " $weak_libs " in 6180228692Sdes *" $deplib_base "*) ;; 6181228692Sdes *) func_append deplibs " $deplib" ;; 6182228692Sdes esac 6183228692Sdes done 6184228692Sdes done 6185228692Sdes libs="$dlprefiles" 6186228692Sdes fi 6187141098Sdes if test "$pass" = dlopen; then 6188141098Sdes # Collect dlpreopened libraries 6189141098Sdes save_deplibs="$deplibs" 6190141098Sdes deplibs= 6191141098Sdes fi 6192228692Sdes 6193125647Sdes for deplib in $libs; do 6194125647Sdes lib= 6195125647Sdes found=no 6196125647Sdes case $deplib in 6197236109Sdes -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 6198236109Sdes |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 6199141098Sdes if test "$linkmode,$pass" = "prog,link"; then 6200141098Sdes compile_deplibs="$deplib $compile_deplibs" 6201141098Sdes finalize_deplibs="$deplib $finalize_deplibs" 6202141098Sdes else 6203228692Sdes func_append compiler_flags " $deplib" 6204141098Sdes fi 6205174832Sdes 6206174832Sdes case $linkmode in 6207174832Sdes lib) 6208174832Sdes deplibs="$deplib $deplibs" 6209174832Sdes test "$pass" = conv && continue 6210174832Sdes newdependency_libs="$deplib $newdependency_libs" 6211174832Sdes ;; 6212174832Sdes prog) 6213174832Sdes if test "$pass" = conv; then 6214174832Sdes deplibs="$deplib $deplibs" 6215174832Sdes continue 6216174832Sdes fi 6217174832Sdes if test "$pass" = scan; then 6218174832Sdes deplibs="$deplib $deplibs" 6219174832Sdes else 6220174832Sdes compile_deplibs="$deplib $compile_deplibs" 6221174832Sdes finalize_deplibs="$deplib $finalize_deplibs" 6222174832Sdes fi 6223174832Sdes ;; 6224174832Sdes *) 6225174832Sdes ;; 6226174832Sdes esac # linkmode 6227174832Sdes 6228141098Sdes continue 6229141098Sdes ;; 6230125647Sdes -l*) 6231141098Sdes if test "$linkmode" != lib && test "$linkmode" != prog; then 6232228692Sdes func_warning "\`-l' is ignored for archives/objects" 6233125647Sdes continue 6234125647Sdes fi 6235228692Sdes func_stripname '-l' '' "$deplib" 6236228692Sdes name=$func_stripname_result 6237228692Sdes if test "$linkmode" = lib; then 6238228692Sdes searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 6239228692Sdes else 6240228692Sdes searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 6241228692Sdes fi 6242228692Sdes for searchdir in $searchdirs; do 6243141098Sdes for search_ext in .la $std_shrext .so .a; do 6244141098Sdes # Search the libtool library 6245141098Sdes lib="$searchdir/lib${name}${search_ext}" 6246141098Sdes if test -f "$lib"; then 6247141098Sdes if test "$search_ext" = ".la"; then 6248141098Sdes found=yes 6249141098Sdes else 6250141098Sdes found=no 6251141098Sdes fi 6252141098Sdes break 2 6253141098Sdes fi 6254141098Sdes done 6255125647Sdes done 6256125647Sdes if test "$found" != yes; then 6257125647Sdes # deplib doesn't seem to be a libtool library 6258125647Sdes if test "$linkmode,$pass" = "prog,link"; then 6259125647Sdes compile_deplibs="$deplib $compile_deplibs" 6260125647Sdes finalize_deplibs="$deplib $finalize_deplibs" 6261125647Sdes else 6262125647Sdes deplibs="$deplib $deplibs" 6263141098Sdes test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6264125647Sdes fi 6265125647Sdes continue 6266141098Sdes else # deplib is a libtool library 6267141098Sdes # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 6268141098Sdes # We need to do some special things here, and not later. 6269141098Sdes if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6270141098Sdes case " $predeps $postdeps " in 6271141098Sdes *" $deplib "*) 6272228692Sdes if func_lalib_p "$lib"; then 6273141098Sdes library_names= 6274141098Sdes old_library= 6275228692Sdes func_source "$lib" 6276141098Sdes for l in $old_library $library_names; do 6277141098Sdes ll="$l" 6278141098Sdes done 6279141098Sdes if test "X$ll" = "X$old_library" ; then # only static version available 6280141098Sdes found=no 6281228692Sdes func_dirname "$lib" "" "." 6282228692Sdes ladir="$func_dirname_result" 6283141098Sdes lib=$ladir/$old_library 6284141098Sdes if test "$linkmode,$pass" = "prog,link"; then 6285141098Sdes compile_deplibs="$deplib $compile_deplibs" 6286141098Sdes finalize_deplibs="$deplib $finalize_deplibs" 6287141098Sdes else 6288141098Sdes deplibs="$deplib $deplibs" 6289141098Sdes test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6290141098Sdes fi 6291141098Sdes continue 6292141098Sdes fi 6293141098Sdes fi 6294228692Sdes ;; 6295141098Sdes *) ;; 6296141098Sdes esac 6297141098Sdes fi 6298125647Sdes fi 6299125647Sdes ;; # -l 6300228692Sdes *.ltframework) 6301228692Sdes if test "$linkmode,$pass" = "prog,link"; then 6302228692Sdes compile_deplibs="$deplib $compile_deplibs" 6303228692Sdes finalize_deplibs="$deplib $finalize_deplibs" 6304228692Sdes else 6305228692Sdes deplibs="$deplib $deplibs" 6306228692Sdes if test "$linkmode" = lib ; then 6307228692Sdes case "$new_inherited_linker_flags " in 6308228692Sdes *" $deplib "*) ;; 6309228692Sdes * ) func_append new_inherited_linker_flags " $deplib" ;; 6310228692Sdes esac 6311228692Sdes fi 6312228692Sdes fi 6313228692Sdes continue 6314228692Sdes ;; 6315125647Sdes -L*) 6316125647Sdes case $linkmode in 6317125647Sdes lib) 6318125647Sdes deplibs="$deplib $deplibs" 6319141098Sdes test "$pass" = conv && continue 6320125647Sdes newdependency_libs="$deplib $newdependency_libs" 6321228692Sdes func_stripname '-L' '' "$deplib" 6322228692Sdes func_resolve_sysroot "$func_stripname_result" 6323228692Sdes func_append newlib_search_path " $func_resolve_sysroot_result" 6324125647Sdes ;; 6325125647Sdes prog) 6326141098Sdes if test "$pass" = conv; then 6327125647Sdes deplibs="$deplib $deplibs" 6328125647Sdes continue 6329125647Sdes fi 6330141098Sdes if test "$pass" = scan; then 6331125647Sdes deplibs="$deplib $deplibs" 6332125647Sdes else 6333125647Sdes compile_deplibs="$deplib $compile_deplibs" 6334125647Sdes finalize_deplibs="$deplib $finalize_deplibs" 6335125647Sdes fi 6336228692Sdes func_stripname '-L' '' "$deplib" 6337228692Sdes func_resolve_sysroot "$func_stripname_result" 6338228692Sdes func_append newlib_search_path " $func_resolve_sysroot_result" 6339125647Sdes ;; 6340125647Sdes *) 6341228692Sdes func_warning "\`-L' is ignored for archives/objects" 6342125647Sdes ;; 6343125647Sdes esac # linkmode 6344125647Sdes continue 6345125647Sdes ;; # -L 6346125647Sdes -R*) 6347141098Sdes if test "$pass" = link; then 6348228692Sdes func_stripname '-R' '' "$deplib" 6349228692Sdes func_resolve_sysroot "$func_stripname_result" 6350228692Sdes dir=$func_resolve_sysroot_result 6351125647Sdes # Make sure the xrpath contains only unique directories. 6352125647Sdes case "$xrpath " in 6353125647Sdes *" $dir "*) ;; 6354228692Sdes *) func_append xrpath " $dir" ;; 6355125647Sdes esac 6356125647Sdes fi 6357125647Sdes deplibs="$deplib $deplibs" 6358125647Sdes continue 6359125647Sdes ;; 6360228692Sdes *.la) 6361228692Sdes func_resolve_sysroot "$deplib" 6362228692Sdes lib=$func_resolve_sysroot_result 6363228692Sdes ;; 6364125647Sdes *.$libext) 6365141098Sdes if test "$pass" = conv; then 6366125647Sdes deplibs="$deplib $deplibs" 6367125647Sdes continue 6368125647Sdes fi 6369125647Sdes case $linkmode in 6370125647Sdes lib) 6371228692Sdes # Linking convenience modules into shared libraries is allowed, 6372228692Sdes # but linking other static libraries is non-portable. 6373228692Sdes case " $dlpreconveniencelibs " in 6374228692Sdes *" $deplib "*) ;; 6375228692Sdes *) 6376228692Sdes valid_a_lib=no 6377228692Sdes case $deplibs_check_method in 6378228692Sdes match_pattern*) 6379228692Sdes set dummy $deplibs_check_method; shift 6380228692Sdes match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 6381228692Sdes if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 6382141098Sdes | $EGREP "$match_pattern_regex" > /dev/null; then 6383228692Sdes valid_a_lib=yes 6384228692Sdes fi 6385228692Sdes ;; 6386228692Sdes pass_all) 6387141098Sdes valid_a_lib=yes 6388141098Sdes ;; 6389228692Sdes esac 6390228692Sdes if test "$valid_a_lib" != yes; then 6391228692Sdes echo 6392228692Sdes $ECHO "*** Warning: Trying to link with static lib archive $deplib." 6393228692Sdes echo "*** I have the capability to make that library automatically link in when" 6394228692Sdes echo "*** you link to this library. But I can only do this if you have a" 6395228692Sdes echo "*** shared version of the library, which you do not appear to have" 6396228692Sdes echo "*** because the file extensions .$libext of this argument makes me believe" 6397228692Sdes echo "*** that it is just a static archive that I should not use here." 6398228692Sdes else 6399228692Sdes echo 6400228692Sdes $ECHO "*** Warning: Linking the shared library $output against the" 6401228692Sdes $ECHO "*** static library $deplib is not portable!" 6402228692Sdes deplibs="$deplib $deplibs" 6403228692Sdes fi 6404228692Sdes ;; 6405228692Sdes esac 6406125647Sdes continue 6407125647Sdes ;; 6408125647Sdes prog) 6409141098Sdes if test "$pass" != link; then 6410125647Sdes deplibs="$deplib $deplibs" 6411125647Sdes else 6412125647Sdes compile_deplibs="$deplib $compile_deplibs" 6413125647Sdes finalize_deplibs="$deplib $finalize_deplibs" 6414125647Sdes fi 6415125647Sdes continue 6416125647Sdes ;; 6417125647Sdes esac # linkmode 6418125647Sdes ;; # *.$libext 6419125647Sdes *.lo | *.$objext) 6420141098Sdes if test "$pass" = conv; then 6421141098Sdes deplibs="$deplib $deplibs" 6422141098Sdes elif test "$linkmode" = prog; then 6423141098Sdes if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 6424141098Sdes # If there is no dlopen support or we're linking statically, 6425141098Sdes # we need to preload. 6426228692Sdes func_append newdlprefiles " $deplib" 6427141098Sdes compile_deplibs="$deplib $compile_deplibs" 6428141098Sdes finalize_deplibs="$deplib $finalize_deplibs" 6429141098Sdes else 6430228692Sdes func_append newdlfiles " $deplib" 6431141098Sdes fi 6432125647Sdes fi 6433125647Sdes continue 6434125647Sdes ;; 6435125647Sdes %DEPLIBS%) 6436125647Sdes alldeplibs=yes 6437125647Sdes continue 6438125647Sdes ;; 6439125647Sdes esac # case $deplib 6440228692Sdes 6441141098Sdes if test "$found" = yes || test -f "$lib"; then : 6442125647Sdes else 6443228692Sdes func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 6444125647Sdes fi 6445125647Sdes 6446117610Sdes # Check to see that this really is a libtool archive. 6447228692Sdes func_lalib_unsafe_p "$lib" \ 6448228692Sdes || func_fatal_error "\`$lib' is not a valid libtool archive" 6449117610Sdes 6450228692Sdes func_dirname "$lib" "" "." 6451228692Sdes ladir="$func_dirname_result" 6452125647Sdes 6453125647Sdes dlname= 6454125647Sdes dlopen= 6455125647Sdes dlpreopen= 6456125647Sdes libdir= 6457125647Sdes library_names= 6458125647Sdes old_library= 6459228692Sdes inherited_linker_flags= 6460117610Sdes # If the library was installed with an old release of libtool, 6461141098Sdes # it will not redefine variables installed, or shouldnotlink 6462117610Sdes installed=yes 6463141098Sdes shouldnotlink=no 6464147455Sdes avoidtemprpath= 6465117610Sdes 6466147455Sdes 6467117610Sdes # Read the .la file 6468228692Sdes func_source "$lib" 6469117610Sdes 6470228692Sdes # Convert "-framework foo" to "foo.ltframework" 6471228692Sdes if test -n "$inherited_linker_flags"; then 6472228692Sdes tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 6473228692Sdes for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 6474228692Sdes case " $new_inherited_linker_flags " in 6475228692Sdes *" $tmp_inherited_linker_flag "*) ;; 6476228692Sdes *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 6477228692Sdes esac 6478228692Sdes done 6479228692Sdes fi 6480228692Sdes dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 6481125647Sdes if test "$linkmode,$pass" = "lib,link" || 6482125647Sdes test "$linkmode,$pass" = "prog,scan" || 6483141098Sdes { test "$linkmode" != prog && test "$linkmode" != lib; }; then 6484228692Sdes test -n "$dlopen" && func_append dlfiles " $dlopen" 6485228692Sdes test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 6486125647Sdes fi 6487125647Sdes 6488141098Sdes if test "$pass" = conv; then 6489125647Sdes # Only check for convenience libraries 6490125647Sdes deplibs="$lib $deplibs" 6491125647Sdes if test -z "$libdir"; then 6492125647Sdes if test -z "$old_library"; then 6493228692Sdes func_fatal_error "cannot find name of link library for \`$lib'" 6494125647Sdes fi 6495125647Sdes # It is a libtool convenience library, so add in its objects. 6496228692Sdes func_append convenience " $ladir/$objdir/$old_library" 6497228692Sdes func_append old_convenience " $ladir/$objdir/$old_library" 6498141098Sdes elif test "$linkmode" != prog && test "$linkmode" != lib; then 6499228692Sdes func_fatal_error "\`$lib' is not a convenience library" 6500125647Sdes fi 6501228692Sdes tmp_libs= 6502228692Sdes for deplib in $dependency_libs; do 6503228692Sdes deplibs="$deplib $deplibs" 6504228692Sdes if $opt_preserve_dup_deps ; then 6505228692Sdes case "$tmp_libs " in 6506228692Sdes *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6507228692Sdes esac 6508228692Sdes fi 6509228692Sdes func_append tmp_libs " $deplib" 6510228692Sdes done 6511125647Sdes continue 6512125647Sdes fi # $pass = conv 6513125647Sdes 6514141098Sdes 6515117610Sdes # Get the name of the library we link against. 6516117610Sdes linklib= 6517228692Sdes if test -n "$old_library" && 6518228692Sdes { test "$prefer_static_libs" = yes || 6519228692Sdes test "$prefer_static_libs,$installed" = "built,no"; }; then 6520228692Sdes linklib=$old_library 6521228692Sdes else 6522228692Sdes for l in $old_library $library_names; do 6523228692Sdes linklib="$l" 6524228692Sdes done 6525228692Sdes fi 6526117610Sdes if test -z "$linklib"; then 6527228692Sdes func_fatal_error "cannot find name of link library for \`$lib'" 6528117610Sdes fi 6529117610Sdes 6530125647Sdes # This library was specified with -dlopen. 6531141098Sdes if test "$pass" = dlopen; then 6532125647Sdes if test -z "$libdir"; then 6533228692Sdes func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 6534125647Sdes fi 6535141098Sdes if test -z "$dlname" || 6536141098Sdes test "$dlopen_support" != yes || 6537141098Sdes test "$build_libtool_libs" = no; then 6538125647Sdes # If there is no dlname, no dlopen support or we're linking 6539141098Sdes # statically, we need to preload. We also need to preload any 6540141098Sdes # dependent libraries so libltdl's deplib preloader doesn't 6541141098Sdes # bomb out in the load deplibs phase. 6542228692Sdes func_append dlprefiles " $lib $dependency_libs" 6543117610Sdes else 6544228692Sdes func_append newdlfiles " $lib" 6545117610Sdes fi 6546125647Sdes continue 6547125647Sdes fi # $pass = dlopen 6548117610Sdes 6549125647Sdes # We need an absolute path. 6550125647Sdes case $ladir in 6551125647Sdes [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 6552125647Sdes *) 6553125647Sdes abs_ladir=`cd "$ladir" && pwd` 6554125647Sdes if test -z "$abs_ladir"; then 6555228692Sdes func_warning "cannot determine absolute directory name of \`$ladir'" 6556228692Sdes func_warning "passing it literally to the linker, although it might fail" 6557125647Sdes abs_ladir="$ladir" 6558125647Sdes fi 6559125647Sdes ;; 6560125647Sdes esac 6561228692Sdes func_basename "$lib" 6562228692Sdes laname="$func_basename_result" 6563117610Sdes 6564125647Sdes # Find the relevant object directory and library name. 6565125647Sdes if test "X$installed" = Xyes; then 6566228692Sdes if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6567228692Sdes func_warning "library \`$lib' was moved." 6568125647Sdes dir="$ladir" 6569125647Sdes absdir="$abs_ladir" 6570125647Sdes libdir="$abs_ladir" 6571117610Sdes else 6572228692Sdes dir="$lt_sysroot$libdir" 6573228692Sdes absdir="$lt_sysroot$libdir" 6574117610Sdes fi 6575147455Sdes test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 6576125647Sdes else 6577141098Sdes if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6578141098Sdes dir="$ladir" 6579141098Sdes absdir="$abs_ladir" 6580141098Sdes # Remove this search path later 6581228692Sdes func_append notinst_path " $abs_ladir" 6582141098Sdes else 6583141098Sdes dir="$ladir/$objdir" 6584141098Sdes absdir="$abs_ladir/$objdir" 6585141098Sdes # Remove this search path later 6586228692Sdes func_append notinst_path " $abs_ladir" 6587141098Sdes fi 6588125647Sdes fi # $installed = yes 6589228692Sdes func_stripname 'lib' '.la' "$laname" 6590228692Sdes name=$func_stripname_result 6591117610Sdes 6592125647Sdes # This library was specified with -dlpreopen. 6593141098Sdes if test "$pass" = dlpreopen; then 6594228692Sdes if test -z "$libdir" && test "$linkmode" = prog; then 6595228692Sdes func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 6596125647Sdes fi 6597228692Sdes case "$host" in 6598228692Sdes # special handling for platforms with PE-DLLs. 6599228692Sdes *cygwin* | *mingw* | *cegcc* ) 6600228692Sdes # Linker will automatically link against shared library if both 6601228692Sdes # static and shared are present. Therefore, ensure we extract 6602228692Sdes # symbols from the import library if a shared library is present 6603228692Sdes # (otherwise, the dlopen module name will be incorrect). We do 6604228692Sdes # this by putting the import library name into $newdlprefiles. 6605228692Sdes # We recover the dlopen module name by 'saving' the la file 6606228692Sdes # name in a special purpose variable, and (later) extracting the 6607228692Sdes # dlname from the la file. 6608228692Sdes if test -n "$dlname"; then 6609228692Sdes func_tr_sh "$dir/$linklib" 6610228692Sdes eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 6611228692Sdes func_append newdlprefiles " $dir/$linklib" 6612228692Sdes else 6613228692Sdes func_append newdlprefiles " $dir/$old_library" 6614228692Sdes # Keep a list of preopened convenience libraries to check 6615228692Sdes # that they are being used correctly in the link pass. 6616228692Sdes test -z "$libdir" && \ 6617228692Sdes func_append dlpreconveniencelibs " $dir/$old_library" 6618228692Sdes fi 6619228692Sdes ;; 6620228692Sdes * ) 6621228692Sdes # Prefer using a static library (so that no silly _DYNAMIC symbols 6622228692Sdes # are required to link). 6623228692Sdes if test -n "$old_library"; then 6624228692Sdes func_append newdlprefiles " $dir/$old_library" 6625228692Sdes # Keep a list of preopened convenience libraries to check 6626228692Sdes # that they are being used correctly in the link pass. 6627228692Sdes test -z "$libdir" && \ 6628228692Sdes func_append dlpreconveniencelibs " $dir/$old_library" 6629228692Sdes # Otherwise, use the dlname, so that lt_dlopen finds it. 6630228692Sdes elif test -n "$dlname"; then 6631228692Sdes func_append newdlprefiles " $dir/$dlname" 6632228692Sdes else 6633228692Sdes func_append newdlprefiles " $dir/$linklib" 6634228692Sdes fi 6635228692Sdes ;; 6636228692Sdes esac 6637125647Sdes fi # $pass = dlpreopen 6638125647Sdes 6639125647Sdes if test -z "$libdir"; then 6640125647Sdes # Link the convenience library 6641141098Sdes if test "$linkmode" = lib; then 6642125647Sdes deplibs="$dir/$old_library $deplibs" 6643125647Sdes elif test "$linkmode,$pass" = "prog,link"; then 6644125647Sdes compile_deplibs="$dir/$old_library $compile_deplibs" 6645125647Sdes finalize_deplibs="$dir/$old_library $finalize_deplibs" 6646125647Sdes else 6647141098Sdes deplibs="$lib $deplibs" # used for prog,scan pass 6648125647Sdes fi 6649125647Sdes continue 6650117610Sdes fi 6651117610Sdes 6652141098Sdes 6653141098Sdes if test "$linkmode" = prog && test "$pass" != link; then 6654228692Sdes func_append newlib_search_path " $ladir" 6655125647Sdes deplibs="$lib $deplibs" 6656125647Sdes 6657125647Sdes linkalldeplibs=no 6658125647Sdes if test "$link_all_deplibs" != no || test -z "$library_names" || 6659125647Sdes test "$build_libtool_libs" = no; then 6660125647Sdes linkalldeplibs=yes 6661125647Sdes fi 6662125647Sdes 6663125647Sdes tmp_libs= 6664125647Sdes for deplib in $dependency_libs; do 6665125647Sdes case $deplib in 6666228692Sdes -L*) func_stripname '-L' '' "$deplib" 6667228692Sdes func_resolve_sysroot "$func_stripname_result" 6668228692Sdes func_append newlib_search_path " $func_resolve_sysroot_result" 6669228692Sdes ;; 6670125647Sdes esac 6671125647Sdes # Need to link against all dependency_libs? 6672141098Sdes if test "$linkalldeplibs" = yes; then 6673125647Sdes deplibs="$deplib $deplibs" 6674125647Sdes else 6675125647Sdes # Need to hardcode shared library paths 6676125647Sdes # or/and link against static libraries 6677125647Sdes newdependency_libs="$deplib $newdependency_libs" 6678125647Sdes fi 6679228692Sdes if $opt_preserve_dup_deps ; then 6680125647Sdes case "$tmp_libs " in 6681228692Sdes *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6682125647Sdes esac 6683125647Sdes fi 6684228692Sdes func_append tmp_libs " $deplib" 6685125647Sdes done # for deplib 6686125647Sdes continue 6687125647Sdes fi # $linkmode = prog... 6688125647Sdes 6689141098Sdes if test "$linkmode,$pass" = "prog,link"; then 6690141098Sdes if test -n "$library_names" && 6691174832Sdes { { test "$prefer_static_libs" = no || 6692228692Sdes test "$prefer_static_libs,$installed" = "built,yes"; } || 6693174832Sdes test -z "$old_library"; }; then 6694141098Sdes # We need to hardcode the library path 6695147455Sdes if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 6696141098Sdes # Make sure the rpath contains only unique directories. 6697228692Sdes case "$temp_rpath:" in 6698228692Sdes *"$absdir:"*) ;; 6699228692Sdes *) func_append temp_rpath "$absdir:" ;; 6700141098Sdes esac 6701141098Sdes fi 6702117610Sdes 6703125647Sdes # Hardcode the library path. 6704125647Sdes # Skip directories that are in the system default run-time 6705125647Sdes # search path. 6706125647Sdes case " $sys_lib_dlsearch_path " in 6707117610Sdes *" $absdir "*) ;; 6708125647Sdes *) 6709125647Sdes case "$compile_rpath " in 6710125647Sdes *" $absdir "*) ;; 6711228692Sdes *) func_append compile_rpath " $absdir" ;; 6712125647Sdes esac 6713125647Sdes ;; 6714117610Sdes esac 6715125647Sdes case " $sys_lib_dlsearch_path " in 6716117610Sdes *" $libdir "*) ;; 6717125647Sdes *) 6718125647Sdes case "$finalize_rpath " in 6719125647Sdes *" $libdir "*) ;; 6720228692Sdes *) func_append finalize_rpath " $libdir" ;; 6721125647Sdes esac 6722125647Sdes ;; 6723117610Sdes esac 6724125647Sdes fi # $linkmode,$pass = prog,link... 6725117610Sdes 6726125647Sdes if test "$alldeplibs" = yes && 6727125647Sdes { test "$deplibs_check_method" = pass_all || 6728125647Sdes { test "$build_libtool_libs" = yes && 6729125647Sdes test -n "$library_names"; }; }; then 6730125647Sdes # We only need to search for static libraries 6731125647Sdes continue 6732125647Sdes fi 6733141098Sdes fi 6734125647Sdes 6735141098Sdes link_static=no # Whether the deplib will be linked statically 6736174832Sdes use_static_libs=$prefer_static_libs 6737228692Sdes if test "$use_static_libs" = built && test "$installed" = yes; then 6738174832Sdes use_static_libs=no 6739174832Sdes fi 6740141098Sdes if test -n "$library_names" && 6741174832Sdes { test "$use_static_libs" = no || test -z "$old_library"; }; then 6742228692Sdes case $host in 6743228692Sdes *cygwin* | *mingw* | *cegcc*) 6744228692Sdes # No point in relinking DLLs because paths are not encoded 6745228692Sdes func_append notinst_deplibs " $lib" 6746228692Sdes need_relink=no 6747228692Sdes ;; 6748228692Sdes *) 6749228692Sdes if test "$installed" = no; then 6750228692Sdes func_append notinst_deplibs " $lib" 6751228692Sdes need_relink=yes 6752228692Sdes fi 6753228692Sdes ;; 6754228692Sdes esac 6755141098Sdes # This is a shared library 6756125647Sdes 6757228692Sdes # Warn about portability, can't link against -module's on some 6758228692Sdes # systems (darwin). Don't bleat about dlopened modules though! 6759228692Sdes dlopenmodule="" 6760228692Sdes for dlpremoduletest in $dlprefiles; do 6761228692Sdes if test "X$dlpremoduletest" = "X$lib"; then 6762228692Sdes dlopenmodule="$dlpremoduletest" 6763228692Sdes break 6764228692Sdes fi 6765228692Sdes done 6766228692Sdes if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 6767228692Sdes echo 6768141098Sdes if test "$linkmode" = prog; then 6769228692Sdes $ECHO "*** Warning: Linking the executable $output against the loadable module" 6770141098Sdes else 6771228692Sdes $ECHO "*** Warning: Linking the shared library $output against the loadable module" 6772141098Sdes fi 6773228692Sdes $ECHO "*** $linklib is not portable!" 6774141098Sdes fi 6775141098Sdes if test "$linkmode" = lib && 6776141098Sdes test "$hardcode_into_libs" = yes; then 6777141098Sdes # Hardcode the library path. 6778141098Sdes # Skip directories that are in the system default run-time 6779141098Sdes # search path. 6780141098Sdes case " $sys_lib_dlsearch_path " in 6781141098Sdes *" $absdir "*) ;; 6782141098Sdes *) 6783141098Sdes case "$compile_rpath " in 6784141098Sdes *" $absdir "*) ;; 6785228692Sdes *) func_append compile_rpath " $absdir" ;; 6786141098Sdes esac 6787141098Sdes ;; 6788141098Sdes esac 6789141098Sdes case " $sys_lib_dlsearch_path " in 6790141098Sdes *" $libdir "*) ;; 6791141098Sdes *) 6792141098Sdes case "$finalize_rpath " in 6793141098Sdes *" $libdir "*) ;; 6794228692Sdes *) func_append finalize_rpath " $libdir" ;; 6795141098Sdes esac 6796141098Sdes ;; 6797141098Sdes esac 6798141098Sdes fi 6799141098Sdes 6800125647Sdes if test -n "$old_archive_from_expsyms_cmds"; then 6801125647Sdes # figure out the soname 6802125647Sdes set dummy $library_names 6803228692Sdes shift 6804228692Sdes realname="$1" 6805228692Sdes shift 6806228692Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 6807125647Sdes # use dlname if we got it. it's perfectly good, no? 6808125647Sdes if test -n "$dlname"; then 6809125647Sdes soname="$dlname" 6810125647Sdes elif test -n "$soname_spec"; then 6811125647Sdes # bleh windows 6812125647Sdes case $host in 6813228692Sdes *cygwin* | mingw* | *cegcc*) 6814228692Sdes func_arith $current - $age 6815228692Sdes major=$func_arith_result 6816125647Sdes versuffix="-$major" 6817117610Sdes ;; 6818117610Sdes esac 6819125647Sdes eval soname=\"$soname_spec\" 6820125647Sdes else 6821125647Sdes soname="$realname" 6822125647Sdes fi 6823125647Sdes 6824125647Sdes # Make a new name for the extract_expsyms_cmds to use 6825125647Sdes soroot="$soname" 6826228692Sdes func_basename "$soroot" 6827228692Sdes soname="$func_basename_result" 6828228692Sdes func_stripname 'lib' '.dll' "$soname" 6829228692Sdes newlib=libimp-$func_stripname_result.a 6830125647Sdes 6831125647Sdes # If the library has no export list, then create one now 6832125647Sdes if test -f "$output_objdir/$soname-def"; then : 6833125647Sdes else 6834228692Sdes func_verbose "extracting exported symbol list from \`$soname'" 6835228692Sdes func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 6836125647Sdes fi 6837125647Sdes 6838125647Sdes # Create $newlib 6839125647Sdes if test -f "$output_objdir/$newlib"; then :; else 6840228692Sdes func_verbose "generating import library for \`$soname'" 6841228692Sdes func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 6842125647Sdes fi 6843125647Sdes # make sure the library variables are pointing to the new library 6844125647Sdes dir=$output_objdir 6845125647Sdes linklib=$newlib 6846141098Sdes fi # test -n "$old_archive_from_expsyms_cmds" 6847125647Sdes 6848228692Sdes if test "$linkmode" = prog || test "$opt_mode" != relink; then 6849125647Sdes add_shlibpath= 6850125647Sdes add_dir= 6851125647Sdes add= 6852125647Sdes lib_linked=yes 6853125647Sdes case $hardcode_action in 6854125647Sdes immediate | unsupported) 6855125647Sdes if test "$hardcode_direct" = no; then 6856125647Sdes add="$dir/$linklib" 6857141098Sdes case $host in 6858174832Sdes *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6859174832Sdes *-*-sysv4*uw2*) add_dir="-L$dir" ;; 6860174832Sdes *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6861174832Sdes *-*-unixware7*) add_dir="-L$dir" ;; 6862141098Sdes *-*-darwin* ) 6863228692Sdes # if the lib is a (non-dlopened) module then we can not 6864228692Sdes # link against it, someone is ignoring the earlier warnings 6865174832Sdes if /usr/bin/file -L $add 2> /dev/null | 6866228692Sdes $GREP ": [^:]* bundle" >/dev/null ; then 6867228692Sdes if test "X$dlopenmodule" != "X$lib"; then 6868228692Sdes $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6869228692Sdes if test -z "$old_library" ; then 6870228692Sdes echo 6871228692Sdes echo "*** And there doesn't seem to be a static archive available" 6872228692Sdes echo "*** The link will probably fail, sorry" 6873228692Sdes else 6874228692Sdes add="$dir/$old_library" 6875228692Sdes fi 6876228692Sdes elif test -n "$old_library"; then 6877228692Sdes add="$dir/$old_library" 6878141098Sdes fi 6879141098Sdes fi 6880141098Sdes esac 6881125647Sdes elif test "$hardcode_minus_L" = no; then 6882125647Sdes case $host in 6883125647Sdes *-*-sunos*) add_shlibpath="$dir" ;; 6884125647Sdes esac 6885125647Sdes add_dir="-L$dir" 6886125647Sdes add="-l$name" 6887125647Sdes elif test "$hardcode_shlibpath_var" = no; then 6888125647Sdes add_shlibpath="$dir" 6889125647Sdes add="-l$name" 6890125647Sdes else 6891125647Sdes lib_linked=no 6892125647Sdes fi 6893125647Sdes ;; 6894125647Sdes relink) 6895228692Sdes if test "$hardcode_direct" = yes && 6896228692Sdes test "$hardcode_direct_absolute" = no; then 6897125647Sdes add="$dir/$linklib" 6898125647Sdes elif test "$hardcode_minus_L" = yes; then 6899236109Sdes add_dir="-L$absdir" 6900141098Sdes # Try looking first in the location we're being installed to. 6901141098Sdes if test -n "$inst_prefix_dir"; then 6902174832Sdes case $libdir in 6903141098Sdes [\\/]*) 6904228692Sdes func_append add_dir " -L$inst_prefix_dir$libdir" 6905141098Sdes ;; 6906141098Sdes esac 6907141098Sdes fi 6908125647Sdes add="-l$name" 6909125647Sdes elif test "$hardcode_shlibpath_var" = yes; then 6910125647Sdes add_shlibpath="$dir" 6911125647Sdes add="-l$name" 6912125647Sdes else 6913125647Sdes lib_linked=no 6914125647Sdes fi 6915125647Sdes ;; 6916125647Sdes *) lib_linked=no ;; 6917125647Sdes esac 6918125647Sdes 6919125647Sdes if test "$lib_linked" != yes; then 6920228692Sdes func_fatal_configuration "unsupported hardcode properties" 6921125647Sdes fi 6922125647Sdes 6923125647Sdes if test -n "$add_shlibpath"; then 6924125647Sdes case :$compile_shlibpath: in 6925125647Sdes *":$add_shlibpath:"*) ;; 6926228692Sdes *) func_append compile_shlibpath "$add_shlibpath:" ;; 6927117610Sdes esac 6928125647Sdes fi 6929141098Sdes if test "$linkmode" = prog; then 6930125647Sdes test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 6931125647Sdes test -n "$add" && compile_deplibs="$add $compile_deplibs" 6932117610Sdes else 6933125647Sdes test -n "$add_dir" && deplibs="$add_dir $deplibs" 6934125647Sdes test -n "$add" && deplibs="$add $deplibs" 6935228692Sdes if test "$hardcode_direct" != yes && 6936228692Sdes test "$hardcode_minus_L" != yes && 6937125647Sdes test "$hardcode_shlibpath_var" = yes; then 6938125647Sdes case :$finalize_shlibpath: in 6939125647Sdes *":$libdir:"*) ;; 6940228692Sdes *) func_append finalize_shlibpath "$libdir:" ;; 6941125647Sdes esac 6942125647Sdes fi 6943117610Sdes fi 6944125647Sdes fi 6945117610Sdes 6946228692Sdes if test "$linkmode" = prog || test "$opt_mode" = relink; then 6947125647Sdes add_shlibpath= 6948125647Sdes add_dir= 6949125647Sdes add= 6950125647Sdes # Finalize command for both is simple: just hardcode it. 6951228692Sdes if test "$hardcode_direct" = yes && 6952228692Sdes test "$hardcode_direct_absolute" = no; then 6953125647Sdes add="$libdir/$linklib" 6954117610Sdes elif test "$hardcode_minus_L" = yes; then 6955125647Sdes add_dir="-L$libdir" 6956125647Sdes add="-l$name" 6957117610Sdes elif test "$hardcode_shlibpath_var" = yes; then 6958125647Sdes case :$finalize_shlibpath: in 6959125647Sdes *":$libdir:"*) ;; 6960228692Sdes *) func_append finalize_shlibpath "$libdir:" ;; 6961117610Sdes esac 6962125647Sdes add="-l$name" 6963141098Sdes elif test "$hardcode_automatic" = yes; then 6964141098Sdes if test -n "$inst_prefix_dir" && 6965141098Sdes test -f "$inst_prefix_dir$libdir/$linklib" ; then 6966228692Sdes add="$inst_prefix_dir$libdir/$linklib" 6967141098Sdes else 6968228692Sdes add="$libdir/$linklib" 6969141098Sdes fi 6970117610Sdes else 6971125647Sdes # We cannot seem to hardcode it, guess we'll fake it. 6972125647Sdes add_dir="-L$libdir" 6973141098Sdes # Try looking first in the location we're being installed to. 6974141098Sdes if test -n "$inst_prefix_dir"; then 6975174832Sdes case $libdir in 6976141098Sdes [\\/]*) 6977228692Sdes func_append add_dir " -L$inst_prefix_dir$libdir" 6978141098Sdes ;; 6979141098Sdes esac 6980141098Sdes fi 6981125647Sdes add="-l$name" 6982117610Sdes fi 6983117610Sdes 6984141098Sdes if test "$linkmode" = prog; then 6985125647Sdes test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 6986125647Sdes test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 6987125647Sdes else 6988125647Sdes test -n "$add_dir" && deplibs="$add_dir $deplibs" 6989125647Sdes test -n "$add" && deplibs="$add $deplibs" 6990125647Sdes fi 6991117610Sdes fi 6992141098Sdes elif test "$linkmode" = prog; then 6993117610Sdes # Here we assume that one of hardcode_direct or hardcode_minus_L 6994117610Sdes # is not unsupported. This is valid on all known static and 6995117610Sdes # shared platforms. 6996117610Sdes if test "$hardcode_direct" != unsupported; then 6997117610Sdes test -n "$old_library" && linklib="$old_library" 6998125647Sdes compile_deplibs="$dir/$linklib $compile_deplibs" 6999125647Sdes finalize_deplibs="$dir/$linklib $finalize_deplibs" 7000117610Sdes else 7001125647Sdes compile_deplibs="-l$name -L$dir $compile_deplibs" 7002125647Sdes finalize_deplibs="-l$name -L$dir $finalize_deplibs" 7003117610Sdes fi 7004125647Sdes elif test "$build_libtool_libs" = yes; then 7005125647Sdes # Not a shared library 7006125647Sdes if test "$deplibs_check_method" != pass_all; then 7007125647Sdes # We're trying link a shared library against a static one 7008125647Sdes # but the system doesn't support it. 7009117610Sdes 7010125647Sdes # Just print a warning and add the library to dependency_libs so 7011125647Sdes # that the program can be linked against the static library. 7012228692Sdes echo 7013228692Sdes $ECHO "*** Warning: This system can not link to static lib archive $lib." 7014228692Sdes echo "*** I have the capability to make that library automatically link in when" 7015228692Sdes echo "*** you link to this library. But I can only do this if you have a" 7016228692Sdes echo "*** shared version of the library, which you do not appear to have." 7017125647Sdes if test "$module" = yes; then 7018228692Sdes echo "*** But as you try to build a module library, libtool will still create " 7019228692Sdes echo "*** a static module, that should work as long as the dlopening application" 7020228692Sdes echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 7021125647Sdes if test -z "$global_symbol_pipe"; then 7022228692Sdes echo 7023228692Sdes echo "*** However, this would only work if libtool was able to extract symbol" 7024228692Sdes echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 7025228692Sdes echo "*** not find such a program. So, this module is probably useless." 7026228692Sdes echo "*** \`nm' from GNU binutils and a full rebuild may help." 7027125647Sdes fi 7028125647Sdes if test "$build_old_libs" = no; then 7029125647Sdes build_libtool_libs=module 7030125647Sdes build_old_libs=yes 7031125647Sdes else 7032125647Sdes build_libtool_libs=no 7033125647Sdes fi 7034125647Sdes fi 7035125647Sdes else 7036125647Sdes deplibs="$dir/$old_library $deplibs" 7037125647Sdes link_static=yes 7038125647Sdes fi 7039125647Sdes fi # link shared/static library? 7040117610Sdes 7041141098Sdes if test "$linkmode" = lib; then 7042125647Sdes if test -n "$dependency_libs" && 7043141098Sdes { test "$hardcode_into_libs" != yes || 7044141098Sdes test "$build_old_libs" = yes || 7045141098Sdes test "$link_static" = yes; }; then 7046125647Sdes # Extract -R from dependency_libs 7047125647Sdes temp_deplibs= 7048125647Sdes for libdir in $dependency_libs; do 7049125647Sdes case $libdir in 7050228692Sdes -R*) func_stripname '-R' '' "$libdir" 7051228692Sdes temp_xrpath=$func_stripname_result 7052125647Sdes case " $xrpath " in 7053125647Sdes *" $temp_xrpath "*) ;; 7054228692Sdes *) func_append xrpath " $temp_xrpath";; 7055125647Sdes esac;; 7056228692Sdes *) func_append temp_deplibs " $libdir";; 7057125647Sdes esac 7058125647Sdes done 7059125647Sdes dependency_libs="$temp_deplibs" 7060125647Sdes fi 7061117610Sdes 7062228692Sdes func_append newlib_search_path " $absdir" 7063125647Sdes # Link against this library 7064125647Sdes test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 7065125647Sdes # ... and its dependency_libs 7066125647Sdes tmp_libs= 7067125647Sdes for deplib in $dependency_libs; do 7068125647Sdes newdependency_libs="$deplib $newdependency_libs" 7069228692Sdes case $deplib in 7070228692Sdes -L*) func_stripname '-L' '' "$deplib" 7071228692Sdes func_resolve_sysroot "$func_stripname_result";; 7072228692Sdes *) func_resolve_sysroot "$deplib" ;; 7073228692Sdes esac 7074228692Sdes if $opt_preserve_dup_deps ; then 7075125647Sdes case "$tmp_libs " in 7076228692Sdes *" $func_resolve_sysroot_result "*) 7077228692Sdes func_append specialdeplibs " $func_resolve_sysroot_result" ;; 7078125647Sdes esac 7079125647Sdes fi 7080228692Sdes func_append tmp_libs " $func_resolve_sysroot_result" 7081125647Sdes done 7082117610Sdes 7083141098Sdes if test "$link_all_deplibs" != no; then 7084125647Sdes # Add the search paths of all dependency libraries 7085125647Sdes for deplib in $dependency_libs; do 7086228692Sdes path= 7087125647Sdes case $deplib in 7088125647Sdes -L*) path="$deplib" ;; 7089125647Sdes *.la) 7090228692Sdes func_resolve_sysroot "$deplib" 7091228692Sdes deplib=$func_resolve_sysroot_result 7092228692Sdes func_dirname "$deplib" "" "." 7093228692Sdes dir=$func_dirname_result 7094125647Sdes # We need an absolute path. 7095125647Sdes case $dir in 7096125647Sdes [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 7097125647Sdes *) 7098125647Sdes absdir=`cd "$dir" && pwd` 7099125647Sdes if test -z "$absdir"; then 7100228692Sdes func_warning "cannot determine absolute directory name of \`$dir'" 7101125647Sdes absdir="$dir" 7102125647Sdes fi 7103125647Sdes ;; 7104125647Sdes esac 7105228692Sdes if $GREP "^installed=no" $deplib > /dev/null; then 7106141098Sdes case $host in 7107141098Sdes *-*-darwin*) 7108228692Sdes depdepl= 7109141098Sdes eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 7110141098Sdes if test -n "$deplibrary_names" ; then 7111141098Sdes for tmp in $deplibrary_names ; do 7112141098Sdes depdepl=$tmp 7113141098Sdes done 7114228692Sdes if test -f "$absdir/$objdir/$depdepl" ; then 7115228692Sdes depdepl="$absdir/$objdir/$depdepl" 7116228692Sdes darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7117228692Sdes if test -z "$darwin_install_name"; then 7118228692Sdes darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7119228692Sdes fi 7120228692Sdes func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 7121228692Sdes func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 7122228692Sdes path= 7123141098Sdes fi 7124141098Sdes fi 7125141098Sdes ;; 7126141098Sdes *) 7127228692Sdes path="-L$absdir/$objdir" 7128141098Sdes ;; 7129141098Sdes esac 7130228692Sdes else 7131228692Sdes eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 7132228692Sdes test -z "$libdir" && \ 7133228692Sdes func_fatal_error "\`$deplib' is not a valid libtool archive" 7134228692Sdes test "$absdir" != "$libdir" && \ 7135228692Sdes func_warning "\`$deplib' seems to be moved" 7136228692Sdes 7137228692Sdes path="-L$absdir" 7138228692Sdes fi 7139125647Sdes ;; 7140125647Sdes esac 7141125647Sdes case " $deplibs " in 7142174832Sdes *" $path "*) ;; 7143174832Sdes *) deplibs="$path $deplibs" ;; 7144174832Sdes esac 7145125647Sdes done 7146125647Sdes fi # link_all_deplibs != no 7147125647Sdes fi # linkmode = lib 7148125647Sdes done # for deplib in $libs 7149228692Sdes if test "$pass" = link; then 7150228692Sdes if test "$linkmode" = "prog"; then 7151228692Sdes compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 7152228692Sdes finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 7153228692Sdes else 7154228692Sdes compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7155228692Sdes fi 7156228692Sdes fi 7157141098Sdes dependency_libs="$newdependency_libs" 7158141098Sdes if test "$pass" = dlpreopen; then 7159125647Sdes # Link the dlpreopened libraries before other libraries 7160125647Sdes for deplib in $save_deplibs; do 7161125647Sdes deplibs="$deplib $deplibs" 7162125647Sdes done 7163117610Sdes fi 7164141098Sdes if test "$pass" != dlopen; then 7165141098Sdes if test "$pass" != conv; then 7166125647Sdes # Make sure lib_search_path contains only unique directories. 7167125647Sdes lib_search_path= 7168125647Sdes for dir in $newlib_search_path; do 7169125647Sdes case "$lib_search_path " in 7170125647Sdes *" $dir "*) ;; 7171228692Sdes *) func_append lib_search_path " $dir" ;; 7172125647Sdes esac 7173125647Sdes done 7174125647Sdes newlib_search_path= 7175125647Sdes fi 7176117610Sdes 7177125647Sdes if test "$linkmode,$pass" != "prog,link"; then 7178125647Sdes vars="deplibs" 7179125647Sdes else 7180125647Sdes vars="compile_deplibs finalize_deplibs" 7181125647Sdes fi 7182125647Sdes for var in $vars dependency_libs; do 7183125647Sdes # Add libraries to $var in reverse order 7184125647Sdes eval tmp_libs=\"\$$var\" 7185125647Sdes new_libs= 7186125647Sdes for deplib in $tmp_libs; do 7187141098Sdes # FIXME: Pedantically, this is the right thing to do, so 7188141098Sdes # that some nasty dependency loop isn't accidentally 7189141098Sdes # broken: 7190141098Sdes #new_libs="$deplib $new_libs" 7191141098Sdes # Pragmatically, this seems to cause very few problems in 7192141098Sdes # practice: 7193125647Sdes case $deplib in 7194125647Sdes -L*) new_libs="$deplib $new_libs" ;; 7195141098Sdes -R*) ;; 7196125647Sdes *) 7197141098Sdes # And here is the reason: when a library appears more 7198141098Sdes # than once as an explicit dependence of a library, or 7199141098Sdes # is implicitly linked in more than once by the 7200141098Sdes # compiler, it is considered special, and multiple 7201141098Sdes # occurrences thereof are not removed. Compare this 7202141098Sdes # with having the same library being listed as a 7203141098Sdes # dependency of multiple other libraries: in this case, 7204141098Sdes # we know (pedantically, we assume) the library does not 7205141098Sdes # need to be listed more than once, so we keep only the 7206141098Sdes # last copy. This is not always right, but it is rare 7207141098Sdes # enough that we require users that really mean to play 7208141098Sdes # such unportable linking tricks to link the library 7209141098Sdes # using -Wl,-lname, so that libtool does not consider it 7210141098Sdes # for duplicate removal. 7211125647Sdes case " $specialdeplibs " in 7212125647Sdes *" $deplib "*) new_libs="$deplib $new_libs" ;; 7213125647Sdes *) 7214125647Sdes case " $new_libs " in 7215125647Sdes *" $deplib "*) ;; 7216125647Sdes *) new_libs="$deplib $new_libs" ;; 7217125647Sdes esac 7218125647Sdes ;; 7219125647Sdes esac 7220125647Sdes ;; 7221125647Sdes esac 7222125647Sdes done 7223125647Sdes tmp_libs= 7224125647Sdes for deplib in $new_libs; do 7225125647Sdes case $deplib in 7226125647Sdes -L*) 7227125647Sdes case " $tmp_libs " in 7228125647Sdes *" $deplib "*) ;; 7229228692Sdes *) func_append tmp_libs " $deplib" ;; 7230125647Sdes esac 7231125647Sdes ;; 7232228692Sdes *) func_append tmp_libs " $deplib" ;; 7233125647Sdes esac 7234125647Sdes done 7235125647Sdes eval $var=\"$tmp_libs\" 7236125647Sdes done # for var 7237117610Sdes fi 7238141098Sdes # Last step: remove runtime libs from dependency_libs 7239141098Sdes # (they stay in deplibs) 7240141098Sdes tmp_libs= 7241141098Sdes for i in $dependency_libs ; do 7242141098Sdes case " $predeps $postdeps $compiler_lib_search_path " in 7243141098Sdes *" $i "*) 7244141098Sdes i="" 7245141098Sdes ;; 7246141098Sdes esac 7247141098Sdes if test -n "$i" ; then 7248228692Sdes func_append tmp_libs " $i" 7249141098Sdes fi 7250141098Sdes done 7251141098Sdes dependency_libs=$tmp_libs 7252125647Sdes done # for pass 7253141098Sdes if test "$linkmode" = prog; then 7254125647Sdes dlfiles="$newdlfiles" 7255228692Sdes fi 7256228692Sdes if test "$linkmode" = prog || test "$linkmode" = lib; then 7257125647Sdes dlprefiles="$newdlprefiles" 7258125647Sdes fi 7259117610Sdes 7260125647Sdes case $linkmode in 7261125647Sdes oldlib) 7262117610Sdes if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7263228692Sdes func_warning "\`-dlopen' is ignored for archives" 7264117610Sdes fi 7265117610Sdes 7266228692Sdes case " $deplibs" in 7267228692Sdes *\ -l* | *\ -L*) 7268228692Sdes func_warning "\`-l' and \`-L' are ignored for archives" ;; 7269228692Sdes esac 7270117610Sdes 7271228692Sdes test -n "$rpath" && \ 7272228692Sdes func_warning "\`-rpath' is ignored for archives" 7273117610Sdes 7274228692Sdes test -n "$xrpath" && \ 7275228692Sdes func_warning "\`-R' is ignored for archives" 7276117610Sdes 7277228692Sdes test -n "$vinfo" && \ 7278228692Sdes func_warning "\`-version-info/-version-number' is ignored for archives" 7279117610Sdes 7280228692Sdes test -n "$release" && \ 7281228692Sdes func_warning "\`-release' is ignored for archives" 7282117610Sdes 7283228692Sdes test -n "$export_symbols$export_symbols_regex" && \ 7284228692Sdes func_warning "\`-export-symbols' is ignored for archives" 7285228692Sdes 7286117610Sdes # Now set the variables for building old libraries. 7287117610Sdes build_libtool_libs=no 7288117610Sdes oldlibs="$output" 7289228692Sdes func_append objs "$old_deplibs" 7290117610Sdes ;; 7291117610Sdes 7292125647Sdes lib) 7293117610Sdes # Make sure we only generate libraries of the form `libNAME.la'. 7294125647Sdes case $outputname in 7295117610Sdes lib*) 7296228692Sdes func_stripname 'lib' '.la' "$outputname" 7297228692Sdes name=$func_stripname_result 7298141098Sdes eval shared_ext=\"$shrext_cmds\" 7299117610Sdes eval libname=\"$libname_spec\" 7300117610Sdes ;; 7301117610Sdes *) 7302228692Sdes test "$module" = no && \ 7303228692Sdes func_fatal_help "libtool library \`$output' must begin with \`lib'" 7304228692Sdes 7305117610Sdes if test "$need_lib_prefix" != no; then 7306117610Sdes # Add the "lib" prefix for modules if required 7307228692Sdes func_stripname '' '.la' "$outputname" 7308228692Sdes name=$func_stripname_result 7309141098Sdes eval shared_ext=\"$shrext_cmds\" 7310117610Sdes eval libname=\"$libname_spec\" 7311117610Sdes else 7312228692Sdes func_stripname '' '.la' "$outputname" 7313228692Sdes libname=$func_stripname_result 7314117610Sdes fi 7315117610Sdes ;; 7316117610Sdes esac 7317117610Sdes 7318117610Sdes if test -n "$objs"; then 7319125647Sdes if test "$deplibs_check_method" != pass_all; then 7320228692Sdes func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 7321125647Sdes else 7322228692Sdes echo 7323228692Sdes $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 7324228692Sdes $ECHO "*** objects $objs is not portable!" 7325228692Sdes func_append libobjs " $objs" 7326125647Sdes fi 7327117610Sdes fi 7328117610Sdes 7329228692Sdes test "$dlself" != no && \ 7330228692Sdes func_warning "\`-dlopen self' is ignored for libtool libraries" 7331117610Sdes 7332117610Sdes set dummy $rpath 7333228692Sdes shift 7334228692Sdes test "$#" -gt 1 && \ 7335228692Sdes func_warning "ignoring multiple \`-rpath's for a libtool library" 7336117610Sdes 7337228692Sdes install_libdir="$1" 7338228692Sdes 7339117610Sdes oldlibs= 7340117610Sdes if test -z "$rpath"; then 7341117610Sdes if test "$build_libtool_libs" = yes; then 7342117610Sdes # Building a libtool convenience library. 7343141098Sdes # Some compilers have problems with a `.al' extension so 7344141098Sdes # convenience libraries should have the same extension an 7345141098Sdes # archive normally would. 7346117610Sdes oldlibs="$output_objdir/$libname.$libext $oldlibs" 7347117610Sdes build_libtool_libs=convenience 7348117610Sdes build_old_libs=yes 7349117610Sdes fi 7350117610Sdes 7351228692Sdes test -n "$vinfo" && \ 7352228692Sdes func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 7353117610Sdes 7354228692Sdes test -n "$release" && \ 7355228692Sdes func_warning "\`-release' is ignored for convenience libraries" 7356117610Sdes else 7357117610Sdes 7358117610Sdes # Parse the version information argument. 7359125647Sdes save_ifs="$IFS"; IFS=':' 7360117610Sdes set dummy $vinfo 0 0 0 7361228692Sdes shift 7362117610Sdes IFS="$save_ifs" 7363117610Sdes 7364228692Sdes test -n "$7" && \ 7365228692Sdes func_fatal_help "too many parameters to \`-version-info'" 7366117610Sdes 7367141098Sdes # convert absolute version numbers to libtool ages 7368141098Sdes # this retains compatibility with .la files and attempts 7369141098Sdes # to make the code below a bit more comprehensible 7370117610Sdes 7371141098Sdes case $vinfo_number in 7372141098Sdes yes) 7373228692Sdes number_major="$1" 7374228692Sdes number_minor="$2" 7375228692Sdes number_revision="$3" 7376141098Sdes # 7377141098Sdes # There are really only two kinds -- those that 7378141098Sdes # use the current revision as the major version 7379141098Sdes # and those that subtract age and use age as 7380141098Sdes # a minor version. But, then there is irix 7381141098Sdes # which has an extra 1 added just for fun 7382141098Sdes # 7383141098Sdes case $version_type in 7384236109Sdes # correct linux to gnu/linux during the next big refactor 7385174832Sdes darwin|linux|osf|windows|none) 7386228692Sdes func_arith $number_major + $number_minor 7387228692Sdes current=$func_arith_result 7388141098Sdes age="$number_minor" 7389141098Sdes revision="$number_revision" 7390141098Sdes ;; 7391228692Sdes freebsd-aout|freebsd-elf|qnx|sunos) 7392141098Sdes current="$number_major" 7393141098Sdes revision="$number_minor" 7394141098Sdes age="0" 7395141098Sdes ;; 7396141098Sdes irix|nonstopux) 7397228692Sdes func_arith $number_major + $number_minor 7398228692Sdes current=$func_arith_result 7399141098Sdes age="$number_minor" 7400141098Sdes revision="$number_minor" 7401174832Sdes lt_irix_increment=no 7402141098Sdes ;; 7403141098Sdes esac 7404141098Sdes ;; 7405141098Sdes no) 7406228692Sdes current="$1" 7407228692Sdes revision="$2" 7408228692Sdes age="$3" 7409141098Sdes ;; 7410141098Sdes esac 7411141098Sdes 7412117610Sdes # Check that each of the things are valid numbers. 7413125647Sdes case $current in 7414147455Sdes 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]) ;; 7415117610Sdes *) 7416228692Sdes func_error "CURRENT \`$current' must be a nonnegative integer" 7417228692Sdes func_fatal_error "\`$vinfo' is not valid version information" 7418117610Sdes ;; 7419117610Sdes esac 7420117610Sdes 7421125647Sdes case $revision in 7422147455Sdes 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]) ;; 7423117610Sdes *) 7424228692Sdes func_error "REVISION \`$revision' must be a nonnegative integer" 7425228692Sdes func_fatal_error "\`$vinfo' is not valid version information" 7426117610Sdes ;; 7427117610Sdes esac 7428117610Sdes 7429125647Sdes case $age in 7430147455Sdes 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]) ;; 7431117610Sdes *) 7432228692Sdes func_error "AGE \`$age' must be a nonnegative integer" 7433228692Sdes func_fatal_error "\`$vinfo' is not valid version information" 7434117610Sdes ;; 7435117610Sdes esac 7436117610Sdes 7437141098Sdes if test "$age" -gt "$current"; then 7438228692Sdes func_error "AGE \`$age' is greater than the current interface number \`$current'" 7439228692Sdes func_fatal_error "\`$vinfo' is not valid version information" 7440117610Sdes fi 7441117610Sdes 7442117610Sdes # Calculate the version variables. 7443117610Sdes major= 7444117610Sdes versuffix= 7445117610Sdes verstring= 7446125647Sdes case $version_type in 7447117610Sdes none) ;; 7448117610Sdes 7449125647Sdes darwin) 7450125647Sdes # Like Linux, but with the current version available in 7451125647Sdes # verstring for coding it into the library header 7452228692Sdes func_arith $current - $age 7453228692Sdes major=.$func_arith_result 7454125647Sdes versuffix="$major.$age.$revision" 7455125647Sdes # Darwin ld doesn't like 0 for these options... 7456228692Sdes func_arith $current + 1 7457228692Sdes minor_current=$func_arith_result 7458174832Sdes xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 7459174832Sdes verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 7460125647Sdes ;; 7461125647Sdes 7462125647Sdes freebsd-aout) 7463125647Sdes major=".$current" 7464125647Sdes versuffix=".$current.$revision"; 7465125647Sdes ;; 7466125647Sdes 7467125647Sdes freebsd-elf) 7468125647Sdes major=".$current" 7469228692Sdes versuffix=".$current" 7470125647Sdes ;; 7471125647Sdes 7472125647Sdes irix | nonstopux) 7473174832Sdes if test "X$lt_irix_increment" = "Xno"; then 7474228692Sdes func_arith $current - $age 7475174832Sdes else 7476228692Sdes func_arith $current - $age + 1 7477174832Sdes fi 7478228692Sdes major=$func_arith_result 7479228692Sdes 7480125647Sdes case $version_type in 7481125647Sdes nonstopux) verstring_prefix=nonstopux ;; 7482125647Sdes *) verstring_prefix=sgi ;; 7483125647Sdes esac 7484125647Sdes verstring="$verstring_prefix$major.$revision" 7485125647Sdes 7486117610Sdes # Add in all the interfaces that we are compatible with. 7487117610Sdes loop=$revision 7488141098Sdes while test "$loop" -ne 0; do 7489228692Sdes func_arith $revision - $loop 7490228692Sdes iface=$func_arith_result 7491228692Sdes func_arith $loop - 1 7492228692Sdes loop=$func_arith_result 7493125647Sdes verstring="$verstring_prefix$major.$iface:$verstring" 7494117610Sdes done 7495125647Sdes 7496125647Sdes # Before this point, $major must not contain `.'. 7497125647Sdes major=.$major 7498125647Sdes versuffix="$major.$revision" 7499117610Sdes ;; 7500117610Sdes 7501236109Sdes linux) # correct to gnu/linux during the next big refactor 7502228692Sdes func_arith $current - $age 7503228692Sdes major=.$func_arith_result 7504117610Sdes versuffix="$major.$age.$revision" 7505117610Sdes ;; 7506117610Sdes 7507117610Sdes osf) 7508228692Sdes func_arith $current - $age 7509228692Sdes major=.$func_arith_result 7510117610Sdes versuffix=".$current.$age.$revision" 7511117610Sdes verstring="$current.$age.$revision" 7512117610Sdes 7513117610Sdes # Add in all the interfaces that we are compatible with. 7514117610Sdes loop=$age 7515141098Sdes while test "$loop" -ne 0; do 7516228692Sdes func_arith $current - $loop 7517228692Sdes iface=$func_arith_result 7518228692Sdes func_arith $loop - 1 7519228692Sdes loop=$func_arith_result 7520117610Sdes verstring="$verstring:${iface}.0" 7521117610Sdes done 7522117610Sdes 7523117610Sdes # Make executables depend on our current version. 7524228692Sdes func_append verstring ":${current}.0" 7525117610Sdes ;; 7526117610Sdes 7527228692Sdes qnx) 7528228692Sdes major=".$current" 7529228692Sdes versuffix=".$current" 7530228692Sdes ;; 7531228692Sdes 7532117610Sdes sunos) 7533117610Sdes major=".$current" 7534117610Sdes versuffix=".$current.$revision" 7535117610Sdes ;; 7536117610Sdes 7537117610Sdes windows) 7538125647Sdes # Use '-' rather than '.', since we only want one 7539125647Sdes # extension on DOS 8.3 filesystems. 7540228692Sdes func_arith $current - $age 7541228692Sdes major=$func_arith_result 7542125647Sdes versuffix="-$major" 7543117610Sdes ;; 7544117610Sdes 7545117610Sdes *) 7546228692Sdes func_fatal_configuration "unknown library version type \`$version_type'" 7547117610Sdes ;; 7548117610Sdes esac 7549117610Sdes 7550117610Sdes # Clear the version info if we defaulted, and they specified a release. 7551117610Sdes if test -z "$vinfo" && test -n "$release"; then 7552117610Sdes major= 7553125647Sdes case $version_type in 7554125647Sdes darwin) 7555125647Sdes # we can't check for "0.0" in archive_cmds due to quoting 7556125647Sdes # problems, so we reset it completely 7557141098Sdes verstring= 7558125647Sdes ;; 7559125647Sdes *) 7560125647Sdes verstring="0.0" 7561125647Sdes ;; 7562125647Sdes esac 7563117610Sdes if test "$need_version" = no; then 7564117610Sdes versuffix= 7565117610Sdes else 7566117610Sdes versuffix=".0.0" 7567117610Sdes fi 7568117610Sdes fi 7569117610Sdes 7570117610Sdes # Remove version info from name if versioning should be avoided 7571117610Sdes if test "$avoid_version" = yes && test "$need_version" = no; then 7572117610Sdes major= 7573117610Sdes versuffix= 7574117610Sdes verstring="" 7575117610Sdes fi 7576125647Sdes 7577117610Sdes # Check to see if the archive will have undefined symbols. 7578117610Sdes if test "$allow_undefined" = yes; then 7579117610Sdes if test "$allow_undefined_flag" = unsupported; then 7580228692Sdes func_warning "undefined symbols not allowed in $host shared libraries" 7581117610Sdes build_libtool_libs=no 7582117610Sdes build_old_libs=yes 7583117610Sdes fi 7584117610Sdes else 7585117610Sdes # Don't allow undefined symbols. 7586117610Sdes allow_undefined_flag="$no_undefined_flag" 7587117610Sdes fi 7588228692Sdes 7589125647Sdes fi 7590117610Sdes 7591228692Sdes func_generate_dlsyms "$libname" "$libname" "yes" 7592228692Sdes func_append libobjs " $symfileobj" 7593228692Sdes test "X$libobjs" = "X " && libobjs= 7594228692Sdes 7595228692Sdes if test "$opt_mode" != relink; then 7596141098Sdes # Remove our outputs, but don't remove object files since they 7597141098Sdes # may have been created when compiling PIC objects. 7598141098Sdes removelist= 7599228692Sdes tempremovelist=`$ECHO "$output_objdir/*"` 7600141098Sdes for p in $tempremovelist; do 7601141098Sdes case $p in 7602228692Sdes *.$objext | *.gcno) 7603141098Sdes ;; 7604141098Sdes $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 7605141098Sdes if test "X$precious_files_regex" != "X"; then 7606228692Sdes if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 7607228692Sdes then 7608141098Sdes continue 7609141098Sdes fi 7610141098Sdes fi 7611228692Sdes func_append removelist " $p" 7612141098Sdes ;; 7613141098Sdes *) ;; 7614141098Sdes esac 7615141098Sdes done 7616228692Sdes test -n "$removelist" && \ 7617228692Sdes func_show_eval "${RM}r \$removelist" 7618117610Sdes fi 7619117610Sdes 7620125647Sdes # Now set the variables for building old libraries. 7621125647Sdes if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 7622228692Sdes func_append oldlibs " $output_objdir/$libname.$libext" 7623125647Sdes 7624125647Sdes # Transform .lo files to .o files. 7625228692Sdes oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 7626125647Sdes fi 7627125647Sdes 7628125647Sdes # Eliminate all temporary directories. 7629174832Sdes #for path in $notinst_path; do 7630228692Sdes # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 7631228692Sdes # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 7632228692Sdes # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 7633174832Sdes #done 7634125647Sdes 7635125647Sdes if test -n "$xrpath"; then 7636117610Sdes # If the user specified any rpath flags, then add them. 7637125647Sdes temp_xrpath= 7638125647Sdes for libdir in $xrpath; do 7639228692Sdes func_replace_sysroot "$libdir" 7640228692Sdes func_append temp_xrpath " -R$func_replace_sysroot_result" 7641117610Sdes case "$finalize_rpath " in 7642117610Sdes *" $libdir "*) ;; 7643228692Sdes *) func_append finalize_rpath " $libdir" ;; 7644117610Sdes esac 7645117610Sdes done 7646141098Sdes if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 7647125647Sdes dependency_libs="$temp_xrpath $dependency_libs" 7648125647Sdes fi 7649117610Sdes fi 7650117610Sdes 7651125647Sdes # Make sure dlfiles contains only unique files that won't be dlpreopened 7652125647Sdes old_dlfiles="$dlfiles" 7653125647Sdes dlfiles= 7654125647Sdes for lib in $old_dlfiles; do 7655125647Sdes case " $dlprefiles $dlfiles " in 7656125647Sdes *" $lib "*) ;; 7657228692Sdes *) func_append dlfiles " $lib" ;; 7658125647Sdes esac 7659117610Sdes done 7660117610Sdes 7661125647Sdes # Make sure dlprefiles contains only unique files 7662125647Sdes old_dlprefiles="$dlprefiles" 7663125647Sdes dlprefiles= 7664125647Sdes for lib in $old_dlprefiles; do 7665125647Sdes case "$dlprefiles " in 7666125647Sdes *" $lib "*) ;; 7667228692Sdes *) func_append dlprefiles " $lib" ;; 7668125647Sdes esac 7669125647Sdes done 7670125647Sdes 7671125647Sdes if test "$build_libtool_libs" = yes; then 7672125647Sdes if test -n "$rpath"; then 7673125647Sdes case $host in 7674228692Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 7675125647Sdes # these systems don't actually have a c library (as such)! 7676125647Sdes ;; 7677125647Sdes *-*-rhapsody* | *-*-darwin1.[012]) 7678125647Sdes # Rhapsody C library is in the System framework 7679228692Sdes func_append deplibs " System.ltframework" 7680125647Sdes ;; 7681125647Sdes *-*-netbsd*) 7682125647Sdes # Don't link with libc until the a.out ld.so is fixed. 7683125647Sdes ;; 7684147455Sdes *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 7685125647Sdes # Do not include libc due to us having libc/libc_r. 7686125647Sdes ;; 7687174832Sdes *-*-sco3.2v5* | *-*-sco5v6*) 7688174832Sdes # Causes problems with __ctype 7689174832Sdes ;; 7690174832Sdes *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7691174832Sdes # Compiler inserts libc in the correct place for threads to work 7692174832Sdes ;; 7693228692Sdes *) 7694125647Sdes # Add libc to deplibs on all other systems if necessary. 7695141098Sdes if test "$build_libtool_need_lc" = "yes"; then 7696228692Sdes func_append deplibs " -lc" 7697117610Sdes fi 7698125647Sdes ;; 7699117610Sdes esac 7700117610Sdes fi 7701117610Sdes 7702117610Sdes # Transform deplibs into only deplibs that can be linked in shared. 7703117610Sdes name_save=$name 7704117610Sdes libname_save=$libname 7705117610Sdes release_save=$release 7706117610Sdes versuffix_save=$versuffix 7707117610Sdes major_save=$major 7708117610Sdes # I'm not sure if I'm treating the release correctly. I think 7709117610Sdes # release should show up in the -l (ie -lgmp5) so we don't want to 7710117610Sdes # add it in twice. Is that correct? 7711117610Sdes release="" 7712117610Sdes versuffix="" 7713117610Sdes major="" 7714117610Sdes newdeplibs= 7715117610Sdes droppeddeps=no 7716125647Sdes case $deplibs_check_method in 7717117610Sdes pass_all) 7718117610Sdes # Don't check for shared/static. Everything works. 7719117610Sdes # This might be a little naive. We might want to check 7720117610Sdes # whether the library exists or not. But this is on 7721117610Sdes # osf3 & osf4 and I'm not really sure... Just 7722141098Sdes # implementing what was already the behavior. 7723117610Sdes newdeplibs=$deplibs 7724117610Sdes ;; 7725117610Sdes test_compile) 7726117610Sdes # This code stresses the "libraries are programs" paradigm to its 7727117610Sdes # limits. Maybe even breaks it. We compile a program, linking it 7728117610Sdes # against the deplibs as a proxy for the library. Then we can check 7729117610Sdes # whether they linked in statically or dynamically with ldd. 7730228692Sdes $opt_dry_run || $RM conftest.c 7731117610Sdes cat > conftest.c <<EOF 7732117610Sdes int main() { return 0; } 7733117610SdesEOF 7734228692Sdes $opt_dry_run || $RM conftest 7735174832Sdes if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 7736117610Sdes ldd_output=`ldd conftest` 7737117610Sdes for i in $deplibs; do 7738228692Sdes case $i in 7739228692Sdes -l*) 7740228692Sdes func_stripname -l '' "$i" 7741228692Sdes name=$func_stripname_result 7742141098Sdes if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7743141098Sdes case " $predeps $postdeps " in 7744141098Sdes *" $i "*) 7745228692Sdes func_append newdeplibs " $i" 7746141098Sdes i="" 7747141098Sdes ;; 7748141098Sdes esac 7749228692Sdes fi 7750141098Sdes if test -n "$i" ; then 7751228692Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 7752228692Sdes deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7753228692Sdes set dummy $deplib_matches; shift 7754228692Sdes deplib_match=$1 7755141098Sdes if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7756228692Sdes func_append newdeplibs " $i" 7757141098Sdes else 7758141098Sdes droppeddeps=yes 7759228692Sdes echo 7760228692Sdes $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7761228692Sdes echo "*** I have the capability to make that library automatically link in when" 7762228692Sdes echo "*** you link to this library. But I can only do this if you have a" 7763228692Sdes echo "*** shared version of the library, which I believe you do not have" 7764228692Sdes echo "*** because a test_compile did reveal that the linker did not use it for" 7765228692Sdes echo "*** its dynamic dependency list that programs get resolved with at runtime." 7766141098Sdes fi 7767117610Sdes fi 7768228692Sdes ;; 7769228692Sdes *) 7770228692Sdes func_append newdeplibs " $i" 7771228692Sdes ;; 7772228692Sdes esac 7773117610Sdes done 7774117610Sdes else 7775141098Sdes # Error occurred in the first compile. Let's try to salvage 7776125647Sdes # the situation: Compile a separate program for each library. 7777117610Sdes for i in $deplibs; do 7778228692Sdes case $i in 7779228692Sdes -l*) 7780228692Sdes func_stripname -l '' "$i" 7781228692Sdes name=$func_stripname_result 7782228692Sdes $opt_dry_run || $RM conftest 7783174832Sdes if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 7784117610Sdes ldd_output=`ldd conftest` 7785141098Sdes if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7786141098Sdes case " $predeps $postdeps " in 7787141098Sdes *" $i "*) 7788228692Sdes func_append newdeplibs " $i" 7789141098Sdes i="" 7790141098Sdes ;; 7791141098Sdes esac 7792117610Sdes fi 7793141098Sdes if test -n "$i" ; then 7794228692Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 7795228692Sdes deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7796228692Sdes set dummy $deplib_matches; shift 7797228692Sdes deplib_match=$1 7798141098Sdes if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7799228692Sdes func_append newdeplibs " $i" 7800141098Sdes else 7801141098Sdes droppeddeps=yes 7802228692Sdes echo 7803228692Sdes $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7804228692Sdes echo "*** I have the capability to make that library automatically link in when" 7805228692Sdes echo "*** you link to this library. But I can only do this if you have a" 7806228692Sdes echo "*** shared version of the library, which you do not appear to have" 7807228692Sdes echo "*** because a test_compile did reveal that the linker did not use this one" 7808228692Sdes echo "*** as a dynamic dependency that programs can get resolved with at runtime." 7809141098Sdes fi 7810141098Sdes fi 7811117610Sdes else 7812117610Sdes droppeddeps=yes 7813228692Sdes echo 7814228692Sdes $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 7815228692Sdes echo "*** make it link in! You will probably need to install it or some" 7816228692Sdes echo "*** library that it depends on before this library will be fully" 7817228692Sdes echo "*** functional. Installing it before continuing would be even better." 7818117610Sdes fi 7819228692Sdes ;; 7820228692Sdes *) 7821228692Sdes func_append newdeplibs " $i" 7822228692Sdes ;; 7823228692Sdes esac 7824117610Sdes done 7825117610Sdes fi 7826117610Sdes ;; 7827117610Sdes file_magic*) 7828228692Sdes set dummy $deplibs_check_method; shift 7829228692Sdes file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7830117610Sdes for a_deplib in $deplibs; do 7831228692Sdes case $a_deplib in 7832228692Sdes -l*) 7833228692Sdes func_stripname -l '' "$a_deplib" 7834228692Sdes name=$func_stripname_result 7835141098Sdes if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7836141098Sdes case " $predeps $postdeps " in 7837141098Sdes *" $a_deplib "*) 7838228692Sdes func_append newdeplibs " $a_deplib" 7839141098Sdes a_deplib="" 7840141098Sdes ;; 7841141098Sdes esac 7842141098Sdes fi 7843141098Sdes if test -n "$a_deplib" ; then 7844228692Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 7845228692Sdes if test -n "$file_magic_glob"; then 7846228692Sdes libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 7847228692Sdes else 7848228692Sdes libnameglob=$libname 7849228692Sdes fi 7850228692Sdes test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 7851141098Sdes for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7852228692Sdes if test "$want_nocaseglob" = yes; then 7853228692Sdes shopt -s nocaseglob 7854228692Sdes potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7855228692Sdes $nocaseglob 7856228692Sdes else 7857228692Sdes potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7858228692Sdes fi 7859141098Sdes for potent_lib in $potential_libs; do 7860117610Sdes # Follow soft links. 7861228692Sdes if ls -lLd "$potent_lib" 2>/dev/null | 7862228692Sdes $GREP " -> " >/dev/null; then 7863125647Sdes continue 7864117610Sdes fi 7865117610Sdes # The statement above tries to avoid entering an 7866117610Sdes # endless loop below, in case of cyclic links. 7867117610Sdes # We might still enter an endless loop, since a link 7868117610Sdes # loop can be closed while we follow links, 7869117610Sdes # but so what? 7870117610Sdes potlib="$potent_lib" 7871117610Sdes while test -h "$potlib" 2>/dev/null; do 7872125647Sdes potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 7873125647Sdes case $potliblink in 7874117610Sdes [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 7875228692Sdes *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 7876117610Sdes esac 7877117610Sdes done 7878228692Sdes if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 7879228692Sdes $SED -e 10q | 7880228692Sdes $EGREP "$file_magic_regex" > /dev/null; then 7881228692Sdes func_append newdeplibs " $a_deplib" 7882117610Sdes a_deplib="" 7883117610Sdes break 2 7884117610Sdes fi 7885141098Sdes done 7886141098Sdes done 7887141098Sdes fi 7888117610Sdes if test -n "$a_deplib" ; then 7889117610Sdes droppeddeps=yes 7890228692Sdes echo 7891228692Sdes $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7892228692Sdes echo "*** I have the capability to make that library automatically link in when" 7893228692Sdes echo "*** you link to this library. But I can only do this if you have a" 7894228692Sdes echo "*** shared version of the library, which you do not appear to have" 7895228692Sdes echo "*** because I did check the linker path looking for a file starting" 7896125647Sdes if test -z "$potlib" ; then 7897228692Sdes $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 7898125647Sdes else 7899228692Sdes $ECHO "*** with $libname and none of the candidates passed a file format test" 7900228692Sdes $ECHO "*** using a file magic. Last file checked: $potlib" 7901125647Sdes fi 7902117610Sdes fi 7903228692Sdes ;; 7904228692Sdes *) 7905117610Sdes # Add a -L argument. 7906228692Sdes func_append newdeplibs " $a_deplib" 7907228692Sdes ;; 7908228692Sdes esac 7909117610Sdes done # Gone through all deplibs. 7910117610Sdes ;; 7911125647Sdes match_pattern*) 7912228692Sdes set dummy $deplibs_check_method; shift 7913228692Sdes match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7914125647Sdes for a_deplib in $deplibs; do 7915228692Sdes case $a_deplib in 7916228692Sdes -l*) 7917228692Sdes func_stripname -l '' "$a_deplib" 7918228692Sdes name=$func_stripname_result 7919141098Sdes if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7920141098Sdes case " $predeps $postdeps " in 7921141098Sdes *" $a_deplib "*) 7922228692Sdes func_append newdeplibs " $a_deplib" 7923141098Sdes a_deplib="" 7924141098Sdes ;; 7925141098Sdes esac 7926141098Sdes fi 7927141098Sdes if test -n "$a_deplib" ; then 7928228692Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 7929141098Sdes for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7930141098Sdes potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 7931141098Sdes for potent_lib in $potential_libs; do 7932141098Sdes potlib="$potent_lib" # see symlink-check above in file_magic test 7933228692Sdes if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 7934228692Sdes $EGREP "$match_pattern_regex" > /dev/null; then 7935228692Sdes func_append newdeplibs " $a_deplib" 7936141098Sdes a_deplib="" 7937141098Sdes break 2 7938141098Sdes fi 7939141098Sdes done 7940125647Sdes done 7941141098Sdes fi 7942125647Sdes if test -n "$a_deplib" ; then 7943125647Sdes droppeddeps=yes 7944228692Sdes echo 7945228692Sdes $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7946228692Sdes echo "*** I have the capability to make that library automatically link in when" 7947228692Sdes echo "*** you link to this library. But I can only do this if you have a" 7948228692Sdes echo "*** shared version of the library, which you do not appear to have" 7949228692Sdes echo "*** because I did check the linker path looking for a file starting" 7950125647Sdes if test -z "$potlib" ; then 7951228692Sdes $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 7952125647Sdes else 7953228692Sdes $ECHO "*** with $libname and none of the candidates passed a file format test" 7954228692Sdes $ECHO "*** using a regex pattern. Last file checked: $potlib" 7955125647Sdes fi 7956125647Sdes fi 7957228692Sdes ;; 7958228692Sdes *) 7959125647Sdes # Add a -L argument. 7960228692Sdes func_append newdeplibs " $a_deplib" 7961228692Sdes ;; 7962228692Sdes esac 7963125647Sdes done # Gone through all deplibs. 7964125647Sdes ;; 7965117610Sdes none | unknown | *) 7966117610Sdes newdeplibs="" 7967228692Sdes tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7968141098Sdes if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7969141098Sdes for i in $predeps $postdeps ; do 7970141098Sdes # can't use Xsed below, because $i might contain '/' 7971228692Sdes tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 7972141098Sdes done 7973141098Sdes fi 7974228692Sdes case $tmp_deplibs in 7975228692Sdes *[!\ \ ]*) 7976228692Sdes echo 7977117610Sdes if test "X$deplibs_check_method" = "Xnone"; then 7978228692Sdes echo "*** Warning: inter-library dependencies are not supported in this platform." 7979117610Sdes else 7980228692Sdes echo "*** Warning: inter-library dependencies are not known to be supported." 7981117610Sdes fi 7982228692Sdes echo "*** All declared inter-library dependencies are being dropped." 7983117610Sdes droppeddeps=yes 7984228692Sdes ;; 7985228692Sdes esac 7986117610Sdes ;; 7987117610Sdes esac 7988117610Sdes versuffix=$versuffix_save 7989117610Sdes major=$major_save 7990117610Sdes release=$release_save 7991117610Sdes libname=$libname_save 7992117610Sdes name=$name_save 7993117610Sdes 7994125647Sdes case $host in 7995125647Sdes *-*-rhapsody* | *-*-darwin1.[012]) 7996228692Sdes # On Rhapsody replace the C library with the System framework 7997228692Sdes newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 7998125647Sdes ;; 7999125647Sdes esac 8000125647Sdes 8001117610Sdes if test "$droppeddeps" = yes; then 8002117610Sdes if test "$module" = yes; then 8003228692Sdes echo 8004228692Sdes echo "*** Warning: libtool could not satisfy all declared inter-library" 8005228692Sdes $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 8006228692Sdes echo "*** a static module, that should work as long as the dlopening" 8007228692Sdes echo "*** application is linked with the -dlopen flag." 8008117610Sdes if test -z "$global_symbol_pipe"; then 8009228692Sdes echo 8010228692Sdes echo "*** However, this would only work if libtool was able to extract symbol" 8011228692Sdes echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 8012228692Sdes echo "*** not find such a program. So, this module is probably useless." 8013228692Sdes echo "*** \`nm' from GNU binutils and a full rebuild may help." 8014117610Sdes fi 8015117610Sdes if test "$build_old_libs" = no; then 8016117610Sdes oldlibs="$output_objdir/$libname.$libext" 8017117610Sdes build_libtool_libs=module 8018117610Sdes build_old_libs=yes 8019117610Sdes else 8020117610Sdes build_libtool_libs=no 8021117610Sdes fi 8022117610Sdes else 8023228692Sdes echo "*** The inter-library dependencies that have been dropped here will be" 8024228692Sdes echo "*** automatically added whenever a program is linked with this library" 8025228692Sdes echo "*** or is declared to -dlopen it." 8026125647Sdes 8027141098Sdes if test "$allow_undefined" = no; then 8028228692Sdes echo 8029228692Sdes echo "*** Since this library must not contain undefined symbols," 8030228692Sdes echo "*** because either the platform does not support them or" 8031228692Sdes echo "*** it was explicitly requested with -no-undefined," 8032228692Sdes echo "*** libtool will only create a static version of it." 8033125647Sdes if test "$build_old_libs" = no; then 8034125647Sdes oldlibs="$output_objdir/$libname.$libext" 8035125647Sdes build_libtool_libs=module 8036125647Sdes build_old_libs=yes 8037125647Sdes else 8038125647Sdes build_libtool_libs=no 8039125647Sdes fi 8040125647Sdes fi 8041117610Sdes fi 8042117610Sdes fi 8043117610Sdes # Done checking deplibs! 8044117610Sdes deplibs=$newdeplibs 8045117610Sdes fi 8046228692Sdes # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8047228692Sdes case $host in 8048228692Sdes *-*-darwin*) 8049228692Sdes newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8050228692Sdes new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8051228692Sdes deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8052228692Sdes ;; 8053228692Sdes esac 8054117610Sdes 8055174832Sdes # move library search paths that coincide with paths to not yet 8056174832Sdes # installed libraries to the beginning of the library search list 8057174832Sdes new_libs= 8058174832Sdes for path in $notinst_path; do 8059174832Sdes case " $new_libs " in 8060174832Sdes *" -L$path/$objdir "*) ;; 8061174832Sdes *) 8062174832Sdes case " $deplibs " in 8063174832Sdes *" -L$path/$objdir "*) 8064228692Sdes func_append new_libs " -L$path/$objdir" ;; 8065174832Sdes esac 8066174832Sdes ;; 8067174832Sdes esac 8068174832Sdes done 8069174832Sdes for deplib in $deplibs; do 8070174832Sdes case $deplib in 8071174832Sdes -L*) 8072174832Sdes case " $new_libs " in 8073174832Sdes *" $deplib "*) ;; 8074228692Sdes *) func_append new_libs " $deplib" ;; 8075174832Sdes esac 8076174832Sdes ;; 8077228692Sdes *) func_append new_libs " $deplib" ;; 8078174832Sdes esac 8079174832Sdes done 8080174832Sdes deplibs="$new_libs" 8081174832Sdes 8082117610Sdes # All the library-specific variables (install_libdir is set above). 8083117610Sdes library_names= 8084117610Sdes old_library= 8085117610Sdes dlname= 8086125647Sdes 8087117610Sdes # Test again, we may have decided not to build it any more 8088117610Sdes if test "$build_libtool_libs" = yes; then 8089236109Sdes # Remove ${wl} instances when linking with ld. 8090236109Sdes # FIXME: should test the right _cmds variable. 8091236109Sdes case $archive_cmds in 8092236109Sdes *\$LD\ *) wl= ;; 8093236109Sdes esac 8094141098Sdes if test "$hardcode_into_libs" = yes; then 8095125647Sdes # Hardcode the library paths 8096125647Sdes hardcode_libdirs= 8097125647Sdes dep_rpath= 8098125647Sdes rpath="$finalize_rpath" 8099228692Sdes test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 8100125647Sdes for libdir in $rpath; do 8101125647Sdes if test -n "$hardcode_libdir_flag_spec"; then 8102125647Sdes if test -n "$hardcode_libdir_separator"; then 8103228692Sdes func_replace_sysroot "$libdir" 8104228692Sdes libdir=$func_replace_sysroot_result 8105125647Sdes if test -z "$hardcode_libdirs"; then 8106125647Sdes hardcode_libdirs="$libdir" 8107125647Sdes else 8108125647Sdes # Just accumulate the unique libdirs. 8109125647Sdes case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8110125647Sdes *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8111125647Sdes ;; 8112125647Sdes *) 8113228692Sdes func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8114125647Sdes ;; 8115125647Sdes esac 8116125647Sdes fi 8117125647Sdes else 8118125647Sdes eval flag=\"$hardcode_libdir_flag_spec\" 8119228692Sdes func_append dep_rpath " $flag" 8120125647Sdes fi 8121125647Sdes elif test -n "$runpath_var"; then 8122125647Sdes case "$perm_rpath " in 8123125647Sdes *" $libdir "*) ;; 8124236109Sdes *) func_append perm_rpath " $libdir" ;; 8125125647Sdes esac 8126125647Sdes fi 8127125647Sdes done 8128125647Sdes # Substitute the hardcoded libdirs into the rpath. 8129125647Sdes if test -n "$hardcode_libdir_separator" && 8130125647Sdes test -n "$hardcode_libdirs"; then 8131125647Sdes libdir="$hardcode_libdirs" 8132236109Sdes eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 8133125647Sdes fi 8134125647Sdes if test -n "$runpath_var" && test -n "$perm_rpath"; then 8135125647Sdes # We should set the runpath_var. 8136125647Sdes rpath= 8137125647Sdes for dir in $perm_rpath; do 8138228692Sdes func_append rpath "$dir:" 8139125647Sdes done 8140125647Sdes eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 8141125647Sdes fi 8142125647Sdes test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 8143125647Sdes fi 8144125647Sdes 8145125647Sdes shlibpath="$finalize_shlibpath" 8146228692Sdes test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 8147125647Sdes if test -n "$shlibpath"; then 8148125647Sdes eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 8149125647Sdes fi 8150125647Sdes 8151117610Sdes # Get the real and link names of the library. 8152141098Sdes eval shared_ext=\"$shrext_cmds\" 8153117610Sdes eval library_names=\"$library_names_spec\" 8154117610Sdes set dummy $library_names 8155228692Sdes shift 8156228692Sdes realname="$1" 8157228692Sdes shift 8158117610Sdes 8159117610Sdes if test -n "$soname_spec"; then 8160117610Sdes eval soname=\"$soname_spec\" 8161117610Sdes else 8162117610Sdes soname="$realname" 8163117610Sdes fi 8164141098Sdes if test -z "$dlname"; then 8165141098Sdes dlname=$soname 8166141098Sdes fi 8167117610Sdes 8168117610Sdes lib="$output_objdir/$realname" 8169174832Sdes linknames= 8170117610Sdes for link 8171117610Sdes do 8172228692Sdes func_append linknames " $link" 8173117610Sdes done 8174117610Sdes 8175117610Sdes # Use standard objects if they are pic 8176228692Sdes test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 8177228692Sdes test "X$libobjs" = "X " && libobjs= 8178117610Sdes 8179228692Sdes delfiles= 8180228692Sdes if test -n "$export_symbols" && test -n "$include_expsyms"; then 8181228692Sdes $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 8182228692Sdes export_symbols="$output_objdir/$libname.uexp" 8183228692Sdes func_append delfiles " $export_symbols" 8184228692Sdes fi 8185228692Sdes 8186228692Sdes orig_export_symbols= 8187228692Sdes case $host_os in 8188228692Sdes cygwin* | mingw* | cegcc*) 8189228692Sdes if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 8190228692Sdes # exporting using user supplied symfile 8191228692Sdes if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 8192228692Sdes # and it's NOT already a .def file. Must figure out 8193228692Sdes # which of the given symbols are data symbols and tag 8194228692Sdes # them as such. So, trigger use of export_symbols_cmds. 8195228692Sdes # export_symbols gets reassigned inside the "prepare 8196228692Sdes # the list of exported symbols" if statement, so the 8197228692Sdes # include_expsyms logic still works. 8198228692Sdes orig_export_symbols="$export_symbols" 8199228692Sdes export_symbols= 8200228692Sdes always_export_symbols=yes 8201228692Sdes fi 8202228692Sdes fi 8203228692Sdes ;; 8204228692Sdes esac 8205228692Sdes 8206117610Sdes # Prepare the list of exported symbols 8207117610Sdes if test -z "$export_symbols"; then 8208117610Sdes if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 8209228692Sdes func_verbose "generating symbol list for \`$libname.la'" 8210117610Sdes export_symbols="$output_objdir/$libname.exp" 8211228692Sdes $opt_dry_run || $RM $export_symbols 8212141098Sdes cmds=$export_symbols_cmds 8213125647Sdes save_ifs="$IFS"; IFS='~' 8214228692Sdes for cmd1 in $cmds; do 8215117610Sdes IFS="$save_ifs" 8216228692Sdes # Take the normal branch if the nm_file_list_spec branch 8217228692Sdes # doesn't work or if tool conversion is not needed. 8218228692Sdes case $nm_file_list_spec~$to_tool_file_cmd in 8219228692Sdes *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 8220228692Sdes try_normal_branch=yes 8221228692Sdes eval cmd=\"$cmd1\" 8222228692Sdes func_len " $cmd" 8223228692Sdes len=$func_len_result 8224228692Sdes ;; 8225228692Sdes *) 8226228692Sdes try_normal_branch=no 8227228692Sdes ;; 8228228692Sdes esac 8229228692Sdes if test "$try_normal_branch" = yes \ 8230228692Sdes && { test "$len" -lt "$max_cmd_len" \ 8231228692Sdes || test "$max_cmd_len" -le -1; } 8232228692Sdes then 8233228692Sdes func_show_eval "$cmd" 'exit $?' 8234228692Sdes skipped_export=false 8235228692Sdes elif test -n "$nm_file_list_spec"; then 8236228692Sdes func_basename "$output" 8237228692Sdes output_la=$func_basename_result 8238228692Sdes save_libobjs=$libobjs 8239228692Sdes save_output=$output 8240228692Sdes output=${output_objdir}/${output_la}.nm 8241228692Sdes func_to_tool_file "$output" 8242228692Sdes libobjs=$nm_file_list_spec$func_to_tool_file_result 8243228692Sdes func_append delfiles " $output" 8244228692Sdes func_verbose "creating $NM input file list: $output" 8245228692Sdes for obj in $save_libobjs; do 8246228692Sdes func_to_tool_file "$obj" 8247228692Sdes $ECHO "$func_to_tool_file_result" 8248228692Sdes done > "$output" 8249228692Sdes eval cmd=\"$cmd1\" 8250228692Sdes func_show_eval "$cmd" 'exit $?' 8251228692Sdes output=$save_output 8252228692Sdes libobjs=$save_libobjs 8253228692Sdes skipped_export=false 8254141098Sdes else 8255228692Sdes # The command line is too long to execute in one step. 8256228692Sdes func_verbose "using reloadable object file for export list..." 8257228692Sdes skipped_export=: 8258174832Sdes # Break out early, otherwise skipped_export may be 8259174832Sdes # set to false by a later but shorter cmd. 8260174832Sdes break 8261141098Sdes fi 8262117610Sdes done 8263117610Sdes IFS="$save_ifs" 8264228692Sdes if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 8265228692Sdes func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8266228692Sdes func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8267117610Sdes fi 8268117610Sdes fi 8269117610Sdes fi 8270117610Sdes 8271117610Sdes if test -n "$export_symbols" && test -n "$include_expsyms"; then 8272228692Sdes tmp_export_symbols="$export_symbols" 8273228692Sdes test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8274228692Sdes $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8275117610Sdes fi 8276117610Sdes 8277228692Sdes if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 8278228692Sdes # The given exports_symbols file has to be filtered, so filter it. 8279228692Sdes func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8280228692Sdes # FIXME: $output_objdir/$libname.filter potentially contains lots of 8281228692Sdes # 's' commands which not all seds can handle. GNU sed should be fine 8282228692Sdes # though. Also, the filter scales superlinearly with the number of 8283228692Sdes # global variables. join(1) would be nice here, but unfortunately 8284228692Sdes # isn't a blessed tool. 8285228692Sdes $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8286228692Sdes func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8287228692Sdes export_symbols=$output_objdir/$libname.def 8288228692Sdes $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8289228692Sdes fi 8290228692Sdes 8291141098Sdes tmp_deplibs= 8292141098Sdes for test_deplib in $deplibs; do 8293228692Sdes case " $convenience " in 8294228692Sdes *" $test_deplib "*) ;; 8295228692Sdes *) 8296228692Sdes func_append tmp_deplibs " $test_deplib" 8297228692Sdes ;; 8298228692Sdes esac 8299141098Sdes done 8300141098Sdes deplibs="$tmp_deplibs" 8301141098Sdes 8302117610Sdes if test -n "$convenience"; then 8303228692Sdes if test -n "$whole_archive_flag_spec" && 8304228692Sdes test "$compiler_needs_object" = yes && 8305228692Sdes test -z "$libobjs"; then 8306228692Sdes # extract the archives, so we have objects to list. 8307228692Sdes # TODO: could optimize this to just extract one archive. 8308228692Sdes whole_archive_flag_spec= 8309228692Sdes fi 8310117610Sdes if test -n "$whole_archive_flag_spec"; then 8311141098Sdes save_libobjs=$libobjs 8312117610Sdes eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8313228692Sdes test "X$libobjs" = "X " && libobjs= 8314117610Sdes else 8315117610Sdes gentop="$output_objdir/${outputname}x" 8316228692Sdes func_append generated " $gentop" 8317117610Sdes 8318141098Sdes func_extract_archives $gentop $convenience 8319228692Sdes func_append libobjs " $func_extract_archives_result" 8320228692Sdes test "X$libobjs" = "X " && libobjs= 8321117610Sdes fi 8322117610Sdes fi 8323228692Sdes 8324117610Sdes if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 8325117610Sdes eval flag=\"$thread_safe_flag_spec\" 8326228692Sdes func_append linker_flags " $flag" 8327117610Sdes fi 8328117610Sdes 8329125647Sdes # Make a backup of the uninstalled library when relinking 8330228692Sdes if test "$opt_mode" = relink; then 8331228692Sdes $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 8332125647Sdes fi 8333125647Sdes 8334117610Sdes # Do each of the archive commands. 8335141098Sdes if test "$module" = yes && test -n "$module_cmds" ; then 8336141098Sdes if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8337141098Sdes eval test_cmds=\"$module_expsym_cmds\" 8338141098Sdes cmds=$module_expsym_cmds 8339141098Sdes else 8340141098Sdes eval test_cmds=\"$module_cmds\" 8341141098Sdes cmds=$module_cmds 8342141098Sdes fi 8343141098Sdes else 8344228692Sdes if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8345228692Sdes eval test_cmds=\"$archive_expsym_cmds\" 8346228692Sdes cmds=$archive_expsym_cmds 8347228692Sdes else 8348228692Sdes eval test_cmds=\"$archive_cmds\" 8349228692Sdes cmds=$archive_cmds 8350141098Sdes fi 8351141098Sdes fi 8352141098Sdes 8353174832Sdes if test "X$skipped_export" != "X:" && 8354228692Sdes func_len " $test_cmds" && 8355228692Sdes len=$func_len_result && 8356228692Sdes test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8357141098Sdes : 8358141098Sdes else 8359228692Sdes # The command line is too long to link in one step, link piecewise 8360228692Sdes # or, if using GNU ld and skipped_export is not :, use a linker 8361228692Sdes # script. 8362141098Sdes 8363141098Sdes # Save the value of $output and $libobjs because we want to 8364141098Sdes # use them later. If we have whole_archive_flag_spec, we 8365141098Sdes # want to use save_libobjs as it was before 8366141098Sdes # whole_archive_flag_spec was expanded, because we can't 8367141098Sdes # assume the linker understands whole_archive_flag_spec. 8368141098Sdes # This may have to be revisited, in case too many 8369141098Sdes # convenience libraries get linked in and end up exceeding 8370141098Sdes # the spec. 8371141098Sdes if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 8372141098Sdes save_libobjs=$libobjs 8373141098Sdes fi 8374141098Sdes save_output=$output 8375228692Sdes func_basename "$output" 8376228692Sdes output_la=$func_basename_result 8377141098Sdes 8378141098Sdes # Clear the reloadable object creation command queue and 8379141098Sdes # initialize k to one. 8380141098Sdes test_cmds= 8381141098Sdes concat_cmds= 8382141098Sdes objlist= 8383141098Sdes last_robj= 8384141098Sdes k=1 8385228692Sdes 8386228692Sdes if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 8387228692Sdes output=${output_objdir}/${output_la}.lnkscript 8388228692Sdes func_verbose "creating GNU ld script: $output" 8389228692Sdes echo 'INPUT (' > $output 8390228692Sdes for obj in $save_libobjs 8391228692Sdes do 8392228692Sdes func_to_tool_file "$obj" 8393228692Sdes $ECHO "$func_to_tool_file_result" >> $output 8394228692Sdes done 8395228692Sdes echo ')' >> $output 8396228692Sdes func_append delfiles " $output" 8397228692Sdes func_to_tool_file "$output" 8398228692Sdes output=$func_to_tool_file_result 8399228692Sdes elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 8400228692Sdes output=${output_objdir}/${output_la}.lnk 8401228692Sdes func_verbose "creating linker input file list: $output" 8402228692Sdes : > $output 8403228692Sdes set x $save_libobjs 8404228692Sdes shift 8405228692Sdes firstobj= 8406228692Sdes if test "$compiler_needs_object" = yes; then 8407228692Sdes firstobj="$1 " 8408228692Sdes shift 8409228692Sdes fi 8410228692Sdes for obj 8411228692Sdes do 8412228692Sdes func_to_tool_file "$obj" 8413228692Sdes $ECHO "$func_to_tool_file_result" >> $output 8414228692Sdes done 8415228692Sdes func_append delfiles " $output" 8416228692Sdes func_to_tool_file "$output" 8417228692Sdes output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 8418228692Sdes else 8419228692Sdes if test -n "$save_libobjs"; then 8420228692Sdes func_verbose "creating reloadable object files..." 8421228692Sdes output=$output_objdir/$output_la-${k}.$objext 8422228692Sdes eval test_cmds=\"$reload_cmds\" 8423228692Sdes func_len " $test_cmds" 8424228692Sdes len0=$func_len_result 8425228692Sdes len=$len0 8426228692Sdes 8427228692Sdes # Loop over the list of objects to be linked. 8428228692Sdes for obj in $save_libobjs 8429228692Sdes do 8430228692Sdes func_len " $obj" 8431228692Sdes func_arith $len + $func_len_result 8432228692Sdes len=$func_arith_result 8433228692Sdes if test "X$objlist" = X || 8434228692Sdes test "$len" -lt "$max_cmd_len"; then 8435228692Sdes func_append objlist " $obj" 8436228692Sdes else 8437228692Sdes # The command $test_cmds is almost too long, add a 8438228692Sdes # command to the queue. 8439228692Sdes if test "$k" -eq 1 ; then 8440228692Sdes # The first file doesn't have a previous command to add. 8441228692Sdes reload_objs=$objlist 8442228692Sdes eval concat_cmds=\"$reload_cmds\" 8443228692Sdes else 8444228692Sdes # All subsequent reloadable object files will link in 8445228692Sdes # the last one created. 8446228692Sdes reload_objs="$objlist $last_robj" 8447228692Sdes eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 8448228692Sdes fi 8449228692Sdes last_robj=$output_objdir/$output_la-${k}.$objext 8450228692Sdes func_arith $k + 1 8451228692Sdes k=$func_arith_result 8452228692Sdes output=$output_objdir/$output_la-${k}.$objext 8453228692Sdes objlist=" $obj" 8454228692Sdes func_len " $last_robj" 8455228692Sdes func_arith $len0 + $func_len_result 8456228692Sdes len=$func_arith_result 8457228692Sdes fi 8458228692Sdes done 8459228692Sdes # Handle the remaining objects by creating one last 8460228692Sdes # reloadable object file. All subsequent reloadable object 8461228692Sdes # files will link in the last one created. 8462228692Sdes test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8463228692Sdes reload_objs="$objlist $last_robj" 8464228692Sdes eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 8465228692Sdes if test -n "$last_robj"; then 8466228692Sdes eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8467228692Sdes fi 8468228692Sdes func_append delfiles " $output" 8469228692Sdes 8470141098Sdes else 8471228692Sdes output= 8472228692Sdes fi 8473228692Sdes 8474228692Sdes if ${skipped_export-false}; then 8475228692Sdes func_verbose "generating symbol list for \`$libname.la'" 8476228692Sdes export_symbols="$output_objdir/$libname.exp" 8477228692Sdes $opt_dry_run || $RM $export_symbols 8478228692Sdes libobjs=$output 8479228692Sdes # Append the command to create the export file. 8480228692Sdes test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8481228692Sdes eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 8482228692Sdes if test -n "$last_robj"; then 8483228692Sdes eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8484125647Sdes fi 8485141098Sdes fi 8486141098Sdes 8487228692Sdes test -n "$save_libobjs" && 8488228692Sdes func_verbose "creating a temporary reloadable object file: $output" 8489141098Sdes 8490228692Sdes # Loop through the commands generated above and execute them. 8491228692Sdes save_ifs="$IFS"; IFS='~' 8492228692Sdes for cmd in $concat_cmds; do 8493228692Sdes IFS="$save_ifs" 8494228692Sdes $opt_silent || { 8495228692Sdes func_quote_for_expand "$cmd" 8496228692Sdes eval "func_echo $func_quote_for_expand_result" 8497228692Sdes } 8498228692Sdes $opt_dry_run || eval "$cmd" || { 8499228692Sdes lt_exit=$? 8500141098Sdes 8501228692Sdes # Restore the uninstalled library and exit 8502228692Sdes if test "$opt_mode" = relink; then 8503228692Sdes ( cd "$output_objdir" && \ 8504228692Sdes $RM "${realname}T" && \ 8505228692Sdes $MV "${realname}U" "$realname" ) 8506228692Sdes fi 8507141098Sdes 8508228692Sdes exit $lt_exit 8509228692Sdes } 8510228692Sdes done 8511141098Sdes IFS="$save_ifs" 8512141098Sdes 8513228692Sdes if test -n "$export_symbols_regex" && ${skipped_export-false}; then 8514228692Sdes func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8515228692Sdes func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8516228692Sdes fi 8517228692Sdes fi 8518228692Sdes 8519228692Sdes if ${skipped_export-false}; then 8520228692Sdes if test -n "$export_symbols" && test -n "$include_expsyms"; then 8521228692Sdes tmp_export_symbols="$export_symbols" 8522228692Sdes test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8523228692Sdes $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8524228692Sdes fi 8525228692Sdes 8526228692Sdes if test -n "$orig_export_symbols"; then 8527228692Sdes # The given exports_symbols file has to be filtered, so filter it. 8528228692Sdes func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8529228692Sdes # FIXME: $output_objdir/$libname.filter potentially contains lots of 8530228692Sdes # 's' commands which not all seds can handle. GNU sed should be fine 8531228692Sdes # though. Also, the filter scales superlinearly with the number of 8532228692Sdes # global variables. join(1) would be nice here, but unfortunately 8533228692Sdes # isn't a blessed tool. 8534228692Sdes $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8535228692Sdes func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8536228692Sdes export_symbols=$output_objdir/$libname.def 8537228692Sdes $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8538228692Sdes fi 8539228692Sdes fi 8540228692Sdes 8541141098Sdes libobjs=$output 8542141098Sdes # Restore the value of output. 8543141098Sdes output=$save_output 8544141098Sdes 8545141098Sdes if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 8546141098Sdes eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8547228692Sdes test "X$libobjs" = "X " && libobjs= 8548141098Sdes fi 8549141098Sdes # Expand the library linking commands again to reset the 8550141098Sdes # value of $libobjs for piecewise linking. 8551141098Sdes 8552141098Sdes # Do each of the archive commands. 8553141098Sdes if test "$module" = yes && test -n "$module_cmds" ; then 8554141098Sdes if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8555141098Sdes cmds=$module_expsym_cmds 8556141098Sdes else 8557141098Sdes cmds=$module_cmds 8558141098Sdes fi 8559141098Sdes else 8560228692Sdes if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8561228692Sdes cmds=$archive_expsym_cmds 8562228692Sdes else 8563228692Sdes cmds=$archive_cmds 8564141098Sdes fi 8565141098Sdes fi 8566228692Sdes fi 8567141098Sdes 8568228692Sdes if test -n "$delfiles"; then 8569228692Sdes # Append the command to remove temporary files to $cmds. 8570228692Sdes eval cmds=\"\$cmds~\$RM $delfiles\" 8571117610Sdes fi 8572228692Sdes 8573228692Sdes # Add any objects from preloaded convenience libraries 8574228692Sdes if test -n "$dlprefiles"; then 8575228692Sdes gentop="$output_objdir/${outputname}x" 8576228692Sdes func_append generated " $gentop" 8577228692Sdes 8578228692Sdes func_extract_archives $gentop $dlprefiles 8579228692Sdes func_append libobjs " $func_extract_archives_result" 8580228692Sdes test "X$libobjs" = "X " && libobjs= 8581228692Sdes fi 8582228692Sdes 8583125647Sdes save_ifs="$IFS"; IFS='~' 8584117610Sdes for cmd in $cmds; do 8585117610Sdes IFS="$save_ifs" 8586141098Sdes eval cmd=\"$cmd\" 8587228692Sdes $opt_silent || { 8588228692Sdes func_quote_for_expand "$cmd" 8589228692Sdes eval "func_echo $func_quote_for_expand_result" 8590228692Sdes } 8591228692Sdes $opt_dry_run || eval "$cmd" || { 8592174832Sdes lt_exit=$? 8593174832Sdes 8594174832Sdes # Restore the uninstalled library and exit 8595228692Sdes if test "$opt_mode" = relink; then 8596228692Sdes ( cd "$output_objdir" && \ 8597228692Sdes $RM "${realname}T" && \ 8598228692Sdes $MV "${realname}U" "$realname" ) 8599174832Sdes fi 8600174832Sdes 8601174832Sdes exit $lt_exit 8602174832Sdes } 8603117610Sdes done 8604117610Sdes IFS="$save_ifs" 8605117610Sdes 8606125647Sdes # Restore the uninstalled library and exit 8607228692Sdes if test "$opt_mode" = relink; then 8608228692Sdes $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8609174832Sdes 8610174832Sdes if test -n "$convenience"; then 8611174832Sdes if test -z "$whole_archive_flag_spec"; then 8612228692Sdes func_show_eval '${RM}r "$gentop"' 8613174832Sdes fi 8614174832Sdes fi 8615174832Sdes 8616141098Sdes exit $EXIT_SUCCESS 8617125647Sdes fi 8618125647Sdes 8619117610Sdes # Create links to the real library. 8620117610Sdes for linkname in $linknames; do 8621117610Sdes if test "$realname" != "$linkname"; then 8622228692Sdes func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8623117610Sdes fi 8624117610Sdes done 8625117610Sdes 8626117610Sdes # If -module or -export-dynamic was specified, set the dlname. 8627117610Sdes if test "$module" = yes || test "$export_dynamic" = yes; then 8628117610Sdes # On all known operating systems, these are identical. 8629117610Sdes dlname="$soname" 8630117610Sdes fi 8631117610Sdes fi 8632117610Sdes ;; 8633117610Sdes 8634125647Sdes obj) 8635117610Sdes if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 8636228692Sdes func_warning "\`-dlopen' is ignored for objects" 8637117610Sdes fi 8638117610Sdes 8639228692Sdes case " $deplibs" in 8640228692Sdes *\ -l* | *\ -L*) 8641228692Sdes func_warning "\`-l' and \`-L' are ignored for objects" ;; 8642228692Sdes esac 8643117610Sdes 8644228692Sdes test -n "$rpath" && \ 8645228692Sdes func_warning "\`-rpath' is ignored for objects" 8646117610Sdes 8647228692Sdes test -n "$xrpath" && \ 8648228692Sdes func_warning "\`-R' is ignored for objects" 8649117610Sdes 8650228692Sdes test -n "$vinfo" && \ 8651228692Sdes func_warning "\`-version-info' is ignored for objects" 8652117610Sdes 8653228692Sdes test -n "$release" && \ 8654228692Sdes func_warning "\`-release' is ignored for objects" 8655228692Sdes 8656125647Sdes case $output in 8657117610Sdes *.lo) 8658228692Sdes test -n "$objs$old_deplibs" && \ 8659228692Sdes func_fatal_error "cannot build library object \`$output' from non-libtool objects" 8660228692Sdes 8661228692Sdes libobj=$output 8662228692Sdes func_lo2o "$libobj" 8663228692Sdes obj=$func_lo2o_result 8664117610Sdes ;; 8665117610Sdes *) 8666117610Sdes libobj= 8667117610Sdes obj="$output" 8668117610Sdes ;; 8669117610Sdes esac 8670117610Sdes 8671117610Sdes # Delete the old objects. 8672228692Sdes $opt_dry_run || $RM $obj $libobj 8673117610Sdes 8674117610Sdes # Objects from convenience libraries. This assumes 8675117610Sdes # single-version convenience libraries. Whenever we create 8676117610Sdes # different ones for PIC/non-PIC, this we'll have to duplicate 8677117610Sdes # the extraction. 8678117610Sdes reload_conv_objs= 8679117610Sdes gentop= 8680117610Sdes # reload_cmds runs $LD directly, so let us get rid of 8681174832Sdes # -Wl from whole_archive_flag_spec and hope we can get by with 8682174832Sdes # turning comma into space.. 8683125647Sdes wl= 8684117610Sdes 8685117610Sdes if test -n "$convenience"; then 8686117610Sdes if test -n "$whole_archive_flag_spec"; then 8687174832Sdes eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 8688228692Sdes reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 8689117610Sdes else 8690117610Sdes gentop="$output_objdir/${obj}x" 8691228692Sdes func_append generated " $gentop" 8692117610Sdes 8693141098Sdes func_extract_archives $gentop $convenience 8694141098Sdes reload_conv_objs="$reload_objs $func_extract_archives_result" 8695117610Sdes fi 8696117610Sdes fi 8697117610Sdes 8698228692Sdes # If we're not building shared, we need to use non_pic_objs 8699228692Sdes test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8700228692Sdes 8701117610Sdes # Create the old-style object. 8702228692Sdes reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8703117610Sdes 8704117610Sdes output="$obj" 8705228692Sdes func_execute_cmds "$reload_cmds" 'exit $?' 8706117610Sdes 8707117610Sdes # Exit if we aren't doing a library object file. 8708117610Sdes if test -z "$libobj"; then 8709117610Sdes if test -n "$gentop"; then 8710228692Sdes func_show_eval '${RM}r "$gentop"' 8711117610Sdes fi 8712117610Sdes 8713141098Sdes exit $EXIT_SUCCESS 8714117610Sdes fi 8715117610Sdes 8716117610Sdes if test "$build_libtool_libs" != yes; then 8717117610Sdes if test -n "$gentop"; then 8718228692Sdes func_show_eval '${RM}r "$gentop"' 8719117610Sdes fi 8720117610Sdes 8721117610Sdes # Create an invalid libtool object if no PIC, so that we don't 8722117610Sdes # accidentally link it into a program. 8723141098Sdes # $show "echo timestamp > $libobj" 8724228692Sdes # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 8725141098Sdes exit $EXIT_SUCCESS 8726117610Sdes fi 8727117610Sdes 8728125647Sdes if test -n "$pic_flag" || test "$pic_mode" != default; then 8729117610Sdes # Only do commands if we really have different PIC objects. 8730117610Sdes reload_objs="$libobjs $reload_conv_objs" 8731117610Sdes output="$libobj" 8732228692Sdes func_execute_cmds "$reload_cmds" 'exit $?' 8733117610Sdes fi 8734117610Sdes 8735117610Sdes if test -n "$gentop"; then 8736228692Sdes func_show_eval '${RM}r "$gentop"' 8737117610Sdes fi 8738117610Sdes 8739141098Sdes exit $EXIT_SUCCESS 8740117610Sdes ;; 8741117610Sdes 8742125647Sdes prog) 8743125647Sdes case $host in 8744228692Sdes *cygwin*) func_stripname '' '.exe' "$output" 8745228692Sdes output=$func_stripname_result.exe;; 8746125647Sdes esac 8747228692Sdes test -n "$vinfo" && \ 8748228692Sdes func_warning "\`-version-info' is ignored for programs" 8749117610Sdes 8750228692Sdes test -n "$release" && \ 8751228692Sdes func_warning "\`-release' is ignored for programs" 8752117610Sdes 8753228692Sdes test "$preload" = yes \ 8754228692Sdes && test "$dlopen_support" = unknown \ 8755228692Sdes && test "$dlopen_self" = unknown \ 8756228692Sdes && test "$dlopen_self_static" = unknown && \ 8757228692Sdes func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 8758125647Sdes 8759125647Sdes case $host in 8760125647Sdes *-*-rhapsody* | *-*-darwin1.[012]) 8761125647Sdes # On Rhapsody replace the C library is the System framework 8762228692Sdes compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 8763228692Sdes finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8764125647Sdes ;; 8765125647Sdes esac 8766125647Sdes 8767141098Sdes case $host in 8768228692Sdes *-*-darwin*) 8769228692Sdes # Don't allow lazy linking, it breaks C++ global constructors 8770228692Sdes # But is supposedly fixed on 10.4 or later (yay!). 8771228692Sdes if test "$tagname" = CXX ; then 8772228692Sdes case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 8773228692Sdes 10.[0123]) 8774228692Sdes func_append compile_command " ${wl}-bind_at_load" 8775228692Sdes func_append finalize_command " ${wl}-bind_at_load" 8776228692Sdes ;; 8777228692Sdes esac 8778228692Sdes fi 8779228692Sdes # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8780228692Sdes compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8781228692Sdes finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8782228692Sdes ;; 8783141098Sdes esac 8784141098Sdes 8785174832Sdes 8786174832Sdes # move library search paths that coincide with paths to not yet 8787174832Sdes # installed libraries to the beginning of the library search list 8788174832Sdes new_libs= 8789174832Sdes for path in $notinst_path; do 8790174832Sdes case " $new_libs " in 8791174832Sdes *" -L$path/$objdir "*) ;; 8792174832Sdes *) 8793174832Sdes case " $compile_deplibs " in 8794174832Sdes *" -L$path/$objdir "*) 8795228692Sdes func_append new_libs " -L$path/$objdir" ;; 8796174832Sdes esac 8797174832Sdes ;; 8798174832Sdes esac 8799174832Sdes done 8800174832Sdes for deplib in $compile_deplibs; do 8801174832Sdes case $deplib in 8802174832Sdes -L*) 8803174832Sdes case " $new_libs " in 8804174832Sdes *" $deplib "*) ;; 8805228692Sdes *) func_append new_libs " $deplib" ;; 8806174832Sdes esac 8807174832Sdes ;; 8808228692Sdes *) func_append new_libs " $deplib" ;; 8809174832Sdes esac 8810174832Sdes done 8811174832Sdes compile_deplibs="$new_libs" 8812174832Sdes 8813174832Sdes 8814228692Sdes func_append compile_command " $compile_deplibs" 8815228692Sdes func_append finalize_command " $finalize_deplibs" 8816125647Sdes 8817117610Sdes if test -n "$rpath$xrpath"; then 8818117610Sdes # If the user specified any rpath flags, then add them. 8819117610Sdes for libdir in $rpath $xrpath; do 8820117610Sdes # This is the magic to use -rpath. 8821117610Sdes case "$finalize_rpath " in 8822117610Sdes *" $libdir "*) ;; 8823228692Sdes *) func_append finalize_rpath " $libdir" ;; 8824117610Sdes esac 8825117610Sdes done 8826117610Sdes fi 8827117610Sdes 8828117610Sdes # Now hardcode the library paths 8829117610Sdes rpath= 8830117610Sdes hardcode_libdirs= 8831117610Sdes for libdir in $compile_rpath $finalize_rpath; do 8832117610Sdes if test -n "$hardcode_libdir_flag_spec"; then 8833117610Sdes if test -n "$hardcode_libdir_separator"; then 8834117610Sdes if test -z "$hardcode_libdirs"; then 8835117610Sdes hardcode_libdirs="$libdir" 8836117610Sdes else 8837117610Sdes # Just accumulate the unique libdirs. 8838125647Sdes case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8839117610Sdes *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8840117610Sdes ;; 8841117610Sdes *) 8842228692Sdes func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8843117610Sdes ;; 8844117610Sdes esac 8845117610Sdes fi 8846117610Sdes else 8847117610Sdes eval flag=\"$hardcode_libdir_flag_spec\" 8848228692Sdes func_append rpath " $flag" 8849117610Sdes fi 8850117610Sdes elif test -n "$runpath_var"; then 8851117610Sdes case "$perm_rpath " in 8852117610Sdes *" $libdir "*) ;; 8853228692Sdes *) func_append perm_rpath " $libdir" ;; 8854117610Sdes esac 8855117610Sdes fi 8856125647Sdes case $host in 8857228692Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 8858228692Sdes testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 8859125647Sdes case :$dllsearchpath: in 8860125647Sdes *":$libdir:"*) ;; 8861228692Sdes ::) dllsearchpath=$libdir;; 8862228692Sdes *) func_append dllsearchpath ":$libdir";; 8863125647Sdes esac 8864174832Sdes case :$dllsearchpath: in 8865174832Sdes *":$testbindir:"*) ;; 8866228692Sdes ::) dllsearchpath=$testbindir;; 8867228692Sdes *) func_append dllsearchpath ":$testbindir";; 8868174832Sdes esac 8869125647Sdes ;; 8870125647Sdes esac 8871117610Sdes done 8872117610Sdes # Substitute the hardcoded libdirs into the rpath. 8873117610Sdes if test -n "$hardcode_libdir_separator" && 8874117610Sdes test -n "$hardcode_libdirs"; then 8875117610Sdes libdir="$hardcode_libdirs" 8876117610Sdes eval rpath=\" $hardcode_libdir_flag_spec\" 8877117610Sdes fi 8878117610Sdes compile_rpath="$rpath" 8879117610Sdes 8880117610Sdes rpath= 8881117610Sdes hardcode_libdirs= 8882117610Sdes for libdir in $finalize_rpath; do 8883117610Sdes if test -n "$hardcode_libdir_flag_spec"; then 8884117610Sdes if test -n "$hardcode_libdir_separator"; then 8885117610Sdes if test -z "$hardcode_libdirs"; then 8886117610Sdes hardcode_libdirs="$libdir" 8887117610Sdes else 8888117610Sdes # Just accumulate the unique libdirs. 8889125647Sdes case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8890117610Sdes *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8891117610Sdes ;; 8892117610Sdes *) 8893228692Sdes func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8894117610Sdes ;; 8895117610Sdes esac 8896117610Sdes fi 8897117610Sdes else 8898117610Sdes eval flag=\"$hardcode_libdir_flag_spec\" 8899228692Sdes func_append rpath " $flag" 8900117610Sdes fi 8901117610Sdes elif test -n "$runpath_var"; then 8902117610Sdes case "$finalize_perm_rpath " in 8903117610Sdes *" $libdir "*) ;; 8904228692Sdes *) func_append finalize_perm_rpath " $libdir" ;; 8905117610Sdes esac 8906117610Sdes fi 8907117610Sdes done 8908117610Sdes # Substitute the hardcoded libdirs into the rpath. 8909117610Sdes if test -n "$hardcode_libdir_separator" && 8910117610Sdes test -n "$hardcode_libdirs"; then 8911117610Sdes libdir="$hardcode_libdirs" 8912117610Sdes eval rpath=\" $hardcode_libdir_flag_spec\" 8913117610Sdes fi 8914117610Sdes finalize_rpath="$rpath" 8915117610Sdes 8916117610Sdes if test -n "$libobjs" && test "$build_old_libs" = yes; then 8917117610Sdes # Transform all the library objects into standard objects. 8918228692Sdes compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8919228692Sdes finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8920117610Sdes fi 8921117610Sdes 8922228692Sdes func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8923117610Sdes 8924228692Sdes # template prelinking step 8925228692Sdes if test -n "$prelink_cmds"; then 8926228692Sdes func_execute_cmds "$prelink_cmds" 'exit $?' 8927117610Sdes fi 8928117610Sdes 8929228692Sdes wrappers_required=yes 8930228692Sdes case $host in 8931228692Sdes *cegcc* | *mingw32ce*) 8932228692Sdes # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 8933228692Sdes wrappers_required=no 8934228692Sdes ;; 8935228692Sdes *cygwin* | *mingw* ) 8936228692Sdes if test "$build_libtool_libs" != yes; then 8937228692Sdes wrappers_required=no 8938228692Sdes fi 8939228692Sdes ;; 8940228692Sdes *) 8941228692Sdes if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8942228692Sdes wrappers_required=no 8943228692Sdes fi 8944228692Sdes ;; 8945228692Sdes esac 8946228692Sdes if test "$wrappers_required" = no; then 8947117610Sdes # Replace the output file specification. 8948228692Sdes compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8949117610Sdes link_command="$compile_command$compile_rpath" 8950117610Sdes 8951117610Sdes # We have no uninstalled library dependencies, so finalize right now. 8952228692Sdes exit_status=0 8953228692Sdes func_show_eval "$link_command" 'exit_status=$?' 8954125647Sdes 8955228692Sdes if test -n "$postlink_cmds"; then 8956228692Sdes func_to_tool_file "$output" 8957228692Sdes postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8958228692Sdes func_execute_cmds "$postlink_cmds" 'exit $?' 8959228692Sdes fi 8960228692Sdes 8961117610Sdes # Delete the generated files. 8962228692Sdes if test -f "$output_objdir/${outputname}S.${objext}"; then 8963228692Sdes func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8964117610Sdes fi 8965117610Sdes 8966174832Sdes exit $exit_status 8967117610Sdes fi 8968117610Sdes 8969117610Sdes if test -n "$compile_shlibpath$finalize_shlibpath"; then 8970117610Sdes compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 8971117610Sdes fi 8972117610Sdes if test -n "$finalize_shlibpath"; then 8973117610Sdes finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 8974117610Sdes fi 8975117610Sdes 8976117610Sdes compile_var= 8977117610Sdes finalize_var= 8978117610Sdes if test -n "$runpath_var"; then 8979117610Sdes if test -n "$perm_rpath"; then 8980117610Sdes # We should set the runpath_var. 8981117610Sdes rpath= 8982117610Sdes for dir in $perm_rpath; do 8983228692Sdes func_append rpath "$dir:" 8984117610Sdes done 8985117610Sdes compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8986117610Sdes fi 8987117610Sdes if test -n "$finalize_perm_rpath"; then 8988117610Sdes # We should set the runpath_var. 8989117610Sdes rpath= 8990117610Sdes for dir in $finalize_perm_rpath; do 8991228692Sdes func_append rpath "$dir:" 8992117610Sdes done 8993117610Sdes finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8994117610Sdes fi 8995117610Sdes fi 8996117610Sdes 8997125647Sdes if test "$no_install" = yes; then 8998125647Sdes # We don't need to create a wrapper script. 8999125647Sdes link_command="$compile_var$compile_command$compile_rpath" 9000125647Sdes # Replace the output file specification. 9001228692Sdes link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 9002125647Sdes # Delete the old output file. 9003228692Sdes $opt_dry_run || $RM $output 9004125647Sdes # Link the executable and exit 9005228692Sdes func_show_eval "$link_command" 'exit $?' 9006228692Sdes 9007228692Sdes if test -n "$postlink_cmds"; then 9008228692Sdes func_to_tool_file "$output" 9009228692Sdes postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 9010228692Sdes func_execute_cmds "$postlink_cmds" 'exit $?' 9011228692Sdes fi 9012228692Sdes 9013141098Sdes exit $EXIT_SUCCESS 9014125647Sdes fi 9015125647Sdes 9016117610Sdes if test "$hardcode_action" = relink; then 9017117610Sdes # Fast installation is not supported 9018117610Sdes link_command="$compile_var$compile_command$compile_rpath" 9019117610Sdes relink_command="$finalize_var$finalize_command$finalize_rpath" 9020125647Sdes 9021228692Sdes func_warning "this platform does not like uninstalled shared libraries" 9022228692Sdes func_warning "\`$output' will be relinked during installation" 9023117610Sdes else 9024117610Sdes if test "$fast_install" != no; then 9025117610Sdes link_command="$finalize_var$compile_command$finalize_rpath" 9026117610Sdes if test "$fast_install" = yes; then 9027228692Sdes relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 9028117610Sdes else 9029117610Sdes # fast_install is set to needless 9030117610Sdes relink_command= 9031117610Sdes fi 9032117610Sdes else 9033117610Sdes link_command="$compile_var$compile_command$compile_rpath" 9034117610Sdes relink_command="$finalize_var$finalize_command$finalize_rpath" 9035117610Sdes fi 9036117610Sdes fi 9037117610Sdes 9038117610Sdes # Replace the output file specification. 9039228692Sdes link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 9040125647Sdes 9041117610Sdes # Delete the old output files. 9042228692Sdes $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 9043117610Sdes 9044228692Sdes func_show_eval "$link_command" 'exit $?' 9045117610Sdes 9046228692Sdes if test -n "$postlink_cmds"; then 9047228692Sdes func_to_tool_file "$output_objdir/$outputname" 9048228692Sdes postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 9049228692Sdes func_execute_cmds "$postlink_cmds" 'exit $?' 9050228692Sdes fi 9051228692Sdes 9052117610Sdes # Now create the wrapper script. 9053228692Sdes func_verbose "creating $output" 9054117610Sdes 9055117610Sdes # Quote the relink command for shipping. 9056117610Sdes if test -n "$relink_command"; then 9057125647Sdes # Preserve any variables that may affect compiler behavior 9058125647Sdes for var in $variables_saved_for_relink; do 9059125647Sdes if eval test -z \"\${$var+set}\"; then 9060228692Sdes relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9061125647Sdes elif eval var_value=\$$var; test -z "$var_value"; then 9062125647Sdes relink_command="$var=; export $var; $relink_command" 9063125647Sdes else 9064228692Sdes func_quote_for_eval "$var_value" 9065228692Sdes relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9066125647Sdes fi 9067125647Sdes done 9068125647Sdes relink_command="(cd `pwd`; $relink_command)" 9069228692Sdes relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9070117610Sdes fi 9071117610Sdes 9072228692Sdes # Only actually do things if not in dry run mode. 9073228692Sdes $opt_dry_run || { 9074117610Sdes # win32 will think the script is a binary if it has 9075117610Sdes # a .exe suffix, so we strip it off here. 9076117610Sdes case $output in 9077228692Sdes *.exe) func_stripname '' '.exe' "$output" 9078228692Sdes output=$func_stripname_result ;; 9079117610Sdes esac 9080125647Sdes # test for cygwin because mv fails w/o .exe extensions 9081125647Sdes case $host in 9082141098Sdes *cygwin*) 9083141098Sdes exeext=.exe 9084228692Sdes func_stripname '' '.exe' "$outputname" 9085228692Sdes outputname=$func_stripname_result ;; 9086125647Sdes *) exeext= ;; 9087125647Sdes esac 9088141098Sdes case $host in 9089141098Sdes *cygwin* | *mingw* ) 9090228692Sdes func_dirname_and_basename "$output" "" "." 9091228692Sdes output_name=$func_basename_result 9092228692Sdes output_path=$func_dirname_result 9093228692Sdes cwrappersource="$output_path/$objdir/lt-$output_name.c" 9094228692Sdes cwrapper="$output_path/$output_name.exe" 9095228692Sdes $RM $cwrappersource $cwrapper 9096228692Sdes trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 9097141098Sdes 9098228692Sdes func_emit_cwrapperexe_src > $cwrappersource 9099141098Sdes 9100228692Sdes # The wrapper executable is built using the $host compiler, 9101228692Sdes # because it contains $host paths and files. If cross- 9102228692Sdes # compiling, it, like the target executable, must be 9103228692Sdes # executed on the $host or under an emulation environment. 9104228692Sdes $opt_dry_run || { 9105228692Sdes $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 9106228692Sdes $STRIP $cwrapper 9107228692Sdes } 9108141098Sdes 9109228692Sdes # Now, create the wrapper script for func_source use: 9110228692Sdes func_ltwrapper_scriptname $cwrapper 9111228692Sdes $RM $func_ltwrapper_scriptname_result 9112228692Sdes trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 9113228692Sdes $opt_dry_run || { 9114228692Sdes # note: this script will not be executed, so do not chmod. 9115228692Sdes if test "x$build" = "x$host" ; then 9116228692Sdes $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 9117228692Sdes else 9118228692Sdes func_emit_wrapper no > $func_ltwrapper_scriptname_result 9119228692Sdes fi 9120228692Sdes } 9121117610Sdes ;; 9122228692Sdes * ) 9123228692Sdes $RM $output 9124228692Sdes trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9125117610Sdes 9126228692Sdes func_emit_wrapper no > $output 9127228692Sdes chmod +x $output 9128117610Sdes ;; 9129117610Sdes esac 9130228692Sdes } 9131141098Sdes exit $EXIT_SUCCESS 9132117610Sdes ;; 9133117610Sdes esac 9134117610Sdes 9135117610Sdes # See if we need to build an old-fashioned archive. 9136117610Sdes for oldlib in $oldlibs; do 9137117610Sdes 9138117610Sdes if test "$build_libtool_libs" = convenience; then 9139228692Sdes oldobjs="$libobjs_save $symfileobj" 9140117610Sdes addlibs="$convenience" 9141117610Sdes build_libtool_libs=no 9142117610Sdes else 9143117610Sdes if test "$build_libtool_libs" = module; then 9144117610Sdes oldobjs="$libobjs_save" 9145117610Sdes build_libtool_libs=no 9146117610Sdes else 9147141098Sdes oldobjs="$old_deplibs $non_pic_objects" 9148228692Sdes if test "$preload" = yes && test -f "$symfileobj"; then 9149228692Sdes func_append oldobjs " $symfileobj" 9150228692Sdes fi 9151117610Sdes fi 9152117610Sdes addlibs="$old_convenience" 9153117610Sdes fi 9154117610Sdes 9155117610Sdes if test -n "$addlibs"; then 9156117610Sdes gentop="$output_objdir/${outputname}x" 9157228692Sdes func_append generated " $gentop" 9158125647Sdes 9159141098Sdes func_extract_archives $gentop $addlibs 9160228692Sdes func_append oldobjs " $func_extract_archives_result" 9161117610Sdes fi 9162117610Sdes 9163117610Sdes # Do each command in the archive commands. 9164117610Sdes if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 9165228692Sdes cmds=$old_archive_from_new_cmds 9166117610Sdes else 9167228692Sdes 9168228692Sdes # Add any objects from preloaded convenience libraries 9169228692Sdes if test -n "$dlprefiles"; then 9170228692Sdes gentop="$output_objdir/${outputname}x" 9171228692Sdes func_append generated " $gentop" 9172228692Sdes 9173228692Sdes func_extract_archives $gentop $dlprefiles 9174228692Sdes func_append oldobjs " $func_extract_archives_result" 9175228692Sdes fi 9176228692Sdes 9177174832Sdes # POSIX demands no paths to be encoded in archives. We have 9178174832Sdes # to avoid creating archives with duplicate basenames if we 9179174832Sdes # might have to extract them afterwards, e.g., when creating a 9180174832Sdes # static archive out of a convenience library, or when linking 9181174832Sdes # the entirety of a libtool archive into another (currently 9182174832Sdes # not supported by libtool). 9183174832Sdes if (for obj in $oldobjs 9184174832Sdes do 9185228692Sdes func_basename "$obj" 9186228692Sdes $ECHO "$func_basename_result" 9187174832Sdes done | sort | sort -uc >/dev/null 2>&1); then 9188174832Sdes : 9189174832Sdes else 9190228692Sdes echo "copying selected object files to avoid basename conflicts..." 9191228692Sdes gentop="$output_objdir/${outputname}x" 9192228692Sdes func_append generated " $gentop" 9193228692Sdes func_mkdir_p "$gentop" 9194174832Sdes save_oldobjs=$oldobjs 9195174832Sdes oldobjs= 9196174832Sdes counter=1 9197174832Sdes for obj in $save_oldobjs 9198174832Sdes do 9199228692Sdes func_basename "$obj" 9200228692Sdes objbase="$func_basename_result" 9201174832Sdes case " $oldobjs " in 9202174832Sdes " ") oldobjs=$obj ;; 9203174832Sdes *[\ /]"$objbase "*) 9204174832Sdes while :; do 9205174832Sdes # Make sure we don't pick an alternate name that also 9206174832Sdes # overlaps. 9207174832Sdes newobj=lt$counter-$objbase 9208228692Sdes func_arith $counter + 1 9209228692Sdes counter=$func_arith_result 9210174832Sdes case " $oldobjs " in 9211174832Sdes *[\ /]"$newobj "*) ;; 9212174832Sdes *) if test ! -f "$gentop/$newobj"; then break; fi ;; 9213174832Sdes esac 9214174832Sdes done 9215228692Sdes func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 9216228692Sdes func_append oldobjs " $gentop/$newobj" 9217174832Sdes ;; 9218228692Sdes *) func_append oldobjs " $obj" ;; 9219174832Sdes esac 9220174832Sdes done 9221174832Sdes fi 9222236109Sdes func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 9223236109Sdes tool_oldlib=$func_to_tool_file_result 9224141098Sdes eval cmds=\"$old_archive_cmds\" 9225141098Sdes 9226228692Sdes func_len " $cmds" 9227228692Sdes len=$func_len_result 9228228692Sdes if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9229141098Sdes cmds=$old_archive_cmds 9230228692Sdes elif test -n "$archiver_list_spec"; then 9231228692Sdes func_verbose "using command file archive linking..." 9232228692Sdes for obj in $oldobjs 9233228692Sdes do 9234228692Sdes func_to_tool_file "$obj" 9235228692Sdes $ECHO "$func_to_tool_file_result" 9236228692Sdes done > $output_objdir/$libname.libcmd 9237228692Sdes func_to_tool_file "$output_objdir/$libname.libcmd" 9238228692Sdes oldobjs=" $archiver_list_spec$func_to_tool_file_result" 9239228692Sdes cmds=$old_archive_cmds 9240141098Sdes else 9241141098Sdes # the command line is too long to link in one step, link in parts 9242228692Sdes func_verbose "using piecewise archive linking..." 9243141098Sdes save_RANLIB=$RANLIB 9244141098Sdes RANLIB=: 9245141098Sdes objlist= 9246141098Sdes concat_cmds= 9247141098Sdes save_oldobjs=$oldobjs 9248228692Sdes oldobjs= 9249141098Sdes # Is there a better way of finding the last object in the list? 9250141098Sdes for obj in $save_oldobjs 9251141098Sdes do 9252141098Sdes last_oldobj=$obj 9253141098Sdes done 9254228692Sdes eval test_cmds=\"$old_archive_cmds\" 9255228692Sdes func_len " $test_cmds" 9256228692Sdes len0=$func_len_result 9257228692Sdes len=$len0 9258141098Sdes for obj in $save_oldobjs 9259141098Sdes do 9260228692Sdes func_len " $obj" 9261228692Sdes func_arith $len + $func_len_result 9262228692Sdes len=$func_arith_result 9263228692Sdes func_append objlist " $obj" 9264228692Sdes if test "$len" -lt "$max_cmd_len"; then 9265141098Sdes : 9266117610Sdes else 9267141098Sdes # the above command should be used before it gets too long 9268141098Sdes oldobjs=$objlist 9269141098Sdes if test "$obj" = "$last_oldobj" ; then 9270228692Sdes RANLIB=$save_RANLIB 9271141098Sdes fi 9272141098Sdes test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9273141098Sdes eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 9274141098Sdes objlist= 9275228692Sdes len=$len0 9276117610Sdes fi 9277141098Sdes done 9278141098Sdes RANLIB=$save_RANLIB 9279141098Sdes oldobjs=$objlist 9280141098Sdes if test "X$oldobjs" = "X" ; then 9281141098Sdes eval cmds=\"\$concat_cmds\" 9282141098Sdes else 9283141098Sdes eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 9284117610Sdes fi 9285141098Sdes fi 9286117610Sdes fi 9287228692Sdes func_execute_cmds "$cmds" 'exit $?' 9288117610Sdes done 9289117610Sdes 9290228692Sdes test -n "$generated" && \ 9291228692Sdes func_show_eval "${RM}r$generated" 9292117610Sdes 9293117610Sdes # Now create the libtool archive. 9294125647Sdes case $output in 9295117610Sdes *.la) 9296117610Sdes old_library= 9297117610Sdes test "$build_old_libs" = yes && old_library="$libname.$libext" 9298228692Sdes func_verbose "creating $output" 9299117610Sdes 9300125647Sdes # Preserve any variables that may affect compiler behavior 9301125647Sdes for var in $variables_saved_for_relink; do 9302125647Sdes if eval test -z \"\${$var+set}\"; then 9303228692Sdes relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9304125647Sdes elif eval var_value=\$$var; test -z "$var_value"; then 9305125647Sdes relink_command="$var=; export $var; $relink_command" 9306125647Sdes else 9307228692Sdes func_quote_for_eval "$var_value" 9308228692Sdes relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9309125647Sdes fi 9310125647Sdes done 9311125647Sdes # Quote the link command for shipping. 9312141098Sdes relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 9313228692Sdes relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9314141098Sdes if test "$hardcode_automatic" = yes ; then 9315141098Sdes relink_command= 9316141098Sdes fi 9317117610Sdes 9318117610Sdes # Only create the output if not a dry run. 9319228692Sdes $opt_dry_run || { 9320117610Sdes for installed in no yes; do 9321117610Sdes if test "$installed" = yes; then 9322117610Sdes if test -z "$install_libdir"; then 9323117610Sdes break 9324117610Sdes fi 9325117610Sdes output="$output_objdir/$outputname"i 9326125647Sdes # Replace all uninstalled libtool libraries with the installed ones 9327125647Sdes newdependency_libs= 9328125647Sdes for deplib in $dependency_libs; do 9329125647Sdes case $deplib in 9330125647Sdes *.la) 9331228692Sdes func_basename "$deplib" 9332228692Sdes name="$func_basename_result" 9333236109Sdes func_resolve_sysroot "$deplib" 9334236109Sdes eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 9335228692Sdes test -z "$libdir" && \ 9336228692Sdes func_fatal_error "\`$deplib' is not a valid libtool archive" 9337228692Sdes func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 9338125647Sdes ;; 9339228692Sdes -L*) 9340228692Sdes func_stripname -L '' "$deplib" 9341228692Sdes func_replace_sysroot "$func_stripname_result" 9342228692Sdes func_append newdependency_libs " -L$func_replace_sysroot_result" 9343228692Sdes ;; 9344228692Sdes -R*) 9345228692Sdes func_stripname -R '' "$deplib" 9346228692Sdes func_replace_sysroot "$func_stripname_result" 9347228692Sdes func_append newdependency_libs " -R$func_replace_sysroot_result" 9348228692Sdes ;; 9349228692Sdes *) func_append newdependency_libs " $deplib" ;; 9350125647Sdes esac 9351125647Sdes done 9352125647Sdes dependency_libs="$newdependency_libs" 9353125647Sdes newdlfiles= 9354228692Sdes 9355125647Sdes for lib in $dlfiles; do 9356228692Sdes case $lib in 9357228692Sdes *.la) 9358228692Sdes func_basename "$lib" 9359228692Sdes name="$func_basename_result" 9360228692Sdes eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9361228692Sdes test -z "$libdir" && \ 9362228692Sdes func_fatal_error "\`$lib' is not a valid libtool archive" 9363228692Sdes func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 9364228692Sdes ;; 9365228692Sdes *) func_append newdlfiles " $lib" ;; 9366228692Sdes esac 9367125647Sdes done 9368125647Sdes dlfiles="$newdlfiles" 9369125647Sdes newdlprefiles= 9370125647Sdes for lib in $dlprefiles; do 9371228692Sdes case $lib in 9372228692Sdes *.la) 9373228692Sdes # Only pass preopened files to the pseudo-archive (for 9374228692Sdes # eventual linking with the app. that links it) if we 9375228692Sdes # didn't already link the preopened objects directly into 9376228692Sdes # the library: 9377228692Sdes func_basename "$lib" 9378228692Sdes name="$func_basename_result" 9379228692Sdes eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9380228692Sdes test -z "$libdir" && \ 9381228692Sdes func_fatal_error "\`$lib' is not a valid libtool archive" 9382228692Sdes func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 9383228692Sdes ;; 9384228692Sdes esac 9385125647Sdes done 9386125647Sdes dlprefiles="$newdlprefiles" 9387141098Sdes else 9388141098Sdes newdlfiles= 9389141098Sdes for lib in $dlfiles; do 9390141098Sdes case $lib in 9391141098Sdes [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9392141098Sdes *) abs=`pwd`"/$lib" ;; 9393141098Sdes esac 9394228692Sdes func_append newdlfiles " $abs" 9395141098Sdes done 9396141098Sdes dlfiles="$newdlfiles" 9397141098Sdes newdlprefiles= 9398141098Sdes for lib in $dlprefiles; do 9399141098Sdes case $lib in 9400141098Sdes [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9401141098Sdes *) abs=`pwd`"/$lib" ;; 9402141098Sdes esac 9403228692Sdes func_append newdlprefiles " $abs" 9404141098Sdes done 9405141098Sdes dlprefiles="$newdlprefiles" 9406117610Sdes fi 9407228692Sdes $RM $output 9408125647Sdes # place dlname in correct position for cygwin 9409228692Sdes # In fact, it would be nice if we could use this code for all target 9410228692Sdes # systems that can't hard-code library paths into their executables 9411228692Sdes # and that have no shared library path variable independent of PATH, 9412228692Sdes # but it turns out we can't easily determine that from inspecting 9413228692Sdes # libtool variables, so we have to hard-code the OSs to which it 9414228692Sdes # applies here; at the moment, that means platforms that use the PE 9415228692Sdes # object format with DLL files. See the long comment at the top of 9416228692Sdes # tests/bindir.at for full details. 9417125647Sdes tdlname=$dlname 9418125647Sdes case $host,$output,$installed,$module,$dlname in 9419228692Sdes *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 9420228692Sdes # If a -bindir argument was supplied, place the dll there. 9421228692Sdes if test "x$bindir" != x ; 9422228692Sdes then 9423228692Sdes func_relative_path "$install_libdir" "$bindir" 9424228692Sdes tdlname=$func_relative_path_result$dlname 9425228692Sdes else 9426228692Sdes # Otherwise fall back on heuristic. 9427228692Sdes tdlname=../bin/$dlname 9428228692Sdes fi 9429228692Sdes ;; 9430125647Sdes esac 9431228692Sdes $ECHO > $output "\ 9432117610Sdes# $outputname - a libtool library file 9433228692Sdes# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 9434117610Sdes# 9435117610Sdes# Please DO NOT delete this file! 9436117610Sdes# It is necessary for linking the library. 9437117610Sdes 9438117610Sdes# The name that we can dlopen(3). 9439125647Sdesdlname='$tdlname' 9440117610Sdes 9441117610Sdes# Names of this library. 9442117610Sdeslibrary_names='$library_names' 9443117610Sdes 9444117610Sdes# The name of the static archive. 9445117610Sdesold_library='$old_library' 9446117610Sdes 9447228692Sdes# Linker flags that can not go in dependency_libs. 9448228692Sdesinherited_linker_flags='$new_inherited_linker_flags' 9449228692Sdes 9450117610Sdes# Libraries that this one depends upon. 9451117610Sdesdependency_libs='$dependency_libs' 9452117610Sdes 9453228692Sdes# Names of additional weak libraries provided by this library 9454228692Sdesweak_library_names='$weak_libs' 9455228692Sdes 9456117610Sdes# Version information for $libname. 9457117610Sdescurrent=$current 9458117610Sdesage=$age 9459117610Sdesrevision=$revision 9460117610Sdes 9461117610Sdes# Is this an already installed library? 9462117610Sdesinstalled=$installed 9463117610Sdes 9464141098Sdes# Should we warn about portability when linking against -modules? 9465141098Sdesshouldnotlink=$module 9466141098Sdes 9467125647Sdes# Files to dlopen/dlpreopen 9468125647Sdesdlopen='$dlfiles' 9469125647Sdesdlpreopen='$dlprefiles' 9470125647Sdes 9471117610Sdes# Directory that this library needs to be installed in: 9472125647Sdeslibdir='$install_libdir'" 9473141098Sdes if test "$installed" = no && test "$need_relink" = yes; then 9474228692Sdes $ECHO >> $output "\ 9475125647Sdesrelink_command=\"$relink_command\"" 9476125647Sdes fi 9477117610Sdes done 9478228692Sdes } 9479117610Sdes 9480117610Sdes # Do a symbolic link so that the libtool archive can be found in 9481117610Sdes # LD_LIBRARY_PATH before the program is installed. 9482228692Sdes func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 9483117610Sdes ;; 9484117610Sdes esac 9485141098Sdes exit $EXIT_SUCCESS 9486228692Sdes} 9487117610Sdes 9488228692Sdes{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 9489228692Sdes func_mode_link ${1+"$@"} 9490117610Sdes 9491117610Sdes 9492228692Sdes# func_mode_uninstall arg... 9493228692Sdesfunc_mode_uninstall () 9494228692Sdes{ 9495228692Sdes $opt_debug 9496228692Sdes RM="$nonopt" 9497117610Sdes files= 9498125647Sdes rmforce= 9499125647Sdes exit_status=0 9500117610Sdes 9501125647Sdes # This variable tells wrapper scripts just to set variables rather 9502125647Sdes # than running their programs. 9503125647Sdes libtool_install_magic="$magic" 9504125647Sdes 9505117610Sdes for arg 9506117610Sdes do 9507125647Sdes case $arg in 9508228692Sdes -f) func_append RM " $arg"; rmforce=yes ;; 9509228692Sdes -*) func_append RM " $arg" ;; 9510228692Sdes *) func_append files " $arg" ;; 9511117610Sdes esac 9512117610Sdes done 9513117610Sdes 9514228692Sdes test -z "$RM" && \ 9515228692Sdes func_fatal_help "you must specify an RM program" 9516117610Sdes 9517125647Sdes rmdirs= 9518125647Sdes 9519117610Sdes for file in $files; do 9520228692Sdes func_dirname "$file" "" "." 9521228692Sdes dir="$func_dirname_result" 9522228692Sdes if test "X$dir" = X.; then 9523228692Sdes odir="$objdir" 9524125647Sdes else 9525228692Sdes odir="$dir/$objdir" 9526125647Sdes fi 9527228692Sdes func_basename "$file" 9528228692Sdes name="$func_basename_result" 9529228692Sdes test "$opt_mode" = uninstall && odir="$dir" 9530117610Sdes 9531228692Sdes # Remember odir for removal later, being careful to avoid duplicates 9532228692Sdes if test "$opt_mode" = clean; then 9533125647Sdes case " $rmdirs " in 9534228692Sdes *" $odir "*) ;; 9535228692Sdes *) func_append rmdirs " $odir" ;; 9536125647Sdes esac 9537125647Sdes fi 9538125647Sdes 9539125647Sdes # Don't error if the file doesn't exist and rm -f was used. 9540228692Sdes if { test -L "$file"; } >/dev/null 2>&1 || 9541228692Sdes { test -h "$file"; } >/dev/null 2>&1 || 9542228692Sdes test -f "$file"; then 9543125647Sdes : 9544125647Sdes elif test -d "$file"; then 9545125647Sdes exit_status=1 9546125647Sdes continue 9547125647Sdes elif test "$rmforce" = yes; then 9548125647Sdes continue 9549125647Sdes fi 9550125647Sdes 9551117610Sdes rmfiles="$file" 9552117610Sdes 9553125647Sdes case $name in 9554117610Sdes *.la) 9555117610Sdes # Possibly a libtool archive, so verify it. 9556228692Sdes if func_lalib_p "$file"; then 9557228692Sdes func_source $dir/$name 9558117610Sdes 9559117610Sdes # Delete the libtool libraries and symlinks. 9560117610Sdes for n in $library_names; do 9561228692Sdes func_append rmfiles " $odir/$n" 9562117610Sdes done 9563228692Sdes test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9564117610Sdes 9565228692Sdes case "$opt_mode" in 9566174832Sdes clean) 9567228692Sdes case " $library_names " in 9568174832Sdes *" $dlname "*) ;; 9569228692Sdes *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9570174832Sdes esac 9571228692Sdes test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9572174832Sdes ;; 9573174832Sdes uninstall) 9574125647Sdes if test -n "$library_names"; then 9575125647Sdes # Do each command in the postuninstall commands. 9576228692Sdes func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9577125647Sdes fi 9578117610Sdes 9579125647Sdes if test -n "$old_library"; then 9580125647Sdes # Do each command in the old_postuninstall commands. 9581228692Sdes func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9582125647Sdes fi 9583125647Sdes # FIXME: should reinstall the best remaining shared library. 9584174832Sdes ;; 9585174832Sdes esac 9586117610Sdes fi 9587117610Sdes ;; 9588117610Sdes 9589117610Sdes *.lo) 9590141098Sdes # Possibly a libtool object, so verify it. 9591228692Sdes if func_lalib_p "$file"; then 9592141098Sdes 9593141098Sdes # Read the .lo file 9594228692Sdes func_source $dir/$name 9595141098Sdes 9596141098Sdes # Add PIC object to the list of files to remove. 9597228692Sdes if test -n "$pic_object" && 9598228692Sdes test "$pic_object" != none; then 9599228692Sdes func_append rmfiles " $dir/$pic_object" 9600141098Sdes fi 9601141098Sdes 9602141098Sdes # Add non-PIC object to the list of files to remove. 9603228692Sdes if test -n "$non_pic_object" && 9604228692Sdes test "$non_pic_object" != none; then 9605228692Sdes func_append rmfiles " $dir/$non_pic_object" 9606141098Sdes fi 9607117610Sdes fi 9608117610Sdes ;; 9609117610Sdes 9610117610Sdes *) 9611228692Sdes if test "$opt_mode" = clean ; then 9612141098Sdes noexename=$name 9613141098Sdes case $file in 9614141098Sdes *.exe) 9615228692Sdes func_stripname '' '.exe' "$file" 9616228692Sdes file=$func_stripname_result 9617228692Sdes func_stripname '' '.exe' "$name" 9618228692Sdes noexename=$func_stripname_result 9619141098Sdes # $file with .exe has already been added to rmfiles, 9620141098Sdes # add $file without .exe 9621228692Sdes func_append rmfiles " $file" 9622141098Sdes ;; 9623141098Sdes esac 9624141098Sdes # Do a test to see if this is a libtool program. 9625228692Sdes if func_ltwrapper_p "$file"; then 9626228692Sdes if func_ltwrapper_executable_p "$file"; then 9627228692Sdes func_ltwrapper_scriptname "$file" 9628228692Sdes relink_command= 9629228692Sdes func_source $func_ltwrapper_scriptname_result 9630228692Sdes func_append rmfiles " $func_ltwrapper_scriptname_result" 9631228692Sdes else 9632228692Sdes relink_command= 9633228692Sdes func_source $dir/$noexename 9634228692Sdes fi 9635125647Sdes 9636141098Sdes # note $name still contains .exe if it was in $file originally 9637141098Sdes # as does the version of $file that was added into $rmfiles 9638228692Sdes func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9639141098Sdes if test "$fast_install" = yes && test -n "$relink_command"; then 9640228692Sdes func_append rmfiles " $odir/lt-$name" 9641141098Sdes fi 9642141098Sdes if test "X$noexename" != "X$name" ; then 9643228692Sdes func_append rmfiles " $odir/lt-${noexename}.c" 9644141098Sdes fi 9645125647Sdes fi 9646125647Sdes fi 9647117610Sdes ;; 9648117610Sdes esac 9649228692Sdes func_show_eval "$RM $rmfiles" 'exit_status=1' 9650117610Sdes done 9651125647Sdes 9652125647Sdes # Try to remove the ${objdir}s in the directories where we deleted files 9653125647Sdes for dir in $rmdirs; do 9654125647Sdes if test -d "$dir"; then 9655228692Sdes func_show_eval "rmdir $dir >/dev/null 2>&1" 9656125647Sdes fi 9657125647Sdes done 9658125647Sdes 9659125647Sdes exit $exit_status 9660228692Sdes} 9661117610Sdes 9662228692Sdes{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 9663228692Sdes func_mode_uninstall ${1+"$@"} 9664117610Sdes 9665228692Sdestest -z "$opt_mode" && { 9666228692Sdes help="$generic_help" 9667228692Sdes func_fatal_help "you must specify a MODE" 9668228692Sdes} 9669117610Sdes 9670228692Sdestest -z "$exec_cmd" && \ 9671228692Sdes func_fatal_help "invalid operation mode \`$opt_mode'" 9672228692Sdes 9673125647Sdesif test -n "$exec_cmd"; then 9674228692Sdes eval exec "$exec_cmd" 9675141098Sdes exit $EXIT_FAILURE 9676125647Sdesfi 9677125647Sdes 9678228692Sdesexit $exit_status 9679117610Sdes 9680117610Sdes 9681141098Sdes# The TAGs below are defined such that we never get into a situation 9682141098Sdes# in which we disable both kinds of libraries. Given conflicting 9683141098Sdes# choices, we go for a static library, that is the most portable, 9684141098Sdes# since we can't tell whether shared libraries were disabled because 9685141098Sdes# the user asked for that or because the platform doesn't support 9686141098Sdes# them. This is particularly important on AIX, because we don't 9687141098Sdes# support having both static and shared libraries enabled at the same 9688141098Sdes# time on that platform, so we default to a shared-only configuration. 9689141098Sdes# If a disable-shared tag is given, we'll fallback to a static-only 9690141098Sdes# configuration. But we'll never go from static-only to shared-only. 9691141098Sdes 9692141098Sdes# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 9693228692Sdesbuild_libtool_libs=no 9694228692Sdesbuild_old_libs=yes 9695141098Sdes# ### END LIBTOOL TAG CONFIG: disable-shared 9696141098Sdes 9697141098Sdes# ### BEGIN LIBTOOL TAG CONFIG: disable-static 9698228692Sdesbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9699141098Sdes# ### END LIBTOOL TAG CONFIG: disable-static 9700141098Sdes 9701117610Sdes# Local Variables: 9702117610Sdes# mode:shell-script 9703117610Sdes# sh-indentation:2 9704117610Sdes# End: 9705228692Sdes# vi:sw=2 9706228692Sdes 9707