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