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