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